Building Simulation · Article 8 of 10

VICUS Solver: the Engine Behind VICUS Buildings

How does a dynamic building simulation compute? Energy balance, time steps, implicit methods and linear systems, explained with worked examples.

Dr.-Ing. Andreas Nicolai, Dipl.-Ing. Stephan Hirth

VICUS Software GmbH

Updated 17 min read
Contents

A dynamic building simulation needs a computational core that turns geometry, building components, weather and use into the time history of temperatures and loads. In VICUS Buildings this core is the VICUS Solver, built on more than 20 years of research at TU Dresden.

This article explains how such a core works. The principles apply to practically every dynamic building simulation; where the VICUS Solver makes a specific choice, this is stated. Each section starts with a simple example and then moves on to the method. No background in numerical methods is required. If you want to try the methods yourself, the Solver Lab offers four interactive experiments on time step, stability and grid spacing.

The core idea: bookkeeping of energy

Picture a bathtub with the tap running and the drain open: the water level rises when more flows in than out, and falls in the opposite case. Knowing the inflow and the outflow, you can predict the water level at any later time.

A room works the same way, only with heat instead of water. Inflows are solar radiation, people, equipment and heating; outflows are transmission through the envelope and ventilation. The “water level” is the heat content, i.e. the stored internal energy UU:

dUdt=∑Q˙in−∑Q˙out\frac{dU}{dt} = \sum \dot Q_\text{in} - \sum \dot Q_\text{out}

In words: the change of heat content per unit time equals the sum of all inflows minus the sum of all outflows. The solver sets up this one balance for every room and every wall layer and advances it step by step through time.

Why energy and not temperature?

Temperatures cannot simply be added up, energies can. The same kilowatt-hour has very different effects depending on where it is stored:

Heat capacityTemperature rise from 1 kWh
Room air, 50 m³about 60 kJ/Kabout 60 K
Concrete slab, 10 m² × 20 cmabout 4,800 kJ/Kabout 0.75 K

The energy is the same in both cases; only the temperature change differs, by a factor of 80. This is why the solver balances energy, which can be summed unambiguously, and then computes the temperature from the heat capacity: T=U/CT = U/C.

A single room as a worked example

The simplest building model is a single room with heat capacity CC, connected to the outdoor air through a heat loss coefficient HH (transmission and ventilation combined, in W/K). Without heating, heat flows out in proportion to the temperature difference:

Q˙out=H (T−Text)\dot Q_\text{out} = H\,(T - T_\text{ext})

With dU/dt=C dT/dtdU/dt = C\,dT/dt this gives the equation that describes the room cooling down:

dTdt=−T−Textτ,τ=CH\frac{dT}{dt} = -\frac{T - T_\text{ext}}{\tau}, \qquad \tau = \frac{C}{H}

The time constant τ\tau expresses how sluggish the room is. After one time constant, about two thirds of the temperature difference to the outdoor air has gone; after three time constants, about 95 %.

Two variants of the same room with H=100H = 100 W/K show how large the difference can be:

Heat capacity CCTime constant τ\taualmost cooled down after 3 τ3\,\tau
room air only (50 m³)60 kJ/K10 minutes30 minutes
room air with walls, ceiling, screed10,000 kJ/Kabout 28 hoursabout 3.5 days

One time step by hand

With the sluggish room, a single computation step can be followed directly. It is 20 °C inside and 0 °C outside, and the time constant is 28 hours. The rate of change is then

dTdt=−20−028 h≈−0.71 K/h\frac{dT}{dt} = -\frac{20 - 0}{28\ \text{h}} \approx -0.71\ \text{K/h}

A step of one hour gives T≈20−0.71=19.29T \approx 20 - 0.71 = 19.29 °C. The exact solution is 19.30 °C. The new temperature then yields a new rate of change, the next step is taken, and so on.

This is exactly how a building simulation works: determine the rate of change, take a step into the future, repeat. Everything else in this article is about doing this quickly, stably and accurately for thousands of coupled quantities. In the Solver Lab you can work through this example interactively.

From room to building: the state vector

A real building has more than one heat store. Every wall stores heat, and not uniformly: in winter the inside of an external wall is warm and the outside cold. To capture this temperature profile, the solver splits every construction into many thin layers (finite volume elements). Each layer gets its own energy balance.

All quantities that store energy and change over time are collected by the solver in one long list, the state vector yy:

Part of yyMeaning
Rooms / zonesInternal energy of the room air (and moisture, if modelled)
ConstructionsInternal energy in every layer of every wall, ceiling and floor slab
Thermal networksEnergy of the fluid in pipes and components

The order of magnitude is easy to estimate: 50 components with 30 layers each already give 1,500 entries, plus the rooms. Larger buildings reach several thousand.

Section through a room and external wall: the room air and the finite-volume layers of the wall become entries of the state vector y; the outdoor temperature is a boundary condition
The room air and every wall layer are each one entry in the state vector. Only direct neighbours are coupled.

For the whole building, the task can then be written in short form:

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

This is nothing more than the bathtub balance, applied to all stores at once. y˙\dot y (“y-dot”, in source code usually ydot) is the list of all rates of change: for every room and every layer, how fast the heat content is currently rising or falling.

How the rates of change are obtained

For the single room, the rate of change could be written as a formula. With thousands of coupled stores this is no longer possible. Instead, y˙\dot y is assembled afresh at every call, in three steps:

  1. Determine temperatures: the temperature of every room and every layer is computed from its stored energy.
  2. Compute heat flows: each sub-model contributes its share, such as conduction between layers, solar radiation through windows, ventilation and infiltration, internal gains, heating and cooling power, or pipe flow.
  3. Sum up: for every room and every layer, all inflows and outflows are added. The result is the corresponding entry in y˙\dot y.
Evaluating y-dot in three steps: determine temperatures from the stored energy, compute heat flows from the sub-models, sum them per room and wall layer
One evaluation of ẏ: the sub-models deliver their heat flows in the second step.

Example: an office on a winter afternoon

For a single room, step 3 might look like this at a given moment:

Heat flowContribution
Sun through the window+300 W
Two people and computers+200 W
Transmission through the envelope−400 W
Ventilation−150 W
Heating (thermostat closed)0 W
Sum = entry in y˙\dot y−50 W

The room is currently losing 50 W. With an effective heat capacity of 10,000 kJ/K, its temperature therefore drops by just under 0.02 K per hour. This number, for every room and every layer, is what the solver needs for the next time step.

The right order: the dependency graph

The sub-models in step 2 depend on each other, much like trades on a building site: the screed goes in only after the underfloor heating. In the simulation, for example, the window model needs the sun position from the climate model, and the room balance needs the output of the heating model:

Weather data → sun position → radiation on the window → heat gain in the room

The VICUS Solver determines the order automatically using a dependency graph. Each model declares which quantities it needs and which it provides; topological sorting then yields a valid evaluation order. Two cases matter:

  • Parallel evaluation: models that do not depend on each other, such as heat conduction in many different walls, are computed simultaneously on several processor cores.
  • Loops: a thermostat measures the room temperature and sets the heating valve, the valve determines the heating power, and the heating power changes the room temperature. Models that influence each other in this way are grouped by the solver and solved together iteratively.

Step by step through the year

With y˙\dot y, the rate of change of every store is known. Time integration turns this into the course of the year: it moves from tt to t+Δtt + \Delta t, computes the new state and repeats until the end of the simulation.

The step size Δt\Delta t is not fixed. The solver adjusts it continuously, much like a driver who goes faster on an open road and slows down before a bend:

  • At night, heating in setback mode, little change: large steps, by default up to one hour in VICUS Buildings.
  • In the morning the heating starts, a window is opened, a blind comes down: small steps of seconds to minutes until the system settles.

After every step the solver checks whether it was good enough: it estimates the error and compares it with a tolerance (in VICUS Buildings a relative tolerance of 10−510^{-5} by default). If the error is too large, the step is rejected and repeated with a smaller step size; if it is well below what is needed, the next step may be larger.

Result output is independent of this. If you request hourly values, you get them, even though the solver has computed with entirely different steps internally; values are interpolated between computation steps to the output times.

Explicit or implicit

There are two fundamentally different ways to take a time step.

Explicit means: the rate of change is determined at the start of the step and used for the whole step. That was the step by hand in the room example.

yn+1=yn+Δt⋅y˙(tn, yn)y_{n+1} = y_n + \Delta t \cdot \dot y(t_n,\, y_n)

Implicit means: the rate of change at the end of the step is used, i.e. at the still unknown new state. The result therefore appears on both sides of the equation and must first be solved for:

yn+1=yn+Δt⋅y˙(tn+1, yn+1)y_{n+1} = y_n + \Delta t \cdot \dot y(t_{n+1},\, y_{n+1})

The explicit step is simpler and cheaper. The room shows once more why buildings are nevertheless computed implicitly.

Example: the fast room with a large step

This time the room in which only the air stores heat (τ\tau = 10 minutes). 20 °C inside, 0 °C outside, a step size of one hour, i.e. six time constants at once:

afterexplicitimplicitexact
1 hour−100 °C2.9 °C0.05 °C
2 hours+500 °C0.4 °C0.00 °C
3 hours−2,500 °C0.06 °C0.00 °C

The explicit method takes the initial cooling rate of 2 K per minute and applies it for 60 minutes. It overshoots far below the outdoor temperature, then even further above it in the next step, and the solution blows up. The implicit method asks instead: which temperature at the end of the step matches the cooling rate at exactly that point? The answer is not exact, but it is physically sensible and stable. With a smaller step it also becomes more accurate.

Here, an explicit method only stays stable if the step is shorter than about two time constants, i.e. shorter than 20 minutes.

Stiff systems

A building contains both room variants at the same time: parts that react within minutes (room air, thin plaster layers) and parts that take days (concrete slabs, screed). Such systems are called stiff. An explicit method must always follow the fastest part, even when that part is hardly changing at all.

A numerical example from the wall: for a layer of thickness Δx\Delta x made of a material with thermal diffusivity α\alpha, the explicit method is stable only for

r=α ΔtΔx2≤0.5r = \frac{\alpha\,\Delta t}{\Delta x^{2}} \le 0.5

For lime plaster (α≈5⋅10−7\alpha \approx 5 \cdot 10^{-7} m²/s) and 1 cm layers that means at most 100 seconds per step, i.e. more than 300,000 steps for one year. Halve the layer thickness and the time step must drop to a quarter. An implicit method, by contrast, can take steps of up to one hour when little is changing. Each of these steps costs more, but overall the implicit method is considerably faster for buildings. In the Solver Lab you can push past this limit directly by changing time step and grid spacing.

ExplicitImplicit (default in the VICUS Solver)
Rate of change taken atstart of the stepend of the step
Equation to solvenoyes, with Newton iteration
Cost per steplowhigh
Step size limited bystability (very small for buildings)accuracy
Suitable for buildingsno (too slow)yes

CVODE: the default integrator

By default the VICUS Solver uses CVODE from the SUNDIALS suite, an implicit method with adaptive step size based on BDF (Backward Differentiation Formulas). The simplest BDF method (order 1) is exactly the implicit step shown above. Higher orders (up to 5) also take the previous time steps into account, much as a curve through several points describes a trend better than a straight line through two. CVODE chooses step size and order itself. Explicit methods (Euler, Runge-Kutta) are available in the solver as reference and test integrators.

What happens inside an implicit step

An implicit time step consists of three nested levels:

  • Time loop (CVODE): chooses the step size Δt\Delta t and moves from tt to t+Δtt + \Delta t.
  • Newton iteration: solves the implicit equation for the new state yn+1y_{n+1}, usually in 1 to 3 passes.
  • Linear system of equations (LSE): in every Newton pass, one system of equations is solved.
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. An error that is too large causes the step to be repeated with a smaller Δt.

The Newton iteration

The Newton iteration is a method for solving equations that cannot be rearranged directly for the unknown. A familiar example is the square root of 2, i.e. the solution of x2−2=0x^{2} - 2 = 0:

  1. Start with an estimate, say x=1.5x = 1.5.
  2. At this point, draw the tangent to the curve x2−2x^{2} - 2 and find where it crosses zero: at x=1.4167x = 1.4167.
  3. Repeat from there: x=1.41422x = 1.41422.

After two passes the result is correct to four decimal places (2=1.41421\sqrt 2 = 1.41421). Each pass replaces the difficult equation with a straight line that is easy to solve.

In the solver, the equation that every implicit step has to solve is:

F(y)=y−yn−Δt⋅y˙(y)=0F(y) = y - y_n - \Delta t \cdot \dot y(y) = 0

The tangent is here called the Jacobian JJ, and the correction Δy\Delta y to the estimate follows from

J Δy=−F(y),y←y+ΔyJ\,\Delta y = -F(y), \qquad y \leftarrow y + \Delta y

If all heat flows were linear in temperature, Newton would be finished after one pass, as in the room example. Non-linearity comes from long-wave radiation (proportional to T4T^{4}), temperature-dependent heat transfer and controllers. But since the state from the previous time step is already a very good starting estimate, 1 to 3 passes are usually enough.

The Jacobian

For every pair of state variables, the Jacobian answers a question of the kind: how much does the balance of room A change if the temperature of wall layer B rises slightly? With nn state variables it has n×nn \times n entries:

J=∂F∂y=I−Δt ∂y˙∂yJ = \frac{\partial F}{\partial y} = I - \Delta t\,\frac{\partial \dot y}{\partial y}

The VICUS Solver determines these entries by trial: it changes one state variable slightly, evaluates y˙\dot y again and checks which balances have changed and by how much. That gives one column of the matrix.

The linear system of equations

With thousands of unknowns, solving J Δy=−FJ\,\Delta y = -F is the most computationally intensive part of the simulation. What makes it manageable is a property of the matrix.

Almost all entries are zero

A wall layer exchanges heat only with its two direct neighbours, a room only with the adjoining component surfaces. For a wall with five layers the matrix therefore looks like this (× = non-zero entry, blank = zero):

J=(×××××××××××××)J = \begin{pmatrix} \times & \times & & & \\ \times & \times & \times & & \\ & \times & \times & \times & \\ & & \times & \times & \times \\ & & & \times & \times \end{pmatrix}

13 of the 25 entries are occupied. With 30 layers it is 88 of 900, and for a building with several thousand states well under one percent. Such matrices are called sparse, and there are solvers that work only with the occupied entries.

Sparsity also saves effort when building the matrix. If layer 1 is perturbed, only layers 1 and 2 respond; if layer 4 is perturbed, only layers 3 to 5. The two perturbations do not overlap and can therefore be tried at the same time in a single evaluation of y˙\dot y. For a wall, three evaluations are enough this way (layers 1, 4, 7, …; then 2, 5, 8, …; then 3, 6, 9, …), regardless of whether it has 10 or 100 layers. This grouping of independent columns is called graph colouring; the VICUS Solver knows the sparsity pattern in advance and applies it to the whole building.

Direct and iterative solvers

There are two kinds of solvers for the system of equations:

  • Direct solvers work on the principle of Gaussian elimination from school: eliminate unknowns step by step, then substitute backwards. Technically this is done via an LU decomposition, as a dense variant (Dense) for small systems or a sparse one (KLU) for large ones. The result is exact up to rounding errors.
  • Iterative solvers (Krylov methods such as GMRES or BiCGStab) approach the solution step by step. They need less memory and can be faster for very large systems. To make them converge quickly, the system is first conditioned with a preconditioner, such as an incomplete LU decomposition (ILU).

The default in VICUS Buildings is the direct sparse solver KLU. For typical building models it is the most robust choice.

What this means in practice

In day-to-day design work nobody has to configure these methods. Understanding them helps, however, when a simulation takes unusually long. The most common causes follow directly from this article:

  • Many small time steps due to switching: a thermostat with a narrow switching differential, or shading that opens and closes frequently, forces the solver into small steps at every switch.
  • Very fine discretisation: more layers per component mean more unknowns and therefore larger systems of equations.
  • Many Newton passes: strongly non-linear models or abrupt input data worsen convergence, and steps are rejected more often.

Solver settings in VICUS Buildings

The defaults (CVODE, KLU, relative tolerance 10−510^{-5}, maximum step size 1 hour) are almost always the best choice for building simulations. If you want to adjust them, all fields are described in the manual under Solver options. Before changing tolerances, look at the solver statistics: they show whether the time goes into many small steps, into Newton passes or into the linear system.

The VICUS Solver is the computational core of VICUS Buildings; its methodology is documented through the open-source project SIM-VICUS. Background is provided in the articles on dynamic building simulation, on the difference between steady-state and dynamic calculation and on validation standards. How the same computational core solves a district heating network is described in VICUS Solver: the Engine for Heat Network Simulation.

Summary

  1. The solver keeps books on energy: for every room and every wall layer, the change in heat content equals inflows minus outflows. Together this gives dy/dt=y˙(t,y)dy/dt = \dot y(t, y).
  2. y˙\dot y is assembled afresh at every call: determine temperatures, compute heat flows, sum up. The order of the sub-models follows from a dependency graph.
  3. Computation proceeds in time steps of adaptive size: large when little happens, small during switching events.
  4. Because buildings are stiff (minutes next to days), the computation is implicit, by default with CVODE. Explicit methods would have to follow the fastest part and would be too slow.
  5. Every implicit step requires a Newton iteration, and every Newton pass a linear system of equations. The fact that the matrix consists almost entirely of zeros is what makes both fast.

Authors

Dr.-Ing. Andreas Nicolai

Dr.-Ing. Andreas Nicolai

Chief Technology Officer

Developer of the solver and 3D engine, with years of experience in numerical simulation and software architecture.

Dipl.-Ing. Stephan Hirth

Dipl.-Ing. Stephan Hirth

Lead Developer VICUS Buildings

Algorithms, workflows and GUI of VICUS Buildings – from solver integration to the 3D engine.

Frequently asked questions

What does the VICUS Solver compute?
The VICUS Solver keeps an energy balance for every room and every wall layer: how much heat flows in, how much flows out, and how does that change the heat content? Together these balances form a large system of coupled differential equations, which the solver advances time step by time step, typically over a full year. Temperatures are derived from the stored energy. The VICUS Solver is the computational core of VICUS Buildings.
Why does building simulation compute implicitly rather than explicitly?
A building contains parts that react within minutes (room air, plaster) alongside parts that take days (concrete slabs, screed). An explicit method would have to follow the fastest part and use steps of seconds to a few minutes, otherwise the solution blows up. An implicit method such as CVODE stays stable even with steps of up to one hour; the step size is then governed only by the required accuracy.
What is ẏ (ydot) in building simulation?
ẏ is the rate of change of all stored quantities: for every room and every wall layer, the answer to the question 'how fast is the heat content rising or falling right now?'. In source code the corresponding function is usually called ydot. It is evaluated at runtime: determine temperatures from the stored energies, compute all heat flows, sum them per room and layer.
What are the Newton iteration and the linear system of equations (LSE)?
With implicit methods the result of a time step depends on itself. The Newton iteration resolves this by repeatedly improving an estimate: it replaces the equation locally by a straight line (or a linear approximation) and jumps to its zero. Each improvement requires solving a linear system J·Δy = −F with the Jacobian J. A time step usually needs 1 to 3 Newton iterations.
How large do these systems of equations get?
Each wall is split internally into many thin layers, and each layer is a separate unknown. Just 50 components with 30 layers each give 1,500 unknowns; larger buildings reach several thousand. The systems are sparse, however, because each layer exchanges heat only with its direct neighbours. The VICUS Solver exploits this with dedicated solvers (KLU, GMRES) and with graph colouring when building the Jacobian.

From article to project

Simulate buildings dynamically in VICUS Buildings.

Import geometry from IFC, assign constructions and usage, and verify summer thermal protection to DIN 4108-2 by thermal simulation.

VICUS Buildings

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.