Unit checking (or dimensional analysis) is an important means of model verification:
Units of Measurement in a Modelica Compiler
Question 1: Is unit checking implemented in the current version of Wolfram System Modeler?
(If not, what options are there to achieve it by other means?)
In Modelica units are stored as attributes to variables (e.g. Real( unit = “m/s” ) ) and are usually enabled by modifications of existing basic types with default values for these attributes (e.g. the default unit for the type Real is " ").
Question 2: How to make use of this “meta information” within the model itself:
-
How can I access the unit of some variable?
parameter String referencedUnit = <function of another variable to access its unit> -
How can I assign such a referenced unit to another variable within the runtime of a model? (e.g. I have written a converter function to convert units of time, say from minutes to months, as this is frequently needed in economic or business simulation models where SIunits are rather an exception).
output convertedTime =Real( quantity = "Time", unit = <to be assigned in func-body> )or
input String timeUnitA; // unit of time to convert from input String timeUnitB; //unit of time to convert to output convertedTime = Real( quantity = "Time", unit = timeUnitB )
(All the above will not work for me as different degrees of variability prohibit this: a modification of the unit attribute must be a constant…).
EDIT: I have cross-posted the second part of my question on stack overflow (5363743)


