Skip to content

Commit 318d953

Browse files
committed
remove incorrect validation of power waves
1 parent 09cc7d4 commit 318d953

File tree

2 files changed

+6
-95
lines changed

2 files changed

+6
-95
lines changed

tests/test_plugins/smatrix/test_terminal_component_modeler.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,58 +1163,6 @@ def test_run_only_and_element_mappings(monkeypatch, tmp_path):
11631163
assert len(modeler_with_mappings.sim_dict) == 2
11641164

11651165

1166-
def test_validate_s_param_def():
1167-
"""Test that the s_param_def field is validated correctly, especially when it is set to 'power'."""
1168-
# Create a base modeler using the existing convenience function
1169-
modeler = make_component_modeler(planar_pec=True)
1170-
1171-
port0_idx = modeler.network_index(modeler.ports[0])
1172-
port1_idx = modeler.network_index(modeler.ports[1])
1173-
S11 = (port0_idx, port0_idx)
1174-
S21 = (port1_idx, port0_idx)
1175-
S12 = (port0_idx, port1_idx)
1176-
S22 = (port1_idx, port1_idx)
1177-
element_mappings = ((S11, S22, 1),)
1178-
1179-
# s_param_def="pseudo" is the most flexible choice when running a subset of simulations
1180-
modeler_pseudo = (
1181-
modeler.updated_copy(
1182-
s_param_def="pseudo",
1183-
assume_ideal_excitation=True,
1184-
run_only=(modeler.ports[0].name,),
1185-
),
1186-
)
1187-
1188-
# s_param_def="power" with assume_ideal_excitation=True should fail
1189-
with pytest.raises(pd.ValidationError):
1190-
modeler.updated_copy(
1191-
s_param_def="power",
1192-
assume_ideal_excitation=True,
1193-
)
1194-
1195-
# s_param_def="power" with run_only not None should fail
1196-
with pytest.raises(pd.ValidationError):
1197-
modeler.updated_copy(
1198-
s_param_def="power",
1199-
run_only=(modeler.ports[0].name,),
1200-
)
1201-
1202-
# s_param_def="power" with element_mappings not empty should fail
1203-
with pytest.raises(pd.ValidationError):
1204-
modeler.updated_copy(
1205-
s_param_def="power",
1206-
element_mappings=element_mappings,
1207-
)
1208-
1209-
# s_param_def="power" with all valid settings should pass
1210-
modeler_power_valid = modeler.updated_copy(
1211-
s_param_def="power",
1212-
assume_ideal_excitation=False,
1213-
run_only=None,
1214-
element_mappings=(),
1215-
)
1216-
1217-
12181166
def test_internal_construct_smatrix_with_port_vi(monkeypatch):
12191167
"""Test _internal_construct_smatrix method by monkeypatching compute_port_VI
12201168
with precomputed voltage and current values and comparing the final S-matrix to expected results.

tidy3d/plugins/smatrix/component_modelers/terminal.py

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -92,45 +92,6 @@ def _warn_rf_license(cls, values):
9292
)
9393
return values
9494

95-
@pd.validator("s_param_def", always=True)
96-
def _validate_s_param_def(cls, s_param_def, values):
97-
"""
98-
Check that the scattering parameter computation is set up correctly for the power wave definition.
99-
"""
100-
101-
if s_param_def == "pseudo":
102-
return s_param_def
103-
104-
assume_ideal_excitation = values.get("assume_ideal_excitation")
105-
if assume_ideal_excitation is True:
106-
raise SetupError(
107-
"Setting `assume_ideal_excitation` to ``True`` is incompatible with "
108-
"using the power wave definition of scattering parameters. "
109-
"Either use the pseudo wave definition by setting 's_param_def' to 'pseudo', "
110-
"or set 'assume_ideal_excitation' to ``False``. "
111-
)
112-
113-
run_only = values.get("run_only")
114-
if run_only is not None:
115-
raise SetupError(
116-
"Computing scattering parameters using the power wave definition "
117-
"requires running a number of simulations equal to the number of ports. "
118-
"Either use the pseudo wave definition by setting 's_param_def' to 'pseudo', "
119-
"or ensure all simulations are run by setting 'run_only' to 'None'. "
120-
)
121-
122-
element_mappings = values.get("element_mappings")
123-
if len(element_mappings) != 0:
124-
raise SetupError(
125-
"Computing scattering parameters using the power wave definition "
126-
"requires running a number of simulations equal to the number of ports. "
127-
"Either use the pseudo wave definition by setting 's_param_def' to 'pseudo', "
128-
"or ensure all simulations are run by keeping 'element_mappings' as its "
129-
"default value of an empty 'tuple'. "
130-
)
131-
132-
return s_param_def
133-
13495
@equal_aspect
13596
@add_ax_if_none
13697
def plot_sim(
@@ -835,7 +796,7 @@ def get_antenna_metrics_data(
835796
) -> AntennaMetricsData:
836797
"""Calculate antenna parameters using superposition of fields from multiple port excitations.
837798
838-
The method computes the radiated far fields and port excitation wave amplitudes
799+
The method computes the radiated far fields and port excitation power wave amplitudes
839800
for a superposition of port excitations, which can be used to analyze antenna radiation
840801
characteristics.
841802
@@ -845,6 +806,8 @@ def get_antenna_metrics_data(
845806
Dictionary mapping port names to their desired excitation amplitudes. For each port,
846807
:math:`\\frac{1}{2}|a|^2` represents the incident power from that port into the system.
847808
If None, uses only the first port without any scaling of the raw simulation data.
809+
Note that in this method ``a`` represents the incident wave amplitude
810+
using the power wave definition in [2].
848811
monitor_name : str = None
849812
Name of the :class:`.DirectivityMonitor` to use for calculating far fields.
850813
If None, uses the first monitor in `radiation_monitors`.
@@ -871,7 +834,7 @@ def get_antenna_metrics_data(
871834
else:
872835
rad_mon = self.get_radiation_monitor_by_name(monitor_name)
873836

874-
# Create data arrays for holding the superposition of all port wave amplitudes
837+
# Create data arrays for holding the superposition of all port power wave amplitudes
875838
f = list(rad_mon.freqs)
876839
coords = {"f": f, "port": list(self.matrix_indices_monitor)}
877840
a_sum = PortDataArray(
@@ -885,7 +848,7 @@ def get_antenna_metrics_data(
885848
radiation_data = sim_data_port[rad_mon.name]
886849

887850
a, b = self.compute_wave_amplitudes_at_each_port(
888-
self.port_reference_impedances, sim_data_port, s_param_def="pseudo"
851+
self.port_reference_impedances, sim_data_port, s_param_def="power"
889852
)
890853
# Select a possible subset of frequencies
891854
a = a.sel(f=f)
@@ -904,7 +867,7 @@ def get_antenna_metrics_data(
904867
a = scale_factor * a
905868
b = scale_factor * b
906869

907-
# Combine the possibly scaled directivity data and the wave amplitudes
870+
# Combine the possibly scaled directivity data and the power wave amplitudes
908871
if combined_directivity_data is None:
909872
combined_directivity_data = scaled_directivity_data
910873
else:

0 commit comments

Comments
 (0)