0

In the example Modelica.Fluid.Examples.Tanks.ThreeTanks, the code shows that the application has a central variable Medium and is used in components where needed:

replaceable package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater
   constrainedby Modelica.Media.Interfaces.PartialMedium;

The application components tanks and pipes, six altogether, have a redeclare Medium statement in each component that refers to the application central variable Medium. The code design makes it convenient to change the Medium at a central place, at least code-wise.

However, when you use OpenModelica GUI you cannot access the central variable Medium, but you can access the variable in each component. Is there really no way to access the central variable from the GUI? Can you access it in some other Modelica software´s GUI?

Here is also a central model System that contains some general attributes used by components, but not Medium.

In the two following examples: TanksWithOverflow and EmptyTanks, there are no central variable Medium. Instead, each component Medium is redeclared with the full reference to the actual Medium. From the GUI you can change the Medium by going through all components, as you in fact need to do in the first example.

In several other examples like ControlledTank, AST_BatchPlant, etc. you often have a central application variable for Medium, but with the same limitations as described above, i.e. cannot be accessed from the OpenModelica GUI.

The code is identical in this respect both from MSL 4.0.0 and 3.2.3.

Thus, the question is, is there some GUI that can address the central variable and change it?

Does the difference in code between the first three examples reflect a later limitation in what to expect from GUI and that there was an earlier GUI that could handle this central Medium variable?

marco
  • 5,944
  • 10
  • 22
janpeter
  • 681
  • 8
  • 22
  • 2
    This is a limitation of OpenModelica. Dymola will let you change the Medium at the top level. As a workaround you can drag and drop the ´ThreeTanks´ model as a component in a new model and then you can edit the Medium in it. – Adrian Pop Aug 26 '23 at 10:30
  • 2
    I opened a ticket so we can look into fixing this: https://github.com/OpenModelica/OpenModelica/issues/11089 – Adrian Pop Aug 26 '23 at 10:39
  • Interesting. Is it easy for you to check Wolframs SystemModeler? See, if can get some information from others. – janpeter Aug 26 '23 at 10:55
  • Sorry, I don't have access to anything else but OpenModelica and Dymola. – Adrian Pop Aug 26 '23 at 11:10
  • Adrian, could you take a screenshot of Dymola where you change the central variable Medium in ThreeTanks. I am curious where you in the GUI represent a central application variable. Is there a menu for the application ThreeTanks where you show parameters etc, similar to a component-menu-interaction? – janpeter Aug 29 '23 at 08:10
  • Adrian, and what you said about workaround in OpenModelica to put ThreeTanks in an encompassing model say TEST.mo, does work for simulation, and you can now access the parameter Medium, but when you change it you get error: Invalid redeclaration of class Medium in component. – janpeter Aug 29 '23 at 08:31
  • 1
    Ok, you discovered a bug in OpenModelica, it should do a package redeclaration, not a component redeclaration. I will check with the latest OpenModelica if this is fixed or not. – Adrian Pop Aug 29 '23 at 12:27
  • 1
    I can confirm that in the nightly-build this bug is fixed, the Medium is correctly redeclared as a package not as a component. – Adrian Pop Aug 31 '23 at 16:47
  • Good. I have now tested the nightly build and see that it works. Thus, if you make a new model and drag ThreeTanks into it giving only the top icon representation (a run button) you can right click that and get in the parameter list the application general parameter "replaceable package Medium = Modelica.Media..." and you can change that at this single spot and the components Tanks and Pipes is "adapted" to the changed Medium. (Or you can alternatively say that the Medium is propagated to the components). – janpeter Sep 01 '23 at 06:39
  • The limitation is that you now do not see the structure of the process with its components. Much more useful would be if you could implement a "component browser" like in Dymola! – janpeter Sep 01 '23 at 06:40
  • 1
    The component browser is on our todo list, but I don't know when we will get to it. – Adrian Pop Sep 01 '23 at 13:54

1 Answers1

2

In Dymola or OpenModelica anyway you cannot change the MSL because is read-only, you need to duplicate the class first:

enter image description here

Then in the duplicated model you just right click on the diagram and you get this:

enter image description here

Where you select "Parameters" and you get this:

enter image description here

You need to wait a bit to get the populated list.

Adrian Pop
  • 4,034
  • 13
  • 16
  • Understand this is Dymola. Good to see that the application Medium package "parameter" is accessible from the component browser, although this parameter is not a component. Would be interesting if some other vendors do the same. – janpeter Aug 29 '23 at 13:41
  • 1
    Yes, in OpenModelica we do have the functionality implemented but is not yet connected to the top level model (only works on top level components). We will add it. – Adrian Pop Aug 29 '23 at 17:06