Skip to contents

collect_vars(expr, iv) returns the unknowns and parameters appearing in expr (an expression, equation, inequality, pair list(a, b), or a list of them), as collect_vars! in ModelingToolkit. Derivatives contribute their variable; a delayed or evaluated variable x(t - tau) contributes x(t) and the parameters of its argument. Only variables whose scope matches depth are kept (0: local, d: ParentScope applied d times, -1: global). collect_scoped_vars(sys) collects the variables of the equations, jumps and constraints of sys that refer to the enclosing system (depth 1 by default). eqtype_supports_collect_vars(eq) tells whether an object is supported.

Usage

collect_vars(expr, iv = NULL, depth = 0, scopes = NULL)

collect_scoped_vars(sys, iv = get_iv(sys), depth = 1)

eqtype_supports_collect_vars(eq)

Arguments

expr

Expressions or equations.

iv

The independent variable, or NULL.

depth

Scope depth to collect.

scopes

Scope map of a system (internal).

sys

A System.

eq

An object.

Value

A list with elements unknowns and parameters.

Examples

t <- t_nounits; D <- D_nounits
x <- Variable("x", t); k <- Parameter("k")
collect_vars(D(x) ~ -k * x, t)
#> $unknowns
#> $unknowns[[1]]
#> x(t)
#> 
#> 
#> $parameters
#> $parameters[[1]]
#> k
#> 
#>