Units - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Science and Engineering : Units : Combining : Units/UseMode

Units

  

UseMode

  

set the default mode for combining units

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

UseMode(mode)

Parameters

mode

-

(optional) symbol; name of mode for combining units

Description

• 

The combine/units command can be used with several modes for combining units, corresponding to subpackages of the Units package. The UseMode(mode) function sets a default mode for combining units, to be used for the current session.

• 

The modes available are currently simple, standard, and natural, corresponding to the Units/Simple, Units/Standard, and Units/Natural subpackages, respectively. If you load any of these packages, Maple will automatically call UseMode with the corresponding argument.

• 

When you load the Units package, Maple will automatically load the subpackage corresponding to the currently selected mode.

• 

Additionally, the mode set by this command determines the default for the symbolic option of the convert/units command. In simple mode, the conversions happen with symbolic = true by default; in the two other modes, the default is symbolic = false.

• 

The default mode if none of these packages have been loaded is simple.

• 

Calling the UseMode command manually can be useful if you use the default Units environment, i.e., without loading any packages, and you wish to select how combine/units should combine units. It can also be useful to do this before loading the Units package, to instruct it which subpackage to load.

• 

The setting effected by the UseMode command applies to any calls to combine/units made by the user themselves, but also to calls from inside other commands, such as plot and int.

• 

The UseMode command returns the previous mode that was in effect. When called without any arguments, its only effect is to return the current mode.

• 

To set a default mode for combining units for all future Maple sessions, add the UseMode command to your Maple initialization file. For more information, see Create Maple Initialization File.

Examples

Notes: 

– 

To enter a unit in 2-D Math input, select the unit from the appropriate Units palette. If the unit you want is not there, select unit and then enter the unit.

– 

When you edit a unit, double brackets appear around it.

The default setting if none of the Units environments have been loaded is simple.

UnitsUseMode

simple

(1)

We can see this because combine/units accepts the following expression, which assumes the unassigned variable distance has a unit of length.

combinedistance+30km,'units'

distance+30km

(2)

In either the Units/Standard or Units/Natural model, this expression is invalid. Notice that if we select the standard units mode, executing the same expression results in an error about adding distance, which is now implicitly unitless, and the term with a unit.

UnitsUseModestandard

simple

(3)

combinedistance+30km,'units'

Error, (in Units:-Standard:-`+`) the units `1` and `km` have incompatible dimensions

To verify that the correct mode was stored, we can call the UseMode command again.

UnitsUseMode

standard

(4)

With the currently selected mode, the default value for the symbolic option of the convert/units command is false. This means, for example, that Maple distinguishes between angles and unitless quantities, and between torque and energy; you cannot convert one to the other.

convert2.4,'units','N''m''radius','Btu'

Error, (in `convert/units`) unable to convert `N*m(radius)` to `Btu`

If we supply the option symbolic = true, or if we switch to the simple mode, then this conversion succeeds, with the implicit understanding that it is the energy required for applying the torque over an angle of one radian.

convert2.4,'units','N''m''radius','Btu','symbolic'='true'

0.002276283395

(5)

UnitsUseMode'simple'

standard

(6)

convert2.4,'units','N''m''radius','Btu'

0.002276283395

(7)

If we load the Units[Standard] package in a new Maple session to enable the Standard Units environment, the standard mode is automatically selected.

restart

withUnitsStandard

`*`&comma;`+`&comma;`-`&comma;`/`&comma;`<`&comma;<=&comma;<>&comma;`=`&comma;&comma;&comma;`^`&comma;abs&comma;add&comma;arccos&comma;arccosh&comma;arccot&comma;arccoth&comma;arccsc&comma;arccsch&comma;arcsec&comma;arcsech&comma;arcsin&comma;arcsinh&comma;arctan&comma;arctanh&comma;argument&comma;ceil&comma;collect&comma;combine&comma;conjugate&comma;cos&comma;cosh&comma;cot&comma;coth&comma;csc&comma;csch&comma;csgn&comma;diff&comma;eval&comma;evalc&comma;evalr&comma;exp&comma;expand&comma;factor&comma;floor&comma;frac&comma;int&comma;ln&comma;log&comma;log10&comma;max&comma;min&comma;mul&comma;normal&comma;polar&comma;root&comma;round&comma;sec&comma;sech&comma;seq&comma;shake&comma;signum&comma;simplify&comma;sin&comma;sinh&comma;sqrt&comma;surd&comma;tan&comma;tanh&comma;trunc&comma;type&comma;verify

(8)

UnitsUseMode

standard

(9)

This means that the combine command we used above will throw an error, as before.

combinedistance&plus;30km&comma;&apos;units&apos;

Error, (in Units:-Standard:-`+`) the units `1` and `km` have incompatible dimensions

You can override the mode by calling UseMode again, or by explicitly supplying the mode option to the combine/units command. In either case, you need to be careful, otherwise the addition operator, +, generates an error before it gets to combine/units. This can be overcome by explicitly using the top level version of + instead of the one from the Units[Standard] package.

combine:-`+`distance&comma;30km&comma;&apos;units&apos;&comma;&apos;mode&apos;&equals;&apos;simple&apos;

distance+30km

(10)

Loading the Units package also loads one of the Units subpackages, as indicated by the currently selected mode. By default, this is the Units[Simple] subpackage, but this can be overridden using the UseMode command.

restart

withUnits&colon;

Automatically loading the Units[Simple] subpackage

restart

UnitsUseModestandard

simple

(11)

withUnits&colon;

Automatically loading the Units[Standard] subpackage

Compatibility

• 

The Units[UseMode] command was introduced in Maple 2017.

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

• 

The Units[UseMode] command was updated in Maple 2018.

See Also

Create Maple Initialization File

Units

Units/Commands

Units/default

Units/Index

Units[Natural]

Units[Simple]

Units[Standard]