<<

Maple 9.5 Application Paper

Units and Dimensional Management

Maple provides the most comprehensive package in the software industry for managing units and dimensions. Problems in science and engineering can now be fully managed with appropriate dimensions in any modern unit system (and even some historical systems!), including MKS, FPS, CGS, Atomic and more. Over 500 standard units are recognized by Maple's Units package. A convenient dialog box located in the Edit menu converts quantities between unit systems automatically.

The Units package offers far more than simple conversions between units of various systems. It preserves the user's chosen units throughout complex computations. It knows the base dimensions of all standard quantities measured in science and engineering. Users also have the option to create their own units and dimensions.

The following techniques are highlighted:

• Different unit systems, for example SI, CGS, MKS, FPS, etc. • Definition of new unit systems • Solving problems involving unit Units and Dimensional Management © Maplesoft, a division of Waterloo Maple Inc., 2004 The intent of this application example is to illustrate Maple techniques in a real world application context. Maple is a general-purpose environment capable of solving problems in any field that depends on mathematics and data. This application illustrates one possibility for this particular field. Note that there are many options within the Maple system to optimize the computations for specific problems.

Introduction

Maple provides the most comprehensive package in the software industry for managing units and dimensions. Problems in science and engineering can now be fully managed with appropriate dimensions in any modern unit system (and even some historical systems!), including MKS, FPS, CGS, Atomic and more. Over 500 standard units are recognized by Maple's Units package. A convenient dialog box located in the Edit menu converts quantities between unit systems automatically.

The Units package offers far more than simple conversions between units of various systems. It preserves the user's chosen units throughout complex computations. It knows the base dimensions of all standard quantities measured in science and engineering. Users also have the option to create their own units and dimensions.

The following techniques are highlighted:

· Different unit systems, for example SI, CGS, MKS, FPS, etc. · Definition of new unit systems · Solving problems involving unit Initialization

> restart: interface(warnlevel=0): interface(displayprecision=4): with(Units): with(Units[Natural]): Overview of the Units Package

The Natural option tells Maple that the unit variables will be expressed as ordinary variables without special notation. Consequently, one should take care not to create a new user variable called km, or miles, etc. There is an option to work in a "protected" mode where such ambiguity is prevented. Some simple examples

Consider the following definition for a length. Notice that Maple casts the answer in meters [m]. SI is the default unit system used by the Units package. > myDist := 4*ft + 3*inches; 6477 myDist := []m 5000

You can easily express the above in standard US (FPS - Foot ) system using the convert command > convert( myDist, system, FPS); evalf( % ); 17 []ft 4

4.250000000 [ ft ] kg m The Units package knows that a is a s2 > myForce := 5*g * 3 * m/s^2; 3 myForce := []N 200

Maple is smart enough to understand when units conflict -- for example, adding a length (ft) to a mass (kg) does not make sense, and Maple returns an error if the user tries to do so. Which units systems and dimensions does the Units package know?

The 8 standard unit systems recognized by the Units package. > GetSystems(); Atomic , CGS, EMU, ESU, FPS, MKS, MTS, SI

The Units package also knows the dimensions of all standard quantities, for example area, frequency, torque, etc. > GetDimension( area ); GetDimension( frequency ); GetDimension( torque ); 2 length 1 time mass length length( radius )

time 2 You can ask Maple to list the base quantities the Units package knows. > GetDimensions(); absorbed_dose , acceleration , action , amount_of_information , amount_of_substance , angular_acceleration,angular_jerk,angular_speed,area,,currency dose_equivalent,dynamic_viscosity,electric_capacitance,,electric_charge electric_conductance,electric_current,,electric_dipole_moment electric_displacement,electric_field_strength,,electric_permittivity electric_polarizability , electric_potential , electric_resistance , electric_resistivity , energy,,,frequency,heat_capacity,,heat_insulation_coefficient heat_transfer_coefficient,,jerk,kinematic_viscosity,,length linear_frequency,linear_mass_density,logarithmic_gain,,luminous_flux luminous_intensity,luminous_luminance,,magnetic_dipole_moment magnetic_flux , magnetic_flux_density , magnetic_inductance , magnetic_permeability,magnetic_polarizability,magnetizing_force,,mass mass_density,molar_electric_charge,moment_of_inertia,,momentum plane_angle,power,,solid_angle,specific_heat_capacity,,speed surface_energy_density,surface_power_density,,thermal_conductivity

thermodynamic_temperature , time, torque , volume, volume_flow

What units does the Units package recognize? Specifiy the dimension, in this case "force", and you can find out using the GetUnits function. > GetUnits( dimension=force ); dynestandard, gramforce standard, kipf standard, newtonSI, ounceforce standard, pond standard,

standard,poundforce standard,,sthene standard tonforce standard

Here are all 569 units known by the package > GetUnits(); British_thermal_unit 39degF, British_thermal_unit 59degF, British_thermal_unit 60degF,

British_thermal_unit IT,British_thermal_unit mean,,British_thermal_unit thermochemical

Calorie 15degC,Calorie 20degC,Calorie IT,Calorie mean,,Calorie thermochemical

Celsius_heat_unit 15degC,Celsius_heat_unit 20degC,,Celsius_heat_unit IT

Celsius_heat_unit mean, Celsius_heat_unit thermochemical , Hefner_unit standard, Q_unit IT,

Q_unit US,Q_unit mean,Q_unit thermochemical ,Rvalue SI,Rvalue standard,,Ufactor SI

Ufactor standard, EMU,abbestandard,abcoulomb EMU,abfarad EMU,, EMU

EMU,absiemens EMU,abtesla EMU, EMU,abwattEMU,,abweber EMU

acceleration_of_free_fall standard, acreUS_survey, acrestandard, ampere SI, angstrom standard,

standard,areSI,arpent PQ_area,arpent PQ_length,,astronomical_unit standard

atmosphere standard,atmosphere technical,atomic_mass_unit SI,barSI,,barge US_petroleum

barleycorn US_survey,barleycorn standard,barn SI,barrel UK,barrel UK_petroleum,,barrel US_dry barrel US_liquid , barrel US_petroleum, barrel beer, barrel bulk, barrique wine, baryestandard,

bath Sacred,bath Talmudic,becquerel SI,bekaSacred,bekaTalmudic,belstandard,,belshazzar metric bicron standard,biennium Gregorian,biennium tropical,biot standard,,bit information bit_per_scond information ,blink standard,blockinformation ,bohr Atomic,,bottle metric

brewster standard, bucket UK, bucket US_liquid , bushel UK, bushel US_dry, bushel US_dry_heaped,

butt UK,butt beer,byteinformation ,cabSacred,cabTalmudic,cableUK_nautical ,,cableUS_nautical calibre standard,calorie 15degC,calorie 20degC,calorie IT,calorie mean,,calorie nutrition calorie thermochemical , SI,candle international ,candle standard,carat diamond,,carat metric

carcel standard, cental avoirdupois , centare SI, century Gregorian, century tropical, chain Gunter,

chain Gunter_US_survey,chain Ramsden,chain Ramsden_US_survey,chain UK_nautical,,circle angle

clostandard,cloveavoirdupois ,coombe UK,coombe US_dry,corSacred,corTalmudic,,cordUK

SI,crith standard,crumb information ,cubic_foot_per_minute standard,,cubit Sacred

cubit Talmudic, cubit US_survey, cubit standard, cupUK, cupUS_liquid , curie radiation , dalton standard,

darcystandard,dash US_liquid ,daySI,daysidereal,debyestandard,decade Gregorian,,decade tropical degree Celsius,degree Fahrenheit,degree Rankine,degree Reaumur,degree angle,,degree centigrade

denier standard,dessertspoon UK,dessertspoon US_liquid ,digit US_survey,,digit standard

diopter standard, dollar US, donkeypower standard, double_word information , dozen Baker,

dozen standard,drachm UK,drachm US_liquid ,drachm apothecary,drachm avoirdupois ,,drexstandard

drop UK,drop US_liquid ,dynestandard,electron Atomic,electron_mass Atomic,,electronvolt SI

ellUS_survey,ellstandard,eontropical,ephah Sacred,ephah Talmudic,ergstandard,,farad SI

faraday carbon12, faraday chemical, faraday physical, fathom US_survey, fathom standard,

fermi standard,fifth US_liquid ,finger US_survey,finger standard,firkin beer,foot PQ,,foot US_survey

foot standard,foot_mercury 32degF,foot_mercury 60degF,,foot_mercury standard

foot_water 39.2degF,foot_water standard,footcandle standard,,footlambert standard

fortnight standard, franklin standard, fresnel standard, furlong US_survey, furlong standard,

galstandard,gallon UK,gallon US_dry,gallon US_liquid ,gallon beer,,gallon old_CA gallon_per_minute UK,gallon_per_minute US_dry,gallon_per_minute US_liquid ,,gmetric

gstandard, standard,gawbleinformation ,gerah Sacred,gerah Talmudic, standard,,gill UK

gill US_liquid , gonangle, grade angle, grain apothecary, grain avoirdupois , grain metric, grain troy,

SI,gramforce standard,graySI,hand US_survey,hand standard,,handbreadth Sacred

handbreadth Talmudic,hartree Atomic,hectare SI,hemisphere angle,henrySI,,hertz SI

hin Sacred,hin Talmudic,hogshead UK,hogshead beer,horsepower UK,,horsepower boiler horsepower electric, horsepower metric, horsepower water, hour SI, hour angle, hour sidereal,

hubble Julian,hubble tropcial,hundredweight long,,hundredweight metric

hundredweight short,hylstandard,inch US_survey,inch standard,,inch_mercury 32degF

inch_mercury 60degF,inch_mercury standard,inch_water 39.2degF,,inch_water standard

janskystandard, jarstandard, jeroboam metric, jouleSI, jupiter standard, katal SI, kayser standard,

SI,kip avoirdupois ,kipf standard,kipf_per_square_inch standard,kitten waterloo,,knotSI

kynestandard,lVolume, standard,langley energy,langley power,last UK,,last US_dry

league US_survey,league nautical,league standard,lethech Sacred,,lethech Talmudic

light_year Julian, light_year tropical, line US_survey, line standard, link Gunter, link Gunter_US_survey,

link Ramsden,link Ramsden_US_survey,liter SI,logSacred,logTalmudic,lotUS_survey,,lotstandard SI,lunelunar,lunour lunar,luxSI,machstandard,magnum metric,,mancus standard marathon standard,mast standard, standard,methusalah metric,,meterSI

meter_mercury 0degC, meter_mercury standard, meter_water 4degC, meter_water standard,

microinch standard,micron standard,mil US_survey,mil angle,,mil circular mil military ,,mil standard

mile US_survey,mile nautical,mile standard,mile_per_gallon UK,,mile_per_gallon US_liquid

mile_per_hour standard,millennium Gregorian,millennium tropical,,millier standard

mina Sacred, mina Talmudic, minute SI, minute angle, minute sidereal, mite standard, moleSI,

month anomalistic ,month lunar,month nodical,month sidereal,nail US_survey,,nail standard

nautical_mile SI,nebuchadnezzar metric,neperSI,newtonSI,,nibble information

nickle information ,nit standard,noxstandard, standard,ohmSI,omerSacred,,omerTalmudic

ounce UK, ounce US_liquid , ounce apothecary, ounce avoirdupois , ounce troy, ounceforce standard,

paceUS_survey,pacestandard,palm US_survey,palm standard,parsec standard,,part_per_billion EU

part_per_billion US,part_per_million standard, SI,peckUK,,peckUS_dry pennyweight troy,pentad standard,perchPQ_area,perch PQ_length,perchUS_survey,,perch standard

perm0degC, perm23degC, permittivity Atomic, standard, pica TeX, pica computer, pica printer,

pied_measure_planche standard,pieze standard,pim Sacred,pim Talmudic,,pin beer

pinch US_liquid ,pint UK,pint US_dry,pint US_liquid ,planck Atomic,planck standard,,point TeX

point angle,point computer,point printer, standard,poleUS_survey,,polestandard

poncelet standard, pond standard, pottle UK, pottle US_dry, pottle US_liquid , pound apothecary,

pound avoirdupois ,pound merchant,pound troy,,pound_per_square_foot standard

pound_per_square_inch standard,poundal standard,poundforce standard,,preeceresistance

preeceresistivity ,puncheon beer,quad IT,quad US,quad mean,,quad thermochemical quadrant angle, quadrant electrical, quadrant standard, quadrennium Gregorian,

quadrennium tropical,quart UK,quart US_dry,quart US_liquid ,,quarter avoirdupois

quinquennium Gregorian,quinquennium tropical,quintal avoirdupois ,quintal metric,,radradiation

radian SI,rehoboam metric,remradiation ,revolution angle,,revolution_per_minute angle

reynstandard, rhestandard, rodUS_survey, rodstandard, roentgen radiation , rood US_survey,

rood standard,rutherford radiation ,rutherford standard,sackUK,sackUS_dry,,salmarazd metric

scruple apothecary,seahSacred,seahTalmudic,seamUK,seamUS_dry,second Atomic,,second SI

second angle,second sidereal,section US_survey,section standard,semicircle angle,,shakestandard

shedstandard, shekel Sacred, shekel Talmudic, siemens SI, sievert SI, sign angle, skotstandard,

metric,slug standard,span Sacred,span Talmudic,span US_survey,span standard,,spat standard

sphere angle,statampere ESU, ESU,statfarad ESU,stathenry ESU,, ESU

statsiemens ESU,stattesla ESU, ESU,statwatt ESU,statweber ESU,,stepUS_survey

stepstandard, steradian SI, sterestandard, sthene standard, standard, stokes standard,

stone avoirdupois ,strike UK,strike US_dry,strontium_unit standard,,svedberg standard

tablespoon AU,tablespoon UK,tablespoon US_liquid ,talbot standard,,talent Sacred

talent Talmudic,teaspoon UK,teaspoon US_liquid ,tesla Atomic,tesla SI,texstandard,,therm EU

therm IT, therm US, therm mean, therm thermochemical , togstandard, tonTNT, tonassay, tonfreight,

tonlong,tonlong_assay,tonmetric,tonpetroleum,tonrefrigeration ,tonregister,,tonshort

tonforce standard,tonne SI, standard,township US_survey,,township standard

triennium Gregorian,triennium tropical,tsubo JP,tunbeer,unit_pole standard,,vacstandard

voltAtomic, voltSI, wattSI, watt_hour standard, weberSI, weekstandard, weyavoirdupois ,

winkstandard,wordinformation ,x_unit copper,x_unit molybdenum,yardUS_survey,,yardstandard

yearGregorian,yearJulian,yearOrthodox,yearanomalistic ,yearellipse,yeargalactic,,yearleap

yearmean,yearsidereal,,yearstandard yeartropical

Adding your own units

You can extend the set of units recognized by the Units package. In this example, we use the Units package to encapsulate the following information about army groups:

1 platoon = 24 soldiers 1 company = 3 platoons 1 battalion = 3 companies 1 brigade = 3 battalions 1 division = 3 brigades 1 corps = 3 divisions We reinitialize the Units environment. > restart: with(Units): Define the army groups as units. > AddBaseUnit(soldier, context = military, dimension = humanlife, spellings = soldiers); AddUnit(platoon, context = military, conversion = 24 * soldier, spellings = platoons); AdddUnit(company, context = military, conversion = 3 * platoon, spellings = companies); AddUnit(battalion, context = military, conversion = 3 * company, spellings = battalions); AddUnit(brigade, context = military, conversion = 3 * battalion, spellings = brigades); AddUnit(corps, context = military, conversion = 3 * brigade, spellings = corps);

Now we add the "military" system to the 8 systems already recognized by the package. > AddSystem(military, check, soldier); with(Units[Natural]): UseSystem( military ): How many soldiers are in 5 battalions? > convert(5*battalion, units, soldier); 1080 [ soldier ] After a fierce battle, your fighting are down to 2 corps and a half-strength company. How many soldiers do you have left? > 2*corps + (1/2)*company; 3924 [ soldier ] How many platoons is that? > evalf[4](convert(%, units, platoon)); 163.5 [ platoon ]

Example Problems Involving Units

Reinitialize > restart; with(Units[Natural]): with (ScientificConstants): How much room does 1 billion dollars worth of gold take up? First, define the dollar value of the gold, cost per troy ounce (assume $268), and the density. > val := 10^9 * USD; costPerOz := 268.00 * USD/oz[troy]; density := 19.3 * g/cm^3; val := 1000000000 [ USD ] é USD ù costPerOz := 8616.400080 ê ú ë kg û é kg ù density := 19300.00000 ê ú ê 3 ú ë m û The resulting mass and volume are: > mass := val/costPerOz; volume := mass/density; mass := 116057.7493 [ kg ] 3 volume := 6.013354886[]m What is the length of one side of a cube having this volume? > length_side := root[3](volume); length_side := 1.818467785 [ m ]

What is the sin of 45 degrees? Users might initially try the following (which is incorrect): > evalf(sin(45)); 0.8509035245 The correct but tedious way without the Units package. > evalf(sin((Pi/180)*45)); 0.7071067810 With Maple's Units package, you can simply state 45*degrees, and functions will understand how to manage the information. This one example will likely save many a high school student at least 20 minutes of grief. > evalf(sin(45*degrees)); 0.7071067810

How many in 3 weeks? > t := 3 * week; t := 3 [ wk] > convert( t, units, s); 1814400 [ s ]

How far do you travel in 35 minutes going 55 miles per hour? Express answer in meters and miles. > d := 55*mph * 35*minutes; 1290828 d := []m 25 > convert( d, units, mi ); 385 []mi 12 > evalf( d ); 51633.12000 [ m ]

Given a molar energy, find the mass energy in Btu's per pound. > molar_energy := 523.432*Btu/mol(carbon); é J ù molar_energy := 551880.6676 ê ú ë mol()carbon û > carbon_mass := 12*kg/mol(carbon); é kg ù carbon_mass := 12 ê ú ë mol()carbon û > mass_energy := molar_energy / carbon_mass; é m2 ù mass_energy := 45990.05563 ê ú ê 2 ú ë s û > convert(%, units, 'Btu/lb'); é Btu ù 19.78539678 ê ú ë lb û

Given a torque of 3 newton meters, how much energy is required to move a lever through 10 degrees? > energy := torque * angle; energy := torque angle > eval(energy, [torque = 3*N*m(radius), angle = 10*deg]); 1 p []J 6 > evalf(%); 0.5235987758 [ J ]

What is the force of gravity on a space vehicle What is the gravitational force on a 500lb satellite orbiting 100 miles above ground.

We have the following definitions: m1 mass of satellite m2 mass of earth G gravitational constant height height of the satellite radius radius of earth (given as: 25000*5280 feet is the circumference of earth)

> m1 := 100*lb; m2 := 6.0*10^24*kg; G_const := Constant (G, units); height := 100*mile; radius := 25000*5280*ft/(2*Pi); m1 := 100 [ lb ] 25 m2 := 0.600000000010 []kg é m3 ù G_const := Constant ()G ê ú SI ê 2ú ë kgs û height := 100 [ mi ] [ ft ] radius := 66000000 p Distance from the center of mass of the satellite to the center of mass of earth. > dist := radius+height; æ 20116800 804672 ö dist := ç + ÷ []m è p 5 ø > Force := simplify (G_const*m1*m2/dist^2); Force := 421.4633896 [ N ]

What is the energy of an electron? > mass := 9.11e-31 * kg; c := 3.00e8 * m/s; E := mass * c^2; -30 mass := 0.91110 []kg

9 é m ù c := 0.30010 ê ú ë s û -13 E := 0.8199000010 []J

For a given phenomena with a frequency of 1.42... GHz, what are: 1. The period, 2. The number of cycles per year, and 3. The number of cycles since the beginning of the earth > frequency := 1.420405761 * GHz; frequency := 1.420405761 [ GHz ] The period in seconds and nano seconds. > 1/frequency; convert(%, units, nanoseconds); -9 0.704024179210 []s 0.7040241792 [ ns ] Cycles per year: > convert(frequency, units, '1/yr'); 17 é 1 ù 0.448236383810 ê ú ë yr û

Given inductance and capacitance, find the resistance in microohms. > resistance := sqrt(inductance / capacitance); inductance resistance := capacitance > eval(resistance, [inductance = 124.*nH, capacitance = 3.52 * uF]): evalf(%); 0.1876892984 [ W] > convert(%, units, uOmega); 187689.2984 [ uOmega ]

Given an power gain from 332 microwatts to 23 milliwatts, what is the gain in decibels? What would the gain have been had the increase had been a voltage increase? Current gain. > gain := 23*mW / (332*uW(base)); 5750 é W ù gain := ê ú 83 ë W()base û > convert(ln (gain), units, dB): evalf (%); 18.40589752 [ dB ] Voltage gain. > voltage_gain := 23*mV / (332*uV(base)); 5750 é V ù voltage_gain := ê ú 83 ë V()base û > convert(ln(voltage_gain), units, dB): evalf (%); 36.81179504 [ dB ]

For further assistance with this application or, additional information on Maplesoft products, please contact [email protected].

Corporate Headquarters European Office Maplesoft, Waterloo, Canada Maplesoft Europe GmbH, Zug, Switzerland t. 519.747.2373 | f. 519.747.5284 t. +41 (0)41 763 33 11 800.267.6583 (US & Canada) f. +41 (0)41 763 33 15 [email protected] [email protected]

www.maplesoft.com | www.mapleapps.com | www.mapleprimes.com

© Maplesoft, a division of Waterloo Maple Inc., 2004. Maplesoft and Maple are trademarks of Waterloo Maple Inc. All other trademarks are property of their respective owners.