Consider the MTK Pin example.
@connector Pin begin
v(t) = 0.0, [description = "Voltage"]
i(t), [connect = Flow]
end
Suppose I wanted to also define the auxiliary variable p(t) = v * i
(for power), such that I could refer to pin.p
. I can’t figure out how to do that. The docs for connector say that connectors can be complex:
Similar to @mtkmodel, @connector accepts begin blocks of @components, @equations, @extend, @parameters, @structural_parameters, @variables.
But @variables
seems to be a no-op (same effect as when defining directly with @variables
).
@connector Pin begin
v(t) = 0.0, [description = "Voltage"]
i(t), [connect = Flow]
p(t), [connect = Flow]
@equations begin
p = v * i
end
end
seems to work, but
- A) It yields a warning about unbalanced connectors
- B) It will generate a lot of redundant connecting equations.
p
really is an auxiliary variable, no need to “connect” it (and I shouldn’t have to specify itsconnect
property)