Skip to contents

In ModelingToolkit, respecialize(sys, mapping) changes the symbolic type of nonnumeric parameters (such as callable parameters holding interpolants) to the concrete type of their values. R is untyped, so the type change itself does not apply: respecialize() checks that each parameter exists and has a nonnumeric value (from mapping, a list of parameters or formulas p ~ value / pairs list(p, value), or from the initial conditions), sets that value as the parameter's initial condition and records class(value)[1] in the variable_type metadata. With all = TRUE every parameter whose initial value is not a number is respecialized. Only complete systems can be respecialized.

Usage

respecialize(sys, mapping = list(), all = length(mapping) == 0L)

Arguments

sys

A complete System.

mapping

Parameters, or pairs of parameters and values.

all

Respecialize all nonnumeric parameters.

Value

The respecialized, complete System.

Examples

t <- t_nounits; D <- D_nounits
x <- Variable("x", t); f <- Parameter("f")
sys <- complete(System(list(D(x) ~ -x), t, ps = list(f), name = "s"))
sys2 <- respecialize(sys, list(list(f, splinefun(1:3, c(1, 4, 9)))))
getmetadata(parameters(sys2)[[1]], "variable_type")
#> [1] "function"