[CHNOSZ-commits] r217 - in pkg/CHNOSZ: . R inst man tests/testthat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Sep 25 15:31:37 CEST 2017
Author: jedick
Date: 2017-09-25 15:31:36 +0200 (Mon, 25 Sep 2017)
New Revision: 217
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/water.R
pkg/CHNOSZ/inst/NEWS
pkg/CHNOSZ/man/subcrt.Rd
pkg/CHNOSZ/man/util.water.Rd
pkg/CHNOSZ/man/water.Rd
pkg/CHNOSZ/tests/testthat/test-DEW.R
Log:
set thermo$opt$water using water("DEW") etc.
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/DESCRIPTION 2017-09-25 13:31:36 UTC (rev 217)
@@ -1,6 +1,6 @@
Date: 2017-09-25
Package: CHNOSZ
-Version: 1.1.0-15
+Version: 1.1.0-16
Title: Thermodynamic Calculations for Geobiochemistry
Author: Jeffrey Dick
Maintainer: Jeffrey Dick <j3ffdick at gmail.com>
Modified: pkg/CHNOSZ/R/water.R
===================================================================
--- pkg/CHNOSZ/R/water.R 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/R/water.R 2017-09-25 13:31:36 UTC (rev 217)
@@ -6,6 +6,14 @@
# calculate the properties of liquid H2O as a function of T and P
# T in Kelvin, P in bar
if(is.null(property)) stop('property was NULL')
+ # set water option
+ if(length(property)==1 & any(property %in% c("SUPCRT", "SUPCRT92", "IAPWS", "IAPWS95", "DEW"))) {
+ thermo <- get("thermo")
+ thermo$opt$water <- property
+ assign("thermo", thermo, "CHNOSZ")
+ message(paste("water: thermo$opt$water was set to", property))
+ return(invisible(property))
+ }
# make T and P equal length
if(!identical(P, "Psat")) {
if(length(P) < length(T)) P <- rep(P, length.out = length(T))
Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/inst/NEWS 2017-09-25 13:31:36 UTC (rev 217)
@@ -1,10 +1,22 @@
-CHANGES IN CHNOSZ 1.1.0-15 (2017-09-25)
+CHANGES IN CHNOSZ 1.1.0-16 (2017-09-25)
---------------------------------------
+MAJOR CHANGES:
+
+- Add functions implementing the Deep Earth Water (DEW) model
+ (Sverjensky et al., 2014): calculateDensity(),
+ calculateGibbsofWater(), calculateEpsilon(), calculateQ(), and
+ water.DEW().
+
+- The computational option for water (thermo$opt$par) can now be
+ set using water("DEW"), water("IAPWS"), etc.
+
- water.lines() now works for diagrams of Eh, pe, logfO2, logaO2,
logfH2, or logaH2 vs pH, T, or P. It is possible to have T or P on
either the x- or y-axis.
+DATABASE UPDATES:
+
- Data file CHNOSZ_aq.csv is no longer added to the database by default.
It is now intended to hold provisional updates. Updated heat capacity
and volume HKF parameters for adenine (Lowe et al., 2017) have been
@@ -14,13 +26,15 @@
the current database. If the species is not found, add.obigt() treats
the argument as a file name, as before.
-- Add 'tol' argument to equil.reaction() (convergence tolerance for
- uniroot).
-
- Remove H2O(gas) from the database (taken from SUPCRT92), as it gives
inconsistent results for metastable steam (Zavarin et al., 2016,
LLNL-TR-701407, doi: 10.2172/1325873).
+OTHER CHANGES:
+
+- Add 'tol' argument to equil.reaction() (convergence tolerance for
+ uniroot).
+
- In hkf() and cgl(), combine 'ghs' and 'eos' arguments into single
argument named 'parameters'.
@@ -33,11 +47,6 @@
to calculate (at P, T) so that the calculations aren't duplicated by
subcrt().
-- Add equations from the Deep Earth Water (DEW) model (Sverjensky
- et al., 2014) in the functions calculateDensity(),
- calculateGibbsofWater(), calculateEpsilon(), calculateQ(), and
- the interface function water.DEW() for use by subcrt().
-
- In water.* functions, rename the "diel" variable to "epsilon".
CHANGES IN CHNOSZ 1.1.0 (2017-05-04)
Modified: pkg/CHNOSZ/man/subcrt.Rd
===================================================================
--- pkg/CHNOSZ/man/subcrt.Rd 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/man/subcrt.Rd 2017-09-25 13:31:36 UTC (rev 217)
@@ -262,7 +262,7 @@
## Subzero (degrees C) calculations
# uncomment the following to try IAPWS95 instead of SUPCRT92
-#thermo$opt$water <<- "IAPWS95"
+water("IAPWS95")
# the limit for H2O92D.f (from SUPCRT92) is currently -20 deg C
# but we go to -30 knowing properties will become NA
sb <- subcrt(c("H2O", "Na+"), T=seq(-30, 10), P=1)$out
Modified: pkg/CHNOSZ/man/util.water.Rd
===================================================================
--- pkg/CHNOSZ/man/util.water.Rd 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/man/util.water.Rd 2017-09-25 13:31:36 UTC (rev 217)
@@ -63,7 +63,7 @@
water.IAPWS95("V", T, "Psat")
# the calculated Psat, while not exact, should be close enough for most
# geochemical calculations to select liquid or vapor
-thermo$opt$water <<- "IAPWS95"
+water("IAPWS95")
thermo$opt$IAPWS.sat <<- "vapor"
V.vapor <- subcrt("water", T=convert(445:455, "C"))$out[[1]]$V
thermo$opt$IAPWS.sat <<- "liquid" # the default
Modified: pkg/CHNOSZ/man/water.Rd
===================================================================
--- pkg/CHNOSZ/man/water.Rd 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/man/water.Rd 2017-09-25 13:31:36 UTC (rev 217)
@@ -19,7 +19,7 @@
}
\arguments{
- \item{property}{character, name(s) of property(s) to calculate}
+ \item{property}{character, name(s) of property(s) to calculate, or name of computational option}
\item{T}{numeric, temperature (K)}
\item{P}{numeric, pressure (bar), or \samp{Psat} for vapor-liquid saturation}
\item{formulation}{character, name of formulation for which to return names of available properties}
@@ -32,14 +32,17 @@
\describe{
- \item{\samp{SUPCRT92}}{(Default) Thermodynamic and electrostatic properties are calculated using a FORTRAN subroutine taken from the \acronym{SUPCRT92} software package (Johnson et al., 1992). See more information below.}
+ \item{\samp{SUPCRT92} (default) or \samp{SUPCRT}}{Thermodynamic and electrostatic properties are calculated using a FORTRAN subroutine taken from the \acronym{SUPCRT92} software package (Johnson et al., 1992). See more information below.}
- \item{\samp{IAPWS95}}{Thermodynamic properties are calculated using an implementation in \R code of the \acronym{IAPWS-95} formulation (Wagner and Pruss, 2002), and electrostatic properties are calculated using the equations of Archer and Wang, 1990. See \code{\link{IAPWS95}} and more information below.}
+ \item{\samp{IAPWS95} or \samp{IAPWS}}{Thermodynamic properties are calculated using an implementation in \R code of the \acronym{IAPWS-95} formulation (Wagner and Pruss, 2002), and electrostatic properties are calculated using the equations of Archer and Wang, 1990. See \code{\link{IAPWS95}} and more information below.}
\item{\samp{DEW}}{Thermodynamic and electrostatic properties are calculated using the Deep Earth Water (\acronym{DEW}) model (Sverjensky et al., 2014). The defaults for \code{T} and \code{P} reflect the minimum values for applicability of the model; calculations for lower \code{T} and/or \code{P} points fall back to using \samp{SUPCRT92}. See \code{\link{DEW}}.}
}
+Use e.g. \code{water("DEW")} to set the option.
+Subsequent calculations with \code{water}, or other functions such as \code{subcrt} and \code{affinity}, will use that option.
+
The allowed \code{property}s for \code{water} are one or more of those given below, depending on the computational option; availability is shown by an asterisk.
The names of properties in the arguments are not case sensitive. Note that some of the properties that can actually be calculated using the different formulations are not implemented here.
Except for \code{rho}, the units are those used by Johnson and Norton, 1991.
@@ -129,15 +132,15 @@
## comparing the formulations
T <- convert(c(25, 100, 200, 300), "K")
# IAPWS-95
-thermo$opt$water <<- "IAPWS95"
+water("IAPWS95")
water(water.props(), T=T)
# SUPCRT92 (the default)
-thermo$opt$water <<- "SUPCRT92"
+water("SUPCRT92")
water(water.props(), T=T)
## calculating Q Born function
# after Table 22 of Johnson and Norton, 1991
-thermo$opt$water <<- "SUPCRT92"
+water("SUPCRT92")
T <- rep(c(375, 400, 425, 450, 475), each=5)
P <- rep(c(250, 300, 350, 400, 450), 5)
w <- water("QBorn", T=convert(T, "K"), P=P)
Modified: pkg/CHNOSZ/tests/testthat/test-DEW.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-DEW.R 2017-09-25 11:40:05 UTC (rev 216)
+++ pkg/CHNOSZ/tests/testthat/test-DEW.R 2017-09-25 13:31:36 UTC (rev 217)
@@ -41,3 +41,8 @@
0.10918151, 0.87729257, 0.05068788, 0.20640645) / 1e6
expect_equal(RQ, DEWQ)
})
+
+test_that("Gibbs energies of species are calculated correctly", {
+ DEWG_HCl <- c(-28784.99, -58496.85, -26520.94, -55276.92, -21928.89, -50337.19, -8014.34, -36746.87)
+ DEWG_Cl <- c(-30054.59, -22839.35, -27910.68, -28094.07, -23568.45, -27959.67, -10443.07, -18744.93)
+})
More information about the CHNOSZ-commits
mailing list