ModelingToolkit.jl
Description¶
ModelingToolkit.jl is a modeling language. It can do both symbolic and numeric computation. It is highly performant and parallel. It is extendable because it brings ideas from symbolic CAS and causal/acausal equation-based modeling frameworks. The model can be input as a high-level description. Then, the model is analyzed and enhanced through symbolic preprocessing. It allows for automatic transformations, such as index reduction, to be applied before solving in order to easily handle equations that could not have been solved without symbolic intervention.
It mixes symbolic computing packages like SymPy or Mathematica with equation-based modeling systems like the causal Simulink and the acausal Modelica. It can easily transform to and from different kinds of equations like DAEs into optimization problems and vice-versa. All the symbolic systems have a direct conversion to a numerical system which can then be handled through the SciML interfaces. Before producing code, it simplifies and parallelizes the model.
Features¶
- Causal and acausal modeling (Simulink/Modelica)
- Automated model transformation, simplification, and composition
- Automatic conversion of numerical models into symbolic models
- Composition of models through the components, a lazy connection system, and tools for expanding/flattening
- Pervasive parallelism in symbolic computations and generated functions
- Transformations like alias elimination and tearing of nonlinear systems for efficiently numerically handling large-scale systems of equations
- The ability to use the entire Symbolics.jl CAS as part of the modeling process.
- Import models from common formats like SBML, CellML, BioNetGen, and more.
- Extendability: the whole system is written in pure Julia, so adding new functions, simplification rules, and model transformations has no barrier.
Feature List · ModelingToolkit.jl
Equation Types¶
- Ordinary differential equations
- Stochastic differential equations
- Partial differential equations
- Nonlinear systems
- Optimization problems
- Continuous-Time Markov Chains
- Chemical Reactions (via Catalyst.jl)
- Nonlinear Optimal Control
Standard Library¶
See ModelingToolkitStandardLibrary.jl
Model Import Formats¶
CellML¶
CellMLToolkit.jl can be used to import CellML models into ModelingToolkit. CellML is an XML-based open standard for mathematical models. It has a repository of more than a thousand models. While it's domain-agnostic, there's a focus on biomedical models. Currently, some of its active categories include:
- Cell Cycle
- Cell Migration
- Circadian Rhythms
- Gene Regulation
- Immunology
- Ion Transport
- Mechanical Constitutive Laws
- Metabolism
- Neurobiology
- PK/PD (pharmacokinetic/pharmacodynamic)
- Protein Modules
- Signal Transduction
- Synthetic Biology
CellMLToolkit.jl imports a CellML model in XML and outputs a ModelingToolkit.jl IR (Intermediate Representation) to work with using the general SciML ecosystem.
SBML¶
SBMLToolkit.jl can be used to import SBML (Systems Biology Markup Language) models into ModelingToolkit and the general SciML ecosystem. It uses SBML.jl which in turn provides a Julia wrapper to libSBML.
BioNetGen¶
You can use SBMLToolkit — more specifically, the writeSBML()
export function.
BioNetGen is for biochemical reaction networks modeling. Thus, you can use ReactionNetworkImporters.jl. You can also use ReactionNetworkImporters.jl to import:
- networks represented by dense or sparse substrate and product stoichiometric matrices
- networks represented by dense or sparse complex stoichiometric and incidence matrices
Notice that you can still use SBMLToolkit.jl, since you can export a model in SBML through BioNetGen (and COPASI, and Virtual Cell, etc.).
Extension Libraries¶
There's a lot of libraries that add features to the general equation-based modeling ecosystem that has ModelingToolkit as its core. Some are:
- Catalyst.jl: Symbolic representations of chemical reactions
- DataDrivenDiffEq.jl: Automatic identification of equations from data
- MomentClosure.jl: Automatic transformation of
ReactionSystems
into deterministic systems - ReactionMechanismSimulator.jl: Simulating and analyzing large chemical reaction mechanisms
- NumCME.jl: High-performance simulation of chemical master equations (CME)
- FiniteStateProjection.jl: High-performance simulation of CMEs via finite state projections
Compatible Numerical Solvers¶
Again, all of the symbolic systems have a direct conversion to a numerical system which can then be handled through the SciML interfaces. For example, after building a model and performing symbolic manipulations, an ODESystem
can be converted into an ODEProblem
to then be solved by a numerical ODE solver. Below is a list of the solver libraries which are the numerical targets of the ModelingToolkit system:
- DifferentialEquations.jl: Multi-package interface of high performance numerical solvers for
ODESystem
,SDESystem
, andJumpSystem
- NonlinearSolve.jl: High performance numerical solving of
NonlinearSystem
- Optimization.jl: Multi-package interface for numerical solving
OptimizationSystem
- NeuralPDE.jl: Physics-Informed Neural Network (PINN) training on
PDESystem
- MethodOfLines.jl: Automated finite difference method (FDM) discretization of
PDESystem