The System type

ModelingToolkit.jl uses System to symbolically represent all types of numerical problems. Users create Systems representing the problem they want to solve and mtkcompile transforms them into a format ModelingToolkit.jl can generate code for (alongside performing other optimizations).

ModelingToolkitBase.SystemType
struct System <: ModelingToolkitBase.IntermediateDeprecationSystem

A symbolic representation of a numerical system to be solved. This is a recursive tree-like data structure - each system can contain additional subsystems. As such, it implements the AbstractTrees.jl interface to enable exploring the hierarchical structure.

Fields

  • tag::UInt64: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    A unique integer tag for the system.

  • eqs::Vector{Equation}: The equations of the system.
  • noise_eqs::Union{Nothing, VecOrMat{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}}: The noise terms for each equation of the system. This field is only used for flattened systems. To represent noise in a hierarchical system, use brownians. In a system with N equations and K independent brownian variables, this should be an N x K matrix. In the special case where N == K and each equation has independent noise, this noise matrix is diagonal. Diagonal noise can be specified by providing an N length vector. If this field is nothing, the system does not have noise.
  • jumps::Vector{Union{JumpProcesses.ConstantRateJump, JumpProcesses.MassActionJump, JumpProcesses.VariableRateJump}}: Jumps associated with the system. Each jump can be a VariableRateJump, ConstantRateJump or MassActionJump. See JumpProcesses.jl for more information. MassActionJumps must use scale_rates = false (pre-scaled rate expressions); see SymbolicMassActionJump.
  • constraints::Vector{Union{Equation, Inequality}}: The constraints of the system. This can be used to represent the constraints in an optimal-control problem or boundary-value differential equation, or the constraints in a constrained optimization.
  • costs::Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: The costs of the system. This can be the cost in an optimal-control problem, or the loss of an optimization problem. Scalar loss values must also be provided as a single- element vector.
  • consolidate::Any: A function which combines costs into a scalar value. This should take two arguments, the costs of this system and the consolidated costs of all subsystems in the order they are present in the systems field. It should return a scalar cost that combines all of the individual values. This defaults to a function that simply sums all cost values.
  • unknowns::Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: The variables being solved for by this system. For example, in a differential equation system, this contains the dependent variables.
  • ps::Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: The parameters of the system. Parameters can either be variables that parameterize the problem being solved for (e.g. the spring constant of a mass-spring system) or additional unknowns not part of the main dynamics of the system (e.g. discrete/clocked variables in a hybrid ODE).
  • brownians::Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: The brownian variables of the system, created via @brownians. Each brownian variable represents an independent noise. A system with brownians cannot be simulated directly. It needs to be compiled using mtkcompile into noise_eqs.
  • poissonians::Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: The poissonian variables of the system, created via @poissonians. Each poissonian variable represents an independent Poisson counting process with an associated rate. A system with poissonians cannot be simulated directly. It needs to be compiled using mtkcompile which converts poissonians into jump equations.
  • iv::Union{Nothing, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: The independent variable for a time-dependent system, or nothing for a time-independent system.
  • observed::Vector{Equation}: Equations that compute variables of a system that have been eliminated from the set of unknowns by mtkcompile. More generally, this contains all variables that can be computed from the unknowns and parameters and do not need to be solved for. Such variables are termed as "observables". Each equation must be of the form observable ~ expression and observables cannot appear on the LHS of multiple equations. Equations must be sorted such that every observable appears on the left hand side of an equation before it appears on the right hand side of any other equation.
  • var_to_name::Dict{Symbol, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    A mapping from the name of a variable to the actual symbolic variable in the system. This is used to enable getproperty syntax to access variables of a system.

  • name::Symbol: The name of the system.
  • description::String: An optional description for the system.
  • bindings::ReadOnlyDicts.ReadOnlyDict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, ModelingToolkitBase.AtomicArrayDict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}}}: Binding relations for variables/parameters. The bound variable (key) is completely determined by the binding (value). Providing an initial condition for a bound variable is an error. Bindings for variables (ones created via @variables and @discretes) are treated as initial conditions.
  • initial_conditions::ModelingToolkitBase.AtomicArrayDict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}}: Initial conditions for variables (unknowns/observables/parameters) which can be changed/overridden. When constructing a numerical problem from the system.
  • guesses::ModelingToolkitBase.AtomicArrayDict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}}: Guess values for variables of a system that are solved for during initialization.
  • systems::Vector{System}: A list of subsystems of this system. Used for hierarchically building models.
  • initialization_eqs::Vector{Equation}: Equations that must be satisfied during initialization of the numerical problem created from this system. For time-dependent systems, these equations are not valid after the initial time.
  • continuous_events::Vector{ModelingToolkitBase.SymbolicContinuousCallback}: Symbolic representation of continuous events in a dynamical system. See SymbolicContinuousCallback.
  • discrete_events::Vector{ModelingToolkitBase.SymbolicDiscreteCallback}: Symbolic representation of discrete events in a dynamica system. See SymbolicDiscreteCallback.
  • connector_type::Any: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    If this system is a connector, the type of connector it is.

  • assertions::Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, String}: A map from expressions that must be through throughout the solution process to an associated error message. By default these assertions cause the generated code to output NaNs if violated, but can be made to error using debug_system.
  • metadata::Base.ImmutableDict{DataType, Any}: The metadata associated with this system, as a Base.ImmutableDict. This follows the same interface as SymbolicUtils.jl. Metadata can be queried and updated using SymbolicUtils.getmetadata and SymbolicUtils.setmetadata respectively.
  • gui_metadata::Any: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    Metadata added by the @mtkmodel macro.

  • is_dde::Bool: Whether the system contains delay terms. This is inferred from the equations, but can also be provided explicitly.
  • tstops::Vector{Any}: Extra time points for the integrator to stop at. These can be numeric values, or expressions of parameters and time.
  • inputs::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    The list of input variables of the system.

  • outputs::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    The list of output variables of the system.

  • tearing_state::Any: The TearingState of the system post-simplification with mtkcompile.
  • namespacing::Bool: Whether the system namespaces variables accessed via getproperty. completed systems do not namespace, but this flag can be toggled independently of complete using toggle_namespacing.
  • complete::Bool: Whether the system is marked as "complete". Completed systems cannot be used as subsystems.
  • index_cache::Union{Nothing, ModelingToolkitBase.IndexCache}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    For systems simplified or completed with split = true (the default) this contains an IndexCache which aids in symbolic indexing. If this field is nothing, the system is either not completed, or completed with split = false.

  • parameter_bindings_graph::Union{Nothing, ModelingToolkitBase.ParameterBindingsGraph}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    Contains the dependency graph of bound parameters to avoid excessive duplicated work during code generation.

  • ignored_connections::Union{Nothing, Vector{Connection}}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    Connections that should be ignored because they were removed by an analysis point transformation. The first element of the tuple contains all such "standard" connections (ones between connector systems) and the second contains all such causal variable connections.

  • preface::Any: SymbolicUtils.Code.Assignments to prepend to all code generated from this system.
  • parent::Union{Nothing, System}: After simplification with mtkcompile, this field contains the unsimplified system with the hierarchical structure. There may be multiple levels of parents. The root parent is used for accessing variables via getproperty syntax.
  • initializesystem::Union{Nothing, System}: A custom initialization system to use if no initial conditions are provided for the unknowns or observables of this system.
  • is_initializesystem::Bool: Whether the current system is an initialization system.
  • is_discrete::Bool

  • state_priorities::ModelingToolkitBase.AtomicArrayDict{Int64, Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Int64}}: State priorities for variables. Used in structural simplification algorithms.

  • irreducibles::ModelingToolkitBase.AtomicArraySet{Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Nothing}}: Variables marked as irreducible for simplification.
  • maybe_zeros::ModelingToolkitBase.AtomicArraySet{Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Nothing}}: Expressions which may be zero and should be given special consideration during simplification.
  • irstructure::IRStructure{SymReal}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    The IRStructure used for efficient symbolic manipulation.

  • isscheduled::Bool: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    Whether the system has been simplified by mtkcompile.

  • schedule::Union{Nothing, ModelingToolkitBase.Schedule}: This field is internal API. It may be removed or changed without notice in a non-breaking release. Usage of this field is not advised.

    The Schedule containing additional information about the simplified system.

source

Utility constructors

Several utility constructors also exist to easily construct alternative system formulations.

ModelingToolkitBase.NonlinearSystemFunction
NonlinearSystem(sys::System) -> System

Given a time-dependent system sys of ODEs, convert it to a time-independent system of nonlinear equations that solve for the steady-state of the unknowns. This is done by replacing every derivative D(x) of an unknown x with zero. Note that this process does not retain noise equations, brownian terms, jumps or costs associated with sys. All other information such as initial conditions, bindings, guesses, observed and initialization equations are retained. The independent variable of sys becomes a parameter of the returned system.

If sys is hierarchical (it contains subsystems) this transformation will be applied recursively to all subsystems. The output system will be marked as complete if and only if the input system is also complete. This also retains the split flag passed to complete.

See also: complete.

source
ModelingToolkitBase.SDESystemFunction
SDESystem(eqs::Vector{Equation}, noise, iv; is_scalar_noise = false, kwargs...)

Construct a system of equations with associated noise terms. Instead of specifying noise using @brownians variables, it is specified using a noise matrix noise. iv is the independent variable of the system.

In the general case, noise should be a N x M matrix where N is the number of equations (length(eqs)) and M is the number of independent random variables. noise[i, j] is the diffusion term for equation i and random variable j. If the noise is diagonal (N == M and noise[i, j] == 0 for all i != j) it can be specified as a Vector of length N corresponding to the diagonal of the noise matrix. As a special case, if all equations have the same noise then all rows of noise are identical. This is known as "scalar noise". In this case, noise can be a Vector corresponding to the repeated row and is_scalar_noise must be true.

Note that systems created in this manner cannot be used hierarchically. This should only be used to construct flattened systems. To use such a system hierarchically, it must be converted to use brownian variables using noise_to_brownians. mtkcompile will automatically perform this conversion.

All keyword arguments are the same as those of the System constructor.

source
SDESystem(eqs::Vector{Equation}, noise, iv, dvs, ps; is_scalar_noise = false, kwargs...)

Identical to the 3-argument SDESystem constructor, but uses the explicitly provided dvs and ps for unknowns and parameters of the system.

source
SDESystem(sys::System, noise; kwargs...) -> System

Attach the given noise matrix noise to the system sys.

source
ModelingToolkitBase.JumpSystemFunction
JumpSystem(jumps, iv; kwargs...) -> System

Construct a System to solve a system of jump equations. jumps is an array of jumps, expressed using JumpProcesses.ConstantRateJump, JumpProcesses.VariableRateJump, and JumpProcesses.MassActionJump. It can also include standard equations to simulate jump-diffusion processes. iv should be the independent variable of the system.

MassActionJumps must be constructed with scale_rates = false (pre-scaled rate expressions). Use SymbolicMassActionJump for convenience, which handles this automatically. JumpProcesses will not re-apply factorial scaling on parameter updates for jumps constructed through the MTK pipeline.

All keyword arguments are the same as those of the System constructor.

source
JumpSystem(jumps, iv, dvs, ps; kwargs...)

Identical to the 2-argument JumpSystem constructor, but uses the explicitly provided dvs and ps for unknowns and parameters of the system.

See the 2-argument JumpSystem for details on MassActionJump requirements.

source
ModelingToolkitBase.OptimizationSystemFunction
OptimizationSystem(cost; kwargs...)

Construct a time-independent System for optimizing the specified scalar cost. The system will have no equations.

Unknowns and parameters of the system are inferred from the cost and other values (such as initial conditions) passed to it.

All keyword arguments are the same as those of the System constructor.

source
OptimizationSystem(cost, dvs, ps; kwargs...)

Identical to the corresponding single-argument OptimizationSystem constructor, except the unknowns and parameters are specified by passing arrays of symbolic variables to dvs and ps respectively.

source
OptimizationSystem(cost::Array; kwargs...)

Construct a time-independent System for optimizing the specified multi-objective cost. The cost will be reduced to a scalar using the consolidate function. This defaults to summing the specified cost and that of all subsystems. The system will have no equations.

Unknowns and parameters of the system are inferred from the cost and other values (such as initial conditions) passed to it.

All keyword arguments are the same as those of the System constructor.

source
OptimizationSystem(cost::Array, dvs, ps; kwargs...)

Identical to the corresponding single-argument OptimizationSystem constructor, except the unknowns and parameters are specified by passing arrays of symbolic variables to dvs and ps respectively.

source

Accessor functions

Several accessor functions exist to query systems for the information they contain. In general, for every field x there exists a has_x function which checks if the system contains the field and a get_x function for obtaining the value in the field. Note that fields of a system cannot be accessed via getproperty - that is reserved for accessing variables, subsystems or analysis points of the hierarchical system.

ModelingToolkitBase.get_eqsFunction
get_eqs(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field eqs of a system sys. It only includes eqs local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_eqs.

source
ModelingToolkitBase.get_noise_eqsFunction
get_noise_eqs(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field noise_eqs of a system sys. It only includes noise_eqs local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_noise_eqs.

source
ModelingToolkitBase.get_jumpsFunction
get_jumps(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field jumps of a system sys. It only includes jumps local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_jumps.

source
ModelingToolkitBase.jumpsFunction
jumps(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the flattened jumps of the system. In other words, obtain all of the jumps in sys and all the subsystems of sys (appropriately namespaced).

source
ModelingToolkitBase.get_constraintsFunction
get_constraints(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field constraints of a system sys. It only includes constraints local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_constraints.

source
ModelingToolkitBase.constraintsFunction
constraints(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get all constraints in the system sys and all of its subsystems, appropriately namespaced.

source
ModelingToolkitBase.get_costsFunction
get_costs(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field costs of a system sys. It only includes costs local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_costs.

source
ModelingToolkitBase.costFunction
cost(
    sys::ModelingToolkitBase.AbstractSystem
) -> SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}

Recursively consolidate the cost vector of sys and all subsystems of sys, returning the final scalar cost function.

source
ModelingToolkitBase.get_consolidateFunction
get_consolidate(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field consolidate of a system sys. It only includes consolidate local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_consolidate.

source
ModelingToolkitBase.get_unknownsFunction
get_unknowns(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field unknowns of a system sys. It only includes unknowns local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_unknowns.

source
ModelingToolkitBase.get_psFunction
get_ps(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field ps of a system sys. It only includes ps local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_ps.

source
ModelingToolkitBase.tunable_parametersFunction
tunable_parameters(sys, p = parameters(sys; initial_parameters = true); default=true)

Get all parameters of sys that are marked as tunable.

Keyword argument default indicates whether variables without tunable metadata are to be considered tunable or not.

Create a tunable parameter by

@parameters u [tunable=true]

For systems created with split = true (the default) and default = true passed to this function, the order of parameters returned is the order in which they are stored in the tunables portion of MTKParameters. Note that array variables will not be scalarized. To obtain the flattened representation of the tunables portion, call Symbolics.scalarize(tunable_parameters(sys)) and concatenate the resulting arrays.

See also getbounds, istunable, MTKParameters, complete

source
ModelingToolkitBase.get_browniansFunction
get_brownians(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field brownians of a system sys. It only includes brownians local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_brownians.

source
ModelingToolkitBase.browniansFunction
brownians(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get all of the brownian variables involved in the system sys and all subsystems, appropriately namespaced.

source
ModelingToolkitBase.get_ivFunction
get_iv(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field iv of a system sys. It only includes iv local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_iv.

source
ModelingToolkitBase.get_observedFunction
get_observed(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field observed of a system sys. It only includes observed local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_observed.

source
ModelingToolkitBase.observablesFunction
observables(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the observed variables of the system sys and its subsystems. These can be expressed in terms of unknowns(sys), and do not have to be explicitly solved for. It is equivalent to all left hand sides of observed(sys).

See also observed.

source
ModelingToolkitBase.get_nameFunction
get_name(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field name of a system sys. It only includes name local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_name.

source
Base.nameofFunction
nameof(sys::ModelingToolkitBase.AbstractSystem) -> Any

Obtain the name of sys.

source
ModelingToolkitBase.get_descriptionFunction
get_description(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field description of a system sys. It only includes description local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_description.

source
ModelingToolkitBase.descriptionFunction
description(sys::ModelingToolkitBase.AbstractSystem) -> Any

Obtain the description associated with sys if present, and an empty string otherwise.

source
ModelingToolkitBase.get_initial_conditionsFunction
get_initial_conditions(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field initial_conditions of a system sys. It only includes initial_conditions local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_initial_conditions.

source
ModelingToolkitBase.get_guessesFunction
get_guesses(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field guesses of a system sys. It only includes guesses local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_guesses.

source
ModelingToolkitBase.get_systemsFunction
get_systems(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field systems of a system sys. It only includes systems local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_systems.

source
ModelingToolkitBase.get_initialization_eqsFunction
get_initialization_eqs(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field initialization_eqs of a system sys. It only includes initialization_eqs local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_initialization_eqs.

source
ModelingToolkitBase.get_continuous_eventsFunction
get_continuous_events(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field continuous_events of a system sys. It only includes continuous_events local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_continuous_events.

source
ModelingToolkitBase.continuous_eventsFunction
continuous_events(sys::AbstractSystem)::Vector{SymbolicContinuousCallback}

Returns a vector of all the continuous_events in an abstract system and its component subsystems. The SymbolicContinuousCallbacks in the returned vector are structs with two fields: eqs and affect which correspond to the first and second elements of a Pair used to define an event, i.e. eqs => affect.

See also get_continuous_events, which only returns the events of the top-level system.

source
ModelingToolkitBase.get_discrete_eventsFunction
get_discrete_events(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field discrete_events of a system sys. It only includes discrete_events local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_discrete_events.

source
ModelingToolkitBase.get_assertionsFunction
get_assertions(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field assertions of a system sys. It only includes assertions local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_assertions.

source
ModelingToolkitBase.get_metadataFunction
get_metadata(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field metadata of a system sys. It only includes metadata local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_metadata.

source
SymbolicUtils.getmetadataMethod
getmetadata(
    sys::ModelingToolkitBase.AbstractSystem,
    k::DataType,
    default
) -> Any

Get the metadata associated with key k in system sys or default if it does not exist.

source
SymbolicUtils.setmetadataMethod
setmetadata(
    sys::ModelingToolkitBase.AbstractSystem,
    k::DataType,
    v
) -> Any

Set the metadata associated with key k in system sys to value v. This is an out-of-place operation, and will return a shallow copy of sys with the appropriate metadata values.

source
ModelingToolkitBase.get_is_ddeFunction
get_is_dde(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field is_dde of a system sys. It only includes is_dde local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_is_dde.

source
ModelingToolkitBase.is_ddeFunction
is_dde(sys::AbstractSystem)

Return a boolean indicating whether a system represents a set of delay differential equations.

source
ModelingToolkitBase.get_tstopsFunction
get_tstops(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field tstops of a system sys. It only includes tstops local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_tstops.

source
ModelingToolkitBase.get_tearing_stateFunction
get_tearing_state(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field tearing_state of a system sys. It only includes tearing_state local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_tearing_state.

source
ModelingToolkitBase.toggle_namespacingFunction
toggle_namespacing(
    sys::ModelingToolkitBase.AbstractSystem,
    value::Bool;
    safe
) -> Any

Return a new sys with namespacing enabled or disabled, depending on value. The keyword argument safe denotes whether systems that do not support such a toggle should error or be ignored.

source
ModelingToolkitBase.get_prefaceFunction
get_preface(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field preface of a system sys. It only includes preface local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_preface.

source
ModelingToolkitBase.prefaceFunction
preface(sys::ModelingToolkitBase.AbstractSystem) -> Any

Obtain the preface associated with sys and all of its subsystems, appropriately namespaced.

source
ModelingToolkitBase.get_parentFunction
get_parent(sys::ModelingToolkitBase.AbstractSystem) -> Any

Get the internal field parent of a system sys. It only includes parent local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_parent.

source
ModelingToolkitBase.get_initializesystemFunction
get_initializesystem(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Get the internal field initializesystem of a system sys. It only includes initializesystem local to sys; not those of its subsystems, like unknowns(sys), parameters(sys) and equations(sys) does.

See also has_initializesystem.

source

getproperty syntax

ModelingToolkit allows obtaining in a system using getproperty. For a system sys with a subcomponent inner containing variable var, sys.inner.var will obtain the appropriately namespaced version of var. Note that this can also be used to access subsystems (sys.inner) or analysis points.

Note

By default, top-level systems not marked as complete will apply their namespace. Systems marked as complete will not do this namespacing. This namespacing behavior can be toggled independently of whether the system is completed using toggle_namespacing and the current namespacing behavior can be queried via ModelingToolkit.does_namespacing.

Base.getpropertyMethod
Base.getproperty(sys::AbstractSystem, name::Symbol)

Access the subsystem, variable or analysis point of sys named name. To check if sys will namespace the returned value, use ModelingToolkitBase.does_namespacing(sys).

See also: ModelingToolkitBase.does_namespacing.

source

Functions for querying system equations

ModelingToolkitBase.has_diff_eqsFunction
has_diff_eqs(sys::AbstractSystem)

Return true if a system contains at least one differential equation (i.e. an equation with a differential term). Note that this does not consider subsystems, and only takes into account equations in the top-level system.

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys1 = tem([eq1], t)
@named osys2 = tem([eq2], t)
osys12 = compose(osys1, [osys2])
osys21 = compose(osys2, [osys1])

has_diff_eqs(osys12) # returns `true`.
has_diff_eqs(osys21) # returns `false`.
source
ModelingToolkitBase.has_alg_eqsFunction
has_alg_eqs(sys::AbstractSystem)

For a system, returns true if it contain at least one algebraic equation (i.e. that does not contain any differentials) in its top-level system.

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys1 = System([eq1], t)
@named osys2 = System([eq2], t)
osys12 = compose(osys1, [osys2])
osys21 = compose(osys2, [osys1])

has_alg_eqs(osys12) # returns `false`.
has_alg_eqs(osys21) # returns `true`.
source
ModelingToolkitBase.get_diff_eqsFunction
get_diff_eqs(sys::AbstractSystem)

For a system, returns a vector of all differential equations (i.e. that does contain a differential) in its top-level system.

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys1 = tem([eq1], t)
@named osys2 = tem([eq2], t)
osys12 = compose(osys1, [osys2])
osys21 = compose(osys2, [osys1])

get_diff_eqs(osys12) # returns `[Differential(t)(X(t)) ~ p - d*X(t)]`.
get_diff_eqs(osys21) # returns `Equation[]``.
source
ModelingToolkitBase.get_alg_eqsFunction
get_alg_eqs(sys::AbstractSystem)

For a system, returns a vector of all algebraic equations (i.e. that does not contain any differentials) in its top-level system.

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys1 = ([eq1], t)
@named osys2 = ([eq2], t)
osys12 = compose(sys1, [osys2])
osys21 = compose(osys2, [osys1])

get_alg_eqs(osys12) # returns `Equation[]`.
get_alg_eqs(osys21) # returns `[0 ~ p - d*X(t)]`.
source
ModelingToolkitBase.has_diff_equationsFunction
has_diff_equations(sys::AbstractSystem)

For a system, returns true if it contain at least one differential equation (i.e. that contain a differential).

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys1 = System([eq1], t)
@named osys2 = System([eq2], t)

has_diff_equations(osys1) # returns `true`.
has_diff_equations(osys2) # returns `false`.
source
ModelingToolkitBase.has_alg_equationsFunction
has_alg_equations(sys::AbstractSystem)

For a system, returns true if it contain at least one algebraic equation (i.e. that does not contain any differentials).

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys1 = System([eq1], t)
@named osys2 = System([eq2], t)

has_alg_equations(osys1) # returns `false`.
has_alg_equations(osys2) # returns `true`.
source
ModelingToolkitBase.diff_equationsFunction
diff_equations(sys::AbstractSystem)

For a system, returns a vector of all its differential equations (i.e. that does contain a differential).

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys = System([eq1, eq2], t)

diff_equations(osys) # returns `[Differential(t)(X(t)) ~ p - d*X(t)]`.
source
ModelingToolkitBase.alg_equationsFunction
alg_equations(sys::AbstractSystem)

For a system, returns a vector of all its algebraic equations (i.e. that does not contain any differentials).

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X
@named osys = System([eq1, eq2], t)

alg_equations(osys) # returns `[0 ~ p - d*X(t)]`.
source
ModelingToolkitBase.is_alg_equationFunction
is_alg_equation(eq)

Return true if the input is an algebraic equation, i.e. an equation that does not contain any differentials.

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X

is_alg_equation(eq1) # false
is_alg_equation(eq2) # true
source
ModelingToolkitBase.is_diff_equationFunction
is_diff_equation(eq)

Return true if the input is a differential equation, i.e. an equation that contains a differential term.

Example:

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D
@parameters p d
@variables X(t)
eq1 = D(X) ~ p - d*X
eq2 = 0 ~ p - d*X

is_diff_equation(eq1) # true
is_diff_equation(eq2) # false
source

String parsing

ModelingToolkit can parse system variables from strings.

ModelingToolkitBase.parse_variableFunction
parse_variable(
    sys::ModelingToolkitBase.AbstractSystem,
    str::AbstractString
) -> Any

Return the variable in sys referred to by its string representation str. Roughly supports the following CFG:

varname                  = "D(" varname ")" | "Differential(" iv ")(" varname ")" | arrvar | maybe_dummy_var
arrvar                   = maybe_dummy_var "[idxs...]"
idxs                     = int | int "," idxs
maybe_dummy_var          = namespacedvar | namespacedvar "(" iv ")" |
                           namespacedvar "(" iv ")" "ˍ" ts | namespacedvar "ˍ" ts |
                           namespacedvar "ˍ" ts "(" iv ")"
ts                       = iv | iv ts
namespacedvar            = ident "₊" namespacedvar | ident "." namespacedvar | ident

Where iv is the independent variable, int is an integer and ident is an identifier.

source

Dumping system data

ModelingToolkitBase.dump_unknownsFunction
dump_unknowns(sys::AbstractSystem)

Return an array of NamedTuples containing the metadata associated with each unknown in sys. Also includes the default value of the unknown, if provided.

using ModelingToolkitBase
using DynamicQuantities
using ModelingToolkitBase: t, D

@parameters p = 1.0, [description = "My parameter", tunable = false] q = 2.0, [description = "Other parameter"]
@variables x(t) = 3.0 [unit = u"m"]
@named sys = System(Equation[], t, [x], [p, q])
ModelingToolkitBase.dump_unknowns(sys)

See also: ModelingToolkitBase.dump_variable_metadata, ModelingToolkitBase.dump_parameters

source
ModelingToolkitBase.dump_parametersFunction
dump_parameters(sys::AbstractSystem)

Return an array of NamedTuples containing the metadata associated with each parameter in sys. Also includes the default value of the parameter, if provided.

using ModelingToolkitBase
using DynamicQuantities
using ModelingToolkitBase: t, D

@parameters p = 1.0, [description = "My parameter", tunable = false] q = 2.0, [description = "Other parameter"]
@variables x(t) = 3.0 [unit = u"m"]
@named sys = System(Equation[], t, [x], [p, q])
ModelingToolkitBase.dump_parameters(sys)

See also: ModelingToolkitBase.dump_variable_metadata, ModelingToolkitBase.dump_unknowns

source
ModelingToolkitBase.dump_variable_metadataFunction
dump_variable_metadata(var)

Return all the metadata associated with symbolic variable var as a NamedTuple.

using ModelingToolkitBase

@parameters p::Int [description = "My description", bounds = (0.5, 1.5)]
ModelingToolkitBase.dump_variable_metadata(p)
source

Inputs and outputs

ModelingToolkitBase.is_boundFunction
is_bound(sys, u)

Determine whether input/output variable u is "bound" within the system, i.e., if it's to be considered internal to sys. A variable/signal is considered bound if it appears in an equation together with variables from other subsystems. The typical usecase for this function is to determine whether the input to an IO component is connected to another component, or if it remains an external input that the user has to supply before simulating the system.

See also bound_inputs, unbound_inputs, bound_outputs, unbound_outputs

source

Debugging utilities

ModelingToolkitBase.debug_systemFunction
debug_system(sys::AbstractSystem; functions = [log, sqrt, (^), /, inv, asin, acos], error_nonfinite = true)

Wrap functions in sys so any error thrown in them shows helpful symbolic-numeric information about its input. If error_nonfinite, functions that output nonfinite values (like Inf or NaN) also display errors, even though the raw function itself does not throw an exception (like 1/0). For example:

julia> sys = debug_system(complete(sys))

julia> prob = ODEProblem(sys, [0.0, 2.0], (0.0, 1.0))

julia> prob.f(prob.u0, prob.p, 0.0)
ERROR: Function /(1, sin(P(t))) output non-finite value Inf with input
  1 => 1
  sin(P(t)) => 0.0

Additionally, all assertions in the system are optionally logged when they fail. A new parameter is also added to the system which controls whether the message associated with each assertion will be logged when the assertion fails. This parameter defaults to true and can be toggled by symbolic indexing with ModelingToolkitBase.ASSERTION_LOG_VARIABLE. For example, prob.ps[ModelingToolkitBase.ASSERTION_LOG_VARIABLE] = false will disable logging.

source

Input validation

The following values can be passed to the check keyword of System to toggle validation of input. Flags can be combined with bitwise | and &.

ModelingToolkitBase.CheckComponentsConstant
const CheckComponents

Value that can be provided to the check keyword of System to only enable checking of basic components of the system, such as equations, variables, etc.

source

These can also be used by custom AbstractSystem subtypes.

Utility functions

These utility functions can be useful when manipulating systems, especially when building custom AbstractSystem subtypes.

ModelingToolkitBase.collect_scoped_vars!Function
collect_scoped_vars!(
    unknowns::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    parameters::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    sys::ModelingToolkitBase.AbstractSystem,
    iv::Union{Nothing, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}};
    ...
)
collect_scoped_vars!(
    unknowns::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    parameters::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    sys::ModelingToolkitBase.AbstractSystem,
    iv::Union{Nothing, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    ::Type{op};
    depth
)

Search through equations and parameter dependencies of sys, where sys is at a depth of depth from the root system, looking for variables scoped to the root system. Also recursively searches through all subsystems of sys, increasing the depth if it is not -1. A depth of -1 indicates searching for variables with GlobalScope.

source
Missing docstring.

Missing docstring for ModelingToolkit.collect_var_to_name!. Check Documenter's build log for details.

ModelingToolkitBase.collect_vars!Function
collect_vars!(
    unknowns::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    parameters::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    expr::SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal},
    iv::Union{Nothing, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}};
    ...
)
collect_vars!(
    unknowns::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    parameters::OrderedCollections.OrderedSet{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    expr::SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal},
    iv::Union{Nothing, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}},
    ::Type{op};
    depth
)

Search through expr for all symbolic variables present in it. Populate dvs with unknowns and ps with parameters present. iv should be the independent variable of the system or nothing for time-independent systems. Expressions where the operator isa op go through validate_operator.

depth is a keyword argument which indicates how many levels down expr is from the root of the system hierarchy. This is used to resolve scoping operators. The scope of a variable can be checked using check_scope_depth.

This function should return nothing.

source
ModelingToolkitBase.modified_unknowns!Function
modified_unknowns!(
    munknowns,
    jump::Union{JumpProcesses.ConstantRateJump, JumpProcesses.VariableRateJump},
    sts
) -> Any

Push to munknowns the variables modified by jump jump. sts is the list of unknowns of the system. Return the modified munknowns.

source

Namespace manipulation

ModelingToolkit namespaces variables from subsystems when using them in a parent system to disambiguate from identically named variables in other subsystems or the parent system. The following functions are useful for manipulating namespacing functionality.

ModelingToolkitBase.renamespaceFunction
renamespace(
    sys,
    x::SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}
) -> SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}

Namespace x with the name of sys.

source
renamespace(sys, ap::AnalysisPoint) -> AnalysisPoint

Namespace an AnalysisPoint by namespacing the involved systems and the name of the point.

source

Linearization and Analysis

Functions for linearization and analysis of systems.

ModelingToolkit.linearization_ap_transformFunction
sys, input_vars, output_vars =
linearization_ap_transform(
    sys,
    inputs::Union{Vector{Symbol}, Vector{AnalysisPoint}, Symbol, AnalysisPoint},
    outputs,
    loop_openings
) -> Tuple{Any, Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}, Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}}

Apply analysis-point transformations to prepare a system for linearization.

Returns

  • sys: The transformed system.
  • input_vars: A vector of input variables corresponding to the input analysis points.
  • output_vars: A vector of output variables corresponding to the output analysis points.
source
ModelingToolkit.get_sensitivity_functionFunction
get_sensitivity_function(
    sys::ModelingToolkitBase.AbstractSystem,
    aps;
    kwargs...
) -> Tuple{ModelingToolkit.LinearizationFunction{Vector{Int64}, Vector{Int64}, Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}, P, H, _A, J1, J2, J3, J4, IA, @NamedTuple{abstol::Float64, reltol::Float64, nlsolve_alg::Nothing}} where {P<:ODEProblem, H<:Union{Expr, ModelingToolkitBase.GeneratedFunctionWrapper}, _A, J1<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, ModelingToolkit.var"#uff#6"{var"#70#fun"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#uff#6"), _A, _B}), var"#70#fun", _A}}, J2<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, P, F, B, ADTypes.AutoForwardDiff{nothing, Nothing}} where {P, F, B}}, J3<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#pff#7"{var"#71#fun", var"#72#setter"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Vector{T} where T<:(ForwardDiff.Dual{T, _A, _B} where {_B, _A, T})}} where {T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#pff#7"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}})), _A, _B}), var"#71#fun", var"#72#setter", _A}}, J4<:(ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#hpf#5"{fun, setter}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Vector{T} where T<:(ForwardDiff.Dual{T, _A, _B} where {_B, _A, T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#hpf#5"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}}))})}} where {T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#hpf#5"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}})), _A, _B}), fun, setter, _A}), IA<:Union{SciMLBase.NoInit, SciMLBase.OverrideInit{Nothing, Nothing, Nothing}}}, System}

Return the sensitivity function for the analysis point(s) aps, and the modified system simplified with the appropriate inputs and outputs.

Keyword Arguments

  • loop_openings: A list of analysis points whose connections should be removed and the outputs set to the input as a part of the linear analysis.

  • system_modifier: A function taking the transformed system and applying any additional transformations, returning the modified system. The modified system is passed to linearization_function.

All other keyword arguments are forwarded to linearization_function.

source
ModelingToolkit.get_comp_sensitivity_functionFunction
get_comp_sensitivity_function(
    sys::ModelingToolkitBase.AbstractSystem,
    aps;
    kwargs...
) -> Tuple{ModelingToolkit.LinearizationFunction{Vector{Int64}, Vector{Int64}, Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}, P, H, _A, J1, J2, J3, J4, IA, @NamedTuple{abstol::Float64, reltol::Float64, nlsolve_alg::Nothing}} where {P<:ODEProblem, H<:Union{Expr, ModelingToolkitBase.GeneratedFunctionWrapper}, _A, J1<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, ModelingToolkit.var"#uff#6"{var"#70#fun"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#uff#6"), _A, _B}), var"#70#fun", _A}}, J2<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, P, F, B, ADTypes.AutoForwardDiff{nothing, Nothing}} where {P, F, B}}, J3<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#pff#7"{var"#71#fun", var"#72#setter"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Vector{T} where T<:(ForwardDiff.Dual{T, _A, _B} where {_B, _A, T})}} where {T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#pff#7"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}})), _A, _B}), var"#71#fun", var"#72#setter", _A}}, J4<:(ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#hpf#5"{fun, setter}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Vector{T} where T<:(ForwardDiff.Dual{T, _A, _B} where {_B, _A, T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#hpf#5"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}}))})}} where {T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#hpf#5"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}})), _A, _B}), fun, setter, _A}), IA<:Union{SciMLBase.NoInit, SciMLBase.OverrideInit{Nothing, Nothing, Nothing}}}, System}

Return the complementary sensitivity function for the analysis point(s) aps, and the modified system simplified with the appropriate inputs and outputs.

Keyword Arguments

  • loop_openings: A list of analysis points whose connections should be removed and the outputs set to the input as a part of the linear analysis.

  • system_modifier: A function taking the transformed system and applying any additional transformations, returning the modified system. The modified system is passed to linearization_function.

All other keyword arguments are forwarded to linearization_function.

source
ModelingToolkit.get_looptransfer_functionFunction
get_looptransfer_function(
    sys::ModelingToolkitBase.AbstractSystem,
    aps;
    kwargs...
) -> Tuple{ModelingToolkit.LinearizationFunction{Vector{Int64}, Vector{Int64}, Vector{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}}, P, H, _A, J1, J2, J3, J4, IA, @NamedTuple{abstol::Float64, reltol::Float64, nlsolve_alg::Nothing}} where {P<:ODEProblem, H<:Union{Expr, ModelingToolkitBase.GeneratedFunctionWrapper}, _A, J1<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, ModelingToolkit.var"#uff#6"{var"#70#fun"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#uff#6"), _A, _B}), var"#70#fun", _A}}, J2<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, P, F, B, ADTypes.AutoForwardDiff{nothing, Nothing}} where {P, F, B}}, J3<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#pff#7"{var"#71#fun", var"#72#setter"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Vector{T} where T<:(ForwardDiff.Dual{T, _A, _B} where {_B, _A, T})}} where {T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#pff#7"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}})), _A, _B}), var"#71#fun", var"#72#setter", _A}}, J4<:(ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#hpf#5"{fun, setter}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Vector{T} where T<:(ForwardDiff.Dual{T, _A, _B} where {_B, _A, T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#hpf#5"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}}))})}} where {T<:(ForwardDiff.Tag{F} where F<:(ModelingToolkit.var"#hpf#5"{_A, SymbolicIndexingInterface.OOPSetter{_A1, System, var"#s177"}} where {_A, _A1, T, var"#s177"<:AbstractVector{T}})), _A, _B}), fun, setter, _A}), IA<:Union{SciMLBase.NoInit, SciMLBase.OverrideInit{Nothing, Nothing, Nothing}}}, System}

Return the loop-transfer function for the analysis point(s) aps, and the modified system simplified with the appropriate inputs and outputs.

Keyword Arguments

  • loop_openings: A list of analysis points whose connections should be removed and the outputs set to the input as a part of the linear analysis.

  • system_modifier: A function taking the transformed system and applying any additional transformations, returning the modified system. The modified system is passed to linearization_function.

All other keyword arguments are forwarded to linearization_function.

source
ModelingToolkit.get_sensitivityFunction
get_sensitivity(sys, ap::AnalysisPoint; kwargs)
get_sensitivity(sys, ap_name::Symbol; kwargs)

Compute the sensitivity function in analysis point ap. The sensitivity function is obtained by introducing an infinitesimal perturbation d at the input of ap, linearizing the system and computing the transfer function between d and the output of ap.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_comp_sensitivity, get_looptransfer.

source
ModelingToolkit.get_comp_sensitivityFunction
get_comp_sensitivity(sys, ap::AnalysisPoint; kwargs)
get_comp_sensitivity(sys, ap_name::Symbol; kwargs)

Compute the complementary sensitivity function in analysis point ap. The complementary sensitivity function is obtained by introducing an infinitesimal perturbation d at the output of ap, linearizing the system and computing the transfer function between d and the input of ap.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_looptransfer.

source
ModelingToolkit.get_looptransferFunction
get_looptransfer(sys, ap::AnalysisPoint; kwargs)
get_looptransfer(sys, ap_name::Symbol; kwargs)

Compute the (linearized) loop-transfer function in analysis point ap, from ap.out to ap.in.

Negative feedback

Feedback loops often use negative feedback, and the computed loop-transfer function will in this case have the negative feedback included. Standard analysis tools often assume a loop-transfer function without the negative gain built in, and the result of this function may thus need negation before use.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_comp_sensitivity, open_loop.

source
ModelingToolkitBase.open_loopFunction
open_loop(
    sys,
    ap::Union{Symbol, AnalysisPoint};
    system_modifier
) -> Tuple{Any, Tuple{Any, Any}}

Apply LoopTransferTransform to the analysis point ap and return the result of apply_transformation.

Keyword Arguments

  • system_modifier: a function which takes the modified system and returns a new system with any required further modifications performed.
source

Additional Equation Classification

Missing docstring.

Missing docstring for alg_equations. Check Documenter's build log for details.

Missing docstring.

Missing docstring for diff_equations. Check Documenter's build log for details.

Missing docstring.

Missing docstring for has_alg_equations. Check Documenter's build log for details.

Missing docstring.

Missing docstring for has_diff_equations. Check Documenter's build log for details.