Teaching Modelica Medical Non-SI Units

左心房为你撑大大i 提交于 2019-12-01 05:15:03

@Jay_At_Play, you may want to take another look at the Modelica Trac site that @MichaelTiller shared. I just discussed an approach that may help. However, as a warning, is is nonstandard and not directly compatible with the Modelica Standard Library.

(I wanted to add this to the comments under the original question, but I don't have the reputation points.)

As far as I know there is no good way to do this in a portable way.

The Modelica specification does not say how to handle user defined units so each tool does it (or not) its own way.

The best way I think is to do as you did by defining types in your model or library even if you have warnings in some tools.

In Dymola you might get rid of the warnings via:

Advanced.CheckUnits = false

in the command window.

Modelica Medical Non-SI (display) Units in Dymola:

  1. To have a suport for medical non-SI (display) units try to extend the Dymola file "C:\Program Files*\Dymola*\insert\displayunit.mos" such as https://github.com/MarekMatejak/Physiolibrary/blob/master/Physiolibrary/Resources/DisplayUnits/displayunit.mos

  2. definition of parameter or variable should have the attribute unit always set to SI unit and displayUnit can be everything what have defined conversion in Dymola file "displayunit.mos":

for example:

parameter Real systolicPressure(final unit="Pa", displayUnit="mmHg") = 16000;

parameter Real diastolicPressure(final unit="Pa", displayUnit="torr") = 10000;

Modelica will always calculate the models in SI units, but the parameter dialogs and output plots in Dymola will be in display units. So be carefull - every value in text code must be in SI unit.

Nominals are not directly connected with conversions.They are only for relative tolerances in numerical mathemathics behind.

If you find any mistake in Physiolibrary display units, please do not hesitate to report that. Thank you!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!