Skip to content

Commit 9e89977

Browse files
Further refactor
1 parent 912464d commit 9e89977

File tree

9 files changed

+28
-37
lines changed

9 files changed

+28
-37
lines changed

tidy3d/plugins/smatrix/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import warnings
66

77
from tidy3d.plugins.smatrix.data.data import ComponentModelerData, TerminalComponentModelerData
8-
from .component_modelers.modal import AbstractComponentModeler, ComponentModeler
9-
from .component_modelers.terminal import TerminalComponentModeler
10-
from .data.data_array import PortDataArray, TerminalPortDataArray
11-
from tidy3d.plugins.smatrix.data.data import TerminalComponentModelerData, ComponentModelerData
12-
from .ports.coaxial_lumped import CoaxialLumpedPort
13-
from .ports.modal import ModalPortDataArray, Port
14-
from .ports.rectangular_lumped import LumpedPort
15-
from .ports.wave import WavePort
8+
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
9+
from tidy3d.plugins.smatrix.modelers.modal import AbstractComponentModeler, ComponentModeler
10+
from tidy3d.plugins.smatrix.modelers.terminal import TerminalComponentModeler
11+
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
12+
from tidy3d.plugins.smatrix.ports.modal import ModalPortDataArray, Port
13+
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
14+
from tidy3d.plugins.smatrix.ports.wave import WavePort
1615

1716
# Instantiate on plugin import till we unite with toplevel
1817
warnings.filterwarnings(
@@ -26,13 +25,14 @@
2625
"AbstractComponentModeler",
2726
"CoaxialLumpedPort",
2827
"ComponentModeler",
29-
"ComponentModelerData"
28+
"ComponentModelerData",
29+
"ComponentModelerDataLumpedPort",
3030
"LumpedPort",
3131
"ModalPortDataArray",
3232
"Port",
3333
"PortDataArray",
3434
"TerminalComponentModeler",
35-
"TerminalComponentModelerData"
35+
"TerminalComponentModelerData",
3636
"TerminalPortDataArray",
3737
"WavePort",
3838
]

tidy3d/plugins/smatrix/data/data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from tidy3d.components.data.sim_data import SimulationData
1414
from tidy3d.components.microwave.data.monitor_data import AntennaMetricsData
1515
from tidy3d.log import log
16-
from tidy3d.plugins.smatrix.component_modelers.base import TerminalPortType
17-
from tidy3d.plugins.smatrix.component_modelers.terminal import TerminalComponentModeler
1816
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
17+
from tidy3d.plugins.smatrix.modelers.base import TerminalPortType
18+
from tidy3d.plugins.smatrix.modelers.terminal import TerminalComponentModeler
1919

2020

2121
class MicrowavePortSimulationData(Tidy3dBaseModel):
@@ -46,6 +46,7 @@ class MicrowaveSMatrixData(Tidy3dBaseModel):
4646
"by terminal ports, representing the scattering parameters between them.",
4747
)
4848

49+
4950
class ComponentModelerData(Tidy3dBaseModel):
5051
pass
5152

tidy3d/plugins/smatrix/local_run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import numpy as np
88

99
from tidy3d.components.data.sim_data import SimulationData
10-
from tidy3d.plugins.smatrix.component_modelers.base import (
11-
DEFAULT_DATA_DIR,
12-
)
13-
from tidy3d.plugins.smatrix.component_modelers.terminal import TerminalComponentModeler
1410
from tidy3d.plugins.smatrix.data.data import (
1511
MicrowavePortSimulationData,
1612
TerminalComponentModelerData,
1713
)
1814
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
15+
from tidy3d.plugins.smatrix.modelers.base import (
16+
DEFAULT_DATA_DIR,
17+
)
18+
from tidy3d.plugins.smatrix.modelers.terminal import TerminalComponentModeler
1919
from tidy3d.plugins.smatrix.ports.wave import WavePort
2020
from tidy3d.plugins.smatrix.utils import check_port_impedance_sign, compute_F, compute_port_VI
2121
from tidy3d.web import BatchData

tidy3d/plugins/smatrix/component_modelers/base.py renamed to tidy3d/plugins/smatrix/modelers/base.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,23 @@
22

33
from __future__ import annotations
44

5-
import os
6-
from abc import ABC, abstractmethod
5+
from abc import ABC
76
from typing import Optional, Union, get_args
87

98
import numpy as np
109
import pydantic.v1 as pd
1110

12-
from tidy3d.components.base import Tidy3dBaseModel, cached_property
11+
from tidy3d.components.base import Tidy3dBaseModel
1312
from tidy3d.components.data.data_array import DataArray
14-
from tidy3d.components.data.sim_data import SimulationData
1513
from tidy3d.components.simulation import Simulation
1614
from tidy3d.components.types import FreqArray
17-
from tidy3d.config import config
1815
from tidy3d.constants import HERTZ
1916
from tidy3d.exceptions import SetupError, Tidy3dKeyError
2017
from tidy3d.log import log
2118
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
2219
from tidy3d.plugins.smatrix.ports.modal import Port
2320
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
2421
from tidy3d.plugins.smatrix.ports.wave import WavePort
25-
from tidy3d.web import Batch, BatchData
2622

2723
# fwidth of gaussian pulse in units of central frequency
2824
FWIDTH_FRAC = 1.0 / 10
@@ -162,4 +158,5 @@ def _shift_value_signed(self, port: Union[Port, WavePort]) -> float:
162158
new_pos = grid_centers[shifted_index]
163159
return new_pos - port_position
164160

161+
165162
AbstractComponentModeler.update_forward_refs()

tidy3d/plugins/smatrix/component_modelers/modal.py renamed to tidy3d/plugins/smatrix/modelers/modal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from tidy3d.components.types import Ax, Complex
1919
from tidy3d.components.viz import add_ax_if_none, equal_aspect
2020
from tidy3d.exceptions import SetupError
21-
from tidy3d.plugins.smatrix.ports.modal import ModalPortDataArray, Port
22-
from tidy3d.web import BatchData
21+
from tidy3d.plugins.smatrix.ports.modal import Port
2322

2423
from .base import FWIDTH_FRAC, AbstractComponentModeler
2524

@@ -257,4 +256,4 @@ def get_max_mode_indices(matrix_elements: tuple[str, int]) -> int:
257256
max_mode_index_out = get_max_mode_indices(self.matrix_indices_monitor)
258257
max_mode_index_in = get_max_mode_indices(self.matrix_indices_source)
259258

260-
return max_mode_index_out, max_mode_index_in
259+
return max_mode_index_out, max_mode_index_in

tidy3d/plugins/smatrix/component_modelers/terminal.py renamed to tidy3d/plugins/smatrix/modelers/terminal.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22

33
from __future__ import annotations
44

5-
import os
65
from typing import Optional, Union
76

87
import numpy as np
98
import pydantic.v1 as pd
109

1110
from tidy3d.components.base import cached_property
12-
from tidy3d.components.data.data_array import DataArray, FreqDataArray
13-
from tidy3d.components.data.monitor_data import MonitorData
14-
from tidy3d.components.data.sim_data import SimulationData
1511
from tidy3d.components.geometry.utils_2d import snap_coordinate_to_grid
16-
from tidy3d.components.microwave.data.monitor_data import AntennaMetricsData
1712
from tidy3d.components.monitor import DirectivityMonitor
1813
from tidy3d.components.simulation import Simulation
1914
from tidy3d.components.source.time import GaussianPulse
@@ -22,17 +17,15 @@
2217
from tidy3d.constants import C_0, OHM
2318
from tidy3d.exceptions import SetupError, Tidy3dKeyError, ValidationError
2419
from tidy3d.log import log
25-
from tidy3d.plugins.smatrix.component_modelers.base import (
26-
DEFAULT_DATA_DIR,
20+
from tidy3d.plugins.smatrix.data.data_array import PortDataArray
21+
from tidy3d.plugins.smatrix.modelers.base import (
2722
AbstractComponentModeler,
2823
TerminalPortType,
2924
)
30-
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
3125
from tidy3d.plugins.smatrix.ports.base_lumped import AbstractLumpedPort
3226
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
3327
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
3428
from tidy3d.plugins.smatrix.ports.wave import WavePort
35-
from tidy3d.web import BatchData
3629

3730

3831
class TerminalComponentModeler(AbstractComponentModeler):
@@ -288,4 +281,5 @@ def get_radiation_monitor_by_name(self, monitor_name: str) -> DirectivityMonitor
288281
return monitor
289282
raise Tidy3dKeyError(f"No radiation monitor named '{monitor_name}'.")
290283

284+
291285
TerminalComponentModeler.update_forward_refs()

tidy3d/plugins/smatrix/smatrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# backwards compatibility support for ``from tidy3d.plugins.smatrix.smatrix import ``
22
from __future__ import annotations
33

4-
from .component_modelers.modal import ComponentModeler
4+
from .modelers.modal import ComponentModeler
55
from .ports.modal import Port
66

77
__all__ = ["ComponentModeler", "Port"]

tidy3d/plugins/smatrix/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from tidy3d.components.data.data_array import DataArray, FreqDataArray
88
from tidy3d.components.data.sim_data import SimulationData
99
from tidy3d.exceptions import Tidy3dError
10-
from tidy3d.plugins.smatrix.component_modelers.base import (
10+
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
11+
from tidy3d.plugins.smatrix.modelers.base import (
1112
AbstractComponentModeler,
1213
TerminalPortType,
1314
)
14-
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
1515
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
1616
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
1717

0 commit comments

Comments
 (0)