Linear circuits: Kirchhoff semantics, modified nodal equations and certified stability #
The component language #
A netlist (Cslib.Electrical.Netlist) has nodes numbered 1, …, nodes, with node 0 the
ground (datum), inputs input ports, and a list of two-terminal branches
(Cslib.Electrical.Branch), each with a positive terminal pos, a negative terminal neg and
an element (Cslib.Electrical.Element). Values are exact rationals in SI units: potentials and
voltages in volts, currents in amperes, time in seconds.
resistor R(ohms),capacitor C(farads),inductor L(henries): linear,R, C, L > 0.voltageSource E input(volts),currentSource J input(amperes): an independent source of constant valueE(J), plus the input signalu_kwheninput = some k.vccs g cp cn(siemens): the branch current isg (φ_cp - φ_cn).vcvs μ cp cn(dimensionless): the branch voltage isμ (φ_cp - φ_cn).
Branch b has voltage v_b = φ_pos - φ_neg, with φ_0 = 0, and current i_b flowing from
pos through the element to neg (passive sign convention); a source supplying power has
v_b i_b < 0. Netlist.check rejects a netlist that names a node above nodes, an input port
at or above inputs, or a nonpositive R, C or L. No other element (diodes, transistors,
switches, mutual inductance, current-controlled sources, nonlinear or time-varying values) is in
the language.
Kirchhoff semantics #
Netlist.IsTrajectoryOn c u φ i s is the semantic definition, on a time set s: node potentials
φ t and branch currents i t such that, at every t ∈ s,
- KCL: the currents leaving each non-ground node through its branches sum to zero;
- KVL, through the potentials: each branch voltage is
φ_pos - φ_neg; - the element laws:
v = R i;v' = i / C(i = C v');i' = v / L(v = L i');v = E + u_k;i = J + u_k;i = g v_c;v = μ v_c.
Only capacitor voltages and inductor currents are required to be differentiable.
Modified nodal equations #
The unknowns are the node potentials followed by all branch currents, z = (φ, i) with
N = nodes + #branches entries (Fin.append). The equations are KCL at each non-ground node
followed by one equation per branch, its element law written with v_b = φ_pos - φ_neg:
E ż = F z + G u + b (Netlist.mna). This is modified nodal analysis with every branch current
kept as an unknown (Hachtel's sparse tableau with the branch voltages eliminated by KVL); the
classical MNA, which eliminates resistor, capacitor, current-source and VCCS currents, is one of
the eliminations that a decoupling certificate may perform. E is singular whenever the circuit
has a branch that is not a capacitor or inductor, and nothing assumes otherwise.
Netlist.isTrajectoryOn_iff proves that the circuit trajectories are exactly the solutions of
the descriptor system: (φ, i) is a trajectory if and only if Fin.append φ i solves
E ż = F z + G u + b.
Certified stability and realizations #
Netlist.isExponentiallyStable_of_decoupling composes the semantics with any index-one
decoupling of the equations, and Netlist.isExponentiallyStable_of_check with the exact checkers of
CslibFrontier.Algorithms.LinearAlgebra.DescriptorCertificate: a well-formed netlist, an
accepted index-one decoupling of its equations, an exactly checked equilibrium z₀ and
exponential stability of the checked reduced matrix (for instance from an accepted dense or
sparse Lyapunov certificate) together prove that
z₀is a circuit trajectory (the DC operating point),- every differential state
x₀(one coordinate per independent capacitor voltage or inductor current, after the decoupling) starts a circuit trajectory, and - every circuit trajectory with zero input converges to
z₀exponentially: all potentials and all branch currents, in the Euclidean norm of the full vector.
The supported class is the circuits whose equations have an index-one decoupling; nothing is claimed for any other circuit. By DAE index theory, loops of capacitors and voltage sources, cutsets of inductors and current sources, inconsistent sources and underdetermined subcircuits have none; this characterization is not proved here, but acceptance implies existence and uniqueness, so a circuit without trajectories, or with fewer than a decoupling would give, has no accepted certificate (the tests prove this for an inconsistent and an index-two circuit). Failure to find a certificate is not an instability proof.
Netlist.isTrajectoryOn_iff_realization gives, for selected output probes
(Cslib.Electrical.Probe: a node-pair voltage or a branch current) and the input ports, the
proper realization ẋ = A x + B u, y - y₀ = C x + D u after the equilibrium shift, on every
time set with unique derivatives and for every input signal, including direct feedthrough D.
No derivative of the input appears; an elimination that would need one has no index-one
decoupling.
Main definitions #
Cslib.Electrical.Element,Cslib.Electrical.Branch,Cslib.Electrical.Netlist,Cslib.Electrical.Probe.Cslib.Electrical.Netlist.check,Cslib.Electrical.Probe.check: well-formedness of a netlist and of a probe (1-based nodes, 0-based branch positions).Cslib.Electrical.Netlist.IsTrajectoryOn: Kirchhoff semantics.Cslib.Electrical.Netlist.eRows,fRows,gRows,bList,probeRows: the rational modified nodal equations, computed by the kernel;Netlist.mnais their real descriptor system.
Main results #
Cslib.Electrical.Netlist.isTrajectoryOn_iff: circuit trajectories are exactly the solutions of the modified nodal equations.Cslib.Electrical.Netlist.probeRows_mulVec: the probe rows compute the probed quantities.Cslib.Electrical.Netlist.isExponentiallyStable_of_decoupling: exponential stability of every trajectory about an operating point, with existence, from any index-one decoupling of the modified nodal equations whose state matrix is exponentially stable.Cslib.Electrical.Netlist.isExponentiallyStable_of_check: its end-to-end certified instance for an acceptedCslib.LinearAlgebra.DecouplingCertand a checked operating point.Cslib.Electrical.Netlist.isTrajectoryOn_iff_realization: the checked proper realization for selected inputs and outputs.
A circuit element. Values are exact rationals in SI units; see the module documentation for the element laws and sign conventions.
- resistor (R : ℚ) : Element
A linear resistor of resistance
Rohms:v = R i. - capacitor (C : ℚ) : Element
A linear capacitor of capacitance
Cfarads:i = C v'. - inductor (L : ℚ) : Element
A linear inductor of inductance
Lhenries:v = L i'. - voltageSource (E : ℚ) (input : Option ℕ) : Element
An independent voltage source
v = E + u_k(volts), withu_k = 0forinput = none. - currentSource (J : ℚ) (input : Option ℕ) : Element
An independent current source
i = J + u_k(amperes). - vccs (g : ℚ) (cp cn : ℕ) : Element
A voltage-controlled current source
i = g (φ_cp - φ_cn),gin siemens. - vcvs (μ : ℚ) (cp cn : ℕ) : Element
A voltage-controlled voltage source
v = μ (φ_cp - φ_cn).
Instances For
An output probe: the voltage φ_p - φ_q, or the current of a branch.
Nodes and branches are indexed differently. Nodes are 1-based: p, q ∈ {0, 1, …, nodes},
with 0 the ground. Branches are 0-based: b ∈ {0, …, branches.length - 1} is the position
of the branch in Netlist.branches. An out-of-range probe evaluates to 0 (Probe.eval,
Netlist.probeRows); Probe.check rejects it.
- voltage (p q : ℕ) : Probe
The voltage
φ_p - φ_qbetween nodespandq(1-based,0is ground). - current (b : ℕ) : Probe
The current of branch
b(0-based position inNetlist.branches).
Well-formedness #
Whether the element's parameters and references are supported for a netlist with n nodes
and m inputs.
Whether every branch refers to existing nodes and inputs and has supported parameters.
The number of unknowns of the modified nodal equations: potentials, then branch currents.
Kirchhoff semantics #
1 if branch br leaves node k, -1 if it enters it, 0 otherwise (or for a self
loop).
Kirchhoff semantics. Node potentials φ and branch currents i form a trajectory of the
circuit with input u on the time set s: KCL holds at every non-ground node and every branch
obeys its element law, with branch voltage φ_pos - φ_neg.
- kcl (t : ℝ) : t ∈ s → ∀ (k : Fin c.nodes), ∑ b : Fin c.branches.length, ↑((c.branches.get b).incidence (↑k + 1)) * i t b = 0
Kirchhoff's current law at node
k + 1. - law (t : ℝ) : t ∈ s → ∀ (b : Fin c.branches.length), Element.Law (fun (τ : ℝ) => potential (φ τ) (c.branches.get b).pos - potential (φ τ) (c.branches.get b).neg) (fun (τ : ℝ) => i τ b) φ u s t (c.branches.get b).elem
The element law of each branch.
Stamps and the modified nodal equations #
The coefficients of an element's equation `d/dt (eV v + eI i) = fV v + fI i + fC v_c + src
- u_input
, withv_c = φ_cp - φ_cn`.
- eV : ℚ
The coefficient of the branch voltage under the derivative.
- eI : ℚ
The coefficient of the branch current under the derivative.
- fV : ℚ
The coefficient of the branch voltage.
- fI : ℚ
The coefficient of the branch current.
- fC : ℚ
The coefficient of the control voltage.
- cp : ℕ
The positive control node.
- cn : ℕ
The negative control node.
- src : ℚ
The constant source value.
The input port added to the source value.
Column j of the row vector of the voltage φ_p - φ_q, with n potential columns.
Column j of the row vector of the current of branch b.
The branch with index b (default beyond the list).
Entry (r, j) of F: -incidence in the KCL rows, the stamp in the branch rows.
The modified nodal equations E ż = F z + G u + b over ℝ.
Row computations #
Element laws as stamped equations #
Circuit trajectories are the solutions of the modified nodal equations. For a
well-formed netlist and a time set with unique derivatives (such as [0, ∞)), potentials φ and
branch currents i form a Kirchhoff trajectory with input u exactly when z = (φ, i) solves
E ż = F z + G u + b.
The probe rows compute the probed quantities.
Exponential stability of a circuit from a decoupling. Let the netlist be well formed, D
an index-one decoupling of its modified nodal equations, z₀ an equilibrium, and ẋ = A x
exponentially stable for the state matrix of D. Then, with zero input, z₀ is a circuit
trajectory, every differential state x₀ (read through D.Q₁') starts a circuit trajectory on
[0, ∞), and every circuit trajectory on [0, ∞) converges to z₀ exponentially in the
Euclidean norm of all potentials and branch currents.
Certified exponential stability of a circuit. Let the netlist be well formed, let d
be an accepted index-one decoupling of its modified nodal equations, z₀ an exactly checked
equilibrium (F z₀ + b = 0), and let ẋ = A x be exponentially stable for the checked reduced
matrix d.A, for instance by an accepted Lyapunov certificate
(Cslib.LinearAlgebra.LyapunovCert.isExponentiallyStable_of_check). Then, with zero input,
- the operating point
z₀ = (φ₀, i₀)is a (constant) circuit trajectory; - every differential state
x₀, read throughQ₁', starts a circuit trajectory on[0, ∞); - every circuit trajectory on
[0, ∞)converges toz₀exponentially: for constantsMandα > 0independent of the trajectory,‖(φ t, i t) - z₀‖ ≤ M exp (-α t) ‖(φ 0, i 0) - z₀‖in the Euclidean norm of all potentials and branch currents.
This is isExponentiallyStable_of_decoupling for DecouplingCert.toDecoupling.
The checked realization of a circuit for the probes probes and its input ports, with the
rational matrices computed from the decoupling d (DecouplingCert.A, reducedB,
outputC and feedthroughD).
Checked proper realization. Let the netlist be well formed, d an accepted decoupling
and z₀ a checked equilibrium. On a time set with unique derivatives (such as [0, ∞)) and for
every input signal u, (φ, i) is a circuit trajectory exactly when
- the vector
z = (φ, i)is reconstructed from the statex = Q₁' (z - z₀)and the input:z = z₀ + Q₁ x - Q₂ P₂ G u, and xsolvesẋ = A x + B uofc.realization d probes.
The probed outputs then satisfy y - y₀ = C x + D u (IsTrajectoryOn.probe_sub_eq).
Output equation. Along a circuit trajectory, the probed outputs differ from their values
at the operating point by C x + D u, where x = Q₁' (z - z₀) is the realization's state.