apply_dae_contract
Stable function · Variable classification
Tier: stable · Kind: function · Topic: Variable classification
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
| not exported | not exported | not exported | apply_dae_contract | ApplyDAEContract |
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):
- Classify every equation as
differential(LHS is the STRUCTURAL time derivative — aDwhosewrtis the literal"t"or absent, esm-spec §4.2) oralgebraic(everything else — authored observed equations, explicit constraints, a SPATIALD, etc). The axis is NOT resolved againstdomain.independent_variable; seeis_differential. - If no algebraic equations exist, stamp
metadata.system_class = "ode"andmetadata.dae_infoand return. - If
dae_supportisfalse, returnE_NO_DAE_SUPPORTnaming the first offending path. - Otherwise, run the trivial-factoring preprocessor: repeatedly
pick any algebraic equation
lhs = Variable(v)whoserhsdoes not referencev, substitutev -> rhsinto every remaining equation (differential and algebraic), and drop the factored equation. Repeat until fixed point. - If algebraic equations remain (cyclic, implicit, or non-bare-LHS),
return
E_NONTRIVIAL_DAEnaming every residual path. - Otherwise, stamp
metadata.system_class = "ode",metadata.dae_info.algebraic_equation_count = 0, andmetadata.dae_info.factored_equation_count = <count>.
The input esm is mutated: factored algebraic equations are removed
and their substitutions applied to the remaining equations.
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.