Skip to contents

add_initialization_parameters(sys) adds a parameter Initial(x) for every unknown, every observed variable, their first derivatives and every solvable parameter of a flat system, as ModelingToolkit does when a system is completed. The value of Initial(x) is the initial value of x.

Usage

add_initialization_parameters(sys, split = TRUE)

Arguments

sys

A flat System (no subsystems).

split

Unused; kept for compatibility.

Value

The system with the added parameters.

Details

In this package complete() and mtkcompile() add only the Initial parameters that the model refers to (in equations, bindings such as q ~ Initial(y), or initialization equations), so the parameter vector of a problem stays free of unused entries; call this function to add them all. The initialization system built by generate_initializesystem() always has the Initial parameters of the constrained variables.

Examples

t <- t_nounits; D <- D_nounits
x <- Variable("x", t); k <- Parameter("k")
sys <- System(list(D(x) ~ -k * x), t, name = "decay")
sys2 <- add_initialization_parameters(sys)
parameters(sys2, initial_parameters = TRUE)
#> [[1]]
#> k
#> 
#> [[2]]
#> Initial(x(t))
#> 
#> [[3]]
#> Initial(xˍt(t))
#>