# ODESystem

## System Constructors

ModelingToolkit.ODESystemType
struct ODESystem <: ModelingToolkit.AbstractODESystem

A system of ordinary differential equations.

Fields

• eqs

The ODEs defining the system.

• iv

Independent variable.

• states

Dependent (state) variables.

• ps

Parameter variables.

• pins

• observed

• tgrad

Time-derivative matrix. Note: this field will not be defined until calculate_tgrad is called on the system.

• name

Name: the name of the system

• systems

systems: The internal systems

• default_u0

default_u0: The default initial conditions to use when initial conditions are not supplied in ODEProblem.

• default_p

default_p: The default parameters to use when parameters are not supplied in ODEProblem.

Example

using ModelingToolkit

@parameters t σ ρ β
@variables x(t) y(t) z(t)
D = Differential(t)

eqs = [D(x) ~ σ*(y-x),
D(y) ~ x*(ρ-z)-y,
D(z) ~ x*y - β*z]

de = ODESystem(eqs,t,[x,y,z],[σ,ρ,β])
source

## Composition and Accessor Functions

• sys.eqs or equations(sys): The equations that define the ODE.
• sys.states or states(sys): The set of states in the ODE.
• sys.parameters or parameters(sys): The parameters of the ODE.
• sys.iv or independent_variable(sys): The independent variable of the ODE.

## Transformations

ModelingToolkit.ode_order_loweringFunction
ode_order_lowering(sys::ODESystem) -> ODESystem


Takes a Nth order ODESystem and returns a new ODESystem written in first order form by defining new variables which represent the N-1 derivatives.

source
ModelingToolkit.liouville_transformFunction
liouville_transform(sys::Any) -> ODESystem


Generates the Liouville transformed set of ODEs, which is the original ODE system with a new variable trJ appended, corresponding to the -tr(Jacobian). This variable is used for properties like uncertainty propagation from a given initial distribution density.

For example, if $u'=p*u$ and p follows a probability distribution $f(p)$, then the probability density of a future value with a given choice of $p$ is computed by setting the inital trJ = f(p), and the final value of trJ is the probability of $u(t)$.

Example:

using ModelingToolkit, OrdinaryDiffEq, Test

@parameters t α β γ δ
@variables x(t) y(t)
D = Differential(t)

eqs = [D(x) ~ α*x - β*x*y,
D(y) ~ -δ*y + γ*x*y]

sys = ODESystem(eqs)
sys2 = liouville_transform(sys)
@variables trJ

u0 = [x => 1.0,
y => 1.0,
trJ => 1.0]

prob = ODEProblem(sys2,u0,tspan,p)
sol = solve(prob,Tsit5())

Where sol[3,:] is the evolution of trJ over time.

Sources:

Probabilistic Robustness Analysis of F-16 Controller Performance: An Optimal Transport Approach

Abhishek Halder, Kooktae Lee, and Raktim Bhattacharya https://abhishekhalder.bitbucket.io/F16ACC2013Final.pdf

source

## Applicable Calculation and Generation Functions

calculate_jacobian
calculate_factorized_W
generate_jacobian
generate_factorized_W
jacobian_sparsity

## Problem Constructors

DiffEqBase.ODEFunctionType
function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
ps = parameters(sys);
jac = false,
sparse = false,
kwargs...) where {iip}

Create an ODEFunction from the ODESystem. The arguments dvs and ps are used to set the order of the dependent variable and parameter vectors, respectively.

source
DiffEqBase.ODEProblemType
function DiffEqBase.ODEProblem{iip}(sys::AbstractODESystem,u0map,tspan,
parammap=DiffEqBase.NullParameters();
kwargs...) where iip