Renumbered
- class pmrf.models.composite.transformed.Renumbered(model: Model, from_ports: tuple[int], to_ports: tuple[int] = None, *, name: str | None = None, metadata: Any = None)
Bases:
ModelA 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.
- Variables:
model (Model) – The underlying model to renumber.
from_ports (tuple[int]) – The original port indices that map to to_ports.
to_ports (tuple[int]) – The new port indices. Can be None, in which case from_ports must contain exactly two ports to be swapped.
- expand()
Expands this model into its internal graph representation for circuit flattening.
Used by Circuit.flattened to unpack composite models into a single flat netlist for a global matrix solve.
pmrf.models.AbstractBuilderdelegates this to its built model, as does a directModel.build()override, so user classes rarely need it. It is mainly for built-in composites such aspmrf.models.Cascadeandpmrf.models.Renumbered.- Returns:
If the model is a composite or routing container, it returns a tuple of: - port_mapping: A list of length nports mapping each external port index
of this model to an internal (Model, port_index) tuple.
internal_connections: A list of sub-nodes (connections) to add to the netlist. Each node is a list of (Model, port_index) tuples.
If the model is a fundamental leaf component, it returns None.
- Return type:
tuple or None
Examples
A 2-port model holding an inductor and capacitor in series:
>>> def expand(self): ... L, C = self.inductor, self.capacitor ... port_mapping = [(L, 0), (C, 1)] ... internal_connections = [[(L, 1), (C, 0)]] ... return port_mapping, internal_connections
- renumber(p: Array) Array
Applies the port renumbering to a parameter matrix.
- Parameters:
p (jnp.ndarray) – The parameter matrix to renumber (e.g., S-parameters).
- Returns:
The renumbered parameter matrix.
- Return type:
jnp.ndarray
- from_ports: tuple[int]
- to_ports: tuple[int] = None