I have been working with several non-SI medical units on OpenModelica and created a package to contain them. What I wanted to do is to select another user defined unit for display purposes. This is done pretty easily for the types in Modelica library such as
Modelica.SIunits.Pressure P_example(displayUnit="bar");
To be more specific about the problem, I am working with 2 different pressure units: cmH2O and mmHg. My variables in the model are in cmH2O, so are all the calculations. I want to plot only few of the variables in mmHg. I have following declarations for the types:
type Pressure = Real(final quantity="Pressure", final unit="cmH2O");
type Pressure_mmHg = Real(final quantity="Pressure", final unit="mmHg");
As well as to_mmHg and from_mmHg functions, just like original Modelica Library. However, the variable I am trying to plot in mmHg still appears in cmH2O.
Types.Pressure P_lv(displayUnit="mmHg");
The following is working but not so fancy as I don't want to define a new variable unnecessarily.
Types.Pressure_mmHg P_lv_in_mmHg = Types.to_mmHg(P_lv);