Details of Units Package Commands - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Science and Engineering : Units : Details : Units/Commands

Details of Units Package Commands

Description

• 

In addition to converting values from one unit to another, the Units package also provides commands that allow you to manage and create entire systems of units.

AddBaseUnit

add a base unit and associated base dimension

AddDimension

add or rename a dimension

AddSystem

add or modify a system of units

AddUnit

add or modify a unit

GetDimension

return dimension as a product of powers of base dimensions

GetDimensions

list all dimensions

GetSystem

list units in a system of units

GetSystems

list all systems of units

GetUnit

get unit information

GetUnits

list all unit names

HasDimension

test whether a dimension exists

HasSystem

test whether a system of units exists

HasUnit

test whether a unit exists

RemoveDimension

remove a dimension

RemoveSystem

remove a system of units

Unit

return argument as a unit in standard form

UseContexts

set default context(s)

UseSystem

set the default system of units

UseUnit

set the default unit for one dimension

UsingContexts

list the default unit contexts

UsingSystem

return the default system of units

  

To display the help page for a particular command, click the corresponding hyperlink.

Command Details

Managing Systems of Units

• 

A system of units is made up of a set of dimensions, with units used to represent those dimensions. To see the dimensions available in the Units package, use the GetDimensions command.

with(Units):

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,exposure,force,frequency,heat_capacity,heat_insulation_coefficient,heat_transfer_coefficient,illuminance,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,pressure,solid_angle,specific_heat_capacity,speed,surface_energy_density,surface_power_density,thermal_conductivity,thermodynamic_temperature,time,torque,volume,volume_flow

(1)
• 

Most of these dimensions are complex dimensions, products of powers of base dimensions.  To see the dimensions used to derive a complex dimension, for example force, use the GetDimension command.

GetDimension('force');

masslengthtime2

(2)
• 

To list the units available to represent force, use the GetUnits command.

GetUnits('dimension'='force');

dynestandard,gramforcestandard,spellings_set:-kipfstandard,newtonSI,ounceforcestandard,planck_forceplanck,pondstandard,poundalstandard,poundforcestandard,spellings_set:-sthenestandard,tonforcestandard

(3)
  

Other optional arguments available for filtering the list of units are described in the GetUnits help page.

• 

For complete information describing a specific unit, use the GetUnit command.

GetUnit('newton');

newton,context=SI,default=false,conversion=1000metreSIgramSIsecondSI2,prefix=SI,symbol=N,symbols=N,spelling=newton,plural=newtons,spellings=newton,newtons,abbreviation=none,abbreviations=

(4)
• 

To attach a unit to a value, use the Unit constructor with either a unit's symbol or any of its spellings. Products of units can also be used. Note that units are automatically converted within the Unit command but not across operations.

  

Note: In Maple 2015 and later versions, units are not surrounded by double brackets.

4*Unit('N');

4N

(5)

8*Unit('N'*'m');

8Nm

(6)

combine(8*Unit('N'*'m'), 'units');

8J

(7)

4*Unit('N') * 2*Unit('m');

8Nm

(8)
• 

To include units in expressions, and convert automatically to the default unit in the current system of units, use either the Natural or Standard environment. The UsingSystem command returns the current system of units. For a list of all the units in that system, use the GetSystem command.

with(Units[Standard]):

UsingSystem();

SI

(9)

GetSystem((9));

secondSI,faradcontexts:-SI,steradiancontexts:-SI,henrycontexts:-SI,candelacontexts:-SI,voltSI,pascalcontexts:-SI,joulecontexts:-SI,molecontexts:-SI,lumencontexts:-SI,coulombcontexts:-SI,wattcontexts:-SI,radiancontexts:-SI,kilogramcontexts:-SI,amperecontexts:-SI,teslaSI,kelvincontexts:-SI,newtoncontexts:-SI,siemenscontexts:-SI,metercontexts:-SI,webercontexts:-SI,nepercontexts:-SI,ohmcontexts:-SI,luxcontexts:-SI,dollarcontexts:-US

(10)

4*Unit('N') * 2*Unit('m');

8J

(11)
• 

For a list of all available systems of units, use the GetSystems command. To set the current system of units, use the UseSystem command.

GetSystems();

Atomic,CGS,EMU,ESU,FPS,MKS,MTS,SI

(12)

UseSystem('FPS');

4*Unit('N') * 2*Unit('m');

12500000000000006584392202157poundalfoot

(13)
• 

To force a conversion to a non-default unit, use the convert/units command.

convert((13), 'units', 'calorie');

1000523cal

(14)
• 

Some units, like calorie, are derived differently in different contexts.  Use the UseContexts command to set the default context for context dependent units. To list the added default contexts, use the UsingContexts command.

convert(8*Unit('J'), 'units', 'calorie[nutrition]');

1523calnutrition

(15)

UseContexts('nutrition');

convert(8*Unit('J'), 'units', 'calorie');

1523calnutrition

(16)

convert(8*Unit('J'), 'units', 'calorie[thermochemical]');

1000523cal

(17)

UsingContexts();

nutrition

(18)

Creating Systems of Units

• 

If the units and systems of units available in the Units package are not sufficient, you can create new systems, units, and dimensions. To create a new base unit and corresponding base dimension, use the AddBaseUnit command. The HasDimension and HasUnit commands check to see if a dimension or unit already exists.

HasDimension('human');

false

(19)

HasUnit('soldier');

false

(20)

AddBaseUnit('soldier', 'context'='army', 'dimension'='human', 'spellings'='soldiers');

HasDimension('human');

true

(21)

HasUnit('soldier');

true

(22)
• 

When a new base unit has been created, new composite dimensions and units can be defined based on that unit using the AddDimension and AddUnit commands. Previously defined or standard dimensions and units can also be redefined using these commands, or removed using the RemoveDimension command.

AddUnit('section', 'context'='army', 'conversion'=10*'soldier', 'spellings'='sections');

convert(150*Unit('soldiers'), 'units', 'sections');

Error, (in convert/units) unable to convert `soldier` to `section`

GetUnit('section');

section,context=standard,default=false,conversion=4046856422415625metreSI2,prefix=false,symbol=none,symbols=,spelling=section,plural=sections,spellings=section,sections,abbreviation=none,abbreviations=

(23)
  

The unit section is already defined and included in the SI system. Specify the newly defined unit in its army context to use the new meaning.

GetUnit('section[army]');

section,context=army,default=false,conversion=10soldierarmy,prefix=false,symbol=none,symbols=,spelling=section,plural=sections,spellings=section,sections,abbreviation=none,abbreviations=

(24)

convert(150*Unit('soldiers'), 'units', 'section[army]');

15sectionarmy

(25)
• 

To create a new system, use the AddSystem command. This command is also used to customize an existing system by adding or changing the default unit for a dimension. To remove a system, use the RemoveSystem command.

HasSystem('military');

false

(26)

AddSystem('military', 'soldier');

UseSystem('military');

50*Unit('soldier')+3*Unit('section[army]');

80soldier

(27)

AddSystem('militarySI', GetSystem('military'), GetSystem('SI'), 'section[army]', 'hour');

UseSystem('militarySI');

(50*Unit('soldier')+3*Unit('section[army]'))*Unit('hour');

8sectionarmyhour

(28)

RemoveSystem('military');

• 

To add or redefine a system, unit, or dimension in all future Maple sessions, add the above commands to your Maple initialization file. For more information, see Create Maple Initialization File.

See Also

convert/dimensions, convert/systems, convert/units, examples,DefaultUnits, examples,NaturalUnits, examples,StandardUnits, Units, Units/Details, Units/Index, worksheet/reference/initialization


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam