DiscreteSystem
System Constructors
ModelingToolkit.DiscreteSystem — Typestruct DiscreteSystem <: AbstractTimeDependentSystemA system of difference equations.
Fields
tag: A tag for the system. If two systems have the same tag, then they are structurally identical.
eqs: The differential equations defining the discrete system.iv: Independent variable.states: Dependent (state) variables. Must not contain the independent variable.ps: Parameter variables. Must not contain the independent variable.tspan: Time span.var_to_name: Array variables.ctrls: Control parameters (some subset ofps).observed: Observed states.name: The name of the system
systems: The internal systems. These are required to have unique names.
defaults: The default values to use when initial conditions and/or parameters are not supplied inDiscreteProblem.
preface: Inject assignment statements before the evaluation of the RHS function.
connector_type: Type of the system.
metadata: Metadata for the system, to be used by downstream packages.
gui_metadata: Metadata for MTK GUI.
tearing_state: Cache for intermediate tearing state.
substitutions: Substitutions generated by tearing.
complete: If a modelsysis complete, thensys.xno longer performs namespacing.
parent: The hierarchical parent system before simplification.
Example
using ModelingToolkit
@parameters σ=28.0 ρ=10.0 β=8/3 δt=0.1
@variables t x(t)=1.0 y(t)=0.0 z(t)=0.0
D = Difference(t; dt=δt)
eqs = [D(x) ~ σ*(y-x),
D(y) ~ x*(ρ-z)-y,
D(z) ~ x*y - β*z]
@named de = DiscreteSystem(eqs,t,[x,y,z],[σ,ρ,β]; tspan = (0, 1000.0)) # or
@named de = DiscreteSystem(eqs)Composition and Accessor Functions
get_eqs(sys)orequations(sys): The equations that define the Discrete System.get_delay_val(sys): The delay of the Discrete System.get_iv(sys): The independent variable of the Discrete System.get_u0_p(sys, u0map, parammap)Numeric arrays for the initial condition and parameters givenvar => valuemaps.
Transformations
Analyses
Applicable Calculation and Generation Functions
Standard Problem Constructors
SciMLBase.DiscreteFunction — MethodSciMLBase.DiscreteFunction{iip}(sys::DiscreteSystem, dvs = states(sys),
ps = parameters(sys);
version = nothing,
kwargs...) where {iip}Create a DiscreteFunction from the DiscreteSystem. The arguments dvs and ps are used to set the order of the dependent variable and parameter vectors, respectively.
SciMLBase.DiscreteProblem — MethodDiscreteProblem(sys::DiscreteSystem; ...) -> Any
DiscreteProblem(sys::DiscreteSystem, u0map; ...) -> Any
DiscreteProblem(
sys::DiscreteSystem,
u0map,
tspan;
...
) -> Any
DiscreteProblem(
sys::DiscreteSystem,
u0map,
tspan,
parammap;
eval_module,
eval_expression,
use_union,
kwargs...
) -> Any
Generates an DiscreteProblem from an DiscreteSystem.
Expression Constructors
ModelingToolkit.DiscreteFunctionExpr — TypeDiscreteFunctionExpr{iip}(sys::DiscreteSystem, dvs = states(sys),
ps = parameters(sys);
version = nothing,
kwargs...) where {iip}Create a Julia expression for an DiscreteFunction from the DiscreteSystem. The arguments dvs and ps are used to set the order of the dependent variable and parameter vectors, respectively.
ModelingToolkit.DiscreteProblemExpr — TypeDiffEqBase.DiscreteProblemExpr(sys::JumpSystem, u0map, tspan,
parammap = DiffEqBase.NullParameters; kwargs...)Generates a blank DiscreteProblem for a JumpSystem to utilize as its solving prob.prob. This is used in the case where there are no ODEs and no SDEs associated with the system.
Continuing the example from the JumpSystem definition:
using DiffEqBase, JumpProcesses
u₀map = [S => 999, I => 1, R => 0]
parammap = [β => 0.1 / 1000, γ => 0.01]
tspan = (0.0, 250.0)
dprob = DiscreteProblem(js, u₀map, tspan, parammap)