Skip to content

Commit

Permalink
Merge pull request #486 from gdsfactory/fix_lumerical_fdtd
Browse files Browse the repository at this point in the history
Fix lumerical fdtd
  • Loading branch information
joamatab authored Nov 15, 2024
2 parents c5849b0 + 8d1d787 commit 69c6459
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
3 changes: 3 additions & 0 deletions gplugins/gmeep/get_meep_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ def get_meep_geometry_from_component(
layer_to_polygons = component_with_booleans.get_polygons_points()

ordered_layer_stack_keys = order_layer_stack(layer_stack)[::-1]

for layername in ordered_layer_stack_keys:
layer = layer_stack.layers[layername].layer

if layer not in layer_to_polygons:
continue
polygons = layer_to_polygons[layer]
print(f"layer: {layer}, polygons: {polygons}")

if layer in layer_to_thickness and layer in layer_to_material:
height = layer_to_thickness[layer] if is_3d else mp.inf
zmin_um = layer_to_zmin[layer] if is_3d else 0
Expand Down
24 changes: 11 additions & 13 deletions gplugins/lumerical/write_sparameters_lumerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ def write_sparameters_lumerical(
component_extended_beyond_pml = gf.components.extension.extend_ports(
component=component_extended, length=ss.port_extension
)
component_extended_beyond_pml.name = "top"
gdspath = component_extended_beyond_pml.write_gds()

filepath_npz = get_sparameters_path(
Expand Down Expand Up @@ -270,17 +269,17 @@ def write_sparameters_lumerical(

layers_thickness = [
layer_to_thickness[layer]
for layer in component_with_booleans.get_layers()
for layer in component_with_booleans.layers
if layer in layer_to_thickness
]
if not layers_thickness:
raise ValueError(
f"no layers for component {component.get_layers()}"
f"no layers for component {component.layers}"
f"in layer stack {layer_stack}"
)
layers_zmin = [
layer_to_zmin[layer]
for layer in component_with_booleans.get_layers()
for layer in component_with_booleans.layers
if layer in layer_to_zmin
]
component_thickness = max(layers_thickness)
Expand Down Expand Up @@ -357,7 +356,7 @@ def write_sparameters_lumerical(
simulation_time=ss.simulation_time,
simulation_temperature=ss.simulation_temperature,
)
component_layers = component_with_booleans.get_layers()
component_layers = component_with_booleans.layers

for layer, thickness in layer_to_thickness.items():
if layer not in component_layers:
Expand Down Expand Up @@ -410,21 +409,21 @@ def write_sparameters_lumerical(
direction = "Backward"
injection_axis = "x-axis"
dxp = 0
dyp = 2 * ss.port_margin + port.width
dyp = 2 * ss.port_margin + port.dwidth
elif 45 < deg < 90 + 45:
direction = "Backward"
injection_axis = "y-axis"
dxp = 2 * ss.port_margin + port.width
dxp = 2 * ss.port_margin + port.dwidth
dyp = 0
elif 90 + 45 < deg < 180 + 45:
direction = "Forward"
injection_axis = "x-axis"
dxp = 0
dyp = 2 * ss.port_margin + port.width
dyp = 2 * ss.port_margin + port.dwidth
elif 180 + 45 < deg < 180 + 45 + 90:
direction = "Forward"
injection_axis = "y-axis"
dxp = 2 * ss.port_margin + port.width
dxp = 2 * ss.port_margin + port.dwidth
dyp = 0

else:
Expand Down Expand Up @@ -545,9 +544,8 @@ def _sample_convergence_wavelength():


if __name__ == "__main__":
import lumapi

s = lumapi.FDTD()
# import lumapi
# s = lumapi.FDTD()

# component = gf.components.straight(length=2.5)
component = gf.components.mmi1x2()
Expand All @@ -557,7 +555,7 @@ def _sample_convergence_wavelength():
component=component,
material_name_to_lumerical=material_name_to_lumerical,
run=False,
session=s,
# session=s,
)
# c = gf.components.coupler_ring(length_x=3)
# c = gf.components.mmi1x2()
Expand Down

0 comments on commit 69c6459

Please sign in to comment.