NonlinearSystem
System Constructors
ModelingToolkit.NonlinearSystem
— Typestruct NonlinearSystem <: AbstractTimeIndependentSystem
A nonlinear system of equations.
Fields
tag
: A tag for the system. If two systems have the same tag, then they are structurally identical.
eqs
: Vector of equations defining the system.unknowns
: Unknown variables.ps
: Parameters.var_to_name
: Array variables.observed
: Observed equations.jac
: Jacobian matrix. Note: this field will not be defined untilcalculate_jacobian
is called on the system.
name
: The name of the system.
description
: A description of the system.
systems
: The internal systems. These are required to have unique names.
defaults
: The default values to use when initial conditions and/or parameters are not supplied inODEProblem
.
guesses
: The guesses to use as the initial conditions for the initialization system.
initializesystem
: The system for performing the initialization.
initialization_eqs
: Extra equations to be enforced during the initialization sequence.
connector_type
: Type of the system.
parameter_dependencies
: Topologically sorted parameter dependency equations, where all symbols are parameters and the LHS is a single parameter.
metadata
: Metadata for the system, to be used by downstream packages.
gui_metadata
: Metadata for MTK GUI.
is_initializesystem
: Whether this is an initialization system.
tearing_state
: Cache for intermediate tearing state.
substitutions
: Substitutions generated by tearing.
namespacing
: If false, thensys.x
no longer performs namespacing.
complete
: If true, denotes the model will not be modified any further.
index_cache
: Cached data for fast symbolic indexing.
parent
: The hierarchical parent system before simplification.
isscheduled
Examples
@variables x y z
@parameters σ ρ β
eqs = [0 ~ σ*(y-x),
0 ~ x*(ρ-z)-y,
0 ~ x*y - β*z]
@named ns = NonlinearSystem(eqs, [x,y,z],[σ,ρ,β])
Composition and Accessor Functions
get_eqs(sys)
orequations(sys)
: The equations that define the nonlinear system.get_unknowns(sys)
orunknowns(sys)
: The set of unknowns in the nonlinear system.get_ps(sys)
orparameters(sys)
: The parameters of the nonlinear system.get_u0_p(sys, u0map, parammap)
Numeric arrays for the initial condition and parameters givenvar => value
maps.
Transformations
ModelingToolkit.structural_simplify
— Functionstructural_simplify(sys; ...)
structural_simplify(
sys,
io;
additional_passes,
simplify,
split,
allow_symbolic,
allow_parameter,
conservative,
fully_determined,
kwargs...
)
Structurally simplify algebraic equations in a system and compute the topological sort of the observed equations in sys
.
Optional Arguments:
- optional argument
io
may take a tuple(inputs, outputs)
. This will convert allinputs
to parameters and allow them to be unconnected, i.e., simplification will allow models wheren_unknowns = n_equations - n_inputs
.
Optional Keyword Arguments:
- When
simplify=true
, thesimplify
function will be applied during the tearing process. allow_symbolic=false
,allow_parameter=true
, andconservative=false
limit the coefficient types during tearing. In particular,conservative=true
limits tearing to only solve for trivial linear systems where the coefficient has the absolute value of $1$.fully_determined=true
controls whether or not an error will be thrown if the number of equations don't match the number of inputs, outputs, and equations.sort_eqs=true
controls whether equations are sorted lexicographically before simplification or not.
Missing docstring for alias_elimination
. Check Documenter's build log for details.
ModelingToolkit.StructuralTransformations.tearing
— Functiontearing(sys; simplify=false)
Tear the nonlinear equations in system. When simplify=true
, we simplify the new residual equations after tearing. End users are encouraged to call structural_simplify
instead, which calls this function internally.
Analyses
Missing docstring for ModelingToolkit.isaffine
. Check Documenter's build log for details.
Missing docstring for ModelingToolkit.islinear
. Check Documenter's build log for details.
Applicable Calculation and Generation Functions
ModelingToolkit.calculate_jacobian
— Functioncalculate_jacobian(sys::AbstractSystem)
Calculate the Jacobian matrix of a system.
Returns a matrix of Num
instances. The result from the first call will be cached in the system object.
ModelingToolkit.generate_jacobian
— Functiongenerate_jacobian(sys::AbstractSystem, dvs = unknowns(sys), ps = parameters(sys),
expression = Val{true}; sparse = false, kwargs...)
Generates a function for the Jacobian matrix of a system. Extra arguments control the arguments to the internal build_function
call.
Missing docstring for jacobian_sparsity
. Check Documenter's build log for details.
Problem Constructors
SciMLBase.NonlinearFunction
— MethodSciMLBase.NonlinearFunction{iip}(sys::NonlinearSystem, dvs = unknowns(sys),
ps = parameters(sys);
version = nothing,
jac = false,
sparse = false,
kwargs...) where {iip}
Create a NonlinearFunction
from the NonlinearSystem
. The arguments dvs
and ps
are used to set the order of the dependent variable and parameter vectors, respectively.
SciMLBase.NonlinearProblem
— MethodDiffEqBase.NonlinearProblem{iip}(sys::NonlinearSystem, u0map,
parammap = DiffEqBase.NullParameters();
jac = false, sparse = false,
checkbounds = false,
linenumbers = true, parallel = SerialForm(),
kwargs...) where {iip}
Generates an NonlinearProblem from a NonlinearSystem and allows for automatically symbolically calculating numerical enhancements.
Torn Problem Constructors
Missing docstring for BlockNonlinearProblem
. Check Documenter's build log for details.
Expression Constructors
ModelingToolkit.NonlinearFunctionExpr
— TypeSciMLBase.NonlinearFunctionExpr{iip}(sys::NonlinearSystem, dvs = unknowns(sys),
ps = parameters(sys);
version = nothing,
jac = false,
sparse = false,
kwargs...) where {iip}
Create a Julia expression for a NonlinearFunction
from the NonlinearSystem
. The arguments dvs
and ps
are used to set the order of the dependent variable and parameter vectors, respectively.
ModelingToolkit.NonlinearProblemExpr
— TypeDiffEqBase.NonlinearProblemExpr{iip}(sys::NonlinearSystem, u0map,
parammap = DiffEqBase.NullParameters();
jac = false, sparse = false,
checkbounds = false,
linenumbers = true, parallel = SerialForm(),
kwargs...) where {iip}
Generates a Julia expression for a NonlinearProblem from a NonlinearSystem and allows for automatically symbolically calculating numerical enhancements.