VICUS Solver: the Engine Behind Heat Network Simulation

How does a solver compute the thermo-hydraulic simulation of a district heating network? From the network graph via the coupling of hydraulics and thermal transport, CVODE and Newton iteration to the sparse linear system — clearly explained.

Table of Contents

Every thermo-hydraulic simulation stands or falls with its computational core, the piece of software that turns network topology, pipe data, load profiles and control logic into a physically reliable pressure, mass-flow and temperature history. In VICUS Districts this core is the VICUS Solver, a simulation solver matured over more than 20 years of research at TU Dresden — the same core that powers VICUS Buildings. This article lifts the hood for the district heating case: step by step it shows how the solver describes a network as a system of equations and integrates it through time.

You do not need a numerics degree for this. The central idea fits in a single sentence, and the interactive demos below can be „cranked through” yourself.

The core idea in one sentence

The solver describes the heat network as a graph of nodes and edges and solves two tightly coupled subproblems on it: the hydraulics — which pressures and mass flows establish themselves? — and the heat transport — how do the temperatures travel through the network? The heart of it is always the same question:

„How fast is the stored energy changing in every fluid volume of the network?”

Once you know this rate of change, you can take a small step into the future, compute the new temperatures and start over. In vector notation, exactly how the time integrator „sees” it, this reads:

dydt=ydot(t,y)\frac{d\mathbf{y}}{dt} = \texttt{ydot}(t,\,\mathbf{y})

Here y\mathbf{y} is the state vector (a long list of all conserved quantities), ydot\texttt{ydot} their rate of change and tt the time.

The network as a graph

The basis of every calculation is the network topology as a graph: nodes are branching and connection points, edges are the network elements — pipes, pumps, valves, the heat exchangers of the transfer stations, producers. Every element brings two models: a hydraulic one (which pressure difference establishes itself at which mass flow?) and a thermal one (what happens to the temperature of the fluid passing through?).

This separation is not a side note but the central architectural decision of the solver — because the two subproblems live on fundamentally different time scales.

Two subproblems: fast hydraulics, sluggish thermal transport

The hydraulics: steady-state and algebraic

Pressure waves propagate through nearly incompressible water at the speed of sound. From the perspective of the slowly travelling temperatures, the flow field therefore establishes itself instantly. That is why the hydraulics are not integrated over time but solved as a steady-state, algebraic system of equations in every evaluation:

  • Mass conservation at every node ii (Kirchhoff’s first law): km˙i,k=0\sum_k \dot{m}_{i,k} = 0
  • Pressure loss per element, e.g. for pipes according to Colebrook-White — depending on mass flow and temperature, since the density and viscosity of the fluid change with it (see pressure loss calculation)

This nonlinear system is solved with the Newton-Raphson method. Bidirectional flows — the flow direction reverses, for instance with decentralised feed-in — are automatically included, because the pressure-loss equation is formulated sign-correctly.

The thermal transport: dynamic and time-dependent

Temperatures change comparatively slowly: the fluid stores energy, and a temperature wave takes minutes to hours to travel through the network, depending on flow velocity. Heat transport is therefore formulated as a system of ordinary differential equations — the energy balance of every fluid volume kk:

CkdTkdt=H˙in,kH˙out,kQ˙loss,kC_k \cdot \frac{dT_k}{dt} = \dot{H}_{\text{in},k} - \dot{H}_{\text{out},k} - \dot{Q}_{\text{loss},k}

with the enthalpy flows H˙=m˙cT\dot H = \dot m \, c \, T and the heat loss to the ground Q˙loss,k=UA(TkTground)\dot{Q}_{\text{loss},k} = UA \cdot (T_k - T_\text{ground}).

Why not put everything into one single large system of equations? That is the route of generic solvers (e.g. in Modelica): one monolithic Jacobian with many direct dependencies. The VICUS Solver takes the considerably more performant second route: the hydraulic system is solved as a separate subproblem within the thermal calculation — two smaller, specialised systems of equations instead of one large one.

Energy instead of temperature: the conserved quantity

As in the building case, the solver does not balance temperature directly but the stored energy — because energy is a conserved quantity whose inflows and outflows can be summed unambiguously. Temperature is a quantity derived from it.

What is in the state vector y?

Part of the y vectorMeaning
Pipe segmentsenergy (mass × specific enthalpy) per finite-volume segment of a pipe
Components with fluid volumeheat exchangers, storage tanks, producer circuits
Groundtemperatures of the coupled ground model (for cold district heating)

The dynamic pipe model splits every pipe into segments so that the propagation of temperature waves is captured correctly; each segment is a separate entry in y. The thermal capacity of the pipe wall is attributed to the fluid via a lumped model — the inertia is correct without an additional computational grid for the pipe wall. For large networks this quickly amounts to thousands of unknowns.

Where does ydot come from? The balance, not a guess

The recipe is the same as for every conservation law:

  1. Choose the conserved quantity y (energy, mass, …), not the temperature.
  2. Write the balance: d(stored)/dt = Σ inflows − Σ outflows.
  3. Express each flux through the state (physical laws).
  4. Solve for dy/dt; that is ydot.

Example: a pipe segment

A segment kk with fluid mass MM and heat capacity cc is passed by the mass flow m˙\dot m and loses heat to the ground:

McdTkdt=m˙c(Tk1Tk)    UA(TkTground)M\,c\,\frac{dT_k}{dt} = \dot m\,c\,\bigl(T_{k-1} - T_k\bigr) \;-\; UA\,\bigl(T_k - T_\text{ground}\bigr)

On the left the change in storage, on the right advection (the warm fluid from the previous segment) minus loss. Solved for dTk/dtdT_k/dt, this is the ydot for this segment — derived from energy conservation plus flux laws, not invented. Chaining many segments together produces exactly the model that runs in the live demo below: a temperature front travelling along a pipe split into 50 segments.

The runtime evaluation — hydraulics included

There is no closed ydot formula sheet in the network case either. The integrator hands over a y and asks for the rate of change; internally the familiar three-stage pipeline runs:

Stagein the heat network
Headenergy → temperatures of all segments
Middlesolve the hydraulic subproblem (Newton-Raphson → mass flows), then enthalpy flows, heat losses, heat exchangers, control
Tailclose the balance per fluid volume → ydot

The middle stage is remarkable: every single ydot evaluation contains a complete hydraulic network calculation, because without current mass flows there are no enthalpy flows. A dependency graph automatically sorts the sub-models into the correct order — controllers that react to quantities they influence themselves are grouped together and solved iteratively.

The schema, interactively

The visualisation below shows the functional schema of the VICUS Solver with its three nested loops — in the network case it is the same as in the building case, because it is the same computational core. The live demo underneath shows the building block of every network model: a cold pipe, split into segments, into which hot supply water flows from t=0t = 0. You can watch the temperature front travel along the pipe at the flow velocity while heat losses damp it on the way — and see where the stability limit of explicit methods lies.

Functional schema of the VICUS Solver
From network model to solution – three nested loops & the y→ẏ data flow
$\dfrac{d\mathbf{y}}{dt} = \texttt{ydot}(t,\,\mathbf{y})$
Program start
Initialisation build models & graph, set y₀
Time loop while t < t_end
pick dt · t → t+dt
compute time step
BDF, order 1–5 · adaptive step size + error control
Newton iteration solve F(y)=0
Newton iteration and LSE are dropped for explicit — $y_{n+1} = y_n + dt\cdot\texttt{ydot}(t_n, y_n)$
↳ in every iteration ydot(t, y) is evaluated — the network data flow in 3 stages
Head · first

State → temperature

convert energy y into temperatures

  • pipe segments
  • components
  • ground
Middle · graph

Compute fluxes

physics at known temperature

  • hydraulics: ṁ, p (Newton-Raphson)
  • heat losses to the ground
  • heat exchangers, control
Tail · last

Σ fluxes → ẏ

close the balance

  • pipe segments
  • components
  • ground
From ẏ, Newton builds both parts of the LSE:
residual $F = y - y_n - dt\,\dot y$  →  right-hand side $-F$
Jacobian $J = I - dt\,\dfrac{\partial \dot y}{\partial y}$  →  coefficient matrix of the LSE — the $A$ in $A\,\Delta y = b$
Linear system of equations (LSE)
$J \cdot \Delta y = -F$  // J numerically via finite differences + sparsity
Direct · dense matrix
Direct · sparse
Iterative · Krylov
Iterative · Krylov (variant)
Finish step & write output interpolate onto output times
Output files

Example 1: a room cools down

The smallest conceivable simulation model: one zone, one equation. A room at 22 °C loses heat to the outdoor air at 5 °C: $\dfrac{dT}{dt} = -\dfrac{T - T_\text{out}}{\tau}$. “Step” executes one time step; the dt slider locates the stability limit.

MethodExplicit Euler
Time t0.00 h
Step #0
T (solver)22.00 °C
T (exact)22.00 °C
Error |Δ|0.00 K
Head · y → T
Middle · flux
Tail · ẏ & step

Above dt = 6 h (= 2τ) the explicit solution starts to oscillate and diverges, even though physically the room only cools gently. Implicit Euler stays stable at the same step size. This is why the VICUS Solver integrates stiff building models implicitly (CVODE).

Example 2: heat conduction through a wall

Now a partial differential equation, the heat equation $\dfrac{\partial T}{\partial t} = \alpha\,\dfrac{\partial^2 T}{\partial x^2}$. The wall (warm inside, cold outside) is split into N cells; each cell balances only with its neighbours. One PDE becomes a system of N coupled ODEs — the VICUS Solver’s finite-volume wall, each layer one entry in y. The N slider shows why fine grids slow the explicit method down.

← inside (22 °C)wall thickness xoutside (5 °C) →
MethodExplicit (FTCS)
Time t0.0 h
Step #0
States (N)10
Δx21.8 mm
Fourier r = α·dt/Δx²0.31
// discretised per cell i:
$\dfrac{dT_i}{dt} = \dfrac{\alpha}{\Delta x^2}\,\bigl(T_{i-1} - 2T_i + T_{i+1}\bigr)$
// only the direct neighbours → tridiagonal
implicit → tridiagonal system, only 3 diagonals populated:$$J=\begin{pmatrix} 1{+}2r & -r & & \\ -r & 1{+}2r & -r & \\ & -r & 1{+}2r & \ddots \\ & & \ddots & \ddots \end{pmatrix}$$This tridiagonal matrix is the Jacobian, the coefficient matrix of the LSE.
Cell 5 x = … mm Click a cell in the diagram, then execute “Step”.

A finer grid (larger N) increases accuracy but makes the problem stiffer: for the explicit method r = α·dt/Δx² grows quadratically, quickly exceeds the stability limit ½, and the profile oscillates and diverges. It would only stay stable with a drastically smaller dt. The implicit method solves a tridiagonal system (the LSE) per step and stays stable for any N and dt. This is why the VICUS Solver discretises walls finely and computes implicitly.

Example 3: counter-flow heat exchanger

Two fluid streams exchange heat across a separating wall; hot and cold flow against each other. Split along the length into N segments, each segment has a hot and a cold fluid temperature: 2N coupled ODEs (flow and heat transfer). This is how the VICUS Solver discretises pipes and heat exchangers in thermal networks. Comparing counter-flow and parallel-flow shows the effect on the effectiveness ε.

ArrangementCounter-flow
Time t0 s
Ċ hot : cold418 : 418 W/K
C_r = C_min/C_max1.00
hot in → out70.0 → 70.0 °C
cold in → out15.0 → 15.0 °C
Heat flow Q0 W
ε (simulated)0.00
ε (analytic, ε-NTU)0.00
// per segment j, with its own capacity rate Ċ = ṁ·c_p:
$M_h\dfrac{dT_{h,j}}{dt} = \dot C_h\,(T_{h,\text{in}}-T_{h,j}) \;-\; UA_\text{seg}\,(T_{h,j}-T_{c,j})$
$M_c\dfrac{dT_{c,j}}{dt} = \dot C_c\,(T_{c,\text{in}}-T_{c,j}) \;+\; UA_\text{seg}\,(T_{h,j}-T_{c,j})$
// cold: inflow from the other side; $\dot C_h \ne \dot C_c$ allowed

In parallel-flow both temperatures converge toward a common mixing temperature; ε remains limited. In counter-flow a nearly constant temperature difference is maintained along the length, and the cold outlet temperature can approach the hot inlet temperature; with large NTU, ε approaches 1. The stream with the smaller $\dot C$ changes its temperature more (steeper curve) and sets $\dot C_\text{min}$; for $C_r\to 0$ both arrangements give the same $\varepsilon = 1-e^{-\text{NTU}}$. The simulated effectiveness matches the analytic ε-NTU relation:$$\varepsilon_\text{counter} = \frac{1-e^{-\text{NTU}(1-C_r)}}{1-C_r\,e^{-\text{NTU}(1-C_r)}}, \qquad \varepsilon_\text{parallel} = \frac{1-e^{-\text{NTU}(1+C_r)}}{1+C_r}.$$

Live demo: temperature propagation along a pipe

The building block of every network model: a pipe (L = 100 m), split into N = 50 segments — each segment one entry in y. The pipe starts cold at 10 °C; from $t=0$, 70 °C supply water flows in on the left. Each segment balances inflow, outflow and heat loss to the ground. Press Step and watch the temperature front travel along the pipe — and turn v, dt and the loss.

supply 70 °C ⟶L = 100 m · N = 50⟶ outlet
MethodExplicit (upwind)
Time t0 s
Step #0
CFL = v·dt/Δx0.75
front position v·t0 m
T at outlet10.0 °C
// per segment k (upwind balance):
$M c\,\dfrac{dT_k}{dt} = \dot m c\,(T_{k-1} - T_k) \;-\; UA\,(T_k - T_\text{ground})$
// coupling only to the upstream neighbour → bidiagonal

What happens here: the front travels along the pipe at v — the temperature change reaches the outlet only after the dead time L/v, damped by the loss factor $e^{-\beta L / v}$: slow flow means longer travel time and more cooling. Push dt past the limit CFL = 1: explicit starts to oscillate and explodes, while implicit solves a bidiagonal LSE per step (a single forward sweep) and stays stable. That the computed front is flatter than the exact one is numerical diffusion — exactly why the dynamic pipe model in VICUS Districts splits pipes into many segments.

Interactive functional schema of the simulation core behind VICUS Districts · „▶ Play the flow" walks step by step through the time loop → Newton → LSE.

Time integration: CVODE and the stiffness of the network

Integration uses CVODE from the SUNDIALS package: an implicit, adaptive multi-step method based on BDF (Backward Differentiation Formulas) of order 1 to 5. The step size is not constant — during calm summer operation the solver takes large steps, during the morning load ramp-up or when a producer comes online it takes small ones. The output (hourly values, say) is decoupled from this and cleanly interpolated.

Why implicit? For the same reason as with buildings: stiffness. A short, fast-flowing pipe segment has a time constant of seconds; the ground around the route responds over weeks. Explicit methods would have to follow the fastest time constant and take tiny steps — an annual simulation would become unusably slow. The implicit method stays stable with large steps; the step size is governed solely by the desired accuracy.

Three nested loops — plus a subproblem

The mental map of the implicit solver applies unchanged:

  • Outer, the time loop (CVODE): picks the step size dt and goes from t to t+dt.
  • Middle, the Newton iteration: solves the nonlinear implicit equation F(y)=yyndtydot(y)=0F(y) = y - y_n - dt \cdot \texttt{ydot}(y) = 0 for y_{n+1} (usually 1–3 iterations).
  • Inner, the linear system of equations (LSE): in every Newton iteration, JΔy=FJ \cdot \Delta y = -F is solved once.

The network case adds the special feature that every ydot evaluation in turn solves the hydraulic subproblem via Newton-Raphson. There are thus two separate Jacobians, each with few dependencies — the hydraulic one is formed analytically for simple elements and numerically for controlled components.

Both systems are sparse: a pipe segment couples thermally only with its neighbours along the flow path, a node hydraulically only with the connected edges. The solver exploits this via sparse solvers; for very large networks, iterative Krylov methods with a preconditioner are used (GMRES + ILU). For most projects the solver picks these settings itself — you only touch them when a simulation is too slow or fails to converge.

From network model to solution in five sentences

  1. The solver describes the heat network as a graph; every element brings a hydraulic and a thermal model.
  2. The hydraulics (pressures, mass flows) are a steady-state algebraic system solved by Newton-Raphson in every evaluation; the thermal transport (temperatures) is a system of ordinary differential equations dy/dt=ydot(t,y)dy/dt = \texttt{ydot}(t, y).
  3. ydot balances the energy of every fluid volume — advection minus heat loss — and is evaluated at runtime in three stages, including the hydraulic subproblem.
  4. Integration uses CVODE (implicit BDF method) with adaptive step size plus error control — necessary because network models are stiff.
  5. Each implicit time step requires a Newton iteration, each Newton iteration a sparse linear system of equations, solved directly (sparse LU) or iteratively (GMRES + ILU).

What this means in practice

For day-to-day network planning you do not need to operate this machinery in detail — but it explains why a genuine thermo-hydraulic annual simulation needs computing time and is nevertheless finished in minutes rather than hours: the domain-specific split into hydraulic and thermal subproblems is the performance lever that makes even large networks with hundreds of participants, decentralised feed-in and prosumer structures reliably computable. The VICUS Solver is the computational core that VICUS Districts is built on; the underlying methodology is documented as open source through the SIM-VICUS research project.

To dig deeper: the article on thermo-hydraulic simulation places the methodology within network planning, pressure loss calculation shows the hydraulic equations in detail, and VICUS Solver: the Engine Behind VICUS Buildings explains the same core from the building perspective — with further interactive demos on the Newton iteration and the linear system of equations.

Frequently Asked Questions

What does the VICUS Solver compute for a heat network?
The VICUS Solver describes the heat network as a graph of nodes and edges (pipes, pumps, valves, producers, consumers) and simultaneously computes pressures, mass flows and temperatures over the simulation period — typically a full year. The hydraulics are solved as a steady-state algebraic system of equations, the heat transport as a system of ordinary differential equations. The VICUS Solver is the computational core that VICUS Districts is built on.
Why are hydraulics and thermal transport formulated separately?
Pressure waves propagate very quickly in nearly incompressible water — from the perspective of the temperatures, the flow field establishes itself practically instantly and is therefore solved as a steady-state subproblem using the Newton-Raphson method. Temperatures, by contrast, change slowly and are integrated over time (CVODE). This domain-specific split is considerably more performant than one monolithic system of equations, as generic Modelica solvers assemble.
What is ydot in heat network simulation?
ydot is the right-hand side of the differential equation dy/dt = ydot(t, y): the rate of change of the stored energy in every fluid volume of the network. For a pipe segment the balance reads: enthalpy inflow minus enthalpy outflow minus heat loss to the ground. Every ydot evaluation first solves the hydraulic subproblem, because the mass flows determine the enthalpy flows.
Why does network simulation compute implicitly rather than explicitly?
Network models are stiff: small pipe segments with fast-flowing fluid have time constants of seconds, while the surrounding ground responds over weeks. Explicit methods would have to take tiny time steps for stability reasons and would be unusably slow for annual simulations. Implicit methods such as CVODE (BDF) stay stable even with large steps — the step size is governed by the desired accuracy, not by stability.
How large do the systems of equations get?
The dynamic pipe model splits every pipe into finite-volume segments; each segment is a separate entry in the state vector y. For large networks with hundreds of participants this quickly amounts to thousands of unknowns. The Jacobian, however, is sparse — each segment couples only along the flow path — and is solved efficiently with sparse solvers, or iteratively with a preconditioner (GMRES + ILU) for very large networks.

Related Articles

Thermo-Hydraulic Simulation: A Deep Dive

Fundamentals of thermo-hydraulic simulation in district heating networks: methods, models and application

Disclaimer: The content of this page is for general information purposes only and does not constitute legal, planning or engineering advice. All information is provided without guarantee. Despite careful research, VICUS Software GmbH assumes no liability for the accuracy, completeness or timeliness of the information provided. Third-party product names and trademarks are mentioned for informational purposes only and are the property of their respective owners.

VICUS Districts

From theory to practice

Put your knowledge into action with VICUS Districts.

Stay up to date

New features, tutorials and updates delivered to your inbox.