Cascade
- class pmrf.models.composite.interconnected.Cascade(cascade: tuple[Model], *, z0: complex = 50 + 0j, name: str | None = None, metadata: Any = None, domain: str = 's', method: str | None = None)
Bases:
ModelRepresents 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.
- Parameters:
cascade (tuple[Model]) – The sequence of models in the cascade.
Examples
Cascading models is most easily done using the ** operator, which is an alias for creating a Cascade model.
>>> 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}")
- primary_matrix(freq)
The primary matrix (e.g.
s,aetc.) as a function of frequency.The primary matrix represents the matrix returned by
pmrf.Model.primary_property, which is either overridden by sub-classes, or is the first proprerty directly overriden out ofpmrf.Model.s(),pmrf.Model.a(),pmrf.Model.y(),pmrf.Model.z()(in that order), unless :meth:pmrf.Model.buildis overridden, in which case the primary matrix of the built model is returned.This method can also be overriden itself in order to to dynamically implement one of the matrices as opposed to overriding it explicitly.
- Return type:
jnp.ndarray
- Raises:
NotImplementedError – If no primary property is overridden.
- domain: str = 's'
The domain to perform the calculation in. Only ‘s’ is supported.
- property merged_cascade: list[Model]
Returns the models of the cascade merged such that any cascades are combined.
This is done only during the forward pass to retain the caller’s original nesting for debugging/inspection purposes.
- method: str | None = None
The algorithm to use for the call to cascade_<domain>. If None, uses the default algorithm for the domain. Algorithms are available in
pmrf.rf.
- property primary_property
The primary property (e.g.
"s","a") as a string.The primary property is the first overridden among
PRIMARY_PROPERTIES, unlessbuildis overridden, in which case the primary property of the built model is returned.- Return type:
str
- Raises:
NotImplementedError – If no primary property is overridden.