Skip to content

Commit 63bc725

Browse files
Before refactoring smatrix on modeler data
1 parent 5533c59 commit 63bc725

File tree

12 files changed

+399
-351
lines changed

12 files changed

+399
-351
lines changed

tidy3d/plugins/smatrix/component_modelers/base.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@
1515
from tidy3d.constants import HERTZ
1616
from tidy3d.exceptions import SetupError, Tidy3dKeyError
1717
from tidy3d.log import log
18-
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
1918
from tidy3d.plugins.smatrix.ports.modal import Port
20-
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
2119
from tidy3d.plugins.smatrix.ports.wave import WavePort
2220

2321
# fwidth of gaussian pulse in units of central frequency
2422
FWIDTH_FRAC = 1.0 / 10
2523
DEFAULT_DATA_DIR = "."
2624

27-
LumpedPortType = Union[LumpedPort, CoaxialLumpedPort]
28-
TerminalPortType = Union[LumpedPortType, WavePort]
29-
3025

3126
class AbstractComponentModeler(ABC, Tidy3dBaseModel):
3227
"""Tool for modeling devices and computing port parameters."""
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
from typing import Union
4+
5+
from .modal import ComponentModeler
6+
from .terminal import TerminalComponentModeler
7+
8+
ComponentModelerType = Union[ComponentModeler, TerminalComponentModeler]

tidy3d/plugins/smatrix/data/terminal.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
from tidy3d.plugins.smatrix.component_modelers.base import TerminalPortType
1717
from tidy3d.plugins.smatrix.component_modelers.terminal import TerminalComponentModeler
1818
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
19+
from tidy3d.plugins.smatrix.utils import (
20+
ab_to_s,
21+
check_port_impedance_sign,
22+
compute_F,
23+
compute_port_VI,
24+
compute_power_delivered_by_port,
25+
compute_power_wave_amplitudes,
26+
s_to_z,
27+
)
1928

2029

2130
class MicrowavePortSimulationData(Tidy3dBaseModel):
@@ -78,9 +87,9 @@ class TerminalComponentModelerData(Tidy3dBaseModel):
7887
@cached_property
7988
def smatrix(self) -> MicrowaveSMatrixData:
8089
"Stores the computed S-matrix and reference impedances for the terminal ports"
81-
from tidy3d.plugins.smatrix.run.local_run import construct_smatrix
90+
from tidy3d.plugins.smatrix.run.terminal import terminal_construct_smatrix
8291

83-
terminal_port_data = construct_smatrix(simulation=self.simulation)
92+
terminal_port_data = terminal_construct_smatrix(simulation=self.simulation)
8493
smatrix_data = MicrowaveSMatrixData(data=terminal_port_data)
8594
return smatrix_data
8695

@@ -141,7 +150,7 @@ def get_antenna_metrics_data(
141150
Container with antenna parameters including directivity, gain, and radiation efficiency,
142151
computed from the superposition of fields from all excited ports.
143152
"""
144-
from tidy3d.plugins.smatrix.run.local_run import compute_power_wave_amplitudes_at_each_port
153+
from tidy3d.plugins.smatrix.run.terminal import compute_power_wave_amplitudes_at_each_port
145154

146155
# Use the first port as default if none specified
147156
if port_amplitudes is None:
@@ -210,14 +219,14 @@ def get_antenna_metrics_data(
210219
@cached_property
211220
def port_reference_impedances(self) -> PortDataArray:
212221
"""The reference impedance used at each port for definining power wave amplitudes."""
213-
from tidy3d.plugins.smatrix.run.local_run import port_reference_impedances
222+
from tidy3d.plugins.smatrix.run.terminal import port_reference_impedances
214223

215224
return port_reference_impedances(self.simulation)
216225

217226
def compute_power_wave_amplitudes_at_each_port(
218227
self, port_reference_impedances: PortDataArray, sim_data: SimulationData
219228
) -> tuple[PortDataArray, PortDataArray]:
220-
from tidy3d.plugins.smatrix.run.local_run import compute_power_wave_amplitudes_at_each_port
229+
from tidy3d.plugins.smatrix.run.terminal import compute_power_wave_amplitudes_at_each_port
221230

222231
data = compute_power_wave_amplitudes_at_each_port(
223232
simulation=self.simulation,
@@ -228,3 +237,10 @@ def compute_power_wave_amplitudes_at_each_port(
228237

229238
# Mirror Utils
230239
# So they can be reused elsewhere without a class reimport
240+
ab_to_s = ab_to_s
241+
compute_F = compute_F
242+
check_port_impedance_sign = check_port_impedance_sign
243+
compute_port_VI = compute_port_VI
244+
compute_power_wave_amplitudes = compute_power_wave_amplitudes
245+
compute_power_delivered_by_port = compute_power_delivered_by_port
246+
s_to_z = s_to_z

tidy3d/plugins/smatrix/data/types.py

Whitespace-only changes.

tidy3d/plugins/smatrix/ports/types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
4+
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
5+
from tidy3d.plugins.smatrix.ports.wave import WavePort
6+
7+
LumpedPortType = Union[LumpedPort, CoaxialLumpedPort]
8+
TerminalPortType = Union[LumpedPortType, WavePort]

tidy3d/plugins/smatrix/run/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from __future__ import annotations
2+
3+
from ..component_modelers.types import ComponentModelerType
4+
5+
6+
def run_batch(
7+
modeler: ComponentModelerType, path_dir: str = DEFAULT_DATA_DIR, **kwargs
8+
) -> BatchData:
9+
batch = Batch(simulations=modeler.sim_dict, **kwargs)
10+
11+
return batch.run(path_dir=path_dir)

tidy3d/plugins/smatrix/run/local_run.py

Lines changed: 0 additions & 188 deletions
This file was deleted.

0 commit comments

Comments
 (0)