[CHNOSZ-commits] r278 - in pkg/CHNOSZ: . R man tests/testthat vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 6 06:08:39 CET 2017


Author: jedick
Date: 2017-11-06 06:08:38 +0100 (Mon, 06 Nov 2017)
New Revision: 278

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/swap.basis.R
   pkg/CHNOSZ/man/nonideal.Rd
   pkg/CHNOSZ/man/subcrt.Rd
   pkg/CHNOSZ/tests/testthat/test-logmolality.R
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/vig.bib
Log:
nomenclature: use "adjusted" (not "apparent") Gibbs energies at specified ionic strength


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/DESCRIPTION	2017-11-06 05:08:38 UTC (rev 278)
@@ -1,6 +1,6 @@
-Date: 2017-11-05
+Date: 2017-11-06
 Package: CHNOSZ
-Version: 1.1.0-76
+Version: 1.1.0-77
 Title: Thermodynamic Calculations for Geobiochemistry
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/swap.basis.R
===================================================================
--- pkg/CHNOSZ/R/swap.basis.R	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/R/swap.basis.R	2017-11-06 05:08:38 UTC (rev 278)
@@ -2,6 +2,9 @@
 # functions related to swapping basis species
 # extracted from basis() 20120114 jmd
 
+## if this file is interactively sourced, the following are also needed to provide unexported functions:
+#source("basis.R")
+
 # return the current basis elements
 basis.elements <- function(basis = get("thermo")$basis) {
   if(is.null(basis)) stop("basis species are not defined")
@@ -14,7 +17,8 @@
   basis.mat <- basis.elements(basis)
   # the standard Gibbs energies of the basis species
   # don't take it from thermo$obigt, even at 25 degC, because G for H2O is NA there
-  G <- unlist(subcrt(basis$ispecies, T=T, property="G")$out)
+  # the sapply(..., "[", 1) is needed to get the first value, in case subcrt appends a polymorph column (i.e. for S(cr))  20171105
+  G <- unlist(sapply(subcrt(basis$ispecies, T=T, property="G")$out, "[", 1))
   # chemical potentials of the basis species
   species.mu <- G - convert(basis$logact, "G", T=convert(T, "K"))
   # chemical potentials of the elements
@@ -36,7 +40,8 @@
   if(any(is.na(ielem))) stop(paste("element(s)", paste(names(emu)[is.na(ielem)], collapse=" "), "not found in basis"))
   # the standard Gibbs energies of the basis species
   # don't take it from thermo$obigt, even at 25 degC, because G for H2O is NA there
-  G <- unlist(subcrt(basis$ispecies, T=T, property="G")$out)
+  # the sapply(..., "[", 1) is needed to get the first value, in case subcrt appends a polymorph column (i.e. for S(cr))  20171105
+  G <- unlist(sapply(subcrt(basis$ispecies, T=T, property="G")$out, "[", 1))
   # the chemical potentials of the basis species in equilibrium
   # with the chemical potentials of the elements
   basis.mu <- colSums((t(basis.mat)*emu)) - G

Modified: pkg/CHNOSZ/man/nonideal.Rd
===================================================================
--- pkg/CHNOSZ/man/nonideal.Rd	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/man/nonideal.Rd	2017-11-06 05:08:38 UTC (rev 278)
@@ -4,7 +4,7 @@
 \alias{Bdot}
 \title{Activity coefficients of aqueous species}
 \description{
-Calculate activity coefficients and apparent (non-ideal) molal properties of aqueous species.
+Calculate activity coefficients and adjusted (non-ideal) molal properties of aqueous species.
 }
 
 \usage{
@@ -27,14 +27,14 @@
 
 \details{
 \code{nonideal} takes a list of dataframes (in \code{speciesprops}) containing the standard molal properties of the identified \code{species}.
-The function calculates the *apparent* properties for given ionic strength (\code{IS}); they are equal to the *standard* values at IS=0.
+The function calculates the *adjusted* properties for given ionic strength (\code{IS}); they are equal to the *standard* values at IS=0.
 The function bypasses (leaves unchanged) properties of all species whose charge (determined by the number of Z in their \code{\link{makeup}}) is equal to zero.
 The proton (\Hplus) and electron (\eminus) are also bypassed by default; this makes sense if you are setting the pH, i.e. activity of \Hplus, to some value.
 To apply the calculations to H+ and/or e-, change \code{\link{thermo}$opt$ideal.H} or \code{ideal.e} to FALSE.
 The lengths of \code{IS} and \code{T} supplied in the arguments should be equal to the number of rows of each dataframe in \code{speciesprops}, or length one to use single values throughout.
 
-If \code{method} is \samp{Alberty}, the values of \code{IS} are combined with Alberty's (2003) equation 3.6-1 (extended Debye-Hückel equation) and its derivatives, to calculate apparent molal properties at the specified ionic strength(s) and temperature(s).
-The apparent molal properties that can be calculated include \samp{G}, \samp{H}, \samp{S} and \samp{Cp}; any columns in the dataframes of \code{speciesprops} with other names are left untouched.
+If \code{method} is \samp{Alberty}, the values of \code{IS} are combined with Alberty's (2003) equation 3.6-1 (extended Debye-Hückel equation) and its derivatives, to calculate adjusted molal properties at the specified ionic strength(s) and temperature(s).
+The adjusted molal properties that can be calculated include \samp{G}, \samp{H}, \samp{S} and \samp{Cp}; any columns in the dataframes of \code{speciesprops} with other names are left untouched.
 
 If \code{method} is \samp{Helgeson}, the \dQuote{B-dot} equation is used.
 This equation seems to have been originally proposed by Huckel, 1925; parameters were derived for use at high temperature and pressure by Helgeson, 1969; Helgeson et al., 1981; Manning, 2013.
@@ -42,7 +42,7 @@
 In addition to \code{IS} and \code{T}, this method depends on values of \code{P}, \code{A_DH}, and \code{B_DH} given in the arguments.
 The calculation of \dQuote{B-dot}, also used in the equations, is made within \code{nonideal} by calling the \code{Bdot} function.
 For some uses, it is desirable to set the \dQuote{B-dot} parameter to zero; this can be done by setting the method to \code{Helgeson0}.
-Currently, \samp{G} is the only apparent molal property that is calculated (but this can be used by \code{\link{subcrt}} to calculate apparent equilibrium constants).
+Currently, \samp{G} is the only adjusted molal property that is calculated (but this can be used by \code{\link{subcrt}} to calculate adjusted equilibrium constants).
 
 \code{Bdot} calculates the \dQuote{B-dot} deviation function (Helgeson, 1969) a.k.a. extended term parameter (written as b_gamma; Helgeson et al., 1981) for activity coefficients in NaCl solutions at high temperature and pressure.
 Data at Psat and 0.5 to 5 kb are taken from Helgeson (1969, Table 2 and Figure 3) and Helgeson et al. (1981, Table 27) and extrapolated values at 10 to 30 kb from Manning et al. (2013, Figure 11).
@@ -54,7 +54,7 @@
 }
 
 \value{
-One (\samp{G}) or more (\samp{H}, \samp{S}, \samp{Cp}; currently only with the Alberty method) standard thermodynamic properties (at IS=0) in \code{speciesprops} are replaced by the corresponding apparent thermodynamic properties (at higher IS).
+One (\samp{G}) or more (\samp{H}, \samp{S}, \samp{Cp}; currently only with the Alberty method) standard thermodynamic properties (at IS=0) in \code{speciesprops} are replaced by the corresponding adjusted thermodynamic properties (at higher IS).
 For all affected species, a column named \code{loggam} (common (base-10) logarithm of gamma, the activity coefficient) is appended to the output dataframe of species properties.
 }
 
@@ -91,8 +91,8 @@
   legend = as.expression(lapply(species, expr.species)))
 
 ## more often, the 'IS' argument of subcrt() is used to compute
-## apparent properties at given ionic strength
-# p. 16 Table 1.3: apparent pKa of acetic acid
+## adjusted properties at given ionic strength
+# p. 16 Table 1.3: adjusted pKa of acetic acid
 # set ideal.H to FALSE to calculate activity coefficients for the proton
 # (makes for better replication of the values in Alberty's book)
 thermo$opt$ideal.H <<- FALSE

Modified: pkg/CHNOSZ/man/subcrt.Rd
===================================================================
--- pkg/CHNOSZ/man/subcrt.Rd	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/man/subcrt.Rd	2017-11-06 05:08:38 UTC (rev 278)
@@ -26,7 +26,7 @@
   \item{logact}{numeric, logarithms of activities of species in reaction}
   \item{convert}{logical, are input and output units of T and P those of the user (\code{TRUE}) (see \code{\link{T.units}}), or are they Kelvin and bar (\code{FALSE})?}
   \item{action.unbalanced}{character \samp{warn} or NULL, what action to take if unbalanced reaction is provided}
-  \item{IS}{numeric, ionic strength(s) at which to calculate apparent molal properties, mol kg\eqn{^{-1}}{^-1}}
+  \item{IS}{numeric, ionic strength(s) at which to calculate adjusted molal properties, mol kg\eqn{^{-1}}{^-1}}
 }
 
 \details{
@@ -76,10 +76,10 @@
 Note that \code{\link{affinity}} provides related functionality but is geared toward the properties of formation reactions of species from the basis species and can be performed in more dimensions.
 Calculations of chemical affinity in \code{subcrt} can be performed for any reaction of interest; however, they are currently limited to constant values of the logarithms of activities of species in the reactions, and hence of \code{logQ}, across the computational range.
 
-If \code{IS} is set to a single value other than zero, \code{\link{nonideal}} is used to calculate the apparent properties (\code{G}, \code{H}, \code{S} and \code{Cp}) of charged aqueous species at the given ionic strength.
+If \code{IS} is set to a single value other than zero, \code{\link{nonideal}} is used to calculate the adjusted properties (\code{G}, \code{H}, \code{S} and \code{Cp}) of charged aqueous species at the given ionic strength.
 To perform calculations at a single \code{P} and \code{T} and for multiple values of ionic strength, supply these values in \code{IS}.
 Calculations can also be performed on a \code{P}-\code{IS}, \code{T}-\code{IS} or \code{P,T}-\code{IS} grid.
-Values of \code{logK} of reactions calculated for \code{IS} not equal to zero are consistent with the apparent Gibbs energies of the charged aqueous species.
+Values of \code{logK} of reactions calculated for \code{IS} not equal to zero are consistent with the adjusted Gibbs energies of the charged aqueous species.
 
 \code{subcrt} is modeled after the functionality of the \acronym{SUPCRT92} package (Johnson et al., 1992).
 Certain features of \acronym{SUPCRT92} are not available here, for example, calculations as a function of density of \H2O instead of pressure, or calculations of temperatures of univariant curves (i.e. for which \code{logK} is zero).

Modified: pkg/CHNOSZ/tests/testthat/test-logmolality.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-logmolality.R	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/tests/testthat/test-logmolality.R	2017-11-06 05:08:38 UTC (rev 278)
@@ -23,11 +23,11 @@
   out0 <- subcrt(c("H+", "HCO3-"), T=25)$out
   # and at IS = 1
   out1 <- subcrt(c("H+", "HCO3-"), T=25, IS=1)$out
-  # the apparent standard Gibbs energy is less than the standard Gibbs energy
+  # the adjusted standard Gibbs energy is less than the standard Gibbs energy
   # by an amount determined by the activity coefficient
   expect_equal(out1[[2]]$G - out0[[2]]$G, -convert(loggam, "G"))
 
-  ## take-home message 0: setting IS in subcrt() gives apparent standard Gibbs energy
+  ## take-home message 0: setting IS in subcrt() gives adjusted standard Gibbs energy
 
   # now, what is the equilibrium constant for the reaction CO2 + H2O = H+ + HCO3-?
   # (this is the standard state property at IS=0)

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2017-11-06 05:08:38 UTC (rev 278)
@@ -1061,7 +1061,7 @@
 
 * H<sup>+</sup> is assumed to behave ideally, so its activity coefficient is 1 for any ionic strength. You can calculate activity coefficients of H<sup>+</sup> by setting `thermo$opt$ideal.H <<- FALSE`.
 
-* Using <span style="color:green">`subcrt()`</span> with `IS` not equal to zero, calculated values of `G` are the **apparent** standard Gibbs energy at specified ionic strength.
+* Using <span style="color:green">`subcrt()`</span> with `IS` not equal to zero, calculated values of `G` are the **adjusted** Gibbs energy at specified ionic strength [denoted by Δ*G*°(*I*); @Alb96].
 
 * Using <span style="color:green">`subcrt()`</span> with `IS` not equal to zero, values in the `logact` argument stand for **log molality** of aqueous species in affinity calculations.
 
@@ -1093,7 +1093,7 @@
 ```
 
 The logarithms of the activity coefficients (`loggam`) are more negative for the higher-charged species, as well as at higher temperature, and have a stabilizing effect.
-That is, the apparent Gibbs energies at *I* > 0 are less than the standard Gibbs energies at *I* = 0.
+That is, the adjusted Gibbs energies at *I* > 0 are less than the standard Gibbs energies at *I* = 0.
 
 We can use these calculations to make some speciation plots, similar to Figures 1.2--1.5 in Alberty (2003).
 These figures show the distribution of differently charged species of adenosine triphosphate (ATP) as a function of pH, and the average number of H<sup>+</sup> and Mg<sup>+2</sup> bound to ATP in solution as a function of pH or pMg (-log*a*<sub>Mg<sup>+2</sup></sub>).

Modified: pkg/CHNOSZ/vignettes/vig.bib
===================================================================
--- pkg/CHNOSZ/vignettes/vig.bib	2017-11-05 05:08:12 UTC (rev 277)
+++ pkg/CHNOSZ/vignettes/vig.bib	2017-11-06 05:08:38 UTC (rev 278)
@@ -225,25 +225,25 @@
 }
 
 @Article{LH06a,
-  author    = {LaRowe, Douglas E. and Helgeson, Harold C.},
-  journal   = {Geochimica et Cosmochimica Acta},
-  title     = {{B}iomolecules in hydrothermal systems: {C}alculation of the standard molal thermodynamic properties of nucleic-acid bases, nucleosides, and nucleotides at elevated temperatures and pressures},
-  year      = {2006},
-  volume    = {70},
-  number    = {18},
-  pages     = {4680--4724},
-  doi       = {10.1016/j.gca.2006.04.010},
+  author        = {LaRowe, Douglas E. and Helgeson, Harold C.},
+  journal       = {Geochimica et Cosmochimica Acta},
+  title         = {{B}iomolecules in hydrothermal systems: {C}alculation of the standard molal thermodynamic properties of nucleic-acid bases, nucleosides, and nucleotides at elevated temperatures and pressures},
+  year          = {2006},
+  volume        = {70},
+  number        = {18},
+  pages         = {4680--4724},
+  doi           = {10.1016/j.gca.2006.04.010},
 }
 
 @Article{LH06b,
-  author    = {LaRowe, Douglas E. and Helgeson, Harold C.},
-  journal   = {Thermochimica Acta},
-  title     = {{T}he energetics of metabolism in hydrothermal systems: {C}alculation of the standard molal thermodynamic properties of magnesium-complexed adenosine nucleotides and {NAD} and {NADP} at elevated temperatures and pressures},
-  year      = {2006},
-  volume    = {448},
-  number    = {2},
-  pages     = {82--106},
-  doi       = {10.1016/j.tca.2006.06.008},
+  author        = {LaRowe, Douglas E. and Helgeson, Harold C.},
+  journal       = {Thermochimica Acta},
+  title         = {{T}he energetics of metabolism in hydrothermal systems: {C}alculation of the standard molal thermodynamic properties of magnesium-complexed adenosine nucleotides and {NAD} and {NADP} at elevated temperatures and pressures},
+  year          = {2006},
+  volume        = {448},
+  number        = {2},
+  pages         = {82--106},
+  doi           = {10.1016/j.tca.2006.06.008},
 }
 
 @Article{MSS13,
@@ -631,24 +631,24 @@
 }
 
 @Article{MD98,
-  author    = {Merino, Enrique and Dewers, Thomas},
-  journal   = {Journal of Hydrology},
-  title     = {Implications of replacement for reaction–transport modeling},
-  year      = {1998},
-  volume    = {209},
-  number    = {1–4},
-  pages     = {137--146},
-  doi       = {10.1016/S0022-1694(98)00150-4},
-  issn      = {0022-1694},
+  author        = {Merino, Enrique and Dewers, Thomas},
+  journal       = {Journal of Hydrology},
+  title         = {{I}mplications of replacement for reaction–transport modeling},
+  year          = {1998},
+  volume        = {209},
+  number        = {1–4},
+  pages         = {137--146},
+  doi           = {10.1016/S0022-1694(98)00150-4},
+  issn          = {0022-1694},
 }
 
 @TechReport{Wol92,
-  author        = {Wolery, Thomas J.},
-  title         = {{EQ}3/6, a software package for geochemical modeling of aqueous systems: {P}ackage overview and installation guide (version 7.0)},
-  institution   = {Lawrence Livermore National Laboratory},
-  year          = {1992},
-  number        = {UCRL-MA-110662 PT I},
-  doi           = {10.2172/138894},
+  author      = {Wolery, Thomas J.},
+  title       = {{E}q3/6, {A} {S}oftware {P}ackage for {G}eochemical {M}odeling of {A}queous {S}ystems: {P}ackage {O}verview and {I}nstallation {G}uide ({V}ersion 7.0)},
+  institution = {Lawrence Livermore National Laboratory},
+  year        = {1992},
+  number      = {UCRL-MA-110662 PT I},
+  doi         = {10.2172/138894},
 }
 
 @Article{Ber88,
@@ -713,3 +713,16 @@
   size          = {268 p.},
 }
 
+ at Article{Alb96,
+  author        = {Alberty, Robert A.},
+  journal       = {European Journal of Biochemistry},
+  title         = {{R}ecommendations for nomenclature and tables in biochemical thermodynamics},
+  year          = {1996},
+  volume        = {240},
+  number        = {1},
+  pages         = {1--14},
+  doi           = {10.1111/j.1432-1033.1996.0001h.x},
+  issn          = {1432-1033},
+  publisher     = {Blackwell Science Ltd},
+}
+



More information about the CHNOSZ-commits mailing list