Skip to content

Commit 2769ee8

Browse files
Documentation and file paths
1 parent 11cbf6f commit 2769ee8

File tree

6 files changed

+70
-5
lines changed

6 files changed

+70
-5
lines changed

tidy3d/plugins/smatrix/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .component_modelers.modal import AbstractComponentModeler, ComponentModeler, ModalPortDataArray
88
from .component_modelers.terminal import TerminalComponentModeler
9-
from .data.terminal import PortDataArray, TerminalPortDataArray
9+
from .data.data_array import PortDataArray, TerminalPortDataArray
1010
from .ports.coaxial_lumped import CoaxialLumpedPort
1111
from .ports.modal import Port
1212
from .ports.rectangular_lumped import LumpedPort

tidy3d/plugins/smatrix/component_modelers/terminal.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
AbstractComponentModeler,
2929
TerminalPortType,
3030
)
31-
from tidy3d.plugins.smatrix.data.terminal import PortDataArray, TerminalPortDataArray
31+
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
3232
from tidy3d.plugins.smatrix.ports.base_lumped import AbstractLumpedPort
3333
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
3434
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
@@ -304,6 +304,7 @@ def run(self, path_dir: str = DEFAULT_DATA_DIR):
304304
##### Backwards compatibility methods #####
305305
@staticmethod
306306
def _check_port_impedance_sign(Z_numpy: np.ndarray):
307+
"""Sanity check for consistent sign of real part of Z for each port across all frequencies."""
307308
from tidy3d.plugins.smatrix.utils import check_port_impedance_sign
308309

309310
return check_port_impedance_sign(Z_numpy)
@@ -317,6 +318,7 @@ def _compute_F(Z_numpy: np.array):
317318
return compute_F(Z_numpy)
318319

319320
def _construct_smatrix(self) -> TerminalPortDataArray:
321+
"""Post process :class:`.BatchData` to generate scattering matrix."""
320322
from tidy3d.plugins.smatrix.local_run import construct_smatrix
321323

322324
return construct_smatrix(self)
@@ -387,6 +389,7 @@ def _upload_terminal_modeler(self):
387389
def ab_to_s(
388390
a_matrix: TerminalPortDataArray, b_matrix: TerminalPortDataArray
389391
) -> TerminalPortDataArray:
392+
"""Get the scattering matrix given the power wave matrices."""
390393
from tidy3d.plugins.smatrix.utils import ab_to_s
391394

392395
return ab_to_s(a_matrix=a_matrix, b_matrix=b_matrix)
@@ -395,13 +398,42 @@ def ab_to_s(
395398
def compute_port_VI(
396399
port_out: TerminalPortType, sim_data: SimulationData
397400
) -> tuple[FreqDataArray, FreqDataArray]:
401+
"""Compute the port voltages and currents.
402+
403+
Parameters
404+
----------
405+
port_out : ``TerminalPortType``
406+
Port for computing voltage and current.
407+
sim_data : :class:`.SimulationData`
408+
Results from simulation containing field data.
409+
410+
Returns
411+
-------
412+
tuple[FreqDataArray, FreqDataArray]
413+
Voltage and current values at the port as frequency arrays.
414+
"""
398415
from tidy3d.plugins.smatrix.utils import compute_port_VI
399416

400417
return compute_port_VI(port_out=port_out, sim_data=sim_data)
401418

402419
def compute_power_wave_amplitudes_at_each_port(
403420
self, port_reference_impedances: PortDataArray, sim_data: SimulationData
404421
) -> tuple[PortDataArray, PortDataArray]:
422+
"""Compute the incident and reflected power wave amplitudes at each port.
423+
The computed amplitudes have not been normalized.
424+
425+
Parameters
426+
----------
427+
port_reference_impedances : :class:`.PortDataArray`
428+
Reference impedance at each port.
429+
sim_data : :class:`.SimulationData`
430+
Results from the simulation.
431+
432+
Returns
433+
-------
434+
tuple[:class:`.PortDataArray`, :class:`.PortDataArray`]
435+
Incident (a) and reflected (b) power wave amplitudes at each port.
436+
"""
405437
from tidy3d.plugins.smatrix.local_run import compute_power_wave_amplitudes_at_each_port
406438

407439
data = compute_power_wave_amplitudes_at_each_port(
@@ -413,6 +445,20 @@ def compute_power_wave_amplitudes_at_each_port(
413445
def compute_power_delivered_by_port(
414446
port: Union[LumpedPort, CoaxialLumpedPort], sim_data: SimulationData
415447
) -> FreqDataArray:
448+
"""Compute the power delivered to the network by a lumped port.
449+
450+
Parameters
451+
----------
452+
port : Union[:class:`.LumpedPort`, :class:`.CoaxialLumpedPort`]
453+
Port for computing voltage and current.
454+
sim_data : :class:`.SimulationData`
455+
Results from the simulation.
456+
457+
Returns
458+
-------
459+
FreqDataArray
460+
Power in units of Watts as a frequency array.
461+
"""
416462
from tidy3d.plugins.smatrix.utils import compute_power_delivered_by_port
417463

418464
return compute_power_delivered_by_port(port=port, sim_data=sim_data)
@@ -421,6 +467,21 @@ def compute_power_delivered_by_port(
421467
def compute_power_wave_amplitudes(
422468
port: Union[LumpedPort, CoaxialLumpedPort], sim_data: SimulationData
423469
) -> tuple[FreqDataArray, FreqDataArray]:
470+
"""Compute the incident and reflected power wave amplitudes at a lumped port.
471+
The computed amplitudes have not been normalized.
472+
473+
Parameters
474+
----------
475+
port : Union[:class:`.LumpedPort`, :class:`.CoaxialLumpedPort`]
476+
Port for computing voltage and current.
477+
sim_data : :class:`.SimulationData`
478+
Results from the simulation.
479+
480+
Returns
481+
-------
482+
tuple[FreqDataArray, FreqDataArray]
483+
Incident (a) and reflected (b) power wave amplitude frequency arrays.
484+
"""
424485
from tidy3d.plugins.smatrix.utils import compute_power_wave_amplitudes
425486

426487
return compute_power_wave_amplitudes(port=port, sim_data=sim_data)
@@ -443,6 +504,9 @@ def get_antenna_metrics_data(
443504

444505
@cached_property
445506
def port_reference_impedances(self) -> PortDataArray:
507+
"""Tabulates the reference impedance of each port at each frequency using the
508+
supplied :class:`.BatchData`.
509+
"""
446510
from tidy3d.plugins.smatrix.data.data import (
447511
MicrowaveSMatrixData,
448512
TerminalComponentModelerData,
@@ -458,6 +522,7 @@ def port_reference_impedances(self) -> PortDataArray:
458522
def s_to_z(
459523
s_matrix: TerminalPortDataArray, reference: Union[complex, PortDataArray]
460524
) -> DataArray:
525+
"""Get the impedance matrix given the scattering matrix and a reference impedance."""
461526
from tidy3d.plugins.smatrix.utils import s_to_z
462527

463528
return s_to_z(s_matrix=s_matrix, reference=reference)

tidy3d/plugins/smatrix/data/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
TerminalPortType,
1818
)
1919
from tidy3d.plugins.smatrix.component_modelers.terminal import TerminalComponentModeler
20-
from tidy3d.plugins.smatrix.data.terminal import PortDataArray, TerminalPortDataArray
20+
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
2121

2222

2323
class MicrowavePortSimulationData(Tidy3dBaseModel):

tidy3d/plugins/smatrix/local_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88

99
from tidy3d.components.data.sim_data import SimulationData
10-
from tidy3d.plugins.smatrix.data.terminal import PortDataArray, TerminalPortDataArray
10+
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray
1111
from tidy3d.plugins.smatrix.ports.wave import WavePort
1212
from tidy3d.plugins.smatrix.utils import check_port_impedance_sign, compute_F, compute_port_VI
1313

tidy3d/plugins/smatrix/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
AbstractComponentModeler,
1212
TerminalPortType,
1313
)
14-
from tidy3d.plugins.smatrix.data.terminal import PortDataArray, TerminalPortDataArray
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)