home *** CD-ROM | disk | FTP | other *** search
- with PHYSICAL_REAL ; use PHYSICAL_REAL ;
-
- package PHYSICAL_UNITS_BASIC is
-
- -- This package specification defines Ada types for physical
- -- quantities. A number of other packages use this package
- -- specification in order to provide a comprehensive dimension
- -- checking and units conversion system.
- --
- -- PHYSICAL QUANTITIES AND THEIR ASSOCIATED DIMENSIONS
- --
- -- Errors can occur in writing equations to solve problems in classical
- --physics. Many of these errors can be prevented by performing a dimensionality
- --check on the equations. All physical quantities have a fundamental dimension
- --that is independent of the units of measurement. The basic physical dimensions
- --are: length, mass, time, electrical charge, temperature and luminous intens-
- --ity.There are a number of systems of units for measuring physical quantities.
- --The MKS system is based on meter, kilogram, second measurement.
- --The CGS system is based on centimeter, gram, second measurement.
- --The English system is based on feet, pound, second measurement.
- --A few physical dimensions and the associated measurement unit in
- --these three systems are :
- --
- --
- -- Physical Quantity Unit System
- -- Dimension MKS CGS English
- --
- -- length meter centimeter feet
- --
- -- mass kilogram gram pound mass
- --
- -- time second second second
- --
- -- force newton dyne poundal
- --
- -- energy joule erg B.t.u.
- --
- --
- -- The checking of a physical equation has two aspects. The first is to check
- --the dimensionality. The dimensionality is independent of the unit system. The
- --second is to check that a consistent system of units is used in the equation.
- -- An example of a dimensionality check is using the basic equation F=ma to
- --determine that force has the dimension mass x length / time squared, then
- -- 2
- --check if F=mv /r is dimensionally correct. The check is performed by
- --expanding the dimensions, e.g. mass x (length/time) x (length/time) / length.
- --with the dimensions expected for force from the basic equation F=ma. As
- --expected, centripetal force has the same dimensionality as the force from
- --Newton's second law of motion.
- --
- -- THE ALGEBRA OF DIMENSIONALITY
- --
- -- The dimension of any physical quantity can be written as
- --
- -- a b c d e f
- -- L M T Q C K
- --
- --where a,b,c,d,e and f are integers such as -4, -3, -2 , -1, 0, 1, 2, 3, 4
- --and L is length, M is mass, T is time, Q is charge, C is luminous intensity
- --and K is temperature. An exponent of zero means the dimension does not apply
- --to the physical quantity. The normal rules of algebra for exponents apply
- --for combining dimensions.
- --
- -- In order to add or subtract two physical quantities the quantities must
- --have the same dimension. The resulting physical quantity has the same
- --dimensions. Physical quantities with the same dimension in different
- --systems of units can be added or subtracted by multiplying one of
- --the quantities by a units conversion factor to obtain compatible units.
- --
- -- The multiplication of two physical quantities results in a new physical
- --quantity that has the sum of the exponents of the dimensions of the initial
- --two quantities.
- --
- -- The division of one physical quantity by another results in a new physical
- --quantity that has the dimension of the exponents of the first quantity minus
- --the exponents of the second quantity.
- --
- -- Taking the square root of a physical quantity results in a new physical
- --quantity having a dimension with exponents half of the initial dimension.
- --
- -- Raising a physical quantity to a power results in a new physical quantity
- --having a dimension with the exponents multiplied by the power.
- --
- -- 2 2 2 2 -2
- -- e.g. v has dimension L/T, v has dimension L /T or L T
- --
- -- The derivative of a physical quantity with respect to another physical
- --quantity results in a new physical quantity with the exponents of the
- --first dimension minus the exponents of the other dimension.
- -- e.g. v has dimension L/T, t has dimension T,
- --
- -- 2
- -- then dv/dt has dimension L/T
- --
- -- The integral of a physical quantity over the range of another physical
- --quantity results in a new physical quantity that has a dimension with the
- --sum of the exponents of the two quantities.
- --
- -- e.g. v has dimension L/T, t has dimension T,
- -- then integral v dt has dimension L/T * T or L
- --
- --
- -- The initial thought was to have metric units and English units
- -- in separate package specifications. This proved inpractical
- -- because time in seconds is both metric and English. Many other
- -- units such as watt of power and Farad of capacitance are in
- -- both systems. A further impracticallity arose when considering
- -- the design of a units system conversion package. e.g. A package
- -- that would provide accurate conversion form meters to inches
- -- to micrometers to light years. The one package specification became
- -- so large that it was inefficient, so, in order to keep the size
- -- reasonable, three packages were created. The basic units, the
- -- mechanical units and the electrical units. Then a package
- -- called other units came into existance for pragmatic reasons.
- --
- -- Notice that there is not a type called LENGTH because
- -- adding length in meters to length in feet is not allowed.
- -- Even LENGTH_METRIC and LENGTH_ENGLISH are not acceptable
- -- because meters can not be added to centimeters and inches can
- -- not be added to feet. Further complication arises because of
- -- seconds of time and seconds of arc. There can be ounces of
- -- milk ( liquid measure ) and ounces of sugar ( weight measure ).
- -- There can be quarts of milk and quarts of strawberries ( dry
- -- measure ). Thus the decision was made that every Ada type
- -- would be a dimension name followed by a unit name.
- --
- -- Now, more choices had to be made. Unit names such as
- -- DENSITY_KILOGRAM_PER_CUBIC_METER or DENSITY_TONS_PER_CUBIC_YARD
- -- start getting long and there are many combinations. The number
- -- of combinations for density are all the units of mass times all
- -- the units of volume. Thus a subset of all possible units was
- -- chosen with the additional short hand notation of _MKS for
- -- the meter, kilogram, second system of units and the _ENGLISH for
- -- the foot, pound, second system. Additional qualifiers are added
- -- to clarify such as VOLUME_QUART_LIQUID and VOLUME_QUART_DRY.
- --
- -- Some other compromises were made:
- -- Only a few units were entered as both singular and plural.
- -- The choice of names is the authors. A committee could expand
- -- the list. For example a meter can be a length or a distance,
- -- length is used as the type and distance is a subtype.
- -- A user may provide additional local subtype names for units
- -- and thus has the full capability for alternate type names.
- --
- -- The comments below are organized to present the physical quantity name with
- --associated information. The second column is one of the typical symbols used
- --for the physical quantity. The third column is the dimension of the physical
- --quantity expressed in terms of the fundamental dimensions. The fourth column
- --is the name of the unit in the MKS measurement system. The fifth column
- --is the typical MKS unit equation. An independent table presents conversion
- --factors from the MKS measurement system to other measurement systems.
- -- Physics developed over a period of many years by many people from a variety
- --of disciplines. Thus, there is ambiguity and duplication of symbols.
- --
- --
- --PHYSICAL QUANTITY SYMBOL DIMENSION MEASUREMENT UNIT UNIT EQUATION
- --_________________ ______ _________ ________________ ______________
- --
- --
- -- BASIC UNITS
- --
- --length s L meter m
- --wave length lambda " " "
- --
- type LENGTH_MKS is new REAL ;
- subtype LENGTH_METER is LENGTH_MKS ;
- subtype LENGTH_METERS is LENGTH_MKS ; -- This could be done for every type
- subtype DISTANCE_METER is LENGTH_MKS ; -- with plurals and alias and
- subtype DISTANCE_METERS is LENGTH_MKS ; -- plurals for the alias
- subtype WAVE_LENGTH_MKS is LENGTH_MKS ;
- subtype WAVE_LENGTH_METER is LENGTH_MKS ;
- type LENGTH_ENGLISH is new REAL ;
- subtype LENGTH_FOOT is LENGTH_ENGLISH ;
- subtype LENGTH_FEET is LENGTH_ENGLISH ;
- type LENGTH_PICOMETER is new REAL ;
- type LENGTH_NANOMETER is new REAL ;
- type LENGTH_MICROMETER is new REAL ;
- type LENGTH_MILLIMETER is new REAL ;
- type LENGTH_CENTIMETER is new REAL ;
- type LENGTH_DECIMETER is new REAL ;
- type LENGTH_DECAMETER is new REAL ;
- type LENGTH_HECTOMETER is new REAL ;
- type LENGTH_KILOMETER is new REAL ;
- type LENGTH_MEGAMETER is new REAL ;
- type LENGTH_GIGAMETER is new REAL ;
- type LENGTH_ANGSTROM is new REAL ;
- type LENGTH_MIL is new REAL ;
- type LENGTH_INCH is new REAL ;
- type LENGTH_YARD is new REAL ;
- type LENGTH_FATHOM is new REAL ;
- type LENGTH_ROD is new REAL ;
- type LENGTH_CHAIN_SURVEYOR is new REAL ;
- type LENGTH_CHAIN_ENGINEER is new REAL ;
- type LENGTH_FURLONG is new REAL ;
- type LENGTH_MILE is new REAL ;
- subtype LENGTH_MILE_STATUTE is LENGTH_MILE ;
- type LENGTH_MILE_NAUTICAL is new REAL ;
- type LENGTH_LEAGUE_LAND is new REAL ;
- type LENGTH_LEAGUE_MARINE is new REAL ;
- type LENGTH_LIGHT_YEAR is new REAL ;
-
- --
- --mass m M kilogram Kg
- --
- type MASS_MKS is new REAL ;
- subtype MASS_KILOGRAM is MASS_MKS ;
- type MASS_ENGLISH is new REAL ;
- subtype MASS_POUND is MASS_ENGLISH ;
- subtype MASS_POUND_AVDP is MASS_ENGLISH ;
- type MASS_POUND_TROY is new REAL ;
- subtype MASS_POUND_APOTHECARY is MASS_POUND_TROY ;
- type MASS_MILLIGRAM is new REAL ;
- type MASS_GRAM is new REAL ;
- type MASS_GRAIN is new REAL ; -- same inall English systems
- type MASS_PENNYWEIGHT_TROY is new REAL ;
- type MASS_CARAT_TROY is new REAL ;
- type MASS_SCRUPLE is new REAL ;
- type MASS_DRAM_AVDP is new REAL ;
- type MASS_OUNCE_AVDP is new REAL ;
- type MASS_OUNCE_TROY is new REAL ;
- type MASS_TON_SHORT is new REAL ;
- type MASS_TON_LONG is new REAL ;
- type MASS_TON_METRIC is new REAL ;
-
- --
- --time t T second sec
- --
- type TIME_SECOND is new REAL ;
- subtype TIME_SECONDS is TIME_SECOND ;
- type TIME_PICOSECOND is new REAL ;
- type TIME_NANOSECOND is new REAL ;
- type TIME_MICROSECOND is new REAL ;
- type TIME_MILLISECOND is new REAL ;
- type TIME_CENTISECOND is new REAL ;
- type TIME_KILOSECOND is new REAL ;
- type TIME_MEGASECOND is new REAL ;
- type TIME_GIGASECOND is new REAL ;
- type TIME_MINUTE is new REAL ;
- type TIME_HOUR is new REAL ;
- type TIME_DAY is new REAL ;
- type TIME_FORTNIGHT is new REAL ;
- type TIME_MONTH is new REAL ;
- type TIME_YEAR is new REAL ;
- type TIME_DECADE is new REAL ;
- type TIME_CENTURY is new REAL ;
- type TIME_MILLENNIA is new REAL ;
-
- --
- --electric charge q Q coulomb c
- -- electric flux
- --
- type CHARGE_COULOMB is new REAL ;
- subtype CHARGE_AMPERE_SECOND is CHARGE_COULOMB ;
- type CHARGE_AMPERE_HOURS is new REAL ;
- type CHARGE_ELECTRON is new REAL ;
- type CHARGE_FARADAY is new REAL ;
-
- --
- --luminous intensity I C candle cd
- --
- type LUMINOUS_INTENSITY_CANDLE is new REAL ;
-
- -- o
- --temperature T K degree kelvin K
- --
- type TEMPERATURE_KELVIN is new real ;
- type TEMPERATURE_CENTIGRADE is new REAL ;
- subtype TEMPERATURE_CELSIUS is TEMPERATURE_CENTIGRADE ;
- type TEMPERATURE_FARENHEIT is new REAL ;
-
- --
- --angle theta none radian none
- --
- type ANGLE_RADIAN is new REAL ;
- subtype ANGLE_RADIANS is ANGLE_RADIAN ;
- subtype PLANE_ANGLE_RADIANS is ANGLE_RADIAN ;
- type ANGLE_SECOND is new REAL ;
- type ANGLE_MINUTE is new REAL ;
- type ANGLE_DEGREE is new REAL ;
- type ANGLE_REVOLUTION is new REAL ;
- type ANGLE_BAM is new REAL ;
-
- --
- --solid angle phi none steradian none
- --
- type SOLID_ANGLE_STERADIAN is new REAL ;
- --
- end PHYSICAL_UNITS_BASIC ;
-