I’m quite noob in Modelica language and I’d appreciate any help about this simple issue. I’d like to know if it’s possible to write variables name (that depends on a submodel) as a function of other variable in order to shorten the general code. Here there is an example about what I’d like to do.
I’m considering a top-level model that includes three identical submodels (OpenTank) of the Standard Modelica Library (tank1,tank2 and tank3). I’d like to know if it’s possible to call the variable (“level”) inside the submodels from the top-level model using a loop like this way (example code is attached) or something similar instead of repeating the code three times (I’m really interested in setting this operation in the top-level model)
What would you advise me to do? Thanks in advance!
model threeTanks
Modelica.Fluid.Vessels.OpenTank tank1;
Modelica.Fluid.Vessels.OpenTank tank2;
Modelica.Fluid.Vessels.OpenTank tank3;
equation
for i in 1:3 loop
tank(i).level= /* … */;
end for;
end threeTanks;