Skip to contents

generate_initializesystem(sys, op = ...) returns the system of nonlinear equations that determines consistent initial values of a time dependent system. Its unknowns are the unknowns of sys, the derivatives of its differential variables (named xˍt) and its solvable parameters (those bound to NA). Its equations are

Usage

generate_initializesystem(
  sys,
  op = list(),
  initialization_eqs = list(),
  guesses = list(),
  default_dd_guess = 0,
  algebraic_only = FALSE,
  time_dependent_init = !is.null(get_iv(sys)),
  name = nameof(sys),
  ...
)

Arguments

sys

A complete System.

op

Operating point: initial conditions and parameter values.

initialization_eqs

Further initialization equations.

guesses

Further guesses, as a variable map.

default_dd_guess

Guess for the derivative variables.

algebraic_only

Ignore the initialization equations of the system (those in initialization_eqs are still used).

time_dependent_init

Build the time dependent initialization.

name

Name of the initialization system.

...

Unused.

Value

A time independent System with is_initializesystem set.

Details

  • the algebraic equations of sys, and xˍt ~ f for each differential equation D(x) ~ f, with observed variables substituted;

  • the bindings of variables;

  • one equation per initial condition in op or in the system: a constant x ~ 1 becomes x ~ Initial(x) with the parameter Initial(x) set to 1, an expression is used as it is; conditions on observed variables and on derivatives (D(x) ~ 0) are allowed;

  • the initialization equations of sys and those in initialization_eqs.

Guesses become the guesses of the returned system, and the parameter values and Initial values its initial conditions, so it can be passed to mtkcompile() with fully_determined = FALSE and then to NonlinearProblem(). InitializationProblem() does all of this.

For a time independent system (or time_dependent_init = FALSE) the initialization system solves only for the solvable parameters; the unknowns enter through Initial(x).

A value of NULL in op (as the pair list(x, NULL)) removes the initial condition of x, and NA makes a parameter solvable.

Examples

t <- t_nounits; D <- D_nounits
x <- Variable("x", t); y <- Variable("y", t)
sys <- mtkcompile(System(list(D(x) ~ -x + y, 0 ~ x^2 + y^2 - 1), t, name = "dae"))
isys <- generate_initializesystem(sys, op = list(x ~ 0.6), guesses = list(y ~ 1))
equations(isys)
#> [[1]]
#> xˍt(t) ~ -x(t) + y(t) 
#> 
#> [[2]]
#> 0 ~ x(t)^2 + y(t)^2 - 1 
#> 
#> [[3]]
#> x(t) ~ Initial(x(t)) 
#> 
unknowns(isys)
#> [[1]]
#> x(t)
#> 
#> [[2]]
#> y(t)
#> 
#> [[3]]
#> xˍt(t)
#>