教授 Modelica 医学非 SI 单位 [英] Teaching Modelica Medical Non-SI Units

查看:34
本文介绍了教授 Modelica 医学非 SI 单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在医学环境中的 Modelica 模型中使用非 SI 单位.我在 Dymola 中使用 Modelica.作为一名工程师,我更喜欢 SI 单位.但是我的模型参数来自医学出版物,我想避免转换错误.医疗单位还简化了与医生的沟通.

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.

例如,使用单位mmHg"(毫米汞柱)代替Pa"表示压力.模型中的压力变量定义如下:

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")

为仿真转换模型会为模型中的每个非 SI 变量生成以下警告(总共约 300 个警告):

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"

如果对模型的更改导致了新的警告,则几乎无法检测到.因此我需要教 Modelica 单位毫米汞柱".

If changes to the model cause a new warning it is near impossible to detect. Therefore I need to teach Modelica the unit "mmHg".

我目前对该主题的了解:
- Modelica 语言规范 3.3,第 19 章单元表达式:可以支持用户定义的单位符号."然而,该文件并没有详细说明这一点.
- 用户可以定义用于模拟GUI的显示单位(Real属性displayUnit"),只要在Dymola目录下的displayunit.mos"文件中定义一个转换因子如下:

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!

编辑(可能对将来遇到此问题的任何人都有帮助):
发布时的版本:Modelica Standard Library 3.2,Dymola 版本 2014(64 位)2013-03-25

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

我忘记将以下内容添加到我目前对该主题的了解中:Physiolibrary 2.1.1 定义了 GUI 的显示单元.对于编码,作者使用以下技巧:

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);

这种方式 Modelica 将压力类型的变量处理为单位为帕斯卡 (N/m2),但将代码中输入的每个值除以给定的标称值.

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.

更正:
在本节中,我之前说过 Physiolibrary 使用 Real 属性nominal 进行单位转换.不是这种情况.感谢 Marek Matejak(生理图书馆的作者)对我的纠正.属性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.

推荐答案

@Jay_At_Play,你可能想再看看 @MichaelTiller 分享的 Modelica Trac 网站.我刚刚讨论了一种可能会有所帮助的方法.但是,作为警告,它是非标准的,并且与 Modelica 标准库不直接兼容.

@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.)

这篇关于教授 Modelica 医学非 SI 单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆