[CHNOSZ-commits] r211 - in pkg/CHNOSZ: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Sep 25 06:12:03 CEST 2017


Author: jedick
Date: 2017-09-25 06:12:03 +0200 (Mon, 25 Sep 2017)
New Revision: 211

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/hkf.R
   pkg/CHNOSZ/R/subcrt.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/eos.Rd
Log:
hkf(): remove 'H2O.PrTr' and 'domega' arguments


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2017-09-25 03:44:26 UTC (rev 210)
+++ pkg/CHNOSZ/DESCRIPTION	2017-09-25 04:12:03 UTC (rev 211)
@@ -1,6 +1,6 @@
 Date: 2017-09-24
 Package: CHNOSZ
-Version: 1.1.0-9
+Version: 1.1.0-10
 Title: Thermodynamic Calculations for Geobiochemistry
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/hkf.R
===================================================================
--- pkg/CHNOSZ/R/hkf.R	2017-09-25 03:44:26 UTC (rev 210)
+++ pkg/CHNOSZ/R/hkf.R	2017-09-25 04:12:03 UTC (rev 211)
@@ -3,7 +3,7 @@
 # 11/17/03 jmd
 
 hkf <- function(property = NULL, T = 298.15, P = 1, parameters = NULL,
-  contrib = c('n', 's', 'o'), H2O.PT = NULL, H2O.PrTr = NULL, domega = TRUE) {
+  contrib = c('n', 's', 'o'), H2O.PT = NULL) {
   # calculate G, H, S, Cp, V, kT, and/or E using
   # the revised HKF equations of state
   thermo <- get("thermo")
@@ -17,7 +17,6 @@
   property <- eargs$prop
   EOS.props <- eargs$props
   EOS.Props <- eargs$Prop
-  domega <- rep(domega, length.out = nrow(parameters))
   # nonsolvation, solvation, and origination contribution
   notcontrib <- ! contrib %in% c('n', 's', 'o')
   if(TRUE %in% notcontrib)
@@ -36,7 +35,7 @@
       H2O.props <- c(H2O.props, 'NBorn', 'UBorn')
     }
     if(is.null(H2O.PT)) H2O.PT <- water(H2O.props, T = T, P = P)
-    if(is.null(H2O.PrTr)) H2O.PrTr <- water(H2O.props, T = thermo$opt$Tr, P = thermo$opt$Pr)
+    H2O.PrTr <- water(H2O.props, T = thermo$opt$Tr, P = thermo$opt$Pr)
     ZBorn <- -1 / H2O.PT$diel
     ZBorn.PrTr <- -1 / H2O.PrTr$diel
   }
@@ -66,8 +65,8 @@
     dwdP <- dwdT <- d2wdT2 <- numeric(length(T))
     Z <- PAR$Z
     omega.PT <- rep(PAR$omega, length(T))
-    if(!identical(Z, 0) & domega[k] & dosupcrt) {
-      # g and f function stuff (Shock et al., 1992; Johnson et al., 1992)
+    if(!identical(Z, 0) & !PAR$name=="H+" & dosupcrt) {
+      # compute derivatives of omega: g and f functions (Shock et al., 1992; Johnson et al., 1992)
       rhohat <- H2O.PT$rho/1000  # just converting kg/m3 to g/cm3
       g <- gfun(rhohat, convert(T, "C"), P, H2O.PT$alpha, H2O.PT$daldT, H2O.PT$beta)
       # after SUPCRT92/reac92.f

Modified: pkg/CHNOSZ/R/subcrt.R
===================================================================
--- pkg/CHNOSZ/R/subcrt.R	2017-09-25 03:44:26 UTC (rev 210)
+++ pkg/CHNOSZ/R/subcrt.R	2017-09-25 04:12:03 UTC (rev 211)
@@ -266,14 +266,12 @@
   out <- list()
   # aqueous species
   if(TRUE %in% isaq | 'rho' %in% eprop) {
-    # load the water properties (better here, once,
-    # than possible many times in hkf()).
+    # load the water properties
     wprop.PT <- character()
     wprop.PrTr <- 'rho'
     dosupcrt <- thermo$opt$water != "IAPWS95"
     if(TRUE %in% (prop %in% c('logk','g','h','s'))) wprop.PrTr <- c(wprop.PrTr,'YBorn')
     if(dosupcrt | TRUE %in% (prop %in% c('logk','g','h'))) wprop.PrTr <- c(wprop.PrTr,'diel')
-    H2O.PrTr <- water(wprop.PrTr,T=thermo$opt$Tr,P=thermo$opt$Pr)
     if(TRUE %in% (prop %in% c('cp'))) {wprop.PT <- c(wprop.PT,'XBorn','YBorn')}
     if(TRUE %in% (prop %in% c('v'))) {wprop.PT <- c(wprop.PT,'QBorn')}
     if(TRUE %in% (prop %in% c('kt'))) {wprop.PT <- c(wprop.PT,'NBorn')}
@@ -287,8 +285,7 @@
       # the overhead of info() and use new obigt2eos() instead
       #si <- info(inpho[isaq],quiet=TRUE)
       si <- obigt2eos(thermo$obigt[inpho[isaq],], "aq", fixGHS = TRUE)
-      domega <- thermo$obigt$name[inpho[isaq]] != 'H+'
-      p.aq <- hkf(eosprop,T=T,P=P,parameters=si,H2O.PT=H2O.PT,H2O.PrTr=H2O.PrTr,domega=domega)
+      p.aq <- hkf(eosprop, T=T, P=P, parameters=si, H2O.PT=H2O.PT)
       if(any(IS!=0)) p.aq <- nonideal(inpho[isaq],p.aq,newIS,T)
       out <- c(out,p.aq)
     }

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2017-09-25 03:44:26 UTC (rev 210)
+++ pkg/CHNOSZ/inst/NEWS	2017-09-25 04:12:03 UTC (rev 211)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.0-9 (2017-09-25)
+CHANGES IN CHNOSZ 1.1.0-10 (2017-09-25)
 --------------------------------------
 
 - water.lines() now works for diagrams of Eh, pe, logfO2, logaO2,
@@ -24,6 +24,11 @@
 - In hkf() and cgl(), combine 'ghs' and 'eos' arguments into single
   argument named 'parameters'.
 
+- Remove 'H2O.PrTr' and 'domega' arguments from hkf(). Properties of
+  water at Pr and Tr and the logic for when to calculate derivatives of
+  omega are now calculated within the function, thereby simplifying the
+  function call from subcrt().
+
 CHANGES IN CHNOSZ 1.1.0 (2017-05-04)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/eos.Rd
===================================================================
--- pkg/CHNOSZ/man/eos.Rd	2017-09-25 03:44:26 UTC (rev 210)
+++ pkg/CHNOSZ/man/eos.Rd	2017-09-25 04:12:03 UTC (rev 211)
@@ -10,19 +10,16 @@
 \usage{
   cgl(property = NULL, T = 298.15, P = 1, parameters = NULL)
   hkf(property = NULL, T = 298.15, P = 1, parameters = NULL,
-    contrib = c("n","s","o"), H2O.PT = NULL, H2O.PrTr = NULL, 
-    domega = TRUE)
+    contrib = c("n", "s", "o"), H2O.PT = NULL)
 }
 
 \arguments{
   \item{property}{character, name(s) of properties to calculate}
   \item{T}{numeric, temperature(s) at which to calculate properties (K)}
   \item{P}{numeric, pressure(s) at which to calculate properties (bar)}
-  \item{parameters}{dataframe, standard molal thermodynamic properties and equations-of-state parameters in the format of \code{thermo$obigt}}
+  \item{parameters}{dataframe, species parameters as one or more rows from \code{thermo$obigt}}
   \item{contrib}{character, which contributions to consider in the revised HKF equations equations of state: (\code{n})onsolvation, (\code{s})olvation (the \eqn{\omega}{omega} terms), or (o)rigination contributions (i.e., the property itself at 25 \eqn{^{\circ}}{°}C and 1 bar). Default is \code{c("n","s","o")}, for all contributions}
   \item{H2O.PT}{dataframe, values of the electrostatic properties of water at the temperature(s) and pressure(s) of interest}
-  \item{H2O.PrTr}{dataframe, values of the electrostatic properties of water at the reference temperature and pressure}
-  \item{domega}{logical, calculate the T and P derivatives of omega?}
 }
 
 \details{
@@ -34,10 +31,10 @@
 \code{hkf} implements the revised HKF equations of state (Helgeson et al., 1981; Tanger and Helgeson, 1988; Shock and Helgeson, 1988).
 The equations-of-state parameters are \code{a1}, \code{a2}, \code{a3}, \code{a4}, \code{c1}, \code{c2}, \code{omega} and \code{Z}; the units of these parameters are as indicated for \code{\link{thermo}$obigt}, without the order of magnitude multipliers.
 Note that the equation-of-state parameter \code{Z} (appearing in the \eqn{g}{g}-function for the temperature derivatives of the omega parameter; Shock et al., 1992) is taken from \code{thermo$obigt} and \emph{not} from the \code{\link{makeup}} of the species.
-\code{H2O.PT} and \code{H2O.PrTr} are optional arguments that contain the electrostatic properties of \eqn{\mathrm{H_2O}}{H2O} required for the calculations.
+\code{H2O.PT} is an optional argument that contains the electrostatic properties of \eqn{\mathrm{H_2O}}{H2O} required for the calculations.
 If either of these is \code{NULL} (the default), the required values are retrieved using \code{\link{water}}. 
 
-Unless \code{domega}, the value of which is recycled to the number of species (number of rows of \code{parameters}), is FALSE for any of the species, the temperature and pressure derivatives of the \code{omega} parameter for charged species (where \code{Z != 0}) are calculated using the \eqn{g}{g}- and \eqn{f}{f}-functions described by Shock et al., 1992 and Johnson et al., 1992.
+The temperature and pressure derivatives of the \code{omega} parameter for charged species (where \code{Z != 0}, but not for the aqueous proton, H+) are calculated using the \eqn{g}{g}- and \eqn{f}{f}-functions described by Shock et al., 1992 and Johnson et al., 1992.
 This option is turned off when the IAPWS-95 equations are activated (see \code{\link{water}}).
 
 The parameters in the \code{cgl} equations of state for crystalline, gas and liquid species (except liquid water) include \code{V}, \code{a}, \code{b}, \code{c}, \code{d}, \code{e}, \code{f} and \code{lambda}.



More information about the CHNOSZ-commits mailing list