quchip.chip.port_network¶
Composable, instantaneous SLH field boundaries.
Classes
|
A component port pairing incoming and outgoing field connections. |
|
|
|
|
|
One directional terminal owned by a |
|
Access one prefixed copy of a template network inside a host. |
|
A named external network port with incoming and outgoing fields. |
|
Compose Markovian ports with instantaneous scalar scattering. |
|
Boundary component with scalar scattering and named terminals. |
- class quchip.chip.port_network.PortNetwork(*, scattering=None, label=None)[source]¶
Bases:
objectCompose Markovian ports with instantaneous scalar scattering.
The network acts on fields at one reference frequency. Scattering matrices are dimensionless and must be unitary. Explicit hidden channels or reference components represent loss and noise. The network reduces feedback loops algebraically, so this class does not model propagation retardation.
- Parameters:
- classmethod from_ports(ports, *, scattering=None, label=None)[source]¶
Build a network containing
portsin declaration order.- Parameters:
- Returns:
Network with the supplied ports and no internal components.
- Return type:
- property external_ports: tuple[NetworkPort, ...]¶
Return the external network ports in channel order.
- property exposures: tuple[NetworkPort, ...]¶
Deprecated alias for
external_ports.
- exposure(exposure)[source]¶
Deprecated alias for
external_port().- Parameters:
exposure (str or NetworkPort) – External reference plane.
- external_port(exposure)[source]¶
Return one external network port by object or label.
- Parameters:
exposure (str or NetworkPort) – External reference plane.
- property parameters: Mapping[str, Any]¶
Return bindable scalar parameters of the network and retained responses.
Paths are
scattering.<output>.<input>,component.<label>.<name>andresponse.<mode>.<name>. A retained mode response hasfreqin GHz, a dimensionlessweightandinternal_ratein 1/ns. Theinternal_ratealready includes the weight.
- set_parameter_value(name, value)[source]¶
Set one network-owned scalar on an isolated structural copy.
- Parameters:
name (str) – Path below
scattering,componentorresponse.value (Any) – Replacement scalar in the parameter’s units.
parametersgives the units of retained mode responses.
- port(label, *, target, rate=None, external_quality_factor=None, operator=None, phase=0.0)[source]¶
Create and add one quantum coupling port.
- Parameters:
- Returns:
The network-owned port, whose
input,outputandsideterminals can be connected immediately.- Return type:
- component(label, *, scattering, terminals=None)[source]¶
Add a scalar scattering component with named terminals.
- Parameters:
label (str) – Unique component label.
scattering (square array-like) – Dimensionless scattering matrix. Rows are outputs and columns are inputs, and concrete matrices must be unitary.
terminals (sequence of str, optional) – Names for both input and output terminals. Defaults to
("signal",)for one channel and numeric names otherwise.
- Returns:
- Return type:
SLHComponent
- through(label)[source]¶
Add a one-channel identity through component.
- Parameters:
label (str) – Component label.
- beam_splitter(label, *, eta=0.5)[source]¶
Add a directional two-input/two-output splitter.
etais the power from inputkto outputk. Witht = sqrt(eta)andr = sqrt(1 - eta), the scattering matrix is[[t, r], [-r, t]]. This component has no component ports. Useinput_terminal(),output_terminal(), orcascade().
- hybrid90(label)[source]¶
Add a directional two-input/two-output ideal 90-degree hybrid.
The scattering matrix is
[[1, 1j], [1j, 1]] / sqrt(2). This component has no component ports. Useinput_terminal(),output_terminal(), orcascade().- Parameters:
label (str) – Unique component label.
- attenuator(label, *, eta=None, loss_db=None, thermal_occupation=None)[source]¶
Add a reciprocal two-sided attenuator with power transmission
eta.Each direction has amplitude transmission
sqrt(eta)and couples to one of two hidden loss channels with amplitudesqrt(1-eta). They default to vacuum.thermal_occupationgives both loads a mean thermal population in quanta, constant across the modeled band. Specify either power transmissionetaor positiveloss_db.- Parameters:
label (str) – Unique component label.
eta (scalar or None, default=None) – Power transmission in the interval [0, 1].
loss_db (scalar or None, default=None) – Positive power loss in dB, mutually exclusive with
eta.thermal_occupation (scalar or None, default=None) – Mean occupation of each hidden load in quanta.
Nonemeans vacuum.
- delay(label, *, duration)[source]¶
Add a two-sided reference section with duration
durationns.The section shifts fields at exposure planes but does not introduce retardation or memory into the Markovian dynamics.
Place it with
link()orconnect()like any other component. The compiler peels adjacent runs from each exposure leg, so the section never enters MarkovianS,L, orH. Every reference section must belong to an exposed run or an acyclic downstream output graph. Its duration is tracked atnetwork.component.<label>.duration.
- filter(label, *, transfer, thermal_occupation=None, **parameters)[source]¶
Add a two-sided passive filter reference section.
transfer(frequency, **parameters)must accept scalar or array frequencies in GHz and return a broadcast-compatible complex value without concretizing traced inputs. Each keyword parameter is tracked atnetwork.component.<label>.<name>.Place the section with
link()orconnect(). The compiler peels it from an adjacent exposure leg, so it never enters the MarkovianS,L, orH. The section reshapes the propagating field but leaves every collapse operator unchanged, including the radiative (Purcell) decay of coupled devices. Model a Purcell filter as aResonatorbetween the readout mode and the port instead (see the Purcell filtering guide). Continuous-wave APIs evaluate the transfer at each frequency. Transient APIs use its narrowband value at the applicable carrier. Concrete evaluations with|H| > 1raise. You cannot serialize networks that contain filters withto_dict().Chip.clone()andChip.with_params()preserve the callable.Declare
thermal_occupationin quanta, constant across the modeled band, for a matched absorptive realization that emits (1-|H|²)n. A scalar transfer alone does not distinguish absorption from reflection. Colored thermal emission cannot feed a quantum coupling through a reference section. Use a dynamical filter/bath model for that case.- Parameters:
label (str) – Unique component label.
transfer (callable) – Passive complex amplitude transfer versus frequency in GHz.
thermal_occupation (scalar or None, default=None) – Mean matched-load occupation in quanta.
Nonemeans vacuum.**parameters (Any) – Named transfer-function parameters tracked by the network.
- mode_reflection(label, *, freq, external_rate, internal_rate=0.0, reference_freq=None)[source]¶
Add a two-sided reference section that reflects like a damped linear mode.
Each pass multiplies the field by
H(f), withH(f)² = ((κ_i − κ_e)/2 − iΩ) / ((κ_e + κ_i)/2 − iΩ)andΩ = 2π(f − freq), the reflection of a mode coupled to the line at rateκ_ewith internal lossκ_i. On a reflection line the incident field passes once inbound and once outbound, so the plane acquires that reflection.His the continuous square root whose real part is nonnegative atreference_freq. Whenreference_freqisNone,His the root that tends to one far belowfreq. The branch fixes the phase of fields that cross only one leg, such as emission from the devices behind the section.Like
filter(), the section stays outside the MarkovianS,L, andHand leaves every collapse operator unchanged. Continuous-wave APIs evaluateHat each frequency. Transient APIs use its value at the applicable carrier. The internal-loss bath is vacuum.eliminate()inserts this section when it removes a mode whose port is alone on its plane. A shared line getsmode_transmission(). Every parameter is tracked atnetwork.component.<label>.<name>and serializes.- Parameters:
label (str) – Unique component label.
freq (float or array-like) – Mode frequency in GHz.
external_rate (float or array-like) – Coupling rate
κ_eto this line, in 1/ns.internal_rate (float or array-like, default=0.0) – Internal loss rate
κ_iin 1/ns.reference_freq (float or array-like or None, default=None) – Frequency in GHz that selects the square-root branch.
- mode_transmission(label, *, freq, external_rate, internal_rate=0.0)[source]¶
Add a one-pass reference section for a damped linear mode.
Side 1 to side 2 multiplies the field by
S_r(f) = ((κ_i - κ_e)/2 - iΩ) / ((κ_e + κ_i)/2 - iΩ), withΩ = 2π(f - freq). Reverse propagation is transparent. With zero external coupling, the section is transparent at every frequency. The section acts on one leg and stays outside the MarkovianS,L, andH. Its internal-loss bath is vacuum. Continuous-wave APIs evaluate the transfer at each frequency. Transient APIs use its value at the applicable carrier. quchip tracks every parameter atnetwork.component.<label>.<name>, and the section serializes.- Parameters:
- Returns:
Two-sided component with forward transfer and transparent reverse propagation.
- Return type:
SLHComponent
- amplifier(label, *, added_noise, gain=None, gain_db=None)[source]¶
Add a phase-preserving amplifier reference section to an output line.
gainis power gainG.added_noiseis input-referred symmetrized noise in quanta and must be at least(1 - 1/G) / 2. Forward propagation from side 1 to side 2 multiplies field amplitudes bysqrt(G). Reverse propagation is transparent.Place side 1 toward the chip and side 2 toward the exposed output plane. The compiler rejects a section that would amplify an incident field into the chip or put the output plane on side 1. Both parameters are tracked at
network.component.<label>.<name>and remain sweepable and differentiable. Acyclic downstream splitters keep its shared output noise. The section remains outside MarkovianS,L, andHand serializes normally.gain_dbcan replace lineargain. Added quanta are constant across the modeled band and exclude the input’s own noise.- Parameters:
label (str) – Component label.
added_noise (float or array-like) – Input-referred symmetrized added noise in quanta.
gain (float or array-like, optional) – Power gain, specified linearly or in dB. Supply at most one.
gain_db (float or array-like, optional) – Power gain, specified linearly or in dB. Supply at most one.
- circulator(label, *, ports=3)[source]¶
Add an ideal circulator routing side
kto sidek + 1.The highest-numbered side routes back to side 1.
- isolator(label, *, thermal_occupation=None)[source]¶
Add an ideal isolator routing side 1 to side 2.
The reverse field is dumped into
hidden.<label>.load, whose thermal population travels back toward side 1.thermal_occupationis in quanta, constant across the modeled band, and defaults to vacuum.- Parameters:
label (str) – Unique component label.
thermal_occupation (scalar or None, default=None) – Mean hidden-load occupation in quanta.
Nonemeans vacuum.
- termination(label, *, thermal_occupation=None)[source]¶
Add a matched one-sided load with an optional thermal input state.
thermal_occupationis the mean thermal population in quanta, constant across the modeled band, and defaults to vacuum.- Parameters:
label (str) – Unique component label.
thermal_occupation (scalar or None, default=None) – Mean load occupation in quanta.
Nonemeans vacuum.
- connect(output, input)[source]¶
Connect one component output to one component input.
- Parameters:
output (FieldTerminal) – Unused directional terminals from this network.
input (FieldTerminal) – Unused directional terminals from this network.
- link(*items)[source]¶
Link consecutive component ports in both directions.
When a two-sided component is passed directly, the chain enters side 1 and leaves side 2. Pass
component.port(k)to select a side explicitly.- Parameters:
*items (Port, SLHComponent, or ComponentPort) – At least two two-sided endpoints.
- cascade(*items)[source]¶
Connect each item’s output to the next item’s input in sequence.
- Parameters:
*items (Port, SLHComponent, or FieldTerminal) – At least two compatible endpoints.
- expose(label, *, at=None, input=None, output=None)[source]¶
Name and return an external network port.
Pass
at=to expose one component port. Useinput=andoutput=for separate input and output connections. Ports and components then select their sole orsignalterminal unless explicit terminals are passed.- Parameters:
label (str) – Unique external reference-plane label.
at (Port, SLHComponent, ComponentPort, or None, default=None) – Physical side to expose for both directions.
input (FieldTerminal, Port, SLHComponent, or None, default=None) – Separate incoming and outgoing connection points.
output (FieldTerminal, Port, SLHComponent, or None, default=None) – Separate incoming and outgoing connection points.
- validate_for(chip)[source]¶
Validate every quantum port target against a chip.
- Parameters:
chip (Chip) – Chip whose device labels must contain every port target.
- resolve(base, *, _compiled=None, _generated=None)[source]¶
Compose this boundary onto an input-free SLH value.
- Parameters:
base (ResolvedSLH) – Resolved quantum-port channels to compose with the network.
- classmethod from_dict(data)[source]¶
Reconstruct a network produced by
to_dict().- Parameters:
data (mapping) – Serialized network payload.
- restrict(ports)[source]¶
Return an independent sub-network of field-graph components reachable from
ports.Every reachable component is copied with its connections, exposures, tracked parameters, and filter callables. Authored boundary scattering is limited to the kept planes. A reachable subgraph that also touches an unselected port raises, because cutting it would change the SLH dynamics.
- Parameters:
ports (sequence of str or Port) – Quantum coupling ports whose field subgraphs are kept.
- Returns:
An independent network with label-based port targets.
- Return type:
- Raises:
KeyError – A selected port is not part of this network.
ValueError – A reachable subgraph also touches an unselected port, boundary scattering couples kept and dropped planes, or the kept ports hold only part of a retained mode response.
- include(template, *, prefix)[source]¶
Copy a reusable network template into this network under
prefix.Components and connections are copied with labels
prefix/label. Tracked parameters therefore use paths such asnetwork.component.prefix/label.name. Filter callables are kept. The template remains unchanged, so you can include it again under another prefix.The template’s exposures become interfaces rather than host planes. Exposures made with
expose(..., at=...)are available throughside(name). Asymmetric exposures useinput(name)andoutput(name). Wire the returned interfaces withlink(),cascade(), orexpose().- Parameters:
template (PortNetwork) – A network without quantum ports or authored boundary scattering.
prefix (str) – A label prefix for the copied components, unique in this network.
- Returns:
Accessors for the copied components and interfaces.
- Return type:
IncludedNetwork
- Raises:
ValueError – The template owns ports or boundary scattering, or
prefixis already in use.
- dynamical_supports(chip, *, _compiled=None)[source]¶
Return device groups coupled by cascade-generated Hamiltonian terms.
Static scattering alone is excluded, because a unitary mixer changes field coordinates but leaves the summed Lindbladian invariant. Each downstream/upstream coupling pair generated by SLH series composition contributes the union of its two quantum-port supports.
- Parameters:
chip (Chip) – Chip used to resolve port target supports.
- fed_ports(chip, exposure, *, _compiled=None)[source]¶
Return
(port, coefficient)pairs reached fromexposure.Each coefficient combines the scattering entry from the exposure to a channel with that port’s weight in the channel. A coherent input
βtherefore reaches the port coupling asc = coefficient · β.