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:
Here is the state vector, a long list of all conserved quantities, their rate of change and 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 (Kirchhoff’s first law):
- 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 :
with the enthalpy flows and the heat loss to the ground .
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 | Meaning |
|---|---|
| Pipe segments | Energy (mass × specific enthalpy) per finite-volume segment of a pipe |
| Components with fluid volume | Heat exchangers, storage tanks, producer circuits |
| Ground | Temperatures 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 . 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?
is derived from a conservation law, always following the same pattern:
- Choose the conserved quantity (energy, mass, …), not the temperature.
- Set up the balance: change in storage equals the sum of inflows minus the sum of outflows.
- Express every flow in terms of the state.
- Solve for . The result is .
Example: a pipe segment
A segment with fluid mass and specific heat capacity is passed by the mass flow and loses heat to the ground:
On the left is the change in storage, on the right the advection from the upstream segment minus the heat loss. Solved for this gives 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 . The integrator passes a state and receives the rate of change; internally this happens in three stages:
| Stage | in the heat network |
|---|---|
| Head | energy → temperatures of all segments |
| Middle | solve the hydraulic subproblem (Newton-Raphson → mass flows), then enthalpy flows, heat losses, heat exchangers, control |
| Tail | close the balance per fluid volume → |
Every single evaluation of 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 (). 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 and moves from to .
- Newton iteration: solves the nonlinear implicit equation for , usually in 1 to 3 iterations.
- Linear system of equations (LSE): in every Newton iteration is solved once.
In the network case, every evaluation of 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
- The solver describes the heat network as a graph; every element has a hydraulic and a thermal model.
- 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 .
- balances the energy of every fluid volume (advection minus heat loss) and is evaluated at runtime in three stages, including the hydraulic subproblem.
- Integration uses CVODE, an implicit BDF method with adaptive step size and error control, because network models are stiff.
- 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
CEO & heat network expert
Expert in heat network simulation and software development, CEO of VICUS Software GmbH.