Units Conversion Library

Download: Units conversion library.ana

These functions convert between different units -- for example, from feet to kilometers, or from Btu (British thermal units) to gigajoules of energy. They relieve you from having to look up conversion factors. They also make your model more transparent by making it clear where you are converting from one units to another -- instead of just embedding conversion constants in the formulas.

Units conversion library.png

You can use the Conversion example section to enter a quantity, select its type (dimensions) and units, and convert it to another unit of that type.

Library functions

Units_factor(oldUnits, newUnits) to give a conversion factor between two units. If you omit newUnits, it will assume the standard units for that type (dimensions). The units parameters text values must match an abbreviation, synonym, or full name (case insensitive) in the Units data table. If the units are of different dimensions, e.g. energy and power, or if it doesn't recognize the units, it will give an error.

Units_conversion(x, oldUnits, newUnits) returns the value of quantity x converted from oldUnits to newUnits. This works for units like temperature, where simple factors don't work.

Units_real_dollars(yr, baseYr) returns a multiplication factor used to convert nominal dollars in year yr to real (also known as constant) dollars using baseYr as the base year. If you omit baseYr, it uses the "Standard base year for inflation" which you can set in the Units Conversion Library user interface. It uses consumer price index data provided by the US Energy Information Administration from 1949 to 2017 with projections up to 2040. It gives an error if yr or baseYr are outside that range.

The Units_table contains the list of units, with abbreviation, full-name, and synonyms, type (dimensions) and conversion factors to the base unit for each type. For example, the base unit for 'Energy' is Joule. The conversion factor for gigajoule (GJ) is 10^9. You can add your own units. Be careful to select the correct type (dimensions).


You are not allowed to post comments.