0

If possible I would like to create an array of replaceable media packages that a user can then change each option using available choices.

Below is a typically way to define the medium.

  replaceable package Medium = Modelica.Media.Interfaces.PartialMedium
    "Coolant medium" annotation (choicesAllMatching=true);

The following is a prototype of what I was hoping could be done where each of the "Mediums" is potentially a different media.

parameter Integer n = 1 "Number of media models";
replaceable package Medium[n] = {Modelica.Media.Interfaces.PartialMedium}
    "Coolant medium" annotation (choicesAllMatching=true);

However, this is not acceptable modelica. I've tried using variations on records as well but found no success. Any ideas? Perhaps this is not permitted in Modelica... Thank you.

Scott G
  • 2,194
  • 1
  • 14
  • 24
  • What is your intention with this? Enable a user to select a coolant medium? If so, there's probably a more idiomatic way to do this, possibly by using replaceable/redeclare. – Christoph Oct 24 '17 at 05:56
  • Can't tell you how I would use it. That's top secret... ok fine I'll say. One use case is with a multi-layered material of different properties in each layer. I'm not using the fluid library but my solid media library which has the same package format. Keeps me from having to make a new model for every additional layer someone may want/need. – Scott G Oct 24 '17 at 12:58

1 Answers1

2

If it was possible to create such an array, consider how you could use it:

model M
  replaceable package Medium[n];
  medium[1] m1; // "Creates a Medium array of size 1"; not reference to Medium 1
  Real r = Medium[1].f(...); // Disallowed syntax; function names do not contain subscripts
end M;

You could probably try the following (works in OpenModelica; not tested in Dymola), but it is of limited value:

package M
  constant Real r;
end M;

model Test
  M[2] m(r={1,2});
  M m1=m[1];
  M m2=m[2];
end Test;
sjoelund.se
  • 3,468
  • 12
  • 15
  • A bit unfortunate that this isn't permitted. Thanks for the suggestion on the example. Unfortunately that is not useful in my case but I did test it in Dymola and it works fine. – Scott G Oct 24 '17 at 13:15