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).
Missing docstring for ModelingToolkit.AbstractSystem. Check Documenter's build log for details.
Utility constructors
Several utility constructors also exist to easily construct alternative system formulations.
Missing docstring for OptimizationSystem. Check Documenter's build log for details.
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.
Missing docstring for ModelingToolkit.has_eqs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_eqs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.equations_toplevel. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_noise_eqs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_noise_eqs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_jumps. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_jumps. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_constraints. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_constraints. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_costs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_costs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_consolidate. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_consolidate. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_unknowns. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_unknowns. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.unknowns_toplevel. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_ps. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_ps. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.parameters_toplevel. Check Documenter's build log for details.
Missing docstring for tunable_parameters. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_brownians. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_brownians. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_iv. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_iv. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_observed. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_observed. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_name. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_name. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_description. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_description. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.description. Check Documenter's build log for details.
Missing docstring for initial_conditions. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_guesses. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_guesses. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_systems. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_initialization_eqs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_initialization_eqs. Check Documenter's build log for details.
Missing docstring for initialization_equations. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_continuous_events. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_continuous_events. Check Documenter's build log for details.
Missing docstring for continuous_events. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.continuous_events_toplevel. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_discrete_events. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_discrete_events. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.discrete_events_toplevel. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_assertions. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_assertions. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.assertions. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_metadata. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_metadata. Check Documenter's build log for details.
Missing docstring for SymbolicUtils.getmetadata(::ModelingToolkit.AbstractSystem, ::DataType, ::Any). Check Documenter's build log for details.
Missing docstring for SymbolicUtils.setmetadata(::ModelingToolkit.AbstractSystem, ::DataType, ::Any). Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_is_dde. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_is_dde. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.is_dde. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_tstops. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_tstops. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.symbolic_tstops. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_tearing_state. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_tearing_state. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.does_namespacing. Check Documenter's build log for details.
Missing docstring for toggle_namespacing. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.iscomplete. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_preface. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_preface. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.preface. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_parent. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_parent. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.has_initializesystem. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.get_initializesystem. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.is_initializesystem. Check Documenter's build log for details.
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.
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.
Missing docstring for Base.getproperty(::ModelingToolkit.AbstractSystem, ::Symbol). Check Documenter's build log for details.
Functions for querying system equations
Missing docstring for has_diff_equations. Check Documenter's build log for details.
Missing docstring for has_alg_equations. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.is_alg_equation. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.is_diff_equation. Check Documenter's build log for details.
String parsing
ModelingToolkit can parse system variables from strings.
Missing docstring for ModelingToolkit.parse_variable. Check Documenter's build log for details.
Dumping system data
Missing docstring for ModelingToolkit.dump_unknowns. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.dump_parameters. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.dump_variable_metadata. Check Documenter's build log for details.
Inputs and outputs
Missing docstring for ModelingToolkit.inputs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.outputs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.bound_inputs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.unbound_inputs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.bound_outputs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.unbound_outputs. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.is_bound. Check Documenter's build log for details.
Debugging utilities
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 &.
Missing docstring for ModelingToolkit.CheckAll. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.CheckNone. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.CheckComponents. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.CheckUnits. Check Documenter's build log for details.
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.
Missing docstring for ModelingToolkit.collect_scoped_vars!. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.collect_var_to_name!. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.collect_vars!. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.eqtype_supports_collect_vars. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.modified_unknowns!. Check Documenter's build log for details.
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.
Missing docstring for ModelingToolkit.renamespace. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.namespace_equations. Check Documenter's build log for details.
Linearization and Analysis
Functions for linearization and analysis of systems.
ModelingToolkit.linearization_ap_transform — Function
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.
ModelingToolkit.get_sensitivity_function — Function
get_sensitivity_function(
sys::ModelingToolkitBase.AbstractSystem,
aps;
kwargs...
) -> Tuple{ModelingToolkit.LinearizationFunction{DI, AI, _A, P, _B, _C, J1, J2, J3, J4, IA, @NamedTuple{abstol::Float64, reltol::Float64, nlsolve_alg::Nothing}} where {DI<:AbstractVector{Int64}, AI<:AbstractVector{Int64}, _A, P<:ODEProblem, _B, _C, J1<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, ModelingToolkit.var"#uff#12"{var"#64#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#12"), _A, _B}), var"#64#fun", _A}}, J2<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, _A, _B, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:ForwardDiff.JacobianConfig, _A, _B}}, J3<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#pff#13"{var"#65#fun", var"#66#setter"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#pff#13"), _A, _B}), var"#65#fun", var"#66#setter", _A}}, J4<:(ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#hpf#11"{fun, setter}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#hpf#11"), _A, _B}), fun, setter, _A}), IA<:Union{SciMLBase.NoInit, SciMLBase.OverrideInit{Nothing, Nothing, Nothing}}}, Any}
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 tolinearization_function.
All other keyword arguments are forwarded to linearization_function.
ModelingToolkit.get_comp_sensitivity_function — Function
get_comp_sensitivity_function(
sys::ModelingToolkitBase.AbstractSystem,
aps;
kwargs...
) -> Tuple{ModelingToolkit.LinearizationFunction{DI, AI, _A, P, _B, _C, J1, J2, J3, J4, IA, @NamedTuple{abstol::Float64, reltol::Float64, nlsolve_alg::Nothing}} where {DI<:AbstractVector{Int64}, AI<:AbstractVector{Int64}, _A, P<:ODEProblem, _B, _C, J1<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, ModelingToolkit.var"#uff#12"{var"#64#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#12"), _A, _B}), var"#64#fun", _A}}, J2<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, _A, _B, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:ForwardDiff.JacobianConfig, _A, _B}}, J3<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#pff#13"{var"#65#fun", var"#66#setter"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#pff#13"), _A, _B}), var"#65#fun", var"#66#setter", _A}}, J4<:(ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#hpf#11"{fun, setter}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#hpf#11"), _A, _B}), fun, setter, _A}), IA<:Union{SciMLBase.NoInit, SciMLBase.OverrideInit{Nothing, Nothing, Nothing}}}, Any}
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 tolinearization_function.
All other keyword arguments are forwarded to linearization_function.
ModelingToolkit.get_looptransfer_function — Function
get_looptransfer_function(
sys::ModelingToolkitBase.AbstractSystem,
aps;
kwargs...
) -> Tuple{ModelingToolkit.LinearizationFunction{DI, AI, _A, P, _B, _C, J1, J2, J3, J4, IA, @NamedTuple{abstol::Float64, reltol::Float64, nlsolve_alg::Nothing}} where {DI<:AbstractVector{Int64}, AI<:AbstractVector{Int64}, _A, P<:ODEProblem, _B, _C, J1<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, ModelingToolkit.var"#uff#12"{var"#64#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#12"), _A, _B}), var"#64#fun", _A}}, J2<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing}}, _A, _B, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:ForwardDiff.JacobianConfig, _A, _B}}, J3<:Union{Nothing, ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#pff#13"{var"#65#fun", var"#66#setter"}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#pff#13"), _A, _B}), var"#65#fun", var"#66#setter", _A}}, J4<:(ModelingToolkit.PreparedJacobian{true, DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgJacobianPrep{Nothing, C, Tuple{Nothing, Nothing, Nothing}}, ModelingToolkit.var"#hpf#11"{fun, setter}, _A, ADTypes.AutoForwardDiff{nothing, Nothing}} where {C<:(ForwardDiff.JacobianConfig{T, _A, _B, <:Tuple{Any, Any}} where {T<:(ForwardDiff.Tag{F} where F<:ModelingToolkit.var"#hpf#11"), _A, _B}), fun, setter, _A}), IA<:Union{SciMLBase.NoInit, SciMLBase.OverrideInit{Nothing, Nothing, Nothing}}}, Any}
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 tolinearization_function.
All other keyword arguments are forwarded to linearization_function.
ModelingToolkit.get_sensitivity — Function
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 toModelingToolkit.linearize
See also get_comp_sensitivity, get_looptransfer.
ModelingToolkit.get_comp_sensitivity — Function
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 toModelingToolkit.linearize
See also get_sensitivity, get_looptransfer.
ModelingToolkit.get_looptransfer — Function
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.
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 toModelingToolkit.linearize
See also get_sensitivity, get_comp_sensitivity, open_loop.