This layered standard on top of FMI 3.0 defines how to exchange dynamic models in differential algebraic equation form.
| Although the document refers to version 3.0 of the FMI standard, everything described in this document also applies to all subsequent minor versions. For further information on compatibility, see section Versioning and Layered Standards in the FMI 3.0 specification. |
Copyright © 2025-2026 The Modelica Association Project FMI.
This document is licensed under the Attribution-ShareAlike 4.0 International license. The code is released under the 2-Clause BSD License. The license text can be found in the LICENSE.txt file that accompanies this distribution.
1. Introduction
1.1. Intent of this Document
A differential-algebraic system of equations (DAE) is a system of equations that either contains differential equations and algebraic equations, or is equivalent to such a system [1].
-
Avoid the requirement of index reduction inside of FMUs.
-
This could improve accuracy due to better drift handling.
-
-
Avoid local nonlinear equation solvers inside of FMUs.
-
This could improve accuracy and avoid problems with different local and global error tolerances.
-
-
Preserve the sparseness of DAE systems which is lost for the corresponding reduced ODE systems.
-
This could improve the performance by usage of the sparseness.
-
-
Allow connections between constraint FMUs.
-
Connecting reduced ODE FMUs could lead globally to a non-solvable (singular) system but not for unreduced DAE FMUs.
-
1.2. How to read this Document
The standard document is in HTML allowing heavy use of in-document links: all state names, function names, many function arguments, XML elements and attributes are links to definitions or descriptions.
In key parts of this document, non-normative examples are used to help understand the standard.
Conventions used in this document:
-
Non-normative text is given like this:
Especially examples are defined in this style. -
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 (regardless of formatting and capitalization).
-
State machine states are formatted as bold link, e.g. InitializationMode.
2. Common Concepts
This layered standard extends FMI 3.0 Model Exchange with support for semi-explicit index-1 differential-algebraic equations by introducing algebraic variables and residual equations alongside the continuous states and state derivatives from the core standard.
2.1. Mathematical Notation
This layered standard uses the same mathematical notation as provided in the FMI 3.0 standard under sub-section Mathematical Notation, with the addition of the symbols introduced here.
| Variable | Description |
|---|---|
A vector of real continuous-time variables representing the continuous-time algebraic variables. |
2.2. Mathematical Formulation
The DAE layered standard version 1.0.0-alpha.1 is intentionally restricted to semi-explicit index-1 DAEs used with FMI Model Exchange during Continuous-Time Mode.
The supported formulation of DAEs is
where:
-
\(\mathbf{x}_c\) denotes the continuous-time states,
-
\(\dot{\mathbf{x}}_c\) denotes the continuous-state derivatives,
-
\(\mathbf{a}_c\) denotes the algebraic variables,
-
\(\mathbf{u}_c\) denotes the continuous-time inputs,
-
\(\mathbf{p}\) denotes the parameters,
-
\(t\) denotes time,
-
\(\mathbf{f}_{\mathit{res}}\) denotes the algebraic equations expressed as residuals, and
-
\(\mathbf{y}\) denotes the outputs.
The equations \(\dot{\mathbf{x}}_c = \mathbf{f}_{\mathit{der}}(\mathbf{x}_c,\mathbf{a}_c,\mathbf{u}_c,\mathbf{p},t)\) are the differential equations of the model, which can be acquired with the usual way of either
-
calling
fmi3Geton the derivative variables provided in the extended<ModelStructure>defined in Section 3 , or -
calling
fmi3GetContinuousStateDerivatives.
The equations \(0 = \mathbf{f}_{\mathit{res}}(\mathbf{x}_c,\mathbf{a}_c,\mathbf{u}_c,\mathbf{p},t)\) are represented in the FMU by residual variables and constrain the algebraic variables together with the other continuous-time variables of the model. These can be acquired by calling fmi3Get on the residual variables provided in the extended <ModelStructure> defined in Section 3.
For the DAE to be index 1 in this layered standard means that the algebraic equations must be solvable for the algebraic variables. In particular, the Jacobian of the algebraic equations with respect to the algebraic variables must be non-singular.
Consequently, for given values of \(\mathbf{x}_c\), \(\mathbf{u}_c\), \(\mathbf{p}\), and \(t\), the algebraic equations determine \(\mathbf{a}_c\). The importer is responsible for determining values of the algebraic variables that satisfy
while the FMU provides the continuous-state derivatives and outputs according to the equations above.
This version of the layered standard does not define support for more general DAE formulations, including fully implicit DAEs, higher-index DAEs, or formulations that require differentiation of algebraic constraints. Such formulations must first be transformed into the supported semi-explicit index-1 form before they can be represented by this version of the layered standard.
The DAE formulation defined by this layered standard applies only while the Model Exchange FMU is in Continuous-Time Mode. Behavior associated with discontinuities, event handling, and DAE formulations outside Continuous Time Mode is outside the scope of version 1.0.0-alpha.1.
2.3. Changing between ODE and DAE Mode
An FMU that implements this layered standard is simultaneously a valid ODE FMU and a DAE FMU. To remain backward-compatible with importers that do not support this layered standard, the FMU defaults to ODE mode on instantiation. An importer that is aware of this layered standard must explicitly switch the FMU into DAE mode before use.
2.3.1. The enableDAEModeParameter Structural Parameter
Switching between ODE and DAE behavior is controlled by a structural parameter called enableDAEModeParameter.
A structural parameter (causality = structuralParameter) may only be set during Configuration Mode or Reconfiguration Mode.
This constraint ensures that the importer can re-examine the model structure from the manifest and reinitialize its solver before any computation takes place.
The variable enableDAEModeParameter is declared in the modelDescription.xml as a Boolean under <ModelVariables>. The name and valueReference is assigned freely by the FMU exporter; the importer locates the parameter by its valueReference declared in the <EnableDAEParameter> element of fmi-ls-manifest.xml.
The description attribute is optional.
An example of how the enableDAEModeParameter is declared:
<Boolean name="enableDAE"
valueReference="123"
causality="structuralParameter"
variability="tunable"
start="false"
description="Set to true to enable DAE mode as defined by FMI-LS-DAE."/>
| Value | Meaning |
|---|---|
|
The FMU behaves as a standard ODE Model Exchange FMU. All DAE-specific information in the layered standard manifest is ignored by the importer. |
|
The FMU behaves as a DAE FMU.
The importer must read the |
2.3.2. Entering DAE Mode
Because enableDAEModeParameter is a structural parameter, the importer must change it inside a configuration or reconfiguration scope.
2.3.2.1. At Instantiation (Configuration Mode)
The typical flow for an importer that uses the FMU in DAE mode from the start is:
-
Call
fmi3InstantiateModelExchange(…)to create the FMU instance. -
Call
fmi3EnterConfigurationMode(instance)to enter Configuration Mode. -
Call
fmi3SetBoolean(instance, {vr}, 1, {true}, 1)to enable DAE mode, wherevris thevalueReferenceofenableDAEModeParameter. -
Call
fmi3ExitConfigurationMode(instance)to return to the Instantiated state. -
Continue with the normal FMI initialization sequence (
fmi3EnterInitializationMode, etc.).
It should be emphasized that initialization in DAE mode is not yet fully specified. This means that when the FMU is initalized in DAE mode, either
-
the FMU will lift the residual equations to be solved by the importer, or
-
the FMU will still initialize in ODE mode, or
-
the FMU will error out.
2.3.2.2. During Simulation (Reconfiguration Mode)
When variability="tunable", an importer may also switch between ODE and DAE mode at runtime by entering Reconfiguration Mode from Event Mode:
-
Call
fmi3EnterConfigurationMode(instance)from Event Mode to enter Reconfiguration Mode. -
Call
fmi3SetBoolean(instance, {vr}, 1, {newValue}, 1)with the new mode value. -
Call
fmi3ExitConfigurationMode(instance)to return to Event Mode.
| After switching modes, the importer is responsible for reinitializing its solver, and ensuring a consistent state before resuming the simulation. |
2.4. ODE with Invariants
Many models possess quantities that remain constant along the exact solution, such as the total energy of a closed mechanical system, the total mass in a chemical reaction, or the distance between two bodies connected by a rigid rod. Such quantities are called invariants of the model.
Invariants also arise from index reduction. Many physical systems, for example in multibody dynamics, are naturally modeled as high-index DAEs. Reducing the index removes algebraic constraints from the equations that are actually solved, and those constraints become invariants of the reduced system.
Numerical integration does not preserve invariants exactly. Even when the initial values satisfy an invariant, the accumulated error of the integration makes the computed solution drift away from the manifold defined by that invariant. Exposing the invariants allows an importer to monitor this drift and to correct for it. See Section 4.3 for a detailed discussion of numerical drift and of the correction methods an importer can apply.
A model with invariants is described by the equations of Section 2.2, together with
where \(\mathbf{f}_{\mathit{inv}}\) denotes the invariants of the model and \(\mathbf{c}\) is constant along the exact solution.
The invariants of an ODE or of a semi-explicit DAE are exposed as variables of the modelDescription.xml and are listed in the <Invariant> element of the extended <ModelStructure>, see Section 3.
An invariant can be scalar or vectorial.
Invariants are independent of the residuals, and the same variable may be referenced by both an <Invariant> and a <Residual> element.
The FMU can optionally also expose the correction \(\boldsymbol{\delta} = \tilde{\mathbf{x}}_c - \mathbf{x}_c\) between the integrated state \(\mathbf{x}_c\) and the state \(\tilde{\mathbf{x}}_c\) projected back onto the invariant manifold.
3. Layered Standard Manifest File
This layered standard requires the use of a layered standard manifest file and it shall be stored inside the FMU at the following path: /extra/org.fmi-standard.fmi-ls-dae/fmi-ls-manifest.xml.
Several new elements are included as direct children of the root element in the layered standard manifest file to describe the DAE formulation.
| Element | Description |
|---|---|
Required element referencing the structural parameter in |
|
List of all algebraic variables exposed for the DAE formulation. |
|
Defines the structure of the DAE formulation for the model.
Especially, the ordered lists of outputs, continuous-time states, and the initial unknowns (the unknowns during InitializationMode) are re-defined and overwrite the corresponding ModelStructure present in the |
|
Optional annotations for the top-level element. |
The XML attributes of <fmiDAEManifest> are:
| Attribute | Namespace | Value | Description |
|---|---|---|---|
|
|
Name of the layered standard in reverse domain name notation. |
|
|
|
Version of the layered standard. This layered standard uses semantic versioning, as defined in [PW13]. |
|
|
|
String with a brief description of the layered standard that is suitable for display to users. |
3.1. Enabling DAE mode
The element <EnableDAEParameter> references the structural parameter in the modelDescription.xml that enables DAE mode.
See Section 2.3.1 for the full semantics and the calling sequences used to change the mode.
| Attribute | Description |
|---|---|
|
The value reference of the structural parameter present in the |
3.2. Algebraic variables
The element <AlgebraicVariables> defines the list of the algebraic variables.
| Element | Description |
|---|---|
|
An |
Each <AlgebraicVariable> has only one attribute defining the value reference.
| Attribute | Description |
|---|---|
|
The value reference for the algebraic variable present in the |
In the core Model Exchange standard there exists the API function fmi3GetNominalsOfContinuousStates, which only holds for the continous time states. There is currently no extension of the API for fmi-ls-dae. The algebraic variable could still have a nominal value defined by the nominal attribute for variables under <ModelVariables> of the modelDescription.xml, but in this case the nominal is constant.
|
3.3. Model Structure
The structure of the model for the DAE-formulation is defined in element <ModelStructure>.
It defines the dependencies between variables.
The <ModelStructure> element is extended with two additional elements - <Residual> and <Invariant> - and the optional dependencies can now include algebraic variables.
An FMU that follows this layered standard must expose all residuals using the <Residual> element.
Invariants of the model can optionally be exposed using the <Invariant> element.
The <ModelStructure> defined here extends the one from the core FMI standard.
All elements defined in the core standard (<Output>, <ContinuousStateDerivative>, <ClockedState>, <InitialUnknown>, <EventIndicator>) retain their existing semantics in this manifest, with the additions that:
-
Each element’s
dependenciesattribute may now also reference algebraic variables. -
The
<InitialUnknown>element is expanded so that algebraic variables can be included as unknowns.
The <ModelStructure> element is extended with two additional elements, <Residual> and <Invariant>, described below.
| Element | Description |
|---|---|
|
Ordered list of residual equations (constraints). Each residual element must reference a unique variable present in the |
|
Ordered list of invariants of the model, see Section 2.4.
Each |
| Attribute | Description |
|---|---|
|
The value reference of the residual variable \({v_{\mathit{unknown}}}\), which must be present in the |
|
Optional attribute defining the algebraic dependencies as a list of value references of the knowns \({\mathbf{v}_{\mathit{known}}}\) that this residual equation directly depends on. Knowns \({\mathbf{v}_{\mathit{known}}}\) in Continuous-Time Mode (ME) for
If |
|
See the description of |
3.4. Getting Partial Derivatives
The partial derivative API functions fmi3GetDirectionalDerivative and fmi3GetAdjointDerivative are used as defined in the core FMI standard, with the following extensions for DAE FMUs:
-
Residual variables can appear as unknowns.
-
Algebraic variables can appear as knowns for any unknown.
3.5. Example
As an example, consider a problem from chemical kinetics due to Robertson [Robertson1966], which is also included among the IDA example programs [Hindmarsh2026IDAExamples], and implemented as the Reference FMU Roberts. The DAE is given by
with initial conditions
The variable \(y_3\) does not appear differentiated in any equation and is therefore an algebraic variable. In the notation of Section 2.2, the continuous-time states and algebraic variables are
There are no inputs or parameters in this example, i.e., \(\mathbf{u}_c\) and \(\mathbf{p}\) are empty. The equations also have no explicit dependence on time.
3.5.1. Robertson DAE - Semi-Explicit DAE
Using the semi-explicit formulation defined in Section 2.2, the differential equations are
with
and the algebraic equation is
with
The initial values in this notation are
The Jacobian of the residual equation with respect to the algebraic variable is
which is non-singular. Hence, the algebraic equation can be locally solved for \(\mathbf{a}_c\), and the Robertson problem is an index-1 DAE in the representation supported by this layered standard.
Assume the FMU has the following variables:
| Variable | valueReference |
|---|---|
\(t\) |
0 |
|
1 |
\(y_1\) |
2 |
\(\dot{y}_1\) |
3 |
\(y_2\) |
4 |
\(\dot{y}_2\) |
5 |
\(y_3\) |
6 |
\(r\) |
7 |
Here, \(y_1\) and \(y_2\) are the components of \(\mathbf{x}_c\), while \(y_3\) is the single component of \(\mathbf{a}_c\). The residual \(\mathbf{f}_{\mathit{res}}\) is represented by the variable \(r\).
The DAE-specific manifest elements are:
<EnableDAEParameter valueReference="1"/>
<AlgebraicVariables>
<AlgebraicVariable valueReference="6"/>
</AlgebraicVariables>
<ModelStructure>
<ContinuousStateDerivative
valueReference="3"
dependencies="2 4 6"
dependenciesKind="constant constant constant"/>
<ContinuousStateDerivative
valueReference="5"
dependencies="2 4 6"
dependenciesKind="constant constant constant"/>
<InitialUnknown
valueReference="3"
dependencies="2 4 6"
dependenciesKind="constant constant constant"/>
<InitialUnknown
valueReference="5"
dependencies="2 4 6"
dependenciesKind="constant constant constant"/>
<InitialUnknown
valueReference="6"
dependencies="2 4 6"
dependenciesKind="constant constant constant"/>
<Residual
valueReference="7"
dependencies="2 4 6"
dependenciesKind="constant constant constant"/>
</ModelStructure>
3.5.2. Robertson DAE - Explicit ODE
Because the residual equation is locally solvable for \(\mathbf{a}_c\), the algebraic variable can be eliminated to obtain an explicit ODE.
For fixed \(\mathbf{x}_c\), \(\mathbf{u}_c\), \(\mathbf{p}\), and \(t\), consider the mapping
Its inverse with respect to \(\mathbf{a}_c\), evaluated at residual zero, gives
For the Robertson problem,
and therefore
Substituting this inverse into the differential equations gives the explicit ODE
For the Robertson problem, this becomes
The quantity corresponding to the algebraic variable in the DAE formulation can still be computed in the ODE representation as
The model is then represented as an ODE Model Exchange FMU. Using the value references of the Robertson FMU, the relevant variables are:
| Variable | valueReference |
|---|---|
\(t\) |
0 |
\(y_1\) |
2 |
\(\dot{y}_1\) |
3 |
\(y_2\) |
4 |
\(\dot{y}_2\) |
5 |
\(y_3\) |
6 |
In the ODE representation, \(y_3\) is computed from \(y_1\) and \(y_2\) and is not listed as an .<AlgebraicVariable>
The corresponding regular ODE ModelStructure available in the modelDescription.xml is:
<ModelStructure>
<ContinuousStateDerivative
valueReference="3"
dependencies="2 4"
dependenciesKind="dependent dependent"/>
<ContinuousStateDerivative
valueReference="5"
dependencies="2 4"
dependenciesKind="dependent dependent"/>
<InitialUnknown
valueReference="3"
dependencies="2 4"
dependenciesKind="dependent dependent"/>
<InitialUnknown
valueReference="5"
dependencies="2 4"
dependenciesKind="dependent dependent"/>
</ModelStructure>
4. Appendix
This appendix contains some general notes and discussions on the topic of DAEs.
4.1. DAE representation
There are different forms of DAEs.
For simplicity discontinuous states are currently disregarded.
4.1.1. Fully-Implicit DAE
The generic fully-implicit DAE, or implicit DAE, formulation:
where \(z(t)\) represents state and additional variables and \(t\) is time.
A similar and sometimes more useful representation:
with dynamic variables \(x(t)\), algebraic variables \(y(t)\) and time \(t\).
Note that \(x(t)\) is not necessarily the state variable, more on this in Section 4.1.7.2.
4.1.2. Semi-Explicit Index 1 / Hessenberg index 1 DAE
The semi-explicit index 1, also called Hessenberg index 1, DAE representation
with \(g\) solvable for \(y\), \(det \left( \frac{\partial}{\partial y}g\right) \neq 0\).
Here \(f\) is called the differential equations and \(g\) the algebraic equations.
4.1.3. Relationship between fully-implicit and semi-explicit DAE
A fully implicit DAE
can always be rewritten as a semi-explicit DAE by introducing a new algebraic variable \(x^{\prime}\)
4.1.4. Semi-Explicit DAE
The semi-explicit DAE representation
with \(g^1\) solvable for \(y\), \(det \left( \frac{\partial}{\partial y}g^1\right) \neq 0\) and \(\left\{ \frac{d}{dt} g_i^k \right\} \subseteq \{ g_i^{k-1}\}, \; k > 1\).
4.1.5. Mass matrix DAE
where mass matrix \(M\) is singular.
An equivalent explicit formulation:
See [cui2020mass].
4.1.6. Linear time-invariant DAE
where matrix \(E\) is singular.
4.1.7. Indices
There are multiple, sometimes closely related, definitions of indices for DAE systems. Usually these indices are a measure of how far from an ODE the DAE is.
4.1.7.1. Differential Index
The minimum number of times a DAE
has to be differentiated with respect to time \(t\) to be able to determine \(\dot{x}(t)\) as a function of \(t\) and \(x\) is called the differential index.
4.1.7.2. Perturbation Index
The perturbation index measures the sensitivity of the solution of a DAE to perturbations of its right-hand side. The DAE
has perturbation index \(p\) along a solution \(x(t)\) if \(p\) is the smallest non-negative integer such that the solution \(\tilde{x}(t)\) of the perturbed system
satisfies
for some constant \(C\) and a sufficiently small and smooth perturbation \(\delta(t)\). A DAE with perturbation index greater than 1 is called a higher-index DAE.
4.1.7.2.1. Example of Structural Singularity
[cellier2006continuous, chapter 7.7 Structural Singularity Elimination] provides a simple electric circuit model that is a higher-index DAE.
The circuit has two capacitors in parallel and can be represented with equations:
When both capacitive voltages \(v_1\) and \(v_2\) are chosen as state variables, equation \(v_2 = v_1\) has no unknowns left, so it is a constraint equation.
There are different ways to solve this. The modeler could change the causality or exporting tools can try to reduce the perturbation index symbolically [2] to end up with a consistent initialization for the system.
4.1.8. Hello World DAE Example
A simple initial-value problem
with variables \(x,y,z \in \mathbb{R}\) and start condition
at time \(t_0\). For this specific example a start condition \(x_0\) is sufficient to calculate consistent start values. The independent variable (usually time) \(t\) is omitted for simplicity.
4.1.8.1. Hello World DAE - Fully-Implicit DAE
The fully-implicit representation
is given by
4.1.8.2. Hello World DAE - Semi-Explicit DAE
The semi-explicit representation
is given by
4.1.8.3. Hello World DAE - Explicit ODE
This simple system could also be transformed into an explicit ODE formulation
with local variables \(y\) and \(z\)
and exported as an ODE ModelExchange FMU.
4.2. Generic DAE Use Case
There are a number of possible reasons to export a model as a system of differential-algebraic equations (DAE) instead of a system of ordinary differential equations (ODE):
-
The exporting tool doesn’t support methods to transform a DAE into ODE representation.
-
The time needed to perform symbolic transformation to ODE representation takes a significant amount of time for large systems.
-
Large system models are usually characterized by a high degree of sparsity. Some DAE solvers can utilize sparsity to reduce simulation time.
-
More efficient simulation of models with large algebraic loops for DAE representation.
See [braun2017solving].
4.2.1. Modelica Example CauerLowPassAnalog
The Modelica model Modelica.Electrical.Analog.Examples.CauerLowPassAnalog from the Modelica Standard Library [3]
Modelica.Electrical.Analog.Examples.CauerLowPassAnalog.has structural singularities.
To produce a complete and consistent set of initial conditions for the DAE, exporting tools usually use a symbolic index reduction algorithm.
The model has nine state candidates
1: L1.v (unit = "V" stateSelect=StateSelect.never ) "Voltage drop of the two pins (= p.v - n.v)" type: Real 2: L2.v (unit = "V" stateSelect=StateSelect.never ) "Voltage drop of the two pins (= p.v - n.v)" type: Real 3: C2.v (start = 0.0 unit = "V" ) "Voltage drop of the two pins (= p.v - n.v)" type: Real 4: C4.v (start = 0.0 unit = "V" ) "Voltage drop of the two pins (= p.v - n.v)" type: Real 5: L1.i (start = 0.0 unit = "A" fixed = true ) "Current flowing from pin p to pin n" type: Real 6: L2.i (start = 0.0 unit = "A" fixed = true ) "Current flowing from pin p to pin n" type: Real 7: C1.v (start = 0.0 unit = "V" fixed = true ) "Voltage drop of the two pins (= p.v - n.v)" type: Real 8: C5.v (start = 0.0 unit = "V" fixed = true ) "Voltage drop of the two pins (= p.v - n.v)" type: Real 9: C3.v (start = 0.0 unit = "V" fixed = true ) "Voltage drop of the two pins (= p.v - n.v)" type: Real
and four constraint equations
1: L2.v = C3.v - C5.v 2: L1.v = C1.v - C3.v 3: C4.v = L2.v 4: C2.v = L1.v
Modelica tools that want to export an ODE ModelExchange FMU need to reduce the perturbation index to index 1 to end up with an ODE representation of the DAE system.
One option to achieve this is the so called dummy derivative method.
From the set of state candidates, five state variables are chosen (e.g. C1.v, C3.v, C5.v, L1.i, L2.i) and the constraint equations
are differentiated
which results in four additional dummy states ($DER.L1.v, $DER.L2.v, $DER.C2.v, $DER.C4.v).
Here the Modelica keyword stateSelect influences how variables are picked.
4.2.2. Scaling Power Grids Example
For simulation models representing power grids on a national or larger scale, traditional ODE solvers could struggle with convergence and performance. Also, the time needed to perform symbolic transformation from DAE to ODE is growing with the number of equations.
See for example Modelica models ScalableTestSuite.Electrical.TransmissionLine.ScaledExperiments.TransmissionLineModelica_N_10 to ScalableTestSuite.Electrical.TransmissionLine.ScaledExperiments.TransmissionLineModelica_N_1280 from ScalableTestSuite [4].
The simulation was performed using OpenModelica v1.27-dev-92 with the following settings:
-
DAE export:
--daeMode -
Method: Sundials IDA [5]
Since OpenModelica does not support FMI 3.0 or FMI-LS-DAE at the time of writing, the export and simulation times were measured using OpenModelica’s default C export and simulation.
4.3. Invariants and Numerical Drift
This section gives the background for Section 2.4.
4.3.1. Numerical Drift
When a mathematical model is derived for a physical system, the fundamental conservation laws (such as energy or momentum) or geometric properties are directly embedded into the differential equations. These conservation laws define the system’s invariants (quantities that remain constant over time). Examples include total energy in a closed system, total mass in a chemical reaction, or angular momentum in a gravitational field.
The analytical solution to the differential equation respects these invariants perfectly. However, when numerical solvers (like Euler’s method, Runge-Kutta, or BDF methods) are used to simulate the differential equations, numerical drift is introduced.
Numerical solvers solve the ODEs/DAEs by approximating the continuous-time variable with a series of discrete steps. At each step, they calculate an update based on the current state, inevitably accumulating a small, local truncation error. While high-order methods can make this error very small for the state variables themselves, they are generally not designed to preserve arbitrary invariants of the system.
This means that even if the initial condition perfectly satisfies an invariant (e.g., total energy = \(E_0\)), after hundreds or thousands of time steps, the computed solution may slowly but surely "drift" away from the manifold defined by that invariant. The solver is effectively solving a nearby differential equation, one whose true solution does not possess the same conserved quantities.
As a consequence of numerical drift, the simulation can produce results that violate fundamental physical laws. A satellite’s orbit might slowly decay or escape when it should be stable. In molecular dynamics, the temperature (related to kinetic energy) might artificially rise or fall, rendering the simulation useless. Also, small drifts can accumulate, leading to a complete breakdown of the solution over long time horizons. The numerical solution may blow up or behave chaotically even when the true solution is well-behaved.
4.3.2. Example: The Mass-Spring Oscillator
Consider a physical system consisting of a mass \(m\) attached to a spring with a spring constant \(k\). When the mass is displaced by a distance \(x\) from its equilibrium position, the spring exerts a restoring force given by Hooke’s law:
Applying Newton’s second law (\(m\ddot{x} = F\)) gives:
To solve this numerically, we convert it into a system of two first-order ODEs by introducing velocity (\(v = \dot{x}\)):
The total mechanical energy \(I(x, v)\) (the Hamiltonian) of this closed system is the sum of kinetic and potential energy, which must remain strictly constant:
In the phase space of \((x, v)\), the analytical solution traces out a perfect, closed ellipse, forever staying on this fixed physical "energy manifold".
Now, let’s simulate this system using the explicit Euler method with a time step \(h\):
If we substitute this numerical update step back into our energy invariant function \(I(x, v)\), we find:
Expanding this expression reveals:
The energy is not conserved. Because the error term on the right is strictly positive (\(h^2 > 0\), \(k > 0\), \(m > 0\)), the total calculated energy artificially increases at every single time step. Instead of tracing a stable, closed ellipse, the numerical solution spirals outward indefinitely. The solver has no built-in knowledge of the system’s physics and lacks a mechanism to constrain its steps to the true energy manifold.
The MassSpringOscillator reference FMU implements this example and exposes \(I(x, v)\) as an <Invariant>, see reference-FMUs/MassSpringOscillator.
|
4.3.3. DAE Index Reduction and ODE with Invariants
The constraints are not always related to conservation laws. If the index of a DAE is reduced to zero to obtain an ODE, some equations may be omitted. In order to ensure that these equations are taken into account and used to avoid drift, these equations should be exploited.
The connection between an ODE solved with invariants and a DAE is fundamental, particularly when dealing with index reduction. Many physical systems, such as multibody dynamics, are naturally modeled as high-index DAEs. Reducing the DAE index to zero (transforming it into an ODE) simplifies the solution process but removes the original algebraic constraints from the solved equations. These constraints, which define the system’s geometric invariants (e.g., the set of physically allowed positions), are then subject to numerical drift.
After sufficient differentiation, we often obtain a pure ODE \(\dot{y}=F(y)\) for which the original algebraic constraint \(g(y)=0\) is no longer part of the differential equations. Instead, it becomes an invariant:
Since the consistent initial condition satisfies \(g(y(0))=0\), the reduced ODE should preserve \(g(y(t))=0\). Thus, the algebraic constraints of the original DAE become invariants of the reduced ODE.
Consider the planar pendulum, an index-3 model constrained by the length of the rod. The full index-3 DAE in Cartesian coordinates is:
Index reduction eliminates \(\lambda\) and produces an ODE in \((x, y, u, v)\), but removes the original constraints. The resulting ODE no longer enforces:
-
Position invariant: \(g_1=x^2 + y^2 - L^2\)
-
Velocity invariant: \(g_2=x u + y v\)
If the invariants are ignored, numerical drift in the integration of the ODE alone causes, for example, the pendulum to stretch or shrink over time. To prevent numerical drift, both constraints must be enforced via projection after each integration step (or every few steps).
4.3.4. Invariant and Manifold Checking
This is where invariant and manifold checking (and correction) becomes essential. To preserve physical fidelity, simulations must actively monitor and correct for drift using one of two strategies.
4.3.4.1. State Augmentation (Continuous Correction)
In this approach the invariants are incorporated in the ODE using a Lagrange multiplier. If numerical errors cause \(g(y) \neq 0\), the trajectory slowly leaves the constraint manifold. An invariant-preserving formulation augments the ODE with a correction term:
where \(\lambda\) is chosen so that:
This equation determines \(\lambda\) and ensures that the solution remains on the constraint manifold.
4.3.4.2. Geometric Projection (Discrete Correction)
In this method, at regular intervals during the simulation, we calculate and monitor the value of the known invariants using the current numerical state. For example, we compute \(I(x_n, v_n)\) and monitor its change from the initial value \(I(x_0, v_0)\). A significant deviation is a direct measure of the simulation’s accumulated error with respect to the physics of the problem.
For critical simulations, the projection method is a popular method where the correction is done during the integration. With standard numerical solvers (multi-step or single step), after a few steps or even after every step, the solution is "projected" back onto the correct invariant manifold. For instance, the state \((x_n, v_n)\) is minimally adjusted to a new state \((\tilde{x}_n, \tilde{v}_n)\) such that \(I(\tilde{x}_n, \tilde{v}_n) = I(x_0, v_0)\). Some off-the-shelf open-source numerical solvers support this feature.
For multiple invariants, the correction is obtained by solving a small constrained least-squares problem involving the Jacobian of all constraints, replacing the single invariant \(I(x)\) with a vector of \(m\) constraints \(H(x) \in \mathbb{R}^m\). For \(m\) constraints \(H(x) \in \mathbb{R}^m\), the correction is:
References
-
[cellier1993automated] Cellier, Francois E., and Hilding Elmqvist. "Automated formula manipulation supports object-oriented continuous-system modeling". IEEE Control Systems Magazine 13.2 (1993): 28-38.
-
[braun2017solving] Willi Braun, Francesco Casella, and Bernhard Bachmann. "Solving Large-Scale Modelica Models: New Approaches and Experimental Results Using OpenModelica". Linköping Electronic Conference Proceedings (Print), pp. 557-563. Linköping University Electronic Press, 2017. https://re.public.polimi.it/bitstream/11311/1065357/1/2017-BraunCasellaBachmann.pdf
-
[casella2015simulation] Casella, Francesco. "Simulation of Large-Scale Models in Modelica: State of the Art and Future Perspectives". Proceedings of the 11th International Modelica Conference, pp. 459-468, 2015. https://dx.doi.org/10.3384/ecp15118459
-
[PW13] Preston-Werner, T. (2013): Semantic Versioning 2.0.0. https://semver.org/spec/v2.0.0.html
-
[Hindmarsh2026IDAExamples] Hindmarsh, Alan C., Radu Serban, and Aaron Collier. Example Programs for IDA v7.8.0. Technical Report UCRL-SM-208113. Lawrence Livermore National Laboratory, 2026.
-
[Brenan] Brenan, K. E., Campbell, S. L., Petzold, L. R. (1996) "Numerical Solution of Initial-Value Problems in Differential-Algebraic Equations" SIAM.
-
[Hairer1] Hairer, E., Wanner, G. (1996). "Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems" Springer.
-
[Hairer2] Hairer, E., Lubich, C., & Wanner, G. "Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations" Springer.
-
[MN2018] NAJAFi M. "Simulation of high-index DAEs and ODEs with constraints in FMI" Proceedings of the 2nd Japanese Modelica Conference Tokyo, Japan, 2018.