Jump to: navigation, search

The UNITS statement is used to declare new units of measurement derived from the other units, or from the base units that are predefined and associated with each of the physcial dimensions supported in ASCEND.

ASCEND will recognize conversion factors when it sees them as {units}. These units are built up from the basic units, and new units can be defined by the user. Note that the assignment x:= 0.5 {100} yields an x value of 50, and that there is no support in ASCEND for 'offset conversions', such as conversions between Fahrenheit and Celsius (F=9/5*C+32). Please keep unit names to 20 characters or less, as this makes life pretty for other users.

One or more unit conversion factors can be defined with the UNITS keyword. A unit of measure, once defined, stays in the system until the system is shut down. A measuring unit cannot be defined differently without first shutting down the system, but duplicate or equivalent definitions are quietly ignored.

A UNITS declaration can occur in a file by itself, inside a model or inside an atom. UNITS definitions are parsed immediately, they will be processed even if a surrounding MODEL or ATOM definition is rejected. Because units and dimensionality are designed into the deepest levels of the system, a unit definition must be parsed before any atoms or relations use that definition. It is good design practice to keep customized unit definitions in separate files and REQUIRE those files at the beginning of any file that uses them. Unit definitions are made in the form, for example:

   (* several unit definitions are allow here. *)

   (* derived SI units) *)
   ohm = {kg*m^2/s^3/ampere^2};

   (* alternative names *)
   kilogram = {kg}

   (* conversions and non-SI units *)
   MW = {1e6*watt};
   foot = {12*inch};

Be careful to check the permitted units of measurement by search through the file models/measures.a4l.

Constants defined as UNITS

ASCEND uses its units of measurement system to declare a number of commonly-used mathematical and physical constants, too. These are also declared in models/measures.a4l. Examples are

PI= {3.1415926535897932385};         (* Circumference/Diameter ratio *)
LIGHT_C = {2.99793e8 * m/s};         (* Speed of light in vacuum *)
GAS_C = {BOLTZMAN_C*AVOGADRO_C};     (* Gas constant *)
SIGMA_C = {5.670e-8 * W/m^2/K^4 };   (* Stefan-Boltzmann constant for blackbody radiation *)
EARTH_G = {9.80665 * m/s/s};         (* Earth's gravitational field, somewhere *)

The benefit of having these as units rather than as special constants is that you don't need to pollute your variable namespace with these things, and you can also conveniently write values such as

theta IS_A angle;
theta = 0.75{PI*rad};

Q IS_A energy_rate;
Q = 1{SIGMA_C} * A * T^4; (* radiant emissive power *)

See also