Concept page: fixed-step vs global ODE solvers, tolerances, code generation
nflow integrates a diagram in one of two ways. By default it runs a fixed-step discrete engine: each block updates once per model sample (the diagram sampleTime), and every continuous block integrates itself with a per-block Euler step. Selecting a solver switches to the global ODE path: all continuous states are assembled into one vector and integrated together, with zero-crossing detection and, for the adaptive solvers, step-size control.
Selecting a solver
Set the model's solver field, scripted with set_param(model, 'Solver', name), or from Simulation Settings in the editor's Simulation menu. The settings open in the inspector's Model tab. The default (no solver, or 'discrete') keeps the fixed-step engine, so existing models are unchanged — the global path is a pure opt-in.
Available solvers
Tolerances
The adaptive solvers are controlled by RelTol (relative, default 1e-6), AbsTol (absolute, default 1e-8) and an optional MaxStep ceiling. Set them with set_param, in the diagram fields, or in the editor's tolerance fields (shown when a variable-step solver is selected). Tighter tolerances give a more accurate trajectory at the cost of more sub-steps.
Code generation
The fixed-step ode1 / ode4 and the adaptive ode45 solvers are lowered to standalone C and Rust by nflow_codegenerate and NFlow.exportfmu: the generated code reproduces the engine's global integration (the generated ode45 stepper mirrors the ode45 backend) and matches the simulation. The CVODES / IDAS backends have no embedded lowering and are rejected by code generation with an actionable message — export such a model with ode4 or ode45, or simulate it with the solver.
Default rationale
The default stays fixed-step so that every existing model keeps producing exactly the same trajectory and the generated code matches the default simulation by construction. Opting into a global solver is a one-line change.
Stopping and resetting
Stop ends the current execution while keeping the results already calculated. Reset also returns simulation time to zero and clears the displayed results. Neither command changes the configured solver.
| Version | Description |
|---|---|
| 1.0.0 | initial version |