Automatic circuit equation formulation for non-smooth electrical circuits Vincent Acary, Olivier Bonnefon, Pascal Denoyelle INRIA Rhône-Alpes February 07, 2008 Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 1 / 20 1 Basics on circuit topology 2 Modified Nodal Analysis 3 MNA and DAE 4 Piecewise Linear modeling 5 Extend MNA for non-smooth components 6 MLCS and MLCP 7 Cost of the automatic equation formulation 8 Simulation 9 Conclusion Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 2 / 20 Basics on circuit topology Circuit branch Vk Ia Ua Vj Figure: Basic branch A branch is described by a pair of branch variables: the tension Ua and the current Ia . Moreover, the Branch Constitutive Equation can be expressed in a general implicit form: F (Ua , Ia , dUa dIa , , ...) = 0 dt dt (1) Some examples with a resistor, a capacitor and a current source: Ua = RIa Ia = C dUa dt Ia = αUb We will see the different forms of this relation. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 3 / 20 Basics on circuit topology The Kirchhoff Current Law (KCL) At any node in an electrical circuit where charge density is not changing in time, the sum of currents flowing towards that node is equal to the sum of currents flowing away from that node. I3 1 V1 2 V2 L3 I2 I1 I4 R4 C2 I1 V0 0 With this example −I1 + I2 + I3 = 0 −I3 + I4 = 0 I1 − I2 − I4 = 0 (KCL1) (KCL2) (KCL0) or the matrix formulation : AI = 0 where A is known as the incidence matrix and I is the vector of branch currents. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 4 / 20 Basics on circuit topology The Kirchhoff Voltage Law (KVL) The directed sum of the electrical differences around a closed circuit must be zero. I3 1 V1 2 V2 L3 I2 I1 I4 R4 C2 I1 V0 0 With this example U1 + U2 = 0 −U2 + U3 + U4 = 0 U1 + U3 + U4 = 0 or the matrix formulation : BU = 0 where B is known as the loop matrix and U is the vector of branch tensions. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 5 / 20 Basics on circuit topology Relation between A and B BAt = 0 Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 6 / 20 Basics on circuit topology Relation between A and B BAt = 0 Proof: 0 B B =B @ 0 1 b1 . C C . A bnl B A=B @ 1 KCL1 C . C A . KCLnn Let p ∈ {1, nl } and q ∈ {1, nn }. We proof that bp .KCLtq = 0. q q j 1 2 The node The node q q k j k is not on the loop p , then bp and KCLq have no common non null coordinate. is on the loop p : bp = (...1... − 1...) KCLq = (...1...1...) The other coordinates are not simultaneous not null. Therefore : bp .KCLtq = 0 Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 6 / 20 Basics on circuit topology An other KVL formulation kp jp Up It consists in writing : ∀p ∈ {1, nb } Up = Vjp − Vkp This system of equation implies BU=0. The matrix formulation is: U − At V = 0 where V is the vector of nodes potential and U the vector of branches tensions. ⇒ In further consideration, BU=0 is eliminated. Example: U1 = V1 − V0 U3 = V2 − V1 Automatic circuit equation formulation for non-smooth electrical circuits U2 = V0 − V1 U4 = V0 − V2 February 07, 2008 7 / 20 Basics on circuit topology The Sparse Tableau Approach STA leads to the following system: AI = 0 (KCL) t U−A V =0 (KVL) F (Ua , Ia , ...) = 0 For all branches : (BCE ) Example: UL UC V1 IL L C IC The vector of unknowns: (IL , IC , UL , UC , V1 )t −IL + IC = 0 UL + V1 = 0 CUC′ (KCL1) UC − V1 = 0 (KVL) LIL′ (BCE ) − IC = 0 Automatic circuit equation formulation for non-smooth electrical circuits − UL = 0 February 07, 2008 8 / 20 Modified Nodal Analysis A Current-Defined Branch (CD) The branch is current-defined if its current is a function of its own voltage, controlling variable or their time–derivatives: dUa dUb dIc Ia = Fi (Ua , Ub , Ic , , , ) (2) dt dt dt A Voltage-Defined Branch (VD) The branch is voltage-defined if its voltage is a function of its own current, controlling variable or their derivatives: dIa dUb dIc Ua = Fu (Ia , Ub , Ic , , , ) (3) dt dt dt Examples : A resistor is a voltage-defined branch because Ua = RIa . A inductor is a voltage-defined branch because Ua = L dIdta . a . A capacitor is a current-defined branch because Ia = C dU dt MNA Hypothesis: The M.N.A. assumes that smooth branches are explicit functions of current or voltage. It means each branch is either Voltage Defined or Current Defined. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 9 / 20 Modified Nodal Analysis MNA unknowns The vector of unknowns contains: All node potentials Vi Currents through all voltage defined branches The following equations are written: The KCL is applied to every node. The Branch Constitutive Equation for all voltage defined branches. Example: UL IL UC V1 L C IC The vector of unknowns is :(V1 , IL )t CV1′ − IL = 0 Automatic circuit equation formulation for non-smooth electrical circuits LIL′ + V1 = 0 February 07, 2008 10 / 20 MNA and DAE MNA and DAE MNA leads to a DAE of the form: C (X )X ′ + J(X ) − S(t) = 0 With C(X) describing the dynamic elements. J(X) describing the static ones. S(t) describing the independent sources. Index of the DAE : 0,1,2. In SPICE,the discretization of this equation is linearized and solved using the Newton-Raphson iterations. But, the non-smooth components such as diodes or transistors, result in troubles in this iterative method. A novel approach is to model this components with piecewise linear function and to formulate the problem as a Complementary Problem. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 11 / 20 Piecewise Linear modeling Ideal Diode Branch Constitutive Equation of the diode: Id = Is (exp (−UD /C ) − 1) The complementary formulation: 0 6 Id ⊥ −UD > 0 Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 12 / 20 Piecewise Linear modeling Ideal Transistor The complementary formulation: Id = ` ... 0 ´ λ Id = −Is 1 Vd Y = A @ Vg A + I λ + C Vs c1 c10 0 6Y ⊥ λ >0 Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 13 / 20 Extend MNA for non-smooth components Extended MNA It consists in replacing the Constitutive Equation of the non-smooth branch with the complementary formulation. Unknowns Before go ahead, the unknowns vector X is decomposed in: x which contains only the dynamic unknowns(currents in inductor and tensions from capacitor branches) Zs which contains only the non dynamic unknowns(Voltage nodes,... ). A good choice of unknowns yields the following system: x ′ = A2x x + A2zs Zs + Rλ + A2s (4) 0 = B2x x + B2zs Zs + B2λ λ + B2s (5) Y = D2x x + D2zs Zs + D2λ λ + D2s (6) 06Y ⊥ λ >0 (7) Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 14 / 20 MLCS and MLCP Mixed Linear Complementary System Given the matrices Ax ∈ Rn×n , Az ∈ Rn×p , Av ∈ Rn×m , Bx ∈ Rp×n , Bz ∈ Rp×p , Bv ∈ Rp×m , Cx ∈ Rm×n , Cz ∈ Rm×p ,Cv ∈ Rm×m , and the vectors a ∈ Rn ,b ∈ Rp ,c ∈ Rm , the explicit MLCS denoted by EMLCS(Ax , Az , Av , Bx , Bz , Bv , Cx , Cz , Cv , a, b, c) consists in finding three vectors x ∈ Rn , z ∈ Rp and v ∈ Rm such that 8 ′ x = Ax x + Az z + Av v + a > > > <0 = B x + B z + B v + b x z v . (8) > > > : 0 ≤ v ⊥ Cx x + Cz z + Cv v + c ≥ 0 The time discretization of a MLCS leads to : Mixed Linear Complementary Problem Given the matrices A ∈ Rn×n , B ∈ Rm×m , C ∈ Rn×m , D ∈ Rm×n , and the vectors a ∈ Rn , b ∈ Rm , the MLCP denoted by MLCP(A, B, C , D, a, b) consists in finding two vectors u ∈ Rn and v ∈ Rm such that 8 > <Au + Cv + a = 0 . (9) > : 0 ≤ v ⊥ Du + Bv + b ≥ 0 At each step, SICONOS solves a MLCP. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 15 / 20 Cost of the automatic equation formulation Cost evaluation Let Nb the number of branches. Nn the number of nodes. N = max{Nb , Nn } The costs of the automatic circuit equation formulation: To parse the Netlist : It consists in reading and storing the Netlist. O(N). A topological analysis to build the unknowns vector: The Minimum Spanning Tree algorithm complexity is O(Nlog(N)) Stamping method: Each component writes its contribution in the table equation. O(N). Matrix product: Multiplied two dense matrices costs O(N 3 ). Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 16 / 20 Simulation Diodes Bridge N1 4 5 7 6 N2 N3 2 3 N0 10 ’DiodeBridge.traj’ 8 U23 6 4 2 0 0 50 100 150 200 250 300 350 400 450 time e-5 s Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 17 / 20 Simulation Buck converter 3 Vramp 9 comparator Verror − 4 i2 10 $A$ C21 R21 − 6 7 5 C11 8 R11 L i1 VI R12 + 1 i3 Vref ampli 2 + Vgate C i4 Rload 0 0.1 0 Inductor current -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 0 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 1.8e-4 2e-4 time s Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 18 / 20 Conclusion Conclusions Software aspects The actual software version is able to parse and simulate a Netlist composed of: Non constant sources. Linear components : resistor, capacitor, inductance. Non smooth components : diode, MOS transistor, comparator. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 19 / 20 Conclusion Conclusions Software aspects The actual software version is able to parse and simulate a Netlist composed of: Non constant sources. Linear components : resistor, capacitor, inductance. Non smooth components : diode, MOS transistor, comparator. Theoritical aspects Formulation of nonsmooth circuits in MLCS New algorithms in Siconos/Numerics for MLCP Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 19 / 20 Conclusion Perspectives Software Aspects Forecast active set: use a local piecewise linear approximation to solve a smaller MLCP. Integration of the nonlinear SPICE component: MNCP solvers. Integration of piecewise smooth model of MOS transistor Specific electrical heuristics. Improve the component model. Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 20 / 20 Conclusion Perspectives Software Aspects Forecast active set: use a local piecewise linear approximation to solve a smaller MLCP. Integration of the nonlinear SPICE component: MNCP solvers. Integration of piecewise smooth model of MOS transistor Specific electrical heuristics. Improve the component model. Theoritical Aspects Topological analysis for the index reduction of the DAE and the relative degree of the EMLCS Topological analysis to reduce the number of unknowns. Multi–grid algorithm: use a set of embedded piecewise linear approximation (from coarser to finer). Other Algorithms for MLCP and MNCP (Nonsmooth Newton methods and Projection methods for VI) Adaptive time–stepping scheme Automatic circuit equation formulation for non-smooth electrical circuits February 07, 2008 20 / 20