Circuit

class pmrf.models.composite.interconnected.Circuit(connections: dataclasses.InitVar[list[list[tuple[pmrf.models.base.Model, int]]]] = None, *, name: str | None = None, metadata: Any = None, domain: str = 's', method: str | None = None, circuit: list[Model] = None, indexed_connections: list[list[tuple[int, int]]] = None, port_idxs: list[int] = None)

Bases: Model

Represents an arbitrary interconnection of multiple Model objects.

This container connects multiple models together based on a specified list of nodes. Each node connects one or more ports of the constituent models to form a composite network.

Parameters:
  • connections (list[list[tuple[Model, int]]]) – A list representing the nodes of the circuit. Each node is a list of tuples, where each tuple contains a Model instance and the integer index of the port to connect to that node.

  • domain (str, default='s') – (experimental) The domain to perform the calculation in. Options are (‘s’, ‘y’), where ‘y’ is experimental.

  • method (str, optional) – The algorithm to use for the call to connect_<domain>_arbitrary. If None, uses the default algorithm for the domain. Algorithms are available in pmrf.rf.

Examples

Create a two-port PI-CLC network. External nodes are defined using Port, and common nodes using Ground.

>>> import pmrf as prf
>>> from pmrf.models import Capacitor, Inductor, Circuit, Port, Ground
>>>
>>> # Instantiate the elements, ports, and ground
>>> C1, C2 = Capacitor(C=2e-12), Capacitor(C=1.5e-12)
>>> L = Inductor(L=3e-9)
>>> p0, p1, ground = Port(), Port(), Ground()
>>>
>>> # Create the connections list
>>> connections = [
...     [(p0, 0), (C1, 1), (L, 1)],         # Node 0 -> Port 1
...     [(p1, 0), (C2, 1), (L, 0)],         # Node 1 -> Port 2
...     [(ground, 0), (C1, 0), (C2, 0)],    # Node 2 -> Ground
... ]
>>>
>>> # Create the circuit model
>>> pi_clc = Circuit(connections)
primary_matrix(frequency: Frequency, **kwargs) Array

The primary matrix (e.g. s, a etc.) as a function of frequency.

The primary matrix represents the matrix returned by pmrf.Model.primary_domain, which is either overridden by sub-classes, or is the first proprerty directly overriden out of pmrf.Model.s(), pmrf.Model.a(), pmrf.Model.y(), pmrf.Model.z() (in that order), unless :meth:pmrf.Model.build is 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.

If this method is called and self.primary_domain is ‘s’, then ‘z0’ should be passed in kwargs.

Parameters:
  • freq (Frequency) – Frequency grid.

  • kwargs – Key-word arguments forwarded to the primary matrix function, such as z0.

Return type:

jnp.ndarray

Raises:

NotImplementedError – If no primary property is overridden.

s_impl(freq: Frequency, z0: Array | ndarray | bool | number | bool | int | float | complex = 50.0) Array
y_impl(freq: Frequency) Array

Evaluate the Y-parameters of the composite circuit.

circuit: list[Model] = None

The models in the circuit.

connections: dataclasses.InitVar[list[list[tuple[pmrf.models.base.Model, int]]]] = None

The connections.

domain: str = 's'

The domain to perform the calculation in.

indexed_connections: list[list[tuple[int, int]]] = None

The indices of the connections.

method: str | None = None

The method for the algorithm

port_idxs: list[int] = None

The indices of the ports.

property primary_domain

The primary domain (e.g. "s", "a") as a string.

The primary property is the first overridden among PRIMARY_DOMAINS, unless build is overridden, in which case the primary property of the built model is returned.

Return type:

str

Raises:

NotImplementedError – If no primary property is overridden.