3
3
import numpy as np
4
4
5
5
from tidy3d .components .data .sim_data import SimulationData
6
- from tidy3d .plugins .smatrix .component_modelers .terminal import TerminalComponentModeler
6
+ from tidy3d .plugins .smatrix .data .terminal import TerminalComponentModelerData
7
7
from tidy3d .plugins .smatrix .data .data_array import PortDataArray , TerminalPortDataArray
8
8
from tidy3d .plugins .smatrix .utils import (
9
9
ab_to_s ,
14
14
15
15
16
16
def terminal_construct_smatrix (
17
- modeler : TerminalComponentModeler , batch_data : BatchData = None
17
+ modeler_data : TerminalComponentModelerData
18
18
) -> TerminalPortDataArray :
19
19
"""
20
20
Constructs the scattering matrix (S-matrix) from raw simulation data.
@@ -26,11 +26,7 @@ def terminal_construct_smatrix(
26
26
27
27
Parameters
28
28
----------
29
- modeler : TerminalComponentModeler
30
- The modeler setup defining the component, ports, and frequencies.
31
- batch_data : BatchData, optional
32
- Pre-computed simulation results. If None, the function will execute the
33
- batch run defined within the `simulation` object.
29
+ modeler_data
34
30
35
31
Returns
36
32
-------
@@ -39,22 +35,22 @@ def terminal_construct_smatrix(
39
35
output port, and input port.
40
36
"""
41
37
42
- port_names = [port .name for port in modeler .ports ]
38
+ port_names = [port .name for port in modeler_data . modeler .ports ]
43
39
44
40
values = np .zeros (
45
- (len (modeler .freqs ), len (port_names ), len (port_names )),
41
+ (len (modeler_data . modeler .freqs ), len (port_names ), len (port_names )),
46
42
dtype = complex ,
47
43
)
48
44
coords = {
49
- "f" : np .array (modeler .freqs ),
45
+ "f" : np .array (modeler_data . modeler .freqs ),
50
46
"port_out" : port_names ,
51
47
"port_in" : port_names ,
52
48
}
53
49
a_matrix = TerminalPortDataArray (values , coords = coords )
54
50
b_matrix = a_matrix .copy (deep = True )
55
51
56
52
# Tabulate the reference impedances at each port and frequency
57
- port_impedances = port_reference_impedances (modeler = modeler )
53
+ port_impedances = port_reference_impedances (modeler = modeler_data . modeler )
58
54
59
55
# loop through source ports
60
56
for port_in in modeler .ports :
@@ -69,7 +65,7 @@ def terminal_construct_smatrix(
69
65
70
66
71
67
def port_reference_impedances (
72
- modeler : TerminalComponentModeler , batch_data : BatchData = None
68
+ modeler_data : TerminalComponentModelerData
73
69
) -> PortDataArray :
74
70
"""
75
71
Calculates the reference impedance for each port across all frequencies.
@@ -94,13 +90,13 @@ def port_reference_impedances(
94
90
PortDataArray
95
91
A data array containing the complex impedance for each port at each frequency.
96
92
"""
97
- port_names = [port .name for port in modeler .ports ]
93
+ port_names = [port .name for port in modeler_data . modeler .ports ]
98
94
99
95
values = np .zeros (
100
- (len (modeler .freqs ), len (port_names )),
96
+ (len (modeler_data . modeler .freqs ), len (port_names )),
101
97
dtype = complex ,
102
98
)
103
- coords = {"f" : np .array (modeler .freqs ), "port" : port_names }
99
+ coords = {"f" : np .array (modeler_data . modeler .freqs ), "port" : port_names }
104
100
port_impedances = PortDataArray (values , coords = coords )
105
101
for port in modeler .ports :
106
102
if isinstance (port , WavePort ):
@@ -114,7 +110,7 @@ def port_reference_impedances(
114
110
# LumpedPorts have a constant reference impedance
115
111
port_impedances .loc [{"port" : port .name }] = np .full (len (modeler .freqs ), port .impedance )
116
112
117
- port_impedances = modeler ._set_port_data_array_attributes (port_impedances )
113
+ port_impedances = modeler_data . modeler ._set_port_data_array_attributes (port_impedances )
118
114
return port_impedances
119
115
120
116
0 commit comments