@@ -113,19 +113,19 @@ def get_antenna_metrics_data(
113
113
"""
114
114
# Use the first port as default if none specified
115
115
if port_amplitudes is None :
116
- port_amplitudes = {self .ports [0 ].name : None }
117
- port_names = [port .name for port in self .ports ]
116
+ port_amplitudes = {self .simulation . ports [0 ].name : None }
117
+ port_names = [port .name for port in self .simulation . ports ]
118
118
# Check port names, and create map from port to amplitude
119
119
port_dict = {}
120
120
for key in port_amplitudes .keys ():
121
- port = self .get_port_by_name (port_name = key )
121
+ port = self .simulation . get_port_by_name (port_name = key )
122
122
port_dict [port ] = port_amplitudes [key ]
123
123
# Get the radiation monitor, use first as default
124
124
# if none specified
125
125
if monitor_name is None :
126
- rad_mon = self .radiation_monitors [0 ]
126
+ rad_mon = self .simulation . radiation_monitors [0 ]
127
127
else :
128
- rad_mon = self .get_radiation_monitor_by_name (monitor_name )
128
+ rad_mon = self .simulation . get_radiation_monitor_by_name (monitor_name )
129
129
130
130
# Create data arrays for holding the superposition of all port power wave amplitudes
131
131
f = list (rad_mon .freqs )
@@ -135,7 +135,7 @@ def get_antenna_metrics_data(
135
135
# Retrieve associated simulation data
136
136
combined_directivity_data = None
137
137
for port , amplitude in port_dict .items ():
138
- sim_data_port = self .batch_data [self ._task_name (port = port )]
138
+ sim_data_port = self .simulation . batch_data [self . simulation ._task_name (port = port )]
139
139
radiation_data = sim_data_port [rad_mon .name ]
140
140
141
141
a , b = self .compute_power_wave_amplitudes_at_each_port (
@@ -176,35 +176,37 @@ def get_antenna_metrics_data(
176
176
@cached_property
177
177
def port_reference_impedances (self ) -> PortDataArray :
178
178
"""The reference impedance used at each port for definining power wave amplitudes."""
179
- return self ._port_reference_impedances (self .batch_data )
179
+ return self ._port_reference_impedances (self .simulation . batch_data )
180
180
181
181
def _port_reference_impedances (self , batch_data ) -> PortDataArray :
182
182
"""Tabulates the reference impedance of each port at each frequency using the
183
183
supplied :class:`.BatchData`.
184
184
"""
185
185
# TODO properly refactor, plugins data types should not have web methods.
186
186
187
- port_names = [port .name for port in self .ports ]
187
+ port_names = [port .name for port in self .simulation . ports ]
188
188
189
189
values = np .zeros (
190
- (len (self .freqs ), len (port_names )),
190
+ (len (self .simulation . freqs ), len (port_names )),
191
191
dtype = complex ,
192
192
)
193
- coords = {"f" : np .array (self .freqs ), "port" : port_names }
193
+ coords = {"f" : np .array (self .simulation . freqs ), "port" : port_names }
194
194
port_impedances = PortDataArray (values , coords = coords )
195
- for port in self .ports :
195
+ for port in self .simulation . ports :
196
196
if isinstance (port , WavePort ):
197
197
# Mode solver data for each wave port is stored in its associated SimulationData
198
- sim_data_port = batch_data [self ._task_name (port = port )]
198
+ sim_data_port = batch_data [self .simulation . _task_name (port = port )]
199
199
# WavePorts have a port impedance calculated from its associated modal field distribution
200
200
# and is frequency dependent.
201
201
impedances = port .compute_port_impedance (sim_data_port ).values
202
202
port_impedances .loc [{"port" : port .name }] = impedances .squeeze ()
203
203
else :
204
204
# LumpedPorts have a constant reference impedance
205
- port_impedances .loc [{"port" : port .name }] = np .full (len (self .freqs ), port .impedance )
205
+ port_impedances .loc [{"port" : port .name }] = np .full (
206
+ len (self .simulation .freqs ), port .impedance
207
+ )
206
208
207
- port_impedances = TerminalComponentModeler ._set_port_data_array_attributes (port_impedances )
209
+ port_impedances = self . simulation ._set_port_data_array_attributes (port_impedances )
208
210
return port_impedances
209
211
210
212
def compute_power_wave_amplitudes_at_each_port (
@@ -225,13 +227,13 @@ def compute_power_wave_amplitudes_at_each_port(
225
227
tuple[:class:`.PortDataArray`, :class:`.PortDataArray`]
226
228
Incident (a) and reflected (b) power wave amplitudes at each port.
227
229
"""
228
- port_names = [port .name for port in self .ports ]
230
+ port_names = [port .name for port in self .simulation . ports ]
229
231
values = np .zeros (
230
- (len (self .freqs ), len (port_names )),
232
+ (len (self .simulation . freqs ), len (port_names )),
231
233
dtype = complex ,
232
234
)
233
235
coords = {
234
- "f" : np .array (self .freqs ),
236
+ "f" : np .array (self .simulation . freqs ),
235
237
"port" : port_names ,
236
238
}
237
239
@@ -240,7 +242,7 @@ def compute_power_wave_amplitudes_at_each_port(
240
242
a = V_matrix .copy (deep = True )
241
243
b = V_matrix .copy (deep = True )
242
244
243
- for port_out in self .ports :
245
+ for port_out in self .simulation . ports :
244
246
V_out , I_out = compute_port_VI (port_out , sim_data )
245
247
indexer = {"port" : port_out .name }
246
248
V_matrix .loc [indexer ] = V_out
0 commit comments