component(f) marks a constructor function f(name, ...) returning a
System as a component, the @component macro of ModelingToolkit: the
systems it builds record the constructor name in their metadata.
connector(f) does the same for connectors (@connector) and also sets
the connector type (see connector_type()), which connect() needs.
connector(sys) marks an existing system as a connector, and
connector("Name", variables = ...) builds a connector constructor from
declarations as mtkmodel() does.
Arguments
- type
The constructor name recorded in the metadata; by default the name of the argument.
- x, f
A constructor function, a
System, or a model name.- ...
For the name form, arguments of
mtkmodel().
Examples
t <- t_nounits
Pin <- connector(function(name) {
v <- Variable("v", t); i <- Variable("i", t, connect = Flow)
System(list(), t, list(v, i), list(), name = name)
})
p <- Pin(name = "p")
connector_type(p)
#> [1] "RegularConnector"
Pin2 <- connector("Pin2", variables = list("v(t)", list("i(t)", connect = Flow)))
Pin2(name = "q")
#> Model q:
#> Equations (0):
#> Unknowns (2): v(t), i(t)
#> Parameters (0):