nuts {CHNOSZ} | R Documentation |
Set units preferences and convert values between units.
nuts(units = NULL) convert(value, units, T = thermo$opt$Tr, P = thermo$opt$Pr, pH = 7, logaH2O = 0) envert(value,units) outvert(value,units)
units |
character, name of units to set in global preferences (nuts ), or name of units (see table) to convert to or from. |
value |
numeric, value(s) to be converted. |
T |
numeric, temperature (Kelvin), used in G-logK, pe-Eh and logfO2-E0 conversions. |
P |
numeric, pressure (bar), used in logfO2-E0 conversions. |
pH |
numeric, pH, used in logfO2-E0 conversions. |
logaH2O |
numeric, logarithm of activity of water, used in logfO2-E0 conversions. |
The global units settings are used by subcrt
, affinity
, and diagram
to accept input or convert output in the units desired by the user. The settings, which can be queried or changed with nuts
, refer to the units of temperature (K
or C
), energy (cal
or J
), and pressure (bar
, MPa
). (The first value in each of those pairs refers to the default units). If the units
argument to nuts
is NULL (the default) the current units settings are printed (with a NULL return); if it is one of T, P or E, the units for that property are printed and also returned.
The actual units conversions are handled by convert
, through which values
are transformed into destination units
(names not case sensitive). The possible unit conversions are shown in the following table. Note that Eh and E0 both stand for the value of Eh (do not confuse E0 with the standard reduction potential, which is written similarly); they have different names so that one can choose to convert to pe or logfO2.
C | K | temperature |
cal | J | energy |
bar | MPa | pressure |
E0 | logfO2 | oxidation state |
G | logK | energy |
cm3bar | calories | energy |
pe | Eh | oxidation state |
envert
and outvert
are wrappers for convert
that handle the conditional conversion of values from or to the user's units. The name of the function nuts
is such to avoid clashing with the name of units
, which is present in the R base package.
Numeric, except for nuts
, which returns character or NULL
.
## examples using convert # temperature (Kelvin) to degrees C convert(273.15,'C') # temperature (degrees C) to Kelvin convert(100,'K') # Gibbs energy (cal mol-1) to/from logK convert(1000,'logK') convert(1000,'logK',T=373.15) convert(1,'G') # Eh (volt) to pe convert(-1,'pe') convert(-1,'pe',T=373.15) # logfO2 to E0 (volt) convert(-80,'E0') convert(-80,'E0',pH=5) convert(-80,'E0',pH=5,logaH2O=-5) # calorie to/from joule convert(10,'j') convert(10,'cal') # cm3bar to calories convert(10,'calories') ## examples showing user unit preference nuts('K') # set temperature units nuts('J') # set energy units # return the name of the (E)nergy units nuts('E') # print names of all units (NULL return) nuts() # defaults nuts('K'); nuts('bar'); nuts('cal')