Library Reference
Types of Dynamical Systems
Machines
AlgebraicDynamics.DWDDynam.AbstractMachine
— TypeMachine{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
).
AlgebraicDynamics.DWDDynam.ContinuousMachine
— TypeContinuousMachine{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$.
AlgebraicDynamics.DWDDynam.DelayMachine
— TypeDelayMachine{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$.
AlgebraicDynamics.DWDDynam.DiscreteMachine
— TypeDiscreteMachine{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$.
Resource Sharers
AlgebraicDynamics.UWDDynam.AbstractResourceSharer
— TypeResourceSharer{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
.
AlgebraicDynamics.UWDDynam.ContinuousResourceSharer
— TypeContinuousResourceSharer{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.
AlgebraicDynamics.UWDDynam.DelayResourceSharer
— TypeDelayResourceSharer{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.
AlgebraicDynamics.UWDDynam.DiscreteResourceSharer
— TypeDiscreteResourceSharer{T}(nports, nstates, f, portmap)
An undirected open discrete system. The dynamics function f
defines a discrete update rule $u_{n+1} = f(u_n, p, t)$.
Composition of Dynamical Systems
Operad Algebras
Catlab.WiringDiagrams.WiringDiagramAlgebras.oapply
— Function 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.
oapply(d::AbstractUWD, r::AbstractResourceSharer)
A version of oapply
where each box of d
is filled with the same resource sharer r
.
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.
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.
oapply(d::OpenCPortGraph, m::AbstractMachine)
A version of oapply
where each box of d
is filled with the same machine m
.
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.
oapply(d::WiringDiagram, m::AbstractMachine)
A version of oapply
where each box of d
is filled with the same machine m
.
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.
Checks
AlgebraicDynamics.UWDDynam.fills
— Functionfills(r::AbstractResourceSharer, d::AbstractUWD, b::Int)
Checks if r
is of the correct signature to fill box b
of the undirected wiring diagram d
.
fills(m::AbstractMachine, d::OpenCPortGraph, b::Int)
Checks if m
is of the correct signature to fill box b
of the open CPG d
.
AlgebraicDynamics.DWDDynam.fills
— Functionfills(m::AbstractMachine, d::WiringDiagram, b::Int)
Checks if m
is of the correct signature to fill box b
of the wiring diagram d
.
Time Evolution
Instantaneous Dynamics
AlgebraicDynamics.UWDDynam.eval_dynamics
— Functioneval_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.
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
.
Time Discretization
AlgebraicDynamics.UWDDynam.euler_approx
— Functioneuler_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)$.
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.
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
.
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)$.
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.
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
.
Discrete Trajectory
AlgebraicDynamics.UWDDynam.trajectory
— Functiontrajectory(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
.
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
.
Package Extensions
OrdinaryDiffEq.jl
SciMLBase.ODEProblem
— TypeODEProblem(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()
.
ODEProblem(r::ContinuousResourceSharer, u0::Vector, tspan)
Constructs an ODEProblem
from the vector field defined by (u,p,t) -> r.dynamics(u,p,t)
.
SciMLBase.DiscreteProblem
— TypeDiscreteProblem(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.
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.
DelayDiffEq.jl
SciMLBase.DDEProblem
— TypeDDEProblem(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()
.
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)
.