(args)
| 5 | |
| 6 | |
| 7 | def main(args): |
| 8 | resolution = args.res |
| 9 | |
| 10 | dpml = 1.0 # PML thickness |
| 11 | sz = 10 + 2 * dpml # size of computational cell (without PMLs) |
| 12 | cell_size = mp.Vector3(0, 0, sz) |
| 13 | pml_layers = [mp.PML(dpml)] |
| 14 | |
| 15 | wvl_min = 0.4 # min wavelength |
| 16 | wvl_max = 0.8 # max wavelength |
| 17 | fmin = 1 / wvl_max # min frequency |
| 18 | fmax = 1 / wvl_min # max frequency |
| 19 | fcen = 0.5 * (fmin + fmax) # center frequency |
| 20 | df = fmax - fmin # frequency width |
| 21 | nfreq = 50 # number of frequency bins |
| 22 | |
| 23 | # rotation angle (in degrees) of source: CCW around Y axis, 0 degrees along +Z axis |
| 24 | theta_r = math.radians(args.theta) |
| 25 | |
| 26 | # plane of incidence is XZ |
| 27 | k = mp.Vector3(math.sin(theta_r), 0, math.cos(theta_r)).scale(fmin) |
| 28 | |
| 29 | # if normal incidence, force number of dimensions to be 1 |
| 30 | dimensions = 1 if theta_r == 0 else 3 |
| 31 | sources = [ |
| 32 | mp.Source( |
| 33 | mp.GaussianSource(fcen, fwidth=df), |
| 34 | component=mp.Ex, |
| 35 | center=mp.Vector3(0, 0, -0.5 * sz + dpml), |
| 36 | ) |
| 37 | ] |
| 38 | |
| 39 | sim = mp.Simulation( |
| 40 | cell_size=cell_size, |
| 41 | boundary_layers=pml_layers, |
| 42 | sources=sources, |
| 43 | k_point=k, |
| 44 | dimensions=dimensions, |
| 45 | resolution=resolution, |
| 46 | ) |
| 47 | |
| 48 | refl_fr = mp.FluxRegion(center=mp.Vector3(0, 0, -0.25 * sz)) |
| 49 | refl = sim.add_flux(fcen, df, nfreq, refl_fr) |
| 50 | |
| 51 | sim.run( |
| 52 | until_after_sources=mp.stop_when_fields_decayed( |
| 53 | 50, mp.Ex, mp.Vector3(0, 0, -0.5 * sz + dpml), 1e-9 |
| 54 | ) |
| 55 | ) |
| 56 | |
| 57 | empty_flux = mp.get_fluxes(refl) |
| 58 | empty_data = sim.get_flux_data(refl) |
| 59 | sim.reset_meep() |
| 60 | |
| 61 | # add a block with n=3.5 for the air-dielectric interface |
| 62 | geometry = [ |
| 63 | mp.Block( |
| 64 | size=mp.Vector3(mp.inf, mp.inf, 0.5 * sz), |
no test coverage detected