Database Management
Reference Manual
Expressions
: Units and Physical Quantity Attributes in Expressions
Units and Physical Quantity Attributes in Expressions
In real expressions the dimension of the result is tracked using:
•
The dimension of any attribute values used (e.g. XLEN, BANG, DENS, GVOL)
•
The unit qualifiers of any values supplied
•
The known result of any function (e.g. ASIN returns an angle, POW, SQRT return a computed dimension, MIN/MAX that of their arguments etc.)
•
The computed result of multiplication and division operation. (e.g. GWEI/GVOL is a density)
•
The need for consistency for addition and subtraction operations
If at any time a value with no dimension occurs where a value with a specific dimension is needed then the value is taken to be one of that dimension in the current working units of that dimension (e.g. mm for distances, degrees for angles). This will occur in addition and subtraction operations, and arguments for typed functions (e.g. trigonometric).
Whenever a clash of physical quantity occurs then either a warning or an error will be raised (e.g. SIN(25inch).
In all expressions and functions physical quantities are tracked and the result, wherever possible is returned in the current units of the resultant physical quantity (dimension). If the system cannot do this (e.g. the expression is not dimensionally sound, or the dimension exceeds the scope which the system can track) then a warning is issued and a simple numeric result is returned.
When a user enters a literal value then the type of physical quantity is not known and the decision as to what it is determined to make it consistent with the context with respect to other values in the expression. When it is finally determined the value is then taken to be in the current units of that quantity. The method of this determination is normally straightforward and is described in specific sections above.
The units for PML variables are also unknown. Where units are known and handled similarly in expression.
To cope with ’unknown’ units each value remembers its original units internally. An attempt is then made to allow for ’unknown’ units across operators and within functions. In general the physical quantity of the result of a function, or expressions, is tracked by the system and the resulting value is one of the resultant physical quantities. For example multiplying 3 distances together gives a result of a volume which will have units such as gallons, litres or cubic ft etc.
On comparison, addition or subtraction of two values then if one has units and the other has none (i.e. not a physical quantity) it is assumed to be the same sort of quantity as the other, and in the current units of that quantity.
For example:
(XLEN GT 10).
If we are working in distance units of inches, it is known that XLEN is a distance value. Internally the value is held in mm, but the units are held as INCH. The units for ’10’ are held as unknown. On doing the comparison, the ’10’ is assumed to be inches and thus multiplied by 25.4 to make sure that the comparison works as expected.
Special action is also taken to preserve the correct units across multiplication, division, POWER and SQRT, as described in the sections above.
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.