How do I compute scattering matrix parameters for modeling my device?#
Date |
Category |
---|---|
2023-12-20 16:57:31 |
Scattering Matrix |
To compute scattering matrix parameters, you need to create a base tidy3d.Simulation (without the modal sources or monitors used to compute S-parameters) and include tidy3d.plugins.smatrix.Port objects. These ports will be converted into modal sources and monitors later, so they require a mode specification and a definition of the direction that points into the system. You should also give them names to refer to later. For example:
from tidy3d.plugins.smatrix.smatrix import Port
num_modes = 1
# Port definition.
port_right_top = Port(
center=[-5, 3, 0],
size=[0, 4, 2],
mode_spec=tidy3d.ModeSpec(num_modes=num_modes),
direction="-",
name="right_top",
)
Next, add the base simulation and ports to the tidy3d.plugins.smatrix.ComponentModeler, along with the frequency of interest and a name for saving the batch of simulations that will get created later.
from tidy3d.plugins.smatrix.smatrix import ComponentModeler
modeler = ComponentModeler(
simulation=sim,
ports=ports,
freqs=[freq0],
verbose=True
)
modeler.plot_sim(z=0)
With the component modeler defined, you should call itโs .solve()
method to run a batch of simulations to compute the S matrix. The tool will loop through each port and create one simulation per mode index (as defined by the mode specifications), where a unique modal source is injected. Each of the ports will also be converted to mode monitors to measure the mode amplitudes and normalization.
from tidy3d.plugins.smatrix.smatrix import Port
smatrix = modeler.run(path_dir="data")
The scattering matrix returned by the solve is an xr.DataArray relating the port names and mode indices. For example smatrix.loc[dict(port_in=name1, mode_index_in=mode_index1, port_out=name2, mode_index_out=mode_index_2)]
gives the complex scattering matrix element.
See this tutorial for more details on computing the scattering matrix.