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 |
|---|---|
fdomain_component | Decorator for frequency-domain (admittance) circuit components. |
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. |
fdomain_component ¤
Decorator for frequency-domain (admittance) circuit components.
Compiles the decorated admittance function into a :class:~circulax.components.base_component.CircuitComponent subclass that is evaluated in the frequency domain rather than the time domain. The component:
- DC analysis — evaluated at
f = 0Hz (e.g. skin-effect reduces toR₀at DC). - Harmonic Balance — evaluated at each harmonic frequency
k · f₀, contributingY(k · f₀) @ V_kdirectly to the frequency-domain residual. - Transient simulation — raises :exc:
RuntimeErrorat setup time (time-domain convolution not supported).
The decorated function must accept f as its first positional argument (frequency in Hz) followed by any number of keyword parameters with defaults. It must return a square Y-matrix of shape (n_ports, n_ports) with dtype=complex128.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ports | tuple[str, ...] | Ordered tuple of port names matching the netlist connection keys. | required |
Returns:
| Type | Description |
|---|---|
Any | A decorator that accepts an admittance function and returns a |
Any | class: |
Example::
@fdomain_component(ports=("p1", "p2"))
def SkinEffectResistor(f: float, R0: float = 1.0, a: float = 0.1):
"""Z(f) = R0 + a * sqrt(|f|)"""
Z = R0 + a * jnp.sqrt(jnp.abs(f) + 1e-30)
Y = 1.0 / Z
return jnp.array([[Y, -Y], [-Y, Y]], dtype=jnp.complex128)
Source code in circulax/s_transforms.py
s_to_y ¤
Convert an S-parameter matrix to an admittance (Y) matrix.
Kurokawa power-wave form: Y = (I - S) (z0 S + z0* I)^-1. Reduces to (1/z0) (I - S) (I + S)^-1 for real z0. A small Im(z0) keeps the inverse well-conditioned when S has eigenvalues at -1 (e.g. an ideal lossless symmetric splitter).
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.
fn may be a plain function or a :class:functools.partial wrapping one (SAX PDKs typically use partials to bind fab-specific defaults). Partials are unwrapped to the innermost callable for __name__ / __doc__ recovery; :func:inspect.signature handles the parameter reduction.
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 |
name | str | None | Optional override for the resulting class name. Useful when wrapping :class: | None |
Returns:
| Name | Type | Description |
|---|---|---|
A | callable | class: |
callable | subclass named after | |
callable | function. |
Raises:
| Type | Description |
|---|---|
RuntimeError | If the dry run fails for any reason. |
Source code in circulax/s_transforms.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |