Options of the structural pipeline of mtkcompile
Source:R/structural-compile.R
mtkcompile_options.Rdmtkcompile() passes its ... to the structural simplification pipeline
(alias elimination, index reduction with the Pantelides algorithm, dummy
derivative state selection and tearing), which accepts these options.
Details
fully_determined:TRUErequires as many equations as unknowns;FALSEskips the consistency check and only tears, keeping surplus variables as unknowns;NULLchecks and decides.check_consistency: check that the system is balanced and not structurally singular (defaultTRUE).dummy_derivative: select states with the dummy derivative method (defaultTRUE). WithFALSEthe index reduced system keeps every differentiated variable as a state and drops the original constraints.eliminate_mm_zeros: eliminate variables that are identically zero and integrate their antiderivatives analytically, so thatD(x) ~ 0gives the observedx ~ x#0with a parameterx#0solved at initialization. The default isFALSE(ModelingToolkit usesTRUE), which keeps such variables as states. WithTRUE, an event that changesxupdatesx#0, as in ModelingToolkit.tearing_alg:"carpanzano"(default) or"modia".allow_symbolic,allow_parameter,conservative: which coefficients an equation may be divided by when it is solved for a variable: ones containing unknowns (defaultFALSE) and ones containing parameters (defaultTRUE); withconservative = TRUE(defaultFALSE) a numeric coefficient must be 1 or -1, while symbolic coefficients still follow the first two options. A parameter whose default value is zero is never divided by.maxiters: iteration limit of the Pantelides algorithm.inline_linear_sccs: solve each block of algebraic equations that is linear in its variables inside the generated right-hand side (defaultFALSE), symbolically for blocks of at mostanalytical_linear_scc_limitvariables (default 2) and numerically at run time for larger ones, so that the block's variables become observed.inline_nonlinear_sccs: an extension of modelcompR (defaultFALSE): solve each torn nonlinear algebraic block by a nested Newton iteration in the generated right-hand side, which turns such a DAE into an ODE.
State selection honors the state_priority and irreducible metadata of
variables and the state_priorities and irreducibles arguments of
System(). Unbalanced systems raise conditions of class
ExtraEquationsSystemException or ExtraVariablesSystemException, and
structurally singular ones InvalidSystemException.
Examples
t <- t_nounits; D <- D_nounits
variables("x(t)", "y(t)", "lam(t)"); parameters("g")
pend <- System(list(D(D(x)) ~ lam * x, D(D(y)) ~ lam * y - g, 0 ~ x^2 + y^2 - 1),
t, name = "pendulum")
unknowns(mtkcompile(pend))
#> [[1]]
#> y(t)
#>
#> [[2]]
#> x(t)
#>
#> [[3]]
#> yˍt(t)
#>
#> [[4]]
#> xˍt(t)
#>
#> [[5]]
#> lam(t)
#>
unknowns(mtkcompile(pend, dummy_derivative = FALSE))
#> [[1]]
#> y(t)
#>
#> [[2]]
#> x(t)
#>
#> [[3]]
#> yˍt(t)
#>
#> [[4]]
#> xˍt(t)
#>
#> [[5]]
#> lam(t)
#>