util.units: Functions to Convert Units

Description Usage Arguments Details Examples

Description

These functions convert values between units and set the user's preferred units.

Usage

1
2
3
4
5
  P.units(units = NULL)
  T.units(units = NULL)
  E.units(units = NULL)
  convert(value, units, T = get("thermo")$opt$Tr,
    P = get("thermo")$opt$Pr, pH = 7, logaH2O = 0)

Arguments

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

Details

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## 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 unit settings
# make K the units for temperature arguments to subcrt() and affinity()
T.units("K") 
# return to default - degrees C
T.units("C")

CHNOSZ documentation built on May 19, 2017, 11:17 a.m.

Search within the CHNOSZ package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.