Skip to content

Commit 72690e9

Browse files
committed
update naming
1 parent 1f1e440 commit 72690e9

File tree

5 files changed

+24
-29
lines changed

5 files changed

+24
-29
lines changed

tests/test_components/test_microwave.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ def make_mw_sim(
202202
)
203203
size_port = [0, sim_width, size_sim[2]]
204204
center_port = [0, 0, center_sim[2]]
205-
impedance_spec = (td.AutoImpedanceSpec(),) * 4
205+
impedance_specs = (td.AutoImpedanceSpec(),) * 4
206206
mode_spec = td.ModeSpec(
207207
num_modes=4,
208208
target_neff=1.8,
209-
microwave_mode_spec=td.MicrowaveModeSpec(impedance_spec=impedance_spec),
209+
microwave_mode_spec=td.MicrowaveModeSpec(impedance_specs=impedance_specs),
210210
)
211211

212212
mode_monitor = td.ModeMonitor(
@@ -476,7 +476,7 @@ def test_impedance_spec_validation():
476476
with pytest.raises(pd.ValidationError):
477477
_ = td.CustomImpedanceSpec(voltage_spec=None, current_spec=None)
478478

479-
_ = td.MicrowaveModeSpec(impedance_spec=(both, voltage_only, current_only, None))
479+
_ = td.MicrowaveModeSpec(impedance_specs=(both, voltage_only, current_only, None))
480480

481481

482482
def test_path_integral_factory_voltage_validation():
@@ -565,7 +565,7 @@ def test_make_path_integrals_validation():
565565
voltage_spec=v_spec,
566566
current_spec=i_spec,
567567
)
568-
microwave_mode_spec = td.MicrowaveModeSpec(impedance_spec=(impedance_spec,))
568+
microwave_mode_spec = td.MicrowaveModeSpec(impedance_specs=(impedance_spec,))
569569

570570
# Test successful creation
571571
voltage_integrals, current_integrals = make_path_integrals(microwave_mode_spec, mode_monitor)
@@ -576,7 +576,7 @@ def test_make_path_integrals_validation():
576576

577577
# Test with None specs - when both are None, use_automatic_setup is True
578578
# This means current integrals will be auto-generated, not None
579-
microwave_mode_spec_none = td.MicrowaveModeSpec(impedance_spec=(None,))
579+
microwave_mode_spec_none = td.MicrowaveModeSpec(impedance_specs=(None,))
580580
voltage_integrals, current_integrals = make_path_integrals(
581581
microwave_mode_spec_none, mode_monitor
582582
)
@@ -596,7 +596,7 @@ def test_make_path_integrals_construction_errors(monkeypatch):
596596
v_spec = td.VoltageIntegralAxisAlignedSpec(center=(1, 2, 3), size=(0, 0, 1), sign="-")
597597

598598
impedance_spec = td.CustomImpedanceSpec(voltage_spec=v_spec, current_spec=None)
599-
microwave_mode_spec = td.MicrowaveModeSpec(impedance_spec=(impedance_spec,))
599+
microwave_mode_spec = td.MicrowaveModeSpec(impedance_specs=(impedance_spec,))
600600

601601
# Mock make_voltage_integral to raise an exception
602602
def mock_make_voltage_integral(path_spec):
@@ -663,7 +663,7 @@ def test_path_integral_factory_mixed_specs():
663663
impedance_spec1 = td.CustomImpedanceSpec(voltage_spec=v_spec, current_spec=None)
664664
impedance_spec2 = td.CustomImpedanceSpec(voltage_spec=None, current_spec=i_spec)
665665
microwave_mode_spec = td.MicrowaveModeSpec(
666-
impedance_spec=(
666+
impedance_specs=(
667667
impedance_spec1,
668668
impedance_spec2,
669669
)
@@ -685,14 +685,6 @@ def test_mode_solver_with_microwave_mode_spec():
685685
height = 0.5 * mm
686686
metal_thickness = 0.1 * mm
687687

688-
def analytical_stripline_impedance(er, width, height, thickness):
689-
assert width > 0.35 * height
690-
term1 = 1 - thickness / height
691-
Cf = 2 / np.pi * np.log(1 / term1 + 1)
692-
if thickness > 0:
693-
Cf -= thickness / np.pi / height * np.log(1 / term1**2 - 1)
694-
return 30 * np.pi / np.sqrt(er) * (term1) / (width / height + Cf)
695-
696688
stripline_sim = make_mw_sim(
697689
transmission_line_type="stripline",
698690
width=width,
@@ -704,11 +696,11 @@ def analytical_stripline_impedance(er, width, height, thickness):
704696

705697
plane = td.Box(center=(0, 0, 0), size=(0, 10 * width, 2 * height + metal_thickness))
706698
num_modes = 3
707-
impedance_spec = (td.AutoImpedanceSpec(), None, None)
699+
impedance_specs = (td.AutoImpedanceSpec(), None, None)
708700
mode_spec = td.ModeSpec(
709701
num_modes=num_modes,
710702
target_neff=2.2,
711-
microwave_mode_spec=td.MicrowaveModeSpec(impedance_spec=impedance_spec),
703+
microwave_mode_spec=td.MicrowaveModeSpec(impedance_specs=impedance_specs),
712704
)
713705
mms = ModeSolver(
714706
simulation=stripline_sim,
@@ -735,8 +727,8 @@ def analytical_stripline_impedance(er, width, height, thickness):
735727
size=(0, width + dl, metal_thickness + dl), sign="+"
736728
),
737729
)
738-
impedance_spec = (custom_spec, None, None)
739-
mms = mms.updated_copy(path="mode_spec/microwave_mode_spec/", impedance_spec=impedance_spec)
730+
impedance_specs = (custom_spec, None, None)
731+
mms = mms.updated_copy(path="mode_spec/microwave_mode_spec/", impedance_specs=impedance_specs)
740732
mms_data: ModeSolverData = mms.data
741733

742734
# _, ax = plt.subplots(1, 1, tight_layout=True, figsize=(15, 15))

tests/test_components/test_mode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def test_plane_crosses_symmetry_plane_warning(monkeypatch):
391391
def test_mode_spec_with_microwave_mode_spec():
392392
"""Test that the number of impedance specs is validated against the number of modes."""
393393

394-
impedance_spec = (td.AutoImpedanceSpec(),)
395-
mw_mode_spec = td.MicrowaveModeSpec(impedance_spec=impedance_spec)
394+
impedance_specs = (td.AutoImpedanceSpec(),)
395+
mw_mode_spec = td.MicrowaveModeSpec(impedance_specs=impedance_specs)
396396
with pytest.raises(pydantic.ValidationError):
397397
td.ModeSpec(num_modes=2, microwave_mode_spec=mw_mode_spec)

tidy3d/components/microwave/microwave_mode_spec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ class MicrowaveModeSpec(Tidy3dBaseModel):
2121
compute voltage, current, and characteristic impedance of the transmission line.
2222
"""
2323

24-
impedance_spec: tuple[Optional[annotate_type(ImpedanceSpecTypes)], ...] = pd.Field(
24+
impedance_specs: tuple[Optional[annotate_type(ImpedanceSpecTypes)], ...] = pd.Field(
2525
...,
26-
title="Impedance Specification",
26+
title="Impedance Specifications",
2727
description="Field controls how the impedance is calculated for each mode calculated by the mode solver.",
2828
)
2929

3030
@cached_property
3131
def _using_auto_current_spec(self) -> bool:
3232
"""Checks whether at least one of the modes will require an auto setup of the current path specification."""
3333
return any(
34-
isinstance(impedance_spec, AutoImpedanceSpec) for impedance_spec in self.impedance_spec
34+
isinstance(impedance_spec, AutoImpedanceSpec) for impedance_spec in self.impedance_specs
3535
)
3636

3737
@cached_property
3838
def num_impedance_specs(self) -> int:
3939
"""The number of impedance specifications to be used."""
40-
return len(self.impedance_spec)
40+
return len(self.impedance_specs)

tidy3d/components/microwave/path_integrals/path_integral_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def make_path_integrals(
112112

113113
v_integrals = []
114114
i_integrals = []
115-
for idx, impedance_spec in enumerate(microwave_mode_spec.impedance_spec):
115+
for idx, impedance_spec in enumerate(microwave_mode_spec.impedance_specs):
116116
if impedance_spec is None:
117117
# Do not calculate impedance for this mode
118118
v_integrals.append(None)

tidy3d/components/mode/mode_solver.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,19 +1370,22 @@ def _filter_polarization(self, mode_solver_data: ModeSolverData):
13701370
]:
13711371
data.values[..., ifreq, :] = data.values[..., ifreq, sort_inds]
13721372

1373-
def _get_path_integrals(
1373+
def _make_path_integrals(
13741374
self,
13751375
) -> tuple[tuple[Optional[VoltageIntegralTypes]], tuple[Optional[CurrentIntegralTypes]]]:
1376+
"""Wrapper for making path integrals from the MicrowaveModeSpec. Note: overriden in the backend to support
1377+
auto creation of path integrals."""
13761378
return make_path_integrals(
13771379
self.mode_spec.microwave_mode_spec,
13781380
self.to_monitor(name=MODE_MONITOR_NAME),
13791381
)
13801382

13811383
def _add_microwave_data(self, mode_solver_data: ModeSolverData) -> ModeSolverData:
1382-
"""Calculate and add microwave data to ``mode_solver_data`` which uses the path specifications."""
1384+
"""Calculate and add microwave data to ``mode_solver_data`` which uses the path specifications.
1385+
Note: this modifies ``mode_solver_data`` in-place."""
13831386
if self.mode_spec.microwave_mode_spec is None:
13841387
return mode_solver_data
1385-
voltage_integrals, current_integrals = self._get_path_integrals()
1388+
voltage_integrals, current_integrals = self._make_path_integrals()
13861389
# Need to operate on the full symmetry expanded fields
13871390
mode_solver_data_expanded = mode_solver_data.symmetry_expanded_copy
13881391
Z0_list = []

0 commit comments

Comments
 (0)