The passes that mtkcompile() combines, as the functions of the same
names in ModelingToolkit. Most users should call mtkcompile().
Usage
tearing(
sys,
state = TearingState(sys),
fully_determined = TRUE,
simplify = FALSE,
tearing_alg = c("carpanzano", "modia"),
allow_symbolic = FALSE,
allow_parameter = TRUE,
conservative = FALSE,
...
)
dummy_derivative(
sys,
state = TearingState(sys),
fully_determined = TRUE,
simplify = FALSE,
tearing_alg = c("carpanzano", "modia"),
allow_symbolic = FALSE,
allow_parameter = TRUE,
conservative = FALSE,
...
)
dae_index_lowering(sys, ...)
pantelides_reassemble(state, var_eq_matching)
alias_elimination(sys)
find_solvables(
state,
allow_symbolic = FALSE,
allow_parameter = TRUE,
conservative = FALSE
)
tearing_substitution(sys)Arguments
- sys
A
System.- state
A
TearingState(); it is modified.- fully_determined
Whether the system has as many equations as unknowns.
- simplify
Simplify the solved expressions.
- tearing_alg
"carpanzano"(the default) or"modia".- allow_symbolic
Allow solving for a variable whose coefficient contains other unknowns.
- allow_parameter
Allow solving for a variable whose coefficient contains parameters.
- conservative
Only divide by the numeric coefficients 1 and -1; symbolic coefficients follow
allow_symbolicandallow_parameter.- ...
Options passed on:
maxitersfor the Pantelides algorithm.- var_eq_matching
The matching returned by the Pantelides pass.
Details
alias_elimination(sys)removes the redundant equations among those that are integer linear combinations of variables and replaces the others by their reduced forms.dae_index_lowering(sys)runs the Pantelides algorithm and returns the system extended by the differentiated equations, which has index one.dummy_derivative(sys)reduces the index and selects states with the dummy derivative method, then tears and reassembles the system.tearing(sys)solves the equations that are linear in a variable for that variable, leaving the remaining (torn) equations as residuals. It does not reduce the index.tearing_substitution(sys)substitutes the observed equations into the equations of a simplified system.pantelides_reassemble(state, var_eq_matching)builds the system from a state after the Pantelides algorithm.find_solvables(state)(find_solvables!in Julia) fillsstate$structure$solvable_graphwith the pairs of equations and variables such that the equation is linear in the variable with a coefficient that can be divided by.
Examples
t <- t_nounits; D <- D_nounits
variables("x(t)", "y(t)", "z(t)"); parameters("k")
sys <- System(list(D(x) ~ -k * y, 0 ~ x - y + z, 0 ~ z - sin(x)), t, name = "sys")
torn <- tearing(sys)
equations(torn); observed(torn)
#> [[1]]
#> Derivative(x(t), t) ~ -k*y(t)
#>
#> [[1]]
#> z(t) ~ sin(x(t))
#>
#> [[2]]
#> y(t) ~ x(t) + z(t)
#>
equations(tearing_substitution(torn))
#> [[1]]
#> Derivative(x(t), t) ~ k*(-x(t) - sin(x(t)))
#>
ts <- TearingState(sys)
find_solvables(ts)
ts$structure$solvable_graph
#> BipartiteGraph with (3, 4) (sources, destinations) and 6 edges
#> 1: 4
#> 2: 2 3 4
#> 3: 1 3
# an index 2 system
sys2 <- System(list(D(x) ~ y, 0 ~ x - sin(t)), t, name = "idx")
equations(dae_index_lowering(sys2))
#> [[1]]
#> Derivative(x(t), t) ~ y(t)
#>
#> [[2]]
#> 0 ~ -cos(t) + Derivative(x(t), t)
#>
unknowns(dummy_derivative(sys2))
#> list()