GeMA
The GeMA main application
Working with units

Introduction

GeMA uses the Udunits package for unit conversions. The set of available units is extensive. Most common units are accepted, including common unit multipliers. Since conversions are done by decomposing each unit into their SI equivalents, any combination of known units is also acceptable.

Whenever a data set (state variables, attributes or proeperties) is created, the unit in which its data will be stored can be specified in the GeMA model. Data units can also be given for physics parameters and most other quantities in the model. If this is done, automatic conversions will take place whenever a calculation needs that data in another compatible unit.

When units are correctly specified, even if a physics is expecting some data in meters and the input is in feets, conversions will take place automatically. Everything will work even if different sets of data in the model are in different incompatible units, like, for example, giving mesh coordinates in inches and a conductivity value in W/(m.K).

Important tips

When defining a unit the following points should be observed:

  • Be careful with the case. Upper case 'K' means Kelvin while lower case 'k' means kilo.
  • When multiplying units, remember to use either a dot or an asterisk (. or *): 'mK' means milli-Kelvin while 'm.K' or 'm*K' means meter times Kelvin.
  • Powers don't need to use the '^' character, so both 'm2' and 'm^2' mean square meters.
  • When your denominator has several units, make sure it's surrounded by parentheses. The correct unit for conductivity, for example, is 'W/(m.K)' and not 'W/m.K'.
  • Common unit names for temperature are: 'degC', 'degF' and 'K'.
  • Units for angles are 'rad' and 'degree'.
  • When working with dimensionless numbers, it is often usefull to convert them between normalized values (between 0.0 an 1.0) and percentage. While the later unit can be expressed as '%', the previous can be obtained with a trick like 'V/V' (in reality, any valid unit symbol can be used, but V/V "looks like" volume divided by volume and feels better), and thus permitting the correct conversions.

Unit conversions

When working with units, GeMA will always take into consideration the unit in which the data is stored and the unit in which it is being requested. If both are the same, no conversion is ever needed. Otherwise, the following rules apply:

  • If the data unit is empty or the requested unit is empty, no conversion is done and the stored data is returned.
  • If both have a unit and they are compatible (there is a conversion factor between them), the conversion is made and the converted result is returned. Otherwise an error is returned.
  • Unknown units are compatible only with empty units.

Unit conversions that include a scale offset (like temperature conversions) are handled correctly, even when present in compound units, so 10 degrees Celsius will be converted to 283.15 Kelvin, while 10 degC/m will be converted to 10 K/m.

Adding new units

Adding new units can be done by updating the set of ".xml" files in the "config" directory that can be found on the same folder as the GeMA executable. Another option is to create a copy of those files on another directory, update them, and change the unitsDir variable on the defaultConfig.lua file (or in a user config file) to point to the new directory. Refer to the documentation on the Configuration options page for changing the configuration file.