DiscreteSystem

System Constructors

ModelingToolkit.DiscreteSystemType
struct DiscreteSystem <: AbstractTimeDependentSystem

A 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 of ps).

  • 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 in DiscreteProblem.
  • 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 model sys is complete, then sys.x no 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)
source

Composition and Accessor Functions

  • get_eqs(sys) or equations(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 given var => value maps.

Transformations

Analyses

Applicable Calculation and Generation Functions

Standard Problem Constructors

SciMLBase.DiscreteFunctionMethod
SciMLBase.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.

source
SciMLBase.DiscreteProblemMethod
DiscreteProblem(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.

source

Expression Constructors

ModelingToolkit.DiscreteFunctionExprType
DiscreteFunctionExpr{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.

source
ModelingToolkit.DiscreteProblemExprType
DiffEqBase.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)
source