Skip to contents

TearingState(sys) builds the structure that the simplification passes of mtkcompile() work on, as the type of the same name in ModelingToolkit: the list fullvars of unknowns and their derivatives, the bipartite incidence graph between equations and fullvars (structure$graph), and the derivative relations between variables (structure$var_to_diff, NA for none). It is a mutable environment.

Usage

TearingState(sys, sort_eqs = TRUE, ...)

Arguments

sys

A System with an independent variable or without one.

sort_eqs

Order the equations by their canonical sort key, so that the result does not depend on the order in which they were written.

...

Unused.

Value

An object of class TearingState.

Examples

t <- t_nounits; D <- D_nounits
variables("x(t)", "y(t)"); parameters("k")
sys <- System(list(D(x) ~ -k * y, 0 ~ x - y), t, name = "sys")
ts <- TearingState(sys)
ts$fullvars
#> [[1]]
#> Derivative(x(t), t)
#> 
#> [[2]]
#> x(t)
#> 
#> [[3]]
#> y(t)
#> 
ts$structure$graph
#> BipartiteGraph with (2, 3) (sources, destinations) and 4 edges
#>   1: 2 3
#>   2: 1 3
ts$structure$var_to_diff
#> [1] NA  1 NA