NonlinearSystem

System Constructors

ModelingToolkit.NonlinearSystemType
struct 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 until calculate_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 in ODEProblem.
  • 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, then sys.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],[σ,ρ,β])
source

Composition and Accessor Functions

  • get_eqs(sys) or equations(sys): The equations that define the nonlinear system.
  • get_unknowns(sys) or unknowns(sys): The set of unknowns in the nonlinear system.
  • get_ps(sys) or parameters(sys): The parameters of the nonlinear system.
  • get_u0_p(sys, u0map, parammap) Numeric arrays for the initial condition and parameters given var => value maps.

Transformations

ModelingToolkit.structural_simplifyFunction
structural_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 all inputs to parameters and allow them to be unconnected, i.e., simplification will allow models where n_unknowns = n_equations - n_inputs.

Optional Keyword Arguments:

  • When simplify=true, the simplify function will be applied during the tearing process.
  • allow_symbolic=false, allow_parameter=true, and conservative=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.
source
Missing docstring.

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

Analyses

Missing docstring.

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

Missing docstring.

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

Applicable Calculation and Generation Functions

ModelingToolkit.calculate_jacobianFunction
calculate_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.

source
ModelingToolkit.generate_jacobianFunction
generate_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.

source
Missing docstring.

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

Problem Constructors

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

source
SciMLBase.NonlinearProblemMethod
DiffEqBase.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.

source

Torn Problem Constructors

Missing docstring.

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

Expression Constructors

ModelingToolkit.NonlinearFunctionExprType
SciMLBase.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.

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

source