From differential-algebraic equations to state-space representation#
This demonstration is taken from Ghiaus (2013).
Differential-algebraic equations (DAE)#
Let’s consider the system of differential-algebraic equations (DAE) obtained from a thermal circuit:
We want to transform this system of equations into state-space representation:
DAE in block matrices#
We write the DAE as:
where \(K = -A^T G A\) and \(K_b = A^T G\).
We write this equation in block matrices corresponding to nodes without capacities, \(\theta_0\), and to nodes with capacities, \(\theta_C\):
\(\begin{bmatrix} 0 & 0\\ 0 & C_C \end{bmatrix}\) \(\begin{bmatrix} \dot{\theta}_0\\ \dot{\theta}_C \end{bmatrix}=\) \(\begin{bmatrix} K_{11} & K_{12}\\ K_{21} & K_{22} \end{bmatrix}\) \(\begin{bmatrix} \theta_0\\ \theta_C \end{bmatrix} +\) \(\begin{bmatrix} K_{b1}\\ K_{b2} \end{bmatrix}b +\) \(\begin{bmatrix} I_{11} & 0\\ 0 & I_{22} \end{bmatrix}\) \(\begin{bmatrix} f_0\\ f_C \end{bmatrix}\)
where:
\(C = \begin{bmatrix} 0 & 0\\ 0 & C_C \end{bmatrix}\) - matrix of capacities separated in blocks of capacities equal to zero and capacities different of zero, grouped in the diagonal matrix \(C_C\).
\(K = -A^T G A = \begin{bmatrix} K_{11} & K_{12}\\ K_{21} & K_{22} \end{bmatrix}\)
\(K_b = A^T G = \begin{bmatrix} K_{b1}\\ K_{b2} \end{bmatrix}\)
\(I_{11}\) and \(I_{22}\) are identity matrices of size of \(\theta_0\) and \(\theta_C\),, respectively.
Elimination of nodes without capacities#
By multiplying the first row with \(-K_{21}K_{11}^{-1}\), we obtain:
\(\begin{bmatrix} 0 & 0\\ 0 & C_C \end{bmatrix}\) \(\begin{bmatrix} \dot{\theta}_0\\ \dot{\theta}_C \end{bmatrix}=\) \(\begin{bmatrix} -K_{21} & -K_{21} K_{11}^{-1} K_{12}\\ K_{21} & K_{22} \end{bmatrix}\) \(\begin{bmatrix} \theta_0\\ \theta_C \end{bmatrix}+\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} K_{b1}\\ K_{b2} \end{bmatrix}b +\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} & 0\\ 0 & I_{22} \end{bmatrix}\) \(\begin{bmatrix} f_0\\ f_C \end{bmatrix}\)
By adding the two rows, we obtain:
\(\begin{bmatrix} 0 & C_C \end{bmatrix}\) \(\begin{bmatrix} \dot{\theta}_0\\ \dot{\theta}_C \end{bmatrix} =\) \(\begin{bmatrix} 0 & -K_{21} K_{11}^{-1} K_{12} + K_{22} \end{bmatrix}\) \(\begin{bmatrix} \theta_0\\ \theta_C \end{bmatrix}+\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} K_{b1} + K_{b2} \end{bmatrix}b+\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} & I_{22} \end{bmatrix}\) \(\begin{bmatrix} f_0\\ f_C \end{bmatrix}\)
State-space representation#
Since the matrix \(C_C\) is invertible, the above equation becomes:
\(\dot{\theta}_C = C_C^{—1}\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} K_{12} + K_{22} \end{bmatrix}\theta_C\) + \(C^{-1}(-K_{21} K_{11}^{-1} K_{b1} + K_{b2})b\) + \(\begin{bmatrix} -K_{21} K_{11}^{-1} & I_{22} \end{bmatrix}\) \(\begin{bmatrix} f_0\\ f_C \end{bmatrix}\)
By grouping all sources into a vector of inputs, \(u = \begin{bmatrix} b \\ f_0 \\ f_C \end{bmatrix}\),
we obtain:
\(\dot{\theta}_C = C_C^{—1}\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} K_{12} + K_{22} \end{bmatrix}\theta_C\)+ \(C_C^{-1}\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} K_{b1} + K_{b2} & -K_{21} K_{11}^{-1} & I_{22} \end{bmatrix}\) \(\begin{bmatrix} b\\ f_0\\ f_C \end{bmatrix}\)
which represents the state equation of the state-space representation:
where:
\(A_s= C_C^{—1}[-K_{21} K_{11}^{-1} K_{12} + K_{22}]\)
\(B_s = C_C^{-1}\) \(\begin{bmatrix} -K_{21} K_{11}^{-1} K_{b1} + K_{b2} & -K_{21} K_{11}^{-1} & I_{22} \end{bmatrix}\)
\(C_s = -K_{11}^{-1} K_{12}\)
\(D_s = -K_{11}^{-1} \begin{bmatrix} K_{b1} & I_{11} & 0 \end{bmatrix}\)
\(\theta_C\) - vector of temperatures in nodes with capacities.
\(\theta_0\) - vector of temperatures in nodes without capacities.
\(u = \begin{bmatrix} b \\ f_0 \\ f_C \end{bmatrix}\), vector of inputs, where \(b\) is the vector of temperature sources, \(f_0\) and \(f_C\) are the vector of flow-rate sources in the nodes without capacities and the nodes with capacities, respectively.
After solving for temperatures, the flows can be obtained:
where:
\(\theta = \begin{bmatrix} \theta_0\\ \theta_C \end{bmatrix}\) is the vector of temperatures;
\(A, G, b\) - incidence and conductance matrices and temperature source vector.
The transformation from the system of differential-algebraic equations (DAE) to state-space representation is implemented in the function tc2ss
of module dm4bem
.
Time integration of state equation#
Numerical integration of the state equation is done by finding the value of temperature at time \(t + \Delta t\) given the value at time \(t\):
or
where \(0 \leq f \leq 1\) is a weighing factor between current and future values.
If \(f = 0\), the scheme is Euler explicit:
If \(f = 1\), the scheme is Euler implicit
If \(f = 0.5\), the scheme is Crank-Nicholson’s or trapezoidal rule:
References#
Ghiaus, C. (2013). Causality issue in the heat balance method for calculating the design heating and cooling loads, Energy 50: 292-301, HAL 03605823
C. Ghiaus (2021). Dynamic Models for Energy Control of Smart Homes, in S. Ploix M. Amayri, N. Bouguila (eds.) Towards Energy Smart Homes, Online ISBN: 978-3-030-76477-7, Print ISBN: 978-3-030-76476-0, Springer, pp. 163-198 HAL 03578578