s_transforms
¤
Utilities for converting between S-parameters.
Utilities for converting between S-parameter and admittance representations, and for wrapping SAX model functions as circulax components.
Functions:
| Name | Description |
|---|---|
s_to_y |
Convert an S-parameter matrix to an admittance (Y) matrix. |
sax_component |
Decorator to convert a SAX model function into a circulax component. |
s_to_y
¤
Convert an S-parameter matrix to an admittance (Y) matrix.
Uses the formula Y = (1/z0) * (I - S) * (I + S)^-1. Requires dense
matrix inversion; if a component can be defined directly in terms of a
Y-matrix it should be, to avoid the overhead of this conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
Array
|
S-parameter matrix of shape |
required |
z0
|
float
|
Reference impedance in ohms. Defaults to |
1.0
|
Returns:
| Type | Description |
|---|---|
Array
|
Y-matrix of the same shape and dtype as |
Source code in circulax/s_transforms.py
sax_component
¤
Decorator to convert a SAX model function into a circulax component.
Inspects fn at decoration time to discover its port interface via a
dry run, then wraps its S-matrix output in an admittance-based physics
function compatible with the circulax nodal solver.
The conversion proceeds in three stages:
- Discovery —
fnis called once with its default (or dummy) parameter values and :func:sax.get_portsextracts the sorted port names from the resulting S-parameter dict. - Physics wrapper — a closure is built that calls
fnat runtime, converts the S-dict to a dense matrix via :func:sax.sdense, converts it to an admittance matrix via :func:s_to_y, and returnsI = Y @ Vas a port current dict. - Component registration — the wrapper is passed to
:func:
~circulax.components.base_component.componentwith the discovered ports, producing a :class:~circulax.components.base_component.CircuitComponentsubclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
callable
|
A SAX model function whose keyword arguments are scalar
parameters and whose return value is a SAX S-parameter dict.
All parameters must have defaults, or will be substituted with
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
callable
|
class: |
callable
|
subclass named after |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the dry run fails for any reason. |