Version: dev

apply_dae_contract

Stable function · Variable classification

Tier: stable · Kind: function · Topic: Variable classification

JuliaTypeScriptPythonRustGo
not exportednot exportednot exportedapply_dae_contractApplyDAEContract

Julia

Julia does not export this function.

TypeScript

TypeScript does not export this function.

Python

Python does not export this function.

Rust

pub fn apply_dae_contract(esm: &mut EsmFile, dae_support: bool) -> Result<DaeInfo, DaeError>

Run the RFC §12 DAE binding contract on esm in place and return the classification summary.

Behavior (rust strategy):

  1. Classify every equation as differential (LHS is the STRUCTURAL time derivative — a D whose wrt is the literal "t" or absent, esm-spec §4.2) or algebraic (everything else — authored observed equations, explicit constraints, a SPATIAL D, etc). The axis is NOT resolved against domain.independent_variable; see is_differential.
  2. If no algebraic equations exist, stamp metadata.system_class = "ode" and metadata.dae_info and return.
  3. If dae_support is false, return E_NO_DAE_SUPPORT naming the first offending path.
  4. Otherwise, run the trivial-factoring preprocessor: repeatedly pick any algebraic equation lhs = Variable(v) whose rhs does not reference v, substitute v -> rhs into every remaining equation (differential and algebraic), and drop the factored equation. Repeat until fixed point.
  5. If algebraic equations remain (cyclic, implicit, or non-bare-LHS), return E_NONTRIVIAL_DAE naming every residual path.
  6. Otherwise, stamp metadata.system_class = "ode", metadata.dae_info.algebraic_equation_count = 0, and metadata.dae_info.factored_equation_count = <count>.

The input esm is mutated: factored algebraic equations are removed and their substitutions applied to the remaining equations.

Source · Rust docs

Go

func ApplyDAEContract(file *ESMFile) (DAEInfo, error)

ApplyDAEContract applies the Go binding’s trivial-DAE strategy to every applicable model in file (mutating each in place) and classifies the result.

Per docs/rfcs/dae-binding-strategies.md, when an ESM model contains algebraic equations alongside differential ones, ApplyDAEContract factors out equations of the form

y ~ f(...)

where y is a plain variable that does not appear in f (acyclic). Such equations are symbolically substituted into every other equation (and into observed-variable expressions) and then removed from the model. The factoring runs to a fixed point so that chains like

z ~ g(y); y ~ h(x); D(x) ~ F(y, z)

reduce to a pure ODE in x.

It returns a populated DAEInfo and, if any non-trivial algebraic equations remain after factoring, a *RuleEngineError with code E_NONTRIVIAL_DAE whose message lists the residual equation paths and points the author at the Julia binding (full DAE via ModelingToolkit.jl) and RFC §12.

ApplyDAEContract does not run the RFC §11 discretization pipeline: it is intended to be composed with discretize() when that lands in Go, or called standalone by tools that need DAE factoring on an already discretized model. Models carrying an explicit non-ODE SystemKind (“nonlinear”, “sde”, “pde”) are skipped — the DAE contract only applies to would-be ODE systems.

Source · Go docs