Optional variable
usersetunits
Default value: none
If a user wishes to have a default unit behavior other than that described,
they can make use of maxima-init.mac and the usersetunits
variable. The unit package will check on startup to see if this variable
has been assigned a list. If it has, it will use setunits on that list and take
the units from that list to be defaults. uforget
will revert to the behavior
defined by usersetunits over its own defaults. For example, if we have a
maxima-init.mac file containing:
usersetunits : [N,J];
we would see the following behavior:
(%i1) load("unit")$ ******************************************************************* * Units version 0.50 * * Definitions based on the NIST Reference on * * Constants, Units, and Uncertainty * * Conversion factors from various sources including * * NIST and the GNU units package * ******************************************************************* Redefining necessary functions... WARNING: DEFUN/DEFMACRO: redefining function TOPLEVEL-MACSYMA-EVAL ... WARNING: DEFUN/DEFMACRO: redefining function ... WARNING: DEFUN/DEFMACRO: redefining function ... WARNING: DEFUN/DEFMACRO: redefining function ... Initializing unit arrays... Done. User defaults found... User defaults initialized. (%i2) kg*m/s^2; (%o2) N (%i3) kg*m^2/s^2; (%o3) J (%i4) kg*m^3/s^2; (%o4) J m (%i5) kg*m*km/s^2; (%o5) (1000) (J) (%i6) setunits([dyn,eV]); (%o6) done (%i7) kg*m/s^2; (%o7) (100000) (dyn) (%i8) kg*m^2/s^2; (%o8) (6241509596477042688) (eV) (%i9) kg*m^3/s^2; (%o9) (6241509596477042688) (eV m) (%i10) kg*m*km/s^2; (%o10) (6241509596477042688000) (eV) (%i11) uforget([dyn,eV]); (%o11) [false, false] (%i12) kg*m/s^2; (%o12) N (%i13) kg*m^2/s^2; (%o13) J (%i14) kg*m^3/s^2; (%o14) J m (%i15) kg*m*km/s^2; (%o15) (1000) (J)
Without usersetunits
, the initial inputs would have been converted
to MKS, and uforget would have resulted in a return to MKS rules. Instead,
the user preferences are respected in both cases. Notice these can still
be overridden if desired. To completely eliminate this simplification - i.e.
to have the user defaults reset to factory defaults - the dontusedimension
command can be used. uforget
can restore user settings again, but
only if usedimension
frees it for use. Alternately,
kill(usersetunits)
will completely remove all knowledge of the user defaults
from the session. Here are some examples of how these various options work.
(%i2) kg*m/s^2; (%o2) N (%i3) kg*m^2/s^2; (%o3) J (%i4) setunits([dyn,eV]); (%o4) done (%i5) kg*m/s^2; (%o5) (100000) (dyn) (%i6) kg*m^2/s^2; (%o6) (6241509596477042688) (eV) (%i7) uforget([dyn,eV]); (%o7) [false, false] (%i8) kg*m/s^2; (%o8) N (%i9) kg*m^2/s^2; (%o9) J (%i10) dontusedimension(N); (%o10) [%force] (%i11) dontusedimension(J); (%o11) [%energy, %force] (%i12) kg*m/s^2; kg m (%o12) ---- 2 s (%i13) kg*m^2/s^2; 2 kg m (%o13) ----- 2 s (%i14) setunits([dyn,eV]); (%o14) done (%i15) kg*m/s^2; kg m (%o15) ---- 2 s (%i16) kg*m^2/s^2; 2 kg m (%o16) ----- 2 s (%i17) uforget([dyn,eV]); (%o17) [false, false] (%i18) kg*m/s^2; kg m (%o18) ---- 2 s (%i19) kg*m^2/s^2; 2 kg m (%o19) ----- 2 s (%i20) usedimension(N); Done. To have Maxima simplify to this dimension, use setunits([unit]) to select a unit. (%o20) true (%i21) usedimension(J); Done. To have Maxima simplify to this dimension, use setunits([unit]) to select a unit. (%o21) true (%i22) kg*m/s^2; kg m (%o22) ---- 2 s (%i23) kg*m^2/s^2; 2 kg m (%o23) ----- 2 s (%i24) setunits([dyn,eV]); (%o24) done (%i25) kg*m/s^2; (%o25) (100000) (dyn) (%i26) kg*m^2/s^2; (%o26) (6241509596477042688) (eV) (%i27) uforget([dyn,eV]); (%o27) [false, false] (%i28) kg*m/s^2; (%o28) N (%i29) kg*m^2/s^2; (%o29) J (%i30) kill(usersetunits); (%o30) done (%i31) uforget([dyn,eV]); (%o31) [false, false] (%i32) kg*m/s^2; kg m (%o32) ---- 2 s (%i33) kg*m^2/s^2; 2 kg m (%o33) ----- 2 s
Unfortunately this wide variety of options is a little confusing at first, but once the user grows used to them they should find they have very full control over their working environment.