[CHNOSZ-commits] r701 - in pkg/CHNOSZ: . R demo inst/extdata/cpetc inst/tinytest man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Feb 7 10:27:29 CET 2022
Author: jedick
Date: 2022-02-07 10:27:29 +0100 (Mon, 07 Feb 2022)
New Revision: 701
Added:
pkg/CHNOSZ/inst/extdata/cpetc/HW97_Cp.csv
pkg/CHNOSZ/inst/extdata/cpetc/HWM96_V.csv
Removed:
pkg/CHNOSZ/inst/extdata/cpetc/Cp.CH4.HW97.csv
pkg/CHNOSZ/inst/extdata/cpetc/V.CH4.HWM96.csv
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/AD.R
pkg/CHNOSZ/demo/00Index
pkg/CHNOSZ/demo/AD.R
pkg/CHNOSZ/inst/tinytest/test-AD.R
pkg/CHNOSZ/man/EOSregress.Rd
pkg/CHNOSZ/man/examples.Rd
pkg/CHNOSZ/man/extdata.Rd
pkg/CHNOSZ/vignettes/eos-regress.Rmd
Log:
Add volume and heat capacity to demo/AD.R
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/DESCRIPTION 2022-02-07 09:27:29 UTC (rev 701)
@@ -1,6 +1,6 @@
Date: 2022-02-07
Package: CHNOSZ
-Version: 1.4.1-26
+Version: 1.4.1-27
Title: Thermodynamic Calculations and Diagrams for Geochemistry
Authors at R: c(
person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),
Modified: pkg/CHNOSZ/R/AD.R
===================================================================
--- pkg/CHNOSZ/R/AD.R 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/R/AD.R 2022-02-07 09:27:29 UTC (rev 701)
@@ -16,9 +16,9 @@
# These calculations are done through (unexported) functions
# to be able to test their output in test-AD.R 20220206
f1 <- .f1(T, P, isPsat)
- drho1_dT <- mapply(.drho1_dT, T, P)
- drho1_dP <- mapply(.drho1_dP, T, P)
- d2rho1_dT2 <- mapply(.d2rho1_dT2, T, P)
+ drho1_dT <- mapply(.drho1_dT, T, P, MoreArgs = list(isPsat = isPsat))
+ drho1_dP <- mapply(.drho1_dP, T, P, MoreArgs = list(isPsat = isPsat))
+ d2rho1_dT2 <- mapply(.d2rho1_dT2, T, P, MoreArgs = list(isPsat = isPsat))
# Calculate other properties of H2O solvent
waterTP <- water(c("rho", "S", "Cp", "V"), T = T, P = P)
@@ -136,7 +136,7 @@
water("rho", T = T, P = P)$rho / 1000
}
-.drho1_dT <- function(T, P) {
+.drho1_dT <- function(T, P, isPsat) {
# Partial derivative of density with respect to temperature at constant pressure 20220206
dT <- 0.1
T1 <- T - dT
@@ -143,11 +143,12 @@
T2 <- T + dT
# Add 1 bar to P so the derivative doesn't blow up when P = Psat at T > 100 degC
# TODO: Is there a better way?
- rho1 <- .rho1(c(T1, T2), P + 1)
+ if(isPsat) P <- P +1
+ rho1 <- .rho1(c(T1, T2), P)
diff(rho1) / (T2 - T1)
}
-.drho1_dP <- function(T, P) {
+.drho1_dP <- function(T, P, isPsat) {
# Partial derivative of density with respect to pressure at constant temperature 20220206
dP <- 0.1
P1 <- P - dP
@@ -154,21 +155,31 @@
P2 <- P + dP
# Subtract 1 degC from T so the derivative doesn't blow up when P = Psat at T > 100 degC
# TODO: Is there a better way?
- rho1 <- .rho1(T - 1, c(P1, P2))
+ if(isPsat) T <- T - 1
+ rho1 <- .rho1(T, c(P1, P2))
diff(rho1) / (P2 - P1)
}
-.d2rho1_dT2 <- function(T, P) {
+.d2rho1_dT2 <- function(T, P, isPsat) {
# Second partial derivative of density with respect to temperature at constant pressure 20220206
- dT <- 0.1
- # Calculate density at five temperature values
- Tval <- seq(T - 2 * dT, T + 2 * dT, dT)
+ # NOTE: dT, Tval, and P <- P + 1 are chosen to produce demo/AD.R;
+ # these may not be the best settings for other T-P ranges 20220207
+ dT <- 0.2
+ # Calculate density at seven temperature values
+ Tval <- seq(T - 3 * dT, T + 3 * dT, dT)
# TODO: Is there a better way to calculate the partial derivative for P = Psat?
- rho1 <- .rho1(Tval, P + 1)
+ if(isPsat) P <- P + 2 else P <- P + 1
+ rho1 <- .rho1(Tval, P)
+ # At P = 281 bar there are identical values of rho1 between T = 683.15 and 683.35 K
+ # Don't allow duplicates because they produce artifacts in the second derivative 20220207
+ if(any(duplicated(rho1))) {
+ message(paste("AD: detected identical values of rho1 in second derivative calculation; returning NA at", T, "K and", P, "bar"))
+ return(NA)
+ }
# https://stackoverflow.com/questions/11081069/calculate-the-derivative-of-a-data-function-in-r
spl <- smooth.spline(Tval, rho1)
- # The second derivative of the fitted spline function at the third point (i.e., T)
- predict(spl, deriv = 2)$y[3]
+ # The second derivative of the fitted spline function at the fourth point (i.e., T)
+ predict(spl, deriv = 2)$y[4]
}
.S1_g <- function(T) {
Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/demo/00Index 2022-02-07 09:27:29 UTC (rev 701)
@@ -27,7 +27,7 @@
TCA Standard Gibbs energies of steps of the citric acid cycle
aluminum Reactions involving Al-bearing minerals
carboxylase Rank abundance distribution for RuBisCO and acetyl-CoA carboxylase
-AD Henry's constant of dissolved gases
+AD Dissolved gases: Henry's constant, volume, and heat capacity
comproportionation Gibbs energy of sulfur comproportionation
Pourbaix Eh-pH diagram for Fe-O-H with equisolubility lines
E_coli Gibbs energy of biomass synthesis in E. coli
Modified: pkg/CHNOSZ/demo/AD.R
===================================================================
--- pkg/CHNOSZ/demo/AD.R 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/demo/AD.R 2022-02-07 09:27:29 UTC (rev 701)
@@ -1,11 +1,21 @@
# CHNOSZ/demo/AD.R
-# calculations using the Akinfiev-Diamond model 20190220
-# after Fig. 1 of Akinfiev and Diamond, 2003
+# Calculate Henry's constant using the Akinfiev-Diamond model 20190220
+# Add volume and heat capacity 20220207
library(CHNOSZ)
+# Start with default settings
+reset()
+# Change energy units to Joules (affects plot labels and subcrt() output)
+E.units("J")
+
+########################
+### HENRY'S CONSTANT ###
+########################
+
# Function to plot natural logarithm of Henry's constant
lines.KH <- function(name = "CO2", T = 1:373, P = "Psat", HKF = FALSE, altH2S = FALSE) {
# use AD or HKF model?
+ if(HKF) add.OBIGT("inorganic_aq")
if(!HKF) add.OBIGT("AD")
# use alternative parameters for H2S? (AD03 Table 1)
if(altH2S) mod.OBIGT("H2S", state = "aq", a = -11.2303, b = 12.6104, c = -0.2102)
@@ -15,12 +25,10 @@
ln_KH <- log(1000/18.0153) + log(10) * sres$out$logK
# plot with units of reciprocal temperature (1000/K)
TK <- convert(T, "K")
- lty <- 1
- if(altH2S) lty <- 2
- if(HKF) lty <- 3
- if(HKF) col <- "red" else col <- "black"
+ if(HKF) lty <- 2 else lty <- 1
+ if(HKF) col <- 2 else col <- 1
+ if(altH2S) lty <- 3
lines(1000/TK, ln_KH, lty = lty, col = col)
- reset()
}
# Set up plot
@@ -42,8 +50,8 @@
points(dat$x, dat$y, pch = dat$pch)
text(3.5, 7.8, quote(italic(P)[sat]))
text(3.05, 9.2, "500 bar")
-legend("bottom", c("Data (AD03, Fig. 1a)", "AD model", "HKF model"),
- lty = c(0, 1, 3), pch = c(1, NA, NA), col = c(1, 1, 2), bty = "n")
+legend("bottom", c("Data (AD03, Fig. 1a)", "AD model", "Revised HKF model"),
+ lty = c(0, 1, 2), pch = c(1, NA, NA), col = c(1, 1, 2), bty = "n")
title(main = syslab(c("CO2", "H2O"), dash = " - "))
# H2 (Fig. 1b of AD03)
@@ -56,8 +64,8 @@
text(1.5, 11, "1000 bar")
dat <- read.csv(system.file("extdata/cpetc/AD03_Fig1b.csv", package = "CHNOSZ"))
points(dat$x, dat$y, pch = dat$pch)
-legend("bottomright", c("Data (AD03, Fig. 1b)", "AD model", "HKF model"),
- lty = c(0, 1, 3), pch = c(1, NA, NA), col = c(1, 1, 2), bty = "n")
+legend("bottomright", c("Data (AD03, Fig. 1b)", "AD model", "Revised HKF model"),
+ lty = c(0, 1, 2), pch = c(1, NA, NA), col = c(1, 1, 2), bty = "n")
title(main = syslab(c("H2", "H2O"), dash = " - "))
# H2S (Fig. 1c of AD03)
@@ -72,8 +80,8 @@
points(dat$x, dat$y, pch = dat$pch)
text(3.4, 6.9, quote(italic(P)[sat]))
text(3.1, 8.6, "1000 bar")
-legend("bottom", c("Data (AD03, Fig. 1c)", "AD model", "AD model (alt. H2S)", "HKF model"),
- lty = c(0, 1, 2, 3), pch = c(1, NA, NA, NA), col = c(1, 1, 1, 2), bty = "n")
+legend("bottom", c("Data (AD03, Fig. 1c)", "AD model", "AD model (alt. H2S)", "Revised HKF model"),
+ lty = c(0, 1, 3, 2), pch = c(1, NA, NA, NA), col = c(1, 1, 1, 2), bty = "n")
title(main = syslab(c("H2S", "H2O"), dash = " - "))
# CH4 (Fig. 1d of AD03)
@@ -83,8 +91,95 @@
dat <- read.csv(system.file("extdata/cpetc/AD03_Fig1d.csv", package = "CHNOSZ"))
points(dat$x, dat$y, pch = dat$pch)
text(3.4, 11, quote(italic(P)[sat]))
-legend("bottomright", c("Data (AD03, Fig. 1d)", "AD model", "HKF model"),
- lty = c(0, 1, 3), pch = c(1, NA, NA), col = c(1, 1, 2), bty = "n")
+legend("bottomright", c("Data (AD03, Fig. 1d)", "AD model", "Revised HKF model"),
+ lty = c(0, 1, 2), pch = c(1, NA, NA), col = c(1, 1, 2), bty = "n")
title(main = syslab(c("CH4", "H2O"), dash = " - "))
+##############
+### VOLUME ###
+##############
+
+# Function to plot volume
+lines.V <- function(species = "CO2", T = seq(300, 440, 1), P = 280, HKF = FALSE) {
+ # Use AD or HKF model?
+ if(HKF) add.OBIGT("inorganic_aq")
+ if(!HKF) add.OBIGT("AD")
+ # Calculate V; use exceed.rhomin to allow HKF calculations in low-density region
+ V <- subcrt(species, T = T, P = P, exceed.rhomin = HKF)$out[[1]]$V
+ if(HKF) lty <- 2 else lty <- 1
+ if(HKF) col <- 2 else col <- "gray20"
+ lines(T, V, lty = lty, col = col, lwd = 1.5)
+}
+
+# Read file with V data for four species
+file <- system.file("extdata/cpetc/HWM96_V.csv", package = "CHNOSZ")
+dat <- read.csv(file)
+# Use data near 280 bar
+dat <- dat[abs(dat$P - 28) < 0.1, ]
+# Setup plot
+par(mfrow = c(2, 2))
+par(mar = c(4, 4, 3, 1))
+par(cex = 1.2)
+par(mgp = c(2.5, 1, 0))
+# Loop over species
+for(species in c("CH4", "CO2", "H2S", "NH3")) {
+ thisdat <- dat[dat$species == species, ]
+ T <- convert(thisdat$T, "C")
+ if(species %in% c("CH4", "CO2")) ylim <- c(0, 2200)
+ if(species %in% c("H2S", "NH3")) ylim <- c(0, 1200)
+ plot(T, thisdat$V, xlim = c(300, 440), ylim = ylim, xlab = axis.label("T"), ylab = axis.label("V"))
+ lines.V(species)
+ lines.V(species, HKF = TRUE)
+ legend("topleft", legend = expr.species(species, use.state = TRUE), bty = "n")
+}
+par(mfrow = c(1, 1))
+plot.window(c(0, 1), c(0, 1))
+box(col = "transparent")
+legend <- c("Hn\u011bdkovsk\u00fd et al. (1996)", "AD model", "Revised HKF model")
+legend(0.26, 0.54, legend, pch = c(1, NA, NA), lty = c(NA, 1, 2), col = c(1, "gray20", 2), lwd = 1.5, inset = c(-10, -10), bty = "n", text.font = 2)
+title(main = "Aqueous nonelectrolytes (280 bar)")
+
+#####################
+### HEAT CAPACITY ###
+#####################
+
+# Function to plot heat capacity
+lines.Cp <- function(species = "CO2", T = seq(300, 440, 1), P = 280, HKF = FALSE) {
+ # Use AD or HKF model?
+ if(HKF) add.OBIGT("inorganic_aq")
+ if(!HKF) add.OBIGT("AD")
+ # Calculate Cp; use exceed.rhomin to allow HKF calculations in low-density region
+ Cp <- subcrt(species, T = T, P = P, exceed.rhomin = HKF)$out[[1]]$Cp
+ if(HKF) lty <- 2 else lty <- 1
+ if(HKF) col <- 2 else col <- "gray20"
+ lines(T, Cp, lty = lty, col = col, lwd = 1.5)
+}
+
+# Read file with Cp data for four species
+file <- system.file("extdata/cpetc/HW97_Cp.csv", package = "CHNOSZ")
+dat <- read.csv(file)
+# Setup plot
+par(mfrow = c(2, 2))
+par(mar = c(4, 4, 3, 1))
+par(cex = 1.2)
+par(mgp = c(2.5, 1, 0))
+# Loop over species
+for(species in c("CH4", "CO2", "H2S", "NH3")) {
+ thisdat <- dat[dat$species == species, ]
+ T <- convert(thisdat$T, "C")
+ if(species %in% c("CH4", "CO2")) ylim <- c(-40000, 40000)
+ if(species %in% c("H2S", "NH3")) ylim <- c(-20000, 20000)
+ plot(T, thisdat$Cp, xlim = c(300, 440), ylim = ylim, xlab = axis.label("T"), ylab = axis.label("Cp"))
+ lines.Cp(species)
+ lines.Cp(species, HKF = TRUE)
+ legend("topleft", legend = expr.species(species, use.state = TRUE), bty = "n")
+# if(species == "CH4") legend("bottomleft", c("Hnedkovsky and Wood (1997)", "AD model", "HKF model"), pch = c(1, NA, NA), lty = c(1, 2), col = c(1, 2))
+}
+par(mfrow = c(1, 1))
+plot.window(c(0, 1), c(0, 1))
+box(col = "transparent")
+legend <- c("Hn\u011bdkovsk\u00fd and Wood (1997)", "AD model", "Revised HKF model")
+legend(0.26, 0.54, legend, pch = c(1, NA, NA), lty = c(NA, 1, 2), col = c(1, "gray20", 2), lwd = 1.5, inset = c(-10, -10), bty = "n", text.font = 2)
+title(main = "Aqueous nonelectrolytes (280 bar)")
+
par(opar)
Deleted: pkg/CHNOSZ/inst/extdata/cpetc/Cp.CH4.HW97.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/cpetc/Cp.CH4.HW97.csv 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/inst/extdata/cpetc/Cp.CH4.HW97.csv 2022-02-07 09:27:29 UTC (rev 701)
@@ -1,16 +0,0 @@
-T,P,Cp
-303.96,28,244.7
-373.58,27.99,210
-448.45,27.99,194.1
-523.31,27.98,230.8
-576.09,28.01,374
-623.24,28,1029
-648.75,28,4480
-661.95,28,21550
-665.95,28.01,9320
-669.15,27.99,-19000
-671.15,28.01,-23590
-674.05,27.98,-16330
-679.15,27.99,-6560
-688.65,28,-2960
-703.75,27.99,-1035
Copied: pkg/CHNOSZ/inst/extdata/cpetc/HW97_Cp.csv (from rev 700, pkg/CHNOSZ/inst/extdata/cpetc/Cp.CH4.HW97.csv)
===================================================================
--- pkg/CHNOSZ/inst/extdata/cpetc/HW97_Cp.csv (rev 0)
+++ pkg/CHNOSZ/inst/extdata/cpetc/HW97_Cp.csv 2022-02-07 09:27:29 UTC (rev 701)
@@ -0,0 +1,90 @@
+species,T,P,Cp
+CH4,303.96,28,244.7
+CH4,373.58,27.99,210
+CH4,448.45,27.99,194.1
+CH4,523.31,27.98,230.8
+CH4,576.09,28.01,374
+CH4,623.24,28,1029
+CH4,648.75,28,4480
+CH4,661.95,28,21550
+CH4,665.95,28.01,9320
+CH4,669.15,27.99,-19000
+CH4,671.15,28.01,-23590
+CH4,674.05,27.98,-16330
+CH4,679.15,27.99,-6560
+CH4,688.65,28,-2960
+CH4,703.75,27.99,-1035
+CO2,303.91,28,208.1
+CO2,373.58,27.98,177.6
+CO2,448.46,27.96,181.6
+CO2,523.31,27.97,214
+CO2,576.09,28.02,308
+CO2,623.23,28.02,839
+CO2,648.75,28,3570
+CO2,661.95,28.01,17040
+CO2,665.95,28,7710
+CO2,669.15,27.99,-15670
+CO2,671.15,28.01,-18420
+CO2,674.05,27.98,-12850
+CO2,679.15,28,-6800
+CO2,688.65,27.99,-2347
+CO2,703.75,28.01,-789
+H2S,304.01,28,170.7
+H2S,373.58,28,139.9
+H2S,448.45,28.04,130.5
+H2S,523.32,28,155.1
+H2S,576.09,27.97,232.6
+H2S,623.23,27.98,633
+H2S,648.75,28.02,2675
+H2S,661.95,28.01,12770
+H2S,665.95,28,4210
+H2S,669.15,28.01,-11220
+H2S,671.15,28.01,-13100
+H2S,674.05,27.98,-9290
+H2S,679.15,28,-4690
+H2S,688.65,27.99,-1731
+H2S,703.75,28,-582
+NH3,303.79,27.99,78
+NH3,373.56,28,88
+NH3,448.44,27.95,107.7
+NH3,523.31,27.99,143.7
+NH3,576.1,28,191.2
+NH3,623.23,27.98,386
+NH3,648.75,27.96,1390
+NH3,661.95,28,6430
+NH3,665.95,28.01,5760
+NH3,669.15,28.01,-3470
+NH3,671.15,28,-6640
+NH3,674.05,27.99,-4910
+NH3,679.15,28,-2390
+NH3,688.65,28.01,-905
+NH3,703.75,28.01,-211.9
+NH3,373.58,27.99,90.7
+NH3,448.46,28.02,109.1
+NH3,523.32,28,141.4
+NH3,576.1,28,187.2
+NH3,623.23,27.99,380
+NH3,648.75,27.96,1348
+NH3,661.95,27.99,6530
+NH3,665.95,28,5050
+NH3,669.15,28.01,-4170
+NH3,671.15,28,-6400
+NH3,674.05,27.99,-4570
+NH3,679.15,28,-2276
+NH3,688.65,28,-792
+NH3,703.75,28.01,-126.1
+NH3,303.74,27.99,78.1
+NH3,373.55,28,92
+NH3,448.46,28.02,112.6
+NH3,523.32,28,139.6
+NH3,576.1,28,190.3
+NH3,623.23,27.99,396
+NH3,648.75,27.97,1414
+NH3,661.95,27.99,6750
+NH3,665.95,28,3560
+NH3,669.15,28,-4840
+NH3,671.15,28,-6090
+NH3,674.05,28,-4230
+NH3,679.15,28,-2103
+NH3,688.65,28.01,-702
+NH3,703.75,28.01,-162.9
Copied: pkg/CHNOSZ/inst/extdata/cpetc/HWM96_V.csv (from rev 700, pkg/CHNOSZ/inst/extdata/cpetc/V.CH4.HWM96.csv)
===================================================================
--- pkg/CHNOSZ/inst/extdata/cpetc/HWM96_V.csv (rev 0)
+++ pkg/CHNOSZ/inst/extdata/cpetc/HWM96_V.csv 2022-02-07 09:27:29 UTC (rev 701)
@@ -0,0 +1,229 @@
+species,T,P,V
+CH4,298.15,28,37.2
+CH4,323.15,28.01,37.5
+CH4,373.15,28,40.7
+CH4,423.15,28,46
+CH4,473.35,27.99,54.4
+CH4,523.15,27.99,65.5
+CH4,573.15,28,92.6
+CH4,623.15,28,167.6
+CH4,653.05,28.01,463
+CH4,657.18,28,608
+CH4,660.34,28,818
+CH4,663.42,28,1183
+CH4,666.25,28,1625
+CH4,668.11,28,1787
+CH4,670.06,28,1754
+CH4,674.53,28.01,1289
+CH4,678.87,28.01,981
+CH4,685.47,28,742
+CH4,705.28,28,476
+CH4,298.15,35,36.3
+CH4,323.15,35,37.1
+CH4,373.15,34.99,40.3
+CH4,423.14,35,45.8
+CH4,473.15,34.99,53.8
+CH4,523.15,35,64.1
+CH4,573.15,35,87.3
+CH4,623.15,35,136.1
+CH4,668.23,34.99,342
+CH4,685.59,35,682
+CH4,694.98,35,761
+CH4,705.45,35,631
+CO2,298.15,1,34.4
+CO2,298.15,20,33.4
+CO2,323.15,20.01,33.8
+CO2,373.15,20,37.8
+CO2,423.15,20,42.7
+CO2,473.35,19.99,50
+CO2,523.15,19.99,61.8
+CO2,573.15,20,84.6
+CO2,623.15,28,133.6
+CO2,653.05,28.01,349
+CO2,657.18,28,476
+CO2,660.33,28,644
+CO2,663.41,28,914
+CO2,666.28,28,1257
+CO2,668.18,28,1397
+CO2,670.06,28,1382
+CO2,674.52,28.01,1040
+CO2,678.87,28.01,811
+CO2,685.46,28,607
+CO2,705.3,28,409
+CO2,298.15,35,33.5
+CO2,323.15,35,33.7
+CO2,373.15,34.99,37.2
+CO2,423.15,35,41.9
+CO2,473.35,34.99,48.4
+CO2,523.15,35,57.7
+CO2,573.15,35,74.1
+CO2,623.15,35,112.8
+CO2,668.23,34.99,283.7
+CO2,685.62,35,570
+CO2,695.14,35,623
+CO2,705.38,35,534
+H2S,298.15,1,34.8
+H2S,298.15,20,34.8
+H2S,323.15,20.01,36
+H2S,373.15,20,39
+H2S,423.15,20,43
+H2S,473.35,19.99,49.2
+H2S,523.15,19.99,58.3
+H2S,573.15,20,76.6
+H2S,623.15,28,113.7
+H2S,653.05,28.01,278.7
+H2S,657.47,28,395
+H2S,660.33,28,513
+H2S,663.42,28,736
+H2S,668.11,28,1120
+H2S,674.55,28,799
+H2S,678.88,28,619
+H2S,685.49,28.01,479
+H2S,705.3,28.01,338
+H2S,298.15,35,35
+H2S,323.15,35,35.8
+H2S,373.15,35,38.4
+H2S,423.15,35,42.5
+H2S,473.35,34.99,47.7
+H2S,523.15,35,55.2
+H2S,573.15,34.99,67.9
+H2S,623.15,35,97.1
+H2S,668.21,35,218.2
+H2S,685.57,35,419
+H2S,694.98,34.99,468
+H2S,705.53,35,405
+NH3,298.16,20,24.63
+NH3,298.15,28.01,24.49
+NH3,373.15,10,26.86
+NH3,382.8,10.68,26.81
+NH3,393.65,10.62,27.24
+NH3,400.75,10.49,27.77
+NH3,403.05,10.5,27.67
+NH3,413.8,10.5,28.35
+NH3,448.27,10.01,30.2
+NH3,523.15,10,37.3
+NH3,573.3,10,49.7
+NH3,623.15,28,63.6
+NH3,653.05,28,139.5
+NH3,657.1,28,171.5
+NH3,660.27,28,231.6
+NH3,663.38,28.01,327
+NH3,666.15,28.01,458
+NH3,668.24,28,540
+NH3,670.1,28,544
+NH3,674.58,28,429
+NH3,678.85,28,342
+NH3,685.41,27.99,281
+NH3,705.23,28,218.8
+NH3,298.15,36.99,24.35
+NH3,373.15,35,26.45
+NH3,448.28,35,29.36
+NH3,523.15,35,35.2
+NH3,573.27,34.99,40.7
+NH3,623.15,35,56.8
+NH3,668.43,35,116.9
+NH3,685.71,35,226.1
+NH3,695.18,35,259.9
+NH3,705.32,35,240.3
+NH3,298.15,0.1,24.8
+NH3,298.15,20,24.91
+NH3,298.15,28,24.34
+NH3,382.83,10.69,27.05
+NH3,623.15,28,63.5
+NH3,653.05,27.99,140.1
+NH3,657.1,28,179.4
+NH3,660.27,28,238.9
+NH3,663.38,28,338
+NH3,666.15,27.99,475
+NH3,668.24,27.99,534
+NH3,670.1,28,539
+NH3,674.58,28,426
+NH3,678.85,28,347
+NH3,685.41,28.01,289.3
+NH3,705.23,28,230
+NH3,298.15,37,24.57
+NH3,668.43,35,118.6
+NH3,685.71,35,227.8
+NH3,695.18,35,261.3
+NH3,705.32,35,239.8
+NH3,298.15,0.1,24.8
+NH3,298.16,20,24.82
+NH3,298.15,28,24.6
+NH3,448.25,9.99,30.4
+NH3,523.15,10,37.6
+NH3,573.28,10.01,50.7
+NH3,623.15,27.99,64.9
+NH3,653.05,28,148.6
+NH3,657.11,28,189.4
+NH3,660.27,28,258.1
+NH3,663.39,28,364
+NH3,666.23,27.99,491
+NH3,668.2,28,535
+NH3,670.1,28,522
+NH3,674.6,28,415
+NH3,678.85,27.99,342
+NH3,685.42,28,290
+NH3,705.23,28,235.1
+NH3,298.15,37,24.3
+NH3,373.15,35,26.4
+NH3,448.27,35,29.5
+NH3,523.15,34.99,34.8
+NH3,573.28,35,41.8
+NH3,623.15,35,57.5
+NH3,668.43,35.01,122.4
+NH3,685.52,35,229
+NH3,695.22,34.99,259.8
+NH3,705.5,34.99,239.2
+NH3,298.15,0.1,24.86
+NH3,298.16,20,24.68
+NH3,298.15,28,24.64
+NH3,382.9,10.68,27.25
+NH3,448.25,10,30.7
+NH3,523.15,10,37.9
+NH3,573.31,10,51.5
+NH3,623.15,27.99,66.4
+NH3,653.15,28,166.4
+NH3,657.12,28,219.1
+NH3,660.29,28,301
+NH3,663.37,28,412
+NH3,666.23,28,508
+NH3,668.19,28,520
+NH3,670.1,27.99,497
+NH3,674.61,28,400
+NH3,678.86,27.99,335
+NH3,685.42,28,287.3
+NH3,705.43,28,239.5
+NH3,298.15,36.99,24.74
+NH3,373.15,35,26.49
+NH3,448.27,35,29.66
+NH3,523.17,35,35.2
+NH3,573.27,34.99,42.4
+NH3,623.15,35,58.8
+NH3,668.43,35,127.2
+NH3,685.61,35,234
+NH3,695.12,34.99,257.7
+NH3,705.39,35,241.8
+NH3,298.15,0.1,24.8
+NH3,298.16,20.01,24.69
+NH3,298.15,28,24.51
+NH3,400.75,10.5,27.87
+NH3,403.05,10.49,27.98
+NH3,413.85,10.5,28.54
+NH3,623.15,27.99,67.8
+NH3,653.05,28.01,184.9
+NH3,657.12,28.01,252.6
+NH3,660.29,28,340
+NH3,663.38,27.99,432
+NH3,666.18,27.99,484
+NH3,668.19,28,475
+NH3,670.09,28,452
+NH3,674.5,28.01,369
+NH3,678.87,28,318
+NH3,685.44,27.99,273.5
+NH3,705.33,28,232.1
+NH3,298.15,37,24.58
+NH3,623.15,35.01,58.8
+NH3,668.42,35,135.4
+NH3,685.67,35.01,235.1
+NH3,695.1,35.01,250.7
+NH3,705.65,35,229.6
Deleted: pkg/CHNOSZ/inst/extdata/cpetc/V.CH4.HWM96.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/cpetc/V.CH4.HWM96.csv 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/inst/extdata/cpetc/V.CH4.HWM96.csv 2022-02-07 09:27:29 UTC (rev 701)
@@ -1,20 +0,0 @@
-T,P,V
-298.15,28,37.2
-323.15,28.01,37.5
-373.15,28,40.7
-423.15,28,46
-473.35,27.99,54.4
-523.15,27.99,65.5
-573.15,28,92.6
-623.15,28,167.6
-653.05,28.01,463
-657.18,28,608
-660.34,28,818
-663.42,28,1183
-666.25,28,1625
-668.11,28,1787
-670.06,28,1754
-674.53,28.01,1289
-678.87,28.01,981
-685.47,28,742
-705.28,28,476
Modified: pkg/CHNOSZ/inst/tinytest/test-AD.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-AD.R 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/inst/tinytest/test-AD.R 2022-02-07 09:27:29 UTC (rev 701)
@@ -30,10 +30,10 @@
sout <- subcrt("CO2", T = T, P = P)$out[[1]]
expect_equal(sout$G, G_ref, tolerance = 13, scale = 1, info = info)
expect_equal(sout$S, S_ref, tolerance = 0.8, scale = 1, info = info)
-expect_equal(sout$Cp[1:3], Cp_ref[1:3], tolerance = 14, scale = 1, info = info)
+expect_equal(sout$Cp[1:3], Cp_ref[1:3], tolerance = 3, scale = 1, info = info)
expect_equal(sout$V[1:3], V_ref[1:3], tolerance = 0.11, scale = 1, info = info)
# Cp and V get much larger, and so do the differences, near the critical point
-expect_equal(sout$Cp[4], Cp_ref[4], tolerance = 1950, scale = 1, info = info)
+expect_equal(sout$Cp[4], Cp_ref[4], tolerance = 800, scale = 1, info = info)
expect_equal(sout$V[4], V_ref[4], tolerance = 24, scale = 1, info = info)
info <- "AD produces correct values for CO2 at 1000 bar"
@@ -46,14 +46,14 @@
# Calculate values using AD model in CHNOSZ
sout <- subcrt("CO2", T = T, P = P)$out[[1]]
expect_equal(sout$G, G_ref, tolerance = 11, scale = 1, info = info)
-expect_equal(sout$S, S_ref, tolerance = 0.09, scale = 1, info = info)
-expect_equal(sout$Cp, Cp_ref, tolerance = 10, scale = 1, info = info)
+expect_equal(sout$S, S_ref, tolerance = 0.1, scale = 1, info = info)
+expect_equal(sout$Cp, Cp_ref, tolerance = 14, scale = 1, info = info)
expect_equal(sout$V, V_ref, tolerance = 0.4, scale = 1, info = info)
info <- "AD gives consistent values of G, H, and S"
T_in_Kelvin <- convert(T, "K")
S_of_elements_in_Joules <- convert(entropy("CO2"), "J")
-expect_equal(sout$H - T_in_Kelvin * sout$S + 298.15 * S_of_elements_in_Joules, sout$G, tolerance = 0.24, scale = 1)
+expect_equal(sout$H - T_in_Kelvin * sout$S + 298.15 * S_of_elements_in_Joules, sout$G)
# 20220206
info <- "Fugacity, density, and density derivatives of H2O are close to values in Akinfiev and Diamond (2003)"
@@ -65,11 +65,11 @@
# g / cm3
expect_equal(CHNOSZ:::.rho1(298.15, 1), 0.9970, tolerance = 0.0001, scale = 1, info = info)
# g / cm3 / K
-expect_equal(CHNOSZ:::.drho1_dT(298.15, 1), -0.0002571, tolerance = 0.000002, scale = 1, info = info)
+expect_equal(CHNOSZ:::.drho1_dT(298.15, 1, FALSE), -0.0002571, tolerance = 0.000002, scale = 1, info = info)
# g / cm3 / bar
-expect_equal(CHNOSZ:::.drho1_dP(298.15, 1), 0.00004511, tolerance = 0.0000001, scale = 1, info = info)
+expect_equal(CHNOSZ:::.drho1_dP(298.15, 1, FALSE), 0.00004511, tolerance = 0.0000001, scale = 1, info = info)
# g / cm3 / K^2
-expect_equal(CHNOSZ:::.d2rho1_dT2(298.15, 1), -0.000009503, tolerance = 0.0000014, scale = 1, info = info)
+expect_equal(CHNOSZ:::.d2rho1_dT2(298.15, 1, FALSE), -0.000009503, tolerance = 0.000007, scale = 1, info = info)
# 20190220 Compare Gibbs energies at 25 degrees calculated with AD model to default OBIGT database
info <- "Gibbs energies at 25 degree C are comparable between AD and default OBIGT database"
Modified: pkg/CHNOSZ/man/EOSregress.Rd
===================================================================
--- pkg/CHNOSZ/man/EOSregress.Rd 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/man/EOSregress.Rd 2022-02-07 09:27:29 UTC (rev 701)
@@ -122,8 +122,11 @@
## fit experimental heat capacities of CH4
## using revised Helgeson-Kirkham-Flowers equations
# read the data from Hnedkovsky and Wood, 1997
-f <- system.file("extdata/cpetc/Cp.CH4.HW97.csv", package="CHNOSZ")
+f <- system.file("extdata/cpetc/HW97_Cp.csv", package="CHNOSZ")
d <- read.csv(f)
+# Use data for CH4
+d <- d[d$species == "CH4", ]
+d <- d[, -1]
# have to convert J to cal and MPa to bar
d$Cp <- convert(d$Cp, "cal")
d$P <- convert(d$P, "bar")
@@ -167,8 +170,12 @@
## model experimental volumes of CH4
## using HKF equation and an exploratory one
-f <- system.file("extdata/cpetc/V.CH4.HWM96.csv", package="CHNOSZ")
+f <- system.file("extdata/cpetc/HWM96_V.csv", package="CHNOSZ")
d <- read.csv(f)
+# Use data for CH4 near 280 bar
+d <- d[d$species == "CH4", ]
+d <- d[, -1]
+d <- d[abs(d$P - 28) < 0.1, ]
d$P <- convert(d$P, "bar")
# the HKF equation
varHKF <- c("invTTheta", "QBorn")
Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/man/examples.Rd 2022-02-07 09:27:29 UTC (rev 701)
@@ -60,7 +60,7 @@
\item{TCA}{Standard Gibbs energies of the tricarboxylic (citric) acid cycle (Canovas and Shock, 2016)}
\item{aluminum}{Reactions involving Al-bearing minerals (Zimmer et al., 2016; Tutolo et al., 2014)}
\item{carboxylase}{Rank abundance distribution for RuBisCO and acetyl-CoA carboxylase}
- \item{AD}{Henry's constant of dissolved gases (Akinfiev and Diamond, 2003)}
+ \item{AD}{Dissolved gases: Henry's constant, volume, and heat capacity (Akinfiev and Diamond, 2003)}
\item{comproportionation}{Gibbs energy of sulfur comproportionation (Amend et al., 2020)}
\item{Pourbaix}{Eh-pH diagram for Fe-O-H with equisolubility lines (Pourbaix, 1974)}
\item{E_coli}{Gibbs energy of biomass synthesis in \emph{E. coli} (LaRowe and Amend, 2016)}
Modified: pkg/CHNOSZ/man/extdata.Rd
===================================================================
--- pkg/CHNOSZ/man/extdata.Rd 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/man/extdata.Rd 2022-02-07 09:27:29 UTC (rev 701)
@@ -27,7 +27,7 @@
\item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Temperature in \degC is in the first column, and heat capacities of the proteins in J mol\eqn{^{-1}}{^-1} K\eqn{^{-1}}{^-1} in the remaining columns. See \code{\link{ionize.aa}} and the vignette \viglink{anintro} for examples that use this file.
\item \code{RH95.csv} Heat capacity data for iron taken from Robie and Hemingway, 1995. Temperature in Kelvin is in the first column, heat capacity in J K\eqn{^{-1}}{^-1} mol\eqn{^{-1}}{^-1} in the second. See \code{\link{subcrt}} for an example that uses this file.
\item \code{SOJSH.csv} Experimental equilibrium constants for the reaction NaCl(aq) = Na+ + Cl- as a function of temperature and pressure taken from Fig. 1 of Shock et al., 1992. See \code{demo("NaCl")} for an example that uses this file.
- \item \code{Cp.CH4.HW97.csv}, \code{V.CH4.HWM96.csv} Apparent molar heat capacities and volumes of CH4 in dilute aqueous solutions reported by Hnědkovský and Wood, 1997 and Hnědkovský et al., 1996. See \code{\link{EOSregress}} and the vignette \viglink{eos-regress} for examples that use these files.
+ \item \code{HWM96_V.csv}, \code{HW97_Cp.csv} Apparent molar volumes and heat capacities of \CH4, \CO2, \H2S, and \NH3 in dilute aqueous solutions reported by Hnědkovský et al., 1996 and Hnědkovský and Wood, 1997. Units are Kelvin, MPa, J/K/mol, and cm3/mol. See \code{\link{EOSregress}} and the vignette \viglink{eos-regress} for examples that use these files.
\item \code{SC10_Rainbow.csv} Values of temperature (\degC), pH and logarithms of activity of \CO2, \H2, \NH4plus, \H2S and \CH4 for mixing of seawater and hydrothermal fluid at Rainbow field (Mid-Atlantic Ridge), taken from Shock and Canovas, 2010. See the vignette \viglink{anintro} for an example that uses this file.
\item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \O2 and pH as a function of temperature for mixing of seawater and hydrothermal fluid, digitized from Figs. 5a and b of Shock and Schulte, 1998. See the vignette \viglink{anintro} for an example that uses this file.
\item \code{rubisco.csv} UniProt IDs for Rubisco, ranges of optimal growth temperature of organisms, domain and name of organisms, and URL of reference for growth temperature, from Dick, 2014. See the vignette \viglink{anintro} for an example that uses this file.
Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2022-02-07 05:26:17 UTC (rev 700)
+++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2022-02-07 09:27:29 UTC (rev 701)
@@ -141,8 +141,11 @@
Here we also convert J to cal and MPa to bar:
```{r Cpdat}
-file <- system.file("extdata/cpetc/Cp.CH4.HW97.csv", package = "CHNOSZ")
+file <- system.file("extdata/cpetc/HW97_Cp.csv", package = "CHNOSZ")
Cpdat <- read.csv(file)
+# Use data for CH4
+Cpdat <- Cpdat[Cpdat$species == "CH4", ]
+Cpdat <- Cpdat[, -1]
Cpdat$Cp <- convert(Cpdat$Cp, "cal")
Cpdat$P <- convert(Cpdat$P, "bar")
```
@@ -192,8 +195,12 @@
First, read the data from @HWM96.
```{r Vdat}
-file <- system.file("extdata/cpetc/V.CH4.HWM96.csv", package = "CHNOSZ")
+file <- system.file("extdata/cpetc/HWM96_V.csv", package = "CHNOSZ")
Vdat <- read.csv(file)
+# Use data for CH4 near 280 bar
+Vdat <- Vdat[Vdat$species == "CH4", ]
+Vdat <- Vdat[abs(Vdat$P - 28) < 0.1, ]
+Vdat <- Vdat[, -1]
Vdat$P <- convert(Vdat$P, "bar")
```
More information about the CHNOSZ-commits
mailing list