util.units {CHNOSZ} | R Documentation |
These functions convert values between units and set the user's preferred units.
P.units(units = NULL) T.units(units = NULL) E.units(units = NULL) convert(value, units, T = 298.15, P = 1, pH = 7, logaH2O = 0)
units |
character, name of units to set or convert to/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 units settings are used by subcrt
, affinity
, and diagram
to accept input in or convert output to the units desired by the user.
The settings, which can be queried or changed with T.units
, E.units
and P.units
, refer to the units of temperature (C
or K
), energy (cal
or J
), and pressure (bar
, MPa
).
(The first value in each of those pairs refers to the default units).
The actual units conversions are handled by convert
, through which values
are transformed into destination units
(names not case sensitive).
The possible conversions and settings for the units
argument are shown in the following table.
Note that Eh and E0 both stand for the value of Eh (oxidation-reduction potential in volts); they have different names so that one can choose to convert between Eh and either pe or logfO2.
property | units | setting of units argument |
temperature | °C, K | C , K |
pressure | bar, MPa | bar , MPa |
energy | cal, J | cal , J |
energy | cal, cm^3 bar | calories , cm3bar |
energy | cal, [none] | G , logK |
oxidation potential | volt, [none] | Eh , pe |
oxidation potential | volt, [none] | E0 , logfO2 |
Another use of the function is to convert the results from solubility
into parts per billion, million, or thousand.
These destination units are specified by ppb, ppm, or ppt.
Additionally, the logarithms can be chosen with logppb, logppm, and logppt.
See demo("contour")
and demo("sphalerite")
for examples.
### direct usage of 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") ### setting the units # make K the units for temperature arguments to subcrt() and affinity() T.units("K") # return to default - degrees C T.units("C")