Structural Transformation

Internal API

The functions documented on this page are internal implementation details of ModelingToolkit. They are not part of the public API and may change or be removed without notice in non-breaking releases. This documentation is provided to help contributors understand the codebase.

These functions are used for structural analysis and transformation of equation systems, including index reduction, tearing, and other algebraic manipulations used in the simplification process.

Tearing and Algebraic Simplification

ModelingToolkit.StructuralTransformations.tearing_reassembleFunction

Main internal function for structural simplification for DAE systems and discrete systems. Generate dummy derivative variables, new equations in terms of variables, return updated system and tearing state.

Terminology and Definition:

A general DAE is in the form of F(u'(t), u(t), p, t) == 0. We can characterize variables in u(t) into two classes: differential variables (denoted v(t)) and algebraic variables (denoted z(t)). Differential variables are marked as SelectedState and they are differentiated in the DAE system, i.e. v'(t) are all the variables in u'(t) that actually appear in the system. Algebraic variables are variables that are not differential variables.

Arguments

  • state: The TearingState of the system.
  • var_eq_matching: The maximal matching after state selection.
  • full_var_eq_matching: The maximal matching prior to state selection.
  • var_sccs: The topologically sorted strongly connected components of the system according to full_var_eq_matching.
source
Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Index Reduction

Missing docstring.

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

Consistency Checking

ModelingToolkit.StructuralTransformations.check_consistencyFunction
check_consistency(
    state::TransformationState,
    orig_inputs;
    nothrow
) -> Bool

Check the consistency of state, given the inputs orig_inputs. If nothrow == false, throws an error if the system is under-/over-determined or singular. In this case, if the function returns it will return true. If nothrow == true, it will return false instead of throwing an error. The singular case will print a warning.

source

Incidence Matrix Operations

Missing docstring.

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

Variable Ordering and Masks

Missing docstring.

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

Missing docstring.

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

ModelingToolkit.StructuralTransformations.computed_highest_diff_variablesFunction
computed_highest_diff_variables(structure)

Computes which variables are the "highest-differentiated" for purposes of pantelides. Ordinarily this is relatively straightforward. However, in our case, there is one complicating condition:

We allow variables in the structure graph that don't appear in the
system at all. What we are interested in is the highest-differentiated
variable that actually appears in the system.

This function takes care of these complications are returns a boolean array for every variable, indicating whether it is considered "highest-differentiated".

source

Shift Operations

These functions handle shift operations in discrete-time systems.

ModelingToolkit.StructuralTransformations.distribute_shiftFunction

Distribute a shift applied to a whole expression or equation. Shift(t, 1)(x + y) will become Shift(t, 1)(x) + Shift(t, 1)(y). Only shifts variables whose independent variable is the same t that appears in the Shift (i.e. constants, time-independent parameters, etc. do not get shifted).

source

System Structure Types and Functions

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Graph Types

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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

Missing docstring.

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