modelica / VehicleInterfaces

Free (standard conforming) library for interface definitions and architectures for vehicle system modeling
Other
43 stars 22 forks source link

Units error (or incompatibiity?) in VehicleInterfaces\Engines\MinimalEngine.mo: r/min vs 1/min #90

Closed simonpickering closed 3 years ago

simonpickering commented 3 years ago

I'm a new user of Modelica and the VehicleInterfaces package.

I'm using OpenModelica v1.18.0 (64bit) and VehicleInterfaces v2.0.0 on Windows 10.

When trying to simulate the VehicleInterfaces\Examples\SeriesHybrid.mo model, there is an error related to the "r/min" displayUnit (line 10).

I edited the file manually and changed this to "1/min" and it now works for me.

I've no idea whether this is a typo or whether it's a version incompatibility, but hopefully it'll help someone else even if the latter.

tobolar commented 3 years ago

Actually, IMO any common variant of revolutions per minute shall be possible: rpm, r/min, rev/min, see Modelica.Units.NonSI.AngularVelocity_rpm (or https://github.com/modelica/ModelicaStandardLibrary/blob/f095aa0350758431efcc9ff65b436c371de9b1ab/Modelica/Units.mo#L1199). It seems to me being a tool problem. @sjoelund ?

simonpickering commented 3 years ago

@tobolar I'm sure your guess is significantly better than mine as today is the first time I've ever tried to use Modelica "in anger"! :)

I am curious though if you don't mind my asking what may be a basic follow-up question or two (and which aren't directly related to VehicleInterface)?:

I assume that the end of the line you linked to ("Angular velocity in revolutions per minute. Alias unit names that are outside of the SI system: rpm, r/min, rev/min") is an annotation/help entry rather than a definition (which I guess is the unit="rev/min" bit?)

That line does appear in the library in my installation fwiw. I did also do some Googling to try to work out how aliases are defined (and found some documentation on the Maplesoft website which looks very similar but uses "1/min" rather than "rev/min" as the eventual unit for Modelica.Units.NonSI.AngularVelocity_rpm (so that's what I tried.)

Is there somewhere else/some other way that aliases for a given unit are defined? e.g. is "rev" defined somewhere on its own with "r" as an alias?

I'm also a little surprised in hindsight that 1/min (which I used and it seemed to work) can be converted to rad/s which is the native AngularSpeed unit that the engine module expects (I think).

All an interesting learning experience :)

tobolar commented 3 years ago

I assume that the end of the line you linked to ("Angular velocity in revolutions per minute. Alias unit names that are outside of the SI system: rpm, r/min, rev/min") is an annotation/help entry rather than a definition (which I guess is the unit="rev/min" bit?)

Yes. Stating this in MSL makes an impression to me this shall be applicable in any tool. But I don't know if this is the case.

Is there somewhere else/some other way that aliases for a given unit are defined?

As long as I know is this tool specific (e.g. displayunit.mos in Dymola). To be sure, in the case of rpm I would rather use "rev/min" as this is obvious. "1/min" could be, in general, misinterpreted. I will change it in VehicleInterfaces.

You can find some discussion on it here: https://stackoverflow.com/questions/24776407/teaching-modelica-medical-non-si-units