Open
Description
Is your feature request related to a problem? Please describe.
When attempting to make a top level variable that summarizes leaf variables, the leaf variables required duplicating at all intermediate levels.
Describe the solution you’d like
Treat the components of a subcomponent as accessible elements. See commented version below.
Describe alternatives you’ve considered
Workaround is available by introducing intermediate variables at all intermediate levels of hierarchy.
Additional context
using ModelingToolkit
@mtkmodel AMdl begin
@description "A Model"
@variables begin
a(t)::Float64 = 0
end
@equations begin
a ~ sin(2π * t / 10)
end
end
@mtkmodel Bmdl begin
@description "B Model"
@components begin
a = [AMdl() for i in 1:2]
end
@variables begin # added to show accessing through a variable
b(t)[1:2]
end
@equations begin # added to show accessing through a variable
[b[i] ~ a[i].a for i in 1:2]
end
end
@mtkmodel Cmdl begin
@description "C Model"
@components begin
b = Bmdl()
end
@variables begin
c(t)[1:2]
end
@equations begin
# [c[i] ~ b.a[i].a for i in 1:2] # does not work - accessing through a component
[c[i] ~ b.b[i].a for i in 1:2] # works - accessing through a variable
end
end
@mtkbuild cmdl = Cmdl()
observed(cmdl) # Check the observed variables
Metadata
Metadata
Assignees
Labels
No labels