I want to use non-SI units in a Modelica model in a medical context. I am using Modelica in Dymola. Being an engineer I prefer the SI units. But my model parameters are sourced from medical publications and I want to avoid conversion mistakes. Medical units also simplify communication with doctors.
For example, the unit "mmHg" (millimetres of mercury) is used instead of "Pa" for pressure. Pressure variables are defined in the model as follows:
type Pressure_mmHg = Real (final quantity="Pressure", final unit="mmHg")
Translating the model for simulation yields the following warning for every single non-SI variable in the model (~300 warnings in total):
Could not decode the unit symbol "mmHg" appearing in the unit string "mmHg"
If changes to the model cause a new warning it is near impossible to detect. Therefore I need to teach Modelica the unit "mmHg".
My current knowledge on the topic:
- Modelica Language Specification 3.3, Chapter 19 Unit Expressions:
"It is possible to support user defined unit symbols."
However the document does not elaborate on this.
- users may define display units (Real attribute "displayUnit") for use in the simulation GUI, as long as a conversion factor is defined in the "displayunit.mos" file in the Dymola directory as follows:
defineUnitConversion("Pa", "mmHg", 760/101325);
This is not an option because it diminishes portability of the model. It has to be performed manually on every computer that runs the model and requires administrator rights (which I don't have).
Thanks in advance for your help, it is much appreciated!
EDIT (might be helpful to anyone coming across this in the future):
Versions at time of posting: Modelica Standard Library 3.2, Dymola Version 2014 (64-bit) 2013-03-25
I forgot to add the following to my current knowledge on the topic: The Physiolibrary 2.1.1 defines displayUnits for the GUI. For coding, the authors use the following trick:
type Pressure = Modelica.SIunits.Pressure(displayUnit="mmHg", nominal=133.322387415);
This way Modelica handles variables of type Pressure as having the unit Pascal (N/m2), but divides every value entered in code by the given nominal.
CORRECTION:
In this section, I previously stated that the Physiolibrary uses the Real attribute nominal for unit conversion. This is NOT the case. Thank you Marek Matejak (author of the Physiolibrary) for correcting me. The sole purpose of the attribute nominal is scaling of the numerical problem for stability reasons.