Internal Details

This section documents the internal implementation details of ModelingToolkit. These APIs are not considered stable and may change without notice in non-breaking releases. They are documented here to help future contributors understand the library's inner workings.

Overview

ModelingToolkit's internal architecture consists of several key components:

  • Structural Transformation: Algorithms for transforming equation systems, including index reduction, tearing, and algebraic simplification
  • Bipartite Graphs: Graph representations used to analyze relationships between equations and variables
  • System Structure: Internal representations of system state and transformations

These components work together to enable ModelingToolkit's symbolic manipulation and code generation capabilities.

Warning

The functions and types documented in this section are internal implementation details. Users should not rely on these APIs as they may change or be removed without deprecation warnings.

Misc

  • Bindings, initial conditions and guesses are stored as AtomicArrayDict. This is a custom wrapper which only supports symbolic keys, and disallows keys which are indexed array variables.
  • Keys of parameter bindings cannot be present in get_ps(sys).

Precompile workloads

The precompile workload in ModelingToolkit and the ones in its OrdinaryDiffEq extensions build and solve the same two small models, so that mtkcompile, ODEProblem construction, initialization and the solver paths are all cached for one shape of generated problem.

ModelingToolkit.precompile_ode_problemFunction
precompile_ode_problem()

Small ODE used by the precompile workloads here and in the OrdinaryDiffEq extensions: tunable parameters, an observed variable eliminated by mtkcompile, and a trivial initialization problem, so the generated problem has the same types as a typical model.

source
ModelingToolkit.precompile_dae_problemFunction
precompile_dae_problem()

Small mass-matrix DAE used by the precompile workloads: one algebraic unknown fixed by a nonlinear constraint, so ODEProblem builds a non-trivial (SCC) initialization problem and solve runs OverrideInit.

source