Solver Lab

Four small models, computed right in your browser. They show how a simulation program advances in time steps and why time step, grid and method decide on stability and accuracy.

VICUS Buildings and VICUS Districts solve large systems of coupled differential equations for room air, wall layers, pipe sections and heat exchangers. The principles behind them can be shown with models that have only a few unknowns. Each experiment runs step by step or as an animation; time step, grid and method can be adjusted. The background is explained in the articles How the VICUS Solver works and How the VICUS Solver simulates a heat network.

1Explicit and implicit: a room cooling down

An unheated room loses heat to the outdoor air. With the time constant τ\tau, the ratio of heat storage capacity to heat loss coefficient, its balance reads:

dTdt=−T−Taτ\frac{dT}{dt} = -\frac{T - T_\mathrm{a}}{\tau}

The explicit Euler method evaluates the right-hand side at the known state of the old time level, the implicit method at the still unknown new one:

explicit:Tn+1=Tn−Δtτ (Tn−Ta)implicit:Tn+1=Tn−Δtτ (Tn+1−Ta)\begin{aligned} \text{explicit:}\quad T^{n+1} &= T^n - \frac{\Delta t}{\tau}\,\big(T^n - T_\mathrm{a}\big) \\[4pt] \text{implicit:}\quad T^{n+1} &= T^n - \frac{\Delta t}{\tau}\,\big(T^{n+1} - T_\mathrm{a}\big) \end{aligned}

In the explicit method the distance to the outdoor temperature is multiplied by 1−Δt/τ1 - \Delta t/\tau in every step. If this factor is negative, the solution oscillates; if its magnitude exceeds 1, it grows. In the implicit method the factor is 1/(1+Δt/τ)1/(1 + \Delta t/\tau), which lies between 0 and 1 for any time step.

Try it: Set the time step to 4 h, then to 7 h. At 7 h, switch to “Implicit”.

A room cools down

Time tt
–
Steps
–
numerical TT
–
exact TexT_\text{ex}
–
Δt/τ\Delta t / \tau
–

Unheated room with time constant τ=3 h\tau = 3\,\mathrm{h}, initial temperature 22 °C, outdoor air 5 °C. Dashed: the exact solution T(t)=Ta+(T0−Ta) e−t/τT(t) = T_\mathrm{a} + (T_0 - T_\mathrm{a})\,e^{-t/\tau}; dots: result after each time step.

2Stability limit on a grid: heat conduction through a wall

For the simulation a wall is divided into layers, each layer being one unknown. The explicit method (FTCS) computes grid point ii from its neighbours in the previous time step:

Tin+1=Tin+r (Ti−1n−2 Tin+Ti+1n),r=α ΔtΔx2T_i^{n+1} = T_i^n + r\,\big(T_{i-1}^n - 2\,T_i^n + T_{i+1}^n\big), \qquad r = \frac{\alpha\,\Delta t}{\Delta x^2}

It is stable only for r≤0.5r \le 0.5. Because the grid spacing enters squared, the limit tightens quickly: with 1 cm layers and α=5⋅10−7 m2/s\alpha = 5 \cdot 10^{-7}\,\mathrm{m^2/s} no more than 100 s per step are allowed, with thin layers of highly conductive materials fractions of a second.

The implicit method uses the neighbour values at the new time level. All grid points then depend on each other, and a system of equations has to be solved in every time step; for a single wall it is tridiagonal and can be solved in O(N)O(N) operations. There is no stability limit any more.

Try it: With “Explicit” and 10 grid points, raise the time step from 5 to 10 min. Then, at 5 min, raise the number of grid points to 20.

Heat conduction through a wall

Time tt
–
Steps
–
Grid spacing Δx\Delta x
–
r=α Δt/Δx2r = \alpha\,\Delta t / \Delta x^2
–
Heat flux inside q˙\dot q
–

24 cm masonry with λ=0.8 W/(m K)\lambda = 0.8\,\mathrm{W/(m\,K)} and α=5⋅10−7 m2/s\alpha = 5 \cdot 10^{-7}\,\mathrm{m^2/s}, initially 5 °C throughout. From t=0t = 0 the inside is held at 22 °C, the outside stays at 5 °C. Dashed: the final steady-state profile with q˙=56.7 W/m2\dot q = 56.7\,\mathrm{W/m^2}; the strip below shows the wall in section.

3A heat exchanger in the time domain

For sizing, the steady-state ε-NTU method is usually sufficient. A dynamic simulation instead represents the exchanger as two flow channels exchanging heat through the separating wall and divides both into cells. For cell jj of the hot side, with the heat capacity MhM_\mathrm{h} of the fluid in the cell:

Mh dTh,jdt=C˙h (Th,j−1−Th,j)−UAN (Th,j−Tc,j)M_\mathrm{h}\,\frac{dT_{\mathrm{h},j}}{dt} = \dot C_\mathrm{h}\,\big(T_{\mathrm{h},j-1} - T_{\mathrm{h},j}\big) - \frac{UA}{N}\,\big(T_{\mathrm{h},j} - T_{\mathrm{c},j}\big)

The cold side is built the same way, in counterflow with the opposite flow direction. Once the start-up has settled, the simulation matches the effectiveness of the ε-NTU formula up to the discretisation error, which decreases with the number of cells.

Try it: Set NTU to 6 and switch between counterflow and parallel flow. In parallel flow the cold side can never become warmer than the hot-side outlet.

Heat exchanger in the time domain

Time tt
–
Hot outlet Th,outT_\text{h,out}
–
Cold outlet Tc,outT_\text{c,out}
–
Simulation ε\varepsilon
–
Formula εNTU\varepsilon_\text{NTU}
–

The hot side enters at 70 °C, the cold side at 15 °C; each channel is divided into 24 cells with a residence time of 60 s. The simulated effectiveness is evaluated on the cold side: ε=C˙c (Tc,out−Tc,in) / (C˙min (Th,in−Tc,in))\varepsilon = \dot C_\text{c}\,(T_\text{c,out} - T_\text{c,in}) \,/\, \big(\dot C_\text{min}\,(T_\text{h,in} - T_\text{c,in})\big).

4A temperature front in a pipe

In a heat network a temperature change travels with the flow through the pipes and loses heat to the ground at temperature TGT_\mathrm{G}:

∂T∂t+v ∂T∂x=−β (T−TG)\frac{\partial T}{\partial t} + v\,\frac{\partial T}{\partial x} = -\beta\,\big(T - T_\mathrm{G}\big)

In the upwind scheme each cell is fed by its upstream neighbour. The explicit variant is stable as long as the Courant number CFL=v Δt/Δx\mathrm{CFL} = v\,\Delta t/\Delta x does not exceed 1. Regardless of that, it smears a sharp front, because the heat spreads over a whole cell in every step. In network simulation this affects transport delays: the coarser the pipe is divided, the less sharply the arrival of a temperature change at the consumer is reproduced.

Try it: Set the time step to 2 s (CFL = 1): the front stays sharp. Then try 3 s, and the same with “Implicit”.

Temperature front in a pipe

Time tt
–
Steps
–
CFL=v Δt/Δx\mathrm{CFL} = v\,\Delta t / \Delta x
–
Outlet ToutT_\text{out}
–
exact Tout,exT_\text{out,ex}
–

100 m pipe in 50 cells (Δx=2 m\Delta x = 2\,\mathrm{m}), initially 10 °C. From t=0t = 0 water at 70 °C flows in and loses heat to the 10 °C ground via β\beta. Dashed: the exact solution (plug flow); the strip below shows the pipe.

Further reading

Stay up to date

New features, tutorials and updates delivered to your inbox.