[ Construction of Engineering Quantities ]
[ Systems of Units ]
[ Quantity Constants and Variables ]
[ Printing a Quantity ]
[ Casting Quantity Output ]
[ Temperature ]
[ Forces and Pressure ]
[ Energy and Work ]
[ Plane Angle ]
[ Making a Quantity Dimensionless ]
ALADDIN makes extensive use of units as a means of clarifying matrix and finite element problem descriptions, and program output.
In ALADDIN, an engineering quantity is simply a numerical value followed by a set of units. The syntax for defining an engineering quantity is
number units
Here number is an integer or floating point number (e.g. 3, 3.0 or -3.1415926), and units
units = [Length]^a . [Mass]^b . [Time]^c . [Temp]^d
is a product of primary length, mass, time, and temperature units. The coefficients a, b, c, and d are exponents.
The multiply, divide, and exponentiation operators (i.e. *, * and ^) are used to build sets of units that are combinations of primary units.
Example 1 : The three statements
100 m^2; 2 m/sec; 2 kg*m^2;
define from left-to-right, an area 100 meters squared, a velocity of 2 meters per second, and a mass moment of inertia of 2 kilograms meters squared.
SI System of Units : The primary units for the SI system are:
SYSTEM BASIC UNIT SYMBOL EXAMPLE ===================================================================== SI Length : meter m 2.3 m; kilometer km 0.023 km; centimeter cm 100 cm; millimeter mm 1500 mm; Mass : kilogram kg 1000 kg; gram g 1500 g; megagram Mg 1 Mg; Time : second sec 10.0 sec; millisecond ms 500 ms; minute min 60 min; hour hr 1 hr; Temperature : centigrade deg_C 100 deg_C;
US System of Units : The primary units for the US system are:
SYSTEM BASIC UNIT SYMBOL EXAMPLE ===================================================================== US Length : inch in 12 in; foot ft 1 ft; yard yard 80 yard; mile mile 1 mile; Mass : pound lb 2240 lb; Time : second sec 10.0 sec; millisecond ms 500 ms; minute min 60 min; hour hr 1 hr; Temperature : fahrenheit deg_F
Supplementary Systems of Units : Planar angles measured in radians and degrees are supplementary units, and ALADDIN 2.0 will deal with them in a consistent way.
SYSTEM SUPPLEMENTARY UNIT SYMBOL EXAMPLE ===================================================================== US and SI Planar Angle : radian rad 2*PI rad; degree deg 360.0 deg;
Note : ALADDIN stores engineering quantities as unscaled values with respect to a set of reference units. By default, all quantities are stored internally in the SI system of units.
A quantity constant is simply a number followed by a set of units.
Example 2 : The statement
2 m
defines the quantity constant two meters.
A quantity variable is simply a quantity constant assigned to a variable name.
Example 3 : The statement
xAccel = 2 m/sec/sec;
assigns acceleration 2 m/sec^2 to the variable xAccel.
Note : Like most programming languages, the ALADDIN language has keywords and constants whose names are reserved for a special purposes -- keyword and constant names should not be used for variable names.
Basic output of quantity constants and quantity variables is handled by the print function.
Example 4 : The statement
print "The x coordinate is ", 2 m, "\n";
generates the output
The x coordinate is 2 m
In Version 1.0 of ALADDIN, the numerical component of a physical quantity will be written in the format 10.4g (this is a C programming convention). Roughly speaking, the g conversion specification will print a quantity as an integer when at all possible. Otherwise, the quantity will be printed as a floating point number, and if needed, in exponential format. Here are some examples:
Example 5 : The statement
print "Acceleration due to gravity is ", 32.2 ft/sec/sec , "\n";
generates the output
Acceleration due to gravity is 32.2 ft/sec^2
The command option
quantity ( < units > )
enables the printing of quantities with a desired scaling of units.
Example 6 : The script of code:
x = 30.5 m; print "distance = ", x (ft), "\n";
generates the output:
distance = 100.1 ft
Example 7 : The script of code:
gravity = 9.81 m/sec^2; print "gravity = ", gravity (ft/sec/sec), "\n";
generates the output:
gravity = 32.19 ft/sec/sec
Temperatures may be stored and manipulated in the SI and US systems of units.
SYSTEM BASIC UNIT SYMBOL EXAMPLE ============================================================ SI Centigrade deg_C 32 deg_C; US Fahreheit deg_F 32 deg_F;
Example 8 : The statements
AverageTemp = 10 deg_C; print "Average Daily Temperature = ", AverageTemp, "\n"; print "Average Daily Temperature = ", AverageTemp (deg_F), "\n";
generate the output
Average Daily Temperature = 10 deg_C Average Daily Temperature = 50 deg_F
Example 9 : The statements
uniform_load = 40 N/m; pressure_load = 20 kPa; print "SI Units : Uniform loading = ", uniform_load, "\n"; print " Presure loading = ", pressure_load, "\n"; print "US Units : Uniform loading = ", uniform_load (lbf/ft), "\n"; print " Presure loading = ", pressure_load (psi), "\n"
generate the output
SI Units : Uniform loading = 40 N/m Presure loading = 20 kPa US Units : Uniform loading = 2.741 lbf/ft Presure loading = 2.901 psi
Note : Text in this section applies to ALADDIN 2.0 (scheduled for release in July 1997).
In engineering terms, "work" is the dot product of a force moving through a distance.
SYSTEM BASIC UNIT SYMBOL EXAMPLE ============================================================ SI Joule Jou 100 Jou;
Example 10 : In this example we compute the potential energy and kinetic energy of a mass-spring system. The script of input:
distance = 2 cm; stiffness = 20 N/cm; velocity = 1 m/sec; mass = 3 kg; print "Potential Energy = ", 1/2*stiffness*distance^2 (Jou), "\n"; print "Kinetic Energy = ", 1/2*mass*velocity^2 (Jou), "\n";
generate the output
Potential Energy = 0.4 Jou Kinetic Energy = 1.5 Jou
Units of N.m are compatible with Jou.
Note : Text in this section applies to ALADDIN 2.0 (scheduled for release in July 1997).
Planar angles are measured in units of radians and degrees.
Example 11 : The statements
w = 0.5*PI rad/sec; print "Circular Freq = ", w, "\n"; print "Circular Freq = ", w (deg/sec), "\n"; print "Period = ", (2*PI rad)/w, "\n"
generate the output
Circular Freq = 1.571 rad/sec Circular Freq = 90 deg/sec Period = 4 sec
In the development of algorithms to solve engineering problems, sometimes it is necessary to remove the units from a physical quantity. That is why ALADDIN has a built in function QDimenLess() which removes units from quantities, as demonstrated by the following:
Example 12 : The script of code:
print "MAKE A QUANTITY DIMENSIONLESS \n"; x = 1 N; y = 1 cm/sec; z = QDimenLess(x); u = QDimenLess(y); print "x (with dimen) = ", x,"\n"; print "y (with dimen) = ", y,"\n"; print "x (without dimen) = ", z,"\n"; print "y (without dimen) = ", u,"\n";
generates the output:
MAKE A QUANTITY DIMENSIONLESS x (with dimen) = 1 N y (with dimen) = 0.01 m/sec x (without dimen) = 1 y (without dimen) = 0.01