Build-in unit conversion in SimBiology

1 回表示 (過去 30 日間)
emjey
emjey 2022 年 7 月 21 日
コメント済み: emjey 2022 年 7 月 21 日
I wonder if you can provide resource with proper definition of units. What one gets with sbiowhos -builtin -unit does not make sense to me.
Below I extracted time related units - the 'Composition' column content would mean that e.g. 'hour' and 'second' are independent and no unit conversion is performed. Could you clarify how unit conversion works in SimBiology?
SimBiology Built-In Units:
Index: Name: Composition: Multiplier:
...
10 day day 1.000000
...
20 hour hour 1.000000
...
31 minute minute 1.000000
  1 件のコメント
emjey
emjey 2022 年 7 月 21 日
Thinking about it and experimenting with SimBiology it looks like SimBiology does the conversion correctly, and it is probably an incomplete documentaiton which caused the confussion.
A related question is about 'item', 'molecule' - are they related?

サインインしてコメントする。

採用された回答

Arthur Goldsipe
Arthur Goldsipe 2022 年 7 月 21 日
Short answer:
You can see the relationship between two by using the function sbiounitcalculator, which shows you that 1 day is equal to 24 hours, that item and molecule are equivalent, and that mole and gram are not dimensionally consistent:
sbiounitcalculator('day', 'hour', 1)
ans = 24
sbiounitcalculator('molecule', 'item', 1)
ans = 1
sbiounitcalculator('mole', 'gram', 1)
Error using SimBiology.internal.calculateConversion
Unable to convert between units. Units are not of the same physical quantity.

Error in sbiounitcalculator (line 23)
results = SimBiology.internal.calculateConversion(fromUnits, toUnits, values(:));
Longer answer:
I'm not realy sure how to answer the question "How does unit conversion work in SimBiology?" I'm a developer of SimBiology, so I know about all the internal details of how unit conversion currently works. But I hope that you don't need to know about all those details. And those details might change over time, so it's better if you don't learn to rely on them. I'd also like unit conversion to "just work" without your having to think about it or needing to ready any documentation.
But I do understand and agree that SimBiology's unit conversion is not always understandable. For example, I find it confusing when a unit like minute is defined in terms of itself. I believe you will only see this sort of circular defintion for a builtin unit that corresponds to either one of the 7 fundamental physical quantities (time, length, mass, temperature, current, light, and quantity of substance) OR is simply dimensionless. However, as you see we have several time units that can be interconverted. I think it would have been better if SimBiology had said that day is defined as 24 hour, hour is defined as 60 minutes, and so forth. We'd still need one unit for each fundamental quantity that could not be defined in terms of any other unit. If you think that would be a useful change, let me know.
If you want to check explicitly whether two units (or compound unit expressions like mole/liter) are dimensionally consistent and see how to convert between those units, then you can use the function sbiounitcalculator. This function will error if either unit expression is invalid or if the two unit expressions are not dimensionally consistent. Otherwise, it will convert a number from one unit to the other, such as converting 2 days to 48 hours.
If you have any remaining questions about unit conversion, please ask. It would help me if you can tell me a little more about the larger workflow of what you're trying to do. Then I will have a better idea of how we can improve SimBiology and its documentation.
  1 件のコメント
emjey
emjey 2022 年 7 月 21 日
That's exactly what I wanted to know. I was not aware of the 'sbiounitcalculator' function - very useful. From what you get when using 'sbiowhos -builtin -unit' is confusing. The confusion comes from the appparent circularity you mentioned. All clear now, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExtend Modeling Environment についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by