Rust-powered system simulation

Drop-in replacement for PathSim. 50-100x faster. Same Python API, powered by a Rust simulation engine with automatic compilation to optimized Rust IR.

Example
Loading...

About

FastSim is a Rust reimplementation of PathSim. The Python API matches PathSim line for line, so existing models run unchanged, but the simulation core and numeric hot path execute entirely in compiled Rust, producing typical speedups of 50 to 100 times. PathSim remains the open-source reference, well suited to learning, research, and small models. FastSim is the proprietary production build of the same API, available under a commercial license. Reach out via Consulting or Support above if you want to evaluate it for your team or set up access for a production deployment.

Beyond running the shared API faster, FastSim adds capabilities that have no PathSim equivalent: a JIT compiler that traces Python callbacks into optimized Rust IR with symbolic automatic differentiation, dedicated blocks for index-1 differential-algebraic equations, and a periodic steady-state solver that finds the limit cycle of a driven system directly via Anderson-accelerated shooting. It can also lower any model to a serializable intermediate representation and compile subsystems or whole systems into fused native blocks. Custom blocks you subclass yourself run at the same native speed, with only the constructor staying in Python.

FastSim is free for noncommercial use under the PolyForm Noncommercial license. For commercial use, get in touch about a commercial license.

Performance

FastSim across the tooling landscape

Cost per integration step across 15 dynamical systems against every tool: FastSim (compiled + per-block), PathSim, OpenModelica, boost::odeint, CasADi/CVODES, SciPy, Diffrax and Numba. A missing marker means the tool cannot express that system (an explicit stepper on a stiff problem, a right-hand side it cannot compile). Warm is steady-state cost; Cold includes one-off compile/JIT. Same model, solver class and tolerances throughout. Lower is better.

JIT compilation

FastSim ships its own NumPy-compatible symbolic tracer. User-supplied Python callbacks get traced lazily the first time they run: the right-hand side of an ODE, the algebraic law of a Function, the output of a Source, the dynamics and outputs of a DynamicalSystem. Every arithmetic operation, every NumPy ufunc, every np.stack, np.sum, np.where or @ on the symbolic inputs records a node into an SSA graph. A pipeline of optimization passes (constant folding, CSE, algebraic identities, FMA fusion, dead-code elimination) simplifies the graph, which is then lowered into a flat Rust tape the simulation evaluates directly.

Once the trace succeeds, the Python interpreter is no longer involved inside the integration loop. Callbacks execute at Rust-native speed with no marshaling, no GIL, no per-op NumPy dispatch. The same graph is also differentiated symbolically to produce an analytical Jacobian that implicit solvers like ESDIRK43 consume for their Newton stage solve. Tracing covers every block that takes a user-supplied function: ODE, Function, Source, DynamicalSystem, DynamicalFunction, Wrapper, MassMatrixDAE, SemiExplicitDAE, and FullyImplicitDAE. If a callback uses something the tracer can't lower, that single block falls back to Python while the rest of the simulation keeps running native.

Intermediate representation

Every FastSim model has a second life as a typed, serializable intermediate representation. sim.to_ir() walks the live simulation and atomizes each block down to scalar SSA operations, producing a hierarchical Module that preserves subsystem structure, connections, parameters, and block-internal events. The IR round-trips losslessly through JSON, so a model can be captured, stored, diffed, or handed to another tool, and it is the substrate FastSim uses for code generation and cross-engine verification rather than a separate hand-written export.

The same op graph also powers compilation. subsystem.compile() fuses an entire subsystem into a single native block with its own fused dx/dt tape, a symbolic Jacobian built from that tape, and any internal events captured and replayed, then drops back into a normal simulation like any other block. sim.compile() takes it one step further and fuses a whole model into one tape over a global state vector. The block boundaries you design stay intact for authoring and introspection; compilation collapses them only where it pays off.

Differential-algebraic equations

FastSim treats index-1 DAEs as first-class blocks in three canonical forms. The SemiExplicitDAE block takes a system split into differential and algebraic parts and reduces it to a pure ODE by solving the algebraic constraint with an inner Newton iteration at every right-hand side evaluation, which means any of the 21 solvers can integrate it, including explicit ones. MassMatrixDAE covers the case where a constant mass matrix multiplies the derivative vector, with zero rows allowed so that physical conservation laws can enter the model directly. FullyImplicitDAE accepts the general residual and requires an implicit solver. All three blocks feed their analytical Jacobians to the stage solver when the user callback is traceable, which is what keeps the preconditioned Anderson acceleration fast.

Periodic steady state

FastSim finds the periodic limit cycle of a driven system directly via matrix-free Anderson-accelerated shooting on the period map g(x₀) = x(T; x₀). sim.periodic_steady_state(period, ...) integrates one period with the inner ODE solver of your choice (explicit, implicit, multistep, DAE-extended), then runs a per-block Anderson step that nudges x₀ toward the fixed point. No monodromy matrix is assembled or factorized; only function evaluations. Convergence uses the same WRMS-scaled NLS_COEF threshold every implicit-stage solver in FastSim does, so tolerances carry over from transient runs without retuning. Pays off when settling time exceeds roughly ten forcing periods: high-Q resonators, weakly-damped loops, large LC filters.

Native FMI 3.0

FastSim implements the FMI 3.0 standard directly in Rust. ModelExchangeFMU exposes the FMU's derivative function as a block right-hand side that the solver integrates alongside everything else, with event indicators translating into ZeroCrossing events and FMU-announced time events populating a ScheduleList. CoSimulationFMU runs the FMU on a fixed communication grid, scheduled through a block-internal event, and the full event-mode handshake runs whenever the FMU signals an event. The FMU behaves like any other block in the graph.

Commercial license

FastSim is free under the PolyForm Noncommercial license for research, teaching and personal projects. Using it, or its generated C code, in a commercial product needs a commercial license. Tell us about your use case and we’ll get back to you.

We use your details only to answer this enquiry. See the privacy policy.