System Accessors

Accessor functions query the information stored in a system. For each field x, has_x checks whether the system contains the field and get_x obtains its value.

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_irreduciblesFunction
get_irreducibles(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_irreducibles.

source
ModelingToolkitBase.irreduciblesFunction
irreducibles(sys::AbstractSystem)

Return the variables in sys and its subsystems that are marked as irreducible.

Irreducible variables are preserved as unknowns during simplification instead of being eliminated as observed variables when possible.

Arguments

  • sys: system to inspect recursively.

Returns

An atomic set of symbolic variables, with subsystem variables namespaced into sys.

Examples

using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, D_nounits as D

@variables x(t) [irreducible = true]
@named sys = System([D(x) ~ -x], t)

irreducibles(sys)
source
ModelingToolkitBase.get_maybe_zerosFunction
get_maybe_zeros(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_maybe_zeros.

source
ModelingToolkitBase.maybe_zerosFunction
maybe_zeros(sys::AbstractSystem)

Return variables in sys and its subsystems that simplification may constrain to zero.

This is primarily used by structural simplification to track variables introduced or retained while handling alias equations.

Arguments

  • sys: system to inspect recursively.

Returns

An atomic set of symbolic variables, with subsystem variables namespaced into sys.

source
ModelingToolkitBase.get_state_prioritiesFunction
get_state_priorities(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_state_priorities.

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.bound_parametersFunction
bound_parameters(
    sys::ModelingToolkitBase.AbstractSystem
) -> ModelingToolkitBase.AtomicArraySet{OrderedCollections.OrderedDict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}, Nothing}}

Return the bound parameters of a system. Currently requires that the system is marked 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_poissoniansFunction
get_poissonians(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_poissonians.

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.independent_variableFunction
independent_variable(sys)

Return the scalar independent variable of sys, or nothing when sys has no scalar independent variable.

Most users should call independent_variables, which always returns a vector. This is the scalar extension point for packages that define custom AbstractSystem subtypes; external packages should extend independent_variable only. The generic independent_variables accessor wraps that scalar value and should not be extended.

Arguments

  • sys: A system-like object with a scalar independent variable.

Returns

  • The scalar independent variable of sys, or nothing.

Examples

struct ScalarIVSystem <: ModelingToolkitBase.AbstractSystem
    iv
end
ModelingToolkitBase.independent_variable(sys::ScalarIVSystem) = getfield(sys, :iv)
source
ModelingToolkitBase.independent_variablesFunction
independent_variables(sys::AbstractSystem) -> Vector{SymbolicT}

Return the independent variables of sys as a vector. This is the user-facing accessor, including for systems with one independent variable.

External packages defining custom AbstractSystem subtypes should extend the scalar independent_variable interface rather than adding methods to this accessor. For systems with a scalar independent variable, this generic accessor wraps that value in a vector.

Arguments

  • sys::AbstractSystem: System whose independent variables are requested.

Returns

  • Vector{SymbolicT}: The independent variables, or an empty vector for a time-independent system.

Examples

using ModelingToolkitBase

@independent_variables t
@named sys = System(Equation[], t)
independent_variables(sys)
source
ModelingToolkitBase.get_ivsFunction
get_ivs(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_ivs.

source
ModelingToolkitBase.get_dvsFunction
get_dvs(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_dvs.

source
ModelingToolkitBase.get_tspanFunction
get_tspan(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_tspan.

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_bindingsFunction
get_bindings(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_bindings.

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.discrete_eventsFunction
discrete_events(sys::AbstractSystem) :: Vector{SymbolicDiscreteCallback}

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

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

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.MiscSystemDataType
abstract type MiscSystemData

Utility metadata key for adding miscellaneous/one-off metadata to systems.

sys = setmetadata(sys, MiscSystemData, mydata)
getmetadata(sys, MiscSystemData, nothing)
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.get_scheduleFunction
get_schedule(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_schedule.

source
ModelingToolkitBase.get_isscheduledFunction
get_isscheduled(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_isscheduled.

source
ModelingToolkitBase.get_index_cacheFunction
get_index_cache(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_index_cache.

source
ModelingToolkitBase.get_irstructure_tlvFunction
get_irstructure_tlv(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_irstructure_tlv.

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
ModelingToolkitBase.get_is_initializesystemFunction
get_is_initializesystem(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_is_initializesystem.

source
ModelingToolkitBase.analytically_integratedFunction
analytically_integrated(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

Return the list of analytically integrated variables in sys. Requires that sys is flattened, since analytically integrated variables cannot be specified for unflattened systems.

source
ModelingToolkitBase.get_connector_typeFunction
get_connector_type(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_connector_type.

source
ModelingToolkitBase.get_ignored_connectionsFunction
get_ignored_connections(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_ignored_connections.

source
ModelingToolkitBase.get_is_discreteFunction
get_is_discrete(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_is_discrete.

source
ModelingToolkitBase.get_bcsFunction
get_bcs(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_bcs.

source
ModelingToolkitBase.get_domainFunction
get_domain(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_domain.

source
ModelingToolkitBase.get_var_to_nameFunction
get_var_to_name(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_var_to_name.

source
ModelingToolkitBase.get_gui_metadataFunction
get_gui_metadata(
    sys::ModelingToolkitBase.AbstractSystem
) -> Any

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

See also has_gui_metadata.

source
ModelingToolkitBase.get_tagFunction
get_tag(sys::ModelingToolkitBase.AbstractSystem) -> Any

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

See also has_tag.

source