This is a page for detailing some of the inner workings to help future contributors to the library.
In the variable "elimination" algorithms, what is actually done is that variables are removed from being states and equations are moved into the
observed category of the system. The
observed equations are explicit algebraic equations which are then substituted out to completely eliminate these variables from the other equations, allowing the system to act as though these variables no longer exist.
However, as a user may have wanted to interact with such variables, for example, plotting their output, these relationships are stored and are then used to generate the
observed equation found in the
SciMLFunction interface, so that
sol[x] lazily reconstructs the observed variable when necessary. In this sense, there is an equivalence between observables and the variable elimination system.
The procedure for variable elimination inside
ModelingToolkit.alias_elimination. This step moves equations into
ModelingToolkit.dae_index_loweringby means of
pantelides!(if the system is an
Before a simulation or optimization can be performed, the symbolic equations stored in an
AbstractSystem must be converted into executable code. This step is typically occurs after the simplification explained above, and is performed when an instance of a
AbsSciMLBase.SciMLProblem, such as a
ODEProblem, is constructed. The call chain typically looks like this, with the function names in the case of an
ODESystem indicated in parenthesis
- Problem constructor (
- Build an
- Write actual executable code (
generate_function, which generates the dynamics function,
ODEFunction also builds functions for observed equations (
build_explicit_observed_function) and jacobians (
generate_jacobian) etc. These are all stored in the