# Library Reference

## Resource Sharers and Machines

`AlgebraicDynamics.UWDDynam.AbstractResourceSharer`

— TypeAn undirected open dynamical system operating on information of type `T`

.

A resource sharer `r`

has signature `r.nports`

.

`AlgebraicDynamics.UWDDynam.ContinuousResourceSharer`

— TypeAn undirected open continuous system. The dynamics function `f`

defines an ODE $\dot u(t) = f(u(t),p,t)$.

`AlgebraicDynamics.UWDDynam.DiscreteResourceSharer`

— TypeAn undirected open discrete system. The dynamics function `f`

defines a discrete update rule $u_{n+1} = f(u_n, p, t)$.

`AlgebraicDynamics.DWDDynam.AbstractMachine`

— TypeA directed open dynamical system operating on information fo type `T`

. A machine `m`

has type signature (`m.ninputs`

, `m.outputs`

).

`AlgebraicDynamics.DWDDynam.ContinuousMachine`

— Type`ContinuousMachine{T}(ninputs, nstates, noutputs, f, r)`

An 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 may depend on the state, parameters, and time, so it must be of the form $r(u,p,t)$.

`AlgebraicDynamics.DWDDynam.DiscreteMachine`

— Type`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 may depend on the state, parameters, and time step, so it must be of the form $r(u_n,p,n)$.

`AlgebraicDynamics.UWDDynam.eval_dynamics`

— Function`eval_dynamics(m::AbstractMachine, u::AbstractVector, xs:AbstractVector, p, t)`

Evaluates the dynamics of the machine `m`

at state `u`

, parameters `p`

, and time `t`

. The exogenous variables are set by `xs`

which may either be a collection of functions $x(t)$ or a collection of constant values.

The length of `xs`

must equal the number of inputs to `m`

.

`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 `t`

and `p`

is allowed if the dynamics of `r`

does not depend on them.

`AlgebraicDynamics.UWDDynam.euler_approx`

— Function`euler_approx(m::ContinuousMachine, h)`

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)$ the 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 where the step size is introduced as a new parameter, the last in the list of parameters.

`euler_approx(r::ContinuousResourceSharer, h)`

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)$ the 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 where the step size is introduced as a new parameter, the last in the list of parameters.

`oapply`

`AlgebraicDynamics.UWDDynam.fills`

— Function`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`

.

`Catlab.WiringDiagrams.WiringDiagramAlgebras.oapply`

— Function`oapply(d::WiringDiagram, ms::Vector)`

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`

).

Each box of the composition pattern `d`

is filled by a machine with the appropriate type signature. Returns the composite machine.

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

A version of `oapply`

where each box of `d`

is filled with the machine `m`

.

`oapply(d::WiringDiagram, generators::Dict)`

A version of `oapply`

where `generators`

is a dictionary mapping the name of each box to its corresponding machine.

` oapply(d::AbstractUWD, rs::Vector)`

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 resource sharer `r`

.

` oapply(d::AbstractUWD, generators::Dict)`

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)`

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`

).

Each box of the composition pattern `d`

is filled by a machine with the appropriate type signature. Returns the composite machine.

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

A version of `oapply`

where each box of `d`

is filled with the machine `m`

.

## Integration with OrdinaryDiffEq.jl and DynamicalSystems.jl

`SciMLBase.ODEProblem`

— Type`ODEProblem(m::ContinuousMachine, xs::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)`

. The exogenous variables are determined by `xs`

.

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

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

.

Missing docstring for `DiscreteDynamicalSystem`

. Check Documenter's build log for details.

Missing docstring for `trajectory`

. Check Documenter's build log for details.