Library Reference

Types of Dynamical Systems

Machines

AlgebraicDynamics.DWDDynam.AbstractMachineType
Machine{T}
Machine{T,N}

A directed open dynamical system operating on information of type T. For type arguments {T,N}, the system operates on arrays of type T and ndims = N. A machine m has type signature (m.ninputs, m.noutputs).

source
AlgebraicDynamics.DWDDynam.ContinuousMachineType
ContinuousMachine{T}(ninputs, nstates, noutputs, f, r)

A directed open continuous system. The dynamics function f defines an ODE $\dot u(t) = f(u(t),x(t),p,t)$, where $u$ is the state and $x$ captures the exogenous variables.

The readout function r may depend on the state, parameters and time, so it must be of the form $r(u,p,t)$. If it is left out, then $r=u$.

source
AlgebraicDynamics.DWDDynam.DelayMachineType
DelayMachine{T}(ninputs, nstates, noutputs, f, r)

A delay open continuous system. The dynamics function f defines an ODE $\dot u(t) = f(u(t), x(t), h(p,t), p, t)$, where $u$ is the state, $x$ captures the exogenous variables, and $h$ is a history function.

The readout function r may depend on the state, history, parameters and time, so it has the signature $r(u,h,p,t)$. If it is left out, then $r=u$.

source
AlgebraicDynamics.DWDDynam.DiscreteMachineType
DiscreteMachine{T}(ninputs, nstates, noutputs, f, r)

A directed open discrete dynamical system. The dynamics function f defines a discrete update rule $u_{n+1} = f(u_n, x_n, p, t)$, where $u_n$ is the state and $x_n$ is the value of the exogenous variables at the $n$th time step.

The readout function r may depend on the state, parameters and time step, so it must be of the form $r(u_n,p,n)$. If it is left out, then $r_n=u_n$.

source

Resource Sharers

AlgebraicDynamics.UWDDynam.AbstractResourceSharerType
ResourceSharer{T}
ResourceSharer{T,N}

An undirected open dynamical system operating on information of type T. For type arguments {T,N}, the system operates on arrays of type T and ndims = N. A resource sharer r has type signature r.nports.

source
AlgebraicDynamics.UWDDynam.ContinuousResourceSharerType
ContinuousResourceSharer{T}(nports, nstates, f, portmap)

An undirected open continuous system. The dynamics function f defines an ODE $\dot u(t) = f(u(t),p,t)$, where $u(t)$ has length nstates. nports is the number of exposed ports and portmap is a list of exposed states. For example, if portmap = [2,2,3] then there are three ports which expose the state variables 2, 2, and 3 respectively.

source
AlgebraicDynamics.UWDDynam.DelayResourceSharerType
DelayResourceSharer{T}(nports, nstates, f, portmap)

An undirected open continuous system. The dynamics function f defines a DDE $\dot u(t) = f(u(t),h(t),p,t)$, where $h$ is a function giving the history of the system's state $u$ before the interval on which the solution will be computed begins (usually for $t < 0$). f should have signature $f(u,h,p,t)$, where $h$ is a function.

source

Composition of Dynamical Systems

Operad Algebras

Catlab.WiringDiagrams.WiringDiagramAlgebras.oapplyFunction
oapply(d::WiringDiagram, ms::Vector{M}) where {M<:AbstractMachine}

Implements the operad algebras for directed composition of dynamical systems, given a composition pattern (implemented by a directed wiring diagram d) and primitive systems (implemented by a collection of machines ms). Returns the composite machine.

Each box of the composition pattern d must be filled by a machine with the appropriate type signature.

source
oapply(d::WiringDiagram, m::AbstractMachine)

A version of oapply where each box of d is filled with the same machine m.

source
oapply(d::WiringDiagram, generators::AbstractDict{S,M}) where {S,M<:AbstractMachine}

A version of oapply where generators is a dictionary mapping the name of each box to its corresponding machine.

source
oapply(d::OpenCPortGraph, ms::Vector{M}) where {M<:AbstractMachine}

Implements the operad algebras for directed composition of dynamical systems, given a composition pattern (implemented by an open circular port graph d) and primitive systems (implemented by a collection of machines ms). Returns the composite machine.

Each box of the composition pattern d must be filled by a machine with the appropriate type signature.

source
oapply(d::OpenCPortGraph, m::AbstractMachine)

A version of oapply where each box of d is filled with the same machine m.

source
 oapply(d::AbstractUWD, rs::Vector{R}) where {R<:AbstractResourceSharer}

Implements the operad algebras for undirected composition of dynamical systems, given a composition pattern (implemented by an undirected wiring diagram d) and primitive systems (implemented by a collection of resource sharers rs). Returns the composite resource sharer.

Each box of d must be filled by a resource sharer of the appropriate type signature.

source
oapply(d::AbstractUWD, r::AbstractResourceSharer)

A version of oapply where each box of d is filled with the same resource sharer r.

source
 oapply(d::AbstractUWD, generators::AbstractDict{S,R}) where {S,R<:AbstractResourceSharer}

A version of oapply where generators is a dictionary mapping the name of each box to its corresponding resource sharer.

source

Checks

AlgebraicDynamics.UWDDynam.fillsFunction
fills(m::AbstractMachine, d::OpenCPortGraph, b::Int)

Checks if m is of the correct signature to fill box b of the open CPG d.

source
fills(r::AbstractResourceSharer, d::AbstractUWD, b::Int)

Checks if r is of the correct signature to fill box b of the undirected wiring diagram d.

source

Time Evolution

Instantaneous Dynamics

AlgebraicDynamics.UWDDynam.eval_dynamicsFunction
eval_dynamics(m::AbstractMachine, u::AbstractVector, x:AbstractVector{F}, p, t) where {F<:Function}
eval_dynamics(m::AbstractMachine{T}, u::AbstractVector, x:AbstractVector{T}, p, t) where T

Evaluates the dynamics of the machine m at state u, parameters p and time t. The exogenous variables are set by x, which may be a collection either of functions $x_i(t)$ or of constant values. In either case, the length of x must equal the number of inputs to m.

source
eval_dynamics(r::AbstractResourceSharer, u::AbstractVector, p, t)

Evaluates the dynamics of the resource sharer r at state u, parameters p and time t. Omitting p and t is allowed if the dynamics of r does not depend on them.

source

Time Discretization

AlgebraicDynamics.UWDDynam.euler_approxFunction
euler_approx(m::ContinuousMachine, h::Float)

Transforms a continuous machine m into a discrete machine via Euler's method with step size h. If the dynamics of m is given by $\dot{u}(t) = f(u(t),x(t),p,t)$, then the dynamics of the new discrete system is given by the update rule $u_{n+1} = u_n + h f(u_n, x_n, p, t)$.

source
euler_approx(m::ContinuousMachine)

Transforms a continuous machine m into a discrete machine via Euler's method. The step size parameter is appended to the end of the system's parameter list.

source
euler_approx(ms::Vector{M}, args...) where {M<:ContinuousMachine}
euler_approx(ms::AbstractDict{S, M}, args...) where {S,M<:ContinuousMachine}

Map euler_approx over a collection of machines with identical args.

source
euler_approx(r::ContinuousResourceSharer, h::Float)

Transforms a continuous resource sharer r into a discrete resource sharer via Euler's method with step size h. If the dynamics of r is given by $\dot{u}(t) = f(u(t),p,t)$, then the dynamics of the new discrete system is given by the update rule $u_{n+1} = u_n + h f(u_n, p, t)$.

source
euler_approx(r::ContinuousResourceSharer)

Transforms a continuous resource sharer r into a discrete resource sharer via Euler's method. The step size parameter is appended to the end of the system's parameter list.

source
euler_approx(rs::Vector{R}, args...) where {T,R<:ContinuousResourceSharer{T}}
euler_approx(rs::AbstractDict{S, R}, args...) where {S,T,R<:ContinuousResourceSharer{T}}

Map euler_approx over a collection of resource sharers with identical args.

source

Discrete Trajectory

AlgebraicDynamics.UWDDynam.trajectoryFunction
trajectory(m::DiscreteMachine, u0::AbstractVector, x::AbstractVector, p, nsteps::Int; dt::Int = 1)
trajectory(m::DiscreteMachine, u0::AbstractVector, x::AbstractVector, p, tspan::Tuple{T,T}; dt::T= one(T)) where {T<:Real}

Evolves the machine m, for nsteps times or over tspan, with step size dt, initial condition u0 and parameters p. Any inputs to m are determined by x as in eval_dynamics(). If m has no inputs, then you can omit x.

source
trajectory(r::DiscreteResourceSharer, u0::AbstractVector, p, nsteps::Int; dt::Int = 1)
trajectory(r::DiscreteResourceSharer, u0::AbstractVector, p, tspan::Tuple{T,T}; dt::T= one(T)) where {T<:Real}

Evolves the resouce sharer r, for nsteps times or over tspan, with step size dt, initial condition u0 and parameters p.

source

Package Extensions

OrdinaryDiffEq.jl

SciMLBase.ODEProblemType
ODEProblem(m::ContinuousMachine, x::Vector, u0::Vector, tspan, p=nothing; kwargs...)

Constructs an ODEProblem from the vector field defined by (u,p,t) -> m.dynamics(u,x,p,t), where the exogenous variables are determined by x as in eval_dynamics().

source
ODEProblem(r::ContinuousResourceSharer, u0::Vector, tspan)

Constructs an ODEProblem from the vector field defined by (u,p,t) -> r.dynamics(u,p,t).

source
SciMLBase.DiscreteProblemType
DiscreteProblem(m::DiscreteMachine, x::Vector, u0::Vector, tspan, p=nothing; kwargs...)

Constructs a DiscreteProblem from the equation of motion defined by (u,p,t) -> m.dynamics(u,x,p,t), where the exogenous variables are determined by x as in eval_dynamics(). Pass nothing in place of p if your system does not have parameters.

source
DiscreteProblem(r::DiscreteResourceSharer, u0::Vector, p)

Constructs a DiscreteProblem from the equation of motion defined by (u,p,t) -> r.dynamics(u,p,t). Pass nothing in place of p if your system does not have parameters.

source

DelayDiffEq.jl

SciMLBase.DDEProblemType
DDEProblem(m::DelayMachine, u0::Vector, x::Vector, h::Function, tspan, p=nothing; kwargs...)

Constructs a DDEProblem from the vector field defined by (u,h,p,t) -> m.dynamics(u,x,h,p,t), where the exogenous variables are determined by x as in eval_dynamics().

source
DDEProblem(r::DelayResourceSharer, u0::Vector, h, tspan)

Constructs a DDEProblem from the vector field defined by (u,h,p,t) -> r.dynamics(u,h,p,t).

source