Skip to contents

mtkcompile(sys) turns a model into a system ready for building numerical problems: it expands connections, flattens the hierarchy, eliminates aliases and trivially solvable variables, reduces the index of differential algebraic systems, and selects states, leaving the eliminated variables as observed equations. structural_simplify() is its former name.

Usage

mtkcompile(
  sys,
  inputs = list(),
  outputs = list(),
  disturbance_inputs = list(),
  simplify = FALSE,
  fully_determined = TRUE,
  structural = TRUE,
  additional_passes = list(),
  split = TRUE,
  ...
)

structural_simplify(sys, ...)

Arguments

sys

A System.

inputs, outputs, disturbance_inputs

Variables to treat as inputs (turned into parameters) and outputs.

simplify

Simplify the resulting expressions.

fully_determined

Require as many equations as unknowns.

structural

Run the full structural pipeline (TRUE) or only the ModelingToolkitBase lowering (FALSE).

additional_passes

A list of functions applied to the result.

split

Unused; kept for compatibility.

...

Options passed to the structural pipeline.

Value

A complete, scheduled System.

Examples

t <- t_nounits; D <- D_nounits
variables("x(t)", "y(t)"); parameters("tau = 3")
sys <- System(list(D(x) ~ (y - x) / tau, y ~ 2 * x), t, name = "sys")
csys <- mtkcompile(sys)
unknowns(csys); observed(csys)
#> [[1]]
#> x(t)
#> 
#> [[1]]
#> y(t) ~ 2*x(t) 
#>