plane_wave = td.PlaneWave(
source_time=td.GaussianPulse(freq0=f0, fwidth=fwidth),
center=(0, 0, z_src),
size=(td.inf, td.inf, 0),
direction="-",
pol_angle=0,
)
dipole = td.PointDipole(
center=(0, 0, z_wse2), source_time=plane_wave.source_time, polarization="Ex"
)
# FOM point monitor.
mnt_point = td.FieldMonitor(
center=(0, 0, z_wse2),
size=(0, 0, 0),
freqs=[f_target],
name="field",
fields=["Ex"],
)
field_monitors = [
td.FieldMonitor(center=(0, 0, z_surface), size=size, freqs=freqs, name=name)
for name, size in [
("field_xy", (td.inf, td.inf, 0)),
("field_xz", (td.inf, 0, td.inf)),
("field_yz", (0, td.inf, td.inf)),
]
]
flux_up = td.FluxMonitor(
center=(0, 0, z_flux_up),
size=(td.inf, td.inf, 0),
freqs=freqs,
name="flux_up",
normal_dir="+",
)
flux_down = flux_up.updated_copy(
center=(0, 0, z_flux_down), normal_dir="-", name="flux_down"
)
# Net flux P_inj - R. The injected power P_inj = flux_net + flux_up is not exactly 1 W.
flux_net = flux_up.updated_copy(
center=(0, 0, z_flux_net), normal_dir="-", name="flux_net"
)
angle_mnt = td.FieldProjectionAngleMonitor(
center=plane_wave.center,
size=plane_wave.size,
name="angle",
normal_dir="+",
freqs=[f_target],
custom_origin=(0, 0, z_wse2),
proj_distance=wvl_target * 10000,
theta=np.linspace(0, 90, 91) * np.pi / 180,
phi=np.linspace(0, 360, 721) * np.pi / 180,
)
def gridspec_with_refinement(min_steps_per_wvl=20, min_steps_along_axis=3):
return td.GridSpec(
grid_x=td.UniformGrid(dl=PIXEL_SIZE),
grid_y=td.UniformGrid(dl=PIXEL_SIZE),
grid_z=td.AutoGrid(min_steps_per_wvl=min_steps_per_wvl),
wavelength=wvls.min(),
snapping_points=[
(0, 0, z) for z in (z_src, z_flux_up, z_flux_down, z_flux_net, z_wse2)
],
layer_refinement_specs=[
td.LayerRefinementSpec.from_structures(
structures=[layer_hbn],
axis=2,
min_steps_along_axis=min_steps_along_axis,
)
],
)
sim_base = td.Simulation(
size=(P, P, z_max - z_min),
center=(0, 0, (z_max + z_min) / 2),
grid_spec=gridspec_with_refinement(),
structures=base_structures,
sources=[plane_wave],
monitors=[*field_monitors, mnt_point, flux_up, flux_down],
run_time=td.RunTimeSpec(quality_factor=20, source_factor=200),
shutoff=1e-6,
boundary_spec=td.BoundarySpec(
x=td.Boundary.periodic(), y=td.Boundary.periodic(), z=td.Boundary.pml()
),
# x-polarized normal incidence.
symmetry=(-1, 1, 0),
)
# Stack and grid at x = 0: close-up, then a wider view.
for xlim, ylim in [((-0.02, 0.02), (0.09, 0.125)), ((0, 0.2), (0.05, 0.35))]:
fig, ax = plt.subplots()
sim_base.plot(x=0, ax=ax)
sim_base.plot_grid(x=0, ax=ax)
ax.set(xlim=xlim, ylim=ylim)
sim_base.plot_3d()