# ODESystem

## Basic Operation of ODESystem

When an ODESystem is triggered, it reads its current time from its trigger link, reads its input, solves its differential equation and computes its output. Let us observe the basic operation of ODESystems with a simple example.

We first construct an ODESystem. Since an ODESystem is represented by its state equation and output equation, we need to define those equations.

julia> using Causal # hide

julia> sfunc(dx,x,u,t) = (dx .= -0.5x)
sfunc (generic function with 1 method)

julia> ofunc(x, u, t) = x
ofunc (generic function with 1 method)

Let us construct the system

julia> ds = ODESystem(righthandside=sfunc, readout=ofunc, state=[1.], input=Inport(1), output=Outport(1))
The applicable method may be too new: running in world age 47354, while current world is 95804.
Closest candidates are:
FastBroadcast.BroadcastCharacteristics(!Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any) at /juliateam/.julia/packages/FastBroadcast/2JngL/src/FastBroadcast.jl:106 (method too new to be called from this world context.)

Note that ds is a single input single output ODESystem with an initial state of [1.] and initial time 0.. To drive, i.e. trigger ds, we need to launch it.

julia> oport, iport, trg, hnd = Outport(1), Inport(1), Outpin(), Inpin{Bool}()
(Outport(numpins:1, eltype:Outpin{Float64}), Inport(numpins:1, eltype:Inpin{Float64}), Outpin(eltype:Float64, isbound:false), Inpin(eltype:Bool, isbound:false))

julia> connect!(oport, ds.input)
ERROR: UndefVarError: ds not defined

julia> connect!(ds.output, iport)
ERROR: UndefVarError: ds not defined

julia> connect!(trg, ds.trigger)
ERROR: UndefVarError: ds not defined

julia> connect!(ds.handshake, hnd)
ERROR: UndefVarError: ds not defined

ERROR: UndefVarError: ds not defined

julia> task2 = @async while true
all(take!(iport) .=== NaN) && break
end
MethodError: no method matching take!(::Missing)
Closest candidates are:
take!(!Matched::IOBuffer) at iobuffer.jl:385
take!(!Matched::Base.GenericIOBuffer) at iobuffer.jl:370
take!(!Matched::Channel) at channels.jl:383
...
Stacktrace:
[1] take!(pin::Inpin{Float64})
@ Causal ~/.julia/packages/Causal/vOCIT/src/connections/pin.jl:111
[4] getindex
[5] macro expansion
[6] macro expansion
@ ./simdloop.jl:77 [inlined]
[7] copyto!
[8] copyto!
[9] copy
[10] materialize
[11] take!(inport::Inport{Inpin{Float64}})
@ Causal ~/.julia/packages/Causal/vOCIT/src/connections/port.jl:186
[12] macro expansion
@ ./none:2 [inlined]
[13] (::Main.ex-ode_ex.var"#1#2")()
@ Main.ex-ode_ex ./task.jl:406

When launched, ds is ready to driven. ds is driven from its trigger link. Note that the trigger link of ds is writable.

julia> ds.trigger.link
ERROR: UndefVarError: ds not defined

Let us drive ds to the time of t of 1 second.

julia> put!(trg, 1.)
ERROR: MethodError: no method matching iterate(::Missing)
Closest candidates are:
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at range.jl:664
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
...

When driven, ds reads current time of t from its trigger link, reads its input value from its input, solves its differential equation and computes its output values and writes its output. So, for the step to be continued, an input values must be written. Note that the input of ds is writable,

julia> ds.input[1].link
ERROR: UndefVarError: ds not defined

Let us write some value.

julia> put!(oport, [5.])
ERROR: MethodError: no method matching iterate(::Missing)
Closest candidates are:
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at range.jl:664
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
...

At this point, ds completed its step and put true to its handshake link to signal that its step is succeeded.

julia> hnd.link
missing

To complete the step and be ready for another step, we need to approve the step by reading its handshake.

julia> take!(hnd)
ERROR: MethodError: no method matching take!(::Missing)
Closest candidates are:
take!(!Matched::IOBuffer) at iobuffer.jl:385
take!(!Matched::Base.GenericIOBuffer) at iobuffer.jl:370
take!(!Matched::Channel) at channels.jl:383
...

At this point, ds can be driven further.

julia> for t in 2. : 10.
put!(trg, t)
put!(oport, [t * 10])
take!(hnd)
end
ERROR: MethodError: no method matching iterate(::Missing)
Closest candidates are:
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at range.jl:664
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
...

Note that all the output value of ds is written to its outputbus,

julia> iport[1].link.buffer
ERROR: type Missing has no field buffer

When we launched ds, we constructed a task and the task is still running.

julia> task

MethodError: no method matching take!(::Missing)
Closest candidates are:
take!(!Matched::IOBuffer) at iobuffer.jl:385
take!(!Matched::Base.GenericIOBuffer) at iobuffer.jl:370
take!(!Matched::Channel) at channels.jl:383
...
Stacktrace:
[1] take!(pin::Inpin{Float64})
@ Causal ~/.julia/packages/Causal/vOCIT/src/connections/pin.jl:111
[4] getindex
[5] macro expansion
[6] macro expansion
@ ./simdloop.jl:77 [inlined]
[7] copyto!
[8] copyto!
[9] copy
[10] materialize
[11] take!(inport::Inport{Inpin{Float64}})
@ Causal ~/.julia/packages/Causal/vOCIT/src/connections/port.jl:186
[12] macro expansion
@ ./none:2 [inlined]
[13] (::Main.ex-ode_ex.var"#1#2")()
@ Main.ex-ode_ex ./task.jl:406

To terminate the task safely, we need to terminateds safely.

julia> put!(trg, NaN)
ERROR: MethodError: no method matching iterate(::Missing)
Closest candidates are:
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at range.jl:664
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
...

julia> put!(ds.output, [NaN])
ERROR: UndefVarError: ds not defined

Now, the state of the task is done.

julia> task

MethodError: no method matching take!(::Missing)
Closest candidates are:
take!(!Matched::IOBuffer) at iobuffer.jl:385
take!(!Matched::Base.GenericIOBuffer) at iobuffer.jl:370
take!(!Matched::Channel) at channels.jl:383
...
Stacktrace:
[1] take!(pin::Inpin{Float64})
@ Causal ~/.julia/packages/Causal/vOCIT/src/connections/pin.jl:111
[4] getindex
[5] macro expansion
[6] macro expansion
@ ./simdloop.jl:77 [inlined]
[7] copyto!
[8] copyto!
[9] copy
[10] materialize
[11] take!(inport::Inport{Inpin{Float64}})
@ Causal ~/.julia/packages/Causal/vOCIT/src/connections/port.jl:186
[12] macro expansion
@ ./none:2 [inlined]
[13] (::Main.ex-ode_ex.var"#1#2")()
@ Main.ex-ode_ex ./task.jl:406

So, it is not possible to drive ds.

## Mutation in State Function in ODESystem

Consider a system with the following ODE

$$$\begin{array}{l} \dot{x} = f(x, u, t) \\ y = g(x, u, t) \\ \end{array}$$$

where $x \in R^d, y \in R^m, u \in R^p$. To construct and ODESystem, The signature of the state function statefunc must be of the form

function statefunc(dx, x, u, t)
dx .= ... # Update dx
end

Note that statefuncdoes not constructdx but updatesdx and does not return anything. This is for performance reasons. On the contrary, the signature of the output function outputfunc must be of the form,

function outputfunc(x, u, t)
y = ... # Compute y
return y
end

Note the output value y is computed and returned from outputfunc. y is not updated but generated in the outputfunc.

## Full API

Causal.@def_ode_systemMacro
@def_ode_system ex

where ex is the expression to define to define a new AbstractODESystem component type. The usage is as follows:

@def_ode_system mutable struct MyODESystem{T1,T2,T3,...,TN,OP,RH,RO,ST,IP,OP} <: AbstractODESystem
param1::T1 = param1_default                     # optional field
param2::T2 = param2_default                     # optional field
param3::T3 = param3_default                     # optional field
⋮
paramN::TN = paramN_default                     # optional field
righthandside::RH = righthandeside_function     # mandatory field
state::ST = state_default                       # mandatory field
input::IP = input_default                       # mandatory field
output::OP = output_default                     # mandatory field
end

Here, MyODESystem has N parameters. MyODESystem is represented by the righthandside and readout function. state, input and output is the state, input port and output port of MyODESystem.

Warning

righthandside must have the signature

function righthandside(dx, x, u, t, args...; kwargs...)
dx .= .... # update dx
end

and readout must have the signature

function readout(x, u, t)
y = ...
return y
end
Warning

New ODE system must be a subtype of AbstractODESystem to function properly.

Warning

New ODE system must be mutable type.

Example

julia> @def_ode_system mutable struct MyODESystem{RH, RO, IP, OP} <: AbstractODESystem
α::Float64 = 1.
β::Float64 = 2.
righthandside::RH = (dx, x, u, t, α=α) -> (dx[1] = α * x[1] + u[1](t))
readout::RO = (x, u, t) -> x
state::Vector{Float64} = [1.]
input::IP = Inport(1)
output::OP = Outport(1)
end

julia> ds = MyODESystem();

julia> ds.input
1-element Inport{Inpin{Float64}}:
Inpin(eltype:Float64, isbound:false)
Causal.ODESystemType
mutable struct ODESystem{RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a generic ODE system.

Fields

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16875"} where var"#s16875"<:Real

State

• input::Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}

Input. Expected to an Inport or Nothing

• output::Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Example

julia> ds = ODESystem(righthandside=(dx,x,u,t)->(dx.=-x), readout=(x,u,t)->x, state=[1.],input=nothing, output=Outport(1));

julia> ds.state
1-element Array{Float64,1}:
1.0
Causal.ContinuousLinearSystemType
mutable struct ContinuousLinearSystem{T1<:(AbstractMatrix{var"#s16875"} where var"#s16875"<:Real), T2<:(AbstractMatrix{var"#s16874"} where var"#s16874"<:Real), T3<:(AbstractMatrix{var"#s16873"} where var"#s16873"<:Real), T4<:(AbstractMatrix{var"#s16872"} where var"#s16872"<:Real), IP<:(Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Inport, var"#s16631"<:Nothing}), OP<:(Union{var"#s16630", var"#s16629"} where {var"#s16630"<:Outport, var"#s16629"<:Nothing}), ST<:(AbstractVector{var"#s16628"} where var"#s16628"<:Real), RH, RO, var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a ContinuousLinearSystem with input and output. state is the initial state and t is the time. modelargs and modelkwargs are passed into ODEProblem and solverargs and solverkwargs are passed into solve method of DifferentialEquations. alg is the algorithm to solve the differential equation of the system.

The ContinuousLinearSystem is represented by the following state and output equations.

$$$\begin{array}{l} \dot{x} = A x + B u \\[0.25cm] y = C x + D u \end{array}$$$

where $x$ is state. solver is used to solve the above differential equation.

Fields

• A::AbstractMatrix{var"#s16875"} where var"#s16875"<:Real

A

• B::AbstractMatrix{var"#s16874"} where var"#s16874"<:Real

B

• C::AbstractMatrix{var"#s16873"} where var"#s16873"<:Real

C

• D::AbstractMatrix{var"#s16872"} where var"#s16872"<:Real

D

• input::Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Inport, var"#s16631"<:Nothing}

Input. Expected to be an Inport of Nothing

• output::Union{var"#s16630", var"#s16629"} where {var"#s16630"<:Outport, var"#s16629"<:Nothing}

Output port

• state::AbstractVector{var"#s16628"} where var"#s16628"<:Real

State

• righthandside::Any

Right-hand-side function

• readout::Any

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.LorenzSystemType
mutable struct LorenzSystem{T1<:Real, T2<:Real, T3<:Real, T4<:Real, RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a LorenzSystem with input and output. sigma, beta, rho and gamma is the system parameters. state is the initial state and t is the time. modelargs and modelkwargs are passed into ODEProblem and solverargs and solverkwargs are passed into solve method of DifferentialEquations. alg is the algorithm to solve the differential equation of the system.

If input is nothing, the state equation of LorenzSystem is

$$$\begin{array}{l} \dot{x}_1 = \gamma (\sigma (x_2 - x_1)) \\[0.25cm] \dot{x}_2 = \gamma (x_1 (\rho - x_3) - x_2) \\[0.25cm] \dot{x}_3 = \gamma (x_1 x_2 - \beta x_3) \end{array}$$$

where $x$ is state. solver is used to solve the above differential equation. If input is not nothing, then the state eqaution is

$$$\begin{array}{l} \dot{x}_1 = \gamma (\sigma (x_2 - x_1)) + \sum_{j = 1}^3 \alpha_{1j} u_j \\[0.25cm] \dot{x}_2 = \gamma (x_1 (\rho - x_3) - x_2) + \sum_{j = 1}^3 \alpha_{2j} u_j \\[0.25cm] \dot{x}_3 = \gamma (x_1 x_2 - \beta x_3) + \sum_{j = 1}^3 \alpha_{3j} u_j \end{array}$$$

where $A = [�lpha_{ij}]$ is cplmat and $u = [u_{j}]$ is the value of the input. The output function is

$$$y = g(x, u, t)$$$

where $t$ is time t, $y$ is the value of the output and $g$ is outputfunc.

Fields

• σ::Real

α

• β::Real

β

• ρ::Real

ρ

• γ::Real

γ

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16875"} where var"#s16875"<:Real

State

• input::Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ForcedLorenzSystemType
mutable struct ForcedLorenzSystem{T1<:Real, T2<:Real, T3<:Real, T4<:Real, CM<:(AbstractMatrix{var"#s16875"} where var"#s16875"<:Real), RH, RO, ST<:(AbstractVector{var"#s16874"} where var"#s16874"<:Real), IP<:(Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}), OP<:(Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a LorenzSystem that is driven by its inputs.

Fields

• σ::Real

σ

• β::Real

β

• ρ::Real

ρ

• γ::Real

γ

• cplmat::AbstractMatrix{var"#s16875"} where var"#s16875"<:Real

Input coupling matrix. Expected a diagonal matrix

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16874"} where var"#s16874"<:Real

State

• input::Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ChenSystemType
mutable struct ChenSystem{T1<:Real, T2<:Real, T3<:Real, T4<:Real, RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a ChenSystem with input and output. a, b, c and gamma is the system parameters. state is the initial state and t is the time. modelargs and modelkwargs are passed into ODEProblem and solverargs and solverkwargs are passed into solve method of DifferentialEquations. alg is the algorithm to solve the differential equation of the system.

If input is nothing, the state equation of ChenSystem is

$$$\begin{array}{l} \dot{x}_1 = \gamma (a (x_2 - x_1)) \\[0.25cm] \dot{x}_2 = \gamma ((c - a) x_1 + c x_2 + x_1 x_3) \\[0.25cm] \dot{x}_3 = \gamma (x_1 x_2 - b x_3) \end{array}$$$

where $x$ is state. solver is used to solve the above differential equation. If input is not nothing, then the state eqaution is

$$$\begin{array}{l} \dot{x}_1 = \gamma (a (x_2 - x_1)) + \sum_{j = 1}^3 \alpha_{1j} u_j \\[0.25cm] \dot{x}_2 = \gamma ((c - a) x_1 + c x_2 + x_1 x_3) + \sum_{j = 1}^3 \alpha_{2j} u_j \\[0.25cm] \dot{x}_3 = \gamma (x_1 x_2 - b x_3) + \sum_{j = 1}^3 \alpha_{3j} u_j \end{array}$$$

where $A = [\alpha_{ij}]$ is cplmat and $u = [u_{j}]$ is the value of the input. The output function is

$$$y = g(x, u, t)$$$

where $t$ is time t, $y$ is the value of the output and $g$ is outputfunc.

Fields

• a::Real

a

• b::Real

b

• c::Real

c

• γ::Real

γ

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16875"} where var"#s16875"<:Real

State

• input::Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}

Input. Expected to be and Inport or Nothing

• output::Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ForcedChenSystemType
mutable struct ForcedChenSystem{T1<:Real, T2<:Real, T3<:Real, T4<:Real, CM<:(AbstractMatrix{var"#s16875"} where var"#s16875"<:Real), RH, RO, ST<:(AbstractVector{var"#s16874"} where var"#s16874"<:Real), IP<:(Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}), OP<:(Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs Chen system driven by its inputs.

Fields

• a::Real

a

• b::Real

b

• c::Real

c

• γ::Real

γ

• cplmat::AbstractMatrix{var"#s16875"} where var"#s16875"<:Real

Input coupling matrix. Expected to be a diaognal matrix

• righthandside::Any

• readout::Any

• state::AbstractVector{var"#s16874"} where var"#s16874"<:Real

State

• input::Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}

Output pprt

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ChuaSystemType
mutable struct ChuaSystem{DT, T1<:Real, T2<:Real, T3<:Real, RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a ChuaSystem with input and output. diode, alpha, beta and gamma is the system parameters. state is the initial state and t is the time. modelargs and modelkwargs are passed into ODEProblem and solverargs and solverkwargs are passed into solve method of DifferentialEquations. alg is the algorithm to solve the differential equation of the system.

If input is nothing, the state equation of ChuaSystem is

$$$\begin{array}{l} \dot{x}_1 = \gamma (\alpha (x_2 - x_1 - h(x_1))) \\[0.25cm] \dot{x}_2 = \gamma (x_1 - x_2 + x_3 ) \\[0.25cm] \dot{x}_3 = \gamma (-\beta x_2) \end{array}$$$

where $x$ is state. solver is used to solve the above differential equation. If input is not nothing, then the state eqaution is

$$$\begin{array}{l} \dot{x}_1 = \gamma (\alpha (x_2 - x_1 - h(x_1))) + \sum_{j = 1}^3 \theta_{1j} u_j \\[0.25cm] \dot{x}_2 = \gamma (x_1 - x_2 + x_3 ) + \sum_{j = 1}^3 \theta_{2j} u_j \\[0.25cm] \dot{x}_3 = \gamma (-\beta x_2) + \sum_{j = 1}^3 \theta_{3j} u_j \end{array}$$$

where $\Theta = [\theta_{ij}]$ is cplmat and $u = [u_{j}]$ is the value of the input. The output function is

$$$y = g(x, u, t)$$$

where $t$ is time t, $y$ is the value of the output and $g$ is outputfunc.

Fields

• diode::Any

Chua diode. See PiecewiseLinearDiode

• α::Real

α

• β::Real

β

• γ::Real

γ

• righthandside::Any

Right-hand-side function

• readout::Any

Reaout function

• state::AbstractVector{var"#s16875"} where var"#s16875"<:Real

State

• input::Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ForcedChuaSystemType
mutable struct ForcedChuaSystem{DT, T1<:Real, T2<:Real, T3<:Real, CM<:(AbstractMatrix{var"#s16875"} where var"#s16875"<:Real), RH, RO, ST<:(AbstractVector{var"#s16874"} where var"#s16874"<:Real), IP<:(Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}), OP<:(Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a Chua system with inputs.

Fields

• diode::Any

Chua diode. See PiecewiseLinearDiode

• α::Real

α

• β::Real

β

• γ::Real

γ

• cplmat::AbstractMatrix{var"#s16875"} where var"#s16875"<:Real

Input coupling matrix. Expected to be a digonal matrix.

• righthandside::Any

Right-hand-side matrix

• readout::Any

• state::AbstractVector{var"#s16874"} where var"#s16874"<:Real

State

• input::Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.RosslerSystemType
mutable struct RosslerSystem{T1<:Real, T2<:Real, T3<:Real, T4<:Real, RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a RosllerSystem with input and output. a, b, c and gamma is the system parameters. state is the initial state and t is the time. modelargs and modelkwargs are passed into ODEProblem and solverargs and solverkwargs are passed into solve method of DifferentialEquations. alg is the algorithm to solve the differential equation of the system.

If input is nothing, the state equation of RosslerSystem is

$$$\begin{array}{l} \dot{x}_1 = \gamma (-x_2 - x_3) \\[0.25cm] \dot{x}_2 = \gamma (x_1 + a x_2) \\[0.25cm] \dot{x}_3 = \gamma (b + x_3 (x_1 - c)) \end{array}$$$

where $x$ is state. solver is used to solve the above differential equation. If input is not nothing, then the state eqaution is

$$$\begin{array}{l} \dot{x}_1 = \gamma (-x_2 - x_3) + \sum_{j = 1}^3 \theta_{1j} u_j \\[0.25cm] \dot{x}_2 = \gamma (x_1 + a x_2 ) + \sum_{j = 1}^3 \theta_{2j} u_j \\[0.25cm] \dot{x}_3 = \gamma (b + x_3 (x_1 - c)) + \sum_{j = 1}^3 \theta_{3j} u_j \end{array}$$$

where $\Theta = [\theta_{ij}]$ is cplmat and $u = [u_{j}]$ is the value of the input. The output function is

$$$y = g(x, u, t)$$$

where $t$ is time t, $y$ is the value of the output and $g$ is outputfunc.

Fields

• a::Real

a

• b::Real

b

• c::Real

c

• γ::Real

γ

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16875"} where var"#s16875"<:Real

State

• input::Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ForcedRosslerSystemType
mutable struct ForcedRosslerSystem{T1<:Real, T2<:Real, T3<:Real, T4<:Real, CM<:(AbstractMatrix{var"#s16875"} where var"#s16875"<:Real), RH, RO, ST<:(AbstractVector{var"#s16874"} where var"#s16874"<:Real), IP<:(Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}), OP<:(Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a Rossler system driven by its input.

Fields

• a::Real

a

• b::Real

b

• c::Real

c

• γ::Real

γ

• cplmat::AbstractMatrix{var"#s16875"} where var"#s16875"<:Real

Input coupling matrix. Expected a diagonal matrix

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16874"} where var"#s16874"<:Real

State

• input::Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}

Input. Expected to be and Inport or Nothing

• output::Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.VanderpolSystemType
mutable struct VanderpolSystem{T1<:Real, T2<:Real, RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a VanderpolSystem with input and output. mu and gamma is the system parameters. state is the initial state and t is the time. modelargs and modelkwargs are passed into ODEProblem and solverargs and solverkwargs are passed into solve method of DifferentialEquations. alg is the algorithm to solve the differential equation of the system.

If input is nothing, the state equation of VanderpolSystem is

$$$\begin{array}{l} \dot{x}_1 = \gamma (x_2) \\[0.25cm] \dot{x}_2 = \gamma (\mu (x_1^2 - 1) x_2 - x_1 ) \end{array}$$$

where $x$ is state. solver is used to solve the above differential equation. If input is not nothing, then the state eqaution is

$$$\begin{array}{l} \dot{x}_1 = \gamma (x_2) + \sum_{j = 1}^3 \theta_{1j} u_j \\[0.25cm] \dot{x}_2 = \gamma (\mu (x_1^2 - 1) x_2 - x_1) + \sum_{j = 1}^3 \theta_{2j} u_j \end{array}$$$

where $\Theta = [\theta_{ij}]$ is cplmat and $u = [u_{j}]$ is the value of the input. The output function is

$$$y = g(x, u, t)$$$

where $t$ is time t, $y$ is the value of the output and $g$ is outputfunc.

Field

• μ::Real

μ

• γ::Real

γ

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16875"} where var"#s16875"<:Real

State

• input::Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.ForcedVanderpolSystemType
mutable struct ForcedVanderpolSystem{T1<:Real, T2<:Real, CM<:(AbstractMatrix{var"#s16875"} where var"#s16875"<:Real), RH, RO, ST<:(AbstractVector{var"#s16874"} where var"#s16874"<:Real), IP<:(Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}), OP<:(Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs a Vanderpol system driven by its input.

Fields

• μ::Real

μ

• γ::Real

γ

• cplmat::AbstractMatrix{var"#s16875"} where var"#s16875"<:Real

Input coupling matrix. Expected to be a dioagonal matrix

• righthandside::Any

Right-hand-side function

• readout::Any

• state::AbstractVector{var"#s16874"} where var"#s16874"<:Real

State

• input::Union{var"#s16873", var"#s16872"} where {var"#s16873"<:Inport, var"#s16872"<:Nothing}

Input. Expected to be an Inport or Nothing

• output::Union{var"#s16632", var"#s16631"} where {var"#s16632"<:Outport, var"#s16631"<:Nothing}

Output port

• trigger::Any

• handshake::Any

• callbacks::Any

• name::Any

• id::Any

• t::Any

• modelargs::Any

• modelkwargs::Any

• solverargs::Any

• solverkwargs::Any

• alg::Any

• integrator::Any

Causal.IntegratorType
mutable struct Integrator{T1<:Real, RH, RO, ST<:(AbstractVector{var"#s16875"} where var"#s16875"<:Real), IP<:(Union{var"#s16874", var"#s16873"} where {var"#s16874"<:Inport, var"#s16873"<:Nothing}), OP<:(Union{var"#s16872", var"#s16632"} where {var"#s16872"<:Outport, var"#s16632"<:Nothing}), var"4004", var"4005", var"4006", Symbol, var"4007", Float64, var"4008", var"4009", var"4010", var"4011", var"4012", var"4013"} <: AbstractODESystem

Constructs an integrator whose input output relation is given by

$$$u(t) = ki * \int_{0}^{t} u(\tau) d\tau$$$

where $u(t)$ is the input, $y(t)$ is the output and $ki$ is the integration constant.