## 3 Generation of Equations
### Realizability Analysis
#### 3.2.2 Algorithm
\begin{pmatrix}\mathbb{Q}1,\mathrm{b}\mathrm{c}\mathrm{Q}\mathrm{I}, \mathrm{b}\mathrm{e}\mathrm{OUT}&\mathrm{R}1&\mathbb{C}1&\mathrm{V}\mathrm{c} \mathrm{c}\mathrm{i}\mathrm{N}&\mathrm{GRD}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ \hline\vdots&\vdots&\vdots&\vdots&1&\vdots&1&\vdots&N_{1}\\ \vdots&\vdots&\vdots&\vdots&1&\vdots&\vdots&\vdots&N_{2}\\ \vdots&\vdots&\vdots&1&\vdots&\vdots&\vdots&\vdots&N_{3}\\ \vdots&\vdots&\vdots&1&\vdots&1&\vdots&\vdots&N_{4}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&1\\ \end{pmatrix} \;. \tag{16}\]

After step 19, the algorithm concludes that the potential on node \(\mathsf{N}_{1}\) is imposed by edge \(\mathsf{B}_{\mathrm{IN}}\) so that the potential on node \(\mathsf{N}_{2}\) is imposed by the capacitor \(\mathsf{B}_{\mathrm{C1}}\). After step 28, the algorithm concludes that the potential on node \(N_{4}\) is imposed by the edge \(\mathsf{B}_{\mathrm{V}\mathrm{C}}\) so that the resistor is current-controlled (so as to impose the potential on node \(N_{3}\)). \[\Lambda= \left( \begin{array}{cccc|ccccc}\text{Q1,bc}&\text{Q1,be}&\text{OUT}& \text{R1}&\text{C1}&\text{Vcc}&\text{IN}&\text{GRD}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ \hline\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&1&\vdots&N_{1}\\ \vdots&\vdots&\vdots&\vdots&1&\vdots&\vdots&\vdots&N_{2}\\ \vdots&\vdots&\vdots&1&\vdots&\vdots&\vdots&\vdots&N_{3}\\ \vdots&\vdots&\vdots&\vdots&\vdots&1&\vdots&\vdots&N_{4}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&1\\ \end{array} \right)\,. \tag{17}\]

This concludes the realizability analysis. To recover the associated port-Hamiltonian structure, we return to the incidence matrix \(\Gamma\). With the new edges ordering \(\mathsf{B}=\{\mathsf{B}_{1},\mathsf{B}_{2}\}\) prescribed by the above analysis, it is rewritten as

\[\Gamma=\left( \begin{array}{cccc|ccccc}\text{Q1,bc}&\text{Q1,be}&\text{OUT}& \text{R1}&\text{C1}&\text{Vcc}&\text{IN}&\text{GRD}\\ \vdots&\vdots&1&\vdots&\vdots&1&1&1&N_{0}\\ \hline\vdots&\vdots&\vdots&\vdots&1&\vdots&-1&\vdots&N_{1}\\ 1&1&\vdots&\vdots&-1&\vdots&\vdots&\vdots&N_{2}\\ -1&\vdots&-1&1&\vdots&\vdots&\vdots&\vdots&N_{3}\\ \vdots&\vdots&\vdots&-1&\vdots&-1&\vdots&\vdots&N_{4}\\ \vdots&-1&\vdots&\vdots&\vdots&\vdots&\vdots&-1\\ \end{array} \right)\,. \tag{18}\]

Finally, the structure (5) is recovered by computing the matrix \(\gamma=\gamma_{2}^{-1}\cdot\gamma_{1}\) in (11) with

\[\gamma_{1}=\left( \begin{array}{cccc}0&0&0\\ 1&1&0\\ -1&0&-1\\ 0&0&0\\ 0&-1&0\\ \end{array} \right);\quad\gamma_{2}=\left( \begin{array}{cccc}0&1&0&-1&0\\ 0&-1&0&0&0\\ 1&0&0&0&0\\ -1&0&-1&0&0\\ 0&0&0&0&-1\\ \end{array} \right). \tag{19}\]

## 4 Guaranteed-Passive Simulation

This section is devoted to the discrete-time simulation of the algebraic-differential system (5); that is, the computation of \(\mathbf{x}(k)\equiv\mathbf{x}(k\cdot T)\) from \(\mathbf{u}(k)\equiv\mathbf{u}(k\cdot T)\), with \(k\in\mathbb{N}\), for the constant sampling frequency \(f_{s}=1/T\). First, we present the design of a numerical scheme that properly transposes the power balance (1) to the discrete time domain: this choice makes the passivity property preserved, from which stability issues stem. Second, a numerical method is used to solve the implicit equations due to the numerical scheme (on \(\mathbf{x}\)) and the algebraic equations (on \(\mathbf{w}\)). ### Numerical Scheme

To ensure the stable simulation of stable dynamical system \(\frac{\mathrm{d}\mathbf{x}}{\mathrm{d}t}=\mathbf{f}(\mathbf{x})\), many numerical schemes focus on the approximation quality of the time derivative (or integration), combined with operation of the vector field \(\mathbf{f}\). Here, we adopt an alternate point of view, by transposing the power balance (1) into the discrete time-domain to preserve passivity.