1

High I am trying to define my own unit in modelica. It is not a derivated unit.

I created a subpackges and put in:

package DiabetesUnits
  extends Modelica.Icons.Package;
  type InternationalUnit = Real (final quantity="InternationalUnit", final unit="IU",  min=0);
  type InsulinConcentration = Real (final quantity="InsulinConcentration", final unit="IU/m3", displayUnit="IU/litre", min=0);
  type InsulinConcentrationRate = Real (final quantity="InsulinConcentrationRate", final unit="IU/(s.dm3)", displayUnit="IU/(hour.litre)");
  type GlucoseConcentration = Real (final quantity="GlucoseConcentration", final unit="g/m3", displayUnit="mg/litre", min=0);
  type GlucoseRate = Real (final quantity="GlucoseConcentrationRate", final unit="g/(s)", displayUnit="mg/(hour)");
end DiabetesUnits;

but when I use it I get the error: Could not decode the unit symbol "IU" appearing in the unit string "IU/m3"

dichter-karl
  • 71
  • 1
  • 4
  • According to [Wikipedia](http://en.wikipedia.org/wiki/International_unit) `1 IU` of Insulin is equivalent to `0.0347 mg` of human insulin, so maybe you could just use mg or µg and convert to IU later (like the conversion `Modelica.SIunits.Conversions.to_degF`). – matth Jul 11 '14 at 13:04

2 Answers2

1

You don't mention what tool you are using, but you can consult the Modelica Specification (Chapter 19) for a discussion of what is legal and what is not. On the face of it, your definitions look reasonable but I didn't dig down into the actual ISO specification that the Modelica Specification references to see if there are specific restrictions that apply to your case (e.g., starting units with "I").

Michael Tiller
  • 9,291
  • 3
  • 26
  • 41
  • Oh, didn't thought the error war due to the naming convention. I use dymola and openmodelica. – dichter-karl Jul 14 '14 at 20:33
  • Well I don't know the reason it failed. My answer is simply to point out potential sources of more information to try and uncover the issue. You might also try contacting the OpenModelica developers directly since they could probably give you a definitive answer on whether it is due to a restriction in the Modelica or ISO specification. – Michael Tiller Jul 15 '14 at 00:07
0

You can deactivate unit checking in Dymola using Advanced.CheckUnits = false I have the same problem using medical units. You might find some relevant information in my thread on medical non-SI units. Answeres by Micheal Tiller and kdavies4 were very helpful to me. kdavies4 implements units as variables which might suit your needs.
Teaching Modelica Medical non-SI units

Community
  • 1
  • 1
Jay_At_Play
  • 136
  • 10