Open
Description
In hierachical modeling I often feel the need to "hide" some of the hierarchal complexity. Let's suppose I have an inner model inner
with parameter p
and an outer model outer
which includes the inner model 2 times. The fact that the outer model contains the inner model is just an implementation detail, in the end it want to expose parameter p
directly from my outer model. I can do something like this:
using ModelingToolkit
using ModelingToolkit: D
@variables t
@mtkmodel inner begin
@parameters begin
p
end
@variables begin
i(t)
end
@equations begin
D(i) ~ p*i
end
end
@mtkmodel outer begin
@parameters begin
p
end
@variables begin
o(t)
end
@components begin
inner1 = inner(p=p)
inner2 = inner(p=p)
end
@equations begin
o ~ inner1.i + inner2.i
end
end
@mtkbuild outerb = outer()
The problem is, that now inner1.p
and inner2.p
only default to outer.p
. But they are still independent. For example I cannot change outer.p
in a callback.
Is there a way to achieve that using the public interface? What I want is essentially something like:
- flattening the system (i.e. put all the equations together in a big eqs vector), removing the subsystems (is there a
- replacing every occurrence of
inner1₊p
andinner2₊p
byp
in the equations - get rid of the
inner1₊p
andinner2₊p
as a parameter all together