A Dirac structure linking (pH1)–(pH3),
\(\mathcal {D}\;&\subset \; T_z\mathcal {Z}\times T_z^*\mathcal {Z}\,\times \, \mathpzc {F}_\mathcal {R}\times \mathpzc {E}_\mathcal {R}\,\times \, \mathpzc {F}_\mathcal {P}\times \mathpzc {E}_\mathcal {P}.\) 

Definition C.1 [1]}
Consider a finite-dimensional linear space \(\mathpzc {F}\)  with dual \(\mathpzc {E}=\mathpzc {F}^*\) ,
and duality inner product \(\langle \,.,\,.\,\rangle :\mathpzc {F}\times \mathpzc {E}\rightarrow \mathbb {R}\) .
A linear subspace \(\mathcal {D}\subset \mathpzc {F}\times \mathpzc {E}\)  is a Dirac structure if \(\langle \,\mathpzc {f}\hspace{-1.0pt},\,\mathpzc {e}\hspace{0.5pt}\,\rangle = 0\) , for all \((\mathpzc {f}\hspace{-1.0pt},\mathpzc {e}\hspace{0.5pt}) \in \mathcal {D}\) , and \({\rm dim}\, \mathcal {D}= {\rm dim}\, \mathpzc {F}\) .

Here, using the natural identification \((V\times V^{\prime })^* = V^*\times V^{\prime *}\)  for linear spaces \({\hspace{0.2pt}\texttt {V}},V^{\prime }\) , the space on the right of (REF ) is viewed as the product \(\mathpzc {F}\times \mathpzc {E}\)  of
\(\mathpzc {F}&= T_z\mathcal {Z}\times \mathpzc {F}_\mathcal {R}\times \mathpzc {F}_\mathcal {P}\quad \text{and}\quad \mathpzc {E}= \mathpzc {F}^* = T_z^*\mathcal {Z}\times \mathpzc {E}_\mathcal {R}\times \mathpzc {E}_\mathcal {P},{with the inner product}\langle \,\mathpzc {f}\hspace{-1.0pt},\,\mathpzc {e}\hspace{0.5pt}\,\rangle  &= \langle \,(\mathpzc {f}\hspace{-1.0pt}_\mathcal {S},\mathpzc {f}\hspace{-1.0pt}_\mathcal {R},\mathpzc {f}\hspace{-1.0pt}_\mathcal {P}),\,(\mathpzc {e}\hspace{0.5pt}_\mathcal {S},\mathpzc {e}\hspace{0.5pt}_\mathcal {R},\mathpzc {e}\hspace{0.5pt}_\mathcal {P})\,\rangle  =\mathpzc {f}\hspace{-1.0pt}_\mathcal {S}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {S} + \mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {R} + \mathpzc {f}\hspace{-1.0pt}_\mathcal {P}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {P} .\nonumber \) 

The \(\langle \,\mathpzc {f}\hspace{-1.0pt},\,\mathpzc {e}\hspace{0.5pt}\,\rangle = 0\)  in the definition represents the lossless routing of energy between parts of the system.
In the circuit context the Dirac structure is essentially Kirchhoff's laws for a given circuit topology.
That they define lossless routing, is Tellegen's theorem.
Port-Hamiltonian system dynamics
The dynamics of a system is specified by
\(\left(-\dot{z}(t), \frac{\partial \mathcal {H}}{\partial z}(z(t)),\; \mathpzc {f}\hspace{-1.0pt}_\mathcal {R}(t), \mathpzc {e}\hspace{0.5pt}_\mathcal {R}(t),\; \mathpzc {f}\hspace{-1.0pt}_\mathcal {P}(t), \mathpzc {e}\hspace{0.5pt}_\mathcal {P}(t) \right) &\in \mathcal {D}(z(t)), \\(\mathpzc {f}\hspace{-1.0pt}_\mathcal {R}(t), \mathpzc {e}\hspace{0.5pt}_\mathcal {R}(t)) &\in \mathcal {R}(z(t)), \nonumber \) 

for \(t\)  in some real interval.
A DAE that fits this structure—it might actually be an ODE—will be called a port-Hamiltonian DAE (pHDAE).
A key point from the physical modelling angle is that \(\mathcal {H}\)  is an algebraic function of \(z\) —the time derivative \(\dot{z}\)  must not enter—and must include the whole set of variables on which system energy depends (and preferably nothing but them).
Hence we can use the chain rule in the form
\(\dot{\mathcal {H}}(z(t)) = \frac{\partial \mathcal {H}}{\partial z}^(z(t))\;\dot{z}(t) = -\mathpzc {f}\hspace{-1.0pt}_\mathcal {S}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {S},\) 

the second equality because from (REF ), \(-\dot{z}\)  is identified with \(\mathpzc {f}\hspace{-1.0pt}_\mathcal {S}\) , and \(\partial \mathcal {H}/\partial z\)  with \(\mathpzc {e}\hspace{0.5pt}_\mathcal {S}\) .
The Dirac structure enforces the power balance equation
\(\mathpzc {f}\hspace{-1.0pt}_\mathcal {S}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {S} + \mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {R} + \mathpzc {f}\hspace{-1.0pt}_\mathcal {P}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {P} = 0\) 
and thus the DAE records energy flow: any solution of (REF ) satisfies
\(\dot{\mathcal {H}}= \mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {R} + \mathpzc {f}\hspace{-1.0pt}_\mathcal {P}\mathop {\cdot }\mathpzc {e}\hspace{0.5pt}_\mathcal {P}.\) 

In particular, energy is conserved if there is no dissipation or external power flow.
Nothing is said about what variables occur in a pHDAE.
It will have the first order form \(f(t,x(t),\dot{x}(t)) = 0\) , where vector \(x(t)\) , the DAE variables, contains the state variables \(z(t)\in \mathcal {Z}\)  as a subvector.
What the remaining \(x_i\)  are, depends on the scenarios chosen to specify the dissipative structure (REF ) and the external port behaviour.

Positive definiteness and passivity results
Matrix positive definiteness
We cite without proof some results on positive definite matrices or matrix pairs that are standard, e.g. [2]}, [3]}, and prove some that are special to this paper. The facts about matrix pairs are present, but not so directly stated, in [4]}.
Definition D.1  
A matrix \(A\in \mathbb {R}^{n\times n}\)  is said to be positive definite (PD) if \(x^A̰x>0\)  for all \(x\in \mathbb {R}^n\setminus \lbrace 0\rbrace \) .
A pair of matrices \((B,B^{\prime })\) , \(B,B^{\prime }\in \mathbb {R}^{n\times n}\)  is called a positive definite matrix pair (PDMP) (resp. negative definite matrix pair (NDMP)) if for all \(y,y^{\prime }\in \mathbb {R}^n\)  not both 0, and \(By+B^{\prime }y^{\prime }=0\) , it holds that \(y^y̰^{\prime }>0\)  (resp. \(y^y̰^{\prime }<0\) ).

Note that positive definiteness of a matrix \(A\)  does not imply that \(A\)  is symmetric.
Lemma D.2  
Let \(A\in \mathbb {R}^{n\times n}\) .
[(i)]
If \(A\)  is PD, then \(A\)  is nonsingular, and \(A^{-1}\)  is PD.

\(A\)  is PD iff its symmetric part \((A+A^/2\)  is PD.

If \(A\)  is PD and \(\tilde{A}=-\tilde{A}^ is skew-symmetric, then \) A+A\( is PD.\)
Lemma D.3  
Let \((B,B^{\prime })\)  with \(B,B^{\prime }\in \mathbb {R}^{n\times n}\)  be a PDMP (resp. NDMP). Then
[(i)]
\((B^{\prime },B)\)  is a PDMP (resp. NDMP);

\(B\)  and \(B^{\prime }\)  are nonsingular and \(-B^{-1}B^{\prime }\) , \(-{B^{\prime }}^{-1}B\)  are PD (resp. \(B^{-1}B^{\prime }\) , \({B^{\prime }}^{-1}B\)  are PD);

\((PBQ,PB^{\prime }Q)\)  is a PDMP (resp. NDMP) for \(P,Q\in \mathbb {R}^{n\times n}\)  with \(P\)  nonsingular, \(Q\)  orthogonal.

\([C,C^{\prime }] = [B,B^{\prime }]\;P\)  is a PDMP (resp. NDMP), where \(P\)  is a permutation matrix as in (REF ), i.e., \((C,C^{\prime })\)  results from swapping any given set of columns of \(B\)  with the corresponding columns of \(B^{\prime }\) .
We prove the results for PDMP \((B,B^{\prime })\) .
[(i)]

Follows immediately from \({y^{\prime }}^y̰=y^y̰^{\prime }\) .

Suppose \(B\)  is singular, so there exists \(y\ne 0\)  with \(By=0\) . Setting \(y^{\prime }=0\)  gives \(By+B^{\prime }y^{\prime }=0\)  with \(y,y^{\prime }\)  not both 0, but \(y^y̰^{\prime }=0\) , contradicting the definition of a PDMP.
For the second part let \(A=-B^{-1}B^{\prime }\) . For any \(y^{\prime }\ne 0\) , set \(y=-B^{-1}B^{\prime }y^{\prime }\) .
Then \(y,y^{\prime }\)  are not both 0 and \(By+B^{\prime }y^{\prime }=0\)  so \(0<{y^{\prime }}^y̰ = -{y^{\prime }}^B̰^{-1}B^{\prime }y^{\prime } = {y^{\prime }}^A̰y^{\prime }\) . Hence \(A\)  is PD.

Let \((C,C^{\prime })=(PBQ,PB^{\prime }Q)\)  with \(P,Q\)  be as stated.
For any \(y,y^{\prime }\) , not both 0, suppose that \(0 = Cy+C^{\prime }y^{\prime } = P(Bz + B^{\prime }z^{\prime })\)  where \(z=Qy\) , \(z^{\prime }=Qy^{\prime }\) . Since \(P\)  and \(Q\)  are nonsingular, \(z,z^{\prime }\)  are not both 0 and \(Bz + B^{\prime }z^{\prime }=0\) .
As \((B,B^{\prime })\)  is a PDMP, we have \(0<z^z̰^{\prime } = y^Q̰^Q̰y^{\prime }=y^y̰^{\prime }\)  since \(Q\)  is orthogonal.
Since \(y,y^{\prime }\)  were arbitrary this shows \((C,C^{\prime })\)  that is a PDMP.

Let \(y,y^{\prime }\in \mathbb {R}^n\) , not both 0, satisfy \(Cy+Cy^{\prime }=0\) .
Defining \([w;w^{\prime }]=P_\beta [y;y^{\prime }]\) , we have \(Bw+B^{\prime }w^{\prime } = Cy+C^{\prime }y^{\prime }=0\) , with \(w,w^{\prime }\)  not both 0. So \(w^w̰^{\prime }>0\)  as \((B,B^{\prime })\)  is a PDMP.
By (REF ) it holds that \(w^w̰^{\prime }=y^y̰^{\prime }\)  (as \(w_jw_j^{\prime }\)  is replaced by \(w_j^{\prime }w_j\)  for each \(j\)  where a swap was done, but the sum stays the same).
Hence \(y^y̰^{\prime }>0\) , which proves \((C,C^{\prime })\)  is a PDMP.
Lemma D.4 
Let \(B,B^{\prime }\in \mathbb {R}^{n\times n}\) .
If \(B\)  is nonsingular and \(B^{-1}B^{\prime }\)  is PD then \((B,B^{\prime })\)  is a NDMP. In particular \(A\in \mathbb {R}^{n\times n}\)  is PD if and only if \((I,A)\)  is a NDMP.

Follows directly from the previous lemma.
Lemma D.5 
If \(M = \begin{bmatrix}M_{11} &M_{12} \\M_{21} &M_{22}\end{bmatrix}\begin{matrix}\mbox{\footnotesize $n$}_1 \\\mbox{\footnotesize $n$}_2\end{matrix}\)  is PD, then
\( P = \begin{bmatrix}M_{11} - N^M̰_{21}, &M_{12} - N^M̰_{22} \\N, &I\end{bmatrix} \) 

is nonsingular for an arbitrary \(n_2\times n_1\)  matrix \(N\) .

Take any \(w = [u;v]\)  and suppose \(Pw=0\) , so
\(0 &= (M_{11} - N^M̰_{21})u + (M_{12} - N^M̰_{22})v,\qquad 0 = Nu + v{Premultiply the first equation by u^ and substitute -Nu = v given by the second equation:}0 &= u^M̰_{11}u - u^N̰^M̰_{21}u + u^M̰_{12}v - u^N̰^M̰_{22}v \\&= u^M̰_{11}u + v^M̰_{21}u + u^M̰_{12}v + v^M̰_{22}v \qquad = w^M̰ w,\) 

so \(w=0\)  by the PD assumption, proving \(P\)  is nonsingular.
Lemma D.6 
Let \(C,C^{\prime },S\in \mathbb {R}^{n\times n}\) . If \((C,C^{\prime })\)  is a PDMP and \(S=-S^, then \) M =I S
C C'\( is nonsingular.\) 

Suppose \(z = \begin{bmatrix}x\\y\end{bmatrix}\)  with \(Mz = 0\) .
So \(x + Sy = 0\) , hence \(y^x̰ = y^-Sy)) = -y^S̰y = 0\)  since \(S\)  is skew-symmetric.
Also \(Cx + C^{\prime }y = 0\) , so as \((C,C^{\prime })\)  is a PDMP we have \(x = y = 0\) , i.e. \(z = 0\) . Hence \(M\)  is nonsingular.
Passivity results
There are various notions of passivity used in the literature. For a discussion of different definitions we refer to [5]}.
Most generally, a system is passive if it can either absorb or store energy, but cannot create energy within itself.
Passivity can be characterized by a dissipation inequality [6]}.
For port-Hamiltonian systems, passivity directly follows from the power-balance.
A port-Hamiltonian system is called passive (with respect to the port variables \(\mathpzc {f}\hspace{-1.0pt}_\mathcal {P},\mathpzc {e}\hspace{0.5pt}_\mathcal {P}\)  and storage function \(\mathcal {H}\) ) if
\(\mathcal {H}(z(t_1))-\mathcal {H}(z(t_0))\le \int _{t_0}^{t_1} \mathpzc {e}\hspace{0.5pt}_\mathcal {P}^_\mathcal {P}\, dt\) 
for all time instants \(t_0\le t_1\) .
Hence, a passive system cannot store more energy in its storage function \(\mathcal {H}\)  than it is supplied with.
We also need the concept of passivity for the dissipative structure \(\mathcal {R}\)  described by a relation \(r(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}},\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}})=0\) .
Definition D.7 [7]}
The resistive structure \(\mathcal {R}\)  is called passive [strictly passive] if \(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\mathop {\cdot }\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}} \ge 0\)  [resp. \(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\mathop {\cdot }\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}} > 0\) , except at the origin] for all consistent \((\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}, \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}})\) .

Definition D.8 [8]}, [4]}
Assume that there exist a disjoint union \(\alpha \stackrel{\cdot }{\smash{\cup }}\beta ={\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\)  such that
\(\left.\left(\left[\frac{\partial r}{\partial \iota _{\alpha }},\frac{\partial r}{\partial \nu _{\beta }}\right]\right)\right|_{(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}^*,\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}^*)}\qquad \text{is nonsingular}\) 

at a given consistent \((\iota ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}},\nu ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}})\) .
The resistive structure is called strictly locally passive at \((\iota ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}, \nu ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}})\) if
\(D_{\cal R}:=-\begin{bmatrix}\frac{\partial r}{\partial \nu _{\alpha }}&\frac{\partial r}{\partial \iota _{\beta }}\end{bmatrix}^{-1}\cdot \begin{bmatrix}\frac{\partial r}{\partial \iota _{\alpha }}&\frac{\partial r}{\partial \nu _{\beta }}\end{bmatrix}.\) 

is positive definite at \((\iota ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}, \nu ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}})\) .
The resistive structure \(\mathcal {R}\)  is called strictly
locally passive if \(D_{\cal R}\)  is positive definite for all consistent \((\iota ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}, \nu ^*_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}})\) .

Strict local passivity implies local passivity, the converse is not true.
Also passive components need not to be strictly locally passive as the following example shows.
Example 7 
The ideal transformer can be described by the relation
\( \begin{bmatrix}\nu _1\\\iota _2\end{bmatrix}=\begin{bmatrix}0&k\\-k&0\end{bmatrix}\begin{bmatrix}\iota _1\\\nu _2\end{bmatrix},\quad \text{where $k\in \mathbb {R}$ is the turns ratio}, \) 
see e.g. [10]}.
This resistive structure is passive, since
\(\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\mathop {\cdot }\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}=\nu _1\iota _1+\nu _2\iota _2=k\nu _2\iota _1-k\nu _2\iota _1=0,\) 
but not strictly locally passive as (A5) is not satisfied.

From [4]} it follows that the positive definiteness of \(D_{\cal R}\)  in Definition REF  does not depend on the specific subsets \(\alpha ,\beta \) . In particular, in a strictly passive circuit one can choose arbitrarily the voltages or currents in every dissipative edge as a variable for a mixed description (REF ).
Defining
\(\bar{E}:=\frac{\partial r}{\partial \iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}}(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}^*, \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}^*), \text{ and } \bar{D}:=\frac{\partial r}{\partial \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}}(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}^*, \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}^*)\) 
strict local passivity implies that the incremental conductance and resistance matrices
\(\bar{G}:=-\bar{E}^{-1}\bar{D} \quad \text{and}\quad \bar{R}:= -\bar{D}^{-1}\bar{E}\) 

are well-defined and positive definite (cf. [4]}).
In the linear setting (A5) reads
\(D \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}+ E \iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}= 0\qquad \text{for some }D,E\in \mathbb {R}^{n_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\times n_{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}}\) 

with positive definite pair \((D,E)\)  so that \(G=-E^{-1}D\)  (or equivalently \(R:= -D^{-1}E\) ) are positive definite.
Note that in the linear setting these properties are globally defined.
Within the port-Hamiltonian setting, the dissipative structure is defined by \(\mathcal {R}\subset \mathpzc {F}_\mathcal {R}\times \mathpzc {E}_\mathcal {R}\)  with \(\mathpzc {e}\hspace{0.5pt}_\mathcal {R}\mathop {\cdot }\mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\le 0\) .
Non-negativity of the dissipative power flow \(\mathpzc {e}\hspace{0.5pt}_\mathcal {R}\mathop {\cdot }\mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\)  respects the common convention that power flows from the “boundary” ports (i.e. ports related to \(\mathcal {P}\)  and \(\mathcal {R}\) ) into the system and from the internal network (the Dirac structure) into the energy storing elements \(\mathcal {S}\) , such that in the power balance equation all flows sum up to zero.
Here, it means the power flows from the energy-dissipating elements into the Dirac structure \(\mathcal {D}\)  (cf. [13]}).
By defining \(\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}=\mathpzc {e}\hspace{0.5pt}_\mathcal {R}\)  and \(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}=-\mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\)  this setting corresponds to the sign convention in circuit analysis and in the definition of strict local passivity (e.g. the positive definiteness of conductance and resistance matrices) and
\(\mathpzc {e}\hspace{0.5pt}_\mathcal {R}\mathop {\cdot } \mathpzc {f}\hspace{-1.0pt}_\mathcal {R}\le 0 \quad \Longleftrightarrow \quad \iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\mathop {\cdot }\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\ge 0. \) 
Using e.g. the voltage-controlled representation of resistors \(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}= \bar{G} \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\)  this gives
\(\iota _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\mathop {\cdot }\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}} =\nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\mathop {\cdot } \bar{G} \nu _{\hspace{0.2pt}{\hspace{0.2pt}\texttt {D}}}\ge 0\quad \Longleftrightarrow \quad \bar{G}\ge 0,\) 
i.e., the resistor is passive iff \(\bar{G}\)  is positive definite.

Matlab code
Below are the Matlab functions for the circuit in Example REF  and for the Diode Clipper example generated from the CpH class, both in Model 2 form. They can be used by Matlab's [basicstyle=]ode15i solver.
flexiblefalse0truesolarized@cyansolarized@bluesolarized@redsolarized@base01solarized@base2falsefalse%@trueutf8trueφ1
numbers=left]code/daefcnExample1mm.m
flexiblefalse0truesolarized@cyansolarized@bluesolarized@redsolarized@base01solarized@base2falsefalse%@trueutf8trueφ1
numbers=left]code/daefcnDiodeClippermm.m
