From differential-algebraic equations to state-space representation#

Binder

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:

\[C \dot{\theta} = -A^T G A \theta + A^T G b + f\]

We want to transform this system of equations into state-space representation:

\[\begin{split}\begin{cases} \dot{\theta}_C = A_s \theta_C + B_s u\\ y = C_s \theta_C + D_s u \end{cases}\end{split}\]

DAE in block matrices#

We write the DAE as:

\[C \dot{\theta} = K \theta + K_b b + f\]

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:

\[\begin{split}\begin{cases} \dot{\theta}_C = A_s \theta_C + B_s u\\ \theta_0 = C_s \theta_C + D_s u \end{cases}\end{split}\]

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:

\[q = G(-A \theta + b)\]

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\):

\[\frac{\theta_{k + 1} - \theta_k}{\Delta t} = f \cdot (A_s \theta_{k+1} + B_s u_{k+1}) + (1 - f) \cdot (A_s \theta_k + B_s u_k)\]

or

\[(I - f \Delta t A) \theta_{k+1} = (I + (1 - f)\Delta t A_s) \theta_k + \Delta t B (f u_{k+1} + (1 - f) u_k)\]

where \(0 \leq f \leq 1\) is a weighing factor between current and future values.

\[ \theta_{k+1} = (I + \Delta t A_s) \theta _k + \Delta t B_s u_k \]
\[\theta_{k+1} = (I - \Delta t A_s)^{-1} ( \theta _k + \Delta t B_s u_{k+1} )\]
\[\theta_{k+1} = (I - 0.5 \Delta t A_s)^{-1} ((I + 0.5 \Delta t A_s) \theta _k + 0.5 \Delta t B_s (u_{k+1} + u_k))\]

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