Skip to content

Commit bbd9207

Browse files
authored
Merge pull request #676 from jonbenfri/workflow-3-cascaded-mzi-bugfixes
Update tidy3d API calls for web and ``ModalComponentModeler``
2 parents 1fd61bf + ed49653 commit bbd9207

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

gplugins/tidy3d/component.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import matplotlib.pyplot as plt
2424
import numpy as np
2525
import tidy3d as td
26+
import tidy3d.web as web
2627
from gdsfactory.component import Component
2728
from gdsfactory.pdk import get_layer_stack
2829
from gdsfactory.technology import LayerStack
@@ -227,7 +228,7 @@ def get_component_modeler(
227228
run_only: tuple[tuple[str, int], ...] | None = None,
228229
element_mappings: Tidy3DElementMapping = (),
229230
extra_monitors: tuple[Any, ...] | None = None,
230-
mode_spec: td.ModeSpec = td.ModeSpec(num_modes=1, filter_pol="te"),
231+
mode_spec: td.ModeSpec = td.ModeSpec(num_modes=1),
231232
boundary_spec: td.BoundarySpec = td.BoundarySpec.all_sides(boundary=td.PML()),
232233
run_time: float = 10e-12,
233234
shutoff: float = 1e-5,
@@ -251,7 +252,7 @@ def get_component_modeler(
251252
run_only: The run only specification for the ComponentModeler. Defaults to None.
252253
element_mappings: The element mappings for the ComponentModeler. Defaults to ().
253254
extra_monitors: The extra monitors for the ComponentModeler. Defaults to None.
254-
mode_spec: The mode specification for the ComponentModeler. Defaults to td.ModeSpec(num_modes=1, filter_pol="te").
255+
mode_spec: The mode specification for the ComponentModeler. Defaults to td.ModeSpec(num_modes=1).
255256
boundary_spec: The boundary specification for the ComponentModeler. Defaults to td.BoundarySpec.all_sides(boundary=td.PML()).
256257
run_time: The run time for the ComponentModeler.
257258
shutoff: The shutoff value for the ComponentModeler. Defaults to 1e-5.
@@ -308,9 +309,6 @@ def get_component_modeler(
308309
freqs=tuple(freqs),
309310
element_mappings=element_mappings,
310311
run_only=run_only,
311-
folder_name=folder_name,
312-
path_dir=path_dir,
313-
verbose=verbose,
314312
)
315313

316314
@td.components.viz.add_ax_if_none
@@ -428,7 +426,7 @@ def write_sparameters(
428426
run_only: tuple[tuple[str, int], ...] | None = None,
429427
element_mappings: Tidy3DElementMapping = (),
430428
extra_monitors: tuple[Any, ...] | None = None,
431-
mode_spec: td.ModeSpec = td.ModeSpec(num_modes=1, filter_pol="te"),
429+
mode_spec: td.ModeSpec = td.ModeSpec(num_modes=1),
432430
boundary_spec: td.BoundarySpec = td.BoundarySpec.all_sides(boundary=td.PML()),
433431
symmetry: tuple[Symmetry, Symmetry, Symmetry] = (0, 0, 0),
434432
run_time: float = 1e-12,
@@ -471,7 +469,7 @@ def write_sparameters(
471469
run_only: The run only specification for the ComponentModeler. Defaults to None.
472470
element_mappings: The element mappings for the ComponentModeler. Defaults to ().
473471
extra_monitors: The extra monitors for the ComponentModeler. Defaults to None.
474-
mode_spec: The mode specification for the ComponentModeler. Defaults to td.ModeSpec(num_modes=1, filter_pol="te").
472+
mode_spec: The mode specification for the ComponentModeler. Defaults to td.ModeSpec(num_modes=1).
475473
boundary_spec: The boundary specification for the ComponentModeler.
476474
Defaults to td.BoundarySpec.all_sides(boundary=td.PML()).
477475
symmetry (tuple[Symmetry, Symmetry, Symmetry], optional): The symmetry for the simulation. Defaults to (0,0,0).
@@ -522,14 +520,12 @@ def write_sparameters(
522520
boundary_spec=boundary_spec,
523521
run_time=run_time,
524522
shutoff=shutoff,
525-
folder_name=folder_name,
526-
verbose=verbose,
527523
symmetry=symmetry,
528524
**kwargs,
529525
)
530526

531527
path_dir = pathlib.Path(dirpath) / modeler._hash_self()
532-
modeler = modeler.updated_copy(path_dir=str(path_dir))
528+
modeler = modeler.updated_copy()
533529

534530
sp = {}
535531

@@ -591,7 +587,8 @@ def write_sparameters(
591587
return dict(np.load(filepath))
592588
else:
593589
time.sleep(0.2)
594-
s = modeler.run()
590+
modeler_data = web.run(modeler, verbose=verbose, path=dirpath / "simulation.hdf5")
591+
s = modeler_data.smatrix()
595592
for port_in in s.port_in.values:
596593
for port_out in s.port_out.values:
597594
for mode_index_in in s.mode_index_in.values:
@@ -645,7 +642,7 @@ def write_sparameters_batch(
645642
run_only: The run only specification for the ComponentModeler. Defaults to None.
646643
element_mappings: The element mappings for the ComponentModeler. Defaults to ().
647644
extra_monitors: The extra monitors for the ComponentModeler. Defaults to None.
648-
mode_spec: The mode specification for the ComponentModeler. Defaults to td.ModeSpec(num_modes=1, filter_pol="te").
645+
mode_spec: The mode specification for the ComponentModeler. Defaults to td.ModeSpec(num_modes=1).
649646
boundary_spec: The boundary specification for the ComponentModeler.
650647
Defaults to td.BoundarySpec.all_sides(boundary=td.PML()).
651648
symmetry (tuple[Symmetry, Symmetry, Symmetry], optional): The symmetry for the simulation. Defaults to (0,0,0).

0 commit comments

Comments
 (0)