Terminated
- class pmrf.models.composite.interconnected.terminated.Terminated(terminated_from: Model, terminated_into: Model, *, name: str | None = None, metadata: Any = None, method: Literal['s', 'a'] = 's')
Bases:
ModelRepresents one network terminated in another.
Mathematically collapses an active network by terminating a subset of its ports with a known load matrix.
- Parameters:
- expand()
Expands this model into its internal graph representation for circuit flattening.
This method is used by graph algorithms (like the solver in Circuit.flattened) to unpack composite models, wrappers, and nested hierarchies into a single flat netlist. This allows global matrix solves to be used, where desired.
pmrf.models.AbstractBuilderdelegates this method to its built model. The legacy directModel.build()override does the same. Most user classes therefore do not need to implement topology expansion manually; it is mainly intended for built-in composite models such aspmrf.models.Cascadeorpmrf.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
Imagine a custom 2-port model that internally connects an Inductor and Capacitor in series. When asked to expand, it exposes the inner components and their wiring:
>>> def expand(self): ... # 1. Grab internal components ... L, C = self.inductor, self.capacitor ... ... # 2. Map our external ports to the internal components ... port_mapping = [ ... (L, 0), # External port 0 maps to Inductor port 0 ... (C, 1) # External port 1 maps to Capacitor port 1 ... ] ... ... # 3. Define the internal connections (the netlist) ... # Connect Inductor port 1 to Capacitor port 0 ... internal_connections = [ ... [(L, 1), (C, 0)] ... ] ... ... return port_mapping, internal_connections
- method: Literal['s', 'a'] = 's'
The termination reduction algorithm method.
- property number_of_ports
Number of ports.
- Return type:
int