@@ -72,10 +72,10 @@ class TerminalComponentModeler(AbstractComponentModeler[NetworkIndex, NetworkEle
72
72
title = "Assume Ideal Excitation" ,
73
73
description = "If ``True``, only the excited port is assumed to have a nonzero incident wave "
74
74
"amplitude power. This choice simplifies the calculation of the scattering matrix. "
75
- "If ``False``, every entry in the vector of incident power wave "
76
- "amplitudes (a) is calculated explicitly. This choice requires a matrix inversion when "
77
- "calculating the scattering matrix, but may lead to more accurate scattering parameters "
78
- "when there are reflections from simulation boundaries. " ,
75
+ "If ``False``, every entry in the vector of incident wave amplitudes (a) is calculated "
76
+ "explicitly. This choice requires a matrix inversion when calculating the scattering "
77
+ "matrix, but may lead to more accurate scattering parameters when there are "
78
+ "reflections from simulation boundaries. " ,
79
79
)
80
80
81
81
S_def : SDef = pd .Field (
@@ -92,6 +92,45 @@ def _warn_rf_license(cls, values):
92
92
)
93
93
return values
94
94
95
+ @pd .validator ("S_def" , always = True )
96
+ def _validate_S_def (cls , S_def , values ):
97
+ """
98
+ Check that the scattering parameter computation is set up correctly for the power wave definition.
99
+ """
100
+
101
+ if S_def == "pseudo" :
102
+ return S_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_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_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_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_def
133
+
95
134
@equal_aspect
96
135
@add_ax_if_none
97
136
def plot_sim (
@@ -132,15 +171,15 @@ def plot_sim_eps(
132
171
133
172
@staticmethod
134
173
def network_index (port : TerminalPortType , mode_index : Optional [int ] = None ) -> NetworkIndex :
135
- """Converts the port, and a ``mode_index`` when the port is a :class:`.WavePort`` , to a unique string specifier.
174
+ """Converts the port, and a ``mode_index`` when the port is a :class:`.WavePort`, to a unique string specifier.
136
175
137
176
Parameters
138
177
----------
139
178
port : ``TerminalPortType``
140
179
The port to convert to an index.
141
180
mode_index : Optional[int]
142
181
Selects a single mode from those supported by the ``port``, which is only used when
143
- the ``port`` is a :class:`.WavePort``
182
+ the ``port`` is a :class:`.WavePort`
144
183
145
184
Returns
146
185
-------
0 commit comments