Time Evolution of Systems
DynamicalSystems.jl provides convenient interfaces for the evolution of systems.
#DynamicalSystemsBase.evolve
— Function.
evolve(ds::DynamicalSystem, T=1 [, u0]; diff_eq_kwargs = Dict())
Evolve the ds.state
(or u0
if given) for total time T
and return the final_state
. For discrete systems T
corresponds to steps and thus it must be integer.
Notice that for BigDiscreteDS
a copy of ds.state
is made for no given u0
, so that ds.state
is not mutated.
evolve
does not store any information about intermediate steps. Use trajectory
if you want to produce a trajectory of the system. If you want to perform step-by-step evolution of a continuous system, use ODEIntegrator(ds, args...)
and the step!(integrator)
function provided by DifferentialEquations
.
#DynamicalSystemsBase.trajectory
— Function.
trajectory(ds::DynamicalSystem, T; kwargs...) -> dataset
Return a dataset what will contain the trajectory of the sytem, after evolving it for time T
. See Dataset
for info on how to manipulate this object.
For the discrete case, T
is an integer and a T×D
dataset is returned (D
is the system dimensionality). For the continuous case, a W×D
dataset is returned, with W = length(0:dt:T)
with 0:dt:T
representing the time vector (not returned).
Keyword Arguments
dt = 0.05
: (only for continuous) Time step of value output during the solving of the continuous system.diff_eq_kwargs = Dict()
: (only for continuous) A dictionaryDict{Symbol, ANY}
of keyword arguments passed into thesolve
of theDifferentialEquations.jl
package, for exampleDict(:abstol => 1e-9)
. If you want to specify a solver, do so by using the symbol:solver
, e.g.:Dict(:solver => DP5(), :maxiters => 1e9)
. This requires you to have been firstusing OrdinaryDiffEq
to access the solvers.
Especially in the continuous case, an API is provided for usage directly with DifferentialEquations.jl, by giving additional constructors:
#DiffEqBase.ODEProblem
— Type.
ODEProblem(ds::ContinuousDS, t)
Return an ODEProblem
with the given system information (t0 is zero). This can be passed directly into solve
from DifferentialEquations.jl
.
#OrdinaryDiffEq.ODEIntegrator
— Type.
ODEIntegrator(ds::ContinuousDS, t; diff_eq_kwargs)
Return an ODEIntegrator
, by first creating an ODEProblem(ds, t)
. This can be used directly with the interfaces of DifferentialEquations.jl
.
diff_eq_kwargs = Dict()
is a dictionary Dict{Symbol, ANY}
of keyword arguments passed into the init
of the DifferentialEquations.jl
package, for example Dict(:abstol => 1e-9)
. If you want to specify a solver, do so by using the symbol :solver
, e.g.: Dict(:solver => DP5(), :tstops => 0:0.01:t)
. This requires you to have been first using OrdinaryDiffEq
to access the solvers.
#DynamicalSystemsBase.variational_integrator
— Function.
variational_integrator(ds::ContinuousDS, k::Int, tfinal, S::Matrix, kwargs...)
Return an ODEIntegrator
that represents the variational equations of motion for the system.
It evolves in parallel ds.state
and k
deviation vectors w_i such that \dot{w}_i = J\times w_i with J the Jacobian at the current state. S
is the initial "conditions" which contain both the system's state as well as the initial diviation vectors: S = cat(2, ds.state, ws)
if ws
is a matrix that has as columns the initial deviation vectors.
The only keyword argument for this funcion is diff_eq_kwargs = Dict()
(see trajectory
).
Notice that if you want to do repeated evolutions of different states of a continuous system, you should use the ODEIntegrator(ds::DynamicalSystem)
in conjunction with DifferentialEquations.reinit!(integrator, newstate)
to avoid the intermediate initializations of the integrator each time.