Is it possible to instantiate vectors of models in MTK?
What I mean is the following. I have created a re-usable “class” which I have named Well
. In the past, I have instantiated several copies of this model and used the instances in equations, example:
@mtkmodel Field begin
# Components used
@components begin
...
w1 = Well()
w2 = Well()
...
end
# Equations for connecting components
@equations begin
w1.p_i ~ ...
w2.p_i ~ ...
...
x ~ w1.p_i + w2.p_i + ...
end
end
This works. However, with many instances of Well
, the code is ugly.
What I would like to do is something similar to:
@mtkmodel Field begin
# Components used
@components begin
...
w[1:5] = Well()
...
end
# Equations for connecting components
@equations begin
w[1:5].p_i .~ ...
...
x ~ sum(w[1:5].p_i)
end
end
When I do this, and try to build the model:
@mtkbuild f = Field()
I get an error message:
type Array has no field p_i
Question:
- Is it possible to use arrays to instantiate models?
- If yes, how do I need to modify my code?