pmrf.models.containers
Classes
|
Overview |
|
Overview |
|
Overview |
|
Overview |
- class pmrf.models.containers.Cascade(models, *, name=None, separator='_', _z0=(50+0j), _param_groups=<factory>)[source]
Bases:
Model
Overview
Represents a cascade, or series connection, of two or more Model objects.
This container connects multiple models end-to-end. The output port of one model is connected to the input port of the next. This is mathematically equivalent to chain-multiplying the ABCD-parameter matrices of the constituent models.
The Cascade model automatically flattens any nested Cascade instances to maintain a simple, linear chain of models. The number of ports of the resulting Cascade network depends on the port count of the final model in the chain.
Example:
Cascading models is most easily done using the ** operator, which is an alias for creating a Cascade model.
```python import pmrf as prf from pmrf.models import Resistor, Capacitor, Inductor
# Create individual component models res = Resistor(50) cap = Capacitor(1e-12) ind = Inductor(1e-9)
# Cascade them together in a series R-L-C configuration # This is equivalent to Cascade(models=(res, ind, cap)) rlc_series = res ** ind ** cap
# Define a frequency axis freq = prf.Frequency(start=1, stop=10, npoints=101, unit=’ghz’)
# Calculate the S-parameters of the cascaded network s_params = rlc_series.s(freq)
print(f”Cascaded model has {rlc_series.nports} ports.”) print(f”S11 at first frequency point: {s_params[0,0,0]:.2f}”) ```
- Parameters:
models (tuple[Model])
name (str | None)
separator (str)
_z0 (complex)
_param_groups (list[ParameterGroup])
- a(freq)[source]
Calculates the cascaded ABCD-parameter matrix.
- Args:
freq (Frequency): Specifies the frequency to calculate the parameters at.
- Returns:
jnp.ndarray: The resultant ABCD-parameter matrix.
- Parameters:
freq (Frequency)
- Return type:
Array
- s(freq)[source]
Calculates the S-parameter matrix.
If the cascade is terminated in a one-port, this computes the resultant one-port reflection coefficient. Otherwise, it converts the cascaded ABCD-matrix to S-parameters.
- Args:
freq (Frequency): Specifies the frequency to calculate the parameters at.
- Returns:
jnp.ndarray: The resultant S-parameter matrix.
- Parameters:
freq (Frequency)
- Return type:
Array
- class pmrf.models.containers.Renumbered(model, to_ports, from_ports, *, name=None, separator='_', _z0=(50+0j), _param_groups=<factory>)[source]
Bases:
Model
Overview
A container that re-numbers the ports of a given Model.
This is useful for creating complex network topologies by explicitly re-mapping the port indices of a sub-network.
- Parameters:
model (Model)
to_ports (tuple[int])
from_ports (tuple[int])
name (str | None)
separator (str)
_z0 (complex)
_param_groups (list[ParameterGroup])
- to_ports: tuple[int]
- from_ports: tuple[int]
- renumber(p)[source]
Applies the port renumbering to a parameter matrix.
- Args:
p (jnp.ndarray): The parameter matrix to renumber (e.g., S-parameters).
- Returns:
jnp.ndarray: The renumbered parameter matrix.
- Parameters:
p (Array)
- Return type:
Array
- class pmrf.models.containers.Flipped(model, *, name=None, separator='_', _z0=(50+0j), _param_groups=<factory>)[source]
Bases:
Renumbered
Overview
A model container that flips the ports of a multi-port network.
For a 2-port network, this is equivalent to swapping port 1 and port 2. For a 4-port network, ports (1,2) are swapped with (3,4), and so on. This is a convenient specialization of the Renumbered model.
- Parameters:
model (Model)
name (str | None)
separator (str)
_z0 (complex)
_param_groups (list[ParameterGroup])
- to_ports: tuple[int]
- from_ports: tuple[int]
- class pmrf.models.containers.Stacked(models, *, name=None, separator='_', _z0=(50+0j), _param_groups=<factory>)[source]
Bases:
Model
Overview
A container that stacks multiple models in a block-diagonal fashion.
This combines several Model objects into a single, larger model where the individual S-parameter matrices are placed along the diagonal of the combined S-parameter matrix. This represents a set of unconnected networks treated as a single component.
- Parameters:
models (tuple[Model, ...])
name (str | None)
separator (str)
_z0 (complex)
_param_groups (list[ParameterGroup])