Heat Network Simulation · Article 2 of 2

VICUS Solver: the Engine Behind Heat Network Simulation

How does a solver compute a district heating network? From the network graph and the hydraulics–thermal coupling to CVODE and Newton iteration.

Dr.-Ing. Hauke Hirsch

CEO & heat network expert

Updated 9 min read
Contents

A thermo-hydraulic simulation needs a computational core that turns network topology, pipe data, load profiles and control logic into the time history of pressures, mass flows and temperatures. In VICUS Districts this core is the VICUS Solver, built on more than 20 years of research at TU Dresden. The same core also runs VICUS Buildings. This article describes how the solver sets up a heat network as a system of equations and integrates it through time.

No background in numerical methods is required. How a temperature front behaves in a discretized pipe, and where the stability limit of explicit methods lies, can be tried out in the Solver Lab.

The core idea

The solver describes the heat network as a graph of nodes and edges and solves two coupled subproblems on it: the hydraulics, i.e. pressures and mass flows, and the heat transport, i.e. the temperatures in the network. For the heat transport it answers one question at every point in time:

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

Once this rate of change is known, the solver can take a small step into the future, compute the new temperatures and repeat. In vector notation:

dydt=y˙(t, y)\frac{dy}{dt} = \dot y(t,\, y)

Here yy is the state vector, a long list of all conserved quantities, y˙\dot y their rate of change and tt the time. In source code the function for the right-hand side is usually called ydot.

The network as a graph

The calculation is based on the network topology as a graph: nodes are branch and connection points, edges are the network elements, i.e. pipes, pumps, valves, heat exchangers of the substations and producers. Each element has two models: a hydraulic one describing the pressure difference as a function of mass flow, and a thermal one describing the temperature change of the fluid flowing through it.

This separation is a fundamental design decision of the solver, because the two subproblems run on very different time scales.

Two subproblems: fast hydraulics, slow thermal behavior

Hydraulics: steady-state and algebraic

Pressure waves propagate through nearly incompressible water at the speed of sound. Compared with the temperatures, the flow adjusts practically instantaneously. The hydraulics are therefore not integrated over time but solved in every evaluation as a steady-state algebraic system:

  • 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, for pipes for example according to Colebrook-White. It depends on mass flow and on temperature, because density and viscosity of the fluid change with it (see pressure loss calculation).

The nonlinear system is solved with the Newton-Raphson method. Flow reversal, for example with decentralized feed-in, is included because the pressure loss equation is formulated with the correct sign.

Thermal behavior: dynamic

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

Ck dTkdt=H˙in,k−H˙out,k−Q˙loss,kC_k\,\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˙ c T\dot H = \dot m\,c\,T and the heat loss to the ground Q˙loss,k=UA (Tk−TG)\dot Q_{\text{loss},k} = UA\,(T_k - T_\text{G}).

Generic solvers, for example for Modelica, put both into a single large system of equations, with a correspondingly large Jacobian and many direct dependencies. The VICUS Solver instead solves the hydraulic system as a separate subproblem within the thermal calculation. Two smaller, specialized systems can be solved considerably faster than one large one.

Energy instead of temperature

As with buildings, the solver balances stored energy, not temperature directly. Energy is a conserved quantity whose inflows and outflows can be summed unambiguously; temperature is computed from it.

What is in the state vector?

Part of yyMeaning
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 divides every pipe into segments so that temperature changes travel through the network with the correct delay. Each segment is a separate entry in yy. The heat capacity of the pipe wall is added to the fluid (lumped model), so the thermal inertia is right without a separate computational grid for the wall. In large networks this adds up to thousands of unknowns.

Where does the right-hand side come from?

y˙\dot y is derived from a conservation law, always following the same pattern:

  1. Choose the conserved quantity (energy, mass, …), not the temperature.
  2. Set up the balance: change in storage equals the sum of inflows minus the sum of outflows.
  3. Express every flow in terms of the state.
  4. Solve for dy/dtdy/dt. The result is y˙\dot y.

Example: a pipe segment

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

M c dTkdt=m˙ c (Tk−1−Tk)−UA (Tk−TG)M\,c\,\frac{dT_k}{dt} = \dot m\,c\,\big(T_{k-1} - T_k\big) - UA\,\big(T_k - T_\text{G}\big)

On the left is the change in storage, on the right the advection from the upstream segment minus the heat loss. Solved for dTk/dtdT_k/dt this gives y˙\dot y for the segment. Many such segments in a row form the pipe model that runs in the Solver Lab as a temperature front in a 100 m pipe.

Evaluation at runtime, including hydraulics

In the network case, too, there is no closed formula for y˙\dot y. The integrator passes a state yy and receives the rate of change; internally this happens in three stages:

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 → y˙\dot y

Every single evaluation of y˙\dot y therefore contains a complete hydraulic network calculation, because without current mass flows there are no enthalpy flows. A dependency graph determines the order of the sub-models; controllers that react to quantities they influence themselves are grouped and solved iteratively.

Time integration and stiffness

Integration uses CVODE from the SUNDIALS suite, an implicit, adaptive multistep method based on BDF (Backward Differentiation Formulas) of order 1 to 5. The step size is not constant: in quiet summer operation the solver takes large steps, during the morning load increase or when a producer switches on, small ones. Output, for example hourly values, is decoupled from this and interpolated.

The calculation is implicit for the same reason as for buildings: network models are stiff. A short pipe segment with fast flow has a time constant of seconds, while the ground around the route reacts over weeks. An explicit method would have to adapt its step size to the fastest time constant; for the pipe this means the fluid may travel at most one segment per time step (v Δt/Δx≤1v\,\Delta t / \Delta x \le 1). An annual simulation would become very slow. The implicit method remains stable even with large steps, and the step size depends only on the required accuracy.

Three nested loops and a subproblem

The procedure is the same as for buildings:

  • Time loop (CVODE): chooses the step size Δt\Delta t and moves from tt to t+Δtt + \Delta t.
  • Newton iteration: solves the nonlinear implicit equation F(y)=y−yn−Δt y˙(y)=0F(y) = y - y_n - \Delta t\,\dot y(y) = 0 for yn+1y_{n+1}, usually in 1 to 3 iterations.
  • Linear system of equations (LSE): in every Newton iteration J Δy=−FJ\,\Delta y = -F is solved once.
Flow of implicit time integration: time loop with adaptive step size and error control, inside it the Newton iteration with evaluation of y-dot and the Jacobian, inside that the linear system with direct and iterative solvers
Time loop, Newton iteration and linear system. In a network, every evaluation of ẏ also contains the hydraulic calculation.

In the network case, every evaluation of y˙\dot y also solves the hydraulic subproblem with Newton-Raphson. There are therefore 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 with sparse solvers; for very large networks iterative Krylov methods with a preconditioner are used (GMRES with ILU). In most projects the solver chooses these settings itself. Changes are only needed if a simulation is too slow or does not converge.

Summary

  1. The solver describes the heat network as a graph; every element has a hydraulic and a thermal model.
  2. The hydraulics (pressures, mass flows) are a steady-state algebraic system solved with Newton-Raphson in every evaluation. The thermal behavior (temperatures) is a system of ordinary differential equations dy/dt=y˙(t,y)dy/dt = \dot y(t, y).
  3. y˙\dot y 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, an implicit BDF method with adaptive step size and error control, because network models are stiff.
  5. Every implicit time step requires a Newton iteration, and every Newton iteration a sparse linear system, solved directly (sparse LU) or iteratively (GMRES with ILU).

What this means in practice

In network design nobody needs to tune these methods. They do explain, however, why an annual thermo-hydraulic simulation takes computing time and still finishes in minutes rather than hours: splitting the problem into a hydraulic and a thermal part makes even large networks with hundreds of consumers, decentralized feed-in and prosumers computable. The VICUS Solver is the computational core of VICUS Districts; the methodology is documented through the open-source project SIM-VICUS.

Further reading: the article on thermo-hydraulic simulation places the methodology in the context of network design, the pressure loss calculation shows the hydraulic equations in detail, and VICUS Solver: the Engine Behind VICUS Buildings covers the Newton iteration and the linear system in more depth. The Solver Lab also has a heat exchanger in the time domain to experiment with.

Author

Dr.-Ing. Hauke Hirsch

Dr.-Ing. Hauke Hirsch

CEO & heat network expert

Expert in heat network simulation and software development, CEO of VICUS Software GmbH.

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?
ẏ is the right-hand side of the differential equation dy/dt = ẏ(t, y), usually called ydot in source code: 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 evaluation of ẏ 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.

From article to project

Plan and simulate heat networks in VICUS Districts.

Build the network from GIS or OpenStreetMap data, size the pipes and simulate the network thermo-hydraulically over a full year – conventional or cold.

VICUS Districts

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.

Stay up to date

New features, tutorials and updates delivered to your inbox.