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.

How the VICUS Solver computes

From network model to solution – three nested loops & the y→ẏ data flow
$\dfrac{d\mathbf{y}}{dt} = \texttt{ydot}(t,\,\mathbf{y})$

How to read this visualisation — first the overview, then the network building block as a live demo: How to read this visualisation — first the overview, then an example to try yourself:

SchemaOverview: the three nested loopsOverview of how the solver works
Pipetemperature wave: N coupled ODEs (advection + loss)warm water pushes through the cold pipe
📖 Each term in one sentence (look up any time)
$\mathbf{y}$ — statelist of all conserved quantities (energy of every pipe segment & component).the long list of all temperatures/energies that change over time.
$\dot{\mathbf{y}}$ = ydot — rate of changethe derivative dy/dt: how fast each state changes.how fast everything is changing right now (the slope).
Balanced(energy)/dt = Σ inflows − Σ outflows — where each equation comes from.what comes in minus what goes out.
$F$ — residual$F=y-y_n-dt\,\texttt{ydot}(y)$; zero when the new state is correct.how far a guess is still off (0 = right).
$J$ — Jacobian$\partial F/\partial y$: how F reacts to small changes of each state.sensitivity table: which knob acts how strongly.
$\Delta y$ — correctionthe Newton step that improves the guess.by how much the guess is corrected.
LSElinear system of equations $J\,\Delta y=-F$, once per Newton iteration.the system of equations that computes the correction.
Newtoniteration that solves the nonlinear implicit equation $F(y)=0$.stepwise approach toward the correct solution.
BDF order (1–5)accuracy degree of the implicit method; higher → larger steps.how „smart" the solver estimates — higher = larger time steps.
Stiffnessvery fast and very slow processes at once (flowing pipe segments vs. ground).fast and sluggish at the same time → explicit needs tiny steps.
Hydraulic subproblemsteady-state system of mass conservation + pressure loss; yields ṁ and p per ydot evaluation (Newton-Raphson).side calculation: how much water is flowing where right now?
CFL number$\text{CFL}=v\,dt/\Delta x$; explicit stable only for CFL ≤ 1.measure of step size with flow — too large → explicit blows up.
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
② + ③ 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

„unpack“ energy y

  • pipe segments
  • components
  • ground
Middle · graph

Compute fluxes

physics at known T

  • 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)
Newton convergence · ‖F‖ per iteration
Each iteration solves the LSE once and shrinks the residual ‖F‖ — usually below tolerance after 2–3 steps. That is how often Newton runs within a single time step.
Finish step & write output interpolate onto output times
📄 Output files
Result · fluid temperature over accepted time steps
Only once Newton has converged is the time step accepted — yielding a new, reliable temperature value. Here stagnant fluid in a pipe cools from 22 °C toward the ground temperature (5 °C).
① Time (CVODE) ② Newton ③ LSE Head: energy→T Middle: fluxes Tail: Σ→ẏ

Step by step: a room cools down

The smallest conceivable simulation model: one zone, one equation. A warm room (22 °C) loses heat to the cold outdoor air (5 °C): $\dfrac{dT}{dt} = -\dfrac{T - T_\text{out}}{\tau}$. Press Step and watch the integrator work its way through time — and turn dt to find the stability limit.

💡 What you learn here Explicit Euler blindly follows the tangent: for large dt the solution overshoots T_out and explodes. Implicit stays stable — at the cost of Newton + LSE. For this linear example the implicit step even resolves directly (without Newton). If the solver takes time steps that are too large, the simple method „overshoots" and computes nonsense. The stable method stays calm — but costs more effort per step. Tip: drag dt past 6 h, then toggle between explicit/implicit.
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

Try it: push dt past 6 h (= 2τ) and step with Explicit Euler — the solution starts to oscillate and explodes, even though physically the room only cools gently. Switch to Implicit Euler: the same large step size stays stable. That is exactly why the VICUS Solver computes stiff building models implicitly (CVODE).

Second example: 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}$. A wall (warm inside, cold outside) is split into N cells; each cell balances only with its neighbours. This turns one PDE into a system of N coupled ODEs — exactly the VICUS Solver’s finite-volume wall, each layer one entry in y. Turn N and see why fine grids bring the explicit method to its knees.

💡 What you learn here A PDE becomes N coupled ODEs through spatial discretisation — this is how the VICUS Solver’s thousands of states arise. A finer grid (large N) makes the problem stiff: explicit needs tiny steps ($r\le\tfrac12$), implicit solves a tridiagonal LSE per step and stays stable. Splitting the wall into many slices turns one equation into a whole bundle. The finer it is, the smaller the time step must be for the simple method — otherwise the solution flickers. Tip: push N up and click a cell — the inspector shows the numbers step by step.
← 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 Tip: click a cell in the diagram, then press Step

The stiffness effect: push N up (finer grid, more accurate!) — for explicit, r = α·dt/Δx² grows quadratically, quickly bursts the limit ½, and the profile jitters and explodes. To stay stable you would have to shrink dt drastically. Implicit solves a tridiagonal system (the LSE!) every step and stays stable for any N and dt. That is exactly why the VICUS Solver discretises walls into many cells and computes implicitly.

Third example: counter-flow heat exchanger

Two fluid streams exchange heat across a 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 + heat transfer). This is exactly how the VICUS Solver discretises pipes and heat exchangers in thermal networks. Compare counter-flow ↔ parallel-flow and see the effectiveness ε.

💡 What you learn here Two opposing streams = 2N coupled ODEs (advection + heat transfer) — as in the VICUS Solver’s thermal networks. Counter-flow is more effective than parallel-flow; with unequal capacity rates the stream with the smaller Ċ changes its temperature more. Hot and cold flow against each other and exchange heat. Counter-flow extracts more than parallel-flow. Whoever has „less mass per time" changes temperature more. Tip: toggle the arrangement and vary NTU and the Ċ ratio — ε matches the theory.
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

Why counter-flow? In parallel-flow both temperatures converge and end at a common mixing temperature — ε is capped. In counter-flow a nearly constant temperature gap is maintained along the length, and the cold outlet temperature can approach the hot inlet temperature → with large NTU, ε approaches 1.
Unequal capacity rates: the stream with the smaller $\dot C$ changes its temperature more (steeper curve) and sets $\dot C_\text{min}$. For $C_r\to 0$ counter- and parallel-flow give the same $\varepsilon = 1-e^{-\text{NTU}}$. The simulated effectiveness matches the analytic $\varepsilon$-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.

💡 What you learn here Advection transports the front at the flow velocity v (dead time L/v!), heat losses damp it exponentially with $e^{-\beta x / v}$. Explicit is stable only for CFL = v·dt/Δx ≤ 1; implicit (bidiagonal LSE, one forward sweep) stays stable for any dt. The warm water pushes its way through the cold pipe — at the far end it arrives later and slightly colder. Time steps that are too large make the simple method „explode"; the stable method handles any step. Tip: push dt up until CFL > 1 — then toggle between explicit/implicit.
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.