mtkmodel(name, ...) returns a constructor f(name, ...) of systems,
the counterpart of ModelingToolkit's @mtkmodel blocks. Each call builds
the model in a fresh environment, in this order:
structural_parameters: a named list of values;parameters,constantsandvariables: declarations, strings such as"R = 1.0"or"v(t) = 0", orlist("i(t)", connect = Flow)to add metadata; each is bound to its name;extend: a named list of quoted calls building base systems, whose variables and subsystems become available unnamespaced (as@extendand@unpack), and which the model extends;components: a named list of quoted calls building subsystems, bound to their names; the name argument is added;equations,initial_conditions,guesses,continuous_eventsanddiscrete_events: quoted expressions (or functions without arguments) evaluated in that environment, returning lists.
The constructor's arguments override structural parameters and the
defaults of declared parameters and variables; comp__arg = value
passes arg = value to the component comp; arguments named after the
declarations of an extended model are passed to it.
Usage
mtkmodel(
name,
structural_parameters = list(),
parameters = list(),
constants = list(),
variables = list(),
components = list(),
extend = list(),
equations = NULL,
initial_conditions = NULL,
guesses = NULL,
continuous_events = NULL,
discrete_events = NULL,
description = "",
connector = FALSE,
iv = NULL,
metadata = list(),
.env = parent.frame()
)Arguments
- name
The model name.
- structural_parameters
Named list of structural parameters.
- parameters, constants, variables
Declarations.
- components, extend
Named lists of quoted constructor calls.
- equations, initial_conditions, guesses, continuous_events, discrete_events
Quoted expressions or functions without arguments.
- description
A string.
- connector
Build a connector.
- iv
The independent variable.
- metadata
A list of system metadata.
- .env
The environment in which blocks see other functions and variables.