Units
UseMode
set the default mode for combining units
Calling Sequence
Parameters
Description
Examples
Compatibility
UseMode(mode)
mode
-
(optional) symbol; name of mode for combining units
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.
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
We can see this because combine/units accepts the following expression, which assumes the unassigned variable distance has a unit of length.
combine⁡distance+30⁢Unit⁡km,units
distance+30⁢km
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.
UnitsUseMode⁡standard
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.
standard
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.
convert⁡2.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.
convert⁡2.4,units,N⁢m⁡radius,Btu,symbolic=true
0.002276283395
UnitsUseMode⁡simple
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
with⁡UnitsStandard
`*`,`+`,`-`,`/`,`<`,<=,<>,`=`,ℑ,ℜ,`^`,abs,add,arccos,arccosh,arccot,arccoth,arccsc,arccsch,arcsec,arcsech,arcsin,arcsinh,arctan,arctanh,argument,ceil,collect,combine,conjugate,cos,cosh,cot,coth,csc,csch,csgn,diff,eval,evalc,evalr,exp,expand,factor,floor,frac,int,ln,log,log10,log2,max,min,mul,normal,polar,root,round,sec,sech,seq,shake,signum,simplify,sin,sinh,sqrt,surd,tan,tanh,trunc,type,verify
This means that the combine command we used above will throw an error, as before.
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,30⁢Unit⁡km,units,mode=simple
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.
with⁡Units:
Automatically loading the Units[Simple] subpackage
Automatically loading the Units[Standard] subpackage
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/Commands
Units/default
Units/Index
Units[Natural]
Units[Simple]
Units[Standard]
Download Help Document