Search code examples
updatesmodelica

Modelica conversion script for replaceable package


Fluid properties routines in Modelica might use replaceable package, I also followed that approach. Now I want to restructure that library/package, in the example below I want to change the path where the medium is stored, as well as the names of some functions:

within ;
package myPackage
  model myModelA
    import Modelica.Units.SI;
    replaceable package Medium = myMediaLib.R134a;
  //replaceable package Medium = myMediaLib_new.R134a;
    SI.Temprature T;
  equation
    T = Medium.temperature_ph(101325,200e3);
  //T = Medium.temperature_phX(101325,200e3);
  end myModelA;

  model myModelB
    import Modelica.Units.SI;
    replaceable package primaryMedium = myMediaLib.R134a;
  //replaceable package primaryMedium = myMediaLib_new.R134a;
    SI.Temprature T;
  equation
    T = primaryMedium.temperature_ph(101325,200e3);
  //T = primaryMedium.temperature_phX(101325,200e3);
  end myModelB;
end myPackage;

The conversion script I tried looks like this (tested several variants also):

convertClass("myMediaLib.R134a", "myMediaLib_new.R134a");
convertClass("myMediaLib.R134a.temperature_ph", "myMediaLib_new.R134a.temperature_phX");

The issue with this is that it changes the name from generic Medium or primaryMedium to the full path. Is it even possible to achieve what I want with conversion script?


Solution

  • I think, the issue is that the second conversion is actually not converting a class, but an element of a class.

    Therefore, would the conversions below do what you need?

    convertClass("myMediaLib.R134a", "myMediaLib_new.R134a");
    convertElement("myMediaLib.R134a", "temperature_ph", "temperature_phX");