Skip to content

Commit 48a433b

Browse files
Add test for gap refinement improvement
1 parent 3d73d77 commit 48a433b

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/test_components/test_layerrefinement.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,3 +801,72 @@ def test_gap_meshing():
801801
# sim.plot(x=0, ax=ax)
802802
# sim.plot_grid(x=0, ax=ax)
803803
# plt.show()
804+
805+
806+
def test_gap_meshing_skip_small_gap():
807+
"""When the gap is very small, make sure it's skipped."""
808+
809+
f0 = 7e9
810+
811+
mm = 1000 # Conversion mm to micron
812+
H = 0.8 * mm # Substrate thickness
813+
T = 0.035 * mm # Metal thickness
814+
815+
# Resonator dimensions
816+
MA, MB, MC, MD = (3.9 * mm, 7.1 * mm, 3.1 * mm, 2.3 * mm)
817+
ME, MF, MG, MH = (0.6 * mm, 0.2 * mm, 1.2 * mm, 0.5 * mm)
818+
MJ, MK, MM, MN = (4.8 * mm, 0.3 * mm, 0.1 * mm, 0.7 * mm)
819+
MP, MQ, MR, MS = (0.1 * mm, 0.7 * mm, 0.4 * mm, 0.3 * mm)
820+
Lsub, Wsub = (2 * MC + MH, 2 * (MH + MK + MB))
821+
822+
geom_patch = td.Box.from_bounds(
823+
rmin=(-MA / 2, MH / 2 + MK, 0), rmax=(MA / 2, MH / 2 + MK + MB, T)
824+
)
825+
geom_hole1 = td.Box.from_bounds(
826+
rmin=(-MH / 2 - MN - MF - ME, MH / 2 + MK + MS, 0),
827+
rmax=(-MH / 2 - MN - MF, MH / 2 + MK + MS + MG, T),
828+
)
829+
geom_hole5 = td.Box.from_bounds(
830+
rmin=(-MA / 2 + 1.5 * MF, MH / 2 + MK + MS + MG + MQ, 0),
831+
rmax=(-MA / 2 + 1.5 * MF + MM, MH / 2 + MK + MB - MP, T),
832+
)
833+
geom_hole6 = geom_hole5.translated(-2 * geom_hole5.center[0], 0, 0)
834+
geom_hole7 = td.Box.from_bounds(
835+
rmin=(-MH / 2 - MN, MH / 2 + MK, 0), rmax=(MH / 2 + MN, MH / 2 + MD, T)
836+
)
837+
for hole in [geom_hole1, geom_hole5, geom_hole6, geom_hole7]:
838+
geom_patch -= hole
839+
840+
x0, y0, z0 = geom_patch.bounding_box.center
841+
struct_patch = td.Structure(geometry=geom_patch, medium=td.PEC)
842+
843+
# Add padding
844+
padding = td.C_0 / f0 / 2
845+
sim_LX = Lsub + padding
846+
sim_LY = Wsub + padding
847+
sim_LZ = H + padding
848+
849+
# Layer refinement on resonator
850+
lr_spec = td.LayerRefinementSpec.from_structures(
851+
structures=[struct_patch],
852+
min_steps_along_axis=1,
853+
corner_refinement=td.GridRefinement(dl=T, num_cells=2),
854+
dl_min_from_gap_width=True,
855+
)
856+
857+
# Define overall grid spec
858+
grid_spec = td.GridSpec.auto(
859+
wavelength=td.C_0 / f0,
860+
min_steps_per_wvl=12,
861+
layer_refinement_specs=[lr_spec],
862+
)
863+
864+
# Define simulation object
865+
sim = td.Simulation(
866+
center=(x0, y0, z0),
867+
size=(sim_LX, sim_LY, sim_LZ),
868+
structures=[struct_patch],
869+
grid_spec=grid_spec,
870+
run_time=1e-9,
871+
)
872+
assert sim.grid_info["min_grid_size"] > 20

0 commit comments

Comments
 (0)