Skip to contents

mtkcompile() 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: TRUE requires as many equations as unknowns; FALSE skips the consistency check and only tears, keeping surplus variables as unknowns; NULL checks and decides.

  • check_consistency: check that the system is balanced and not structurally singular (default TRUE).

  • dummy_derivative: select states with the dummy derivative method (default TRUE). With FALSE the 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 that D(x) ~ 0 gives the observed x ~ x#0 with a parameter x#0 solved at initialization. The default is FALSE (ModelingToolkit uses TRUE), which keeps such variables as states. With TRUE, an event that changes x updates x#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 (default FALSE) and ones containing parameters (default TRUE); with conservative = TRUE (default FALSE) 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 (default FALSE), symbolically for blocks of at most analytical_linear_scc_limit variables (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 (default FALSE): 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)
#>