From noreply at r-forge.r-project.org Sun Oct 1 05:39:30 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Oct 2017 05:39:30 +0200 (CEST) Subject: [CHNOSZ-commits] r232 - in pkg/CHNOSZ: . R data demo man vignettes Message-ID: <20171001033930.90E53188CF2@r-forge.r-project.org> Author: jedick Date: 2017-10-01 05:39:25 +0200 (Sun, 01 Oct 2017) New Revision: 232 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/EOSregress.R pkg/CHNOSZ/R/cgl.R pkg/CHNOSZ/R/hkf.R pkg/CHNOSZ/R/nonideal.R pkg/CHNOSZ/R/protein.info.R pkg/CHNOSZ/R/util.affinity.R pkg/CHNOSZ/R/util.data.R pkg/CHNOSZ/R/util.formula.R pkg/CHNOSZ/R/util.units.R pkg/CHNOSZ/R/water.R pkg/CHNOSZ/R/wjd.R pkg/CHNOSZ/data/opt.csv pkg/CHNOSZ/demo/wjd.R pkg/CHNOSZ/man/EOSregress.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/util.formula.Rd pkg/CHNOSZ/man/util.units.Rd pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/vignettes/dayhoff.pdf pkg/CHNOSZ/vignettes/wjd.Rnw pkg/CHNOSZ/vignettes/wjd.lyx Log: cleanup: remove thermo$opt$Tr, Pr, Theta, Psi, R Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-01 03:39:25 UTC (rev 232) @@ -1,6 +1,6 @@ Date: 2017-09-30 Package: CHNOSZ -Version: 1.1.0-30 +Version: 1.1.0-31 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/EOSregress.R =================================================================== --- pkg/CHNOSZ/R/EOSregress.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/EOSregress.R 2017-10-01 03:39:25 UTC (rev 232) @@ -19,17 +19,18 @@ EOSvar <- function(var, T, P, ...) { # get the variables of a term in a regression equation # T (K), P (bar) - opt <- get("thermo")$opt + Theta <- 228 # K + Psi <- 2600 # bar out <- switch(EXPR = var, "(Intercept)" = rep(1, length(T)), "T" = T, "P" = P, - "TTheta" = T-opt$Theta, # T-Theta - "invTTheta" = (T-opt$Theta)^-1, # 1/(T-Theta) - "TTheta2" = (T-opt$Theta)^2, # (T-Theta)^2 - "invTTheta2" = (T-opt$Theta)^-2, # 1/(T-Theta)^2 - "invPPsi" = (P+opt$Psi)^-1, # 1/(P-Psi) - "invPPsiTTheta" = (P+opt$Psi)^-1 * (T-opt$Theta)^-1, # 1/[(P-Psi)(T-Theta)] + "TTheta" = T - Theta, # T-Theta + "invTTheta" = (T - Theta)^-1, # 1/(T-Theta) + "TTheta2" = (T - Theta)^2, # (T-Theta)^2 + "invTTheta2" = (T - Theta)^-2, # 1/(T-Theta)^2 + "invPPsi" = (P + Psi)^-1, # 1/(P+Psi) + "invPPsiTTheta" = (P + Psi)^-1 * (T - Theta)^-1, # 1/[(P+Psi)(T-Theta)] "TXBorn" = T*water("XBorn", T=T, P=P)[, 1], "drho.dT" = -water("rho", T=T, P=P)[, 1]*water("E", T=T, P=P)[, 1], "V.kT" = water("V", T=T, P=P)[, 1]*water("kT", T=T, P=P)[, 1], Modified: pkg/CHNOSZ/R/cgl.R =================================================================== --- pkg/CHNOSZ/R/cgl.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/cgl.R 2017-10-01 03:39:25 UTC (rev 232) @@ -4,14 +4,10 @@ cgl <- function(property = NULL, parameters = NULL, T = 298.15, P = 1) { # calculate properties of crystalline, liquid (except H2O) and gas species - # argument handling - thermo <- get("thermo") - Tr <- thermo$opt$Tr - Pr <- thermo$opt$Pr - + Tr <- 298.15 + Pr <- 1 # the number of T, P conditions ncond <- max(c(length(T), length(P))) - # initialize output list out <- list() # loop over each species @@ -27,7 +23,7 @@ for(i in 1:length(property)) { PROP <- property[i] # a test for availability of the EoS parameters - # here we assume that the parameters are in the same position as in thermo$obigt + # here we assume that the parameters are in the same columns as in thermo$obigt # leave T transition (in 20th column) alone hasEOS <- any(!is.na(PAR[, 13:19])) # if at least one of the EoS parameters is available, zero out any NA's in the rest @@ -110,10 +106,10 @@ # the corrections are 0 for anything other than quartz and coesite if(!PAR$name %in% c("quartz", "coesite")) return(list(G=0, H=0, S=0, V=0)) ncond <- max(c(length(T), length(P))) - # get Tr, Pr and TtPr (transition temperature at Pr) - Pr <- get("thermo")$opt$Pr # 1 bar - Tr <- get("thermo")$opt$Tr # 298.15 K - TtPr <- 848 # Kelvin + # Tr, Pr and TtPr (transition temperature at Pr) + Pr <- 1 # bar + Tr <- 298.15 # K + TtPr <- 848 # K # constants from SUP92D.f aa <- 549.824 ba <- 0.65995 Modified: pkg/CHNOSZ/R/hkf.R =================================================================== --- pkg/CHNOSZ/R/hkf.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/hkf.R 2017-10-01 03:39:25 UTC (rev 232) @@ -10,12 +10,11 @@ # calculate G, H, S, Cp, V, kT, and/or E using # the revised HKF equations of state # H2O.props - H2O properties needed for subcrt() output - thermo <- get("thermo") # constants - Tr <- thermo$opt$Tr - Pr <- thermo$opt$Pr - Theta <- thermo$opt$Theta - Psi <- thermo$opt$Psi + Tr <- 298.15 # K + Pr <- 1 # bar + Theta <- 228 # K + Psi <- 2600 # bar # make T and P equal length if(!identical(P, "Psat")) { if(length(P) < length(T)) P <- rep(P, length.out = length(T)) @@ -28,6 +27,7 @@ # rho - for subcrt() output and g function # Born functions and epsilon - for HKF calculations H2O.props <- c(H2O.props, "QBorn", "XBorn", "YBorn", "epsilon") + thermo <- get("thermo") if(grepl("SUPCRT", thermo$opt$water)) { # using H2O92D.f from SUPCRT92: alpha, daldT, beta - for partial derivatives of omega (g function) H2O.props <- c(H2O.props, "alpha", "daldT", "beta") @@ -40,7 +40,7 @@ # using DEW model: get beta to calculate dgdP H2O.props <- c(H2O.props, "beta") } - H2O <- water(H2O.props, T = c(thermo$opt$Tr, T), P = c(thermo$opt$Pr, P)) + H2O <- water(H2O.props, T = c(Tr, T), P = c(Pr, P)) H2O.PrTr <- H2O[1, ] H2O.PT <- H2O[-1, ] ZBorn <- -1 / H2O.PT$epsilon Modified: pkg/CHNOSZ/R/nonideal.R =================================================================== --- pkg/CHNOSZ/R/nonideal.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/nonideal.R 2017-10-01 03:39:25 UTC (rev 232) @@ -26,11 +26,12 @@ # Alberty, 2003 Eq. 3.6-1 loggamma <- function(a,Z,I,B) { - a * Z^2 * I^(1/2) / (1 + B * I^(1/2)) } # TODO: check the following equations 20080208 jmd + R <- 1.9872 # gas constant, cal K^-1 mol^-1 if(prop=='log') return(loggamma(eval(A),Z,I,B)) - else if(prop=='G') return(thermo$opt$R * T * loggamma(eval(A),Z,I,B)) - else if(prop=='H') return(thermo$opt$R * T^2 * loggamma(eval(DD(A,'T',1)),Z,I,B)) - else if(prop=='S') return(- thermo$opt$R * T * loggamma(eval(DD(A,'T',1)),Z,I,B)) - else if(prop=='Cp') return(thermo$opt$R * T^2 *loggamma(eval(DD(A,'T',2)),Z,I,B)) + else if(prop=='G') return(R * T * loggamma(eval(A),Z,I,B)) + else if(prop=='H') return(R * T^2 * loggamma(eval(DD(A,'T',1)),Z,I,B)) + else if(prop=='S') return(- R * T * loggamma(eval(DD(A,'T',1)),Z,I,B)) + else if(prop=='Cp') return(R * T^2 *loggamma(eval(DD(A,'T',2)),Z,I,B)) } if(!is.numeric(species[[1]])) species <- info(species,'aq') proptable <- as.list(proptable) @@ -50,7 +51,7 @@ if(species[i] == info("e-") & thermo$opt$ideal.e) next didit <- FALSE for(j in 1:ncol(myprops)) { - #if(colnames(myprops)[j]=='G') myprops[,j] <- myprops[,j] + thermo$opt$R * T * mlg(Z,IS,convert(T,'C')) + #if(colnames(myprops)[j]=='G') myprops[,j] <- myprops[,j] + R * T * mlg(Z,IS,convert(T,'C')) cname <- colnames(myprops)[j] if(cname %in% c('G','H','S','Cp')) { myprops[,j] <- myprops[,j] + loggamma2(Z,IS,T,cname) Modified: pkg/CHNOSZ/R/protein.info.R =================================================================== --- pkg/CHNOSZ/R/protein.info.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/protein.info.R 2017-10-01 03:39:25 UTC (rev 232) @@ -191,7 +191,8 @@ G0protform <- G0protform + G0ionization } # standard Gibbs energy of formation reaction of non/ionized residue equivalents, dimensionless - G0res.RT <- G0protform/thermo$opt$R/TK/plength + R <- 1.9872 # gas constant, cal K^-1 mol^-1 + G0res.RT <- G0protform/R/TK/plength message("protein.equil [1]: per residue, reaction to form ", iword, " protein from basis species has G0/RT of ", signif(G0res.RT[1], digits)) # coefficients of basis species in formation reactions of residues resbasis <- suppressMessages(protein.basis(aa, T=T, normalize=TRUE)) Modified: pkg/CHNOSZ/R/util.affinity.R =================================================================== --- pkg/CHNOSZ/R/util.affinity.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/util.affinity.R 2017-10-01 03:39:25 UTC (rev 232) @@ -17,7 +17,7 @@ ### unexported functions ### -energy <- function(what,vars,vals,lims,T=get("thermo")$opt$Tr,P="Psat",IS=0,sout=NULL,exceed.Ttr=FALSE,transect=FALSE) { +energy <- function(what,vars,vals,lims,T=298.15,P="Psat",IS=0,sout=NULL,exceed.Ttr=FALSE,transect=FALSE) { # 20090329 extracted from affinity() and made to # deal with >2 dimensions (variables) @@ -235,7 +235,7 @@ transect <- any(sapply(args,length) > 3) ## convert T, P args and take care of # single values for T, P or IS - T <- thermo$opt$Tr + T <- 298.15 P <- "Psat" IS <- 0 T.is.var <- P.is.var <- IS.is.var <- FALSE @@ -371,7 +371,7 @@ return(args) } -A.ionization <- function(iprotein, vars, vals, T=get("thermo")$opt$Tr, P="Psat", pH=7, transect=FALSE) { +A.ionization <- function(iprotein, vars, vals, T=298.15, P="Psat", pH=7, transect=FALSE) { # a function to build a list of values of A/2.303RT of protein ionization # that can be used by energy(); 20120527 jmd # some of the variables might not affect the values (e.g. logfO2) Modified: pkg/CHNOSZ/R/util.data.R =================================================================== --- pkg/CHNOSZ/R/util.data.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/util.data.R 2017-10-01 03:39:25 UTC (rev 232) @@ -156,6 +156,7 @@ # 20110808 jmd thermo <- get("thermo") # get calculated value based on EOS + Theta <- 228 # K if(identical(state, "aq")) { if(prop=="Cp") { # value of X consistent with IAPWS95 @@ -163,7 +164,7 @@ # we use the value of X consistent with SUPCRT X <- -3.055586E-7 refval <- eos$Cp - calcval <- eos$c1 + eos$c2/(298.15-thermo$opt$Theta)^2 + eos$omega*298.15*X + calcval <- eos$c1 + eos$c2/(298.15-Theta)^2 + eos$omega*298.15*X tol <- thermo$opt$Cp.tol units <- "cal K-1 mol-1" } else if(prop=="V") { @@ -173,7 +174,7 @@ Q <- 0.00002775729 refval <- eos$V calcval <- 41.84*eos$a1 + 41.84*eos$a2/2601 + - (41.84*eos$a3 + 41.84*eos$a4/2601) / (298.15-thermo$opt$Theta) - Q * eos$omega + (41.84*eos$a3 + 41.84*eos$a4/2601) / (298.15-Theta) - Q * eos$omega tol <- thermo$opt$V.tol units <- "cm3 mol-1" } @@ -181,7 +182,7 @@ # all other states if(prop=="Cp") { refval <- eos$Cp - Tr <- thermo$opt$Tr + Tr <- 298.15 calcval <- eos$a + eos$b*Tr + eos$c*Tr^-2 + eos$d*Tr^-0.5 + eos$e*Tr^2 + eos$f*Tr^eos$lambda tol <- thermo$opt$Cp.tol units <- "cal K-1 mol-1" @@ -222,7 +223,8 @@ refval <- ghs[,8] DH <- ghs[,9] S <- ghs[,10] - calcval <- DH - thermo$opt$Tr * (S - Se) + Tr <- 298.15 + calcval <- DH - Tr * (S - Se) # now on to the comparison # calculate the difference diff <- calcval - refval Modified: pkg/CHNOSZ/R/util.formula.R =================================================================== --- pkg/CHNOSZ/R/util.formula.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/util.formula.R 2017-10-01 03:39:25 UTC (rev 232) @@ -80,7 +80,7 @@ return(entropy) } -GHS <- function(formula, G=NA, H=NA, S=NA, T=get("thermo")$opt$Tr) { +GHS <- function(formula, G=NA, H=NA, S=NA, T=298.15) { # for all NA in G, H and S, do nothing # for no NA in G, H and S, do nothing # for one NA in G, H and S, calculate its value from the other two: Modified: pkg/CHNOSZ/R/util.units.R =================================================================== --- pkg/CHNOSZ/R/util.units.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/util.units.R 2017-10-01 03:39:25 UTC (rev 232) @@ -40,8 +40,8 @@ message("changed energy units to ", get("thermo")$opt$E.units) } -convert <- function(value, units, T=get("thermo")$opt$Tr, - P=get("thermo")$opt$Pr, pH=7, logaH2O=0) { +convert <- function(value, units, T=298.15, + P=1, pH=7, logaH2O=0) { # converts value(s) to the specified units if(is.null(value)) return(NULL) @@ -65,7 +65,7 @@ if(units=='cal') value <- value / Jcal } else if(units %in% c('g','logk')) { - R <- get("thermo")$opt$R + R <- 1.9872 # gas constant, cal K^-1 mol^-1 if(units=='logk') value <- value / (-log(10) * R * T) if(units=='g') value <- value * (-log(10) * R * T) } Modified: pkg/CHNOSZ/R/water.R =================================================================== --- pkg/CHNOSZ/R/water.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/water.R 2017-10-01 03:39:25 UTC (rev 232) @@ -2,7 +2,7 @@ # calculate thermodynamic and electrostatic properties of H2O # 20061016 jmd -water <- function(property = NULL, T = get("thermo")$opt$Tr, P = "Psat") { +water <- function(property = NULL, T = 298.15, P = "Psat") { # calculate the properties of liquid H2O as a function of T and P # T in Kelvin, P in bar if(is.null(property)) return(get("thermo")$opt$water) @@ -156,15 +156,16 @@ return(convert(P, "bar")) } ## thermodynamic properties + Tr <- 298.15 # convert to SUPCRT reference state # at the triple point # I2S = SUPCRT - IAPWS ( + entropy in G ) dH <- -68316.76 - 451.75437 dS <- 16.7123 - 1.581072 - dG <- -56687.71 + 19.64228 - dS * (T - get("thermo")$opt$Tr) + dG <- -56687.71 + 19.64228 - dS * (T - Tr) # does the reference state used for GHS also go here? dU <- -67434.5 - 451.3229 - dA <- -55814.06 + 20.07376 - dS * (T - get("thermo")$opt$Tr) + dA <- -55814.06 + 20.07376 - dS * (T - Tr) # calculate pressure from the given T and estimated rho pressure <- function() return(convert(IAPWS95("p", T=T, rho=my.rho), "bar")) # convert IAPWS95() (specific, joule) to (molar, cal) @@ -344,7 +345,7 @@ ilow <- T < 373.15 | P < 1000 if(any(ilow)) { out[ilow, ] <- water.SUPCRT92(property, T=T[ilow], P=P[ilow]) - iPrTr <- T==get("thermo")$opt$Tr & P==get("thermo")$opt$Pr + iPrTr <- T == 298.15 & P == 1 if(sum(iPrTr)==sum(ilow)) message(paste("water.DEW: using SUPCRT calculations for Pr,Tr")) if(sum(iPrTr)==0) message(paste("water.DEW: using SUPCRT calculations for", sum(ilow), "low-T or low-P condition(s)")) if(sum(iPrTr)==1 & sum(ilow) > sum(iPrTr)) message(paste("water.DEW: using SUPCRT calculations for Pr,Tr and", sum(ilow)-1, "other low-T or low-P condition(s)")) Modified: pkg/CHNOSZ/R/wjd.R =================================================================== --- pkg/CHNOSZ/R/wjd.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/R/wjd.R 2017-10-01 03:39:25 UTC (rev 232) @@ -359,7 +359,8 @@ ## assemble the standard molal Gibbs energies of the species s <- subcrt(ispecies, P=P, T=T, property="G", exceed.Ttr=TRUE) G0 <- sapply(1:length(s$out), function(i) s$out[[i]]$G) - G0.RT <- G0/get("thermo")$opt$R/convert(T, "K") + R <- 1.9872 # gas constant, cal K^-1 mol^-1 + G0.RT <- G0/R/convert(T, "K") ## if Y is provided use that as initial guess if(!missing(Y)) { # giving both Y and B is not allowed @@ -416,6 +417,7 @@ equil.potentials <- function(w, tol=0.01, T=25) { ## return the average of the element.potentials, only if w is.near.equil 20120613 + R <- 1.9872 # gas constant, cal K^-1 mol^-1 if(!is.near.equil(w, tol=tol)) return(NULL) - else return(colMeans(element.potentials(w)) * get("thermo")$opt$R * convert(T, "K")) + else return(colMeans(element.potentials(w)) * R * convert(T, "K")) } Modified: pkg/CHNOSZ/data/opt.csv =================================================================== --- pkg/CHNOSZ/data/opt.csv 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/data/opt.csv 2017-10-01 03:39:25 UTC (rev 232) @@ -1,2 +1,2 @@ -Tr,Pr,Theta,Psi,R,cutoff,E.units,T.units,P.units,state,water,G.tol,Cp.tol,V.tol,varP,IAPWS.sat,paramin,ideal.H,ideal.e -298.15,1,228,2600,1.9872,1e-10,cal,C,bar,aq,SUPCRT92,100,1,1,FALSE,liquid,1000,TRUE,TRUE +cutoff,E.units,T.units,P.units,state,water,G.tol,Cp.tol,V.tol,varP,IAPWS.sat,paramin,ideal.H,ideal.e +1E-10,cal,C,bar,aq,SUPCRT92,100,1,1,FALSE,liquid,1000,TRUE,TRUE Modified: pkg/CHNOSZ/demo/wjd.R =================================================================== --- pkg/CHNOSZ/demo/wjd.R 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/demo/wjd.R 2017-10-01 03:39:25 UTC (rev 232) @@ -7,7 +7,9 @@ # turn formulas into a stoichiometric matrix A <- i2A(dlen$formula) # assemble Gibbs energies/RT at 500 K -G0.RT <- 1000 * dlen$G500 / thermo$opt$R / thermo$opt$Tr +T <- 500 # K +R <- 1.9872 # gas constant, cal K^-1 mol^-1 +G0.RT <- 1000 * dlen$G500 / R / T # a function to minimize Gibbs energy for system with # given mole fraction of carbon (xC) min.atmos <- function(xC) { Modified: pkg/CHNOSZ/man/EOSregress.Rd =================================================================== --- pkg/CHNOSZ/man/EOSregress.Rd 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/man/EOSregress.Rd 2017-10-01 03:39:25 UTC (rev 232) @@ -149,7 +149,8 @@ title("Cp from EOS parameters in database") # continuing from above, with user-defined variables -invTTTheta3 <- function(T, P) (2*T)/(T-T*thermo$opt$Theta)^3 +Theta <- 228 # K +invTTTheta3 <- function(T, P) (2*T)/(T-T*Theta)^3 invTX <- function(T, P) 1/T*water("XBorn", T=T, P=P)[,1] # print the calculated values of invTTTheta3 EOSvar("invTTTheta3", d$T, d$P) Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/man/data.Rd 2017-10-01 03:39:25 UTC (rev 232) @@ -44,20 +44,14 @@ \itemize{ \item \code{thermo$opt} - List of operational parameters. Square brackets indicate default values. + List of computational settings. Square brackets indicate default values. \tabular{lll}{ - \code{Tr} \tab numeric \tab Reference temperature (K) [298.15]\cr - \code{Pr} \tab numeric \tab Reference pressure (bar) [1]\cr - \code{Theta} \tab numeric \tab \eqn{\Theta}{Theta} in the revised HKF equations of state (K) [228]\cr - \code{Psi} \tab numeric \tab \eqn{\Psi}{Psi} in the revised HKF equations of state (bar) [2600]\cr - \code{R} \tab numeric \tab Value of the gas constant (cal K\ifelse{latex}{\eqn{^{-1}}}{\ifelse{html}{\out{-1}}{^-1}} mol\ifelse{latex}{\eqn{^{-1}}}{\ifelse{html}{\out{-1}}{^-1}}) [1.9872]\cr \code{cutoff} \tab numeric \tab Cutoff below which values are taken to be zero [1e-10] (see \code{\link{makeup}})\cr - \code{E.units} \tab character \tab The user's units of energy ([\samp{cal}] or \samp{J})\cr + \code{E.units} \tab character \tab The user's units of energy ([\samp{cal}] or \samp{J}) (see \code{\link{subcrt}})\cr \code{T.units} \tab character \tab The user's units of temperature ([\samp{C}] or \samp{K})\cr \code{P.units} \tab character \tab The user's units of pressure ([\samp{bar}] or \samp{MPa})\cr - \code{state} \tab character \tab The default physical state for searching species [\samp{aq}]\cr - \code{water} \tab character \tab Computational option for properties of water ([\samp{SUPCRT}] or \samp{IAPWS})\cr - \code{online} \tab logical \tab Allow online searches of protein composition? Default [\code{NA}] is to ask the user.\cr + \code{state} \tab character \tab The default physical state for searching species [\samp{aq}] (see \code{\link{info}})\cr + \code{water} \tab character \tab Computational option for properties of water ([\samp{SUPCRT}] or \samp{IAPWS}; see \code{\link{water}})\cr \code{G.tol} \tab numeric \tab Difference in G above which \code{\link{checkGHS}} produces a message (cal mol\ifelse{latex}{\eqn{^{-1}}}{\ifelse{html}{\out{-1}}{^-1}}) [100]\cr \code{Cp.tol} \tab numeric \tab Difference in Cp above which \code{\link{checkEOS}} produces a message (cal K\ifelse{latex}{\eqn{^{-1}}}{\ifelse{html}{\out{-1}}{^-1}} mol\ifelse{latex}{\eqn{^{-1}}}{\ifelse{html}{\out{-1}}{^-1}}) [1]\cr \code{V.tol} \tab numeric \tab Difference in V above which \code{\link{checkEOS}} produces a message (cm\ifelse{latex}{\eqn{^{3}}}{\ifelse{html}{\out{3}}{^3}} mol\ifelse{latex}{\eqn{^{-1}}}{\ifelse{html}{\out{-1}}{^-1}}) [1]\cr Modified: pkg/CHNOSZ/man/util.formula.Rd =================================================================== --- pkg/CHNOSZ/man/util.formula.Rd 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/man/util.formula.Rd 2017-10-01 03:39:25 UTC (rev 232) @@ -17,7 +17,7 @@ as.chemical.formula(makeup, drop.zero = TRUE) mass(formula) entropy(formula) - GHS(formula, G = NA, H = NA, S = NA, T = get("thermo")$opt$Tr) + GHS(formula, G = NA, H = NA, S = NA, T = 298.15) ZC(formula) i2A(formula) } Modified: pkg/CHNOSZ/man/util.units.Rd =================================================================== --- pkg/CHNOSZ/man/util.units.Rd 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/man/util.units.Rd 2017-10-01 03:39:25 UTC (rev 232) @@ -14,8 +14,7 @@ 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) + convert(value, units, T = 298.15, P = 1, pH = 7, logaH2O = 0) } \arguments{ Modified: pkg/CHNOSZ/man/water.Rd =================================================================== --- pkg/CHNOSZ/man/water.Rd 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/man/water.Rd 2017-10-01 03:39:25 UTC (rev 232) @@ -10,7 +10,7 @@ } \usage{ - water(property = NULL, T = get("thermo")$opt$Tr, P = "Psat") + water(property = NULL, T = 298.15, P = "Psat") water.SUPCRT92(property=NULL, T = 298.15, P = 1) water.IAPWS95(property=NULL, T = 298.15, P = 1) water.DEW(property=NULL, T = 373.15, P = 1000) Modified: pkg/CHNOSZ/vignettes/dayhoff.pdf =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/vignettes/wjd.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/wjd.Rnw 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/vignettes/wjd.Rnw 2017-10-01 03:39:25 UTC (rev 232) @@ -1,4 +1,4 @@ -%% LyX 2.2.2 created this file. For more info, see http://www.lyx.org/. +%% LyX 2.2.3 created this file. For more info, see http://www.lyx.org/. %% Do not edit unless you really know what you are doing. \documentclass[english,noae,round]{article} \usepackage{mathpazo} @@ -17,7 +17,6 @@ \hypersetup{pdftitle={Winding journey down (in Gibbs energy)}, pdfauthor={Jeffrey M. Dick}, citecolor=blue} -\usepackage{breakurl} \makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. @@ -69,7 +68,6 @@ data(thermo) @ - \section{Is it winding?} The ``winding'' in the title refers to the observation that the @@ -158,7 +156,6 @@ identical(diff(w$F.Y), sort(diff(w$F.Y))) @ - \section{Is it near the bottom? Testing for equilibrium} @@ -215,7 +212,6 @@ w3 <- wjd(imax=3) ep3 <- element.potentials(w3, plot.it=TRUE) @ - \end{center} \setkeys{Gin}{width=1.0\textwidth} @@ -251,7 +247,6 @@ is.near.equil(w, tol=0.00001) @ - \subsection{Different initial solutions yield similar results} \paragraph{Different guesses for an underdetermined system} @@ -409,7 +404,9 @@ # turn formulas into a stoichiometric matrix A <- i2A(dlen$formula) # assemble Gibbs energies/RT at 500 K -G0.RT <- 1000 * dlen$G500 / thermo$opt$R / thermo$opt$Tr +T <- 500 # K +R <- 1.9872 # gas constant, cal K^-1 mol^-1 +G0.RT <- 1000 * dlen$G500 / R / T # a function to minimize Gibbs energy for system with # given mole fraction of carbon (xC) min.atmos <- function(xC) { @@ -452,7 +449,6 @@ # text(35, log10(Xs[, 27]) + 0.5, dlen$formula, adj=0) # text(7, log10(Xs[, 1]), dlen$formula, adj=1) @ - \begin{center} \includegraphics[width=0.7\columnwidth]{dayhoff} \par\end{center} @@ -536,7 +532,6 @@ basis.logact(ep) @ - \subsection{Bulk composition instead of moles of species} \texttt{run.wjd()} can be given B (bulk chemical composition), instead @@ -562,7 +557,6 @@ basis.logact(ep) @ - \section{Document History} \begin{itemize} \item 2012-01-01 Initial version Modified: pkg/CHNOSZ/vignettes/wjd.lyx =================================================================== --- pkg/CHNOSZ/vignettes/wjd.lyx 2017-09-30 02:19:19 UTC (rev 231) +++ pkg/CHNOSZ/vignettes/wjd.lyx 2017-10-01 03:39:25 UTC (rev 232) @@ -2092,11 +2092,21 @@ \begin_layout Plain Layout -G0.RT <- 1000 * dlen$G500 / thermo$opt$R / thermo$opt$Tr +T <- 500 # K \end_layout \begin_layout Plain Layout +R <- 1.9872 # gas constant, cal K^-1 mol^-1 +\end_layout + +\begin_layout Plain Layout + +G0.RT <- 1000 * dlen$G500 / R / T +\end_layout + +\begin_layout Plain Layout + # a function to minimize Gibbs energy for system with \end_layout From noreply at r-forge.r-project.org Sun Oct 1 10:40:38 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Oct 2017 10:40:38 +0200 (CEST) Subject: [CHNOSZ-commits] r233 - in pkg/CHNOSZ: . R data demo inst inst/extdata/OBIGT man Message-ID: <20171001084038.BC468188C44@r-forge.r-project.org> Author: jedick Date: 2017-10-01 10:40:37 +0200 (Sun, 01 Oct 2017) New Revision: 233 Added: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/data/thermo.R pkg/CHNOSZ/demo/activity_ratios.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz pkg/CHNOSZ/man/subcrt.Rd Log: add Berman_cr.csv Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-01 08:40:37 UTC (rev 233) @@ -1,6 +1,6 @@ -Date: 2017-09-30 +Date: 2017-10-01 Package: CHNOSZ -Version: 1.1.0-31 +Version: 1.1.0-32 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/R/info.R 2017-10-01 08:40:37 UTC (rev 233) @@ -73,7 +73,7 @@ return(out) } -info.character <- function(species, state=NULL, check.protein=TRUE) { +info.character <- function(species, state=NULL, check.protein=TRUE, grep.state=FALSE) { # returns the rownumbers of thermo$obigt having an exact match of 'species' to # thermo$obigt$[species|abbrv|formula] or NA otherwise # a match to thermo$obigt$state is also required if 'state' is not NULL @@ -113,7 +113,8 @@ # special treatment for H2O: aq retrieves the liq if(species %in% c("H2O", "water") & state=="aq") state <- "liq" # the matches for both species and state - matches.state <- matches.species & grepl(state, get("thermo")$obigt$state) + if(grep.state) matches.state <- matches.species & grepl(state, thermo$obigt$state) + else matches.state <- matches.species & state == thermo$obigt$state if(!any(matches.state)) { # the requested state is not available for this species available.states <- thermo$obigt$state[matches.species] @@ -160,19 +161,19 @@ # use new obigt2eos function here this <- obigt2eos(this, this$state) # identify any missing GHS values - naGHS <- which(is.na(this[8:10])) + naGHS <- is.na(this[8:10]) # a missing one of G, H or S can cause problems for subcrt calculations at high T - if(length(naGHS)==1) { + if(sum(naGHS)==1) { # calculate a single missing one of G, H, or S from the others GHS <- as.numeric(GHS(as.character(this$formula), G=this[,8], H=this[,9], S=this[,10])) message("info.numeric: ", colnames(this)[8:10][naGHS], " of ", this$name, "(", this$state, ") is NA; set to ", round(GHS[naGHS],2)) - this[, naGHS+7] <- GHS[naGHS] + this[, which(naGHS)+7] <- GHS[naGHS] } # now perform consistency checks for GHS and EOS parameters if check.it=TRUE if(check.it) { # check GHS if they were all present - if(length(naGHS)==0) calcG <- checkGHS(this) + if(sum(naGHS)==0) calcG <- checkGHS(this) # check tabulated heat capacities against EOS parameters calcCp <- checkEOS(this, this$state, "Cp") # fill in NA heat capacity Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-01 08:40:37 UTC (rev 233) @@ -122,7 +122,7 @@ for(i in 1:length(species)) { mysearch <- species[i] if(can.be.numeric(mysearch)) mysearch <- thermo$obigt$name[as.numeric(mysearch)] - si <- info.character(mysearch, state[i]) + si <- info.character(mysearch, state[i], grep.state=TRUE) # that could have the side-effect of adding a protein; re-read thermo thermo <- get("thermo", "CHNOSZ") if(is.na(si[1])) stop('no info found for ',species[i],' ',state[i]) Modified: pkg/CHNOSZ/data/thermo.R =================================================================== --- pkg/CHNOSZ/data/thermo.R 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/data/thermo.R 2017-10-01 08:40:37 UTC (rev 233) @@ -10,7 +10,7 @@ local({ # create obigt data frame sources_aq <- paste0(c("H2O", "inorganic", "organic", "biotic"), "_aq") - sources_cr <- paste0(c("inorganic", "organic"), "_cr") + sources_cr <- paste0(c("inorganic", "organic", "Berman"), "_cr") sources_liq <- paste0(c("organic"), "_liq") sources_gas <- paste0(c("inorganic", "organic"), "_gas") OBIGTdir <- system.file("extdata/OBIGT/", package="CHNOSZ") Modified: pkg/CHNOSZ/demo/activity_ratios.R =================================================================== --- pkg/CHNOSZ/demo/activity_ratios.R 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/demo/activity_ratios.R 2017-10-01 08:40:37 UTC (rev 233) @@ -13,7 +13,7 @@ # make the pseudospecies H4SiO4 available for use as a basis species add.obigt("CHNOSZ_aq", "pseudo-H4SiO4") basis(c("Al+3", "pseudo-H4SiO4", "K+", "H2O", "H+", "O2")) -species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "k-feldspar")) +species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "K-feldspar")) a <- affinity(H4SiO4 = c(-6, -2, res), `K+` = c(-3, 6, res)) diagram(a, ylab = ratlab("K+"), fill = fill, yline = 1.7) title(main = syslab(c("K2O", "Al2O3", "SiO2", "H2O"))) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/inst/NEWS 2017-10-01 08:40:37 UTC (rev 233) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-30 (2017-09-30) +CHANGES IN CHNOSZ 1.1.0-32 (2017-10-01) --------------------------------------- MAJOR CHANGES: @@ -26,6 +26,12 @@ species) to their defaults. data(thermo) is still used to reset *everything* (the database and all computational and system settings). +- In add.obigt(), using 'file' without a file suffix now can be used to + locate corresponding files (such as CHNOSZ_aq.csv or DEW_aq.csv) in + the extdata/OBIGT package directory. + +- add.obigt() gets new argument 'species' for selecting species to add. + DATABASE UPDATES: - Add DEW_aq.csv with aqueous species data from the DEW spreadsheet @@ -33,12 +39,11 @@ database in CHNOSZ are not included. For the time being, only selected species are fully referenced. -- In add.obigt(), using 'file' without a file suffix now can be used to - locate corresponding files (such as CHNOSZ_aq.csv or DEW_aq.csv) in - the extdata/OBIGT package directory. +- Add Berman_cr.csv with names and formulas for minerals whose + thermodynamic properties are calculated using the Berman (1988) + formulation. The state "cr_Berman" is used to distinguish these + minerals from the Helgeson data. -- add.obigt() gets new argument 'species' for selecting species to add. - - 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 Added: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Property changes on: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz ___________________________________________________________________ Added: svn:mime-type + application/x-xz Modified: pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz 2017-10-01 08:40:37 UTC (rev 233) @@ -1,66 +1,58 @@ -?7zXZ???F!t/?????&[]7I??b???9??????TB;q?"?q???cL;?"??&?K?0??u?`iB?????As??L#?S?+Wssu???f??W??  M6??b?,"/?u??NO??_?w???d?$?4??'?cdv??L:???/7????H??? )@w?-?????|???/???(#bg?Z,??M????NK?r?">:?)O?vH 6vB?)i?s|?,??H?)????% ??(??A? -??hP?7??q???A??Z????-?-?z???# ->?40rw?RJ??? ??j?????gS???N?c?L??e?B?W?????M?????zR3W?M??b?$)??S????w{G3??i'}?????"?6??5??QHN?5]d?I??????o ??r??????1-e??B????Q??N??????P??"?cP??/??[_b??B?a??Kb[yy?7f????%v!"?? F??? -?????)?&15?3??,s??q?sLHU?'?o: ?1??$O??td???sa?^W????? ???CpHnA?)?D5A??:A0!?A???z??ga??f}? D???GRUZM??9?J~Z???????b????q??????y??,?LBDT fRC??????9m?'iY :?pKi_]XJ?d? ?? ??R??(T????N???j?????9-?2=?,o?/???:?9??????S??32 EQ???^???u8?h)???y?????=*???6?!<???v?q39OMp53?????%Mx4`?2?`?9??A?K?*d(/? #??????Az???qlg????????2?F?83?A?n?s?? U? ?q?"???jo???v/????H??? ???[??~??L?m???-i??:?yn?jx???:?B ?4??cx????}q?P36 L?_V ?????D? -??? 6a?to??Y???*?? Lg??I5P16??C???????O`W?1nS???i??????????3?Z?ES???$z -}-??P.??L?9????vrP??0?n/?? ?5?????\T????????Qs?*?/2?MM?Km/?D;???????w?Q????n?g"???5????e??c?:?????XC??*G,??w??7?[?Q6I??H>?\u??Js??P_J??e? ?E8?${?RP -????*? 6?Kb?????V ??"????s?8?"T?'4hW%??.>G5@????M?&#?/?y?????A???e????G??? -?X??Ap??r -?`?n?C!rAD????"p??W?@??c??s?=?;??YS???,??? ????)I<4n0???A?8?{/???lr?????h??f+??L?M??Z&??xM={?[????????HS??s????`?@?? ??k9|??&?I6???q?Xj?? l? ??-??????^v???? %G??j?e??Jy??-??$???%x?oe?u??R'+9????r?.)????X???c@??e#??????)?;MV??Q.???+???p???????????M??z??%ipa?G$????D??d&Dj??? \}*X+YIU?vw???j?? x?E at s/??A??????B???CN a_w???C??D.????]\?? ?-u?kTF??1H??{??A?(????=2$??1???s?0???lAC{?f??? C??7p -*???? a?$?} !???@???????????2??????_]+I???Xn?????6???G?TV?r??$?bp[????????{?>(? -???Jg?????sR?iiU??.????*C -? -??9b -?n??CmC;:1?q?iY???=a?????86r??????v??R?Z?"L????Z?????4?=^? ?ho>???V[???\h??_?wqHD?????j??\?RS_lA|?*s?S?c0a;?#?t r?Kp??{?A4B???j???????L#??????7?o:?W?;?Q??Be?17??????Z??????My?????~o;8?KT?%46?%4A?4?\?H?????z?qL?.?[?"?2$????H????????j?t?m????s??RE-CkRz?>?-?4M?n\??B?? ??h([k? -j?;???lW'???`(???J?i???xJ?k???R?h?}np}Jq ?`b????????!?4??M??b`x? ?d???'c5?4Q?m??$B9Va??;o??2a)gR"??,_??|??>R??X?JIB?J?z?Q~u??7?U????_?kg?=3O4_???O???????3q???a#???a?yey%?cY??/N]?!???Ua??????A?G??'???????w?5fD???6l7*???:??}??K"???? -a?]???`?u -??MQ*:?????g??s -??????????A??P?}0.?N??&?^??R]???m???????%?&?~???S??5??dT????$!?G-?lR ciCJ????????J?-&?i?4??cW??YP9?z?#))?????@??o?2C'/?1????n?F??\:??.?@`?(,V?61?;wf?;????!?e?L?@?@5!2??????S??,??M??!?H???_\???h?P=??eD?C& -=R1???$??mvt'???jL????z?????(??X???Q%#$??8?F?? ????OIeo?Ny?bz? ?h??"?%??y???B?uv?r?Z??s!Sh?????e7>L?Bv.?;W?????u??,???l};?+?{??R?;?2?Z??R?^?E Xr-L???9?C????"{02D#r3?????sR ?+?_q???f?6??n?\!?????#??Own??^????>g?????1?4<???bl??+???????????????0?lMm?C?-?a -!????K??4&??h?g"W??5?f??"_???????1??)???????@S??k?k?????????p'???@p????Q???T??^%.??P??p;.Z??xT??A??w?C???:#s$FM?=?A9????>t!????b1f{??}0?????60?????rv???]??Ld?]^?s?????]rz?3??swn?J?A??????v?z??????~?W??x?r#;?/????`?????O VR??&?%>=k??h???uX???w???u??? a???????? ??Z?m?^?xK??(O?&L at F?????$RKK,l???5;?d;???=J3????#?!G&?a?^?????sI??z?)????^?????T?;?x?;?lZ??uS??a??k???[OgU?LT?;^?a???U*??????5???g y?/?Uu??q(? -u?",&????,??$p????'?T???haP&u????"??I??3]E??? h?????Sa??:1P??9?jvvAF?:?i%1??m?6?w)O!??f?Cx??nR?LV?S?cXpBb??D???F}??????p??25??H??>8?y?7?#?4??]???$W?{ -?y?? ?S`!a???gjCHoz?1~??Q????????????????/F?U!?Jb5?K??f/??1yP1?????z??YJ???;S??+C??#???y?%ts?X??bTs?)???*?k???Ai?????????? $:???????1?w?^f??^nm???r??K??H?R?~????b?C?;?,e A?^???j:DR??1E??{W?a??MC??+? \???;?????mO? -;?j??gn?????C?_;?!? ??Zrd?5?\?E -?(7 \??&+?Q?????K?:???,?r?+?c?G*?9M??H ?i??t??}s?S??=?????7??{???[V???B:8Kn?jc? -???T?????4??"u?3@/Z@?T\??f? vp'???? -a~???{e?XX@9??;????G1? |??F?.u9??? i???V??2?,???S? R)??:?^C:y??<4??s??l?1?=????4??"?E?g???"@k??gXf???4qO?c??_???????/C?ZG?X??? ???C??????!?!???8?.?,+??g??6? -&k+?FD??OP??Y6???j6A5???t?+????$?????;?f??Lv???S?????-??u??? ???1???3?`?????r9jT?????#??,u|???D'ssf?????????7G"? z?F???]?V???1?${4+?JW_?h??I?na)iMB6??d??? -H?9???mp??`?|nG7??'zF"?????h\?????a?5??G[???1Y?& |i??j? ??ky?;K??x??Xc?????W??8?L???@,????+Y-^??lj?+?"??N]?ZOq?b???:J??(6W8???W?e???? )??WN??4???D|??ul??A?t?@$? ??? ?A=?a??.'kL??|??$1???????t?l?b???>': -n?f?n?9i??? -? - at c?????RX?R????~????????(Ff?W9"??+M?V]????? ?\O?-fg?^p???#p?g?l?E?l??:0D?{????I1!??K???? ?YRYc ???2??t?^2f??E??T+ -??????z.^#????Y?j -?N??pt??B??????????D|? ?o?g? 7??t???"T?%?k?V?e$ 3??v;?X??:??j??Qed?B???S?-}???????aL? -??N?=s?r?.mS??$??/????\?Bq??SE~,w Of -?|????qg`?Spa?? -/K??????)???????nh?????BP?#?_????;?mD???????3ts?Il?l[??j??+????7?^`???z?,?&?~?????i??a??? -??? ?~?z?.?F????+.?)??m??$er????]?{?R?Gw[4??y'v?3???? Y^????d ??W#?c0?4?9H?O???%??=j?(`&|S?:KA???`?Y?#?+>???[7(ww!)3x?x??L??????C&,nl?8p1_? [&n?5rN???ul???Caq^"???;???Gx???,[?DH?N??^-Y?xF????Eo?????)???O G -bN????!jPf)??%??;|\?p???V??}???o:??.H?B?K}A|5 ?E?w????JJ??ng?#?L2?U????@ +?1??qA???Y*???vX4??x???}? ?_5nSX???? C???d/??? 0??l???h??Rt?e??>??#?D???z?b6? ?-X???U??????????????AvG?/?sx?x??.?Z????Tzg#Y+??1d?????x??j?` J}????????L|?x?st?R??m??}T2?H?x~f~zfJ!"?}????J7?&??!l$f???LU KLh?T7o:H???"????4c???;u??8????5?~?o??k?8z6N????D -?:????????(?+?^r??Z(S???????R???^??p???Ikk???/??i)?|?S??t?????W???C[?????u?????I??zc?+??X??k??:a'????b?;j???F5?|Fkh??R???%k?~#???F? -?U????R0{r????N??(b???v??2???v?cZ;?>M??F?p?53?'??v~?J?NOy?9?cG??????e??B_??:?@>)q???C??5b`?Zn7;?A??9???s????X_?J?+p?? ???4-?J???&?? ????????6?5?L#S?Q?%.A??_?????R?3%?????lI'?J??WL27FE?5!??b??u?? ??D?)W=??,8?t??y?k???M?b,?(_- ??b??Z??????f?F??D?4??9??c%??? -S?\??2@???C??3,?WF?1M)??M???p.??/??k?y?=g??}`?8{???j`???z?|???A4Z{??>????_*?K???,? k?Y?z?r??-c?f?Z??iUW???N??K??XN:????????:?)??^???[$G??k??I6???oy?A?????o#?Z?O6+B_|I -R?+8???=?n???G??????????LN???X?;V?3??YM?yS?t??!? WK??w????'?U?{???M??zo???YPY????w?'??Ms????vC6???z???Kf?g???Q;XV?~????O???o(???H?J????U? -V\9+??8tF????????UDY?-???z7??nP???/e???9??8??%?\?pe?Atrp}??8?????????p??NM???a??*\???????`?L???????g?YZ \ No newline at end of file +?7zXZ???F!t/?????&S]7I??b???9??????TB;q?"?q???cL;?"??B??.?=???c;?5o?-W???x1}??Q^Y^5???????^w?OAqx]s "???!?? j?@v #???7???>3??)O2??d??l??CEe9????P????r)2??D??????????KM?=_5?E:?-?O?F??b?S???I~R?i???o? ?!??wO0j? !3?h????%C??U??kq?!???6e?????Zy?@%M?????????X?,S????s?Tc7?x?tW???2C??aV?g??{???E?|w?&??O?U?T????????`??????r??3D? ??????F??Wn?Y???0??_<9XoN?2?*i???? +??$?B`??????W???5R?x???EXX? +J??????6T?J??????R?YZ????zp%c??????R?x??[Dw????v-??O??????j???im,??R???oo???/)E?;2??-Dg???`??:u7?B5?w?ik3\Z.P??4 +!9???|??@"?-r???c%?;???QVTT}?'u?????????3???'??j??|?-?'??!??????(B?\k~?????b?rs@???_%T?_6?2O?H~~?? ?&)?,?%?"?F^T ?????',??1?^*|qL)d>~?h???`?? ???o?&?4?hc+ +?F& `Q?/T'cF???h),?}C??zd"l???7I??]?*|a?`(??N?m?ki\VS???????d?fz?GT????"Z?p`?a???g??ik?9??9? ?u? ?B*?N)E?"?t?R?u37???U +?5}#[9??!?#?x??????NZ?-???P?=???{$?B??j~?}?????J?RGz.W1Xcm????I???;?g%w?)??c???ZS?>??!0=:+?????? +Mi?r7??!??"KBW??`T?cqy??? +???*???? ?r@???a???z??vE7?V?|???_???????@???[?g?KH??>??MI??jf?K? ??++@"?x???zr +???#M.??????~]???:???l%???$?????H????@$h?O?u8????S/3'?1???#?3n u?#????>???5z?H?O???b?????J2j?j?#kY ?o&pqa??: J?4?????Gi24w?h?x`??????1???'????|f*??Z??? u+??#9M%???yk!?0dl?b4?o?,?9?f(?0?:??P?Jc?U???aL??(???@A?)L?;??,w?"N ?^aY'?Z?S3??k+?B???????` +???b +?w??(?;?}U?????????\12?ZD!?"??????)???t"???I?????u??Z? 3q?Z?t?SU^6F?.??,4?E?3??%?`? cn?*?v?f?? +????9P3??b?1?????d?,???]?n?b-M.^8^?/:UEIz?EZ:??~???????i?xA????????&?q?b?'???????K?????i??;OV?????l??PR??g?T;5Az????8Zi?7??Jr?(?P???W???4OL?H?? ??fV??????C??? +l!?&???Q???????r?a? WXf????[.a??]SGv?4F???[h??Oh?)=?6?6?P????\#???t??]?+R??wny3?????????W\4?%G?}"?P?V???0W1d5F??j????#$????B???bL?z??????{?kQ??%B$??XXrAH?x')?I??U?&????P{+??????????"u?S?'??-?X#?????{=???$?y+^|?/??m+?M6YV?R??D??B>??;5??XG?V???]??O?????W??\K_$>V=???? +??????;?c???cb??[&??{q??H??G I??A????V??g?????W?N:Y2?zr??v?7?t~2-??1/???!???K???3x?Hi3?]C????h?N?Gi????D? ????k?gS?#5?rD???H??>f?f&?{??{?(p0|????WTj???Q?p[Sbkp,?}??(??Y?k?Y??yG?=P?????6??Lb^E?????gN???eH????:T?>0`??u9??".R S???p??????#y?qB= +p)d?O?!???k< +?6P?c6??(~3????!0>?etY ?2?U?????b?? ?]0??}??-p2????D????Zg???nw?Ya??S?I|/??????p/????ql?.|%t????u?R?BI????? +?_ ??????v??N????E??G\?f?"??}?aWC0?'??,?_t???????UW? ?????#K:>, ?x?oQ?????y5????8???????jD????]Juy???????3|t?K???'Ki??_?v????>? ????T?= ??h?>?/{??*?+*y?we??!???9_R? +??e?:?????F&D~?U?'Rp??_ra%A???o?"j???,p?????%????P??ue???}???:?X???#g'GY\???g???:??`?/?g+I?6?? ?????Gy?Ds? ??`?*?d???l??``???{?????-G!? +??u2???D? ????P} +?O???Hp9wk???;a?????????[r????????E?????????U?x_4??? +????L?*?|? ?h?????E?T??%0`????z?????_??J?0?Y????????u/( e0??P????C????%?L?4E??+V?n???{A??.???h??$/9????]gS?????@)R!?q^??@%??Y?"?e?H?ZBZ?l?'???-???rq^???3]???~h?\9?$??????????"????iq??P?Y?p??R??5???llmY????dN???[So,?l???t??????aa??S???'+?y????k5??J?y0?S?`)4??n)? +???? Ez#*Z?(lm?0?D)?nun??Vu?}|%??????x????SM??k ?8r' ?=;???^m?hq{???YaXyq?G??????q?Z?6Y??????D?? +e??ClCc????D?????_j????;?*%??&?9??A???E'%??x????`W??;?b??0#?c?qW?+??6[]f?Z?'D??X? ?[?s3f?F?????~??EJ?T [o?;??????6?V??Z?O????????????Tft?i!S?6k??????q?PyX?????/??O??a?u*?)???c?dt&????????{ ???f?ny???? ??G/??B??w(fi_???n??v?U?s?j(Z? ??? -?<'??wwX??$ck???T?1*?v~&??>???N??'??3??2???5vR??? ec?B8=u?WI??`F?W, ?:&2@??_}5?5x???8?LOq=?%?q?hJ(?+Y???M?SSU????/??'?;)??????z????????6 _-?%@ ????:??H??g???~?^r&??'? ??X??OK????D!?p????HC?h?0?????X?f???;/??m??R?6?I??? +?\??I !?;?J??Mg???4???"a;Vn??????????????q???R????'??&T?x?|???o??&` ??7_?!-?8"????3/???6?4Q5A?6???]?D??5S??p??6???Q??Md5r?|?\??'??y?????J???????? H$?? ?N0????T?m??T\PDXuI????9?x?hTzpI?3.? ???_?: F ????)M???U? ????J=|?2?I? ??????????d?????Rnh??????????+R?????????u?K??#=???!jZ?V6????gz???o-??d?9?_??6?hP?3????x??4s$x(M?]?b/?=N?H4DP???0?p8kB[?Ep? +?t?v?1??? ?????"???R(?1*?eP?w<(?H???r????C??/???M?C???Z?X???T?i:?=ps?????-?????$???R???$S^?Hu?????H??@?\~?u ?}?????`?.~ +}?S??Et ????\?`?=<???x?? r?O????f!3??????W??s?T??.f?`?????s???|??????pq???M}1g?:>\ P???T(A>?~?JF?a?G`?N????j?????j;7?????C??P????e??Dj(???X? +u +?P?n????M?4Y??bHi?xb?&???X??T U?#)}?%?kB?E)?)D?????{???\??t?IP??? +??Ka`]??K?P??g???b??iS???*?h??T?S@???>?? ?}?/??????????8????N?g????? |'?KVBd.?D79????h??a!A?{???N?W?????k??Z???????E??????b??-p?%??]<-J?^????H? e?`??#?n^o? ??|??y}M<:??-%5^????? )?Q??\o??~t/{?-3g0?c???f????<3??E?j????;?h?,???s???????J???????zy?????_n????c +Q??????????<Spo?Dbe?????r??j!K?!??i??l?W??(?w?!flt??}?q?&???~?`.??:?#3?^ +T ??F!^0$?????uA?]i????FR?>???(??C?%1{??G???u7????#??a???CR=Y?2?Q ?84=X??*?t?h(??Y?=@?P?? ??q?????c???K?????P?uT0iU??^???H +?? [1?u ??? ??????,????S?B^&?8~8? ?N?#_??:??z0r?R;?@k?1.xg??C?@????????S?e??7????>%q ?1:?3?d?H?????????P,?????? '??A?Y?c?f?jqK+??GE +?[T????f? H\!9????_?!z??B$??p?4????XCw@?1xyQ^E}E?? m?9??O \N??d??Tgk?:v??k?mV2????D????Ua??F??? +??? oh?g????4C?I2?np??PV;?a?M?\e? +,?]{G2?.????s????;B? +M?s[??S?????H@C?V ????7??I??S?mZ???Y[?[Ibf~J89????~#}??4????gE???f??`?Z n?=?k???c,d???1????sc?b j|?S??Y?v?p$@ $???|B"??t??V????l? ?qeC?[??x@\??|byW?g?(???'?>j +)?J??8j T?8?84?Ys???e?Ge8BH?f3???4`?V9F???????c?wY~d?A?3???.?S"?V????,?\)?j?????}???cHo?sU??????d?+?>?7@????>A3N?_?N??????3C?????q?3}k? =??? ?eH???l?`?D???? +????-?h%?? E??tJ?????6?F???L???Msf?DW?$??sz?n-???[?-B9?Bm?[???????nw????+*;???/?&?u~????Z???&???y?i?X?"??????W?`??K(_?=Q????4??_ah?Q^L??@????2?[]B?5jak?hFi?J?]p,'v+?As?r?i?x??Q?L?e?[??5R???:??S?{? +??H?!0??iU?????:?tY?;M?[i???hq@?j7?jr?*b?_?q?????k???,=R_Y?+%???{??M??S< ????N?0??G?sH.?"???,U?? ??O? ??64 ??`x???Z??U"?6l?<$(9?u?M)?+?p??9??2?????????]??cv?2[??????}F???y???j?r?B?L????{??S?^?L???N???g?YZ \ No newline at end of file Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-01 03:39:25 UTC (rev 232) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-01 08:40:37 UTC (rev 233) @@ -132,7 +132,7 @@ subcrt(c("glucose", "ethanol", "CO2")) ## properties of reactions -subcrt(c("H2O", "H+", "k-feldspar", "kaolinite", "K+", "SiO2"), +subcrt(c("H2O", "H+", "K-feldspar", "kaolinite", "K+", "SiO2"), c(-1, -2, -2, 1, 2, 4)) subcrt(c("glucose", "ethanol", "CO2"), c(-1, 2, 2)) # to specify the states From noreply at r-forge.r-project.org Mon Oct 2 06:45:02 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 2 Oct 2017 06:45:02 +0200 (CEST) Subject: [CHNOSZ-commits] r234 - in pkg/CHNOSZ: . R data inst inst/extdata inst/extdata/Berman inst/extdata/OBIGT man man/macros tests/testthat vignettes Message-ID: <20171002044502.1FF9218858A@r-forge.r-project.org> Author: jedick Date: 2017-10-02 06:45:01 +0200 (Mon, 02 Oct 2017) New Revision: 234 Added: pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/inst/extdata/Berman/ pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv pkg/CHNOSZ/man/berman.Rd pkg/CHNOSZ/tests/testthat/test-berman.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz pkg/CHNOSZ/man/eos.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/macros/macros.Rd pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: add Berman (1988) equations and data for minerals Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-02 04:45:01 UTC (rev 234) @@ -1,6 +1,6 @@ -Date: 2017-10-01 +Date: 2017-10-02 Package: CHNOSZ -Version: 1.1.0-32 +Version: 1.1.0-33 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/NAMESPACE 2017-10-02 04:45:01 UTC (rev 234) @@ -58,7 +58,7 @@ "nonideal", "anim.TCA", "uniprot.aa", "run.guess", # added 20170301 or later "GHS_Tr", "calculateDensity", "calculateGibbsOfWater", - "calculateEpsilon", "calculateQ", "water.DEW" + "calculateEpsilon", "calculateQ", "water.DEW", "berman" ) # Load shared objects Added: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R (rev 0) +++ pkg/CHNOSZ/R/berman.R 2017-10-02 04:45:01 UTC (rev 234) @@ -0,0 +1,105 @@ +# CHNOSZ/berman.R 20170930 +# calculate thermodynamic properties of minerals using Berman formulation + +berman <- function(name, T = 298.15, P = 1) { + # reference temperature and pressure + Pr <- 1 + Tr <- 298.15 + file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ") + dat <- read.csv(file, as.is=TRUE) + # remove the multipliers + multexp <- c(0, 0, 0, 0, # Ber88 Table 2 + 0, -2, -5, -7, # Table 3a + 6, 12, 6, 10, # Table 4 + 0, 0, 0, 2, 5, 0, # Table 3b + 0, 0, 0, -3, -5, 2, 6, -4 # Table 5 + ) + dat[, 2:27] <- t(t(dat[, 2:27]) / 10^multexp) + # which row has data for this mineral? + irow <- which(dat$name == name) + # only the immediately following assign() call is needed for the function to work, + # but an explicit dummy assignment here is used to avoid "Undefined global functions or variables" in R CMD check + GfPrTr <- HfPrTr <- SPrTr <- Tmax <- Tmin <- VPrTr <- + d0 <- d1 <- d2 <- d3 <- d4 <- d5 <- k0 <- k1 <- k2 <- k3 <- v1 <- v2 <- v3 <- v4 <- NA + # assign values to the variables used below + for(i in 1:ncol(dat)) assign(colnames(dat)[i], dat[irow, i]) + # check that G in data file is the G of formation from the elements --> Benson-Helgeson convention (DG = DH - T*DS) + # we get the entropy of the elements using the chemical formula in thermo$obigt + iname <- info(name, "cr_Berman", check.it=FALSE) + SPrTr_elements <- convert(entropy(info(iname)$formula), "J") + GfPrTr_calc <- HfPrTr - Tr * (SPrTr - SPrTr_elements) + Gdiff <- GfPrTr_calc - GfPrTr + if(abs(Gdiff) >= 1000) warning(paste0(name, ": GfPrTr(calc) - GfPrTr(table) is too big! == ", + round(GfPrTr_calc - GfPrTr), " J/mol"), call.=FALSE) + # (the tabulated GfPrTr is unused below) + + ### thermodynamic properties ### + # calculate Cp and V (Berman, 1988 Eqs. 4 and 5) + Cp <- k0 + k1 * T^-0.5 + k2 * T^-2 + k3 * T^-3 + P_Pr <- P - Pr + T_Tr <- T - Tr + V <- VPrTr * (1 + v1 * P_Pr + v2 * P_Pr^2 + v3 * T_Tr + v4 * T_Tr^2) + # calculate Ga (Ber88 Eq. 6) --> Berman-Brown convention (DG = DH - T*S) + Ga <- HfPrTr - T * SPrTr + k0 * ( (T - Tr) - T * (log(T) - log(Tr)) ) + + 2 * k1 * ( (T^0.5 - Tr^0.5) + T*(T^-0.5 - Tr^-0.5) ) - + k2 * ( (T^-1 - Tr^-1) - T / 2 * (T^-2 - Tr^-2) ) - + k3 * ( (T^-2 - Tr^-2) / 2 - T / 3 * (T^-3 - Tr^-3) ) + + VPrTr * ( (v1 / 2 - v2) * (P^2 - Pr^2) + v2 / 3 * (P^3 - Pr^3) + + (1 - v1 + v2 + v3 * (T - Tr) + v4 * (T - Tr)^2) * (P - Pr) ) + # calculate Ha (symbolically integrated using sympy - expressions not simplified) + intCp <- T*k0 - Tr*k0 + k2/Tr - k2/T + k3/(2*Tr^2) - k3/(2*T^2) + 2.0*k1*T^0.5 - 2.0*k1*Tr^0.5 + intVminusTdVdT <- -VPrTr + P*(VPrTr + VPrTr*v2 - VPrTr*v1 - Tr*VPrTr*v3 + VPrTr*v4*Tr^2 - VPrTr*v4*T^2) + + P^2*(VPrTr*v1/2 - VPrTr*v2) + VPrTr*v1/2 - VPrTr*v2/3 + Tr*VPrTr*v3 + VPrTr*v4*T^2 - VPrTr*v4*Tr^2 + VPrTr*v2*P^3/3 + Ha <- HfPrTr + intCp + intVminusTdVdT + # calculate S (also symbolically integrated) + intCpoverT <- k0*log(T) - k0*log(Tr) - k3/(3*T^3) + k3/(3*Tr^3) + k2/(2*Tr^2) - k2/(2*T^2) + 2.0*k1*Tr^-0.5 - 2.0*k1*T^-0.5 + intdVdT <- -VPrTr*(v3 + v4*(-2*Tr + 2*T)) + P*VPrTr*(v3 + v4*(-2*Tr + 2*T)) + S <- SPrTr + intCpoverT - intdVdT + + ### disorder thermodynamic properties ### + if(!is.na(Tmin) & !is.na(Tmax) & any(T > Tmin)) { + # starting disorder contributions are 0 + Cpds <- Hds <- Sds <- Vds <- Gds <- 0 + # the lower integration limit is Tmin + iTds <- T > Tmin + Tds <- T[iTds] + # the upper integration limit is Tmax + Tds[Tds > Tmax] <- Tmax + # Ber88 Eqs. 15, 16, 17, 18, 19 + Cpds[iTds] <- d0 + d1 * Tds^-0.5 + d2 * Tds^-2 + d3 * Tds + d4 * Tds^2 + Hds[iTds] <- d0 * (Tds - Tmin) + 2 * d1 * (Tds^-0.5 - Tmin^-0.5) - + d2 * (Tds^-1 - Tmin^-1) + d3 * (Tds^2 - Tmin^2) / 2 + d4 * (Tds^3 - Tmin^3) / 3 + Sds[iTds] <- d0 * (log(Tds) - log(Tmin)) - 2 * d1 * (Tds^-0.5 - Tmin^-0.5) - + d2 * (Tds^-2 - Tmin^-2) / 2 + d3 * (Tds - Tmin) + d4 * (Tds^2 - Tmin^2) / 2 + # we can't do this if d5 == 0 (dolomite and gehlenite) + if(d5 != 0) Vds <- Hds / d5 + Gds <- Hds - T * Sds + Vds * (P - Pr) + # Gds above Tmax (Eq. 20) + ihigh <- T > Tmax + # note that Gds[ihigh] and Sds[ihigh] on the rhs were both calculated at Tmax (above) + Gds[ihigh] <- Gds[ihigh] - (T[ihigh] - Tmax) * Sds[ihigh] + # apply the disorder contributions + Ga <- Ga + Gds + Ha <- Ha + Hds + S <- S + Sds + V <- V + Vds + Cp <- Cp + Cpds + } + + ### (for testing) use G = H - TS to check that integrals for H and S are written correctly + Ga_fromHminusTS <- Ha - T * S + if(!all.equal(Ga_fromHminusTS, Ga)) stop("incorrect integrals detected using DG = DH - T*S") + + ### thermodynamic and unit conventions used in SUPCRT ### + # use entropy of the elements in calculation of G --> Benson-Helgeson convention (DG = DH - T*DS) + Gf <- Ga + Tr * SPrTr_elements + # convert J to cal + G <- convert(Gf, "cal") + H <- convert(Ha, "cal") + S <- convert(S, "cal") + Cp <- convert(Cp, "cal") + # convert J/bar to cm^3/mol + V <- V * 10 + + data.frame(T=T, P=P, G=G, H=H, S=S, Cp=Cp, V=V) +} Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/data/refs.csv 2017-10-02 04:45:01 UTC (rev 234) @@ -17,6 +17,7 @@ BH83,"T. S. Bowers and H. C. Helgeson",1983,"Geochim. Cosmochim. Acta 47, 1247-1275",rutile,https://doi.org/10.1016/0016-7037(83)90066-2 Hel85,"H. C. Helgeson",1985,"Am. J. Sci. 285, 845-855","ferrosilite and siderite",https://doi.org/10.2475/ajs.285.9.845 JH85,"K. J. Jackson and H. C. Helgeson",1985,"Econ. Geol. 80, 1365-1378","Sn minerals",https://doi.org/10.2113/gsecongeo.80.5.1365 +Ber88,"R. G. Berman",1988,"J. Petrol. 29, 445-522","minerals",https://doi.org/10.1093/petrology/29.2.445 SH88,"E. L. Shock and H. C. Helgeson",1988,"Geochim. Cosmochim. Acta 52, 2009-2036","ionic species",https://doi.org/10.1016/0016-7037(88)90181-0 SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183","inorganic neutral species",https://doi.org/10.1016/0016-7037(89)90341-4 SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/inst/NEWS 2017-10-02 04:45:01 UTC (rev 234) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-32 (2017-10-01) +CHANGES IN CHNOSZ 1.1.0-33 (2017-10-02) --------------------------------------- MAJOR CHANGES: @@ -11,8 +11,11 @@ - The computational setting for water (thermo$opt$par) can now be set using water("DEW"), water("IAPWS"), etc. -- Add demo DEW.R. +- Usage of the DEW model is demonstrated in the new demo DEW.R. +- Add berman() function and extdata/Berman/*.csv files for calculating + the thermodynamic properties using equations of Berman, 1988. + - Implement SUPCRT92's handling of variable volume for quartz and coesite. Calculations for other minerals still assume constant volume of each phase. @@ -40,9 +43,10 @@ selected species are fully referenced. - Add Berman_cr.csv with names and formulas for minerals whose - thermodynamic properties are calculated using the Berman (1988) + thermodynamic properties are calculated using the Berman 1988 formulation. The state "cr_Berman" is used to distinguish these - minerals from the Helgeson data. + minerals from the Helgeson data. The parameters themselves are + stored in extdata/Berman/*.csv. - 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 Added: pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv 2017-10-02 04:45:01 UTC (rev 234) @@ -0,0 +1,68 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +akermanite,-3663786,-3860441,212,9.252,387.06,-29.388,0,-4.079,-0.785,0,25.011,67.224,358,298,0,0,0,452,,,,,,,, +albite,-3703293,-3921618,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, +"albite,high",-3703293,-3921618,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, +"albite,low",-3711715,-3935100,207.443,10.043,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, +almandine,-4941728,-5265502,339.927,11.511,573.96,-14.831,-292.92,502.208,-0.558,0.321,18.613,74.539,,,,,,,,,,,,,, +andalusite,-2441806,-2589972,91.434,5.147,236.48,-11.029,-75.268,93.644,-0.77,1.923,23.443,7.189,,,,,,,,,,,,,, +anorthite,-4003221,-4228730,200.186,10.075,439.37,-37.341,0,-31.702,-1.272,3.176,10.918,41.985,,,,,,,,,,,,,, +anthophyllite,-11342582,-12069032,535.195,26.56,1219.31,-57.665,-347.661,440.09,-1.259,0,27.06,31.325,,,,,,,,,,,,,, +antigorite,-66076529,-71364156,3602.996,174.246,7394.51,0,-5483.63,8728.412,-1.978,4.944,24.965,39.444,,,,,,,,,,,,,, +brucite,-834868,-925937,63.064,2.468,136.84,-5.371,-43.619,55.269,-2.023,6.726,32.854,10.94,,,,,,,,,,,,,, +Ca-Al-pyroxene,-3122310,-3298767,140.751,6.356,310.7,-16.716,-74.553,94.878,-0.87,2.171,22.25,52.863,,,,,,,,,,,,,, +calcite,-1128295,-1206819,91.725,3.69,178.19,-16.577,-4.827,16.66,-1.4,0,8.907,227.402,,,,,,,,,,,,,, +chrysotile,-4035373,-4363356,220.134,10.72,610.02,-55.812,-18.573,19.547,-1.81,4.524,27.151,67.351,,,,,,,,,,,,,, +clinochlore,-8250546,-8909590,435.154,21.147,1214.28,-112.171,0,-125.625,-1.819,0,26.452,0,,,,,,,,,,,,,, +coesite,-852585,-907604,39.424,2.064,94.907,-7.673,-5.279,2.627,-1.037,3,7.396,43.605,,,,,,,,,,,,,, +cordierite,-8651517,-9158727,417.97,23.311,954.39,-79.623,-23.173,-37.021,-1.158,0,3.003,18.017,,,,,,,,,,,,,, +corundum,-1582199,-1675700,50.82,2.558,155.02,-8.284,-38.614,40.908,-0.385,0.375,21.342,47.18,,,,,,,,,,,,,, +"cristobalite,alpha",-853918,-907753,43.394,2.587,83.51,-3.747,-24.554,28.007,-2.515,0,20.824,0,535,298,0.048,-14.216,44.142,0,,,,,,,, +"cristobalite,beta",-853327,-906377,46.029,2.73,83.51,-3.747,-24.554,28.007,-1.1,5.535,3.189,0,,,,,,,,,,,,,, +diaspore,-920806,-999378,35.308,1.776,143.24,-15.404,-3.231,6.463,-0.599,0,29.718,0,,,,,,,,,,,,,, +diopside,-3026202,-3200583,142.5,6.62,305.41,-16.049,-71.66,92.184,-0.872,1.707,27.795,83.082,,,,,,,,,,,,,, +dolomite,-2162354,-2325248,154.89,6.432,328.48,-25.544,-46.885,79.038,-1.07,0,14.23,363.778,,,,,,,1423,298,-9.42,0,3.85,1.732,5.02,0 +"enstatite,clino",-1458601,-1545926,66.325,3.131,139.96,-4.97,-44.002,53.571,-0.75,0.448,21.915,74.92,,,,,,,,,,,,,, +enstatite,-1458181,-1545552,66.17,3.133,166.58,-12.006,-22.706,27.915,-0.749,0.447,24.656,74.67,,,,,,,,,,,,,, +"enstatite,proto",-1456965,-1543959,67.438,3.242,166.58,-12.006,-22.706,27.915,-0.75,0.448,16.832,116.65,,,,,,,,,,,,,, +fayalite,-1380154,-1479360,150.93,4.63,248.93,-19.239,0,-13.91,-0.73,0,26.546,79.482,,,,,,,,,,,,,, +ferrosilite,-1117472,-1194375,95.882,3.296,169.06,-11.93,-20.971,29.253,-0.99,0,31.808,75.85,,,,,,,,,,,,,, +forsterite,-2055023,-2174420,94.01,4.366,238.64,-20.013,0,-11.624,-0.791,1.351,29.464,88.633,,,,,,,,,,,,,, +gehlenite,-3785954,-3988158,198.6,9.033,373.09,-22.768,-47.785,47.791,-0.996,2.488,24.926,5.664,,,,,,,1600,698,-221.74,0,172.91,36.95,-146.9,0 +grossular,-6270974,-6632859,255.15,12.538,573.43,-20.394,-188.872,231.931,-0.654,1.635,18.994,79.756,,,,,,,,,,,,,, +hematite,-743681,-825627,87.437,3.027,146.86,0,-55.768,52.563,-0.479,0.304,38.31,1.65,955,298,0,-7.403,27.921,1287,,,,,,,, +ilmenite,-1155320,-1231947,108.628,3.17,150,-4.416,-33.237,34.815,-0.584,1.23,27.248,29.968,,,,,,,,,,,,,, +jadeite,-2846482,-3025118,133.574,6.034,311.29,-20.051,-53.503,66.257,-0.86,2.149,23.118,25.785,,,,,,,,,,,,,, +kaolinite,-3799770,-4120327,203.7,9.952,523.23,-44.267,-22.443,9.231,-1.2,0,32,0,,,,,,,,,,,,,, +kyanite,-2443370,-2594220,82.43,4.412,262.68,-20.014,-19.997,-6.318,-0.646,0,23.973,0,,,,,,,,,,,,,, +lawsonite,-4509709,-4865666,229.176,10.144,728.67,-82.481,0,85.056,-0.769,1.922,26.283,0,,,,,,,,,,,,,, +lime,-603350,-635090,37.75,1.676,58.79,-1.339,-11.471,10.298,-1.022,2.565,34.61,67.406,,,,,,,,,,,,,, +magnesite,-1029875,-1113636,65.21,2.803,162.3,-11.093,-48.826,87.466,-0.89,2.212,18.436,415.968,,,,,,,,,,,,,, +magnetite,-1014235,-1117403,146.114,4.452,207.93,0,-72.433,66.436,-0.582,1.751,30.291,138.47,848,298,0,-19.502,61.037,1565,,,,,,,, +margarite,-5852244,-6236603,265.084,12.958,699.8,-55.871,-68.077,73.432,-1.155,2.886,21.019,124.556,,,,,,,,,,,,,, +meionite,-13105915,-13849723,730,34.036,1511.35,-132.433,0,-75.161,-1.11,0,9.34,0,,,,,,,,,,,,,, +merwinite,-4309707,-4537497,251.777,9.847,453.62,-32.5,0,-34.423,-0.551,1.381,29.376,87.235,,,,,,,,,,,,,, +monticellite,-2132222,-2250027,108.3,5.148,226.34,-15.427,-11.797,-2.329,-0.904,2,27.863,76.339,,,,,,,,,,,,,, +muscovite,-5596723,-5976740,293.157,14.087,651.49,-38.732,-185.232,274.247,-1.717,4.295,33.527,0,,,,,,,,,,,,,, +paragonite,-5563572,-5944208,277.699,13.216,577.57,-14.728,-322.144,505.008,-1.973,4.933,39.424,59.701,,,,,,,,,,,,,, +periclase,-569209,-601500,26.951,1.125,61.11,-2.962,-6.212,0.584,-0.622,1.511,37.477,3.556,,,,,,,,,,,,,, +phlogopite,-5827224,-6207342,334.158,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, +K-feldspar,-3745415,-3970791,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,1436,298,282.98,-4.83,36.21,-15.733,34.77,41.063 +"K-feldspar,high",-3738804,-3959704,229.157,10.896,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,, +"K-feldspar,low",-3745415,-3970791,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,, +prehnite,-5820154,-6198606,288.634,14.016,716.05,-64.046,-21.825,26.85,-1.427,0,1.468,1128.353,,,,,,,,,,,,,, +pyrope,-5936009,-6286548,266.359,11.316,640.72,-45.421,-47.019,0,-0.576,0.442,22.519,37.044,,,,,,,,,,,,,, +pyrophyllite,-5266865,-5640781,239.4,12.76,665.93,-58.974,-49.799,66.181,-1.354,0,12.637,381.661,,,,,,,,,,,,,, +quartz,-856288,-910700,41.46,2.269,80.01,-2.403,-35.467,49.157,-2.434,10.137,23.895,0,848,373,0.0237,-9.187,24.607,0,,,,,,,, +"quartz,beta",-855033,-908627,44.207,2.37,80.01,-2.403,-35.467,49.157,-1.238,7.087,0,0,,,,,,,,,,,,,, +rutile,-889497,-944750,50.46,1.882,77.84,0,-33.678,40.294,-0.454,0.584,25.716,15.409,,,,,,,,,,,,,, +sillimanite,-2439265,-2586091,95.93,4.983,256.73,-18.872,-29.774,25.096,-0.753,0,13.431,0,,,,,,,,,,,,,, +sphene,-2455134,-2596652,129.29,5.565,234.62,-10.403,-51.183,59.146,-0.59,0,25.2,0,,,,,,,,,,,,,, +spinel,-2176537,-2300313,84.535,3.977,235.9,-17.666,-17.104,4.062,-0.489,0,21.691,50.528,,,,,,,,,,,,,, +talc,-5517657,-5897387,261.24,13.61,664.11,-51.872,-21.472,-32.737,-1.699,5.665,29.447,0,,,,,,,,,,,,,, +tremolite,-11578548,-12305578,551.15,27.268,1229.36,-64.019,-320.899,420.881,-1.392,3.481,24.374,98.338,,,,,,,,,,,,,, +"tridymite,low",-854026,-907750,43.77,2.675,75.37,0,-59.581,95.825,-2.508,0,19.339,0,383,298,0,42.67,-144.575,130,,,,,,,, +"tridymite,high",-853844,-907045,45.524,2.737,75.37,0,-59.581,95.825,-0.74,3.735,4.829,0,,,,,,,,,,,,,, +wollastonite,-1546123,-1631500,81.81,3.983,149.07,-6.903,-36.593,48.435,-1.245,3.113,28.18,0,,,,,,,,,,,,,, +pseudowollastonite,-1543085,-1627427,85.279,4.016,141.16,-4.172,-58.576,94.074,-1.245,3.113,28.18,0,,,,,,,,,,,,,, +zoisite,-6494148,-6889488,297.576,13.588,749.17,-65.093,-23.805,12.486,-0.515,1.288,34.67,0,,,,,,,,,,,,,, +clinozoisite,-6496497,-6894968,287.076,13.673,749.17,-65.093,-23.805,12.486,-0.515,1.288,34.67,0,,,,,,,,,,,,,, Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Added: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd (rev 0) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-02 04:45:01 UTC (rev 234) @@ -0,0 +1,52 @@ +\encoding{UTF-8} +\name{berman} +\alias{berman} +\title{Thermodynamic Properties of Minerals} +\description{ +Calculate thermodynamic properties of minerals using the equations of Berman (1988). +} + +\usage{ + berman(name, T = 298.15, P = 1) +} + +\arguments{ + \item{name}{character, name of mineral} + \item{T}{numeric, temperature(s) at which to calculate properties (K)} + \item{P}{numeric, pressure(s) at which to calculate properties (bar)} +} + +\details{ +This function calculates the thermodynamic properties of minerals at high \P and \T using equations given by Berman (1988). +The \code{name} refers to a mineral that must be listed in \code{thermo$obigt} with the state \samp{cr_Berman}. +This file also holds the chemical formula, which is required for calculating the entropies of the elements in the mineral. +These entropies are used to convert the apparent Gibbs energies from the Berman-Brown convention to the the Benson-Helgeson convention. + +Becuase they use a different set of parameters than Helgeson et al., 1978 (see \code{\link{cgl}}), the standard state thermodynamic properties and parameters for the calculations are stored in files under \code{extdata/Berman}. +} + +\examples{ +\dontshow{data(thermo)} +# other than the formula, the parameters aren't stored in +# thermo$obigt, so this shows NAs +info(info("quartz", "cr_Berman")) +# properties of alpha-quartz (aQz) at 298.15 K and 1 bar +berman("quartz") +# Gibbs energies of aQz and coesite at higher T and P +T <- seq(200, 1300, 100) +P <- seq(23000, 32000, length.out=length(T)) +G_aQz <- berman("quartz", T=T, P=P)$G +G_Cs <- berman("coesite", T=T, P=P)$G +# that is close to the univariant curve (Ber88 Fig. 4), +# so the difference in G is close to 0 +DGrxn <- G_Cs - G_aQz +stopifnot(all(abs(DGrxn) < 100)) +} + +\references{ +Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O?K{\s2}O?CaO?MgO?FeO?Fe{\s2}O{\s3}?Al{\s2}O{\s3}?SiO{\s2}?TiO{\s2}?H{\s2}O?CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445} + +Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K. (1978) Summary and critique of the thermodynamic properties of rock-forming minerals. \emph{Am. J. Sci.} \bold{278-A}, 1--229. \url{http://www.worldcat.org/oclc/13594862} +} + +\concept{Secondary thermodynamic modeling} Modified: pkg/CHNOSZ/man/eos.Rd =================================================================== --- pkg/CHNOSZ/man/eos.Rd 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/man/eos.Rd 2017-10-02 04:45:01 UTC (rev 234) @@ -42,8 +42,6 @@ For both \code{hkf} and \code{cgl}, if at least one equations-of-state parameter for a species is provided, any NA values of the other parameters are reset to zero. If all equations-of-state parameters are NA, but values of \samp{Cp} and/or \samp{V} are available, those values are used in the integration of \samp{G}, \samp{H} and \samp{S} as a function of temperature. - -The \code{T} and \code{P} arguments should all be the same length; the functions perform no argument validating. } \section{Warning}{ Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/man/extdata.Rd 2017-10-02 04:45:01 UTC (rev 234) @@ -10,6 +10,15 @@ \details{ + Files in \code{Berman} contain mineral data using the Berman formulation: + \itemize{ + \item \code{Ber88.csv} lists thermodynamic data for minerals taken from Berman (1988). + These consist of standard state thermodyamic properties (Table 2 in the paper), parameters for calculating heat capacity (Table 3a), coefficients for calculation of mineral expansivities and compressibilities (Table 4), parameters describing polymorph transitions (Table 3b), and parameters describing temperature dependent disordering (Table 5). + The values are entered as shown in the source Tables, preserving units and multipliers. + \code{\link{berman}} removes these multipliers and, after calculation of thermodynamic properties at \P and \T, converts to units used by \code{\link{subcrt}}. + Following conventions used in data files for other software packages, the names of sanidine and microcline were changed to K-feldspar,high and K-feldspar,low. + } + Files in \code{abundance} contain protein abundance and microbial occurrence data: \itemize{ \item \code{TBD+05.csv} lists genes with transcriptomic expression changes in carbon limitation stress response experiments in yeast (Tai et al., 2005). See \code{\link{yeast.aa}} for an example that uses this file. @@ -24,7 +33,7 @@ } - Files in \code{cpetc} contain heat capacity and other thermodynamic data and parameters: + Files in \code{cpetc} contain experimental and calculated thermodynamic and environmental data: \itemize{ \item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Temperature in \eqn{^{\circ}}{?}C 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 \code{anintro.Rmd} for examples that uses 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. @@ -102,6 +111,8 @@ \references{ Bazarkina, E. F., Zotov, A. V. and Akinfiev, N. N. (2010) Pressure-dependent stability of cadmium chloride complexes: Potentiometric measurements at 1?1000 bar and 25?C. \emph{Geol. Ore Deposits} \bold{52}, 167--178. \url{https://doi.org/10.1134/S1075701510020054} +Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O?K{\s2}O?CaO?MgO?FeO?Fe{\s2}O{\s3}?Al{\s2}O{\s3}?SiO{\s2}?TiO{\s2}?H{\s2}O?CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445} + Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V. (1964) Thermodynamic Equilibria In Prebiological Atmospheres. \emph{Science} \bold{146}, 1461--1464. \url{https://doi.org/10.1126/science.146.3650.1461} Dayhoff, M. O. and Lippincott, E. R., Eck, R. V. and Nagarajan (1967) Thermodynamic Equilibrium In Prebiological Atmospheres of C, H, O, N, P, S, and Cl. Report SP-3040, National Aeronautics and Space Administration. \url{http://ntrs.nasa.gov/search.jsp?R=19670017966} @@ -116,17 +127,17 @@ Gattiker, A., Michoud, K., Rivoire, C., Auchincloss, A. H., Coudert, E., Lima, T., Kersey, P., Pagni, M., Sigrist, C. J. A., Lachaize, C., Veuthey, A.-L., Gasteiger, E. and Bairoch, A. (2003) Automatic annotation of microbial proteomes in Swiss-Prot. \emph{Comput. Biol. Chem.} \bold{27}, 49--58. \url{https://doi.org/10.1016/S1476-9271(02)00094-4} -Gaucher, E. A., Thomson, J. M., Burgan, M. F. and Benner, S. A (2003) Inferring the palaeoenvironment of ancient bacteria on the basis of resurrected proteins. \emph{Nature} \bold{425}(6955), 285--288. \code{https://doi.org/10.1038/nature01977} +Gaucher, E. A., Thomson, J. M., Burgan, M. F. and Benner, S. A (2003) Inferring the palaeoenvironment of ancient bacteria on the basis of resurrected proteins. \emph{Nature} \bold{425}(6955), 285--288. \url{https://doi.org/10.1038/nature01977} -Ghaemmaghami, S., Huh, W., Bower, K., Howson, R. W., Belle, A., Dephoure, N., O'Shea, E. K. and Weissman, J. S. (2003) Global analysis of protein expression in yeast. \emph{Nature} \bold{425}(6959), 737--741. \code{https://doi.org/10.1038/nature02046} +Ghaemmaghami, S., Huh, W., Bower, K., Howson, R. W., Belle, A., Dephoure, N., O'Shea, E. K. and Weissman, J. S. (2003) Global analysis of protein expression in yeast. \emph{Nature} \bold{425}(6959), 737--741. \url{https://doi.org/10.1038/nature02046} -Huh, W. K., Falvo, J. V., Gerke, L. C., Carroll, A. S., Howson, R. W., Weissman, J. S. and O'Shea, E. K. (2003) Global analysis of protein localization in budding yeast. \emph{Nature} \bold{425}(6959), 686--691. \code{https://doi.org/10.1038/nature02026} +Huh, W. K., Falvo, J. V., Gerke, L. C., Carroll, A. S., Howson, R. W., Weissman, J. S. and O'Shea, E. K. (2003) Global analysis of protein localization in budding yeast. \emph{Nature} \bold{425}(6959), 686--691. \url{https://doi.org/10.1038/nature02026} HAMAP system. HAMAP FTP directory, \url{ftp://ftp.expasy.org/databases/hamap/} -Hn?dkovsk?, L., Wood, R. H. and Majer, V. (1996) Volumes of aqueous solutions of CH4, CO2, H2S, and NH3 at temperatures from 298.15 K to 705 K and pressures to 35 MPa. \emph{J. Chem. Thermodyn.} \bold{28}, 125--142. \url{https://doi.org/10.1006/jcht.1996.0011} +Hn?dkovsk?, L., Wood, R. H. and Majer, V. (1996) Volumes of aqueous solutions of \CH4, \CO2, \H2S, and \NH3 at temperatures from 298.15 K to 705 K and pressures to 35 MPa. \emph{J. Chem. Thermodyn.} \bold{28}, 125--142. \url{https://doi.org/10.1006/jcht.1996.0011} -Hn?dkovsk?, L. and Wood, R. H. (1997) Apparent molar heat capacities of aqueous solutions of CH4, CO2, H2S, and NH3 at temperatures from 304 K to 704 K at a pressure of 28 MPa. \emph{J. Chem. Thermodyn.} \bold{29}, 731--747. \url{https://doi.org/10.1006/jcht.1997.0192} +Hn?dkovsk?, L. and Wood, R. H. (1997) Apparent molar heat capacities of aqueous solutions of \CH4, \CO2, \H2S, and \NH3 at temperatures from 304 K to 704 K at a pressure of 28 MPa. \emph{J. Chem. Thermodyn.} \bold{29}, 731--747. \url{https://doi.org/10.1006/jcht.1997.0192} Joint Genome Institute (2007) Bison Pool Environmental Genome. Protein sequence files downloaded from IMG/M (\url{http://img.jgi.doe.gov/cgi-bin/m/main.cgi?section=FindGenomes&page=findGenomes}) Modified: pkg/CHNOSZ/man/macros/macros.Rd =================================================================== --- pkg/CHNOSZ/man/macros/macros.Rd 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/man/macros/macros.Rd 2017-10-02 04:45:01 UTC (rev 234) @@ -13,6 +13,11 @@ \newcommand{\NH4plus}{\ifelse{latex}{\eqn{\mathrm{NH_{4}^{+}}}}{\ifelse{html}{\out{NH4+}}{NH4+}}} \newcommand{\H2}{\ifelse{latex}{\eqn{\mathrm{H_{2}}}}{\ifelse{html}{\out{H2}}{H2}}} +% subscripted numbers +\newcommand{\s2}{\ifelse{latex}{\eqn{_2}}{\ifelse{html}{\out{2}}{2}}} +\newcommand{\s3}{\ifelse{latex}{\eqn{_3}}{\ifelse{html}{\out{3}}{3}}} +\newcommand{\s4}{\ifelse{latex}{\eqn{_4}}{\ifelse{html}{\out{4}}{4}}} + % other common variables \newcommand{\T}{\ifelse{latex}{\eqn{T}}{\ifelse{html}{\out{T}}{T}}} \newcommand{\P}{\ifelse{latex}{\eqn{P}}{\ifelse{html}{\out{P}}{P}}} Added: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R (rev 0) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 04:45:01 UTC (rev 234) @@ -0,0 +1,69 @@ +# test-berman.R 20171001 +context("berman") + +# calculate properties for all available minerals at Tr,Pr +file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ") +dat <- read.csv(file, as.is=TRUE) +mineral <- unique(dat$name) +prop_Berman <- NULL + +test_that("properties of all minerals are computed without warnings", { + # running this without error means that: + # - formulas for the minerals are found in thermo$obigt + # - there are no warnings for minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) + expect_silent(properties <- lapply(mineral, berman)) + # save the results so we can use them in the next tests + assign("prop_Berman", properties, inherits=TRUE) + + ## - warnings are produced for 7 minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) + #expect_warning(Berman <- lapply(mineral, berman), + # "annite|dawsonite|dravite|fluortremolite|greenalite|siderite|Na-Fe-saponite.3W", all=TRUE) +}) + +# assemble a data frame for Berman properties +prop_Berman <- do.call(rbind, prop_Berman) +# find the mineral data using Helgeson formulation +icr <- suppressMessages(info(mineral, "cr")) +icr1 <- suppressMessages(info(mineral, "cr1")) +# if there's no match for "cr", try to get "cr1" (lowest-temperature phase) +icr[is.na(icr)] <- icr1[is.na(icr)] +# all of these except rutile (Robie et al., 1979) reference Helgeson et al., 1978 +# NOTE: with check.it = TRUE (the default), this calculates Cp from the tabulated Maier-Kelley parameters +prop_Helgeson <- suppressMessages(info(icr)) + +# now we can compare Berman and Helgeson G, H, S, Cp, V +# minerals with missing properties are not matched here +# (i.e. fluorphlogopite, fluortremolite, glaucophane, and pyrope: no G and H in prop_Helgeson data) + +test_that("Berman and Helgeson properties have large differences for few minerals", { + # which minerals differ in DGf by more than 4 kcal/mol? + idiffG <- which(abs(prop_Berman$G - prop_Helgeson$G) > 4000) + expect_match(mineral[idiffG], + "anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite") + ## we find 9 of them, as follow: + #expect_match(mineral[idiffG], + # "anthophyllite|antigorite|Ca-Al-pyroxene|cordierite,dry|cordierite,hydrous|lawsonite|margarite|merwinite|paragonite") + + # which minerals differ in DHf by more than 4 kcal/mol? + idiffH <- which(abs(prop_Berman$H - prop_Helgeson$H) > 4000) + # we get the above, plus phlogopite and clinozoisite: + expect_match(mineral[idiffH], + "anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite|phlogopite|clinozoisite") + + # which minerals differ in S by more than 4 cal/K/mol? + idiffS <- which(abs(prop_Berman$S - prop_Helgeson$S) > 4) + expect_match(mineral[idiffS], "albite|almandine") + #expect_match(mineral[idiffS], "albite|almandine|annite|cordierite,hydrous|fluortremolite") + + # which minerals differ in Cp by more than 4 cal/K/mol? + idiffCp <- which(abs(prop_Berman$Cp - prop_Helgeson$Cp) > 4) + expect_match(mineral[idiffCp], "antigorite|cristobalite,beta|K-feldspar") + #expect_match(mineral[idiffCp], + # "antigorite|cordierite,hydrous|cristobalite,beta|fluortremolite|glaucophane|greenalite|K-feldspar") + + # which minerals differ in V by more than 1 cm^3/mol? + idiffV <- which(abs(prop_Berman$V - prop_Helgeson$V) > 1) + expect_match(mineral[idiffV], "anthophyllite|antigorite|chrysotile|merwinite") + #expect_match(mineral[idiffV], + # "anthophyllite|antigorite|chrysotile|cordierite,hydrous|glaucophane|greenalite|merwinite") +}) Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-01 08:40:37 UTC (rev 233) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-02 04:45:01 UTC (rev 234) @@ -172,6 +172,16 @@ ```{r reflist, results="asis", echo=FALSE} ``` +### `r setfile("Berman_cr.csv")` +```{r Berman_cr, results="asis", echo=FALSE} +cat("This file gives the identifiying information for minerals whose properties are calculated using the formulation of @Ber88.\n") +cat("To distinguish these minerals from the original set of mineral data in CHNOSZ (based on the compliation of @HDNB78), the physical states are listed as `cr_Berman`.\n") +cat("The actual data are stored separately (`extdata/Berman/*.csv`).
") +``` + +```{r reflist, results="asis", echo=FALSE} +``` + ## Liquids {.tabset .tabset-pills} ### `r setfile("organic_liq.csv")` @@ -256,6 +266,13 @@ ```{r reflist2, results="asis", echo=FALSE} ``` [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 234 From noreply at r-forge.r-project.org Mon Oct 2 08:22:50 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 2 Oct 2017 08:22:50 +0200 (CEST) Subject: [CHNOSZ-commits] r235 - in pkg/CHNOSZ: . R man tests/testthat Message-ID: <20171002062250.79151180290@r-forge.r-project.org> Author: jedick Date: 2017-10-02 08:22:50 +0200 (Mon, 02 Oct 2017) New Revision: 235 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/R/cgl.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/man/berman.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/tests/testthat/test-berman.R Log: make berman() usable by subcrt() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-02 06:22:50 UTC (rev 235) @@ -1,6 +1,6 @@ Date: 2017-10-02 Package: CHNOSZ -Version: 1.1.0-33 +Version: 1.1.0-34 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/R/berman.R 2017-10-02 06:22:50 UTC (rev 235) @@ -1,7 +1,7 @@ # CHNOSZ/berman.R 20170930 # calculate thermodynamic properties of minerals using Berman formulation -berman <- function(name, T = 298.15, P = 1) { +berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE) { # reference temperature and pressure Pr <- 1 Tr <- 298.15 @@ -23,15 +23,17 @@ d0 <- d1 <- d2 <- d3 <- d4 <- d5 <- k0 <- k1 <- k2 <- k3 <- v1 <- v2 <- v3 <- v4 <- NA # assign values to the variables used below for(i in 1:ncol(dat)) assign(colnames(dat)[i], dat[irow, i]) + # get the entropy of the elements using the chemical formula in thermo$obigt + if(is.null(thisinfo)) thisinfo <- info(info(name, "cr_Berman", check.it=FALSE)) + SPrTr_elements <- convert(entropy(thisinfo$formula), "J") # check that G in data file is the G of formation from the elements --> Benson-Helgeson convention (DG = DH - T*DS) - # we get the entropy of the elements using the chemical formula in thermo$obigt - iname <- info(name, "cr_Berman", check.it=FALSE) - SPrTr_elements <- convert(entropy(info(iname)$formula), "J") - GfPrTr_calc <- HfPrTr - Tr * (SPrTr - SPrTr_elements) - Gdiff <- GfPrTr_calc - GfPrTr - if(abs(Gdiff) >= 1000) warning(paste0(name, ": GfPrTr(calc) - GfPrTr(table) is too big! == ", - round(GfPrTr_calc - GfPrTr), " J/mol"), call.=FALSE) - # (the tabulated GfPrTr is unused below) + if(check.G) { + GfPrTr_calc <- HfPrTr - Tr * (SPrTr - SPrTr_elements) + Gdiff <- GfPrTr_calc - GfPrTr + if(abs(Gdiff) >= 1000) warning(paste0(name, ": GfPrTr(calc) - GfPrTr(table) is too big! == ", + round(GfPrTr_calc - GfPrTr), " J/mol"), call.=FALSE) + # (the tabulated GfPrTr is unused below) + } ### thermodynamic properties ### # calculate Cp and V (Berman, 1988 Eqs. 4 and 5) Modified: pkg/CHNOSZ/R/cgl.R =================================================================== --- pkg/CHNOSZ/R/cgl.R 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/R/cgl.R 2017-10-02 06:22:50 UTC (rev 235) @@ -14,88 +14,95 @@ for(k in 1:nrow(parameters)) { # the parameters for *this* species PAR <- parameters[k, ] - # start with NA values - values <- data.frame(matrix(NA, ncol = length(property), nrow=ncond)) - colnames(values) <- property - # additional calculations for quartz and coesite - qtz <- quartz_coesite(PAR, T, P) - isqtz <- !identical(qtz$V, 0) - for(i in 1:length(property)) { - PROP <- property[i] - # a test for availability of the EoS parameters - # here we assume that the parameters are in the same columns as in thermo$obigt - # leave T transition (in 20th column) alone - hasEOS <- any(!is.na(PAR[, 13:19])) - # if at least one of the EoS parameters is available, zero out any NA's in the rest - if(hasEOS) PAR[, 13:19][, is.na(PAR[, 13:19])] <- 0 - # equations for lambda adapted from HOK+98 - if(PROP == "Cp") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp - else p <- PAR$a + PAR$b * T + PAR$c * T^-2 + PAR$d * T^-0.5 + PAR$e * T^2 + PAR$f * T^PAR$lambda - } - if(PROP == "V") { - if(isqtz) p <- qtz$V - else p <- rep(PAR$V, ncond) - } - if(PROP %in% c("E", "kT")) { - p <- rep(NA, ncond) - warning("cgl: E and/or kT of cr, gas and/or liq species are NA.") - } - if(PROP == "G") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp * (T - Tr - T * log(T/Tr)) else { - # Gibbs energy integral: the value at Tref plus heat capacity terms - p <- PAR$a * (T - Tr - T * log(T/Tr)) - - PAR$b * (T - Tr)^2 / 2 - PAR$c * (1/T + T/Tr^2 - 2/Tr) / 2 - - PAR$d * (T^0.5 - 0.5 * T * Tr^-0.5 - 0.5 * Tr^0.5) / -0.25 - - PAR$e * (T^3 - 3 * T * Tr^2 + 2 * Tr^3) / 6 + if(PAR$state=="cr_Berman") { + # use Berman equations (parameters not in thermo$obigt) + properties <- berman(PAR$name, T=T, P=P, thisinfo=PAR) + iprop <- match(property, colnames(properties)) + values <- properties[, iprop, drop=FALSE] + } else { + # start with NA values + values <- data.frame(matrix(NA, ncol = length(property), nrow=ncond)) + colnames(values) <- property + # additional calculations for quartz and coesite + qtz <- quartz_coesite(PAR, T, P) + isqtz <- !identical(qtz$V, 0) + for(i in 1:length(property)) { + PROP <- property[i] + # a test for availability of the EoS parameters + # here we assume that the parameters are in the same columns as in thermo$obigt + # leave T transition (in 20th column) alone + hasEOS <- any(!is.na(PAR[, 13:19])) + # if at least one of the EoS parameters is available, zero out any NA's in the rest + if(hasEOS) PAR[, 13:19][, is.na(PAR[, 13:19])] <- 0 + # equations for lambda adapted from HOK+98 + if(PROP == "Cp") { + # use constant Cp if the EoS parameters are not available + if(!hasEOS) p <- PAR$Cp + else p <- PAR$a + PAR$b * T + PAR$c * T^-2 + PAR$d * T^-0.5 + PAR$e * T^2 + PAR$f * T^PAR$lambda } - # use additional heat capacity term if it's defined - if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { - if(PAR$lambda == -1) p <- p + PAR$f * (log(T/Tr) - T * (1/Tr - 1/T)) - else p <- p + PAR$f * ( T^(PAR$lambda + 1) - (PAR$lambda + 1) * T * Tr^PAR$lambda + - PAR$lambda * Tr^(PAR$lambda + 1) ) / ( PAR$lambda * (PAR$lambda + 1) ) + if(PROP == "V") { + if(isqtz) p <- qtz$V + else p <- rep(PAR$V, ncond) } - # entropy and volume terms - if(!is.na(PAR$S)) p <- p - PAR$S * (T - Tr) - if(isqtz) p <- p + qtz$G - else if(!is.na(PAR$V)) p <- p + convert(PAR$V * (P - Pr), "calories") - p <- PAR$G + p - } - if(PROP == "H") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp * (T - Tr) else { - p <- PAR$a * (T - Tr) + PAR$b * (T^2 - Tr^2) / 2 + - PAR$c * (1/T - 1/Tr) / -1 + PAR$d * (T^0.5 - Tr^0.5) / 0.5 + - PAR$e * (T^3 - Tr^3) / 3 + if(PROP %in% c("E", "kT")) { + p <- rep(NA, ncond) + warning("cgl: E and/or kT of cr, gas and/or liq species are NA.") } - if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { - if(PAR$lambda == -1) p <- p + PAR$f * log(T/Tr) - else p <- p - PAR$f * ( T^(PAR$lambda + 1) - Tr^(PAR$lambda + 1) ) / (PAR$lambda + 1) + if(PROP == "G") { + # use constant Cp if the EoS parameters are not available + if(!hasEOS) p <- PAR$Cp * (T - Tr - T * log(T/Tr)) else { + # Gibbs energy integral: the value at Tref plus heat capacity terms + p <- PAR$a * (T - Tr - T * log(T/Tr)) - + PAR$b * (T - Tr)^2 / 2 - PAR$c * (1/T + T/Tr^2 - 2/Tr) / 2 - + PAR$d * (T^0.5 - 0.5 * T * Tr^-0.5 - 0.5 * Tr^0.5) / -0.25 - + PAR$e * (T^3 - 3 * T * Tr^2 + 2 * Tr^3) / 6 + } + # use additional heat capacity term if it's defined + if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { + if(PAR$lambda == -1) p <- p + PAR$f * (log(T/Tr) - T * (1/Tr - 1/T)) + else p <- p + PAR$f * ( T^(PAR$lambda + 1) - (PAR$lambda + 1) * T * Tr^PAR$lambda + + PAR$lambda * Tr^(PAR$lambda + 1) ) / ( PAR$lambda * (PAR$lambda + 1) ) + } + # entropy and volume terms + if(!is.na(PAR$S)) p <- p - PAR$S * (T - Tr) + if(isqtz) p <- p + qtz$G + else if(!is.na(PAR$V)) p <- p + convert(PAR$V * (P - Pr), "calories") + p <- PAR$G + p } - if(isqtz) p <- p + qtz$H - ## SUPCRT seems to ignore this term? ... 20070802 - #else p <- p + convert(PAR$V*(P-Pr),'calories') - p <- PAR$H + p - } - if(PROP=="S") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp * log(T/Tr) else { - p <- PAR$a * log(T / Tr) + PAR$b * (T - Tr) + - PAR$c * (T^-2 - Tr^-2) / -2 + PAR$e * (T^2 - Tr^2) / 2 + - PAR$d * (T^-0.5 - Tr^-0.5) / -0.5 + if(PROP == "H") { + # use constant Cp if the EoS parameters are not available + if(!hasEOS) p <- PAR$Cp * (T - Tr) else { + p <- PAR$a * (T - Tr) + PAR$b * (T^2 - Tr^2) / 2 + + PAR$c * (1/T - 1/Tr) / -1 + PAR$d * (T^0.5 - Tr^0.5) / 0.5 + + PAR$e * (T^3 - Tr^3) / 3 + } + if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { + if(PAR$lambda == -1) p <- p + PAR$f * log(T/Tr) + else p <- p - PAR$f * ( T^(PAR$lambda + 1) - Tr^(PAR$lambda + 1) ) / (PAR$lambda + 1) + } + if(isqtz) p <- p + qtz$H + ## SUPCRT seems to ignore this term? ... 20070802 + #else p <- p + convert(PAR$V*(P-Pr),'calories') + p <- PAR$H + p } - if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { - p <- p + PAR$f * (T^PAR$lambda - Tr^PAR$lambda) / PAR$lambda + if(PROP=="S") { + # use constant Cp if the EoS parameters are not available + if(!hasEOS) p <- PAR$Cp * log(T/Tr) else { + p <- PAR$a * log(T / Tr) + PAR$b * (T - Tr) + + PAR$c * (T^-2 - Tr^-2) / -2 + PAR$e * (T^2 - Tr^2) / 2 + + PAR$d * (T^-0.5 - Tr^-0.5) / -0.5 + } + if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { + p <- p + PAR$f * (T^PAR$lambda - Tr^PAR$lambda) / PAR$lambda + } + p <- PAR$S + p + qtz$S } - p <- PAR$S + p + qtz$S + values[, i] <- p } - values[, i] <- p - } - out[[k]] <- values - } - return(out) + } # end calculations using parameters from thermo$obigt + out[[k]] <- values + } # end loop over species + return(out) } ### unexported function ### Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-02 06:22:50 UTC (rev 235) @@ -293,8 +293,8 @@ } # crystalline, gas, liquid (except water) species - iscgl <- reaction$state %in% c('liq','cr','gas','cr1','cr2','cr3', - 'cr4','cr5','cr6','cr7','cr8','cr9') & reaction$name != 'water' + cglstates <- c("liq", "cr", "gas", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9", "cr_Berman") + iscgl <- reaction$state %in% cglstates & reaction$name != "water" if(TRUE %in% iscgl) { #si <- info(inpho[iscgl],quiet=TRUE) @@ -314,9 +314,12 @@ # name and state myname <- reaction$name[i] mystate <- reaction$state[i] + # don't proceed if the state is cr_Berman + if(mystate=="cr_Berman") next # check if we're below the transition temperature if(!(reaction$state[i] %in% c('cr1','liq','cr','gas'))) { Ttr <- Ttr(inpho[i]-1,P=P,dPdT=dPdTtr(inpho[i]-1)) + if(all(is.na(Ttr))) next if(any(T < Ttr)) { status.Ttr <- "(extrapolating G)" if(!exceed.Ttr) { @@ -332,10 +335,9 @@ Ttr <- Ttr(inpho[i],P=P,dPdT=dPdTtr(inpho[i])) else { Ttr <- thermo$obigt$z.T[inpho[i]] - if(is.na(Ttr)) next } - if(all(Ttr==0)) next - if(any(T >= Ttr)) { + if(all(is.na(Ttr))) next + if(!all(Ttr==0) & any(T >= Ttr)) { status.Ttr <- "(extrapolating G)" if(!exceed.Ttr) { p.cgl[[ncgl[i]]]$G[T>=Ttr] <- NA @@ -357,14 +359,13 @@ # use variable-pressure standard Gibbs energy for gases isgas <- reaction$state %in% "gas" - if(any(isgas) & "g" %in% eosprop & thermo$opt$varP) { + if(any(isgas) & "G" %in% eosprop & thermo$opt$varP) { for(i in which(isgas)) out[[i]]$G <- out[[i]]$G - convert(log10(P), "G", T=T) } # logK if('logK' %in% calcprop) { for(i in 1:length(out)) { - # NOTE: the following depends on the water function renaming g to G out[[i]] <- cbind(out[[i]],data.frame(logK=convert(out[[i]]$G,'logK',T=T))) colnames(out[[i]][ncol(out[[i]])]) <- 'logK' } Modified: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-02 06:22:50 UTC (rev 235) @@ -7,13 +7,15 @@ } \usage{ - berman(name, T = 298.15, P = 1) + berman(name, T = 298.15, P = 1, thisinfo = NULL, check.G = FALSE) } \arguments{ \item{name}{character, name of mineral} \item{T}{numeric, temperature(s) at which to calculate properties (K)} \item{P}{numeric, pressure(s) at which to calculate properties (bar)} + \item{thisinfo}{dataframe, row for mineral from \code{thermo$obigt}} + \item{check.G}{logical, check consistency of G, H, and S?} } \details{ @@ -23,6 +25,11 @@ These entropies are used to convert the apparent Gibbs energies from the Berman-Brown convention to the the Benson-Helgeson convention. Becuase they use a different set of parameters than Helgeson et al., 1978 (see \code{\link{cgl}}), the standard state thermodynamic properties and parameters for the calculations are stored in files under \code{extdata/Berman}. + +If \code{check.G} is TRUE, the tabulated value of DGfTrPr is compared with one calculated from DHfPrTr - T*DSPrTr (DS is the difference between the summed entropies of the elements and the tabulated entropy for the mineral). +A warning is produced if the absolute value of the difference between tabulated and calculated DGfTrPr is greater than 1000 J/mol. + +Providing \code{thisinfo} means that the mineral name is not searched in \code{thermo$obigt}, potentially saving some running time. } \examples{ @@ -34,13 +41,25 @@ berman("quartz") # Gibbs energies of aQz and coesite at higher T and P T <- seq(200, 1300, 100) -P <- seq(23000, 32000, length.out=length(T)) +P <- seq(22870, 31900, length.out=length(T)) G_aQz <- berman("quartz", T=T, P=P)$G G_Cs <- berman("coesite", T=T, P=P)$G # that is close to the univariant curve (Ber88 Fig. 4), # so the difference in G is close to 0 DGrxn <- G_Cs - G_aQz stopifnot(all(abs(DGrxn) < 100)) + +# calculate the properties of a "reaction" between +# the Helgeson and Berman versions of quartz +T <- 1000 +P <- c(10000, 20000) +subcrt(rep("quartz", 2), c("cr", "cr_Berman"), c(-1, 1), T=T, P=P) + +# make a P-T diagram for SiO2 minerals (Ber88 Fig. 4) +basis(c("SiO2", "O2"), c("cr_Berman", "gas")) +species(c("quartz", "quartz,beta", "coesite"), "cr_Berman") +a <- affinity(T=c(200, 1700, 200), P=c(0, 50000, 200)) +diagram(a) } \references{ Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/man/extdata.Rd 2017-10-02 06:22:50 UTC (rev 235) @@ -41,7 +41,7 @@ \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. Data were extracted from the figure using g3data (\url{http://www.frantz.fi/software/g3data.php}). 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 \code{eos-regress.Rmd} for examples that use these files. \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{?}C), 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 \code{anintro.Rmd} for an example that uses this file. - \item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \eqn{\mathrm{O_2}}{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 \code{anintro.Rmd} 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 \code{anintro.Rmd} 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 \code{anintro.Rmd} for an example that uses this file. } Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 04:45:01 UTC (rev 234) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 06:22:50 UTC (rev 235) @@ -11,7 +11,7 @@ # running this without error means that: # - formulas for the minerals are found in thermo$obigt # - there are no warnings for minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) - expect_silent(properties <- lapply(mineral, berman)) + expect_silent(properties <- lapply(mineral, berman, check.G=TRUE)) # save the results so we can use them in the next tests assign("prop_Berman", properties, inherits=TRUE) From noreply at r-forge.r-project.org Mon Oct 2 13:35:04 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 2 Oct 2017 13:35:04 +0200 (CEST) Subject: [CHNOSZ-commits] r236 - in pkg/CHNOSZ: . R demo inst man Message-ID: <20171002113504.296E71891E6@r-forge.r-project.org> Author: jedick Date: 2017-10-02 13:35:03 +0200 (Mon, 02 Oct 2017) New Revision: 236 Added: pkg/CHNOSZ/demo/lambda.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/berman.Rd pkg/CHNOSZ/man/examples.Rd Log: add transition calculations to berman() and add demo labmda.R Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-02 11:35:03 UTC (rev 236) @@ -1,6 +1,6 @@ Date: 2017-10-02 Package: CHNOSZ -Version: 1.1.0-34 +Version: 1.1.0-35 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/R/berman.R 2017-10-02 11:35:03 UTC (rev 236) @@ -1,10 +1,16 @@ # CHNOSZ/berman.R 20170930 -# calculate thermodynamic properties of minerals using Berman formulation +# calculate thermodynamic properties of minerals using equations from: +# Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals +# in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. +# J. Petrol. 29, 445-522. https://doi.org/10.1093/petrology/29.2.445 -berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE) { +berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE, calc.transition=TRUE, calc.disorder=TRUE, units="cal") { # reference temperature and pressure Pr <- 1 Tr <- 298.15 + # the number of conditions we have + ncond <- max(length(T), length(P)) + # get thermodynamic parameters file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ") dat <- read.csv(file, as.is=TRUE) # remove the multipliers @@ -17,10 +23,10 @@ dat[, 2:27] <- t(t(dat[, 2:27]) / 10^multexp) # which row has data for this mineral? irow <- which(dat$name == name) - # only the immediately following assign() call is needed for the function to work, + # the function works fine with just the following assign() call, # but an explicit dummy assignment here is used to avoid "Undefined global functions or variables" in R CMD check - GfPrTr <- HfPrTr <- SPrTr <- Tmax <- Tmin <- VPrTr <- - d0 <- d1 <- d2 <- d3 <- d4 <- d5 <- k0 <- k1 <- k2 <- k3 <- v1 <- v2 <- v3 <- v4 <- NA + GfPrTr <- HfPrTr <- SPrTr <- Tlambda <- Tmax <- Tmin <- Tref <- VPrTr <- + d0 <- d1 <- d2 <- d3 <- d4 <- d5 <- dTdP <- k0 <- k1 <- k2 <- k3 <- l1 <- l2 <- v1 <- v2 <- v3 <- v4 <- NA # assign values to the variables used below for(i in 1:ncol(dat)) assign(colnames(dat)[i], dat[irow, i]) # get the entropy of the elements using the chemical formula in thermo$obigt @@ -58,8 +64,46 @@ intdVdT <- -VPrTr*(v3 + v4*(-2*Tr + 2*T)) + P*VPrTr*(v3 + v4*(-2*Tr + 2*T)) S <- SPrTr + intCpoverT - intdVdT + ### polymorphic transition properties *** + if(!is.na(Tlambda) & !is.na(Tref) & any(T > Tref) & calc.transition) { + # starting transition contributions are 0 + Cptr <- Htr <- Str <- Gtr <- numeric(ncond) + ## Ber88 Eq. 8: Cp at 1 bar + #Cplambda_1bar <- T * (l1 + l2 * T)^2 + # Eq. 9: Tlambda at P + Tlambda_P <- Tlambda + dTdP * (P - 1) + # Eq. 8a: Cp at P + Td <- Tlambda - Tlambda_P + Tprime <- T + Td + # with the condition that Tref < Tprime < Tlambda(1bar) + iTprime <- Tref < Tprime & Tprime < Tlambda + Tprime <- Tprime[iTprime] + Cptr[iTprime] <- Tprime * (l1 + l2 * Tprime)^2 + # we got Cp, now calculate the integrations for H and S + # the lower integration limit is Tref + iTtr <- T > Tref + Ttr <- T[iTtr] + # the upper integration limit is Tlambda_P + Ttr[Ttr > Tlambda_P] <- Tlambda_P + # derived variables + tref <- Tref - Td + x1 <- l1^2 * Td + 2 * l1 * l2 * Td^2 + l2^2 * Td^3 + x2 <- l1^2 + 4 * l1 * l2 * Td + 3 * l2^2 * Td^2 + x3 <- 2 * l1 * l2 + 3 * l2^2 * Td + x4 <- l2 ^ 2 + # Eqs. 10, 11, 12 + Htr[iTtr] <- x1 * (Ttr - tref) + x2 / 2 * (Ttr^2 - tref^2) + x3 / 3 * (Ttr^3 - tref^3) + x4 / 4 * (Ttr^4 - tref^4) + Str[iTtr] <- x1 * (log(Ttr) - log(tref)) + x2 * (Ttr - tref) + x3 / 2 * (Ttr^2 - tref^2) + x4 / 3 * (Ttr^3 - tref^3) + Gtr <- Htr - T * Str + # apply the transition contributions + Ga <- Ga + Gtr + Ha <- Ha + Htr + S <- S + Str + Cp <- Cp + Cptr + } + ### disorder thermodynamic properties ### - if(!is.na(Tmin) & !is.na(Tmax) & any(T > Tmin)) { + if(!is.na(Tmin) & !is.na(Tmax) & any(T > Tmin) & calc.disorder) { # starting disorder contributions are 0 Cpds <- Hds <- Sds <- Vds <- Gds <- 0 # the lower integration limit is Tmin @@ -95,11 +139,16 @@ ### thermodynamic and unit conventions used in SUPCRT ### # use entropy of the elements in calculation of G --> Benson-Helgeson convention (DG = DH - T*DS) Gf <- Ga + Tr * SPrTr_elements + # the output will just have "G" and "H" + G <- Gf + H <- Ha # convert J to cal - G <- convert(Gf, "cal") - H <- convert(Ha, "cal") - S <- convert(S, "cal") - Cp <- convert(Cp, "cal") + if(grepl("cal", units)) { + G <- convert(Gf, "cal") + H <- convert(Ha, "cal") + S <- convert(S, "cal") + Cp <- convert(Cp, "cal") + } # convert J/bar to cm^3/mol V <- V * 10 Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/R/examples.R 2017-10-02 11:35:03 UTC (rev 236) @@ -29,7 +29,7 @@ demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW"), to.file=FALSE) { + "adenine", "DEW", "lambda"), to.file=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { # say something so the user sees where we are Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/R/util.expression.R 2017-10-02 11:35:03 UTC (rev 236) @@ -96,9 +96,11 @@ # D for greek Delta # p for subscript italic P (in Cp) # 0 for degree sign (but not immediately following a number e.g. 2.303) + # l for subscript small lambda if(thischar=='D') thisexpr <- substitute(Delta) if(thischar=='p') thisexpr <- substitute(a[italic(P)], list(a="")) if(thischar=='0' & !can.be.numeric(prevchar)) thisexpr <- substitute(degree) + if(thischar=='l') thisexpr <- substitute(a[lambda], list(a="")) # put it together expr <- substitute(a*b, list(a=expr, b=thisexpr)) } Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/demo/00Index 2017-10-02 11:35:03 UTC (rev 236) @@ -20,3 +20,4 @@ activity_ratios mineral stability plots with activity ratios on the axes adenine HKF parameters regressed from heat capacity and volume of aqueous adenine DEW Deep Earth Water (DEW) model for high pressures +lambda Effects of lambda transtion on thermodynamic properties of quartz Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-02 11:35:03 UTC (rev 236) @@ -24,9 +24,9 @@ PT20.0 <- data.frame(P=20000, T=seq(200, 800, 10)) PT <- rbind(PT0.5, PT1.0, PT2.0, PT5.0, PT10.0, PT20.0) # reaction 1: quartz = SiO2(aq) [equivalent to quartz + 3 H2O = Si(OH)4] -SiO2_logK <- subcrt(c("quartz", "SiO2"), c(-1, 1), P=PT$P, T=PT$T)$out$logK +SiO2_logK <- subcrt(c("quartz", "SiO2"), c("cr_Berman", "aq"), c(-1, 1), P=PT$P, T=PT$T)$out$logK # reaction 2: 2 quartz = Si2O4(aq) [equivalent to 2 quartz + 3 H2O = Si2O(OH)6] -Si2O4_logK <- subcrt(c("quartz", "Si2O4"), c(-2, 1), P=PT$P, T=PT$T)$out$logK +Si2O4_logK <- subcrt(c("quartz", "Si2O4"), c("cr_Berman", "aq"), c(-2, 1), P=PT$P, T=PT$T)$out$logK # plot the sum of molalities (== activities) for each pressure plot(c(200, 1000), c(-2.5, 0.5), type="n", xlab=axis.label("T"), ylab="log molality") for(P in unique(PT$P)) { Added: pkg/CHNOSZ/demo/lambda.R =================================================================== --- pkg/CHNOSZ/demo/lambda.R (rev 0) +++ pkg/CHNOSZ/demo/lambda.R 2017-10-02 11:35:03 UTC (rev 236) @@ -0,0 +1,61 @@ +# plot effects of lambda transition in quartz +# after Berman 1988 Figs. 1 and 2 +layout(matrix(c(1, 4:2, 1, 7:5), nrow=4), heights=c(0.7, 3, 3, 3)) +# plot title first +par(mar=c(0, 0, 0, 0)) +plot.new() +text(0.5, 0.5, "Effects of lambda transition in quartz, after Berman (1988) Figs. 1 and 2", cex=1.8) +opar <- par(mar=c(4, 4.5, 1, 0.5), cex=0.8) + +T <- convert(seq(0, 1400, 1), "K") + +labplot <- function(x) label.plot(x, xfrac=0.9, yfrac=0.1, paren=TRUE) +# this sets the units used for making the axis labels +E.units("J") +Cplab <- axis.label("Cp") +Vlab <- axis.label("V") +Tlab <- axis.label("T") + +# calculate properties at 1 kbar with and without transition +Qz_1bar <- berman("quartz", T=T, units="J") +Qz_1bar_notrans <- berman("quartz", T=T, calc.transition=FALSE, units="J") +# Fig. 1a: volume +plot(T, Qz_1bar$V, type="l", xlab=Tlab, ylab=Vlab, ylim=c(22.5, 24)) +legend("topleft", legend="1 bar", bty="n") +labplot("a") +# TODO: why don't we get the curvature his plot for V shows? +# Should it be in the v4 parameter (but it's zero)?? + +# Fig. 1b: heat capacity +plot(T, Qz_1bar$Cp, type="l", xlab=Tlab, ylab=Cplab) +lines(T, Qz_1bar_notrans$Cp, lty=3) +legend("topleft", legend="1 bar", bty="n") +labplot("b") + +# calculate properties at 10 kbar with and without transition +Qz_10bar <- berman("quartz", T=T, P=10000, units="J") +Qz_10bar_notrans <- berman("quartz", T=T, P=10000, calc.transition=FALSE, units="J") +# Fig. 1c: heat capacity +plot(T, Qz_10bar$Cp, type="l", xlab=Tlab, ylab=Cplab) +lines(T, Qz_10bar_notrans$Cp, lty=3) +legend("topleft", legend="10 kb", bty="n") +labplot("c") + +# like Ber88 Fig. 2 +Tlambda <- 848 # Kelvin +dTdP <- 0.0237 +Pkb <- seq(1, 50, 1) +P <- 1000 * Pkb +T <- Tlambda + dTdP * (P - 1) +Qz_withtrans <- berman("quartz", T=T, P=P, units="J") +Qz_notrans <- berman("quartz", T=T, P=P, calc.transition=FALSE, units="J") +Qz_lambda <- Qz_withtrans - Qz_notrans +Plab <- expression(list(italic(P), "kb")) +plot(Pkb, Qz_lambda$G, type="l", ylim=c(-300, -50), ylab=axis.label("DlG"), xlab=Plab) +labplot("d") +plot(Pkb, Qz_lambda$H, type="l", ylim=c(1200, 1800), ylab=axis.label("DlH"), xlab=Plab) +labplot("e") +plot(Pkb, Qz_lambda$S, type="l", ylim=c(0, 3), ylab=axis.label("DlS"), xlab=Plab) +labplot("f") + +par(opar) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/inst/NEWS 2017-10-02 11:35:03 UTC (rev 236) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-33 (2017-10-02) +CHANGES IN CHNOSZ 1.1.0-35 (2017-10-02) --------------------------------------- MAJOR CHANGES: @@ -14,8 +14,11 @@ - Usage of the DEW model is demonstrated in the new demo DEW.R. - Add berman() function and extdata/Berman/*.csv files for calculating - the thermodynamic properties using equations of Berman, 1988. + thermodynamic properties of mineral using equations of Berman, 1988. +- Calculations related to Berman's (1988) Figs. 1 and 2 for the lambda + transition of quartz are presented in the new demo lambda.R. + - Implement SUPCRT92's handling of variable volume for quartz and coesite. Calculations for other minerals still assume constant volume of each phase. Modified: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-02 11:35:03 UTC (rev 236) @@ -7,7 +7,8 @@ } \usage{ - berman(name, T = 298.15, P = 1, thisinfo = NULL, check.G = FALSE) + berman(name, T = 298.15, P = 1, thisinfo = NULL, check.G = FALSE, + calc.transition = TRUE, calc.disorder = TRUE, units = "cal") } \arguments{ @@ -16,13 +17,16 @@ \item{P}{numeric, pressure(s) at which to calculate properties (bar)} \item{thisinfo}{dataframe, row for mineral from \code{thermo$obigt}} \item{check.G}{logical, check consistency of G, H, and S?} + \item{calc.transition}{logical, include calculation of polymorphic transition properties?} + \item{calc.disorder}{logical, include calculation of disordering properties?} + \item{units}{character, energy units, \samp{cal} or \samp{J}} } \details{ This function calculates the thermodynamic properties of minerals at high \P and \T using equations given by Berman (1988). The \code{name} refers to a mineral that must be listed in \code{thermo$obigt} with the state \samp{cr_Berman}. This file also holds the chemical formula, which is required for calculating the entropies of the elements in the mineral. -These entropies are used to convert the apparent Gibbs energies from the Berman-Brown convention to the the Benson-Helgeson convention. +These entropies are used to convert the apparent Gibbs energies from the Berman-Brown convention to the the Benson-Helgeson convention (cf. Anderson, 2005). Becuase they use a different set of parameters than Helgeson et al., 1978 (see \code{\link{cgl}}), the standard state thermodynamic properties and parameters for the calculations are stored in files under \code{extdata/Berman}. @@ -63,6 +67,8 @@ } \references{ +Anderson, G. M. (2005) \emph{Thermodynamics of Natural Systems}, 2nd ed., Cambridge University Press, 648 p. \url{http://www.worldcat.org/oclc/474880901} + Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O?K{\s2}O?CaO?MgO?FeO?Fe{\s2}O{\s3}?Al{\s2}O{\s3}?SiO{\s2}?TiO{\s2}?H{\s2}O?CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445} Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K. (1978) Summary and critique of the thermodynamic properties of rock-forming minerals. \emph{Am. J. Sci.} \bold{278-A}, 1--229. \url{http://www.worldcat.org/oclc/13594862} Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-02 06:22:50 UTC (rev 235) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-02 11:35:03 UTC (rev 236) @@ -18,7 +18,7 @@ "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW"), + "adenine", "DEW", "lambda"), to.file=FALSE) } @@ -56,34 +56,37 @@ \code{activity_ratios} \tab mineral stability plots with activity ratios on the axes \cr \code{adenine} \tab HKF parameters regressed from heat capacity and volume of aqueous adenine (Lowe et al., 2017) \cr \code{adenine} \tab Deep Earth Water (DEW) model for high pressures (Sverjensky et al., 2014a and 2014b) \cr + \code{lambda} \tab Effects of lambda transtion on thermodynamic properties of quartz (Berman, 1988) \cr } } \references{ - Aksu, S. and Doyle, F. M. (2001) Electrochemistry of copper in aqueous glycine solutions. \emph{J. Electrochem. Soc.} \bold{148}, B51--B57. \url{https://doi.org/10.1149/1.1344532} +Aksu, S. and Doyle, F. M. (2001) Electrochemistry of copper in aqueous glycine solutions. \emph{J. Electrochem. Soc.} \bold{148}, B51--B57. \url{https://doi.org/10.1149/1.1344532} - Dick, J. M. (2009) Calculation of the relative metastabilities of proteins in subcellular compartments of \emph{Saccharomyces cerevisiae}. \emph{BMC Syst. Biol.} \bold{3}:75. \url{https://doi.org/10.1186/1752-0509-3-75} +Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O?K{\s2}O?CaO?MgO?FeO?Fe{\s2}O{\s3}?Al{\s2}O{\s3}?SiO{\s2}?TiO{\s2}?H{\s2}O?CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445} - Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{https://doi.org/10.1371/journal.pone.0022782} +Dick, J. M. (2009) Calculation of the relative metastabilities of proteins in subcellular compartments of \emph{Saccharomyces cerevisiae}. \emph{BMC Syst. Biol.} \bold{3}:75. \url{https://doi.org/10.1186/1752-0509-3-75} - Dick, J. M. (2016) Proteomic indicators of oxidation and hydration state in colorectal cancer. \emph{PeerJ} \bold{4}:e2238. \url{https://doi.org/10.7717/peerj.2238} +Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{https://doi.org/10.1371/journal.pone.0022782} - Garrels, R. M. and Christ, C. L. (1965) \emph{Solutions, Minerals, and Equilibria}, Harper & Row, New York, 450 p. \url{http://www.worldcat.org/oclc/517586} +Dick, J. M. (2016) Proteomic indicators of oxidation and hydration state in colorectal cancer. \emph{PeerJ} \bold{4}:e2238. \url{https://doi.org/10.7717/peerj.2238} - Lowe, A. R., Cox, J. S. and Tremaine, P. R. (2017) Thermodynamics of aqueous adenine: Standard partial molar volumes and heat capacities of adenine, adeninium chloride, and sodium adeninate from \emph{T} = 278.15 K to 393.15 K. \emph{J. Chem. Thermodyn.} \bold{112}, 129--145. \url{https://doi.org/10.1016/j.jct.2017.04.005} +Garrels, R. M. and Christ, C. L. (1965) \emph{Solutions, Minerals, and Equilibria}, Harper & Row, New York, 450 p. \url{http://www.worldcat.org/oclc/517586} + +Lowe, A. R., Cox, J. S. and Tremaine, P. R. (2017) Thermodynamics of aqueous adenine: Standard partial molar volumes and heat capacities of adenine, adeninium chloride, and sodium adeninate from \emph{T} = 278.15 K to 393.15 K. \emph{J. Chem. Thermodyn.} \bold{112}, 129--145. \url{https://doi.org/10.1016/j.jct.2017.04.005} - Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5} +Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5} - Schulte, M. D. and Shock, E. L. (1995) Thermodynamics of Strecker synthesis in hydrothermal systems. \emph{Orig. Life Evol. Biosph.} \bold{25}, 161--173. \url{https://doi.org/10.1007/BF01581580} +Schulte, M. D. and Shock, E. L. (1995) Thermodynamics of Strecker synthesis in hydrothermal systems. \emph{Orig. Life Evol. Biosph.} \bold{25}, 161--173. \url{https://doi.org/10.1007/BF01581580} - Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} +Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} - Stumm, W. and Morgan, J. J. (1996) \emph{Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters}, John Wiley & Sons, New York, 1040 p. \url{http://www.worldcat.org/oclc/31754493} +Stumm, W. and Morgan, J. J. (1996) \emph{Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters}, John Wiley & Sons, New York, 1040 p. \url{http://www.worldcat.org/oclc/31754493} - Sverjensky, D. A., Harrison, B. and Azzolini, D. (2014a) Water in the deep Earth: The dielectric constant and the solubilities of quartz and corundum to 60 kb and 1,200 \degC. \emph{Geochim. Cosmochim. Acta} \bold{129}, 125--145. \url{https://doi.org/10.1016/j.gca.2013.12.019} +Sverjensky, D. A., Harrison, B. and Azzolini, D. (2014a) Water in the deep Earth: The dielectric constant and the solubilities of quartz and corundum to 60 kb and 1,200 \degC. \emph{Geochim. Cosmochim. Acta} \bold{129}, 125--145. \url{https://doi.org/10.1016/j.gca.2013.12.019} - Sverjensky, D. A., Stagno, V. and Huang, F. (2014b) Important role for organic carbon in subduction-zone fluids in the deep carbon cycle. \emph{Nat. Geosci.} \bold{7}, 909--913. \url{https://doi.org/10.1038/ngeo2291} +Sverjensky, D. A., Stagno, V. and Huang, F. (2014b) Important role for organic carbon in subduction-zone fluids in the deep carbon cycle. \emph{Nat. Geosci.} \bold{7}, 909--913. \url{https://doi.org/10.1038/ngeo2291} } From noreply at r-forge.r-project.org Mon Oct 2 16:42:02 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 2 Oct 2017 16:42:02 +0200 (CEST) Subject: [CHNOSZ-commits] r237 - in pkg/CHNOSZ: . R data inst/extdata/Berman inst/extdata/OBIGT tests/testthat vignettes Message-ID: <20171002144202.AF3FF1891E4@r-forge.r-project.org> Author: jedick Date: 2017-10-02 16:42:02 +0200 (Mon, 02 Oct 2017) New Revision: 237 Added: pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/vignettes/obigt.bib Log: add modifications to Berman data (1990 to 1992) Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-02 11:35:03 UTC (rev 236) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-02 14:42:02 UTC (rev 237) @@ -1,6 +1,6 @@ Date: 2017-10-02 Package: CHNOSZ -Version: 1.1.0-35 +Version: 1.1.0-36 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-02 11:35:03 UTC (rev 236) +++ pkg/CHNOSZ/R/berman.R 2017-10-02 14:42:02 UTC (rev 237) @@ -11,8 +11,14 @@ # the number of conditions we have ncond <- max(length(T), length(P)) # get thermodynamic parameters - file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ") - dat <- read.csv(file, as.is=TRUE) + dir <- system.file("extdata/Berman/", package="CHNOSZ") + Ber88 <- read.csv(paste0(dir, "/Ber88.csv"), as.is=TRUE) + Ber90 <- read.csv(paste0(dir, "/Ber90.csv"), as.is=TRUE) + SHD91 <- read.csv(paste0(dir, "/SHD91.csv"), as.is=TRUE) + ZS92 <- read.csv(paste0(dir, "/ZS92.csv"), as.is=TRUE) + # assemble the files and remove duplicates (keep the latest) + dat <- rbind(ZS92, SHD91, Ber90, Ber88) + dat <- dat[!duplicated(dat$name), ] # remove the multipliers multexp <- c(0, 0, 0, 0, # Ber88 Table 2 0, -2, -5, -7, # Table 3a @@ -36,7 +42,8 @@ if(check.G) { GfPrTr_calc <- HfPrTr - Tr * (SPrTr - SPrTr_elements) Gdiff <- GfPrTr_calc - GfPrTr - if(abs(Gdiff) >= 1000) warning(paste0(name, ": GfPrTr(calc) - GfPrTr(table) is too big! == ", + if(is.na(GfPrTr)) warning(paste0(name, ": GfPrTr(table) is NA"), call.=FALSE) + else if(abs(Gdiff) >= 1000) warning(paste0(name, ": GfPrTr(calc) - GfPrTr(table) is too big! == ", round(GfPrTr_calc - GfPrTr), " J/mol"), call.=FALSE) # (the tabulated GfPrTr is unused below) } Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-02 11:35:03 UTC (rev 236) +++ pkg/CHNOSZ/data/refs.csv 2017-10-02 14:42:02 UTC (rev 237) @@ -20,10 +20,16 @@ Ber88,"R. G. Berman",1988,"J. Petrol. 29, 445-522","minerals",https://doi.org/10.1093/petrology/29.2.445 SH88,"E. L. Shock and H. C. Helgeson",1988,"Geochim. Cosmochim. Acta 52, 2009-2036","ionic species",https://doi.org/10.1016/0016-7037(88)90181-0 SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183","inorganic neutral species",https://doi.org/10.1016/0016-7037(89)90341-4 +Ber90,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","annite",http://ammin.geoscienceworld.org/content/75/3-4/328 +Ber90.1,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","almandine and ilmenite: revised H and/or S",http://ammin.geoscienceworld.org/content/75/3-4/328 SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O +SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H corrections for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 SPRONS92.1,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","titanite: @BH83 + "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", SPRONS92.2,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","Ca-bearing minerals; "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", Sho92,"E. L. Shock",1992,"Geochim. Cosmochim. Acta 56, 3481-3491","diglycine, alanylglycine, leucylglycine, and diketopiperazine",https://doi.org/10.1016/0016-7037(92)90392-V +ZS92,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","F,Cl,OH biotite and apatite endmembers. GHS and V were taken from Table 6 of @ZS92; heat capacity and volume parameters from `berman.dat` in SUPCRT92b.zip file on the [DEW website](http://www.dewcommunity.org/resources.html).",https://doi.org/10.1016/0016-7037(92)90390-5 +ZS92.1,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","phlogopite: updated by @Ber90, then revised G and H using correction for K-bearing silicates [@SHD91]",https://doi.org/10.1016/0016-7037(92)90390-5 +ZS92.2,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","annite: revised G and H",https://doi.org/10.1016/0016-7037(92)90390-5 Sho93,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349","ethylacetate and acetamide",https://doi.org/10.1016/0016-7037(93)90542-5 Sho93.1,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349","carbon monoxide and ethylene",https://doi.org/10.1016/0016-7037(93)90542-5 SK93,"E. L. Shock and C. M. Koretsky",1993,"Geochim. Cosmochim. Acta 57, 4899-4922","metal-acetate complexes",https://doi.org/10.1016/0016-7037(93)90128-J Added: pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv 2017-10-02 14:42:02 UTC (rev 237) @@ -0,0 +1,5 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +almandine,-4941728,-5267216,340.007,11.511,573.96,-14.831,-292.92,502.208,-0.558,0.321,18.613,74.539,,,,,,,,,,,,,, +annite,,-5142800,420,15.408,727.21,-47.7504,-138.319,211.906,-1.697,0,34.447,0,,,,,,,,,,,,,, +ilmenite,-1155320,-1232448,108.628,3.17,150,-4.416,-33.237,34.815,-0.584,1.23,27.248,29.968,,,,,,,,,,,,,, +phlogopite,-5827224,-6210391,334.346,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, Added: pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv 2017-10-02 14:42:02 UTC (rev 237) @@ -0,0 +1,11 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +muscovite,-5603417,-5983434,293.157,14.087,651.49,-38.732,-185.232,274.247,-1.717,4.295,33.527,0,,,,,,,,,,,,,, +phlogopite,-5833918,-6214036,334.158,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, +K-feldspar,-3752109,-3977485,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,1436,298,282.98,-4.83,36.21,-15.733,34.77,41.063 +"K-feldspar,high",-3745498,-3966398,229.157,10.896,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,, +"K-feldspar,low",-3752109,-3977485,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,, +paragonite,-5570375,-5951011,277.699,13.216,577.57,-14.728,-322.144,505.008,-1.973,4.933,39.424,59.701,,,,,,,,,,,,,, +albite,-3710096,-3928421,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, +"albite,high",-3710096,-3928421,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, +"albite,low",-3718518,-3941903,207.443,10.043,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, +jadeite,-2853285,-3031921,133.574,6.034,311.29,-20.051,-53.503,66.257,-0.86,2.149,23.118,25.785,,,,,,,,,,,,,, Added: pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv 2017-10-02 14:42:02 UTC (rev 237) @@ -0,0 +1,13 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +annite,-4799801,-5151031,420,15.408,727.208,-47.7504,-138.319,211.906,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +phlogopite,-5836969,-6218621,334.346,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, +fluormuscovite,-5772803,-6111401,299.03,14.087,680.36024,-65.15743,0,11.058312,-1.7169021,4.2947,33.5273302,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +fluorphlogopite,-6063382,-6403168,336.394,14.637,653.70816,-51.7519,0,-32.459472,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +fluorannite,-4983910,-5293254,422.291,15.075,742.82736,-68.1741,0,41.844184,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +fluortremolite,-11782144,-12457969,570.279,27.045,1272.64728,-94.93496,0,-1.05177392,-1.3917727,3.4809,24.3738877,98.338,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +fluorapatite,-6443050,-6823447,387.857,15.753,668.77056,-45.34201,0,-74.634192,0,0,0,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +hydroxyapatite,-6297702,-6694689,398.735,15.822,758.81024,-64.80598,0,-44.793904,0,0,0,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +chlorapatite,-6217424,-6597260,399.907,16.403,663.87528,-44.35877,0,-69.023448,0,0,0,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +fluortalc,-5717018,-6056244,264.052,13.33,602.74704,-47.66831,0,-29.2588712,-1.6988979,5.665,29.4468112,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +chlorphlogopite,-5600840,-5939422,360.703,16.59,573.45904,-20.63549,-164.657136,210.576536,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, +chlorannite,-4582036,-4890196,449.529,17.247,690.44368,-47.60137,-87.253136,137.682888,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 11:35:03 UTC (rev 236) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 14:42:02 UTC (rev 237) @@ -2,8 +2,14 @@ context("berman") # calculate properties for all available minerals at Tr,Pr -file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ") -dat <- read.csv(file, as.is=TRUE) +dir <- system.file("extdata/Berman/", package="CHNOSZ") +Ber88 <- read.csv(paste0(dir, "/Ber88.csv"), as.is=TRUE) +Ber90 <- read.csv(paste0(dir, "/Ber90.csv"), as.is=TRUE) +SHD91 <- read.csv(paste0(dir, "/SHD91.csv"), as.is=TRUE) +ZS92 <- read.csv(paste0(dir, "/ZS92.csv"), as.is=TRUE) +# assemble the files and remove duplicates (keep the latest) +dat <- rbind(ZS92, SHD91, Ber90, Ber88) +dat <- dat[!duplicated(dat$name), ] mineral <- unique(dat$name) prop_Berman <- NULL @@ -11,7 +17,10 @@ # running this without error means that: # - formulas for the minerals are found in thermo$obigt # - there are no warnings for minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) - expect_silent(properties <- lapply(mineral, berman, check.G=TRUE)) + #expect_silent(properties <- lapply(mineral, berman, check.G=TRUE)) + # - warnings are produced for 3 minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) + expect_warning(properties <- lapply(mineral, berman, check.G=TRUE), + "almandine|annite|phlogopite|fluortremolite", all=TRUE) # save the results so we can use them in the next tests assign("prop_Berman", properties, inherits=TRUE) @@ -39,7 +48,7 @@ # which minerals differ in DGf by more than 4 kcal/mol? idiffG <- which(abs(prop_Berman$G - prop_Helgeson$G) > 4000) expect_match(mineral[idiffG], - "anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite") + "paragonite|anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite") ## we find 9 of them, as follow: #expect_match(mineral[idiffG], # "anthophyllite|antigorite|Ca-Al-pyroxene|cordierite,dry|cordierite,hydrous|lawsonite|margarite|merwinite|paragonite") @@ -48,16 +57,16 @@ idiffH <- which(abs(prop_Berman$H - prop_Helgeson$H) > 4000) # we get the above, plus phlogopite and clinozoisite: expect_match(mineral[idiffH], - "anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite|phlogopite|clinozoisite") + "paragonite|anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite|phlogopite|clinozoisite") # which minerals differ in S by more than 4 cal/K/mol? idiffS <- which(abs(prop_Berman$S - prop_Helgeson$S) > 4) - expect_match(mineral[idiffS], "albite|almandine") + expect_match(mineral[idiffS], "albite|annite|almandine|fluortremolite") #expect_match(mineral[idiffS], "albite|almandine|annite|cordierite,hydrous|fluortremolite") # which minerals differ in Cp by more than 4 cal/K/mol? idiffCp <- which(abs(prop_Berman$Cp - prop_Helgeson$Cp) > 4) - expect_match(mineral[idiffCp], "antigorite|cristobalite,beta|K-feldspar") + expect_match(mineral[idiffCp], "antigorite|cristobalite,beta|K-feldspar|fluortremolite") #expect_match(mineral[idiffCp], # "antigorite|cordierite,hydrous|cristobalite,beta|fluortremolite|glaucophane|greenalite|K-feldspar") Modified: pkg/CHNOSZ/vignettes/obigt.bib =================================================================== --- pkg/CHNOSZ/vignettes/obigt.bib 2017-10-02 11:35:03 UTC (rev 236) +++ pkg/CHNOSZ/vignettes/obigt.bib 2017-10-02 14:42:02 UTC (rev 237) @@ -913,3 +913,39 @@ issn = {0016-7037}, } + at Article{ZS92, + author = {Chen Zhu and Dimitri A Sverjensky}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{F}-{C}l-{OH} partitioning between biotite and apatite}, + year = {1992}, + volume = {56}, + number = {9}, + pages = {3435 - 3467}, + doi = {10.1016/0016-7037(92)90390-5}, + issn = {0016-7037}, +} + + at Article{Ber90, + author = {Berman, R. G.}, + journal = {American Mineralogist}, + title = {{M}ixing properties of {C}a-{M}g-{F}e-{M}n garnets}, + year = {1990}, + volume = {75}, + number = {3-4}, + pages = {328--344}, + issn = {0003-004X}, + publisher = {Mineralogical Society of America}, + url = {http://ammin.geoscienceworld.org/content/75/3-4/328}, +} + + at Article{SHD91, + author = {Sverjensky, Dimitri A. and Hemley, J. J. and D'Angelo, W. M.}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{T}hermodynamic assessment of hydrothermal alkali feldspar-mica-aluminosilicate equilibria}, + year = {1991}, + volume = {55}, + number = {4}, + pages = {989--1004}, + doi = {10.1016/0016-7037(91)90157-Z}, +} + From noreply at r-forge.r-project.org Tue Oct 3 04:31:20 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Oct 2017 04:31:20 +0200 (CEST) Subject: [CHNOSZ-commits] r238 - in pkg/CHNOSZ: . R data inst inst/extdata/Berman inst/extdata/OBIGT tests/testthat Message-ID: <20171003023120.7E127189170@r-forge.r-project.org> Author: jedick Date: 2017-10-03 04:31:15 +0200 (Tue, 03 Oct 2017) New Revision: 238 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/data/OBIGT.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/tests/testthat/test-util.data.R Log: test that data(thermo) and data(OBIGT) make the same database Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-03 02:31:15 UTC (rev 238) @@ -1,6 +1,6 @@ -Date: 2017-10-02 +Date: 2017-10-03 Package: CHNOSZ -Version: 1.1.0-36 +Version: 1.1.0-37 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/R/berman.R 2017-10-03 02:31:15 UTC (rev 238) @@ -91,7 +91,7 @@ iTtr <- T > Tref Ttr <- T[iTtr] # the upper integration limit is Tlambda_P - Ttr[Ttr > Tlambda_P] <- Tlambda_P + Ttr[Ttr >= Tlambda_P] <- Tlambda_P[Ttr >= Tlambda_P] # derived variables tref <- Tref - Td x1 <- l1^2 * Td + 2 * l1 * l2 * Td^2 + l2^2 * Td^3 Modified: pkg/CHNOSZ/data/OBIGT.R =================================================================== --- pkg/CHNOSZ/data/OBIGT.R 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/data/OBIGT.R 2017-10-03 02:31:15 UTC (rev 238) @@ -9,7 +9,7 @@ local({ # create obigt data frame sources_aq <- paste0(c("H2O", "inorganic", "organic", "biotic"), "_aq") - sources_cr <- paste0(c("inorganic", "organic"), "_cr") + sources_cr <- paste0(c("inorganic", "organic", "Berman"), "_cr") sources_liq <- paste0(c("organic"), "_liq") sources_gas <- paste0(c("inorganic", "organic"), "_gas") OBIGTdir <- system.file("extdata/OBIGT/", package="CHNOSZ") Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/data/refs.csv 2017-10-03 02:31:15 UTC (rev 238) @@ -21,15 +21,15 @@ SH88,"E. L. Shock and H. C. Helgeson",1988,"Geochim. Cosmochim. Acta 52, 2009-2036","ionic species",https://doi.org/10.1016/0016-7037(88)90181-0 SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183","inorganic neutral species",https://doi.org/10.1016/0016-7037(89)90341-4 Ber90,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","annite",http://ammin.geoscienceworld.org/content/75/3-4/328 -Ber90.1,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","almandine and ilmenite: revised H and/or S",http://ammin.geoscienceworld.org/content/75/3-4/328 +Ber90.1,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","almandine and ilmenite: modified H and/or S",http://ammin.geoscienceworld.org/content/75/3-4/328 SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O -SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H corrections for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 +SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H revisions for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 +SHD91.1,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","phlogopite: H and S modified by @Ber90, followed by G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 +SHD91.2,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","annite: G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 SPRONS92.1,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","titanite: @BH83 + "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", SPRONS92.2,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","Ca-bearing minerals; "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", Sho92,"E. L. Shock",1992,"Geochim. Cosmochim. Acta 56, 3481-3491","diglycine, alanylglycine, leucylglycine, and diketopiperazine",https://doi.org/10.1016/0016-7037(92)90392-V ZS92,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","F,Cl,OH biotite and apatite endmembers. GHS and V were taken from Table 6 of @ZS92; heat capacity and volume parameters from `berman.dat` in SUPCRT92b.zip file on the [DEW website](http://www.dewcommunity.org/resources.html).",https://doi.org/10.1016/0016-7037(92)90390-5 -ZS92.1,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","phlogopite: updated by @Ber90, then revised G and H using correction for K-bearing silicates [@SHD91]",https://doi.org/10.1016/0016-7037(92)90390-5 -ZS92.2,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","annite: revised G and H",https://doi.org/10.1016/0016-7037(92)90390-5 Sho93,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349","ethylacetate and acetamide",https://doi.org/10.1016/0016-7037(93)90542-5 Sho93.1,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349","carbon monoxide and ethylene",https://doi.org/10.1016/0016-7037(93)90542-5 SK93,"E. L. Shock and C. M. Koretsky",1993,"Geochim. Cosmochim. Acta 57, 4899-4922","metal-acetate complexes",https://doi.org/10.1016/0016-7037(93)90128-J Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/inst/NEWS 2017-10-03 02:31:15 UTC (rev 238) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-35 (2017-10-02) +CHANGES IN CHNOSZ 1.1.0-37 (2017-10-03) --------------------------------------- MAJOR CHANGES: Modified: pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/inst/extdata/Berman/Ber90.csv 2017-10-03 02:31:15 UTC (rev 238) @@ -1,5 +1,5 @@ name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 -almandine,-4941728,-5267216,340.007,11.511,573.96,-14.831,-292.92,502.208,-0.558,0.321,18.613,74.539,,,,,,,,,,,,,, -annite,,-5142800,420,15.408,727.21,-47.7504,-138.319,211.906,-1.697,0,34.447,0,,,,,,,,,,,,,, -ilmenite,-1155320,-1232448,108.628,3.17,150,-4.416,-33.237,34.815,-0.584,1.23,27.248,29.968,,,,,,,,,,,,,, -phlogopite,-5827224,-6210391,334.346,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, +almandine,-4943492,-5267216,340.007,11.511,573.96,-14.831,-292.92,502.208,-0.558,0.321,18.613,74.539,,,,,,,,,,,,,, +annite,-4793115,-5142800,420,15.408,727.21,-47.7504,-138.319,211.906,-1.697,0,34.447,0,,,,,,,,,,,,,, +ilmenite,-1155794,-1232448,108.628,3.17,150,-4.416,-33.237,34.815,-0.584,1.23,27.248,29.968,,,,,,,,,,,,,, +phlogopite,-5830350,-6210391,334.346,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, Modified: pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/inst/extdata/Berman/SHD91.csv 2017-10-03 02:31:15 UTC (rev 238) @@ -1,6 +1,6 @@ name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 muscovite,-5603417,-5983434,293.157,14.087,651.49,-38.732,-185.232,274.247,-1.717,4.295,33.527,0,,,,,,,,,,,,,, -phlogopite,-5833918,-6214036,334.158,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, +phlogopite,-5837044,-6217085,334.346,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, K-feldspar,-3752109,-3977485,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,1436,298,282.98,-4.83,36.21,-15.733,34.77,41.063 "K-feldspar,high",-3745498,-3966398,229.157,10.896,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,, "K-feldspar,low",-3752109,-3977485,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,, @@ -9,3 +9,4 @@ "albite,high",-3710096,-3928421,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, "albite,low",-3718518,-3941903,207.443,10.043,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,, jadeite,-2853285,-3031921,133.574,6.034,311.29,-20.051,-53.503,66.257,-0.86,2.149,23.118,25.785,,,,,,,,,,,,,, +annite,-4799809,-5149494,420,15.408,727.21,-47.7504,-138.319,211.906,-1.697,0,34.447,0,,,,,,,,,,,,,, Modified: pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/inst/extdata/Berman/ZS92.csv 2017-10-03 02:31:15 UTC (rev 238) @@ -1,6 +1,4 @@ name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 -annite,-4799801,-5151031,420,15.408,727.208,-47.7504,-138.319,211.906,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, -phlogopite,-5836969,-6218621,334.346,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,, fluormuscovite,-5772803,-6111401,299.03,14.087,680.36024,-65.15743,0,11.058312,-1.7169021,4.2947,33.5273302,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, fluorphlogopite,-6063382,-6403168,336.394,14.637,653.70816,-51.7519,0,-32.459472,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, fluorannite,-4983910,-5293254,422.291,15.075,742.82736,-68.1741,0,41.844184,-1.6969784,0,34.4473262,0,NA,NA,NA,NA,NA,NA,NA,NA,,,,,, Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-03 02:31:15 UTC (rev 238) @@ -20,7 +20,7 @@ #expect_silent(properties <- lapply(mineral, berman, check.G=TRUE)) # - warnings are produced for 3 minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) expect_warning(properties <- lapply(mineral, berman, check.G=TRUE), - "almandine|annite|phlogopite|fluortremolite", all=TRUE) + "fluortremolite", all=TRUE) # save the results so we can use them in the next tests assign("prop_Berman", properties, inherits=TRUE) Modified: pkg/CHNOSZ/tests/testthat/test-util.data.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-util.data.R 2017-10-02 14:42:02 UTC (rev 237) +++ pkg/CHNOSZ/tests/testthat/test-util.data.R 2017-10-03 02:31:15 UTC (rev 238) @@ -48,6 +48,14 @@ expect_true(all(newdat$name %in% thermo$obigt$name[isp])) }) +test_that("data(thermo) and data(OBIGT) produce the same database", { + data(thermo) + d1 <- get("thermo")$obigt + data(OBIGT) + d2 <- get("thermo")$obigt + expect_equal(d1, d2) +}) + # reference # Richard, L. and Helgeson, H. C. (1998) Calculation of the thermodynamic properties at elevated From noreply at r-forge.r-project.org Tue Oct 3 09:35:25 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Oct 2017 09:35:25 +0200 (CEST) Subject: [CHNOSZ-commits] r239 - in pkg/CHNOSZ: . R data demo inst inst/extdata/Berman inst/extdata/OBIGT man tests/testthat vignettes Message-ID: <20171003073525.7FC09189209@r-forge.r-project.org> Author: jedick Date: 2017-10-03 09:35:24 +0200 (Tue, 03 Oct 2017) New Revision: 239 Added: pkg/CHNOSZ/inst/extdata/Berman/JUN92.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/affinity.R pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/R/util.misc.R pkg/CHNOSZ/data/buffer.csv pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/dehydration.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/species.Rd pkg/CHNOSZ/man/subcrt.Rd pkg/CHNOSZ/man/util.misc.Rd pkg/CHNOSZ/tests/testthat/test-basis.R pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/tests/testthat/test-subcrt.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: rename "cr1" to "cr" (lowest-T polymorph for minerals with transitions) Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-03 07:35:24 UTC (rev 239) @@ -1,6 +1,6 @@ Date: 2017-10-03 Package: CHNOSZ -Version: 1.1.0-37 +Version: 1.1.0-38 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/affinity.R =================================================================== --- pkg/CHNOSZ/R/affinity.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/R/affinity.R 2017-10-03 07:35:24 UTC (rev 239) @@ -1,6 +1,13 @@ # CHNOSZ/affinity.R # calculate affinities of formation reactions +## if this file is interactively sourced, the following are also needed to provide unexported functions: +#source("util.affinity.R") +#source("util.units.R") +#source("util.character.R") +#source("util.list.R") +#source("subcrt.R") + affinity <- function(...,property=NULL,sout=NULL,exceed.Ttr=FALSE, return.buffer=FALSE,balance="PBB",iprotein=NULL,loga.protein=-3) { # ...: variables over which to calculate Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/R/berman.R 2017-10-03 07:35:24 UTC (rev 239) @@ -8,16 +8,20 @@ # reference temperature and pressure Pr <- 1 Tr <- 298.15 - # the number of conditions we have + # get T and P to be same length ncond <- max(length(T), length(P)) + T <- rep(T, length.out=ncond) + P <- rep(P, length.out=ncond) # get thermodynamic parameters dir <- system.file("extdata/Berman/", package="CHNOSZ") Ber88 <- read.csv(paste0(dir, "/Ber88.csv"), as.is=TRUE) Ber90 <- read.csv(paste0(dir, "/Ber90.csv"), as.is=TRUE) SHD91 <- read.csv(paste0(dir, "/SHD91.csv"), as.is=TRUE) ZS92 <- read.csv(paste0(dir, "/ZS92.csv"), as.is=TRUE) - # assemble the files and remove duplicates (keep the latest) - dat <- rbind(ZS92, SHD91, Ber90, Ber88) + JUN92 <- read.csv(paste0(dir, "/JUN92.csv"), as.is=TRUE) + # assemble the files in reverse chronological order + dat <- rbind(JUN92, ZS92, SHD91, Ber90, Ber88) + # remove duplicates (only the first, i.e. latest entry is kept) dat <- dat[!duplicated(dat$name), ] # remove the multipliers multexp <- c(0, 0, 0, 0, # Ber88 Table 2 @@ -90,6 +94,8 @@ # the lower integration limit is Tref iTtr <- T > Tref Ttr <- T[iTtr] + Tlambda_P <- Tlambda_P[iTtr] + Td <- Td[iTtr] # the upper integration limit is Tlambda_P Ttr[Ttr >= Tlambda_P] <- Tlambda_P[Ttr >= Tlambda_P] # derived variables @@ -137,12 +143,17 @@ S <- S + Sds V <- V + Vds Cp <- Cp + Cpds + } else { + + # FIXME: for now, we skip this check if disorder properties are calculated + + ### (for testing) use G = H - TS to check that integrals for H and S are written correctly + Ga_fromHminusTS <- Ha - T * S + # (fails with with berman("K-feldspar", T=convert(600, "K"), P=10000)) + if(!isTRUE(all.equal(Ga_fromHminusTS, Ga))) stop(paste0(name, ": incorrect integrals detected using DG = DH - T*S")) + } - ### (for testing) use G = H - TS to check that integrals for H and S are written correctly - Ga_fromHminusTS <- Ha - T * S - if(!all.equal(Ga_fromHminusTS, Ga)) stop("incorrect integrals detected using DG = DH - T*S") - ### thermodynamic and unit conventions used in SUPCRT ### # use entropy of the elements in calculation of G --> Benson-Helgeson convention (DG = DH - T*DS) Gf <- Ga + Tr * SPrTr_elements Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/R/info.R 2017-10-03 07:35:24 UTC (rev 239) @@ -129,15 +129,23 @@ # all of the species that match ispecies <- which(matches.species) # we return only the first species that matches - # unless they are 'cr1' 'cr2' etc. and we requested state 'cr' - if(identical(state, "cr")) ispecies.out <- ispecies - else ispecies.out <- ispecies[1] + ispecies.out <- ispecies[1] # let user know if there is more than one state for this species if(length(ispecies) > length(ispecies.out)) { ispecies.other <- ispecies[!ispecies %in% ispecies.out] - othertext <- paste(thermo$obigt$state[ispecies.other], collapse=", ") - message("info.character: found ", species, "(", thermo$obigt$state[ispecies.out], - "), also available in ", othertext) + otherstates <- thermo$obigt$state[ispecies.other] + transtext <- othertext <- "" + # we count, but don't show the states for phase transitions (cr2, cr3, etc) + istrans <- otherstates %in% c("cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9") + ntrans <- sum(istrans) + if(ntrans == 1) transtext <- paste(" with", ntrans, "phase transition") + else if(ntrans > 1) transtext <- paste(" with", ntrans, "phase transitions") + otherstates <- otherstates[!istrans] + if(length(otherstates) > 0) othertext <- paste0(", also available in ", paste(otherstates, collapse=", ")) + if(transtext != "" | othertext != "") { + starttext <- paste0("info.character: found ", species, "(", thermo$obigt$state[ispecies.out], ")") + message(starttext, transtext, othertext) + } } return(ispecies.out) } Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-03 07:35:24 UTC (rev 239) @@ -116,7 +116,7 @@ sinfo <- ispecies } else { # from names, get species indices and states and possibly - # keep track of phase species (cr1 cr2 ...) + # keep track of phase species (cr,cr2 ...) sinfo <- numeric() newstate <- character() for(i in 1:length(species)) { @@ -127,7 +127,7 @@ thermo <- get("thermo", "CHNOSZ") if(is.na(si[1])) stop('no info found for ',species[i],' ',state[i]) if(!is.null(state[i])) is.cr <- state[i]=='cr' else is.cr <- FALSE - if(thermo$obigt$state[si[1]]=='cr1' & (is.null(state[i]) | is.cr)) { + if(thermo$obigt$state[si[1]]=='cr' & (is.null(state[i]) | is.cr)) { newstate <- c(newstate,'cr') sinfo <- c(sinfo,si[1]) } else { @@ -151,7 +151,7 @@ state <- as.character(tos[sinfo]) name <- as.character(ton[sinfo]) # a counter of all species considered - # inpho is longer than sinfo if cr1 cr2 ... phases are present + # inpho is longer than sinfo if cr,cr2 ... phases are present # sinph shows which of sinfo correspond to inpho # pre-20091114: the success of this depends on there not being duplicated aqueous or other # non-mineral-phase species (i.e., two entries in obigt for Cu+ screw this up @@ -160,7 +160,7 @@ inpho <- sinph <- coeff.new <- numeric() for(i in 1:length(sinfo)) { if(newstate[i]=='cr') { - searchstates <- c('cr','cr1','cr2','cr3','cr4','cr5','cr6','cr7','cr8','cr9') + searchstates <- c('cr','cr2','cr3','cr4','cr5','cr6','cr7','cr8','cr9') tghs <- thermo$obigt[(ton %in% name[i]) & tos %in% searchstates,] # we only take one if they are in fact duplicated species and not phase species if(all(tghs$state==tghs$state[1])) tghs <- thermo$obigt[sinfo[i],] @@ -293,11 +293,10 @@ } # crystalline, gas, liquid (except water) species - cglstates <- c("liq", "cr", "gas", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9", "cr_Berman") + cglstates <- c("liq", "cr", "gas", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9", "cr_Berman") iscgl <- reaction$state %in% cglstates & reaction$name != "water" if(TRUE %in% iscgl) { - #si <- info(inpho[iscgl],quiet=TRUE) si <- obigt2eos(thermo$obigt[inpho[iscgl],], "cgl", fixGHS = TRUE) p.cgl <- cgl(eosprop, parameters = si, T = T, P = P) # replace Gibbs energies with NA where the @@ -316,8 +315,8 @@ mystate <- reaction$state[i] # don't proceed if the state is cr_Berman if(mystate=="cr_Berman") next - # check if we're below the transition temperature - if(!(reaction$state[i] %in% c('cr1','liq','cr','gas'))) { + # if this phase is cr2 or higher, check if we're below the transition temperature + if(!(reaction$state[i] %in% c('liq','cr','gas'))) { Ttr <- Ttr(inpho[i]-1,P=P,dPdT=dPdTtr(inpho[i]-1)) if(all(is.na(Ttr))) next if(any(T < Ttr)) { @@ -327,14 +326,20 @@ p.cgl[[ncgl[i]]]$G[T= Ttr)) { @@ -343,7 +348,7 @@ p.cgl[[ncgl[i]]]$G[T>=Ttr] <- NA status.Ttr <- "(using NA for G)" } - message(paste('subcrt: some points above transition temperature for',myname, mystate, status.Ttr)) + if(warn.above) message(paste('subcrt: some points above temperature limit for',myname, mystate, status.Ttr)) } } } @@ -380,7 +385,7 @@ for(i in 1:length(is)) v[[i]] <- out[[match(ns[i],is)]] out <- v - # deal with phases (cr1 cr2) here + # deal with phases (cr,cr2) here # we have to eliminate rows from out, # reaction and values from isaq, iscgl, isH2O out.new <- list() @@ -390,10 +395,12 @@ isH2O.new <- logical() for(i in 1:length(sinfo)) { iphases <- which(sinfo[i]==sinph) - # deal with repeated species here ... divide iphases - # by the number of duplicates + # deal with repeated species here if(TRUE %in% duplicated(inpho[iphases])) { - iphases <- iphases[length(which(sinfo==sinfo[i]))] + # only take the first, not the duplicates + ndups <- length(which(sinfo==sinfo[i])) + nphases <- length(iphases) / ndups + iphases <- iphases[1:nphases] } if(length(iphases)>1) { message(paste('subcrt:',length(iphases),'phases for',thermo$obigt$name[sinfo[i]],'... '), appendLF=FALSE) Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/R/util.expression.R 2017-10-03 07:35:24 UTC (rev 239) @@ -53,7 +53,7 @@ } # write logarithm of activity or fugacity if(log != "") { - if(log %in% c("aq", "cr", "liq", "cr1", "cr2", "cr3", "cr4")) acity <- "a" + if(log %in% c("aq", "cr", "liq", "cr2", "cr3", "cr4")) acity <- "a" else if(log %in% c("g", "gas")) acity <- "f" else stop(paste("'", log, "' is not a recognized state", sep="")) logacity <- substitute(log~italic(a), list(a=acity)) Modified: pkg/CHNOSZ/R/util.misc.R =================================================================== --- pkg/CHNOSZ/R/util.misc.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/R/util.misc.R 2017-10-03 07:35:24 UTC (rev 239) @@ -31,7 +31,7 @@ GHS_Tr <- function(ispecies, Htr) { # calculate G, H, and S at Tr for cr2, cr3, ... phases 20170301 # Htr: enthalpy(ies) of transition - # ispecies: the species index for cr1 + # ispecies: the species index for cr (the lowest-T phase) thisinfo <- info(ispecies) name <- thisinfo$name # start from Tr (T=298.15 K) @@ -43,10 +43,10 @@ # where to store the calculated GHS at Tr Gf_Tr <- Hf_Tr <- S_Tr <- numeric() for(i in 1:(length(Htr)+1)) { - # check that we have the correct one of cr1, cr2, ... - thiscr <- paste0("cr", i) + # check that we have the correct one of cr, cr2, cr3, ... + if(i==1) thiscr <- "cr" else thiscr <- paste0("cr", i) if(thisinfo$state!=thiscr | thisinfo$name!=name) stop(paste("species", thisis, "is not", name, thiscr)) - # if we're above cr1, calculate the equivalent GHS at Tr + # if we're above cr (lowest-T), calculate the equivalent GHS at Tr if(i > 1) { # set the starting GHS to 0 (in case they're NA - we only need the increments over temperature) thisinfo$G <- thisinfo$H <- thisinfo$S <- 0 Modified: pkg/CHNOSZ/data/buffer.csv =================================================================== --- pkg/CHNOSZ/data/buffer.csv 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/data/buffer.csv 2017-10-03 07:35:24 UTC (rev 239) @@ -12,9 +12,9 @@ CYSTINE,cystine,aq,-3 ETHANOL,ethanol,aq,-3 MAMINE,methanamine,aq,-3 -HM,hematite,cr1,0 -HM,magnetite,cr1,0 -FeFeO,iron,cr1,0 +HM,hematite,cr,0 +HM,magnetite,cr,0 +FeFeO,iron,cr,0 FeFeO,FeO,cr,0 CO2-AC,CO2,aq,-3 CO2-AC,"acetic acid",aq,-3 @@ -30,11 +30,11 @@ GSH-GSSG,GSSG,aq,-9 NADred-NADox,HNAD(red)-,aq,-3 NADred-NADox,NAD(ox)-,aq,-3 -QFM,quartz,cr1,0 +QFM,quartz,cr,0 QFM,fayalite,cr,0 -QFM,magnetite,cr1,0 +QFM,magnetite,cr,0 PPM,pyrite,cr,0 -PPM,pyrrhotite,cr1,0 -PPM,magnetite,cr1,0 +PPM,pyrrhotite,cr,0 +PPM,magnetite,cr,0 water,water,liq,0 -quartz,quartz,cr1,0 +quartz,quartz,cr,0 Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/data/refs.csv 2017-10-03 07:35:24 UTC (rev 239) @@ -5,7 +5,7 @@ Kel60.3,"K. K. Kelley",1960,"U. S. Bureau of Mines Bull. 584","gypsum Cp",http://www.worldcat.org/oclc/693388901 Pan70,"L. B. Pankratz",1970,"U. S. Bureau of Mines Report of Investigations 7430",chlorargyrite,http://www.worldcat.org/oclc/14154245 PK70,"L. B. Pankratz and E. G. King",1970,"U. S. Bureau of Mines Report of Investigations 7435","bornite and chalcopyrite",http://www.worldcat.org/oclc/14154292 -HDNB78,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","minerals and phase transitions",http://www.worldcat.org/oclc/13594862 +HDNB78,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","data for minerals (n = 167) and phase transitions",http://www.worldcat.org/oclc/13594862 HDNB78.1,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","litharge S, V, and Cp parameters",http://www.worldcat.org/oclc/13594862 RHF79,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","chlorargyrite, rutile, and titanite",http://pubs.er.usgs.gov/publication/b1452 RHF79.1,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","dickite, fluorphlogopite, halloysite, and pyrope",http://pubs.er.usgs.gov/publication/b1452 @@ -22,10 +22,12 @@ SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183","inorganic neutral species",https://doi.org/10.1016/0016-7037(89)90341-4 Ber90,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","annite",http://ammin.geoscienceworld.org/content/75/3-4/328 Ber90.1,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","almandine and ilmenite: modified H and/or S",http://ammin.geoscienceworld.org/content/75/3-4/328 +Eva90,"B. W. Evans",1990,"Lithos 25, 3-23","glaucophane and pumpellyite",https://doi.org/10.1016/0024-4937(90)90003-J SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H revisions for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.1,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","phlogopite: H and S modified by @Ber90, followed by G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.2,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","annite: G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 +JUN92,"C. de Capitani",1992,"JUN92.bs database supplied with Theriak/Domino software","data as listed in JUN92.bs database",http://titan.minpet.unibas.ch/minpet/theriak/theruser.html SPRONS92.1,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","titanite: @BH83 + "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", SPRONS92.2,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","Ca-bearing minerals; "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", Sho92,"E. L. Shock",1992,"Geochim. Cosmochim. Acta 56, 3481-3491","diglycine, alanylglycine, leucylglycine, and diketopiperazine",https://doi.org/10.1016/0016-7037(92)90392-V @@ -73,7 +75,7 @@ AP01,"J. P. Amend and A. V. Plyasunov",2001,"Geochim. Cosmochim. Acta 65, 3901-3917",carbohydrates,https://doi.org/10.1016/S0016-7037(01)00707-4 AS01,"J. P. Amend and E. L. Shock",2001,"FEMS Microbiol. Rev. 25, 175-243","NO and N2O",https://doi.org/10.1111/j.1574-6976.2001.tb00576.x AS01.1,"J. P. Amend and E. L. Shock",2001,"FEMS Microbiol. Rev. 25, 175-243","selenium and molybdenite",https://doi.org/10.1111/j.1574-6976.2001.tb00576.x -MVT01,"L. Mercury, P. Vieillard. and Y. Tardy",2001,"Appl. Geochem. 16, 161-181","ice polymorphs",https://doi.org/10.1016/S0883-2927(00)00025-1 +MVT01,"L. Mercury, P. Vieillard. and Y. Tardy",2001,"Appl. Geochem. 16, 161-181","polymorphs of ice",https://doi.org/10.1016/S0883-2927(00)00025-1 PS01,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","aqueous nonelectrolytes",https://doi.org/10.1016/S0016-7037(01)00678-0 PS01.1,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","acetic acid and methane",https://doi.org/10.1016/S0016-7037(01)00678-0 Ric01,"L. Richard",2001,"Geochim. Cosmochim. Acta 65, 3827-3877","organic sulfur compounds",https://doi.org/10.1016/S0016-7037(01)00761-X Modified: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/demo/buffer.R 2017-10-03 07:35:24 UTC (rev 239) @@ -3,7 +3,7 @@ # reproduces Figure 6 of Schulte and Shock, 1995 (doi:10.1007/BF01581580) b.species <- c("Fe", "CO2", "H2O", "N2", "H2", "H2S", "SiO2") -b.state <- c("cr1", "gas", "liq", "gas", "gas", "aq", "aq") +b.state <- c("cr", "gas", "liq", "gas", "gas", "aq", "aq") b.logact <- c(0, 1, 0, 0, 0, 0, 0) basis(b.species, b.state, b.logact) xlim <- c(0, 350) Modified: pkg/CHNOSZ/demo/dehydration.R =================================================================== --- pkg/CHNOSZ/demo/dehydration.R 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/demo/dehydration.R 2017-10-03 07:35:24 UTC (rev 239) @@ -17,7 +17,7 @@ reactants <- c("[AABB]", "[AABB]", "malate-2", "goethite", "gypsum", "epsomite", "ethanol") products <- c("[UPBB]", "[PBB]", "fumarate-2", "hematite", "anhydrite", "hexahydrite", "ethylene") rstate <- c("aq", "cr", "aq", "cr", "cr", "cr", "aq") -pstate <- c("aq", "cr", "aq", "cr1", "cr", "cr", "gas") +pstate <- c("aq", "cr", "aq", "cr", "cr", "cr", "gas") rcoeff <- c(-1, -1, -1, -2, -0.5, -1, -1) pcoeff <- c(1, 1, 1, 1, 0.5, 1, 1) # position and rotation of the names Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/inst/NEWS 2017-10-03 07:35:24 UTC (rev 239) @@ -1,12 +1,12 @@ -CHANGES IN CHNOSZ 1.1.0-37 (2017-10-03) +CHANGES IN CHNOSZ 1.1.0-38 (2017-10-03) --------------------------------------- MAJOR CHANGES: - Add functions implementing the Deep Earth Water (DEW) model - (Sverjensky et al., 2014): calculateDensity(), - calculateGibbsofWater(), calculateEpsilon(), calculateQ(), and - water.DEW(). + (Sverjensky et al., 2014): water.DEW() and its supporting functions + calculateDensity(), calculateGibbsofWater(), calculateEpsilon(), + calculateQ(). - The computational setting for water (thermo$opt$par) can now be set using water("DEW"), water("IAPWS"), etc. @@ -19,14 +19,27 @@ - Calculations related to Berman's (1988) Figs. 1 and 2 for the lambda transition of quartz are presented in the new demo lambda.R. +COMPUTATIONAL IMPROVEMENTS: + +- For minerals with phase transitions (states 'cr2' 'cr3' etc.) in + thermo$obigt (i.e. the Helgeson minerals), it is now possible to use + the minerals in basis(), species(), affinity() with proper accounting + for transition effects. Just set the state to 'cr' or omit it, + e.g. species("quartz"). + - Implement SUPCRT92's handling of variable volume for quartz and coesite. Calculations for other minerals still assume constant volume of each phase. +- calculations of the g function are now enabled for DEW (with + pressure derivative) and IAPWS-95 (no derivatives included). + - 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: + - Add data(OBIGT) and data(CHNOSZ) commands to reset only the thermodynamic database (OBIGT) or system settings (CHNOSZ: basis and species) to their defaults. data(thermo) is still used to reset @@ -38,8 +51,6 @@ - add.obigt() gets new argument 'species' for selecting species to add. -DATABASE UPDATES: - - Add DEW_aq.csv with aqueous species data from the DEW spreadsheet (May 2017 version). Species with data unchanged from the default database in CHNOSZ are not included. For the time being, only @@ -79,14 +90,11 @@ - In water.* functions, rename the "diel" variable to "epsilon". -- calculations of the g function (but not its derivatives) are now - enabled for DEW and IAPWS-95. +CLEANUP: - To save space, taxid_names.csv has been trimmed to hold only those taxids listed in extdata/bison/gi.taxid.txt. -CLEANUP: - - Remove Eco.csv.xz and rename more.aa() to yeast.aa(). - Remove transfer() and associated functions draw.transfer(), apc(), and Added: pkg/CHNOSZ/inst/extdata/Berman/JUN92.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/JUN92.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/JUN92.csv 2017-10-03 07:35:24 UTC (rev 239) @@ -0,0 +1,3 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +glaucophane,-11225858,-11960500,535,26.05,1717.5,-192.72,70.5,0,-1.16,2.9,22,88,,,,,,,,,,,,,, +pumpellyite,-13448936,-14402300,584,29.55,1576,-106.038,-283.042,383.8351,-0.51516,1.288,34.67,0,,,,,,,,,,,,,, Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz 2017-10-03 02:31:15 UTC (rev 238) +++ pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz 2017-10-03 07:35:24 UTC (rev 239) @@ -1,58 +1,81 @@ -?7zXZ???F!t/?????&S]7I??b???9??????TB;q?"?q???cL;?"??B??.?=???c;?5o?-W???x1}??Q^Y^5???????^w?OAqx]s "???!?? j?@v #???7???>3??)O2??d??l??CEe9????P????r)2??D??????????KM?=_5?E:?-?O?F??b?S???I~R?i???o? ?!??wO0j? !3?h????%C??U??kq?!???6e?????Zy?@%M?????????X?,S????s?Tc7?x?tW???2C??aV?g??{???E?|w?&??O?U?T????????`??????r??3D? ??????F??Wn?Y???0??_<9XoN?2?*i???? -??$?B`??????W???5R?x???EXX? -J??????6T?J??????R?YZ????zp%c??????R?x??[Dw????v-??O??????j???im,??R???oo???/)E?;2??-Dg???`??:u7?B5?w?ik3\Z.P??4 -!9???|??@"?-r???c%?;???QVTT}?'u?????????3???'??j??|?-?'??!??????(B?\k~?????b?rs@???_%T?_6?2O?H~~?? ?&)?,?%?"?F^T ?????',??1?^*|qL)d>~?h???`?? ???o?&?4?hc+ -?F& `Q?/T'cF???h),?}C??zd"l???7I??]?*|a?`(??N?m?ki\VS???????d?fz?GT????"Z?p`?a???g??ik?9??9? ?u? ?B*?N)E?"?t?R?u37???U -?5}#[9??!?#?x??????NZ?-???P?=???{$?B??j~?}?????J?RGz.W1Xcm????I???;?g%w?)??c???ZS?>??!0=:+?????? -Mi?r7??!??"KBW??`T?cqy??? -???*???? ?r@???a???z??vE7?V?|???_???????@???[?g?KH??>??MI??jf?K? ??++@"?x???zr -???#M.??????~]???:???l%???$?????H????@$h?O?u8????S/3'?1???#?3n u?#????>???5z?H?O???b?????J2j?j?#kY ?o&pqa??: J?4?????Gi24w?h?x`??????1???'????|f*??Z??? u+??#9M%???yk!?0dl?b4?o?,?9?f(?0?:??P?Jc?U???aL??(???@A?)L?;??,w?"N ?^aY'?Z?S3??k+?B???????` -???b -?w??(?;?}U?????????\12?ZD!?"??????)???t"???I?????u??Z? 3q?Z?t?SU^6F?.??,4?E?3??%?`? cn?*?v?f?? -????9P3??b?1?????d?,???]?n?b-M.^8^?/:UEIz?EZ:??~???????i?xA????????&?q?b?'???????K?????i??;OV?????l??PR??g?T;5Az????8Zi?7??Jr?(?P???W???4OL?H?? ??fV??????C??? -l!?&???Q???????r?a? WXf????[.a??]SGv?4F???[h??Oh?)=?6?6?P????\#???t??]?+R??wny3?????????W\4?%G?}"?P?V???0W1d5F??j????#$????B???bL?z??????{?kQ??%B$??XXrAH?x')?I??U?&????P{+??????????"u?S?'??-?X#?????{=???$?y+^|?/??m+?M6YV?R??D??B>??;5??XG?V???]??O?????W??\K_$>V=???? -??????;?c???cb??[&??{q??H??G I??A????V??g?????W?N:Y2?zr??v?7?t~2-??1/???!???K???3x?Hi3?]C????h?N?Gi????D? ????k?gS?#5?rD???H??>f?f&?{??{?(p0|????WTj???Q?p[Sbkp,?}??(??Y?k?Y??yG?=P?????6??Lb^E?????gN???eH????:T?>0`??u9??".R S???p??????#y?qB= -p)d?O?!???k< -?6P?c6??(~3????!0>?etY ?2?U?????b?? ?]0??}??-p2????D????Zg???nw?Ya??S?I|/??????p/????ql?.|%t????u?R?BI????? -?_ ??????v??N????E??G\?f?"??}?aWC0?'??,?_t???????UW? ?????#K:>, ?x?oQ?????y5????8???????jD????]Juy???????3|t?K???'Ki??_?v????>? ????T?= ??h?>?/{??*?+*y?we??!???9_R? -??e?:?????F&D~?U?'Rp??_ra%A???o?"j???,p?????%????P??ue???}???:?X???#g'GY\???g???:??`?/?g+I?6?? ?????Gy?Ds? ??`?*?d???l??``???{?????-G!? -??u2???D? ????P} -?O???Hp9wk???;a?????????[r????????E?????????U?x_4??? -????L?*?|? ?h?????E?T??%0`????z?????_??J?0?Y????????u/( e0??P????C????%?L?4E??+V?n???{A??.???h??$/9????]gS?????@)R!?q^??@%??Y?"?e?H?ZBZ?l?'???-???rq^???3]???~h?\9?$??????????"????iq??P?Y?p??R??5???llmY????dN???[So,?l???t??????aa??S???'+?y????k5??J?y0?S?`)4??n)? -???? Ez#*Z?(lm?0?D)?nun??Vu?}|%??????x????SM??k ?8r' ?=;???^m?hq{???YaXyq?G??????q?Z?6Y??????D?? -e??ClCc????D?????_j????;?*%??&?9??A???E'%??x????`W??;?b??0#?c?qW?+??6[]f?Z?'D??X? ?[?s3f?F?????~??EJ?T [o?;??????6?V??Z?O????????????Tft?i!S?6k??????q?PyX?????/??O??a?u*?)???c?dt&????????{ ???f?ny???? ??G/??B??w(fi_???n??v?U?s?j(Z? ??? -?<'??wwX??$ck???T?1*?v~&??>???N??'??3??2???5vR??? ec?B8=u?WI??`F?W, ?:&2@??_}5?5x???8?LOq=?%?q?hJ(?+Y???M?SSU????/??'?;)??????z????????6 _-?%@ ????:??H??g???~?^r&??'? ??X??OK????D!?p????HC?h?0?????X?f???;/??m??R?6?I??? -?\??I !?;?J??Mg???4???"a;Vn??????????????q???R????'??&T?x?|???o??&` ??7_?!-?8"????3/???6?4Q5A?6???]?D??5S??p??6???Q??Md5r?|?\??'??y?????J???????? H$?? ?N0????T?m??T\PDXuI????9?x?hTzpI?3.? ???_?: F ????)M???U? ????J=|?2?I? ??????????d?????Rnh??????????+R?????????u?K??#=???!jZ?V6????gz???o-??d?9?_??6?hP?3????x??4s$x(M?]?b/?=N?H4DP???0?p8kB[?Ep? -?t?v?1??? ?????"???R(?1*?eP?w<(?H???r????C??/???M?C???Z?X???T?i:?=ps?????-?????$???R???$S^?Hu?????H??@?\~?u ?}?????`?.~ -}?S??Et ????\?`?=<???x?? r?O????f!3??????W??s?T??.f?`?????s???|??????pq???M}1g?:>\ P???T(A>?~?JF?a?G`?N????j?????j;7?????C??P????e??Dj(???X? -u -?P?n????M?4Y??bHi?xb?&???X??T U?#)}?%?kB?E)?)D?????{???\??t?IP??? -??Ka`]??K?P??g???b??iS???*?h??T?S@???>?? ?}?/??????????8????N?g????? |'?KVBd.?D79????h??a!A?{???N?W?????k??Z???????E??????b??-p?%??]<-J?^????H? e?`??#?n^o? ??|??y}M<:??-%5^????? )?Q??\o??~t/{?-3g0?c???f????<3??E?j????;?h?,???s???????J???????zy?????_n????c -Q??????????<Spo?Dbe?????r??j!K?!??i??l?W??(?w?!flt??}?q?&???~?`.??:?#3?^ -T ??F!^0$?????uA?]i????FR?>???(??C?%1{??G???u7????#??a???CR=Y?2?Q ?84=X??*?t?h(??Y?=@?P?? ??q?????c???K?????P?uT0iU??^???H -?? [1?u ??? ??????,????S?B^&?8~8? ?N?#_??:??z0r?R;?@k?1.xg??C?@????????S?e??7????>%q ?1:?3?d?H?????????P,?????? '??A?Y?c?f?jqK+??GE -?[T????f? H\!9????_?!z??B$??p?4????XCw@?1xyQ^E}E?? m?9??O \N??d??Tgk?:v??k?mV2????D????Ua??F??? -??? oh?g????4C?I2?np??PV;?a?M?\e? -,?]{G2?.????s????;B? -M?s[??S?????H@C?V ????7??I??S?mZ???Y[?[Ibf~J89????~#}??4????gE???f??`?Z n?=?k???c,d Author: jedick Date: 2017-10-03 09:49:57 +0200 (Tue, 03 Oct 2017) New Revision: 240 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/man/subcrt.Rd Log: subcrt(): output column named 'polymorph', not 'state', to identify transitions Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-03 07:35:24 UTC (rev 239) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-03 07:49:57 UTC (rev 240) @@ -1,6 +1,6 @@ Date: 2017-10-03 Package: CHNOSZ -Version: 1.1.0-38 +Version: 1.1.0-39 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-03 07:35:24 UTC (rev 239) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-03 07:49:57 UTC (rev 240) @@ -430,7 +430,7 @@ } # update our objects - out.new[[i]] <- cbind(out.new.entry,data.frame(state=phasestate)) + out.new[[i]] <- cbind(out.new.entry,data.frame(polymorph=phasestate)) reaction.new[i,] <- reaction[iphases[phasestate[1]],] # mark the minerals with multiple phases rs <- as.character(reaction.new$state) @@ -470,7 +470,7 @@ if(length(calcprop)>1) for(i in 1:length(out)) { # keep state/loggam columns if they exists ipp <- match(calcprop, colnames(out[[i]])) - if('state' %in% colnames(out[[i]])) ipp <- c(ipp,match('state',colnames(out[[i]]))) + if('polymorph' %in% colnames(out[[i]])) ipp <- c(ipp,match('polymorph',colnames(out[[i]]))) if('loggam' %in% colnames(out[[i]])) ipp <- c(ipp,match('loggam',colnames(out[[i]]))) out[[i]] <- out[[i]][,ipp,drop=FALSE] } @@ -478,7 +478,7 @@ # add up reaction properties if(do.reaction) { o <- 0 - statecols <- NULL + morphcols <- NULL # do our affinity calculations here if(!is.null(logact)) { logQ <- logK <- rep(0,length(T)) @@ -495,12 +495,12 @@ # the addition of properties for(i in 1:length(coeff)) { # assemble state columns if they exist - if('state' %in% colnames(out[[i]])) { - sc <- as.data.frame(out[[i]]$state) - out[[i]] <- out[[i]][,-match('state',colnames(out[[i]]))] + if('polymorph' %in% colnames(out[[i]])) { + sc <- as.data.frame(out[[i]]$polymorph) + out[[i]] <- out[[i]][,-match('polymorph',colnames(out[[i]]))] colnames(sc) <- as.character(reaction$name[i]) - if(is.null(statecols)) statecols <- sc - else statecols <- cbind(statecols,sc) + if(is.null(morphcols)) morphcols <- sc + else morphcols <- cbind(morphcols,sc) } # include a zero loggam column if we need it # for those species that are ideal @@ -511,8 +511,8 @@ o.i <- cbind(o.i,loggam=0) o <- o + o.i * coeff[i] } - # output for reaction (stack on state columns if exist) - if(!is.null(statecols)) out <- list(reaction=reaction,out=o,state=statecols) + # output for reaction (stack on polymorph columns if exist) + if(!is.null(morphcols)) out <- list(reaction=reaction,out=o,polymorphs=morphcols) else out <- list(reaction=reaction,out=o) } else { # output for species: strip the coeff column from reaction @@ -532,7 +532,7 @@ if(convert) P.out <- outvert(P,"bar") else P.out <- P # try to stuff in a column of rho if we have aqueous species # watch out! supcrt-ish densities are in g/cc not kg/m3 - if('rho' %in% calcprop | (missing(property) & any(c(isaq,isH2O))) & (names(out)[i])!='state') + if('rho' %in% calcprop | (missing(property) & any(c(isaq,isH2O))) & (names(out)[i])!='polymorph') out[[i]] <- cbind(data.frame(T=T.out,P=P.out,rho=H2O.PT$rho/1000),out[[i]]) else out[[i]] <- cbind(data.frame(T=T.out,P=P.out,out[[i]])) Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-03 07:35:24 UTC (rev 239) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-03 07:49:57 UTC (rev 240) @@ -63,7 +63,7 @@ Alternatively, if the \code{\link{basis}} species of a system were previously defined, and if the species being considered are within the compositional range of the basis species, an unbalanced reaction given in the arguments to \code{subcrt} will be balanced automatically, without altering the coefficients on the species identified in the arguments (unless perhaps they correspond to basis species), and without a warning. However, if a reaction is unbalanced and \code{action.unbalanced} is set to NULL, no warnings are generated and no attempt is made to balance the reaction. -Minerals with phase transitions (denoted by having states \samp{cr} (lowest T phase), \samp{cr2}, \samp{cr3} etc.) can be defined generically by \samp{cr} in the \code{state} argument with a character value for \code{species}. +Minerals with polymorphic transitions (denoted by having states \samp{cr} (lowest T phase), \samp{cr2}, \samp{cr3} etc.) can be defined generically by \samp{cr} in the \code{state} argument with a character value for \code{species}. \code{subcrt} in this case simultaneously calculates the requested properties of all the phases of each such mineral (phase species) and, using the values of the transition temperatures calculated from those at P = 1 bar given in the thermodynamic database together with functions of the entropies and volumes of transitions (see \code{\link{dPdTtr}}), determines the stable phase of the mineral at any grid point and substitutes the properties of this phase at that point for further calculations. If individual phase species of minerals are specified (by \samp{cr}, \samp{cr2} etc. in \code{state}), and \code{exceed.Ttr} is \code{FALSE} (the default), the Gibbs energies of these minerals are assigned values of NA at conditions beyond their transition temperature, where another of the phases is stable. If you set \code{exceed.Ttr} to \code{TRUE} while investigating the properties of phases of minerals identified generically (by \samp{cr}) the function will identify the stable phase on the basis not of the transition temperatures but of the calculated Gibbs energies of the phase species. @@ -158,12 +158,12 @@ basis("CHNOS") subcrt("C2H5OH", 1) # reaction -## properties of mineral phases -# properties of the stable phases +## mineral polymorphs +# properties of the stable polymorph subcrt("pyrrhotite") # properties of just the high-T phase subcrt(c("pyrrhotite"), state="cr2") -# phase transitions in a reaction +# polymorphic transitions in a reaction subcrt(c("pyrite", "pyrrhotite", "H2O", "H2S", "O2"), c(-1, 1, -1, 1, 0.5)) ## these produce messages about problems with the calculation From noreply at r-forge.r-project.org Tue Oct 3 10:41:50 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Oct 2017 10:41:50 +0200 (CEST) Subject: [CHNOSZ-commits] r241 - in pkg/CHNOSZ: . R demo inst man tests/testthat Message-ID: <20171003084150.E7953188779@r-forge.r-project.org> Author: jedick Date: 2017-10-03 10:41:50 +0200 (Tue, 03 Oct 2017) New Revision: 241 Added: pkg/CHNOSZ/demo/berman.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/berman.Rd pkg/CHNOSZ/man/subcrt.Rd pkg/CHNOSZ/tests/testthat/test-subcrt.R Log: get tests and examples to work with 'polymorph' output from subcrt() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-03 08:41:50 UTC (rev 241) @@ -1,6 +1,6 @@ Date: 2017-10-03 Package: CHNOSZ -Version: 1.1.0-39 +Version: 1.1.0-40 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/R/berman.R 2017-10-03 08:41:50 UTC (rev 241) @@ -4,7 +4,7 @@ # in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. # J. Petrol. 29, 445-522. https://doi.org/10.1093/petrology/29.2.445 -berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE, calc.transition=TRUE, calc.disorder=TRUE, units="cal") { +berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE, calc.transition=TRUE, calc.disorder=FALSE, units="cal") { # reference temperature and pressure Pr <- 1 Tr <- 298.15 @@ -143,17 +143,14 @@ S <- S + Sds V <- V + Vds Cp <- Cp + Cpds - } else { - - # FIXME: for now, we skip this check if disorder properties are calculated - - ### (for testing) use G = H - TS to check that integrals for H and S are written correctly - Ga_fromHminusTS <- Ha - T * S - # (fails with with berman("K-feldspar", T=convert(600, "K"), P=10000)) - if(!isTRUE(all.equal(Ga_fromHminusTS, Ga))) stop(paste0(name, ": incorrect integrals detected using DG = DH - T*S")) - } + ### (for testing) use G = H - TS to check that integrals for H and S are written correctly + Ga_fromHminusTS <- Ha - T * S + # FIXME: this check fails if disorder properties are calculated: + # berman("K-feldspar", T=convert(600, "K"), P=10000, calc.disorder=TRUE) + if(!isTRUE(all.equal(Ga_fromHminusTS, Ga))) stop(paste0(name, ": incorrect integrals detected using DG = DH - T*S")) + ### thermodynamic and unit conventions used in SUPCRT ### # use entropy of the elements in calculation of G --> Benson-Helgeson convention (DG = DH - T*DS) Gf <- Ga + Tr * SPrTr_elements Added: pkg/CHNOSZ/demo/berman.R =================================================================== --- pkg/CHNOSZ/demo/berman.R (rev 0) +++ pkg/CHNOSZ/demo/berman.R 2017-10-03 08:41:50 UTC (rev 241) @@ -0,0 +1,28 @@ +# CHNOSZ/demo/berman.R 20171003 +# make some mineral activity diagrams using Berman (1988) and related data + +# using the Helgeson data +# set up basis species +basis(c("K+", "Al+3", "quartz", "H2O", "O2", "H+")) +# use pH = 0 so that aK+ = aK+/aH+ +basis("pH", 0) +# load the species +species(c("K-feldspar", "muscovite", "kaolinite", "pyrophyllite", "andalusite"), "cr") +# calculate affinities in aK+ - temperature space +a <- affinity(`K+`=c(0, 6), T=c(25, 650), P=1000) +# note that we go just past the quartz transition, but it has no effect on the diagram +diagram(a) + +# now using the Berman data +basis("SiO2", "cr_Berman") +# it might be good to check that we have Berman's quartz and not coesite or some other SiO2 phase +info(basis()$ispecies[3]) +# remove the Helgeson minerals +species(delete=TRUE) +# load the Berman minerals +species(c("K-feldspar", "muscovite", "kaolinite", "pyrophyllite", "andalusite"), "cr_Berman") +# calculate affinities in aK+ - temperature space +a <- affinity(`K+`=c(0, 6), T=c(25, 650), P=1000) +diagram(a, add=TRUE, names="", col="blue", lwd=2) + +legend("topleft", lty=c(1, 1), lwd=c(1, 2), col=c("black", "blue"), legend=c("Helgeson et al., 1978", "Berman, 1988")) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/inst/NEWS 2017-10-03 08:41:50 UTC (rev 241) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-38 (2017-10-03) +CHANGES IN CHNOSZ 1.1.0-40 (2017-10-03) --------------------------------------- MAJOR CHANGES: @@ -90,6 +90,9 @@ - In water.* functions, rename the "diel" variable to "epsilon". +- Components of subcrt() output indicating the stable polymorph of a + mineral are now named 'polymorph', not 'state'. + CLEANUP: - To save space, taxid_names.csv has been trimmed to hold only those Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-03 08:41:50 UTC (rev 241) @@ -83,7 +83,7 @@ } \section{Known Bugs}{ - \code{\link{subcrt}} does not correctly identify the stable polymorph of some minerals at high temperature. + \code{\link{subcrt}} does not correctly identify the stable polymorph of some minerals at high temperature (see skarn example). The values generated by \code{\link{buffer}} may not be applied correctly by \code{\link{affinity}} in calculating the affinities of the formation reactions. (The values returned by \code{affinity(..., return.buffer=TRUE)} do appear to be correct in the examples). } Modified: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-03 08:41:50 UTC (rev 241) @@ -8,7 +8,7 @@ \usage{ berman(name, T = 298.15, P = 1, thisinfo = NULL, check.G = FALSE, - calc.transition = TRUE, calc.disorder = TRUE, units = "cal") + calc.transition = TRUE, calc.disorder = FALSE, units = "cal") } \arguments{ @@ -34,6 +34,8 @@ A warning is produced if the absolute value of the difference between tabulated and calculated DGfTrPr is greater than 1000 J/mol. Providing \code{thisinfo} means that the mineral name is not searched in \code{thermo$obigt}, potentially saving some running time. + +FIXME: the default for \code{calc.disorder} is temporarily FALSE, as the code produces incorrect Gibbs energies. } \examples{ Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-03 08:41:50 UTC (rev 241) @@ -204,13 +204,10 @@ coeff=c(-1, -3, -4, -2, 3, 3, 2, 2, 3), state=c("cr", "g", "aq", "aq", "cr", "cr", "cr", "aq", "liq"), P=P, T=T, grid="P") -# the results are not identical to SUPCRT92, at least because CHNOSZ -# doesn't have volume changes for quartz, and has updated -# parameters for species e.g. Cu+ from Shock et al., 1997 -# the following is to help detect unintended changes to the code -# across revisions; the code *should* be fixed sometime so that -# the last 1 becomes a 3 -stopifnot(all.equal(s$state$chalcopyrite[1:11], +# The results are not identical to SUPCRT92, as CHNOSZ has updated +# parameters for species e.g. Cu+ from Shock et al., 1997. +# FIXME: the last 1 should be a 3 +stopifnot(all.equal(s$polymorphs$chalcopyrite[1:11], c(1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 1))) ## Standard Gibbs energy of reactions with HCN and Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-03 07:49:57 UTC (rev 240) +++ pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-03 08:41:50 UTC (rev 241) @@ -18,7 +18,7 @@ iacanthite <- info("acanthite", "cr2") #expect_message(subcrt(iacanthite), "subcrt: some points below transition temperature for acanthite cr2 \\(using NA for G\\)") expect_message(subcrt(iacanthite), "subcrt: some points above temperature limit for acanthite cr2 \\(using NA for G\\)") - expect_equal(subcrt("acanthite")$out$acanthite$state, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3)) + expect_equal(subcrt("acanthite")$out$acanthite$polymorph, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3)) }) test_that("heat capacity of minerals are consistent with literature", { @@ -63,7 +63,7 @@ sout.C7 <- s.C7$out expect_equal(sout.C7$G/1000, AS01.C7, tolerance=1e-4) # we can also check that sulfur has expected phase transitions - expect_equal(s.C7$state$sulfur, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3)) + expect_equal(s.C7$polymorphs$sulfur, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3)) ## AS01 Table 8.3 Reaction E12: 4(2-)propanol(aq) + 3CO2(aq) + 2H2O(l) = 3CH4(aq) + 4lactic acid(aq) #DG0.E12 <- c(132.52, 132.26, 132.29, 132.49, 132.74, 133.15, 133.98, 135.04, 136.31, 137.79, 141.97, 149.53) From noreply at r-forge.r-project.org Wed Oct 4 17:51:39 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 4 Oct 2017 17:51:39 +0200 (CEST) Subject: [CHNOSZ-commits] r242 - in pkg/CHNOSZ: . R demo inst inst/extdata/OBIGT man tests/testthat vignettes Message-ID: <20171004155139.2E5A4188833@r-forge.r-project.org> Author: jedick Date: 2017-10-04 17:51:38 +0200 (Wed, 04 Oct 2017) New Revision: 242 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/H2O_aq.csv.xz pkg/CHNOSZ/man/makeup.Rd pkg/CHNOSZ/tests/testthat/test-IAPWS95.R pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/tests/testthat/test-makeup.R pkg/CHNOSZ/tests/testthat/test-subcrt.R pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: change formula of aqueous electron from "Z0-1" to "(Z-1)" Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-04 15:51:38 UTC (rev 242) @@ -1,6 +1,6 @@ -Date: 2017-10-03 +Date: 2017-10-04 Package: CHNOSZ -Version: 1.1.0-40 +Version: 1.1.0-41 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/R/basis.R 2017-10-04 15:51:38 UTC (rev 242) @@ -104,7 +104,7 @@ rownames(comp) <- as.character(thermo$obigt$formula[ispecies]) # FIXME: the electron doesn't look like a chemical formula # this is needed for affinity() to understand a 'pe' or 'Eh' variable - if("Z0-1" %in% rownames(comp)) rownames(comp)[rownames(comp)=="Z0-1"] <- "e-" + if("(Z-1)" %in% rownames(comp)) rownames(comp)[rownames(comp)=="(Z-1)"] <- "e-" # now check it for validity of basis species # the first test: matrix is square if( nrow(comp) > ncol(comp) ) stop("overdetermined system; square stoichiometric matrix needed") Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/demo/00Index 2017-10-04 15:51:38 UTC (rev 242) @@ -21,3 +21,4 @@ adenine HKF parameters regressed from heat capacity and volume of aqueous adenine DEW Deep Earth Water (DEW) model for high pressures lambda Effects of lambda transtion on thermodynamic properties of quartz +berman Mineral stability diagrams calculated using Berman's equations Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/inst/NEWS 2017-10-04 15:51:38 UTC (rev 242) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-40 (2017-10-03) +CHANGES IN CHNOSZ 1.1.0-41 (2017-10-04) --------------------------------------- MAJOR CHANGES: @@ -71,6 +71,11 @@ inconsistent results for metastable steam (Zavarin et al., 2016, LLNL-TR-701407, doi: 10.2172/1325873). +- Change the formula of the electron from "Z0-1" (parsed as "zero Z + with minus one charge") to the equivalent but nicer-to-read "(Z-1)" + (parsed as "minus one Z"; the parentheses cause "-1" to be interpreted + as the coefficient on Z instead of the charge in the formula). + OTHER CHANGES: - Add 'tol' argument to equil.reaction() (convergence tolerance for Modified: pkg/CHNOSZ/inst/extdata/OBIGT/H2O_aq.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/H2O_aq.csv.xz 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/inst/extdata/OBIGT/H2O_aq.csv.xz 2017-10-04 15:51:38 UTC (rev 242) @@ -1 +1 @@ -?7zXZ???F!t/????]7I??b???9??????TB;q?"?q???cL;?"??= 1000 J/cal different from GfPrTr(table) - #expect_warning(Berman <- lapply(mineral, berman), - # "annite|dawsonite|dravite|fluortremolite|greenalite|siderite|Na-Fe-saponite.3W", all=TRUE) }) # assemble a data frame for Berman properties @@ -41,14 +37,11 @@ # minerals with missing properties are not matched here # (i.e. fluorphlogopite, fluortremolite, glaucophane, and pyrope: no G and H in prop_Helgeson data) -test_that("Berman and Helgeson properties have large differences for few minerals", { +test_that("Berman and Helgeson tabulated properties have large differences for few minerals", { # which minerals differ in DGf by more than 4 kcal/mol? idiffG <- which(abs(prop_Berman$G - prop_Helgeson$G) > 4000) expect_match(mineral[idiffG], "paragonite|anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite") - ## we find 9 of them, as follow: - #expect_match(mineral[idiffG], - # "anthophyllite|antigorite|Ca-Al-pyroxene|cordierite,dry|cordierite,hydrous|lawsonite|margarite|merwinite|paragonite") # which minerals differ in DHf by more than 4 kcal/mol? idiffH <- which(abs(prop_Berman$H - prop_Helgeson$H) > 4000) @@ -59,17 +52,52 @@ # which minerals differ in S by more than 4 cal/K/mol? idiffS <- which(abs(prop_Berman$S - prop_Helgeson$S) > 4) expect_match(mineral[idiffS], "albite|annite|almandine|fluortremolite") - #expect_match(mineral[idiffS], "albite|almandine|annite|cordierite,hydrous|fluortremolite") # which minerals differ in Cp by more than 4 cal/K/mol? idiffCp <- which(abs(prop_Berman$Cp - prop_Helgeson$Cp) > 4) expect_match(mineral[idiffCp], "antigorite|cristobalite,beta|K-feldspar|fluortremolite") - #expect_match(mineral[idiffCp], - # "antigorite|cordierite,hydrous|cristobalite,beta|fluortremolite|glaucophane|greenalite|K-feldspar") # which minerals differ in V by more than 1 cm^3/mol? idiffV <- which(abs(prop_Berman$V - prop_Helgeson$V) > 1) expect_match(mineral[idiffV], "anthophyllite|antigorite|chrysotile|merwinite") - #expect_match(mineral[idiffV], - # "anthophyllite|antigorite|chrysotile|cordierite,hydrous|glaucophane|greenalite|merwinite") }) + + +test_that("Berman and Helgeson calculated properties are similar", { + # Reference values for G were taken from the spreadsheet Berman_Gibbs_Free_Energies.xlsx + # (http://www.dewcommunity.org/uploads/4/1/7/6/41765907/sunday_afternoon_sessions__1_.zip accessed on 2017-10-03) + # The spreadsheet also has values for some minerals using the Helgeson data + T <- c(100, 100, 1000, 1000) + P <- c(5000, 50000, 5000, 50000) + + ## Start with uncomplicated minerals (no transitions) + # Helgeson akermanite + Ak_Hel_G <- c(-872485, -772662, -970152, -870328) + Ak_Hel <- subcrt("akermanite", T=T, P=P)$out[[1]] + expect_equal(Ak_Hel_G, Ak_Hel$G, tol=1e-5) + # Berman andalusite + And_Ber_G <- c(-579368, -524987, -632421, -576834) + And_Ber <- subcrt("andalusite", "cr_Berman", T=T, P=P)$out[[1]] + expect_equal(And_Ber_G, And_Ber$G, tol=1e-4) + + ## Now a more complicated case with polymorphic transitions + # Helgeson quartz + Qz_Hel_G <- c(-202778, -179719, -223906, -199129) + Qz_Hel <- subcrt("quartz", T=T, P=P)$out[[1]] + # they're very close, but less so at the extremest condition + expect_equal(Qz_Hel_G[-4], Qz_Hel$G[-4], tol=1e-5) + expect_equal(Qz_Hel_G[4], Qz_Hel$G[4], tol=1e-2) + # Berman alpha-quartz + aQz_Ber_G <- c(-202800, -179757, -223864, -200109) + aQz_Ber <- subcrt("quartz", "cr_Berman", T=T, P=P)$out[[1]] + # here, the high-P, low-T point suffers + expect_equal(aQz_Ber_G[-2], aQz_Ber$G[-2], tol=1e-5) + expect_equal(aQz_Ber_G[2], aQz_Ber$G[2], tol=1e-2) + + ## This one has disordering effects + Kfs_Ber_G <- c(-888115, -776324, -988950, -874777) + Kfs_Ber <- subcrt("K-feldspar", "cr_Berman", T=T, P=P)$out[[1]] + # we lose some accuracy at high T + expect_equal(Kfs_Ber_G[1:2], Kfs_Ber$G[1:2], tol=1e-5) + expect_equal(Kfs_Ber_G[3:4], Kfs_Ber$G[3:4], tol=1e-2) +}) Modified: pkg/CHNOSZ/tests/testthat/test-makeup.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-makeup.R 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/tests/testthat/test-makeup.R 2017-10-04 15:51:38 UTC (rev 242) @@ -14,10 +14,11 @@ test_that("numeric species indices, and coefficients indicating charge can be parsed", { # these are all equivalent formulas for the electron expect_equal(makeup("-1"), makeup("Z0-1")) + expect_equal(makeup("-1"), makeup("(Z-1)")[1]) expect_equal(makeup("-1"), makeup("Z-1+0")) # the species index of the electron in thermo$obigt ie <- info("e-") - expect_equal(makeup("-1"), makeup(ie)) + expect_equal(makeup("-1"), makeup(ie)[1]) }) test_that("signed and fractional coefficients can be parsed", { Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-04 15:51:38 UTC (rev 242) @@ -90,7 +90,7 @@ oldwat <- water("IAPWS95") sb <- subcrt(c("H2O", "Na+"), T=c(-30, -20, 0, 10), P=1)$out # the test is not a demanding numerical comparison, more that we got numbers and no error - expect_that(all(sb$`Na+`$G < sb$water$G), is_true()) + expect_true(all(sb$`Na+`$G < sb$water$G)) # clean up water(oldwat) }) Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-04 15:51:38 UTC (rev 242) @@ -14,7 +14,7 @@ bibliography: obigt.bib # so that these appear in the bibliography nocite: | - @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ + @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ, @JOH92, @WP02, @CWM89, @PRPG97, @TH88, @Kul06 # 20170212: comment the csl line to build package on R-Forge, to avoid # getting an error there (pandoc-citeproc: error while parsing the XML string) csl: elementa.csl @@ -119,8 +119,14 @@ Symbols show whether the data were present in the earliest of the sprons92.dat (??), slop98.dat (\*), slop07.dat (???), or slop15.dat (???) datafiles for the SUPCRT92 package. Any additional comments are placed at the beginning of the sections. -Abbreviations used below are: Cp (heat capacity), GHS (standard Gibbs energy, enthalpy, entropy), HKF (Helgeson-Kirkham-Flowers equations), V (volume). +Abbreviations used below are: Cp (heat capacity), GHS (standard Gibbs energy, enthalpy, entropy), HKF (Helgeson-Kirkham-Flowers equations), *V* (volume), *T* (temperature), *P* (pressure). +# Recent additions (late 2017) + +* Mineral data using the [Berman (1988)]() equations are listed under **Solids**. + +* Aqueous species data compatible with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under **Optional Data**. + # Sources of data {.tabset .tabset-fade} @@ -131,7 +137,19 @@ ### `r setfile("H2O_aq.csv")` ```{r H2O_aq, results="asis", echo=FALSE} -cat('This file contains H2O, *e*-, and H+. The properties of H2O are listed as NA; CHNOSZ calculates its properties using a Fortran subroutine taken from SUPRCT92 [@JOH92]. The properties of the proton (H+) are 0. The properties of the electron (*e*-) are 0, except for *S*??, which is the opposite of *S*?? for the "element" of charge, Z (see `?thermo`).\n') +cat('This file contains H2O, *e*-, and H+.\n') +cat('The properties of H2O are listed as NA; CHNOSZ calculates its properties using a Fortran subroutine taken from SUPRCT92 ([Johnson et al., 1992](https://doi.org/10.1016/0098-3004(92)90029-Q)) (default) or using the IAPWS-95 equations ([Wagner and Pru??, 2002](https://doi.org/10.1063/1.1461829)) or the [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model ([Sverjensky et al., 2014](https://doi.org/10.1016/j.gca.2013.12.019)).\n\n') +cat('By convention, the standard Gibbs energy of formation, entropy, and heat capacity of the aqueous proton (H+) are 0 at all *T* and *P* ([e.g. Cox et al., 1989](http://www.worldcat.org/oclc/18559968)).\n') +cat('The formation reaction of the proton can be expressed as ½H2,(*g*) + Z = H+, where Z is the "element" of positive charge.\n') +cat('Because the conventional standard Gibbs energy of this reaction is 0 at all *T*, the standard entropy of the reaction is also constrained to be zero (cf. [Puigdomenech et al., 1997](http://www.oecd-nea.org/dbtdb/pubs/book-pdf/427-494.pdf)).\n') +cat('Therefore, the "element" of positive charge (Z) has zero thermodynamic properties except for an entropy, *S*??*T*r, that is negative one-half that of H2,(*g*).\n') +cat('The standard entropy of the aqueous electron, which is a solely a pseudospecies defined by *e*- = -Z, is opposite that of Z.**\n\n') +cat('Despite these considerations, the final column of the thermodynamic database (`thermo$obigt`) lists a charge of "0" for both the aqueous proton and electron.\n') +cat('Data in this this column are used in CHNOSZ only to specify the charge that is input to the "*g*-function" ([Tanger and Helgeson, 1988](https://doi.org/10.2475/ajs.288.1.19); [Shock and Helgeson, 1988](https://doi.org/10.1016/0016-7037(88)90181-0)).\n') +cat('Setting it to zero prevents activation of the *g*-function, which would result in non-zero contributions to thermodynamic properties, conflicting with the conventions mentioned above.\n') +cat('All other calculations in CHNOSZ obtain the elemental makeup, including the correct charge for the species, by parsing the chemical formulas stored in the database.^^\n\n') +cat('**Likewise, [GEM-Selektor](http://gems.web.psi.ch/) defines "independent components" to be stoichiometric units usually consisting of elements and charge; the latter, [which is named Zz](http://gems.web.psi.ch/tests/TestNaCl-dep.html) and has a standard molal entropy of -65.34 J/mol/K and heat capacity of -14.418 J/mol/K (negative one-half those of gaseous hydrogen), is negated in the formula of the hypothetical "aqueous electron" ([Kulik, 2006](https://doi.org/10.1016/j.chemgeo.2005.08.014)).\n\n') +cat('^^ Relatedly, charged amino acid sidechain groups have a charge that is tabulated as zero, because other values would be incompatible with group additivity of cations and anions (for which the *g*-function produces derivatives of the omega parameter (ω) in the revised HKF equations of state that are not opposite each other) to give a neutral species (for which the derivatives of ω are taken to be zero) (cf. [Dick et al., 2006](https://doi.org/10.5194/bg-3-311-2006)).\n') ``` ```{r used, include=FALSE} # initialize the list of used species @@ -147,7 +165,7 @@ ### `r setfile("inorganic_aq.csv")` ```{r inorganic_aq, results="asis", echo=FALSE} -cat("ZnCl4-2 was present in sprons92.dat but not in slop98.dat or later files, and is not included in CHNOSZ.
") +cat("ZnCl4-2 was present in sprons92.dat but not in slop98.dat or later files, and is not included in CHNOSZ.
") ``` ```{r reflist, results="asis", echo=FALSE} Modified: pkg/CHNOSZ/vignettes/obigt.bib =================================================================== --- pkg/CHNOSZ/vignettes/obigt.bib 2017-10-03 08:41:50 UTC (rev 241) +++ pkg/CHNOSZ/vignettes/obigt.bib 2017-10-04 15:51:38 UTC (rev 242) @@ -742,6 +742,17 @@ doi = {10.1016/S0016-7037(97)00009-4}, } + at Article{TH88, + author = {Tanger, IV, John C. and Helgeson, Harold C.}, + journal = {American Journal of Science}, + title = {{C}alculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: {R}evised equations of state for the standard partial molal properties of ions and electrolytes}, + year = {1988}, + volume = {288}, + number = {1}, + pages = {19--98}, + doi = {10.2475/ajs.288.1.19}, +} + @Article{TSD97, author = {Tardy, Yves and Schaul, Rapha\`ele and Duplay, Jo\"elle}, journal = {Comptes Rendus de l'Academie des Sciences, Serie IIa: Sciences de la Terre et des Planetes}, @@ -764,6 +775,27 @@ url = {https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf}, } + at Article{WP02, + author = {Wagner, W. and Pru{\ss}, A.}, + journal = {Journal of Physical and Chemical Reference Data}, + title = {{T}he {IAPWS} formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use}, + year = {2002}, + volume = {31}, + number = {2}, + pages = {387 -- 535}, + doi = {10.1063/1.1461829}, +} + + at Book{CWM89, + editor = {Cox, J. D. and Wagman, D. D. and Medvedev, V. A.}, + publisher = {Hemisphere Publishing Corporation}, + title = {{CODATA} {K}ey {V}alues for {T}hermodynamics}, + year = {1989}, + address = {New York}, + pages = {271}, + url = {http://www.worldcat.org/oclc/18559968}, +} + @Article{GM09, author = {Grevel, Klaus-Dieter and Majzlan, Juraj}, journal = {Geochimica et Cosmochimica Acta}, @@ -950,16 +982,16 @@ } @Article{Eva90, - author = {Evans, Bernard W.}, - journal = {Lithos}, - title = {{P}hase relations of epidote-blueschists}, - year = {1990}, - volume = {25}, - number = {1}, - pages = {3--23}, - note = {Third International Eclogite Conference}, - doi = {10.1016/0024-4937(90)90003-J}, - issn = {0024-4937}, + author = {Evans, Bernard W.}, + journal = {Lithos}, + title = {{P}hase relations of epidote-blueschists}, + year = {1990}, + volume = {25}, + number = {1}, + pages = {3--23}, + note = {Third International Eclogite Conference}, + doi = {10.1016/0024-4937(90)90003-J}, + issn = {0024-4937}, } @Misc{JUN92, @@ -970,3 +1002,27 @@ url = {http://titan.minpet.unibas.ch/minpet/theriak/prog170204/}, } + at Incollection{PRPG97, + author = {Puigdomenech, Ignasi and Rard, Joseph A. and Plyasunov, Andrey V. and Grenthe, Ingmar}, + booktitle = {Modelling in Aquatic Chemistry}, + publisher = {OECD Nuclear Energy Data Bank}, + title = {{T}emperature corrections to thermodynamic data and enthalpy calculations}, + year = {1997}, + editor = {Grenthe, I. and Puigdomenech, I.}, + pages = {427--493}, + url = {http://www.oecd-nea.org/dbtdb/pubs/book-pdf/427-494.pdf}, +} + + at Article{Kul06, + author = {Kulik, D. A.}, + journal = {Chemical Geology}, + title = {{D}ual-thermodynamic estimation of stoichiometry and stability of solid solution end members in aqueous???solid solution systems}, + year = {2006}, + volume = {225}, + number = {3}, + pages = {189--212}, + note = {Solid solutions: from theory to experiment}, + doi = {10.1016/j.chemgeo.2005.08.014}, + issn = {0009-2541}, +} + From noreply at r-forge.r-project.org Thu Oct 5 15:55:46 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 5 Oct 2017 15:55:46 +0200 (CEST) Subject: [CHNOSZ-commits] r243 - in pkg/CHNOSZ: . R inst man tests/testthat vignettes Message-ID: <20171005135547.0323D1891B5@r-forge.r-project.org> Author: jedick Date: 2017-10-05 15:55:46 +0200 (Thu, 05 Oct 2017) New Revision: 243 Added: pkg/CHNOSZ/R/util.test.R pkg/CHNOSZ/man/util.test.Rd Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/cgl.R pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/makeup.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/tests/testthat/test-makeup.R pkg/CHNOSZ/tests/testthat/test-subcrt.R pkg/CHNOSZ/vignettes/obigt.Rmd Log: add expect_maxdiff() for testing maximum differences between values Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-05 13:55:46 UTC (rev 243) @@ -1,6 +1,6 @@ -Date: 2017-10-04 +Date: 2017-10-05 Package: CHNOSZ -Version: 1.1.0-41 +Version: 1.1.0-42 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/NAMESPACE 2017-10-05 13:55:46 UTC (rev 243) @@ -58,7 +58,8 @@ "nonideal", "anim.TCA", "uniprot.aa", "run.guess", # added 20170301 or later "GHS_Tr", "calculateDensity", "calculateGibbsOfWater", - "calculateEpsilon", "calculateQ", "water.DEW", "berman" + "calculateEpsilon", "calculateQ", "water.DEW", "berman", + "maxdiff", "expect_maxdiff" ) # Load shared objects @@ -77,5 +78,5 @@ "example", "head", "installed.packages", "read.csv", "tail", "write.csv", "write.table") -# Imports from colorspace +# Imports from other packages importFrom("colorspace", "diverge_hcl") Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/R/basis.R 2017-10-05 13:55:46 UTC (rev 243) @@ -150,7 +150,7 @@ ispecies <- suppressMessages(info(as.character(thermo$buffers$species)[ibuff[k]], as.character(thermo$buffers$state)[ibuff[k]], check.it=FALSE)) bufmakeup <- makeup(ispecies) - inbasis <- rownames(bufmakeup) %in% colnames(basis()) + inbasis <- names(bufmakeup) %in% colnames(basis()) if(FALSE %in% inbasis) { stop(paste("the elements '",c2s(rownames(bufmakeup)[!inbasis]), "' of species '",thermo$buffers$species[ibuff[k]],"' in buffer '",state[i], Modified: pkg/CHNOSZ/R/cgl.R =================================================================== --- pkg/CHNOSZ/R/cgl.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/R/cgl.R 2017-10-05 13:55:46 UTC (rev 243) @@ -2,6 +2,7 @@ # calculate standard thermodynamic properties of non-aqueous species # 20060729 jmd + cgl <- function(property = NULL, parameters = NULL, T = 298.15, P = 1) { # calculate properties of crystalline, liquid (except H2O) and gas species Tr <- 298.15 @@ -20,6 +21,10 @@ iprop <- match(property, colnames(properties)) values <- properties[, iprop, drop=FALSE] } else { + # in CHNOSZ, we have + # 1 cm^3 bar --> convert(1, "calories") == 0.02390057 cal + # but SUPCRT92 in REAC92D.F uses + cm3bar_to_cal <- 0.023901488 # cal # start with NA values values <- data.frame(matrix(NA, ncol = length(property), nrow=ncond)) colnames(values) <- property @@ -66,7 +71,7 @@ # entropy and volume terms if(!is.na(PAR$S)) p <- p - PAR$S * (T - Tr) if(isqtz) p <- p + qtz$G - else if(!is.na(PAR$V)) p <- p + convert(PAR$V * (P - Pr), "calories") + else if(!is.na(PAR$V)) p <- p + PAR$V * (P - Pr) * cm3bar_to_cal p <- PAR$G + p } if(PROP == "H") { @@ -81,8 +86,7 @@ else p <- p - PAR$f * ( T^(PAR$lambda + 1) - Tr^(PAR$lambda + 1) ) / (PAR$lambda + 1) } if(isqtz) p <- p + qtz$H - ## SUPCRT seems to ignore this term? ... 20070802 - #else p <- p + convert(PAR$V*(P-Pr),'calories') + else if(!is.na(PAR$V)) p <- p + PAR$V * (P-Pr) * cm3bar_to_cal p <- PAR$H + p } if(PROP=="S") { @@ -147,11 +151,12 @@ VPrTtb <- VPrTtb - Vdiff V <- V - Vdiff } - GVterm <- convert(1, "calories") * (VPrTra * (P - Pstar) + VPrTtb * (Pstar - Pr) - + cm3bar_to_cal <- 0.023901488 + GVterm <- cm3bar_to_cal * (VPrTra * (P - Pstar) + VPrTtb * (Pstar - Pr) - 0.5 * ca * (2 * Pr * (P - Pstar) - (P^2 - Pstar^2)) - ca * k * (T - Tr) * (P - Pstar) + k * (ba + aa * ca * k) * (T - Tr) * log((aa + P/k) / (aa + Pstar/k))) - SVterm <- convert(1, "calories") * (-k * (ba + aa * ca * k) * + SVterm <- cm3bar_to_cal * (-k * (ba + aa * ca * k) * log((aa + P/k) / (aa + Pstar/k)) + ca * k * (P - Pstar)) - Sstar list(G=GVterm, S=SVterm, H=GVterm + T*SVterm, V=V) } Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/R/info.R 2017-10-05 13:55:46 UTC (rev 243) @@ -132,18 +132,22 @@ ispecies.out <- ispecies[1] # let user know if there is more than one state for this species if(length(ispecies) > length(ispecies.out)) { + mystate <- thermo$obigt$state[ispecies.out] ispecies.other <- ispecies[!ispecies %in% ispecies.out] otherstates <- thermo$obigt$state[ispecies.other] transtext <- othertext <- "" # we count, but don't show the states for phase transitions (cr2, cr3, etc) istrans <- otherstates %in% c("cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9") - ntrans <- sum(istrans) - if(ntrans == 1) transtext <- paste(" with", ntrans, "phase transition") - else if(ntrans > 1) transtext <- paste(" with", ntrans, "phase transitions") + if(mystate=="cr") { + # if we are "cr" we show the number of phase transitions + ntrans <- sum(istrans) + if(ntrans == 1) transtext <- paste(" with", ntrans, "phase transition") + else if(ntrans > 1) transtext <- paste(" with", ntrans, "phase transitions") + } otherstates <- otherstates[!istrans] if(length(otherstates) > 0) othertext <- paste0(", also available in ", paste(otherstates, collapse=", ")) if(transtext != "" | othertext != "") { - starttext <- paste0("info.character: found ", species, "(", thermo$obigt$state[ispecies.out], ")") + starttext <- paste0("info.character: found ", species, "(", mystate, ")") message(starttext, transtext, othertext) } } Modified: pkg/CHNOSZ/R/makeup.R =================================================================== --- pkg/CHNOSZ/R/makeup.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/R/makeup.R 2017-10-05 13:55:46 UTC (rev 243) @@ -68,7 +68,7 @@ mcc <- lapply(seq_along(cf), function(i) ce[[i]]*cf[i]) # unlist the subformula counts and sum them together by element um <- unlist(mcc) - out <- tapply(um, names(um), sum) + out <- unlist(tapply(um, names(um), sum, simplify=FALSE)) } # all done with the counting, now apply the multiplier out <- out * multiplier @@ -123,7 +123,8 @@ count <- c(count, mycount) # in case there are repeated elements, sum all of their counts # (tapply hint from https://stat.ethz.ch/pipermail/r-help/2011-January/265341.html) - out <- tapply(count, element, sum) + # use simplify=FALSE followed by unlist to get a vector, not array 20171005 + out <- unlist(tapply(count, element, sum, simplify=FALSE)) # tapply returns alphabetical sorted list. keep the order appearing in the formula out <- out[match(unique(element), names(out))] return(out) Added: pkg/CHNOSZ/R/util.test.R =================================================================== --- pkg/CHNOSZ/R/util.test.R (rev 0) +++ pkg/CHNOSZ/R/util.test.R 2017-10-05 13:55:46 UTC (rev 243) @@ -0,0 +1,25 @@ +# CHNOSZ/util.test.R +# functions for writing tests 20171005 + +# the maximum (absolute) pairwise difference between x and y +maxdiff <- function(x, y) max(abs(y - x)) + +# modelled after the "expect_" functions in testthat ... +# is the maximum of the pairwise differences between two objects less than some value? +expect_maxdiff <- function(object, expected, maxdiff = 0) { + if(!"testthat" %in% row.names(installed.packages())) { + stop("please install the 'testthat' package to use this function") + } else { + # get the names for the object and expected values + # we use a double substitute here because + # as.character(substitute(x$a$b)) == c("$", "x$a", "b") + # as.character(substitute(substitute(x$a$b)))[2] == "x$a$b" --> better for printing + lab_act <- as.character(substitute(substitute(object)))[2] + lab_exp <- as.character(substitute(substitute(expected)))[2] + truemd <- maxdiff(object, expected) + failmsg <- sprintf("maxdiff(%s, %s) not less than %s", lab_act, lab_exp, maxdiff) + truemsg <- sprintf("actual value: %s", truemd) + testthat::expect(maxdiff(object, expected) <= maxdiff, sprintf("%s\n%s", failmsg, truemsg)) + invisible(object) + } +} Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/inst/NEWS 2017-10-05 13:55:46 UTC (rev 243) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-41 (2017-10-04) +CHANGES IN CHNOSZ 1.1.0-42 (2017-10-05) --------------------------------------- MAJOR CHANGES: @@ -98,6 +98,9 @@ - Components of subcrt() output indicating the stable polymorph of a mineral are now named 'polymorph', not 'state'. +- Add maxdiff() and expect_maxdiff() for calculating and testing the + maximum absolute pairwise difference between two objects. + CLEANUP: - To save space, taxid_names.csv has been trimmed to hold only those Added: pkg/CHNOSZ/man/util.test.Rd =================================================================== --- pkg/CHNOSZ/man/util.test.Rd (rev 0) +++ pkg/CHNOSZ/man/util.test.Rd 2017-10-05 13:55:46 UTC (rev 243) @@ -0,0 +1,31 @@ +\encoding{UTF-8} +\name{util.test} +\alias{util.test} +\alias{maxdiff} +\alias{expect_maxdiff} +\title{Functions for Writing Tests} +\description{ +Functions modelled after the \code{expect_} functions in \CRANpkg{testthat}. +} + +\usage{ + maxdiff(x, y) + expect_maxdiff(object, expected, maxdiff = 0) +} + +\arguments{ + \item{x}{numeric object} + \item{y}{numeric object} + \item{object}{numeric, object to test} + \item{expected}{numeric, expected value} + \item{maxdiff}{numeric, maximum pairwise difference between object and expected value} +} + +\details{ +\code{maxdiff} computes the maximum (absolute) pairwise difference between x and y, i.e. \code{max(abs(y - x))}. + +\code{expect_maxdiff} tests that the maximum of the pairwise differences between two objects is less than the value of the argument \code{maxdiff}. +The function uses \code{\link[testthat]{expect}} to generate an expectation in the \CRANpkg{testthat} framework. +} + +\keyword{utilities} Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-05 13:55:46 UTC (rev 243) @@ -62,8 +62,7 @@ expect_match(mineral[idiffV], "anthophyllite|antigorite|chrysotile|merwinite") }) - -test_that("Berman and Helgeson calculated properties are similar", { +test_that("high-T,P calculated properties are similar to precalculated ones", { # Reference values for G were taken from the spreadsheet Berman_Gibbs_Free_Energies.xlsx # (http://www.dewcommunity.org/uploads/4/1/7/6/41765907/sunday_afternoon_sessions__1_.zip accessed on 2017-10-03) # The spreadsheet also has values for some minerals using the Helgeson data @@ -74,30 +73,32 @@ # Helgeson akermanite Ak_Hel_G <- c(-872485, -772662, -970152, -870328) Ak_Hel <- subcrt("akermanite", T=T, P=P)$out[[1]] - expect_equal(Ak_Hel_G, Ak_Hel$G, tol=1e-5) + expect_maxdiff(Ak_Hel_G, Ak_Hel$G, 5) # Berman andalusite And_Ber_G <- c(-579368, -524987, -632421, -576834) And_Ber <- subcrt("andalusite", "cr_Berman", T=T, P=P)$out[[1]] - expect_equal(And_Ber_G, And_Ber$G, tol=1e-4) + expect_maxdiff(And_Ber_G, And_Ber$G, 10) ## Now a more complicated case with polymorphic transitions # Helgeson quartz Qz_Hel_G <- c(-202778, -179719, -223906, -199129) Qz_Hel <- subcrt("quartz", T=T, P=P)$out[[1]] # they're very close, but less so at the extremest condition - expect_equal(Qz_Hel_G[-4], Qz_Hel$G[-4], tol=1e-5) - expect_equal(Qz_Hel_G[4], Qz_Hel$G[4], tol=1e-2) + expect_maxdiff(Qz_Hel_G[-4], Qz_Hel$G[-4], 1) + expect_maxdiff(Qz_Hel_G[4], Qz_Hel$G[4], 250) # Berman alpha-quartz aQz_Ber_G <- c(-202800, -179757, -223864, -200109) aQz_Ber <- subcrt("quartz", "cr_Berman", T=T, P=P)$out[[1]] # here, the high-P, low-T point suffers - expect_equal(aQz_Ber_G[-2], aQz_Ber$G[-2], tol=1e-5) - expect_equal(aQz_Ber_G[2], aQz_Ber$G[2], tol=1e-2) + expect_maxdiff(aQz_Ber_G[-2], aQz_Ber$G[-2], 1.2) + expect_maxdiff(aQz_Ber_G[2], aQz_Ber$G[2], 1250) ## This one has disordering effects + # (see test-subcrt.R for test with Helgeson/SUPCRT92 values) + # Berman K-feldspar Kfs_Ber_G <- c(-888115, -776324, -988950, -874777) Kfs_Ber <- subcrt("K-feldspar", "cr_Berman", T=T, P=P)$out[[1]] # we lose some accuracy at high T - expect_equal(Kfs_Ber_G[1:2], Kfs_Ber$G[1:2], tol=1e-5) - expect_equal(Kfs_Ber_G[3:4], Kfs_Ber$G[3:4], tol=1e-2) + expect_maxdiff(Kfs_Ber_G[1:2], Kfs_Ber$G[1:2], 7) + expect_maxdiff(Kfs_Ber_G[3:4], Kfs_Ber$G[3:4], 1600) }) Modified: pkg/CHNOSZ/tests/testthat/test-makeup.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-makeup.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/tests/testthat/test-makeup.R 2017-10-05 13:55:46 UTC (rev 243) @@ -14,11 +14,11 @@ test_that("numeric species indices, and coefficients indicating charge can be parsed", { # these are all equivalent formulas for the electron expect_equal(makeup("-1"), makeup("Z0-1")) - expect_equal(makeup("-1"), makeup("(Z-1)")[1]) + expect_equal(makeup("-1"), makeup("(Z-1)")) expect_equal(makeup("-1"), makeup("Z-1+0")) # the species index of the electron in thermo$obigt ie <- info("e-") - expect_equal(makeup("-1"), makeup(ie)[1]) + expect_equal(makeup("-1"), makeup(ie)) }) test_that("signed and fractional coefficients can be parsed", { @@ -56,7 +56,7 @@ pf <- protein.formula(protein) # a matrix with elements on the columns basis(protein) # yup, a basis set made of proteins, just for fun bmat <- basis.elements() # a matrix with elements on the columns - expect_equal(as.array(makeup(pf)[[1]]), makeup(as.chemical.formula(pf)[1])) + expect_equal(makeup(pf)[[1]], makeup(as.chemical.formula(pf)[1])) expect_equal(makeup(pf), makeup(bmat)) }) Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-05 13:55:46 UTC (rev 243) @@ -3,32 +3,21 @@ # delete the basis definition in case there is one basis(delete=TRUE) -test_that("unbalanced reactions give a warning", { +test_that("unbalanced reactions give a warning or are balanced given sufficient basis species", { expect_warning(subcrt(c("glucose", "ethanol"), c(-1, 3)), "reaction was unbalanced, missing H-6O3") -}) - -test_that("unbalanced reactions are balanced given sufficient basis species", { basis("CHNOS") s <- subcrt(c("malic acid", "citric acid"), c(-1, 1)) expect_equal(s$reaction$coeff, c(-1, 1, -2, -1, 1.5)) expect_equal(s$reaction$name, c("malic acid", "citric acid", "CO2", "water", "oxygen")) }) -test_that("phase transitions of minerals give expected messages and results", { - iacanthite <- info("acanthite", "cr2") - #expect_message(subcrt(iacanthite), "subcrt: some points below transition temperature for acanthite cr2 \\(using NA for G\\)") - expect_message(subcrt(iacanthite), "subcrt: some points above temperature limit for acanthite cr2 \\(using NA for G\\)") - expect_equal(subcrt("acanthite")$out$acanthite$polymorph, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3)) -}) +#test_that("heat capacity of wollastonite is consistent with the literature", { +# # from Helgeson et al., 1978 Table 6 +# # here, set P to NA so that water() is not called to get Psat +# expect_maxdiff(subcrt("wollastonite", T=c(200, 500, 800), P=NA)$out$wollastonite$Cp, c(25.4, 28.3, 29.9), 0.05) +#}) -test_that("heat capacity of minerals are consistent with literature", { - # from Helgeson et al., 1978 Table 6 - # here, set P to NA so that water() is not called to get Psat - expect_equal(subcrt("wollastonite", T=c(200, 500, 800), P=NA)$out$wollastonite$Cp, c(25.4, 28.3, 29.9), tolerance=1e-2) -}) - test_that("standard Gibbs energies of reactions involving aqueous species are consistent with the literature", { - # from Amend and Shock, 2001 [AS01] Table 3 T <- c(2, 18, 25, 37, 45, 55, 70, 85, 100, 115, 150, 200) # standard Gibbs energies in kJ/mol @@ -38,40 +27,22 @@ AS01.H2O <- c(78.25, 79.34, 79.89, 80.90, 81.63, 82.59, 84.13, 85.78, 87.55, 89.42, 94.22, 102.21) sout.H2O <- subcrt(c("H2O", "H+", "OH-"), c(-1, 1, 1), T=T)$out # tolerances set to lowest order of magnitute to pass - expect_equal(sout.H2O$G/1000, AS01.H2O, tolerance=1e-4) + expect_maxdiff(sout.H2O$G/1000, AS01.H2O, 0.01) # AS01 Table 4.3 Reaction A1: H2(aq) + 0.5O2(aq) = H2O(l) AS01.A1 <- c(-263.94, -263.45, -263.17, -262.62, -262.20, -261.63, -260.67, -259.60, -258.44, -257.18, -253.90, -248.44) sout.A1 <- subcrt(c("H2", "O2", "H2O"), "aq", c(-1, -0.5, 1), T=T)$out - expect_equal(sout.A1$G/1000, AS01.A1, tolerance=1e-4) + expect_maxdiff(sout.A1$G/1000, AS01.A1, 0.01) - # AS01 Table 5.1 NO(g) -> NO(aq) - DG0.NO.g <- c(91.39, 88.04, 86.57, 84.03, 82.33, 80.20, 76.99, 73.75, 70.50, 67.23, 59.53, 48.38) - DG0.NO.aq <- c(104.56, 102.87, 102.06, 100.58, 99.53, 98.15, 95.98, 93.67, 91.25, 88.72, 82.46, 72.77) - sout.NO <- subcrt("NO", c("gas", "aq"), c(-1, 1), T=T)$out - # higher tolerance, our values for NO(aq) differ slightly from AS01 - expect_equal(sout.NO$G/1000, DG0.NO.aq - DG0.NO.g, tolerance=1e-2) - - # AS01 Table 5.1 Reaction B10: NH3(aq) + 1.5O2(aq) = H+ + NO2- + H2O(l) - AS01.B10 <- c(-268.85, -268.01, -267.50, -266.46, -265.66, -264.55, -262.66, -260.54, -258.19, -255.63, -248.81, -237.06) - sout.B10 <- subcrt(c("NH3", "O2", "H+", "NO2-", "H2O"), "aq", c(-1, -1.5, 1, 1, 1), T=T)$out - expect_equal(sout.B10$G/1000, AS01.B10, tolerance=1e-3) - # AS01 Table 6.3 Reaction C7: 5S2O3-2 + H2O(l) + 4O2(aq) = 6SO4-2 + 2H+ + 4S(s) AS01.C7 <- c(-1695.30, -1686.90, -1682.80, -1675.30, -1670.00, -1663.10, -1652.00, -1640.30, -1628.00, -1615.20, -1583.50, -1533.00) s.C7 <- subcrt(c("S2O3-2", "H2O", "O2", "SO4-2", "H+", "S"), c("aq", "liq", "aq", "aq", "aq", "cr"), c(-5, -1, -4, 6, 2, 4), T=T) sout.C7 <- s.C7$out - expect_equal(sout.C7$G/1000, AS01.C7, tolerance=1e-4) + expect_maxdiff(sout.C7$G/1000, AS01.C7, 0.05) # we can also check that sulfur has expected phase transitions expect_equal(s.C7$polymorphs$sulfur, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3)) - ## AS01 Table 8.3 Reaction E12: 4(2-)propanol(aq) + 3CO2(aq) + 2H2O(l) = 3CH4(aq) + 4lactic acid(aq) - #DG0.E12 <- c(132.52, 132.26, 132.29, 132.49, 132.74, 133.15, 133.98, 135.04, 136.31, 137.79, 141.97, 149.53) - #sout.E12 <- subcrt(c("2-propanol", "CO2", "H2O", "CH4", "lactic acid"), c(-4, -3, -2, 3, 4), T=T)$out - ## this one is on hold until the HKF parameters of 2-propanol can be located - #expect_equal(sout.E12$G/1000, DG0.E12, 1e-4) - - # return to our favourite units + # return to our favorite units E.units("cal") }) @@ -82,7 +53,7 @@ expect_equal(s.H2O$G[1], NA_real_) # we should get something at -20 deg C expect_equal(floor(s.H2O$G[2]), -56001) - # for historical reasons, an input temperature of 0 was converted to 0.01 + # following SUPCRT92, an input temperature of 0 is converted to 0.01 expect_equal(s.H2O$T[22], 0.01) }) @@ -95,40 +66,72 @@ water(oldwat) }) +test_that("phase transitions of minerals give expected messages and results", { + iacanthite <- info("acanthite", "cr2") + #expect_message(subcrt(iacanthite), "subcrt: some points below transition temperature for acanthite cr2 \\(using NA for G\\)") + expect_message(subcrt(iacanthite), "subcrt: some points above temperature limit for acanthite cr2 \\(using NA for G\\)") + expect_equal(subcrt("acanthite")$out$acanthite$polymorph, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3)) +}) + +test_that("calculations for K-feldspar are consistent with SUPCRT92", { + T <- c(100, 100, 1000, 1000) + P <- c(5000, 50000, 5000, 50000) + SUPCRT_G <- c(-886628, -769531, -988590, -871493) + SUPCRT_H <- c(-932344, -815247, -865868, -748771) + SUPCRT_S <- c(62.6, 62.6, 150.6, 150.6) + SUPCRT_V <- c(108.9, 108.9, 108.9, 108.9) + SUPCRT_Cp <- c(56.7, 56.7, 80.3, 80.3) + CHNOSZ <- subcrt("K-feldspar", T=T, P=P)$out[[1]] + expect_equal(round(CHNOSZ$G), SUPCRT_G) + expect_equal(round(CHNOSZ$H), SUPCRT_H) + expect_equal(round(CHNOSZ$S, 1), SUPCRT_S) + expect_equal(round(CHNOSZ$V, 1), SUPCRT_V) + expect_equal(round(CHNOSZ$Cp, 1), SUPCRT_Cp) +}) + test_that("calculations for quartz are consistent with SUPCRT92", { # output from SUPCRT92 for reaction specified as "1 QUARTZ" run at 1 bar # (SUPCRT shows phase transition at 574.850 deg C, and does not give Cp values around the transition) S92_1bar <- read.table(header = TRUE, text = " T G H S V - 572 -214482 -209535 24.7 23.3 573 -214507 -209517 24.7 23.3 574 -214532 -209499 24.8 23.3 575 -214557 -209192 25.1 23.7 576 -214582 -209176 25.1 23.7 - 577 -214607 -209159 25.2 23.7 ") - CHNOSZ_1bar <- subcrt("quartz", T=seq(572, 577), P=1)$out[[1]] - expect_equal(CHNOSZ_1bar$G, S92_1bar$G, tolerance = 1e-5) - expect_equal(CHNOSZ_1bar$H, S92_1bar$H, tolerance = 1e-5) - expect_equal(CHNOSZ_1bar$S, S92_1bar$S, tolerance = 1e-2) - expect_equal(CHNOSZ_1bar$V, S92_1bar$V, tolerance = 1e-2) + CHNOSZ_1bar <- subcrt("quartz", T=seq(573, 576), P=1)$out[[1]] + expect_maxdiff(CHNOSZ_1bar$G, S92_1bar$G, 0.5) + expect_maxdiff(CHNOSZ_1bar$H, S92_1bar$H, 0.5) + expect_maxdiff(CHNOSZ_1bar$S, S92_1bar$S, 0.05) + expect_maxdiff(CHNOSZ_1bar$V, S92_1bar$V, 0.05) - # output from SUPCRT92 for reaction specified as "1 QUARTZ" run at 500 bar - # (SUPCRT shows phase transition at 587.811 deg C) + # 500 bar: SUPCRT shows phase transition at 587.811 deg C S92_500bar <- read.table(header = TRUE, text = " T G H S V - 585 -214523 -209335 24.6 23.3 586 -214548 -209318 24.7 23.3 587 -214573 -209301 24.7 23.3 588 -214602 -208700 25.4 23.7 589 -214627 -208684 25.4 23.7 - 590 -214653 -208668 25.4 23.7 ") - CHNOSZ_500bar <- subcrt("quartz", T=seq(585, 590), P=500)$out[[1]] - expect_equal(CHNOSZ_500bar$G, S92_500bar$G, tolerance = 1e-5) - expect_equal(CHNOSZ_500bar$H, S92_500bar$H, tolerance = 1e-4) - expect_equal(CHNOSZ_500bar$S, S92_500bar$S, tolerance = 1e-3) - expect_equal(CHNOSZ_500bar$V, S92_500bar$V, tolerance = 1e-2) + CHNOSZ_500bar <- subcrt("quartz", T=seq(586, 589), P=500)$out[[1]] + expect_maxdiff(CHNOSZ_500bar$G, S92_500bar$G, 0.5) + expect_maxdiff(CHNOSZ_500bar$H, S92_500bar$H, 25) + expect_maxdiff(CHNOSZ_500bar$S, S92_500bar$S, 0.05) + expect_maxdiff(CHNOSZ_500bar$V, S92_500bar$V, 0.05) + + # 5000 bar: SUPCRT shows phase transition at 704.694 deg C + S92_5000bar <- read.table(header = TRUE, text = " + T G H S V + 703 -215044 -204913 26.7 23.3 + 704 -215071 -204895 26.7 23.3 + 705 -215142 -204254 27.4 23.7 + 706 -215170 -204238 27.5 23.7 + ") + CHNOSZ_5000bar <- subcrt("quartz", T=seq(703, 706), P=5000)$out[[1]] + expect_maxdiff(CHNOSZ_5000bar$G, S92_5000bar$G, 20) + expect_maxdiff(CHNOSZ_5000bar$H, S92_5000bar$H, 300) + expect_maxdiff(CHNOSZ_5000bar$S, S92_5000bar$S, 0.5) + expect_maxdiff(CHNOSZ_5000bar$V, S92_5000bar$V, 0.05) }) test_that("duplicated species yield correct phase transitions", { Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-04 15:51:38 UTC (rev 242) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-05 13:55:46 UTC (rev 243) @@ -148,8 +148,8 @@ cat('Data in this this column are used in CHNOSZ only to specify the charge that is input to the "*g*-function" ([Tanger and Helgeson, 1988](https://doi.org/10.2475/ajs.288.1.19); [Shock and Helgeson, 1988](https://doi.org/10.1016/0016-7037(88)90181-0)).\n') cat('Setting it to zero prevents activation of the *g*-function, which would result in non-zero contributions to thermodynamic properties, conflicting with the conventions mentioned above.\n') cat('All other calculations in CHNOSZ obtain the elemental makeup, including the correct charge for the species, by parsing the chemical formulas stored in the database.^^\n\n') -cat('**Likewise, [GEM-Selektor](http://gems.web.psi.ch/) defines "independent components" to be stoichiometric units usually consisting of elements and charge; the latter, [which is named Zz](http://gems.web.psi.ch/tests/TestNaCl-dep.html) and has a standard molal entropy of -65.34 J/mol/K and heat capacity of -14.418 J/mol/K (negative one-half those of gaseous hydrogen), is negated in the formula of the hypothetical "aqueous electron" ([Kulik, 2006](https://doi.org/10.1016/j.chemgeo.2005.08.014)).\n\n') -cat('^^ Relatedly, charged amino acid sidechain groups have a charge that is tabulated as zero, because other values would be incompatible with group additivity of cations and anions (for which the *g*-function produces derivatives of the omega parameter (ω) in the revised HKF equations of state that are not opposite each other) to give a neutral species (for which the derivatives of ω are taken to be zero) (cf. [Dick et al., 2006](https://doi.org/10.5194/bg-3-311-2006)).\n') +cat('**Likewise, [GEM-Selektor](http://gems.web.psi.ch/) defines "independent components" to be stoichiometric units usually consisting of elements and charge; the latter, [which is named Zz](http://gems.web.psi.ch/tests/TestNaCl-dep.html) and has a standard molal entropy of -65.34 J/mol/K and heat capacity of -14.418 J/mol/K (negative one-half those of gaseous hydrogen), is negated in the formula of the fictive "aqueous electron" ([Kulik, 2006](https://doi.org/10.1016/j.chemgeo.2005.08.014)).\n\n') +cat('^^ Relatedly, charged amino acid sidechain groups have a charge that is tabulated as zero, because other values would be incompatible with group additivity of cations and anions (which have derivatives of the omega parameter (ω) in the revised HKF equations of state that are not opposites of each other) to give a neutral species (for which the derivatives of ω are taken to be zero) (cf. [Dick et al., 2006](https://doi.org/10.5194/bg-3-311-2006)).\n') ``` ```{r used, include=FALSE} # initialize the list of used species From noreply at r-forge.r-project.org Sat Oct 7 05:48:12 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 7 Oct 2017 05:48:12 +0200 (CEST) Subject: [CHNOSZ-commits] r244 - in pkg/CHNOSZ: . R inst man tests/testthat Message-ID: <20171007034812.22182189023@r-forge.r-project.org> Author: jedick Date: 2017-10-07 05:48:11 +0200 (Sat, 07 Oct 2017) New Revision: 244 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/cgl.R pkg/CHNOSZ/R/util.misc.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/util.expression.Rd pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/tests/testthat/test-eos.R pkg/CHNOSZ/tests/testthat/test-subcrt.R Log: clean up and simplify code in cgl() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-07 03:48:11 UTC (rev 244) @@ -1,6 +1,6 @@ -Date: 2017-10-05 +Date: 2017-10-07 Package: CHNOSZ -Version: 1.1.0-42 +Version: 1.1.0-43 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/cgl.R =================================================================== --- pkg/CHNOSZ/R/cgl.R 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/R/cgl.R 2017-10-07 03:48:11 UTC (rev 244) @@ -2,7 +2,6 @@ # calculate standard thermodynamic properties of non-aqueous species # 20060729 jmd - cgl <- function(property = NULL, parameters = NULL, T = 298.15, P = 1) { # calculate properties of crystalline, liquid (except H2O) and gas species Tr <- 298.15 @@ -23,86 +22,61 @@ } else { # in CHNOSZ, we have # 1 cm^3 bar --> convert(1, "calories") == 0.02390057 cal - # but SUPCRT92 in REAC92D.F uses + # but REAC92D.F in SUPCRT92 uses cm3bar_to_cal <- 0.023901488 # cal # start with NA values values <- data.frame(matrix(NA, ncol = length(property), nrow=ncond)) colnames(values) <- property - # additional calculations for quartz and coesite - qtz <- quartz_coesite(PAR, T, P) - isqtz <- !identical(qtz$V, 0) - for(i in 1:length(property)) { - PROP <- property[i] - # a test for availability of the EoS parameters - # here we assume that the parameters are in the same columns as in thermo$obigt - # leave T transition (in 20th column) alone - hasEOS <- any(!is.na(PAR[, 13:19])) - # if at least one of the EoS parameters is available, zero out any NA's in the rest - if(hasEOS) PAR[, 13:19][, is.na(PAR[, 13:19])] <- 0 - # equations for lambda adapted from HOK+98 - if(PROP == "Cp") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp - else p <- PAR$a + PAR$b * T + PAR$c * T^-2 + PAR$d * T^-0.5 + PAR$e * T^2 + PAR$f * T^PAR$lambda + # a test for availability of heat capacity coefficients (a, b, c, d, e, f) + # based on the column assignments in thermo$obigt + if(any(!is.na(PAR[, 13:18]))) { + # we have at least one of the heat capacity coefficients; + # zero out any NA's in the rest (leave lambda and T of transition (columns 19-20) alone) + PAR[, 13:18][, is.na(PAR[, 13:18])] <- 0 + # calculate the heat capacity and its integrals + Cp <- PAR$a + PAR$b*T + PAR$c*T^-2 + PAR$d*T^-0.5 + PAR$e*T^2 + PAR$f*T^PAR$lambda + intCpdT <- PAR$a*(T - Tr) + PAR$b*(T^2 - Tr^2)/2 + PAR$c*(1/T - 1/Tr)/-1 + PAR$d*(T^0.5 - Tr^0.5)/0.5 + PAR$e*(T^3-Tr^3)/3 + intCpdlnT <- PAR$a*log(T / Tr) + PAR$b*(T - Tr) + PAR$c*(T^-2 - Tr^-2)/-2 + PAR$d*(T^-0.5 - Tr^-0.5)/-0.5 + PAR$e*(T^2 - Tr^2)/2 + # do we also have the lambda parameter (Cp term with adjustable exponent on T)? + if(!is.na(PAR$lambda) & !identical(PAR$lambda, 0)) { + # equations for lambda adapted from Helgeson et al., 1998 (doi:10.1016/S0016-7037(97)00219-6) + if(PAR$lambda == -1) intCpdT <- intCpdT + PAR$f*log(T/Tr) + else intCpdT <- intCpdT - PAR$f*( T^(PAR$lambda + 1) - Tr^(PAR$lambda + 1) ) / (PAR$lambda + 1) + intCpdlnT <- intCpdlnT + PAR$f*(T^PAR$lambda - Tr^PAR$lambda) / PAR$lambda } - if(PROP == "V") { - if(isqtz) p <- qtz$V - else p <- rep(PAR$V, ncond) + } else { + # use constant heat capacity if the coefficients are not available + Cp <- PAR$Cp + CpdT <- PAR$Cp*(T - Tr) + intCpdlnT <- PAR$Cp*log(T / Tr) + } + # volume and its integrals + if(PAR$name %in% c("quartz", "coesite")) { + # volume calculations for quartz and coesite + qtz <- quartz_coesite(PAR, T, P) + V <- qtz$V + intVdP <- qtz$intVdP + intdVdTdP <- qtz$intdVdTdP + } else { + # for other minerals, volume is constant (Helgeson et al., 1978) + V <- rep(PAR$V, ncond) + # if the volume is NA, set its integrals to zero + if(is.na(PAR$V)) intVdP <- intdVdTdP <- numeric(ncond) + else { + intVdP <- PAR$V*(P - Pr) * cm3bar_to_cal + intdVdTdP <- 0 } - if(PROP %in% c("E", "kT")) { - p <- rep(NA, ncond) - warning("cgl: E and/or kT of cr, gas and/or liq species are NA.") - } - if(PROP == "G") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp * (T - Tr - T * log(T/Tr)) else { - # Gibbs energy integral: the value at Tref plus heat capacity terms - p <- PAR$a * (T - Tr - T * log(T/Tr)) - - PAR$b * (T - Tr)^2 / 2 - PAR$c * (1/T + T/Tr^2 - 2/Tr) / 2 - - PAR$d * (T^0.5 - 0.5 * T * Tr^-0.5 - 0.5 * Tr^0.5) / -0.25 - - PAR$e * (T^3 - 3 * T * Tr^2 + 2 * Tr^3) / 6 - } - # use additional heat capacity term if it's defined - if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { - if(PAR$lambda == -1) p <- p + PAR$f * (log(T/Tr) - T * (1/Tr - 1/T)) - else p <- p + PAR$f * ( T^(PAR$lambda + 1) - (PAR$lambda + 1) * T * Tr^PAR$lambda + - PAR$lambda * Tr^(PAR$lambda + 1) ) / ( PAR$lambda * (PAR$lambda + 1) ) - } - # entropy and volume terms - if(!is.na(PAR$S)) p <- p - PAR$S * (T - Tr) - if(isqtz) p <- p + qtz$G - else if(!is.na(PAR$V)) p <- p + PAR$V * (P - Pr) * cm3bar_to_cal - p <- PAR$G + p - } - if(PROP == "H") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp * (T - Tr) else { - p <- PAR$a * (T - Tr) + PAR$b * (T^2 - Tr^2) / 2 + - PAR$c * (1/T - 1/Tr) / -1 + PAR$d * (T^0.5 - Tr^0.5) / 0.5 + - PAR$e * (T^3 - Tr^3) / 3 - } - if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { - if(PAR$lambda == -1) p <- p + PAR$f * log(T/Tr) - else p <- p - PAR$f * ( T^(PAR$lambda + 1) - Tr^(PAR$lambda + 1) ) / (PAR$lambda + 1) - } - if(isqtz) p <- p + qtz$H - else if(!is.na(PAR$V)) p <- p + PAR$V * (P-Pr) * cm3bar_to_cal - p <- PAR$H + p - } - if(PROP=="S") { - # use constant Cp if the EoS parameters are not available - if(!hasEOS) p <- PAR$Cp * log(T/Tr) else { - p <- PAR$a * log(T / Tr) + PAR$b * (T - Tr) + - PAR$c * (T^-2 - Tr^-2) / -2 + PAR$e * (T^2 - Tr^2) / 2 + - PAR$d * (T^-0.5 - Tr^-0.5) / -0.5 - } - if(!is.na(PAR$f) & !is.na(PAR$lambda)) if(PAR$f != 0) { - p <- p + PAR$f * (T^PAR$lambda - Tr^PAR$lambda) / PAR$lambda - } - p <- PAR$S + p + qtz$S - } - values[, i] <- p } + # get the values of each of the requested thermodynamic properties + for(i in 1:length(property)) { + if(property[i] == "Cp") values[, i] <- Cp + if(property[i] == "V") values[, i] <- V + if(property[i] == "E") values[, i] <- rep(NA, ncond) + if(property[i] == "kT") values[, i] <- rep(NA, ncond) + if(property[i] == "G") values[, i] <- PAR$G - PAR$S*(T - Tr) + intCpdT - T*intCpdlnT + intVdP + if(property[i] == "H") values[, i] <- PAR$H + intCpdT + intVdP - T*intdVdTdP + if(property[i] == "S") values[, i] <- PAR$S + intCpdlnT - intdVdTdP + } } # end calculations using parameters from thermo$obigt out[[k]] <- values } # end loop over species @@ -112,7 +86,7 @@ ### unexported function ### # calculate GHS and V corrections for quartz and coesite 20170929 -# (these are the only mineral phases which SUPCRT92 applies a variable volume) +# (these are the only mineral phases for which SUPCRT92 uses an inconstant volume) quartz_coesite <- function(PAR, T, P) { # the corrections are 0 for anything other than quartz and coesite if(!PAR$name %in% c("quartz", "coesite")) return(list(G=0, H=0, S=0, V=0)) @@ -131,8 +105,8 @@ # constants from REAC92D.f VPrTra <- 22.688 # VPrTr(a-quartz) Vdiff <- 2.047 # VPrTr(a-quartz) - VPrTr(coesite) - #k <- 38.5 # dPdTtr(a/b-quartz) - k <- 38.45834 # calculated in CHNOSZ: dPdTtr(info("quartz")) + k <- 38.5 # dPdTtr(a/b-quartz) + #k <- 38.45834 # calculated in CHNOSZ: dPdTtr(info("quartz")) # code adapted from REAC92D.f qphase <- gsub("cr", "", PAR$state) if(qphase == 2) { @@ -158,6 +132,7 @@ k * (ba + aa * ca * k) * (T - Tr) * log((aa + P/k) / (aa + Pstar/k))) SVterm <- cm3bar_to_cal * (-k * (ba + aa * ca * k) * log((aa + P/k) / (aa + Pstar/k)) + ca * k * (P - Pstar)) - Sstar - list(G=GVterm, S=SVterm, H=GVterm + T*SVterm, V=V) + # note the minus sign on "SVterm" in order that intdVdTdP has the correct sign + list(intVdP=GVterm, intdVdTdP=-SVterm, V=V) } Modified: pkg/CHNOSZ/R/util.misc.R =================================================================== --- pkg/CHNOSZ/R/util.misc.R 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/R/util.misc.R 2017-10-07 03:48:11 UTC (rev 244) @@ -21,11 +21,12 @@ } Ttr <- function(ispecies,P=1,dPdT=NULL) { - # calculate a phase transition temperature - # taking account of P (from dP/dT) - T <- get("thermo")$obigt$z.T[ispecies] + # calculate a phase transition temperature for given P + TtrPr <- get("thermo")$obigt$z.T[ispecies] + # the constant slope, dP/dT if(is.null(dPdT)) dPdT <- dPdTtr(ispecies) - return(T + P / dPdT) + Pr <- 1 + TtrPr + (P - Pr) / dPdT } GHS_Tr <- function(ispecies, Htr) { Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/inst/NEWS 2017-10-07 03:48:11 UTC (rev 244) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-42 (2017-10-05) +CHANGES IN CHNOSZ 1.1.0-42 (2017-10-06) --------------------------------------- MAJOR CHANGES: Modified: pkg/CHNOSZ/man/util.expression.Rd =================================================================== --- pkg/CHNOSZ/man/util.expression.Rd 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/man/util.expression.Rd 2017-10-07 03:48:11 UTC (rev 244) @@ -61,8 +61,10 @@ \tabular{ll}{ \samp{D} \tab Delta \cr \samp{A} \tab bold A (chemical affinity) \cr - \samp{p} \tab subscript italic P (isobaric heat capacity) \cr - \samp{0} \tab degree sign (standard-state property) \cr } + \samp{p} \tab subscript italic P (for isobaric heat capacity) \cr + \samp{0} \tab degree sign (for a standard-state property) \cr + \samp{l} \tab subscript lambda \cr + } A \samp{0} gets interpreted as a degree sign only if it does not immediately follow a number (so that e.g. \samp{2.303} can be included in an expression). Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-07 03:48:11 UTC (rev 244) @@ -65,40 +65,27 @@ test_that("high-T,P calculated properties are similar to precalculated ones", { # Reference values for G were taken from the spreadsheet Berman_Gibbs_Free_Energies.xlsx # (http://www.dewcommunity.org/uploads/4/1/7/6/41765907/sunday_afternoon_sessions__1_.zip accessed on 2017-10-03) - # The spreadsheet also has values for some minerals using the Helgeson data T <- c(100, 100, 1000, 1000) P <- c(5000, 50000, 5000, 50000) - ## Start with uncomplicated minerals (no transitions) - # Helgeson akermanite - Ak_Hel_G <- c(-872485, -772662, -970152, -870328) - Ak_Hel <- subcrt("akermanite", T=T, P=P)$out[[1]] - expect_maxdiff(Ak_Hel_G, Ak_Hel$G, 5) - # Berman andalusite - And_Ber_G <- c(-579368, -524987, -632421, -576834) - And_Ber <- subcrt("andalusite", "cr_Berman", T=T, P=P)$out[[1]] - expect_maxdiff(And_Ber_G, And_Ber$G, 10) + # anadalusite: an uncomplicated mineral (no transitions) + And_G <- c(-579368, -524987, -632421, -576834) + And <- subcrt("andalusite", "cr_Berman", T=T, P=P)$out[[1]] + expect_maxdiff(And_G, And$G, 10) - ## Now a more complicated case with polymorphic transitions - # Helgeson quartz - Qz_Hel_G <- c(-202778, -179719, -223906, -199129) - Qz_Hel <- subcrt("quartz", T=T, P=P)$out[[1]] - # they're very close, but less so at the extremest condition - expect_maxdiff(Qz_Hel_G[-4], Qz_Hel$G[-4], 1) - expect_maxdiff(Qz_Hel_G[4], Qz_Hel$G[4], 250) - # Berman alpha-quartz - aQz_Ber_G <- c(-202800, -179757, -223864, -200109) - aQz_Ber <- subcrt("quartz", "cr_Berman", T=T, P=P)$out[[1]] + # quartz: a mineral with polymorphic transitions + aQz_G <- c(-202800, -179757, -223864, -200109) + aQz <- subcrt("quartz", "cr_Berman", T=T, P=P)$out[[1]] # here, the high-P, low-T point suffers - expect_maxdiff(aQz_Ber_G[-2], aQz_Ber$G[-2], 1.2) - expect_maxdiff(aQz_Ber_G[2], aQz_Ber$G[2], 1250) + expect_maxdiff(aQz_G[-2], aQz$G[-2], 1.2) + expect_maxdiff(aQz_G[2], aQz$G[2], 1250) - ## This one has disordering effects - # (see test-subcrt.R for test with Helgeson/SUPCRT92 values) - # Berman K-feldspar - Kfs_Ber_G <- c(-888115, -776324, -988950, -874777) - Kfs_Ber <- subcrt("K-feldspar", "cr_Berman", T=T, P=P)$out[[1]] + # K-feldspar: this one has disordering effects + Kfs_G <- c(-888115, -776324, -988950, -874777) + Kfs <- subcrt("K-feldspar", "cr_Berman", T=T, P=P)$out[[1]] # we lose some accuracy at high T - expect_maxdiff(Kfs_Ber_G[1:2], Kfs_Ber$G[1:2], 7) - expect_maxdiff(Kfs_Ber_G[3:4], Kfs_Ber$G[3:4], 1600) + expect_maxdiff(Kfs_G[1:2], Kfs$G[1:2], 7) + expect_maxdiff(Kfs_G[3:4], Kfs$G[3:4], 1600) + + # (see test-subcrt.R for feldspar and quartz tests with Helgeson/SUPCRT92 values) }) Modified: pkg/CHNOSZ/tests/testthat/test-eos.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-eos.R 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/tests/testthat/test-eos.R 2017-10-07 03:48:11 UTC (rev 244) @@ -1,5 +1,19 @@ context("eos") +test_that("cgl() with NA volume produces reasonable results", { + # 20171006: after rewriting much of the code in cgl(), melanterite and hydronium jarosite + # disappeared from the example diagram after Majzlan et al., 2006. + # Because the volumes are NA, the integral properties became NA, + # but it makes more sense to set them to zero. + ispecies <- info("melanterite") + expect_equal(info(ispecies)$V, NA_real_) + sout <- subcrt(ispecies, T=c(25, 25, 100, 100), P=c(1, 100, 1, 100))$out[[1]] + expect_false(any(is.na(sout$H))) + # for melanterite, which is listed in the database with zero heat capacity, + # all Cp and V integrals evaluate to zero + expect_length(unique(sout$H), 1) +}) + test_that("gfun() gives expected results", { # calculate values of g and its derivatives # up to 350 degrees C at Psat Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-05 13:55:46 UTC (rev 243) +++ pkg/CHNOSZ/tests/testthat/test-subcrt.R 2017-10-07 03:48:11 UTC (rev 244) @@ -11,12 +11,6 @@ expect_equal(s$reaction$name, c("malic acid", "citric acid", "CO2", "water", "oxygen")) }) -#test_that("heat capacity of wollastonite is consistent with the literature", { -# # from Helgeson et al., 1978 Table 6 -# # here, set P to NA so that water() is not called to get Psat -# expect_maxdiff(subcrt("wollastonite", T=c(200, 500, 800), P=NA)$out$wollastonite$Cp, c(25.4, 28.3, 29.9), 0.05) -#}) - test_that("standard Gibbs energies of reactions involving aqueous species are consistent with the literature", { # from Amend and Shock, 2001 [AS01] Table 3 T <- c(2, 18, 25, 37, 45, 55, 70, 85, 100, 115, 150, 200) @@ -89,7 +83,33 @@ expect_equal(round(CHNOSZ$Cp, 1), SUPCRT_Cp) }) -test_that("calculations for quartz are consistent with SUPCRT92", { +test_that("calculations for quartz are nearly consistent with SUPCRT92", { + # using SUPCRT's equations, the alpha-beta transition occurs at + # 705 degC at 5000 bar and 1874 degC at 50000 bar, + # so here beta-quartz is stable only at T=1000, P=5000 + T <- c(100, 100, 1000, 1000) + P <- c(5000, 50000, 5000, 50000) + SUPCRT_G <- c(-202778, -179719, -223906, -199129) + SUPCRT_H <- c(-214133, -191708, -199359, -177118) + SUPCRT_S <- c(12.3, 10.6, 31.8, 29.8) + SUPCRT_V <- c(22.5, 20.3, 23.7, 21.9) + SUPCRT_Cp <- c(12.3, 12.3, 16.9, 16.9) + CHNOSZ <- subcrt("quartz", T=T, P=P)$out[[1]] + # NOTE: Testing has shown that, where alpha-quartz is stable above Ttr(Pr) but below Ttr(P), + # SUPCRT92 computes the heat capacity and its integrals using parameters of beta-quartz. + # (see e.g. the equation for CprdT under the (Cpreg .EQ. 2) case in the Cptrms subroutine of SUPCRT). + # ... is that incorrect? + # CHNOSZ's behavior is different - it only uses the lower-T polymorph below Ttr(P); + # so we get different values from SUPCRT at T=1000, P=50000 (4th condition) where alpha-quartz is stable + # (above Ttr at 1 bar (575 degC), but below Ttr at 50000 bar) + expect_equal(round(CHNOSZ$G)[-4], SUPCRT_G[-4]) + expect_equal(round(CHNOSZ$H)[-4], SUPCRT_H[-4]) + expect_equal(round(CHNOSZ$S, 1)[-4], SUPCRT_S[-4]) + expect_equal(round(CHNOSZ$Cp, 1)[-4], SUPCRT_Cp[-4]) + expect_equal(round(CHNOSZ$V, 1), SUPCRT_V) +}) + +test_that("more calculations for quartz are nearly consistent with SUPCRT92", { # output from SUPCRT92 for reaction specified as "1 QUARTZ" run at 1 bar # (SUPCRT shows phase transition at 574.850 deg C, and does not give Cp values around the transition) S92_1bar <- read.table(header = TRUE, text = " @@ -100,25 +120,11 @@ 576 -214582 -209176 25.1 23.7 ") CHNOSZ_1bar <- subcrt("quartz", T=seq(573, 576), P=1)$out[[1]] - expect_maxdiff(CHNOSZ_1bar$G, S92_1bar$G, 0.5) - expect_maxdiff(CHNOSZ_1bar$H, S92_1bar$H, 0.5) - expect_maxdiff(CHNOSZ_1bar$S, S92_1bar$S, 0.05) - expect_maxdiff(CHNOSZ_1bar$V, S92_1bar$V, 0.05) + expect_equal(round(CHNOSZ_1bar$G), S92_1bar$G) + expect_equal(round(CHNOSZ_1bar$H), S92_1bar$H) + expect_equal(round(CHNOSZ_1bar$S, 1), S92_1bar$S) + expect_equal(round(CHNOSZ_1bar$V, 1), S92_1bar$V) - # 500 bar: SUPCRT shows phase transition at 587.811 deg C - S92_500bar <- read.table(header = TRUE, text = " - T G H S V - 586 -214548 -209318 24.7 23.3 - 587 -214573 -209301 24.7 23.3 - 588 -214602 -208700 25.4 23.7 - 589 -214627 -208684 25.4 23.7 - ") - CHNOSZ_500bar <- subcrt("quartz", T=seq(586, 589), P=500)$out[[1]] - expect_maxdiff(CHNOSZ_500bar$G, S92_500bar$G, 0.5) - expect_maxdiff(CHNOSZ_500bar$H, S92_500bar$H, 25) - expect_maxdiff(CHNOSZ_500bar$S, S92_500bar$S, 0.05) - expect_maxdiff(CHNOSZ_500bar$V, S92_500bar$V, 0.05) - # 5000 bar: SUPCRT shows phase transition at 704.694 deg C S92_5000bar <- read.table(header = TRUE, text = " T G H S V @@ -128,6 +134,7 @@ 706 -215170 -204238 27.5 23.7 ") CHNOSZ_5000bar <- subcrt("quartz", T=seq(703, 706), P=5000)$out[[1]] + # NOTE: calculated values *below* the transition are different expect_maxdiff(CHNOSZ_5000bar$G, S92_5000bar$G, 20) expect_maxdiff(CHNOSZ_5000bar$H, S92_5000bar$H, 300) expect_maxdiff(CHNOSZ_5000bar$S, S92_5000bar$S, 0.5) From noreply at r-forge.r-project.org Sat Oct 7 08:08:38 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 7 Oct 2017 08:08:38 +0200 (CEST) Subject: [CHNOSZ-commits] r245 - in pkg/CHNOSZ: . R data inst man tests/testthat vignettes Message-ID: <20171007060838.588DA183C22@r-forge.r-project.org> Author: jedick Date: 2017-10-07 08:08:37 +0200 (Sat, 07 Oct 2017) New Revision: 245 Removed: pkg/CHNOSZ/data/CHNOSZ.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/berman.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/vignettes/obigt.Rmd Log: berman(): improve disorder calculations Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-07 06:08:37 UTC (rev 245) @@ -1,6 +1,6 @@ Date: 2017-10-07 Package: CHNOSZ -Version: 1.1.0-43 +Version: 1.1.0-44 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/R/basis.R 2017-10-07 06:08:37 UTC (rev 245) @@ -3,11 +3,13 @@ basis <- function(species=NULL, state=NULL, logact=NULL, delete=FALSE) { thermo <- get("thermo") + oldbasis <- thermo$basis ## delete the basis species if requested - oldbasis <- thermo$basis - if(delete) { + if(delete | identical(species, "")) { thermo$basis <- NULL + thermo$species <- NULL assign("thermo", thermo, "CHNOSZ") + return(invisible(oldbasis)) } ## return the basis definition if requested if(is.null(species)) return(oldbasis) @@ -182,7 +184,7 @@ # just list the keywords if none is specified if(is.null(key)) return(basis.key) # delete any previous basis definition - basis(delete=TRUE) + basis("") # match the keyword to the available ones ibase <- match(key, basis.key) if(is.na(ibase)) stop(paste(key, "is not a keyword for preset basis species")) Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/R/berman.R 2017-10-07 06:08:37 UTC (rev 245) @@ -4,7 +4,7 @@ # in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. # J. Petrol. 29, 445-522. https://doi.org/10.1093/petrology/29.2.445 -berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE, calc.transition=TRUE, calc.disorder=FALSE, units="cal") { +berman <- function(name, T = 298.15, P = 1, thisinfo=NULL, check.G=FALSE, calc.transition=TRUE, calc.disorder=TRUE, units="cal") { # reference temperature and pressure Pr <- 1 Tr <- 298.15 @@ -124,19 +124,28 @@ Tds <- T[iTds] # the upper integration limit is Tmax Tds[Tds > Tmax] <- Tmax - # Ber88 Eqs. 15, 16, 17, 18, 19 - Cpds[iTds] <- d0 + d1 * Tds^-0.5 + d2 * Tds^-2 + d3 * Tds + d4 * Tds^2 - Hds[iTds] <- d0 * (Tds - Tmin) + 2 * d1 * (Tds^-0.5 - Tmin^-0.5) - - d2 * (Tds^-1 - Tmin^-1) + d3 * (Tds^2 - Tmin^2) / 2 + d4 * (Tds^3 - Tmin^3) / 3 - Sds[iTds] <- d0 * (log(Tds) - log(Tmin)) - 2 * d1 * (Tds^-0.5 - Tmin^-0.5) - - d2 * (Tds^-2 - Tmin^-2) / 2 + d3 * (Tds - Tmin) + d4 * (Tds^2 - Tmin^2) / 2 - # we can't do this if d5 == 0 (dolomite and gehlenite) + # Ber88 Eqs. 15, 16, 17 + Cpds[iTds] <- d0 + d1*Tds^-0.5 + d2*Tds^-2 + d3*Tds + d4*Tds^2 + Hds[iTds] <- d0*(Tds - Tmin) + d1*(Tds^0.5 - Tmin^0.5)/0.5 + + d2*(Tds^-1 - Tmin^-1)/-1 + d3*(Tds^2 - Tmin^2)/2 + d4*(Tds^3 - Tmin^3)/3 + Sds[iTds] <- d0*(log(Tds) - log(Tmin)) + d1*(Tds^-0.5 - Tmin^-0.5)/-0.5 + + d2*(Tds^-2 - Tmin^-2)/-2 + d3*(Tds - Tmin) + d4*(Tds^2 - Tmin^2)/2 + # Eq. 18; we can't do this if d5 == 0 (dolomite and gehlenite) + # "d5 is a constant computed in such as way as to scale the disordring enthalpy to the volume of disorder" (Berman, 1988) if(d5 != 0) Vds <- Hds / d5 - Gds <- Hds - T * Sds + Vds * (P - Pr) - # Gds above Tmax (Eq. 20) + # Berman puts the Vds term directly into Eq. 19 (commented below), but that necessarily makes Gds != Hds - T * Sds + #Gds <- Hds - T * Sds + Vds * (P - Pr) + # instead, we include the Vds term with Hds + Hds <- Hds + Vds * (P - Pr) + # disordering properties above Tmax (Eq. 20) ihigh <- T > Tmax - # note that Gds[ihigh] and Sds[ihigh] on the rhs were both calculated at Tmax (above) - Gds[ihigh] <- Gds[ihigh] - (T[ihigh] - Tmax) * Sds[ihigh] + # again, Berman put the Sds term (for T > Tmax) into Eq. 20 for Gds (commented below), which would also make Gds != Hds - T * Sds + #Gds[ihigh] <- Gds[ihigh] - (T[ihigh] - Tmax) * Sds[ihigh] + # instead, we add the Sds[ihigh] term to Hds + Hds[ihigh] <- Hds[ihigh] - (T[ihigh] - Tmax) * Sds[ihigh] + # by writing Gds = Hds - T * Sds, the above two changes w.r.t. Berman's + # equations affect the computed values only for Hds, not Gds + Gds <- Hds - T * Sds # apply the disorder contributions Ga <- Ga + Gds Ha <- Ha + Hds @@ -147,8 +156,6 @@ ### (for testing) use G = H - TS to check that integrals for H and S are written correctly Ga_fromHminusTS <- Ha - T * S - # FIXME: this check fails if disorder properties are calculated: - # berman("K-feldspar", T=convert(600, "K"), P=10000, calc.disorder=TRUE) if(!isTRUE(all.equal(Ga_fromHminusTS, Ga))) stop(paste0(name, ": incorrect integrals detected using DG = DH - T*S")) ### thermodynamic and unit conventions used in SUPCRT ### Deleted: pkg/CHNOSZ/data/CHNOSZ.R =================================================================== --- pkg/CHNOSZ/data/CHNOSZ.R 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/data/CHNOSZ.R 2017-10-07 06:08:37 UTC (rev 245) @@ -1,21 +0,0 @@ -# CHNOSZ/data/CHNOSZ.R -# clear system settings (basis/species) - -# we only work if the CHNOSZ environment exists -if(!"CHNOSZ" %in% search()) { - message("data(CHNOSZ): please run data(thermo) first") -} else { - - local({ - # get thermo from CHNOSZ environment - thermo <- get("thermo", "CHNOSZ") - # set basis,species components - thermo$basis <- NULL - thermo$species <- NULL - # place it in CHNOSZ environment - assign("thermo", thermo, "CHNOSZ") - }) - - message("data(CHNOSZ): cleared basis and species settings") - -} Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/inst/NEWS 2017-10-07 06:08:37 UTC (rev 245) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-42 (2017-10-06) +CHANGES IN CHNOSZ 1.1.0-44 (2017-10-07) --------------------------------------- MAJOR CHANGES: @@ -40,9 +40,8 @@ DATABASE UPDATES: -- Add data(OBIGT) and data(CHNOSZ) commands to reset only the - thermodynamic database (OBIGT) or system settings (CHNOSZ: basis and - species) to their defaults. data(thermo) is still used to reset +- Add data(OBIGT) command to reset only the thermodynamic database + (OBIGT) to its default. data(thermo) is still used to reset *everything* (the database and all computational and system settings). - In add.obigt(), using 'file' without a file suffix now can be used to Modified: pkg/CHNOSZ/man/basis.Rd =================================================================== --- pkg/CHNOSZ/man/basis.Rd 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/man/basis.Rd 2017-10-07 06:08:37 UTC (rev 245) @@ -39,8 +39,8 @@ If this occurs, any existing species definition (created by the \code{species} function) is deleted. However, \code{\link{swap.basis}} can be used to change the species (the compositions and/or physical states thereof) in the basis set while maintaining the list of species of interest, with the added benefit of equivalence of the chemical potentials of the elements before and after the swap. -Call \code{basis} with \code{delete} set to TRUE to clear the basis definition. -Any current basis definition (before being deleted) is returned by this call or by calling \code{basis} with all default arguments. +Call \code{basis} with \code{delete} set to TRUE or code{species} set to \code{""} to clear the basis definition. +This also deletes the \code{\link{species}} list, if any. If the value of \code{basis} is one of the keywords in the following table, the corresponding set of basis species is loaded, and their activities are given preset values. This approach is used by many of the examples in the package. @@ -63,7 +63,7 @@ } \value{ -Returns the value of \code{thermo$basis} after any modifications; or, if \code{delete} is TRUE, its value before deletion. +Returns the value of \code{thermo$basis} after any modifications; or, if \code{delete} is TRUE, its value before deletion (invisibly). } \section{Side Effects}{ @@ -91,7 +91,7 @@ basis(c("H2O", "O2")) basis(c("H2O", "O2", "H+")) ## clear the basis species -basis(delete=TRUE) +basis("") \dontrun{ ## marked dontrun because they produce errors Modified: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-07 06:08:37 UTC (rev 245) @@ -8,7 +8,7 @@ \usage{ berman(name, T = 298.15, P = 1, thisinfo = NULL, check.G = FALSE, - calc.transition = TRUE, calc.disorder = FALSE, units = "cal") + calc.transition = TRUE, calc.disorder = TRUE, units = "cal") } \arguments{ @@ -34,8 +34,6 @@ A warning is produced if the absolute value of the difference between tabulated and calculated DGfTrPr is greater than 1000 J/mol. Providing \code{thisinfo} means that the mineral name is not searched in \code{thermo$obigt}, potentially saving some running time. - -FIXME: the default for \code{calc.disorder} is temporarily FALSE, as the code produces incorrect Gibbs energies. } \examples{ Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/man/data.Rd 2017-10-07 06:08:37 UTC (rev 245) @@ -3,7 +3,6 @@ \docType{data} \alias{thermo} \alias{OBIGT} -\alias{CHNOSZ} \alias{opt} \alias{element} \alias{refs} @@ -15,7 +14,7 @@ This includes the computational settings, thermodynamic database, and system settings (chemical species). The system settings are changed using \code{\link{basis}} and \code{\link{species}}. -To restore the default system settings (no species loaded), use \code{data(CHNOSZ)}. +To restore the default system settings (no species loaded), use \code{basis("")}. The thermodynamic database is changed using \code{\link{add.obigt}} and \code{\link{mod.obigt}}. To restore the default database, use \code{data(OBIGT)}. @@ -24,7 +23,7 @@ To restore the default computational settings, thermodynamic database, and system settings, use \code{data(thermo)}. In an interactive session, use \code{data(thermo)} to restore the thermodynamic database and computational and system settings to their initial state. -Or, use \code{data(CHNOSZ)} to clear the system settings (basis and species), or \code{data(OBIGT)} to restore the default database. +Or, use \code{basis("")} to clear the system settings (basis and species), or \code{data(OBIGT)} to restore the default database. The data files provided with CHNOSZ are in the \code{data} and \code{extdata/OBIGT} directories of the package. The \code{*.csv} files in these directories are used to build the \code{thermo} data object in an environment named \code{CHNOSZ}. @@ -34,7 +33,6 @@ \usage{ data(thermo) data(OBIGT) - data(CHNOSZ) } \format{ Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-07 06:08:37 UTC (rev 245) @@ -71,21 +71,19 @@ # anadalusite: an uncomplicated mineral (no transitions) And_G <- c(-579368, -524987, -632421, -576834) And <- subcrt("andalusite", "cr_Berman", T=T, P=P)$out[[1]] - expect_maxdiff(And_G, And$G, 10) + expect_maxdiff(And$G, And_G, 7.5) # quartz: a mineral with polymorphic transitions aQz_G <- c(-202800, -179757, -223864, -200109) aQz <- subcrt("quartz", "cr_Berman", T=T, P=P)$out[[1]] + expect_maxdiff(aQz$G[-2], aQz_G[-2], 1.2) # here, the high-P, low-T point suffers - expect_maxdiff(aQz_G[-2], aQz$G[-2], 1.2) - expect_maxdiff(aQz_G[2], aQz$G[2], 1250) + expect_maxdiff(aQz$G[2], aQz_G[2], 1250) # K-feldspar: this one has disordering effects Kfs_G <- c(-888115, -776324, -988950, -874777) Kfs <- subcrt("K-feldspar", "cr_Berman", T=T, P=P)$out[[1]] - # we lose some accuracy at high T - expect_maxdiff(Kfs_G[1:2], Kfs$G[1:2], 7) - expect_maxdiff(Kfs_G[3:4], Kfs$G[3:4], 1600) - - # (see test-subcrt.R for feldspar and quartz tests with Helgeson/SUPCRT92 values) + expect_maxdiff(Kfs$G[1:2], Kfs_G[1:2], 5) + # we are less consistent with the reference values at high T + expect_maxdiff(Kfs$G[3:4], Kfs_G[3:4], 350) }) Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-07 03:48:11 UTC (rev 244) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-07 06:08:37 UTC (rev 245) @@ -14,7 +14,7 @@ bibliography: obigt.bib # so that these appear in the bibliography nocite: | - @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ, @JOH92, @WP02, @CWM89, @PRPG97, @TH88, @Kul06 + @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ, @JOH92, @WP02, @CWM89, @PRPG97, @TH88, @Kul06, @Sho09 # 20170212: comment the csl line to build package on R-Forge, to avoid # getting an error there (pandoc-citeproc: error while parsing the XML string) csl: elementa.csl @@ -123,9 +123,9 @@ # Recent additions (late 2017) -* Mineral data using the [Berman (1988)]() equations are listed under **Solids**. +* Mineral data using the [Berman (1988)]() equations are listed under **Solids** / **Berman**. -* Aqueous species data compatible with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under **Optional Data**. +* Aqueous species data intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under **Optional Data** / **DEW**. # Sources of data {.tabset .tabset-fade} @@ -184,7 +184,7 @@ ### `r setfile("inorganic_cr.csv")` ```{r inorganic_cr, results="asis", echo=FALSE} cat("Chamosite,7A and witherite were present in sprons92.dat but not in slop98.dat or later files, and are not included in CHNOSZ.\n\n") -cat("Parameters used here for goethite differ slightly from those listed in the slop files [@Sho09].
") +cat("The source of parameters used here for goethite is different from that in the slop files ([Shock, 2009](https://doi.org/10.2113/gsecongeo.104.8.1235)).
") ``` ```{r reflist, results="asis", echo=FALSE} @@ -196,8 +196,8 @@ ### `r setfile("Berman_cr.csv")` ```{r Berman_cr, results="asis", echo=FALSE} -cat("This file gives the identifiying information for minerals whose properties are calculated using the formulation of @Ber88.\n") -cat("To distinguish these minerals from the original set of mineral data in CHNOSZ [based on the compliation of @HDNB78], the physical states are listed as `cr_Berman`.\n") +cat("This file gives the identifiying information for minerals whose properties are calculated using the formulation of [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445).\n") +cat("To distinguish these minerals from the original set of mineral data in CHNOSZ (based on the compliation of [Helgeson et al., 1978](http://www.worldcat.org/oclc/13594862)), the physical states are listed as `cr_Berman`.\n") cat("The actual data are stored separately (`extdata/Berman/*.csv`).
") ``` @@ -223,7 +223,7 @@ ## Optional Data {.tabset .tabset-pills} ```{r Optional_Data, results="asis", echo=FALSE} -cat("These files contain optional data updates that are not loaded by default (using `data(thermo)`). To load these data, run `add.obigt('CHNOSZ_aq')` or `add.obigt('DEW_aq')`.\n\n") +cat("These files contain optional data updates that are not loaded by default (using `data(thermo)`). To load these data, run `add.obigt('CHNOSZ')` or `add.obigt('DEW')`.\n\n") ``` ### `r setfile("DEW_aq.csv")` @@ -236,8 +236,8 @@ ### `r setfile("CHNOSZ_aq.csv")` ```{r CHNOSZ_aq, results="asis", echo=FALSE} -cat("The primary aqueous silica species in CHNSOZ is SiO2 [@SHS89]. The pseudospecies H4SiO4 is used to make activity diagrams with *a*H4SiO4 as a variable. The GHS and HKF parameters for this pseudospecies were calculated using CHNOSZ; see the vignette [*Regressing thermodynamic data*](eos-regress.html) for more information.\n\n") -cat("HKF coefficients for adenine regressed from experimental Cp and V data were reported by Lowe et al. (2017). See [`demo(adenine)`](../demo/adenine.R).
") +cat("The primary aqueous silica species in CHNSOZ is SiO2 ([Shock et al., 1989](https://doi.org/10.1016/0016-7037(89)90341-4)). The pseudospecies H4SiO4 is used to make activity diagrams with *a*H4SiO4 as a variable. The GHS and HKF parameters for this pseudospecies were calculated using CHNOSZ; see the vignette [*Regressing thermodynamic data*](eos-regress.html) for more information.\n\n") +cat("HKF coefficients for adenine regressed from experimental Cp and V data were reported by [Lowe et al. (2017)](https://doi.org/10.1016/j.jct.2017.04.005). See [`demo(adenine)`](../demo/adenine.R).
") ``` ```{r noreflist, results="asis", echo=FALSE} From noreply at r-forge.r-project.org Sun Oct 8 16:27:07 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 8 Oct 2017 16:27:07 +0200 (CEST) Subject: [CHNOSZ-commits] r246 - in pkg/CHNOSZ: . R demo inst man tests/testthat vignettes Message-ID: <20171008142707.2DB90188B9A@r-forge.r-project.org> Author: jedick Date: 2017-10-08 16:27:06 +0200 (Sun, 08 Oct 2017) New Revision: 246 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/equilibrate.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/R/water.R pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/demo/berman.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/equilibrate.Rd pkg/CHNOSZ/tests/testthat/test-equilibrate.R pkg/CHNOSZ/vignettes/anintro.Rmd Log: allow varying values for loga.balance Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-08 14:27:06 UTC (rev 246) @@ -1,6 +1,6 @@ -Date: 2017-10-07 +Date: 2017-10-08 Package: CHNOSZ -Version: 1.1.0-44 +Version: 1.1.0-45 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/R/diagram.R 2017-10-08 14:27:06 UTC (rev 246) @@ -48,7 +48,7 @@ } else if(what %in% rownames(eout$basis)) { # to calculate the loga of basis species at equilibrium if(!missing(groups)) stop("can't plot equilibrium activities of basis species for grouped species") - if(alpha) stop("equilibrium activities of basis species not available with alpha=TRUE") + if(isTRUE(alpha) | is.character(alpha)) stop("equilibrium activities of basis species not available with alpha=TRUE") plot.loga.basis <- TRUE } else if(what=="loga.equil" & !"loga.equil" %in% names(eout)) stop("'eout' is not the output from equil()") else if(what!="loga.equil") stop(what, " is not a basis species or 'loga.equil'") @@ -127,10 +127,12 @@ } ## alpha: plot fractional degree of formation - ## scale the activities to sum=1 ... 20091017 - if(alpha) { + # scale the activities to sum=1 ... 20091017 + # allow scaling by balancing component 20171008 + if(isTRUE(alpha) | is.character(alpha)) { # remove the logarithms act <- lapply(plotvals, function(x) 10^x) + if(identical(alpha, "balance")) for(i in 1:length(act)) act[[i]] <- act[[i]] * eout$n.balance[i] # sum the activities sumact <- Reduce("+", act) # divide activities by the total Modified: pkg/CHNOSZ/R/equilibrate.R =================================================================== --- pkg/CHNOSZ/R/equilibrate.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/R/equilibrate.R 2017-10-08 14:27:06 UTC (rev 246) @@ -2,6 +2,10 @@ # functions to calculation logarithm of activity # of species in (metastable) equilibrium +## if this file is interactively sourced, the following are also needed to provide unexported functions: +#source("util.misc.R") +#source("util.character.R") + equilibrate <- function(aout, balance=NULL, loga.balance=NULL, ispecies=1:length(aout$values), normalize=FALSE, as.residue=FALSE, method=c("boltzmann", "reaction"), tol=.Machine$double.eps^0.25) { @@ -28,14 +32,25 @@ nspecies <- length(aout$values) ## say what the balancing coefficients are if(length(n.balance) < 100) message(paste("equilibrate: n.balance is", c2s(n.balance))) - ## logarithm of total activity of the balance + ## logarithm of total activity of the balancing basis species if(is.null(loga.balance)) { # sum up the activities, then take absolute value # in case n.balance is negative sumact <- abs(sum(10^aout$species$logact * n.balance)) loga.balance <- log10(sumact) } - message(paste0("equilibrate: loga.balance is ", loga.balance)) + # make loga.balance the same length as the values of affinity + loga.balance <- unlist(loga.balance) + nvalues <- length(unlist(aout$values[[1]])) + if(length(loga.balance) == 1) { + # we have a constant loga.balance + message(paste0("equilibrate: loga.balance is ", loga.balance)) + loga.balance <- rep(loga.balance, nvalues) + } else { + # we are using a variable loga.balance (supplied by the user) + if(!identical(length(loga.balance), nvalues)) stop("length of loga.balance (", length(loga.balance), ") doesn't match the affinity values (", nvalues, ")") + message(paste0("equilibrate: loga.balance has same length as affinity values (", length(loga.balance), ")")) + } ## normalize -- normalize the molar formula by the balance coefficients m.balance <- n.balance isprotein <- grepl("_", as.character(aout$species$name)) @@ -94,6 +109,7 @@ Anames <- names(Astar) # first loop: make vectors A <- palply("", 1:length(A), function(i) as.vector(A[[i]])) + loga.balance <- as.vector(loga.balance) # second loop: get the exponentiated Astars (numerators) # need to convert /2.303RT to /RT #A[[i]] <- exp(log(10)*Astar[[i]]/n.balance[i])/n.balance[i] @@ -103,7 +119,7 @@ At <- A[[1]] At[] <- 0 for(i in 1:length(A)) At <- At + A[[i]]*n.balance[i] - # fourth loop: calculate log abundances and replace the dimensions + # fourth loop: calculate log abundances A <- palply("", 1:length(A), function(i) loga.balance + log10(A[[i]]/At)) # fifth loop: replace dimensions for(i in 1:length(A)) dim(A[[i]]) <- Astardim @@ -139,6 +155,7 @@ Anames <- names(Astar) # make a matrix out of the list of Astar Astar <- list2array(lapply(Astar, c)) + if(length(loga.balance) != nrow(Astar)) stop("length of loga.balance must be equal to the number of conditions for affinity()") # that produces the same result (other than colnames) and is much faster than #Astar <- sapply(Astar, c) # also, latter has NULL nrow for length(Astar[[x]])==1 @@ -148,7 +165,7 @@ # to calculate logact(thing) from Abar for the ith condition [2] logactfun <- function(Abar, i) Astar[i,] - Abar * n.balance # to calculate difference between logafun and loga.balance for the ith condition - logadiff <- function(Abar, i) loga.balance - logafun(logactfun(Abar, i)) + logadiff <- function(Abar, i) loga.balance[i] - logafun(logactfun(Abar, i)) # to calculate a range of Abar that gives negative and positive values of logadiff for the ith condition Abarrange <- function(i) { # starting guess of Abar (min/max) from range of Astar / n.balance Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/R/util.plot.R 2017-10-08 14:27:06 UTC (rev 246) @@ -72,8 +72,14 @@ # (i.e. redox variable is on the y axis) # get axes, T, P, and xpoints from output of affinity() or equilibrate() if(missing(eout)) stop("'eout' (the output of affinity(), equilibrate(), or diagram()) is missing") + # number of variables used in affinity() + nvar1 <- length(eout$vars) + # if these were on a transect, the actual number of variables is less + dim <- dim(eout$loga.equil[[1]]) # for output from equilibrate() + if(is.null(dim)) dim <- dim(eout$values[[1]]) # for output from affinity() + nvar2 <- length(dim) # we only work on diagrams with 2 variables - if(length(eout$vars) != 2) return(NA) + if(nvar1 != 2 | nvar2 != 2) return(NA) # if needed, swap axes so T or P is on x-axis swapped <- FALSE if(eout$vars[2] %in% c("T", "P")) { Modified: pkg/CHNOSZ/R/water.R =================================================================== --- pkg/CHNOSZ/R/water.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/R/water.R 2017-10-08 14:27:06 UTC (rev 246) @@ -318,7 +318,7 @@ available_properties <- c("G", "epsilon", "QBorn", "V", "rho", "beta") if(is.null(property)) return(available_properties) # we can't use Psat here - if(identical(P, "Psat")) stop("Psat isn't supported in this implementation of the DEW model") + if(identical(P, "Psat")) stop("Psat isn't supported in this implementation of the DEW model. Try setting P to at least 1000 bar.") # use uppercase property names (including H, S, etc., so we get them from the SUPCRT properties) wprop <- water.SUPCRT92() iprop <- match(property, wprop) Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-08 14:27:06 UTC (rev 246) @@ -7,7 +7,7 @@ oldwat <- water("DEW") #### plot 1: quartz solubility at high pressure -## after Figure 7D of Sverjensky et al., 2014 +## after Figure 7D of Sverjensky et al., 2014a [SHA14] ## (Geochim. Cosmochim. Acta, https://doi.org/10.1016/j.gca.2013.12.019) # load SiO2 and Si2O4 data taken from DEW spreadsheet @@ -41,14 +41,13 @@ text(lastT+25, tail(logm, 1), Pkb, adj=0) } t1 <- quote("Solubility of"~alpha*"-quartz") -t2 <- "(after Sverjensky et al., 2014)" +t2 <- "after Sverjensky et al., 2014a" mtitle(as.expression(c(t1, t2))) # TODO: lines are a little low at highest P and P ... # does the Berman, 1988 quartz data increase high-PT solubilities? #### plot 2: correlations between non-solvation volume and HKF a1 parameter -## after Figures 12B and 12C of Sverjensky et al., 2014 -## (Geochim. Cosmochim. Acta, https://doi.org/10.1016/j.gca.2013.12.019) +## after Figures 12B and 12C of Sverjensky et al., 2014a [SHA14] # load the fitted parameters for species as used by SHA14 # TODO: also use their Ca+2?? # NOTE: don't load NaCl, NH4+, or HS- here because the DEW spreadsheet lists a1 from the correlation @@ -86,8 +85,8 @@ t2 <- quote("volume and HKF "*italic(a)[1]*" parameter") mtitle(as.expression(c(t1, t2))) -#### plots 3 and 4: aqueous inorganic and organic carbon species at high pressure -## after Figure 1b of Sverjensky et al., 2014 +#### plot 3: aqueous inorganic and organic carbon species at high pressure +## after Figure 1b of Sverjensky et al., 2014b [SSH14] ## (Nature Geoscience, https://doi.org/10.1038/NGEO2291) # define system with loga.species = 0 @@ -103,19 +102,100 @@ legend("bottomleft", legend=dp, bty="n") } -# first plot: CHNOSZ default database data(OBIGT) -dfun() -t1 <- quote("CHNOSZ default database"[]) -t2 <- quote("(not recommended for high"~italic(P)*")") -mtitle(as.expression(c(t1, t2))) -# second plot: use CO2, HCO3-, CO3-2, and methane data from DEW spreadsheet +## (not run) make diagram using CHNOSZ default database +#dfun() +#t1 <- quote("CHNOSZ default database"[]) +#t2 <- quote("(not recommended for high"~italic(P)*")") +#mtitle(as.expression(c(t1, t2))) +# make diagram using CO2, HCO3-, CO3-2, and methane data from DEW spreadsheet add.obigt("DEW_aq", c("CO2", "HCO3-", "CO3-2", "methane")) dfun() CO2quote <- quote(list(CO[2], HCO[3]^"-", CO[3]^"-2")) DEWexpr <- substitute("DEW data for"~x, list(x=CO2quote)) mtitle(as.expression(c(DEWexpr, "and methane"))) +#### plot 4: after SSH14 Fig. 3 (added 20171008) +# conditions: +# T = 600, 700, 800, 900, 1000 degC +# P = 5.0GPa (50000 bar) +# fO2 = QFM - 2 +# pH set by jadeite + kyanite + coesite +# dissolved carbon 0.03, 0.2, 1, 4, 20 molal + +T <- seq(600, 1000, 5) + +## use DEW model +data(thermo) +water("DEW") +# add species data for DEW +inorganics <- c("methane", "CO2", "HCO3-", "CO3-2") +organics <- c("formic acid", "formate", "acetic acid", "acetate", "propanoic acid", "propanoate") + +# skip updating acetate because the new data from the DEW spreadsheet give different logK +add.obigt("DEW", c(inorganics, organics[-4])) +## set basis species +b.species <- c("Fe", "CO3-2", "H2O", "O2", "SiO2", "H+") +b.state <- c("cr", "aq", "liq", "gas", "aq", "aq") +basis(b.species, b.state) +# for the time being we use a constant pH +basis("H+", -4) + +## define a QFM buffer using Berman minerals +mod.buffer("QFM_Berman", c("quartz", "fayalite", "magnetite"), "cr_Berman", 0) + +## calculate fO2 in QFM buffer minus 2 +basis("O2", "QFM_Berman") +a <- affinity(T=T, P=50000, return.buffer=TRUE) +QFM_2 <- a$O2 - 2 + +## now that we have QFM-2, remove QFM buffer for calculations below +basis("O2", 0) + +## add species +species(c(inorganics, organics)) + +## calculate affinities on the T-logfO2 transect +a <- affinity(T=T, O2=QFM_2, P=50000) + +## use the total carbon molality as an approximation of total activity +molC <- splinefun(seq(600, 1000, 100), c(0.03, 0.2, 1, 4, 20))(T) +loga.C <- log10(molC) + +## calculate metastable equilibrium activities +e <- equilibrate(a, loga.balance=loga.C) + +## make the diagram; don't plot names of low-abundance species +names <- c(inorganics, organics) +names[c(4, 5, 7, 9)] <- "" +col <- rep("black", length(names)) +col[c(1, 3, 6, 8, 10)] <- c("red", "darkgreen", "purple", "orange", "navyblue") +diagram(e, alpha="balance", names=names, col=col, ylim=c(0, 0.8)) + +## add legend and title +ltxt1 <- "P = 50000 bar" +ltxt2 <- substitute(logfO2=="QFM-2", list(logfO2=axis.label("O2"))) +ltxt3 <- "pH = 4" +legend("left", legend=as.expression(c(ltxt1, ltxt2, ltxt3)), bty="n") +t1 <- "Aqueous carbon speciation" +t2 <- "after Sverjensky et al., 2014b" +mtitle(c(t1, t2)) + +### additional checks +# check that we're within 0.1 of the QFM-2 values used by SSH14 +stopifnot(maxdiff(QFM_2[T %% 100 == 0], c(-17.0, -14.5, -12.5, -10.8, -9.4)) < 0.1) +# Here are the logKs of aqueous species dissociation reactions at 600 degC and 50000 bar, +# taken from the Supporting Information of the paper (p. 103-109): +inorganic.logK <- c(24.4765, -9.0784, -5.3468, 0) +organic.logK <- c(1.7878, 2.5648, 15.3182, 16.9743, 30.4088, 28.9185) +# calculate equilibrium constants of the reactions in CHNOSZ; use a negative sign to change from formation to dissociation +logK.calc <- -unlist(affinity(T=600, P=50000, property="logK")$values) +logK.calc - c(inorganic.logK, organic.logK) +# check that we're within 0.021 of the logK values used by SSH14 +stopifnot(maxdiff(logK.calc, c(inorganic.logK, organic.logK)) < 0.021) + +############# +### all done! # reset the database and previous water computational option data(OBIGT) water(oldwat) Modified: pkg/CHNOSZ/demo/berman.R =================================================================== --- pkg/CHNOSZ/demo/berman.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/demo/berman.R 2017-10-08 14:27:06 UTC (rev 246) @@ -1,6 +1,8 @@ # CHNOSZ/demo/berman.R 20171003 # make some mineral activity diagrams using Berman (1988) and related data +res <- 200 + # using the Helgeson data # set up basis species basis(c("K+", "Al+3", "quartz", "H2O", "O2", "H+")) @@ -9,7 +11,7 @@ # load the species species(c("K-feldspar", "muscovite", "kaolinite", "pyrophyllite", "andalusite"), "cr") # calculate affinities in aK+ - temperature space -a <- affinity(`K+`=c(0, 6), T=c(25, 650), P=1000) +a <- affinity(`K+`=c(0, 5, res), T=c(200, 650, res), P=1000) # note that we go just past the quartz transition, but it has no effect on the diagram diagram(a) @@ -22,7 +24,8 @@ # load the Berman minerals species(c("K-feldspar", "muscovite", "kaolinite", "pyrophyllite", "andalusite"), "cr_Berman") # calculate affinities in aK+ - temperature space -a <- affinity(`K+`=c(0, 6), T=c(25, 650), P=1000) +a <- affinity(`K+`=c(0, 5, res), T=c(200, 650, res), P=1000) diagram(a, add=TRUE, names="", col="blue", lwd=2) -legend("topleft", lty=c(1, 1), lwd=c(1, 2), col=c("black", "blue"), legend=c("Helgeson et al., 1978", "Berman, 1988")) +legend("topleft", lty=c(1, 1), lwd=c(1, 2), col=c("black", "blue"), + legend=c("Helgeson et al., 1978 (unadjusted)", "Berman, 1988 (adjusted by Sverjensky et al., 1991)")) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/inst/NEWS 2017-10-08 14:27:06 UTC (rev 246) @@ -1,26 +1,40 @@ -CHANGES IN CHNOSZ 1.1.0-44 (2017-10-07) +CHANGES IN CHNOSZ 1.1.0-45 (2017-10-08) --------------------------------------- MAJOR CHANGES: +- Add berman() function and extdata/Berman/*.csv files for calculating + thermodynamic properties of minerals using equations of Berman, 1988. + +- Calculations related to Berman's (1988) Figs. 1 and 2 for the lambda + transition of quartz are presented in the new demo lambda.R. + - Add functions implementing the Deep Earth Water (DEW) model (Sverjensky et al., 2014): water.DEW() and its supporting functions calculateDensity(), calculateGibbsofWater(), calculateEpsilon(), calculateQ(). -- The computational setting for water (thermo$opt$par) can now be - set using water("DEW"), water("IAPWS"), etc. +- The computational setting for water (thermo$opt$par) can now be set + using water("DEW"), water("IAPWS"), etc. -- Usage of the DEW model is demonstrated in the new demo DEW.R. +- Usage of the DEW model is shown in the new demo DEW.R. This demo also + depends on the Berman equations (above) and, for the last diagram, the + following two NEWS items: -- Add berman() function and extdata/Berman/*.csv files for calculating - thermodynamic properties of mineral using equations of Berman, 1988. +- In equilibrate(), it is now possible to combine affinity calculations + with changing activity of the balancing basis species (loga.balance). + For example, in the last plot of the DEW demo, the affinity transect + involves simultaneously varying temperature and logfO2 (given as + arguments to affinity()) as well as total concentration of carbon + (approximated by the loga.balance argument in equilibrate()). -- Calculations related to Berman's (1988) Figs. 1 and 2 for the lambda - transition of quartz are presented in the new demo lambda.R. - COMPUTATIONAL IMPROVEMENTS: +- The 'alpha' argument of diagram() can be set to 'balance' to scale + the values by the balancing component. This is useful for making + "percent carbon" plots for systems where the species have different + carbon numbers. + - For minerals with phase transitions (states 'cr2' 'cr3' etc.) in thermo$obigt (i.e. the Helgeson minerals), it is now possible to use the minerals in basis(), species(), affinity() with proper accounting Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/man/diagram.Rd 2017-10-08 14:27:06 UTC (rev 246) @@ -27,7 +27,7 @@ \arguments{ \item{eout}{list, object returned by \code{\link{equilibrate}} or \code{\link{affinity}}} \item{what}{character, what property to calculate and plot} - \item{alpha}{logical, for speciation diagrams, plot degree of formation instead of activities?} + \item{alpha}{logical or character (\samp{balance}), for speciation diagrams, plot degree of formation instead of activities?} \item{normalize}{logical, divide chemical affinities by balance coefficients (rescale to whole formulas)?} \item{as.residue}{logical, divide chemical affinities by balance coefficients (no rescaling)?} \item{balance}{character, balancing constraint; see \code{\link{equilibrate}}} @@ -80,6 +80,7 @@ The allowed variables are any that \code{\link{affinity}} accepts: temperature, pressure, or the chemical activities of the basis species If \code{alpha} is TRUE, the fractional degrees of formation (ratios of activities to total activity) are plotted. +Or, setting \code{alpha} to \samp{balance} allows the activities to be multiplied by the number of the balancing component; this is useful for making \dQuote{percent carbon} diagrams where the species differ in carbon number. If \code{groups} is supplied, the activities of the species identified in each numeric element of this list are multiplied by the balance coefficients of the species, then summed together. The names of the list are used to label the lines or fields for the summed activities of the resulting groups. Modified: pkg/CHNOSZ/man/equilibrate.Rd =================================================================== --- pkg/CHNOSZ/man/equilibrate.Rd 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/man/equilibrate.Rd 2017-10-08 14:27:06 UTC (rev 246) @@ -23,8 +23,8 @@ \item{normalize}{logical, normalize the molar formulas of species by the balancing coefficients?} \item{as.residue}{logical, report results for the normalized formulas?} \item{Astar}{numeric, affinities of formation reactions excluding species contribution} - \item{n.balance}{numeric, number of moles of conserved component in the formation reactions of the species of interest} - \item{loga.balance}{numeric, logarithm of total activity of balanced quantity} + \item{n.balance}{numeric, number of moles of balancing component in the formation reactions of the species of interest} + \item{loga.balance}{numeric (single value or vector), logarithm of total activity of balanced quantity} \item{method}{character, equilibration method to use} \item{tol}{numeric, convergence tolerance for \code{\link{uniroot}}} } @@ -37,7 +37,7 @@ \code{aout} contains the chemical affinities of formation reactions of each species of interest. \code{equilibrate} needs to be provided constraints on how to balance the reactions representing transformations between the species. -\code{balance} indicates the balancing constraints, according to the following scheme: +\code{balance} indicates the balancing component, according to the following scheme: \itemize{ \item \samp{NULL}: autoselect @@ -53,6 +53,7 @@ NOTE: The summation of activities assumes an ideal system, so \sQuote{molality} is equivalent to \sQuote{activity} here. \code{loga.balance} gives the logarithm of the total activity of \code{balance} (which is total activity of species for \samp{1} or total activity of amino acid residue-equivalents for \samp{length}). If \code{loga.balance} is missing, its value is taken from the activities of species listed in \code{aout}; this default is usually the desired operation. +The supplied value of \code{loga.balance} may also be a vector of values, with length corresponding to the number of conditions in the calculations of \code{\link{affinity}}. \code{normalize} if TRUE indicates to normalize the molar formulas of species by the balance coefficients. This operation is intended for systems of proteins, whose conventional formulas are much larger than the basis speices. @@ -70,15 +71,13 @@ The input values to \code{equil.reaction} and \code{equil.boltzmann} are in a list, \code{Astar}, all elements of the list having the same dimensions; they can be vectors, matrices, or higher-dimensionsal arrays. Each list element contains the chemical affinities of the formation reactions of one of the species of interest (in dimensionless base-10 units, i.e. A/2.303RT), calculated at unit activity of the species of interest. -The equilibrium activities (in base-10 log units) of the species of interest returned by either function satisfy the constraints that 1) the final chemical affinities of the formation reactions of the species are all equal and 2) the total activity of the conserved component is equal to (\code{loga.balance}). +The equilibrium base-10 logarithm activities of the species of interest returned by either function satisfy the constraints that 1) the final chemical affinities of the formation reactions of the species are all equal and 2) the total activity of the balancing component is equal to (\code{loga.balance}). The first constraint does \emph{not} impose a complete equilibrium, where the affinities of the formation reactions are all equal to zero, but allows for a metastable equilibrium, where the affinities of the formation reactions are equal to each other. In \code{equil.reaction} (the algorithm described in Dick, 2008 and the only one available prior to CHNOSZ_0.8), the calculations of relative abundances of species are based on a solving a system of equations representing the two constraints stated above. -A close approximation of the solution is found using \code{\link{uniroot}}. -Prior to CHNOSZ_0.9-9, the values in the \code{Astar} were used to generate initial guesses of the logarithms of activities of species; values of \code{loga.balance} that were hugely different from these guesses could generate errors from \code{uniroot} such as "f() values at end points not of opposite sign". -Now (from version 0.9-9), a more flexible method for generating guesses is in place. +The solution is found using \code{\link{uniroot}} with a flexible method for generating initial guesses. -In \code{equil.boltzmann} (algorithm available beginning with CHNOSZ_0.8), the chemical activities of species are calculated using the Boltzmann distribution. +In \code{equil.boltzmann}, the chemical activities of species are calculated using the Boltzmann distribution. This calculation is faster than the algorithm of \code{equil.reaction}, but is limited to systems where the transformations are all balanced on one mole of species. If \code{equil.boltzmann} is called with \code{balance} other than \samp{1}, it stops with an error. @@ -106,10 +105,10 @@ res <- 100 Astar <- affinity(pH=c(0, 14, res))$values # the logarithms of activity for a total activity -# of the balanced quantity (C or CO2) equal to 0.001 +# of the balancing component (CO2) equal to 0.001 loga.boltz <- equil.boltzmann(Astar, c(1, 1, 1), 0.001) # calculated another way -loga.react <- equil.reaction(Astar, c(1, 1, 1), 0.001) +loga.react <- equil.reaction(Astar, c(1, 1, 1), rep(0.001, 100)) # probably close enough for most purposes stopifnot(all.equal(loga.boltz, loga.react)) # the first ionization constant (pKa) Modified: pkg/CHNOSZ/tests/testthat/test-equilibrate.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-equilibrate.R 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/tests/testthat/test-equilibrate.R 2017-10-08 14:27:06 UTC (rev 246) @@ -122,6 +122,38 @@ expect_error(equilibrate(a, balance=1.000001, method="boltzmann"), "won't run equil.boltzmann") }) +test_that("equilibrate() can be used with a vector of loga.balance values", { + # system is balanced on CO2; species have different number of C, so loga.balance affects the equilibrium activities + basis("CHNOS") + species(c("formic acid", "acetic acid", "propanoic acid")) + # calculate reference values at logfO2 = -80, log(aCO2tot) = -6 + basis("O2", -80) + a <- affinity() + e80.6 <- unlist(equilibrate(a, loga.balance = -6)$loga.equil) + # calculate reference values at logfO2 = -60, log(aCO2tot) = -8 + basis("O2", -60) + a <- affinity() + e60.8 <- unlist(equilibrate(a, loga.balance = -8)$loga.equil) + # calculate affinity on a transect: logfO2 from -80 to -60 + O2 <- seq(-80, -60) + aO2 <- affinity(O2=O2) + # values calculated at the ends of the transect should be the same as above + eO2.6 <- equilibrate(aO2, loga.balance = -6)$loga.equil + expect_equal(list2array(eO2.6)[1, ], e80.6) + eO2.8 <- equilibrate(aO2, loga.balance = -8)$loga.equil + expect_equal(list2array(eO2.8)[21, ], e60.8) + # make an vector of loga.balance to go with the logfO2 transect + # first we make a vector with non-matching length, and get an error + logaCO2.wronglen <- seq(-6, -8) + expect_error(equilibrate(aO2, loga.balance=logaCO2.wronglen), "length of loga.balance \\(3) doesn't match the affinity values \\(21)") + # now do it with the correct length + logaCO2 <- seq(-6, -8, length.out=length(O2)) + eO2 <- equilibrate(aO2, loga.balance=logaCO2) + # now the first set of conditions is logfO2 = -80, log(aCO2tot) = -6 + expect_equal(list2array(eO2$loga.equil)[1, ], e80.6) + # and the final set is logfO2 = -80, log(aCO2tot) = -6 + expect_equal(list2array(eO2$loga.equil)[21, ], e60.8) +}) # references Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-07 06:08:37 UTC (rev 245) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-08 14:27:06 UTC (rev 246) @@ -930,7 +930,7 @@ That makes a diagram that is similar to Figure 6b of Shock and Schulte (1998). ```{marginfigure} -Some differences from the original diagrams may be caused by the sensitivity of the calculations to log*f*O2, for which the values we use here may carry artifacts introduced by digitization of their plot. +Some differences from the original diagrams could be caused by the sensitivity of the calculations to log*f*O2, for which the values we use here may carry artifacts introduced by digitization of their plot. ``` It is also possible to plot the distribution of species within individual groups, such as alcohols and ketones. We do this by setting the names and line types for the *other* species to values that prevent them from being plotted: From noreply at r-forge.r-project.org Mon Oct 9 01:36:33 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Oct 2017 01:36:33 +0200 (CEST) Subject: [CHNOSZ-commits] r247 - in pkg/CHNOSZ: . R data demo inst/extdata/Berman inst/extdata/OBIGT tests/testthat vignettes Message-ID: <20171008233633.34A091891B0@r-forge.r-project.org> Author: jedick Date: 2017-10-09 01:36:32 +0200 (Mon, 09 Oct 2017) New Revision: 247 Added: pkg/CHNOSZ/inst/extdata/Berman/BDat17.csv pkg/CHNOSZ/inst/extdata/Berman/FDM+14.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/berman.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz pkg/CHNOSZ/inst/extdata/OBIGT/DEW_aq.csv pkg/CHNOSZ/tests/testthat/test-berman.R pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: update some thermodynamic data and references Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-08 23:36:32 UTC (rev 247) @@ -1,6 +1,6 @@ -Date: 2017-10-08 +Date: 2017-10-09 Package: CHNOSZ -Version: 1.1.0-45 +Version: 1.1.0-46 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/berman.R =================================================================== --- pkg/CHNOSZ/R/berman.R 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/R/berman.R 2017-10-08 23:36:32 UTC (rev 247) @@ -19,8 +19,10 @@ SHD91 <- read.csv(paste0(dir, "/SHD91.csv"), as.is=TRUE) ZS92 <- read.csv(paste0(dir, "/ZS92.csv"), as.is=TRUE) JUN92 <- read.csv(paste0(dir, "/JUN92.csv"), as.is=TRUE) + FDM14 <- read.csv(paste0(dir, "/FDM+14.csv"), as.is=TRUE) + BDat17 <- read.csv(paste0(dir, "/BDat17.csv"), as.is=TRUE) # assemble the files in reverse chronological order - dat <- rbind(JUN92, ZS92, SHD91, Ber90, Ber88) + dat <- rbind(BDat17, FDM14, JUN92, ZS92, SHD91, Ber90, Ber88) # remove duplicates (only the first, i.e. latest entry is kept) dat <- dat[!duplicated(dat$name), ] # remove the multipliers Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/data/refs.csv 2017-10-08 23:36:32 UTC (rev 247) @@ -24,14 +24,15 @@ Ber90.1,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","almandine and ilmenite: modified H and/or S",http://ammin.geoscienceworld.org/content/75/3-4/328 Eva90,"B. W. Evans",1990,"Lithos 25, 3-23","glaucophane and pumpellyite",https://doi.org/10.1016/0024-4937(90)90003-J SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O +SH90.1,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","formic acid, formate, and propanoate",https://doi.org/10.1016/0016-7037(90)90429-O SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H revisions for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.1,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","phlogopite: H and S modified by @Ber90, followed by G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.2,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","annite: G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 -JUN92,"C. de Capitani",1992,"JUN92.bs database supplied with Theriak/Domino software","data as listed in JUN92.bs database",http://titan.minpet.unibas.ch/minpet/theriak/theruser.html +JUN92,"C. de Capitani",1992,"JUN92.bs database supplied with Theriak/Domino software","data as listed in `JUN92.bs` data file",http://titan.minpet.unibas.ch/minpet/theriak/theruser.html SPRONS92.1,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","titanite: @BH83 + "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", SPRONS92.2,"H. C. Helgeson et al.",1992,"sprons92.dat computer data file","Ca-bearing minerals; "Gibbs free energies and enthalpies were corrected to be consistent with updated values of Gibbs free energies of Ca2+ and CO32- [@SH88] together with the solubilities of calcite and aragonite reported by @PB82 "", Sho92,"E. L. Shock",1992,"Geochim. Cosmochim. Acta 56, 3481-3491","diglycine, alanylglycine, leucylglycine, and diketopiperazine",https://doi.org/10.1016/0016-7037(92)90392-V -ZS92,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","F,Cl,OH biotite and apatite endmembers. GHS and V were taken from Table 6 of @ZS92; heat capacity and volume parameters from `berman.dat` in SUPCRT92b.zip file on the [DEW website](http://www.dewcommunity.org/resources.html).",https://doi.org/10.1016/0016-7037(92)90390-5 +ZS92,"C. Zhu and D. A. Sverjensky",1982,"Geochim. Cosmochim. Acta 56, 3435-3467","F,Cl,OH biotite and apatite endmembers. GHS and V were taken from Table 6 of @ZS92; heat capacity and volume parameters from `berman.dat`.",https://doi.org/10.1016/0016-7037(92)90390-5 Sho93,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349","ethylacetate and acetamide",https://doi.org/10.1016/0016-7037(93)90542-5 Sho93.1,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349","carbon monoxide and ethylene",https://doi.org/10.1016/0016-7037(93)90542-5 SK93,"E. L. Shock and C. M. Koretsky",1993,"Geochim. Cosmochim. Acta 57, 4899-4922","metal-acetate complexes",https://doi.org/10.1016/0016-7037(93)90128-J @@ -77,7 +78,7 @@ AS01.1,"J. P. Amend and E. L. Shock",2001,"FEMS Microbiol. Rev. 25, 175-243","selenium and molybdenite",https://doi.org/10.1111/j.1574-6976.2001.tb00576.x MVT01,"L. Mercury, P. Vieillard. and Y. Tardy",2001,"Appl. Geochem. 16, 161-181","polymorphs of ice",https://doi.org/10.1016/S0883-2927(00)00025-1 PS01,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","aqueous nonelectrolytes",https://doi.org/10.1016/S0016-7037(01)00678-0 -PS01.1,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","acetic acid and methane",https://doi.org/10.1016/S0016-7037(01)00678-0 +PS01.1,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","acetic acid, propanoic acid, and methane",https://doi.org/10.1016/S0016-7037(01)00678-0 Ric01,"L. Richard",2001,"Geochim. Cosmochim. Acta 65, 3827-3877","organic sulfur compounds",https://doi.org/10.1016/S0016-7037(01)00761-X SSW01,"M. D. Schulte, E. L. Shock and R. H. Wood",2001,"Geochim. Cosmochim. Acta 65, 3919-3930","AsH3, CF4, CH3F, Cl2, ClO2, N2O, NF3, NO, PH3, and SF6",https://doi.org/10.1016/S0016-7037(01)00717-7 MGN03,"J. Majzlan, K.-D. Grevel and A. Navrotsky",2003,"Am. Mineral. 88, 855-859","goethite, lepidocrocite, and maghemite GHS",https://doi.org/10.2138/am-2003-5-614 @@ -111,6 +112,7 @@ LD12.3,"D. E. LaRowe and J. M. Dick",2012,"Geochim. Cosmochim. Acta 80, 70-91","methionine sidechain GHS",https://doi.org/10.1016/j.gca.2011.11.041 DEH+13,"J. M. Dick, K. A. Evans et al.",2013,"Geochim. Cosmochim. Acta 122, 247-266","phenanthrene and methylphenanthrene isomers",https://doi.org/10.1016/j.gca.2013.08.020 FDM+14,"S. Facq et al.",2014,"Geochim. Cosmochim. Acta 132, 375-390","CO2, CO3-2, and HCO3-",https://doi.org/10.1016/j.gca.2014.01.030 +FDM+14.1,"S. Facq et al.",2014,"Geochim. Cosmochim. Acta 132, 375-390","aragonite; source of data: `berman.dat`",https://doi.org/10.1016/j.gca.2014.01.030 SHA14,"D. A. Sverjensky et al.",2014,"Geochim. Cosmochim. Acta 129, 125-145","SiO2 and Si2O4",https://doi.org/10.1016/j.gca.2013.12.019 SHA14.1,"D. A. Sverjensky et al.",2014,"Geochim. Cosmochim. Acta 129, 125-145","revisions for AlO2- and HAlO2",https://doi.org/10.1016/j.gca.2013.12.019 SHA14.2,"D. A. Sverjensky et al.",2014,"Geochim. Cosmochim. Acta 129, 125-145","revisions for BO(OH) and BO2-",https://doi.org/10.1016/j.gca.2013.12.019 @@ -133,7 +135,7 @@ CHNOSZ.7,"J. M. Dick",2017,"CHNOSZ package documentation","charge of NpO2(Oxal), La(Succ)+, NH4(Succ)-, and NpO2(Succ) as listed by @PSK99",http://chnosz.net CHNOSZ.8,"J. M. Dick",2017,"CHNOSZ package documentation","Incorrect values of HKF a1--a4 parameters for [-CH2NH2] were printed in Table 6 of @DLH06; corrected values are used here.",http://chnosz.net LCT17,"A. R. Lowe, J. S. Cox and P. R. Tremaine",2017,"J. Chem. Thermodynamics 112, 129-145","adenine Cp and V",https://doi.org/10.1016/j.jct.2017.04.005 -DEW17,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","data from Aqueous Species Table in spreadsheet (see detailed references there)",http://www.dewcommunity.org +DEW17,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","other data from Aqueous Species Table in spreadsheet (see detailed references there)",http://www.dewcommunity.org DEW17.1,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","revised with new predicted a1 for ions",http://www.dewcommunity.org DEW17.2,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","revised with new predicted a1 for cations",http://www.dewcommunity.org DEW17.3,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","revised with new predicted a1 for complex species",http://www.dewcommunity.org @@ -165,7 +167,6 @@ DEW17.32,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","NaOH: Fitted to Ho & Palmer (1997) data with a1 pred. from the sum of the ions and used to predict the volume",http://www.dewcommunity.org DEW17.33,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","OH-: August 16th, 2013 fit to Bandura & Lvov (2005)",http://www.dewcommunity.org DEW17.34,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","propane: Shock & Helgeson (1990) with new a1-a4 based on revised correlation to predict a1 in Sverjensky et al. (2013)",http://www.dewcommunity.org -DEW17.35,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","propanoate: Revised a1 from new delVn correlation for -1 ions; kept original regression c1 and c2 plus omega from Shock & Helgeson (1990)",http://www.dewcommunity.org DEW17.36,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","S3-: Regression of data from Pokrovski & Dubessy (2015), Guggenheim (1971); Feb. 2015",http://www.dewcommunity.org DEW17.38,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","SO2: Shock et al. (1989) with revised a1 predicted as a complex from delVn",http://www.dewcommunity.org DEW17.39,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","toluene: Plyasunov & Shock (2001) with new a1 to a4 predicted with revised a1 consistent with Sverjensky et al. (2013)",http://www.dewcommunity.org @@ -173,3 +174,5 @@ DEW17.101,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","methane: revised with new predicted a1 for complex species",http://www.dewcommunity.org DEW17.102,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","MgCl+: revised volume increased in order that a1 of the complex is the sum of the a1 values of the ions",http://www.dewcommunity.org DEW17.103,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","NaCl: revised with new predicted a1 for complex species",http://www.dewcommunity.org +DEW17.104,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","propanoate: Revised a1 from new delVn correlation for -1 ions",http://www.dewcommunity.org +BDat17.1,"D. A. Sverjensky et al.",2017,"berman.dat file in SUPCRT92b.zip on the DEW website","antigorite: "Oct. 21, 2016: Revised volume coefficients consistent with @HDR06 and @YIY+14 "",http://www.dewcommunity.org/resources.html Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-08 23:36:32 UTC (rev 247) @@ -6,9 +6,11 @@ # activate DEW model oldwat <- water("DEW") +########### #### plot 1: quartz solubility at high pressure ## after Figure 7D of Sverjensky et al., 2014a [SHA14] ## (Geochim. Cosmochim. Acta, https://doi.org/10.1016/j.gca.2013.12.019) +########### # load SiO2 and Si2O4 data taken from DEW spreadsheet iSi <- add.obigt("DEW_aq", c("SiO2", "Si2O4")) @@ -46,8 +48,11 @@ # TODO: lines are a little low at highest P and P ... # does the Berman, 1988 quartz data increase high-PT solubilities? +########### #### plot 2: correlations between non-solvation volume and HKF a1 parameter ## after Figures 12B and 12C of Sverjensky et al., 2014a [SHA14] +########### + # load the fitted parameters for species as used by SHA14 # TODO: also use their Ca+2?? # NOTE: don't load NaCl, NH4+, or HS- here because the DEW spreadsheet lists a1 from the correlation @@ -85,9 +90,11 @@ t2 <- quote("volume and HKF "*italic(a)[1]*" parameter") mtitle(as.expression(c(t1, t2))) -#### plot 3: aqueous inorganic and organic carbon species at high pressure +########### +#### plot 3: logfO2-pH diagram for aqueous inorganic and organic carbon species at high pressure ## after Figure 1b of Sverjensky et al., 2014b [SSH14] ## (Nature Geoscience, https://doi.org/10.1038/NGEO2291) +########### # define system with loga.species = 0 basis("CHNOS+") @@ -115,12 +122,16 @@ DEWexpr <- substitute("DEW data for"~x, list(x=CO2quote)) mtitle(as.expression(c(DEWexpr, "and methane"))) -#### plot 4: after SSH14 Fig. 3 (added 20171008) +########### +#### plot 4: speciation of carbon as a function T, logfO2 and pH (added 20171008) +## after SSH14 Fig. 3 +########### + # conditions: # T = 600, 700, 800, 900, 1000 degC # P = 5.0GPa (50000 bar) # fO2 = QFM - 2 -# pH set by jadeite + kyanite + coesite +# pH set by jadeite + kyanite + coesite (approximated here as constant) # dissolved carbon 0.03, 0.2, 1, 4, 20 molal T <- seq(600, 1000, 5) @@ -135,16 +146,14 @@ # skip updating acetate because the new data from the DEW spreadsheet give different logK add.obigt("DEW", c(inorganics, organics[-4])) ## set basis species -b.species <- c("Fe", "CO3-2", "H2O", "O2", "SiO2", "H+") -b.state <- c("cr", "aq", "liq", "gas", "aq", "aq") -basis(b.species, b.state) +basis(c("Fe", "SiO2", "CO3-2", "H2O", "oxygen", "H+")) # for the time being we use a constant pH basis("H+", -4) -## define a QFM buffer using Berman minerals +## define a QFM buffer using Berman's equations for minerals mod.buffer("QFM_Berman", c("quartz", "fayalite", "magnetite"), "cr_Berman", 0) -## calculate fO2 in QFM buffer minus 2 +## calculate logfO2 as QFM minus 2 basis("O2", "QFM_Berman") a <- affinity(T=T, P=50000, return.buffer=TRUE) QFM_2 <- a$O2 - 2 @@ -181,7 +190,7 @@ t2 <- "after Sverjensky et al., 2014b" mtitle(c(t1, t2)) -### additional checks +## additional checks # check that we're within 0.1 of the QFM-2 values used by SSH14 stopifnot(maxdiff(QFM_2[T %% 100 == 0], c(-17.0, -14.5, -12.5, -10.8, -9.4)) < 0.1) # Here are the logKs of aqueous species dissociation reactions at 600 degC and 50000 bar, @@ -194,8 +203,9 @@ # check that we're within 0.021 of the logK values used by SSH14 stopifnot(maxdiff(logK.calc, c(inorganic.logK, organic.logK)) < 0.021) -############# +########### ### all done! # reset the database and previous water computational option data(OBIGT) water(oldwat) +########### Added: pkg/CHNOSZ/inst/extdata/Berman/BDat17.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/BDat17.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/BDat17.csv 2017-10-08 23:36:32 UTC (rev 247) @@ -0,0 +1,2 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +antigorite,-66076529,-71364156,3602.996,174.246,7394.51,0,-5483.63,8728.412,-1.485,4,27.2,80,,,,,,,,,,,,,, Added: pkg/CHNOSZ/inst/extdata/Berman/FDM+14.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/Berman/FDM+14.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/Berman/FDM+14.csv 2017-10-08 23:36:32 UTC (rev 247) @@ -0,0 +1,2 @@ +name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5 +aragonite,-1128353.67,-1207213.7,88.7,3.42,195,-21,-0.1,22,-1.345,1.7,41.8,0,,,,,,,,,,,,,, Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/inst/extdata/OBIGT/DEW_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/DEW_aq.csv 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/inst/extdata/OBIGT/DEW_aq.csv 2017-10-08 23:36:32 UTC (rev 247) @@ -57,8 +57,8 @@ FeCl3,FeCl3(0),FeCl3,aq,DEW17,NA,26.Sep.17,-99307,-134400,18,-28,37.4,8.927750435512179,4.2169678004086695,1.3022132117708338,-2.9533294488688946,-7.4792707212502485,-8.738199999999999,0.3,0 FeCl4-,FeCl4(-),FeCl4-,aq,DEW17,NA,26.Sep.17,-127917,-180057,26,-95.9,55.8,12.950315210745682,8.046848504824029,-1.9091054640732654,-3.1116567171894256,-38.64687843457357,-22.56943,1.2363,-1 FeO,FeO(0),FeO,aq,DEW17,NA,26.Sep.17,-50720,,-10,0,3,2.246926435512177,-2.1438393852779156,6.635689757212449,-2.6903736798126108,8.930455103006798,-3.0346,0.3,0 -formate,FORMATE,HCOO-,aq,DEW17,NA,26.Sep.17,-83862,-101680,21.7,-20.177464600379487,26.159971565219035,5.268366909492395,7.6836443146635105,3.4705805840890083,-3.0966418559681896,17,-12.4,1.3003,-1 -"formic acid",FORMIC-ACID,HCOOH,aq,DEW17,NA,26.Sep.17,-88982,-101680,38.9,19.024124873651285,34.69001430971288,8.092450502078368,3.4216794020330656,1.9690549970623223,-2.920452226480047,22.1924,-3.1196,-0.3442,0 +formate,FORMATE,HCOO-,aq,SH90.1,DEW17.1,26.Sep.17,-83862,-101680,21.7,-20.177464600379487,26.159971565219035,5.268366909492395,7.6836443146635105,3.4705805840890083,-3.0966418559681896,17,-12.4,1.3003,-1 +"formic acid",FORMIC-ACID,HCOOH,aq,SH90.1,DEW17.3,26.Sep.17,-88982,-101680,38.9,19.024124873651285,34.69001430971288,8.092450502078368,3.4216794020330656,1.9690549970623223,-2.920452226480047,22.1924,-3.1196,-0.3442,0 Ga+3,Ga(+3),Ga+3,aq,DEW17,NA,26.Sep.17,-38000,-50600,-79,-30.799816226244204,-44.900021278327145,-9.112600703984713,-1.513730145487252,14.464344791566415,-2.7164223957855573,13.244942645072129,-9.308522565285944,2.7276,3 Gd+3,Gd(+3),Gd+3,aq,DEW17,NA,26.Sep.17,-158600,-164200,-49.2,-35.899991514322814,-40.400091694714845,-7.815913141749289,-2.4648289055059194,13.665950891634948,-2.6771039730463855,6.560657450392803,-10.347428271467557,2.3265,3 glutamate,GLUTAMATE,C5H8NO4-,aq,DEW17,NA,26.Sep.17,-167258,0,44.4,11.10918772896642,79.70753937846106,17.46,12.34,-5.51,-3.29,50,-14.8,0.9569,-1 @@ -148,7 +148,7 @@ PO4-3,PO4(-3),PO4-3,aq,DEW17,NA,26.Sep.17,-243500,-305300,-53,-114.89996391595473,-30.600095804682038,-1.1970758608927012,-7.319635964606203,9.590613498435385,-2.4764062492231798,-9.47495397363052,-26.43972264967998,5.6114,-3 Pr+3,Pr(+3),Pr+3,aq,DEW17,NA,26.Sep.17,-162600,-168800,-50,-47.69967108409179,-42.09999378698761,-8.527528167362654,-1.9428711200045896,14.104105087060267,-2.69868170789901,-1.197656471892774,-12.751022999829498,2.235,3 propane,PROPANE,C3H8,aq,DEW17,NA,26.Sep.17,-1963,-30490,33.37,110.59958327471779,66.99993622090898,14.290088050581724,9.322445153802782,-2.9786811657360044,-3.1643898826582073,66.32953185662123,19.49453511306001,-0.5053,0 -propanoate,PROPANOATE,C2H5COO-,aq,DEW17,NA,26.Sep.17,-86770,-122630,26.5,32.45551213710533,54.950066467724966,8.378618967437145,19.33650894227708,0.04597812207649099,-3.5783712796737346,52.3,-4.2,1.2276,-1 +propanoate,PROPANOATE,C2H5COO-,aq,SH90.1,DEW17.104,26.Sep.17,-86770,-122630,26.5,32.45551213710533,54.950066467724966,8.378618967437145,19.33650894227708,0.04597812207649099,-3.5783712796737346,52.3,-4.2,1.2276,-1 "propanoic acid",PROPANOIC-ACID,C3H6O2,aq,DEW17,NA,26.Sep.17,-93450,-122470,49.4,61.28421794436844,68.27064151281941,14.6,7.9,6.9,-4.3,63.3,-1.4,-0.09,0 propanol,PROPANOL,C3H7OH,aq,DEW17,NA,26.Sep.17,-41910,-75320,40.6,82.84849041327438,70.88199974121683,14.6,9.1,12.2,-5.5,74.3,3.3,-0.2,0 Ra+2,Ra(+2),Ra+2,aq,DEW17,NA,26.Sep.17,-134200,-126100,13,-14.40028139320611,-10.59999289581294,1.5462375047327335,-8.634006964911572,7.8259092280446785,-2.422070152070556,6.285875837483136,-5.967937319796084,0.929,2 Modified: pkg/CHNOSZ/tests/testthat/test-berman.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-08 23:36:32 UTC (rev 247) @@ -7,8 +7,11 @@ Ber90 <- read.csv(paste0(dir, "/Ber90.csv"), as.is=TRUE) SHD91 <- read.csv(paste0(dir, "/SHD91.csv"), as.is=TRUE) ZS92 <- read.csv(paste0(dir, "/ZS92.csv"), as.is=TRUE) +JUN92 <- read.csv(paste0(dir, "/JUN92.csv"), as.is=TRUE) +FDM14 <- read.csv(paste0(dir, "/FDM+14.csv"), as.is=TRUE) +BDat17 <- read.csv(paste0(dir, "/BDat17.csv"), as.is=TRUE) # assemble the files and remove duplicates (keep the latest) -dat <- rbind(ZS92, SHD91, Ber90, Ber88) +dat <- rbind(BDat17, FDM14, JUN92, ZS92, SHD91, Ber90, Ber88) dat <- dat[!duplicated(dat$name), ] mineral <- unique(dat$name) prop_Berman <- NULL @@ -16,9 +19,7 @@ test_that("properties of all minerals are computed without warnings", { # running this without error means that: # - formulas for the minerals are found in thermo$obigt - # - there are no warnings for minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) - #expect_silent(properties <- lapply(mineral, berman, check.G=TRUE)) - # - warnings are produced for 3 minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) + # - warnings are produced for mineral(s) with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table) expect_warning(properties <- lapply(mineral, berman, check.G=TRUE), "fluortremolite", all=TRUE) # save the results so we can use them in the next tests @@ -55,11 +56,11 @@ # which minerals differ in Cp by more than 4 cal/K/mol? idiffCp <- which(abs(prop_Berman$Cp - prop_Helgeson$Cp) > 4) - expect_match(mineral[idiffCp], "antigorite|cristobalite,beta|K-feldspar|fluortremolite") + expect_match(mineral[idiffCp], "glaucophane|antigorite|cristobalite,beta|K-feldspar|fluortremolite") # which minerals differ in V by more than 1 cm^3/mol? idiffV <- which(abs(prop_Berman$V - prop_Helgeson$V) > 1) - expect_match(mineral[idiffV], "anthophyllite|antigorite|chrysotile|merwinite") + expect_match(mineral[idiffV], "glaucophane|anthophyllite|antigorite|chrysotile|merwinite") }) test_that("high-T,P calculated properties are similar to precalculated ones", { Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-08 23:36:32 UTC (rev 247) @@ -117,10 +117,12 @@ Any secondary references (`ref2`) are listed with bullet points. Each reference is followed by the number of species, and a note (from `thermo$refs`). Symbols show whether the data were present in the earliest of the sprons92.dat (?), slop98.dat (\*), slop07.dat (?), or slop15.dat (?) datafiles for the SUPCRT92 package. +NOTE: URLs for the slop files and other data files cited below (`JUN92.bs`, `berman.dat`, and the DEW model spreadsheet) are given in the References. Any additional comments are placed at the beginning of the sections. -Abbreviations used below are: Cp (heat capacity), GHS (standard Gibbs energy, enthalpy, entropy), HKF (Helgeson-Kirkham-Flowers equations), *V* (volume), *T* (temperature), *P* (pressure). +Abbreviations used below are: Cp (heat capacity), GHS (standard Gibbs energy, enthalpy, entropy), HKF (Helgeson-Kirkham-Flowers equations), V (volume), T (temperature), P (pressure). + # Recent additions (late 2017) * Mineral data using the [Berman (1988)]() equations are listed under **Solids** / **Berman**. Modified: pkg/CHNOSZ/vignettes/obigt.bib =================================================================== --- pkg/CHNOSZ/vignettes/obigt.bib 2017-10-08 14:27:06 UTC (rev 246) +++ pkg/CHNOSZ/vignettes/obigt.bib 2017-10-08 23:36:32 UTC (rev 247) @@ -1014,15 +1014,48 @@ } @Article{Kul06, - author = {Kulik, D. A.}, - journal = {Chemical Geology}, - title = {{D}ual-thermodynamic estimation of stoichiometry and stability of solid solution end members in aqueous?solid solution systems}, + author = {Kulik, D. A.}, + journal = {Chemical Geology}, + title = {{D}ual-thermodynamic estimation of stoichiometry and stability of solid solution end members in aqueous?solid solution systems}, + year = {2006}, + volume = {225}, + number = {3}, + pages = {189--212}, + note = {Solid solutions: from theory to experiment}, + doi = {10.1016/j.chemgeo.2005.08.014}, + issn = {0009-2541}, +} + + at Misc{BDat17, + author = {berman.dat}, + title = {{D}ata file in {SUPCRT}92b.zip on the {DEW} website}, + howpublished = {Last updated on 2017-02-03. Accessed on 2017-05-04.}, + year = {2017}, + url = {http://www.dewcommunity.org/resources.html}, +} + + at Article{HDR06, + author = {Hilairet, Nad?ge and Daniel, Isabelle and Reynard, Bruno}, + journal = {Geophysical Research Letters}, + title = {{E}quation of state of antigorite, stability field of serpentines, and seismicity in subduction zones}, year = {2006}, - volume = {225}, - number = {3}, - pages = {189--212}, - note = {Solid solutions: from theory to experiment}, - doi = {10.1016/j.chemgeo.2005.08.014}, - issn = {0009-2541}, + volume = {33}, + number = {2}, + pages = {L02302}, + doi = {10.1029/2005GL024728}, + issn = {1944-8007}, } + at Article{YIY+14, + author = {Yang, Cuiping and Inoue, Toru and Yamada, Akihiro and Kikegawa, Takumi and Ando, Jun-ichi}, + journal = {Physics of the Earth and Planetary Interiors}, + title = {{E}quation of state and phase transition of antigorite under high pressure and high temperature}, + year = {2014}, + volume = {228}, + number = {Supplement C}, + pages = {56--62}, + note = {High-Pressure Research in Earth Science: Crust, Mantle, and Core}, + doi = {10.1016/j.pepi.2013.07.008}, + issn = {0031-9201}, +} + From noreply at r-forge.r-project.org Mon Oct 9 05:14:35 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Oct 2017 05:14:35 +0200 (CEST) Subject: [CHNOSZ-commits] r248 - in pkg/CHNOSZ: . demo man Message-ID: <20171009031435.5207A1885C7@r-forge.r-project.org> Author: jedick Date: 2017-10-09 05:14:34 +0200 (Mon, 09 Oct 2017) New Revision: 248 Removed: pkg/CHNOSZ/demo/berman.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/man/berman.Rd Log: delete demo/berman.R; move diagram to man/berman.Rd Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-08 23:36:32 UTC (rev 247) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-09 03:14:34 UTC (rev 248) @@ -1,6 +1,6 @@ Date: 2017-10-09 Package: CHNOSZ -Version: 1.1.0-46 +Version: 1.1.0-47 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-08 23:36:32 UTC (rev 247) +++ pkg/CHNOSZ/demo/00Index 2017-10-09 03:14:34 UTC (rev 248) @@ -21,4 +21,3 @@ adenine HKF parameters regressed from heat capacity and volume of aqueous adenine DEW Deep Earth Water (DEW) model for high pressures lambda Effects of lambda transtion on thermodynamic properties of quartz -berman Mineral stability diagrams calculated using Berman's equations Deleted: pkg/CHNOSZ/demo/berman.R =================================================================== --- pkg/CHNOSZ/demo/berman.R 2017-10-08 23:36:32 UTC (rev 247) +++ pkg/CHNOSZ/demo/berman.R 2017-10-09 03:14:34 UTC (rev 248) @@ -1,31 +0,0 @@ -# CHNOSZ/demo/berman.R 20171003 -# make some mineral activity diagrams using Berman (1988) and related data - -res <- 200 - -# using the Helgeson data -# set up basis species -basis(c("K+", "Al+3", "quartz", "H2O", "O2", "H+")) -# use pH = 0 so that aK+ = aK+/aH+ -basis("pH", 0) -# load the species -species(c("K-feldspar", "muscovite", "kaolinite", "pyrophyllite", "andalusite"), "cr") -# calculate affinities in aK+ - temperature space -a <- affinity(`K+`=c(0, 5, res), T=c(200, 650, res), P=1000) -# note that we go just past the quartz transition, but it has no effect on the diagram -diagram(a) - -# now using the Berman data -basis("SiO2", "cr_Berman") -# it might be good to check that we have Berman's quartz and not coesite or some other SiO2 phase -info(basis()$ispecies[3]) -# remove the Helgeson minerals -species(delete=TRUE) -# load the Berman minerals -species(c("K-feldspar", "muscovite", "kaolinite", "pyrophyllite", "andalusite"), "cr_Berman") -# calculate affinities in aK+ - temperature space -a <- affinity(`K+`=c(0, 5, res), T=c(200, 650, res), P=1000) -diagram(a, add=TRUE, names="", col="blue", lwd=2) - -legend("topleft", lty=c(1, 1), lwd=c(1, 2), col=c("black", "blue"), - legend=c("Helgeson et al., 1978 (unadjusted)", "Berman, 1988 (adjusted by Sverjensky et al., 1991)")) Modified: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd 2017-10-08 23:36:32 UTC (rev 247) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-09 03:14:34 UTC (rev 248) @@ -64,6 +64,39 @@ species(c("quartz", "quartz,beta", "coesite"), "cr_Berman") a <- affinity(T=c(200, 1700, 200), P=c(0, 50000, 200)) diagram(a) + +## a longer example, comparing diagrams made using the +## Berman and Helgeson datasets, after Sverjensky et al., 1991 +res <- 200 +# using the Helgeson data +# set up basis species +basis(c("K+", "Al+3", "quartz", "H2O", "O2", "H+")) +# use pH = 0 so that aK+ = aK+/aH+ +basis("pH", 0) +# load the species +species(c("K-feldspar", "muscovite", "kaolinite", + "pyrophyllite", "andalusite"), "cr") +# calculate affinities in aK+ - temperature space +a <- affinity(`K+`=c(0, 5, res), T=c(200, 650, res), P=1000) +# note that we go just past the quartz transition, +# but it has no effect on the diagram +diagram(a, xlab=ratlab("K+")) +# now using the Berman data +basis("SiO2", "cr_Berman") +# it might be good to check that we have Berman's quartz +# and not coesite or some other SiO2 phase +info(basis()$ispecies[3]) +# remove the Helgeson minerals +species(delete=TRUE) +# load the Berman minerals +species(c("K-feldspar", "muscovite", "kaolinite", + "pyrophyllite", "andalusite"), "cr_Berman") +a <- affinity(`K+`=c(0, 5, res), T=c(200, 650, res), P=1000) +diagram(a, add=TRUE, names="", col="blue", lwd=2) +legend("topleft", lty=c(1, 1, NA), lwd=c(1, 2, 0), col=c("black", "blue", ""), + legend=c("Helgeson et al., 1978 (unadjusted)", + "Berman, 1988", " (adjusted by Sverjensky et al., 1991)"), bty="n") +title(main="Comparison of Helgeson and Berman datasets at 1000 bar") } \references{ @@ -72,6 +105,8 @@ Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O?K{\s2}O?CaO?MgO?FeO?Fe{\s2}O{\s3}?Al{\s2}O{\s3}?SiO{\s2}?TiO{\s2}?H{\s2}O?CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445} Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K. (1978) Summary and critique of the thermodynamic properties of rock-forming minerals. \emph{Am. J. Sci.} \bold{278-A}, 1--229. \url{http://www.worldcat.org/oclc/13594862} + +Sverjensky, D. A., Hemley, J. J. and D'Angelo, W. M. (1991) Thermodynamic assessment of hydrothermal alkali feldspar-mica-aluminosilicate equilibria. \emph{Geochim. Cosmochim. Acta} \bold{55}, 989-1004. \url{https://doi.org/10.1016/0016-7037(91)90157-Z} } \concept{Secondary thermodynamic modeling} From noreply at r-forge.r-project.org Mon Oct 9 17:16:40 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Oct 2017 17:16:40 +0200 (CEST) Subject: [CHNOSZ-commits] r249 - in pkg/CHNOSZ: . data demo inst inst/extdata/OBIGT man vignettes Message-ID: <20171009151640.CA065188827@r-forge.r-project.org> Author: jedick Date: 2017-10-09 17:16:40 +0200 (Mon, 09 Oct 2017) New Revision: 249 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/adenine.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/biotic_aq.csv.xz pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: use Lowe et al., 2017 parameters for adenine Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-09 15:16:40 UTC (rev 249) @@ -1,6 +1,6 @@ Date: 2017-10-09 Package: CHNOSZ -Version: 1.1.0-47 +Version: 1.1.0-48 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/data/refs.csv 2017-10-09 15:16:40 UTC (rev 249) @@ -88,7 +88,7 @@ HPT06,"B. Hawrylak, R. Palepu and P. R. Tremaine",2006,"J. Chem. Thermodynamics 38, 988-1007","methyldiethanolamine and methyldiethanolammonium chloride HKF parameters",https://doi.org/10.1016/j.jct.2005.10.013 LH06a,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724","nucleic-acid bases, nucleosides, and nucleotides",https://doi.org/10.1016/j.gca.2006.04.010 LH06a.1,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724","citric acid and citrate",https://doi.org/10.1016/j.gca.2006.04.010 -LH06a.2,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724","adenine GHS",https://doi.org/10.1016/j.gca.2006.04.010 +LH06a.2,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724","adenine-old, HKF parameters superseded by @LCT17",https://doi.org/10.1016/j.gca.2006.04.010 LH06b,"D. E. LaRowe and H. C. Helgeson",2006,"Thermochim. Acta 448, 82-106","Mg-complexed adenosine nucleotides (ATP), NAD, and NADP",https://doi.org/10.1016/j.tca.2006.06.008 LH06b.1,"D. E. LaRowe and H. C. Helgeson",2006,"Thermochim. Acta 448, 82-106","pyridine and piperidine",https://doi.org/10.1016/j.tca.2006.06.008 DLH06,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336","amino acid, protein, and organic groups",https://doi.org/10.5194/bg-3-311-2006 @@ -134,7 +134,7 @@ CHNOSZ.6,"J. M. Dick",2017,"CHNOSZ package documentation","dipeptides not included in slop files after slop98.dat",http://chnosz.net CHNOSZ.7,"J. M. Dick",2017,"CHNOSZ package documentation","charge of NpO2(Oxal), La(Succ)+, NH4(Succ)-, and NpO2(Succ) as listed by @PSK99",http://chnosz.net CHNOSZ.8,"J. M. Dick",2017,"CHNOSZ package documentation","Incorrect values of HKF a1--a4 parameters for [-CH2NH2] were printed in Table 6 of @DLH06; corrected values are used here.",http://chnosz.net -LCT17,"A. R. Lowe, J. S. Cox and P. R. Tremaine",2017,"J. Chem. Thermodynamics 112, 129-145","adenine Cp and V",https://doi.org/10.1016/j.jct.2017.04.005 +LCT17,"A. R. Lowe, J. S. Cox and P. R. Tremaine",2017,"J. Chem. Thermodynamics 112, 129-145","adenine HKF parameters",https://doi.org/10.1016/j.jct.2017.04.005 DEW17,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","other data from Aqueous Species Table in spreadsheet (see detailed references there)",http://www.dewcommunity.org DEW17.1,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","revised with new predicted a1 for ions",http://www.dewcommunity.org DEW17.2,"D. A. Sverjensky et al.",2017,"Deep Earth Water (DEW) spreadsheet","revised with new predicted a1 for cations",http://www.dewcommunity.org Modified: pkg/CHNOSZ/demo/adenine.R =================================================================== --- pkg/CHNOSZ/demo/adenine.R 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/demo/adenine.R 2017-10-09 15:16:40 UTC (rev 249) @@ -57,7 +57,10 @@ # error bars (arrows trick from https://stackoverflow.com/questions/13032777/scatter-plot-with-error-bars) arrows(AdH$T, AdH$Cp - AdH$Cp_SD, AdH$T, AdH$Cp + AdH$Cp_SD, length = 0.05, angle = 90, code = 3) # get LH06 predictions using HKF model -LH06 <- subcrt("adenine", T = TK)$out$adenine +# this version of adenine parameters has been superseded by LCT17 +# but are still available as optional data +add.obigt("CHNOSZ", "adenine-old") +LH06 <- subcrt("adenine-old", T = TK)$out$adenine lines(TK, LH06$Cp, lty = 3) # density model (parameters from LCT17 Table 11) lines(TK, Cpfun(160.4, -653239, -7930.3, TK), lty = 2) @@ -104,9 +107,7 @@ lines(TK, LH06$V, lty = 3) # density model with coefficients from LCT17 lines(TK, Vfun(73.9, -917.0, -7930.3, TK), lty = 2) -# load HKF coefficients for adenine reported by LCT17 -# note that the Cp coefficients here are very close to those regressed above! -add.obigt("CHNOSZ_aq", "adenine") +# HKF heat capacity coefficients from LCT17 LCT17 <- subcrt("adenine", T = TK)$out$adenine lines(TK, LCT17$V, lwd = 2, col = "royalblue") legend("bottomright", lty = c(3, 2, 1), lwd = c(1, 1, 2), col = c("black", "black", "royalblue"), bty = "n", Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/inst/NEWS 2017-10-09 15:16:40 UTC (rev 249) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-45 (2017-10-08) +CHANGES IN CHNOSZ 1.1.0-48 (2017-10-09) --------------------------------------- MAJOR CHANGES: @@ -75,10 +75,13 @@ minerals from the Helgeson data. The parameters themselves are stored in extdata/Berman/*.csv. +- Update HKF parameters of adenine based on experimental heat capacity + and volume data (Lowe et al., 2017). Add demo/adenine.R comparing + the updates with the previous data (LaRowe and Helgeson, 2006). + - 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 - added to this file. + It is now intended to hold optional data. Currently it contains + pseudo-H4SiO4 and adenine-old. - Remove H2O(gas) from the database (taken from SUPCRT92), as it gives inconsistent results for metastable steam (Zavarin et al., 2016, Modified: pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv 2017-10-09 15:16:40 UTC (rev 249) @@ -1,3 +1,3 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T pseudo-H4SiO4,NA,H4SiO4,aq,CHNOSZ.4,NA,18.Feb.17,-312565,-346409,51.4246,-40.0964,52.1998,89.2031,-176.5071,-452.1431,101.36051,67.0854,-52.0776,0.1215745,0 -adenine,NA,C5H5N5,aq,LCT17,LH06a.2,26.Jul.17,74770,31235,53.41,51.63,90.6,23.53,0,-17.75,0,48.54,-3.318,-1.093,0 +adenine-old,NA,C5H5N5,aq,LH06a.2,NA,03.Mar.17,74770,31235,53.41,56.24,89.59,21.5046,8.501,-2.6632,-5.3561,87.88,-15.87,0.065,0 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/biotic_aq.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/biotic_aq.csv.xz 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/inst/extdata/OBIGT/biotic_aq.csv.xz 2017-10-09 15:16:40 UTC (rev 249) @@ -1,4 +1,4 @@ -?7zXZ???F!t/?????/]7I??b???9??????TB;q?"?q???cL;?"??I?,t?b?PK??7?t(?em?A-P?Q?]?? ??8?.f?|?????V[?????=??K????VTm??~vw? ?2/ ??Wa???s?-?????p?lVs????H???u???? ?%?XF??k#??????????+??(??m5?St5?Fa?a??jN??8????>z???3MwS?%??????+?3x??`cw`?; $? (???????P?>????>?1b???QA??????>6o?=?-?((??pN???i????VOL?A???9 c?E3??XP?? ??kj?s?????Y!&o??w(??3?+?"???????; ??R6eW????![?????r?O>O?*?h\t????ty??)B????n<?9l?N!3???z '???}???nV?,0uVe??????? j?????|B??d^7&KK?- @@ -20,64 +20,66 @@ :???K???]t;"\???2m@\,(d??????? ??*?g?bA????'??'x?=;?kx?e|?d???nM????>??)?)?(K?jv??y&5?v d?9?p{?X??v?L????-8[?"J?jh?>k}?L6???????b?)???Y????^????i??j???7T?D?????j? ?5?? bN?.\?p????[?_~?$r7?Tzt&???]W??a???H?L?????+?????fXw??GF%y3J?F**?8x?+":?*?????U?:?? -?DVT??-r???6J?!?v?e,?W??T??????????jf?????I?zbcO?,????8?W???/?c$?S?-??lG?W??R+???????UYp???z? K???)A??M?????%v?j????>??????2??[j5???H????????^?? U9{??W??x5???g???r^?t????}??R?e???T??>?p?q6?o?Y9?????y?$ut?3? - -?S1?U??3?????8oT?-? X~?Ay????O?h??d@??/?~????9 ??G1??<9:O?L????Re?b????Zk2??b???f_?sG??Lw????? fF?DC?t?W????0 Z??Q?o?5?Q????q????0?TO????/#???T?l???????-??m?,r?e?xrlo~?>?x?C,???5?|nMb8??x?m?B?????n????fU?/????????Df???R? -???C?j??1!?yy???T?%u??+?Jg?????b??{#&{8?H 6???1?B?A*???????B?Q%?m(?/?Bb{? ?i?z5???0?1g?kG??? ?:??\3Sh??"?3ky??w?t -???xi0!?KR? ???9????? -U????????P ;????T???;?j7????42j at S???J?L7n? -=?+????gU^F$ -?,??H??*$m????f2A????X?5?PP????z#q?c?k???h???????Q???KR??+??EF&???f??}H??Zw????2?cd*????!?3?K?@,l?!?v5?_???h??0X??9?$7'?e?'?????:(?U?FJz?a??????????u?b?? -?G???B?????V8 ?G???l?B -3?5 n?GC??D?m'o??9??????????pe{)??=<,????R????}?_???e?????0S3?3?e8?6IFw?? ???ab??B8W??:??'????{< ???nD??`?~w??????e????;Y?g?h???????3??/cG??s ?;?5?z?U??G?E???D???>???U56???^b??0?R?wO??#?o?]:???^3??0jh??z????A?8??c?????>?/???7???????p?Y????/????????w??-?M(??Nc6-?Qk?L?H???6,????;^u???7??|Ddp??h??3?????2CI|?' i???o??y[B#h;?? -|??q????O?p5`?????A??]h?!?2j?N?^?P??6t???tI?Ln{? ??????? -)K-??:I?so?z???BQh?\=??[???S_|N?I?"??W??h?A ??#??r?x6?U?` ?H???????????4?T??5$L??D??E>??Aqp??????? ?y$?z>?/0???C??F??zfu?D??d~T?Yn}a?UF?7?!b~??>v????\@Z_???"??m!?)}MQ????????uk?#?)=[?0#?&f?;??O?v\?+?Q}1F???/????7n??*!@?5??A?{??-&??_ ???c?5F???{?????i??8???i??t??]??*d???VTU?????4%?N&M??L?^%? -?]?? m?S???G????R6??K?yd/??Z???\? ?c????? ?????A??L???o? ?2???=? ??+???????;??y?:h???n???????? J??m??h? ?`?l?F????- ???X???h?!?[???{??^(???;?g?f????p????h&???????\FRc????P -oH? ??y\4???\_?????n???Xz?/?cU??-${?$????,???G??#?? -~8????????t{?a?X ?E>?r?F| ^???Gh????[????????Bi?O???g`??}W???? ?$)???p??pk?L??1?i?C?U9f@?9bqD???????)?? nV???k '??T?#?v)????{?\5R=??P Q??????_???Xn???4^u??i?w?!U?Gi)?>9??q ??l?V????`h?M???????J?????s?J(????U?#?8c?y T?"y7?r?5. O??? ??]?Z?B?!??IuM?m?@?L?Hq&?B??Ni?Ox>??24o?F8#d?8?a?????KD+??a?R???I?-g?"??d?2(D-??.?~???~?%?)????9rL|?8M??/D?V?j???Bu?|??| -M!!???c`WMU???K??????v;0?6??Fg b??n??|??b?7P)kk??Z5t?????j??Xze'?!????V7??%xQ?P?@????'??????/??c%o?s??7?f?ox???lZ?$??^'?C?d??????m???;??|?#?5???)e?W]????d?????P??f2DGD?*?c?>???Za-?????E?^?q@Q??H7*??r??L??~?Q01?`n???f??o^k??u gE?MJ???2[????*y??5k]S?x?????2??t?Q????#?&r??6e???Z??$??O%?\???Al?2????????%?f'?u4?^???11x?Z???VN? ]C??*?61????b&0????????9t^X???P???~i?????P ?f%??~?C?|??w??d?B?.E?GB??>gZ/?D??a?nn?i??}??C9XD%?;??i??D????<.zD?e?7?? mA???HK?Z)????DT?p -??1[(I??D?u???? +??l?aE??I?6????????qEpk??C??>???=tR}?s?xc????P??????Tf??? ???? -V??Tz?f:6?[????????% dJUd??????&??TH.F84t??)?U????U?%s?n9I?q?? A?dnr?/^f |?-?Z}????A`p????????^I/?[??D(tQ????&???RK?4b??pt?Eb?u???]??m?E,??????~\S?Ew?'?"? N????? ??!??n?????????,rn?$j????i?64>j [|? C??????#??>?Z??JgCd?u?1??=w?j ?&xEk????_? x???|?;=?!J??w?,????P?AH??????`a6??9?WWy?? -??wbK??m??p=?I"?()c?B??1?????~???+?]????LP??"HW8?iI????L?O~??!?f:f)???l'$??N?W??V?d?k??_? -???[[??i?$4??2;?F??=??%8?l???x?????yT?G???f?.?d?*r++?t????u6?????X??a/2_???J?l???_?" ? ??? ??i?od6S.???*3e?s????J????????b?jJ????N??YRa7m0/r A?jOi?A???Fv?rVau k??@?AJ?9'?r=2?[s???H??? -Tr?'n?tY[? @ -?"X??P?8?f?b0Q:??L?????r]?{?H,?ZE?y??>???????\^???x??????}?3^????ux???t9?Y?*R????c? ^??`uj?y??}mC?K?v69??A??6??O? ?8^?3?4i?D\??V?>??(?Y8?? ? ?}^??V??'^???J???+?7Hi?z?o%;h?uXd?B?Mxd5??5?A????`?+?J3??g?b??p4?# -???????i?X?W??????T?f?????e?nz?L ???"K Ow??v3?>??Hl??"??????cE?}?o??4??Ex??o??|:Unh<.Sg9]z???T\9&";\?y??5??L???? -a?g?? ??z??@T?H<-S?'??_??*GB????{???:!??r????|z?M??V?I??O?{??Fx????>?{a??8?l??Y ?;???? 9??1?E??????*?????_D4?E?????Yt_L??BJ??x???-M?e/?,? ????n????Ysn??e9Q?????e???????T]???^ ?????^??T?m??}??*? ?jM/?l $S:?~??J????A?????????M?:??3?OPDV???`}????A?A?j(???S???b?p??:E????Vp{|7???????w? -/??M???D,;k??????m?Z?y?? -??G???m?W&?r?9k?y?;?Ms?????????W?z=?@???????l??)???>??????]??? ????N}??}?cK"? ????P??????c???C ??a??????i?'@???`s?????B?@=U?>;?o??9????d?Y??P(??#?????"??-gcv?jD?????O???????j???;f!2r4?)z?????!??v?^g?sw??f`u:????\???C A????>???I:?m???????K??\???(AlC??.~?/v`"??$?M?t??????D???w@???%q0lIsh?S4?$bl??O+???9??g?F*???xK??57??i???????-I?0Zi?D?`?r?`W??? -]?x?w????????Tg?!?ut ??G?8+ -1%M7???d? ??CB??????3k????i??/?g??R???Hq?/???B?`??????8??@??%]?BL??"ZW?H*????1? L???@b??r?unR?A?7???'?t????2O6?x?I=????@`G?????_?d???n?_??e.?"*?>??=_~?\4?l?-?????3?P?$??+7??) ????N??*q??????B??LqU??gWi?U ?I" i??e?t?GTl?rIK?`77??_2g$P?hl\??0X.:???"ySbC~d????????w?u???Ks+?B>H|?/Pp?????@????Y"???fd2?? 7?"????4R?_????w;W?;E???Zd???g!?????(?%??-???c~ -#c}?2???%"???3?f??B??yO)?????.>e??r?\t???`?? -??M?%w$?W~?cg?$??aU??b? ??n?K1??PC5????WB)-p8??O?8X??k?/?w$?tX??8?C??2dt6R+?(??oe?~?????=?????ut;m??fK?^Bv?????dC?????4?BG??_{fs?? m?wO????^aI??????`?? -???+?"6DXO????"?M4? \???qvf@?YX??6?CB??dY???:??q??k????*??? ^@??_???+ -??????MK1????b???4???f??E?i?f?m8?eD??I=??2~PT?&?`)G?>????????)?1G\I??o? ??9?1 at r% l???R?m -?5M:?)^??&n??;h???J???????5? -b???+0?i?n?yX??^]?3??a?I??Mn?G???[??d ?|-6?/??H|?????}?a?}z?E?3? 0G???5={?Y??d?\?~??Y?s??Zk?? +V?jE??by???????D?????']'iA??BZ???]???ro???}?r>r?B???S#??.?%???~}_!? +??Rs?n?\?I!??yY?l??e?d?`j?hGF??????D ???P??%qG?7v'???$B?44}?4??C?v +?? ?s??D?Z-?????2?????`??#w[ ?f{,?f8?]?z???8? _Wz]?LOu*????)???j??????????c??o,?DK??k?AW?W_jm??;RE{??f??}??????{}gO}S?W\??j-?O'????0m?????T4!?*>{?s????k?}?K???4??)?????2????8:??0+wMk??/???x???M?[?I????aa^???1=?{??Q?a-?/??????&%[?0InP)F@????k??R ?&????????O?rK#??{?}?????^t?+Br?P9J?\??$?%?????.??d????=?P3???kZ?7??v?vi |V???B??w???<???????M?*h???$????6????????\`7??qY??Lr at c$/1???tw?w?*??(p?p???y?8?}+E???.1? X??O?m?#?;f?i?F?5?)u??S d??2???\?Gf_s?J 4?4?????????:??F?j????{4Q?+ Q?=GX5`???????oE???U???D??;??p??J?????f??t+??/??3???? iL??;h???U??'\?x???????8??"??+???f?z????? +e??????(?_?Q?? +F??n?c??????/%?y%?p???^S?7[`]p8??Y??:??4????*I?!8????=??],??]????A[?#?????~NJ?`?9B???o?????x.a3b?8?7?4???????{??M??^???"'?q@ T`?N?|??3????F?z?????s???}???????4%G?\??N?? +:'??'<7?=???(R??5??w? +???7?,L?????#??????I??????*???863??-???^s?????9?J?&?????????? +t?2d?O*W?D$? 2??p?i ?i ??!?????}??R?T??f??1?^??"@???????j(B%??9?y???????w?8??^???lZ??c???kx9]?R???S?~??nU??@?lu?)?k! ;?-'??t*!r????p?K?@?}????????2???q????a?5?D?????K?]XZAj????7?2????x??#r??&B2?G??+??Q|6??P?tK)? ???Vw3??s?????k??h?6??Br?I?$%N;\?Oq?#;??^??K??????C?V?????q??T??9?6B%????C\.2???4???I/7O?? ??r?o$??_ ???(A?????/?4d?e?*?,4???qS?^nv???]@L&%???Nu>?V??K|???/ +??$^{?d?? ???_??ZC???????O???;???t?8?LJ?jr ???lP?c????E?B?idM??f?&??K?0f;?9?}?) x??+?????YGX$??g??? ?\???k??/C +5?~?G???????7d?wPZ??LL?e{?s??=??=J3?????=??>x????FbR???=?l??dY? ????m?Vn?,?_ ???Y????\??F1?Va??a;?&?u??C==Y?/Zr%??]?BX???IX???$<?W1????In????uIh?n[rN?~U?Q????@????L?>{?S????"'??????0?Ie?? c?<.?g9????*???????A 8????t??a?.??Zn??'l?R?(??? I9Y??#'y??h?R?D??? +2????u?O?????? ???????[?s ?G~??????u?3??3 +??b?S~U"+?ic??? ??H?V?????????7a=Bd=???%??Xr0r??'??????gLdy)?!1????f???????????.q~ +??a3?????? 1?N0?T??/???-Uc??i??e=U~d:?????3??.?|?? ??r??Nm?/K?J???c???J?^?9%?l?y?????u??H?? +?Y????Tv\v?H?D??m?nY??I????]????U??x?v????D????+?n&?M?\L)O????7??y???ZK???!r?*AE???]?^c??S%?r?? sx??0Q??$d???e???G?????!?1?w\?~a???}?*??7?????WO?@-SX??k?%rK????j??.?E?Q{|??X?f????,K}?2|??????c??j?O??D?b???N*?0???G??fZ?*?%?}??? +?????-???B;9c??????9g??' +?~'???7u> ???CM????E??%??mJF? Gu`?????e??_????O$?I? ???6??!???@I?o?6???B???Pq??\p?H??????YH? ??@i??a?L??GQ?.4?m?/a9????&??9?/??\?f?q?C??u]?t????(??;?p ??Y???"??Z?/x}O?~?{{?W?Y-???- |?????a??Nb??N?? +kq)wR?aP???????J 9??UJ|?4?)????+[9????????"??~????????????7;]??gNf?????t ??.??4y,????I??d?g?z??qu???? +:5??J?]???S7????Z????????xm(???U????.?????`??2?lZ??c?HFD?BS???IO???U2n??A,J??U?????sM??????:??2iQM?JRK??]????)l??]?4S?????9]??xp]??;^ 6r????u^%????h:?v(????Yt???iW?  ?@y?c+???F?{7 ??V?M????L???X? ?^q???X?g- ??^?3+???{a?????0?i-9?.?W?????]OSJ???y?&? ??'_[n?,?????O??}Dl??J???K??????3g??b??pQ)?E???????? +CQh?H????*????B_??G??????????c?`?}???kGG_X?? +??X?14?B?]-p?v?????????.??+y +4?|?????oz;4?]????????K`????W +???3P??S?F?w??????a(?hAv??F ??F|}???%??xn??X?J+??`??p??1c?'??k??`?k{?????C?@n?X??o?x%|?K?8x?????9r??g/??OfBrI}|=????HQ?k???????E??dn5'?}?}?KK2I ??,\??p`2????? ??????????&y????[9?H?????s??)?_I?T???z7?j?g.?????0?8?qi?\???????m?j??????QE?????9).?h????93?? +??????z?`}7??B????????)w?X!,?2II +???]g+4??[????@?????}?`??U??~)R? JhO|???u?n??,???tKW%J??q??a?[*'?E?iE??W?????-1???O??U??-lg?????I?????N4????-/??f?l4?:8"???????/?>??Y???fT\MY?.1?F?????L?N? o +?!ztt?(????=?Z?]????P?}3???_????????@?;?9???6T??iJ +??n???x[ +?K??????M{?h?P_?f?a?=?\ ??CJ?????ZE'???????!#?hB????w?o?!? ??????'#'?R?"?? ?\?!????????.?a'W????U1`?Vb?wg?W???????1ma?????IB???-_?W"a????7 ??????r&\A5?}??D???v??:?/?????m]3?w%??V??????56?l??+n{?l??1???*???eD,+?B?#???????+t??`?U-^}?S??&??? ??????"%?? ?:?Y??0?}??1>????;zk}Or???;??@x?Ng???U? U?u$??yg?OH? +<`5??W??!?F ??S? y#?????????h{(???'HU?wu4?????6??^?u?-@/???O???}?? +f?O_m=?CE????!t[????B7?z??q?h???P"La6?4?s>?0Z??S??MZ?M??M^Y??q-xV????Rv??????F?????#???A????,>2??fn?3@??????\?????????0??rQ?fI??d??3???@6?r??j??-l?7?F?,??r??('KU? E?$??rz?&??"? + ???????s+????nEq)???????,????o_??'???.KaD.?\????5?|?h?/yLf???EC??I? }???? ???D??~??S????#?aw"????dzR????nn??>??????????T +???BW?l??r?Sy????nAtl??p?%K?>???w???? +??+q??n? ??`rh??~?+?W%8l?l%??????bS=+?F????^??m?{?9?v??>j???|????4?V? =????????(??('??7hK???(?CT???ebOjZ +"???P?????????????? e??+??o?6h?k????l??7????[?>24?>??V}I???-?????' +??m?F?c?^p?_J6>???????c????C?4??R'@%G??g?@e!(?Ko??? ???J?FU+??B??y?H?,???c??6???=?T??????W? ?: +?/UD?!xe,?w4???Kz?$R??b?K.3)-4R?a??)????e#??????????????N?O?2?E???v???V?{~B?wc???~?n.?'-???3?=?/aVL??),?\t??_m???}?M?4? ???*c??!?p?b2? b??~Y??????n??1r?t?-~{???t?Od%?????????MP???.?q???4Z5E?!?Ca?*7?4 ??C? +??y?H????? ???????* S}? ?????{??-?p???KF????S?e?fQ8J???xA:????????X??b}?Fu????-?Z???m????=d?u?q?N-}V>??/??b#??8w?j???BC?$E?d/????????????1?wf??`,???U???oq????9Xy???Pb?Ik??????#H6"???y"z]G?+? R?????/??'?]f???F?ZK)?M?}?)???=d?sK????H??#InFFK????X?s?Y/?x?>??][? ??Un>!?Z.?Dk?C??Y2n???-??G?f??:"C?'?5?| `? ? Fp*D??!? ??Y????a?w?Yn\ ?#a8?5?n?? wS???0?'??_;|?X???01z???w??u???& '?%|RA???5??sH>?1??;=.?????d~???z +?$???8 ;]-s9+N^*?f?1?"?TC9?1????(>?3c?@???i'??? es?? +??\???]k?eK???n??b?? +&@???u??g???q~????j?Z#'??#$???F????FN???w??lm???*?m?????|a???o ?vn>??????f???_m??@Y|Xug?\?? ?7???N!????j??q????yt????$;f??j*H?gRPs???2 T?Do ?H??j?zF Aa^=??a????%??*z ?yI? ???!? ??????nIw4?Gv.Nbv?\?Z~??u??0KY0?xU??Y#?????h? J4?@?\n[??5??W????,&?R?? +??:%???I???fGm??u3?b?_PJ????????kp????7??^??m0????g?YZ \ No newline at end of file Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-09 03:14:34 UTC (rev 248) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-09 15:16:40 UTC (rev 249) @@ -31,32 +31,33 @@ \code{demos} is a function to run other examples that are provided as \code{\link{demo}s}. \code{\link{demo}} is called with settings to not echo the source code and to not ask before making each plot. The demo(s) to run is/are specified by \code{which}; the default is to run them in the order of the list below. +Demos that are displayed on the CHNOSZ website (\url{http://chnosz.net/demos}) are indicated with an asterisk. See the comments in the source code for more information about each demo. \tabular{ll}{ \code{sources} \tab cross-check the reference list with the thermodynamic database \cr \code{protein.equil} \tab chemical activities of two proteins in metastable equilibrium (Dick and Shock, 2011) \cr - \code{affinity} \tab affinities of metabolic reactions and amino acid synthesis \cr - \code{NaCl} \tab equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr - \code{density} \tab density of \H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr - \code{ORP} \tab temperature dependence of oxidation-reduction potential for redox standards \cr - \code{revisit} \tab coefficient of variation of metastable equilibrium activities of proteins \cr - \code{findit} \tab minimize the standard deviation of logarithms of activities of sulfur species \cr + \code{affinity} \tab affinities of metabolic reactions and amino acid synthesis (Amend and Shock, 1998, 2001) \cr + \code{NaCl} \tab * equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr + \code{density} \tab * density of \H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr + \code{ORP} \tab * temperature dependence of oxidation-reduction potential for redox standards \cr + \code{revisit} \tab * coefficient of variation of metastable equilibrium activities of proteins \cr + \code{findit} \tab * minimize the standard deviation of logarithms of activities of sulfur species \cr \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \cr - \code{buffer} \tab minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr + \code{buffer} \tab * minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr \code{protbuff} \tab chemical activities buffered by thiol peroxidases or sigma factors \cr - \code{yeastgfp} \tab subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams (Dick, 2009) \cr - \code{mosaic} \tab Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr - \code{copper} \tab another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr - \code{solubility} \tab solubility of calcite (cf. Manning et al., 2013) or \CO2 (cf. Stumm and Morgan, 1996) \cr - \code{wjd} \tab Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast \cr - \code{dehydration} \tab log K of dehydration reactions; SVG file contains tooltips and links \cr - \code{bugstab} \tab formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr - \code{Shh} \tab affinities of transcription factors relative to Sonic hedgehog \cr - \code{activity_ratios} \tab mineral stability plots with activity ratios on the axes \cr - \code{adenine} \tab HKF parameters regressed from heat capacity and volume of aqueous adenine (Lowe et al., 2017) \cr - \code{adenine} \tab Deep Earth Water (DEW) model for high pressures (Sverjensky et al., 2014a and 2014b) \cr - \code{lambda} \tab Effects of lambda transtion on thermodynamic properties of quartz (Berman, 1988) \cr + \code{yeastgfp} \tab * subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams (Dick, 2009) \cr + \code{mosaic} \tab * Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr + \code{copper} \tab * another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr + \code{solubility} \tab * solubility of calcite (cf. Manning et al., 2013) or \CO2 (cf. Stumm and Morgan, 1996) \cr + \code{wjd} \tab * Gibbs energy minimization: prebiological atmospheres (Dayhoff et al., 1964) and cell periphery of yeast \cr + \code{dehydration} \tab * log K of dehydration reactions; SVG file contains tooltips and links \cr + \code{bugstab} \tab * formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr + \code{Shh} \tab * affinities of transcription factors relative to Sonic hedgehog (Dick, 2015) \cr + \code{activity_ratios} \tab * mineral stability plots with activity ratios on the axes \cr + \code{adenine} \tab * HKF parameters regressed from heat capacity and volume of aqueous adenine (Lowe et al., 2017) \cr + \code{DEW} \tab * Deep Earth Water (DEW) model for high pressures (Sverjensky et al., 2014a and 2014b) \cr + \code{lambda} \tab * Effects of lambda transition on thermodynamic properties of quartz (Berman, 1988) \cr } } @@ -64,12 +65,20 @@ \references{ Aksu, S. and Doyle, F. M. (2001) Electrochemistry of copper in aqueous glycine solutions. \emph{J. Electrochem. Soc.} \bold{148}, B51--B57. \url{https://doi.org/10.1149/1.1344532} +Amend, J. P. and Shock, E. L. (1998) Energetics of amino acid synthesis in hydrothermal ecosystems. \emph{Science} \bold{281}, 1659--1662. \url{https://doi.org/10.1126/science.281.5383.1659} + [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 249 From noreply at r-forge.r-project.org Tue Oct 10 17:22:41 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 10 Oct 2017 17:22:41 +0200 (CEST) Subject: [CHNOSZ-commits] r250 - in pkg/CHNOSZ: . R demo inst man Message-ID: <20171010152242.0024E18860E@r-forge.r-project.org> Author: jedick Date: 2017-10-10 17:22:41 +0200 (Tue, 10 Oct 2017) New Revision: 250 Added: pkg/CHNOSZ/demo/TCA.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/util.plot.Rd Log: add TCA.R demo (citric acid cycle; Canovas and Shock, 2016) Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-10 15:22:41 UTC (rev 250) @@ -1,6 +1,6 @@ -Date: 2017-10-09 +Date: 2017-10-10 Package: CHNOSZ -Version: 1.1.0-48 +Version: 1.1.0-49 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/R/diagram.R 2017-10-10 15:22:41 UTC (rev 250) @@ -72,8 +72,10 @@ }) plotvar <- eout$property # we change 'A' to 'A/2.303RT' so the axis label is made correctly - if(plotvar=="A") plotvar <- "A/2.303RT" - message(paste("diagram: plotting", plotvar, "from affinity(), divided by balancing coefficients")) + if(plotvar=="A") { + plotvar <- "A/2.303RT" + message("diagram: plotting A/2.303RT / n.balance (maximum affinity method for 2-D diagrams)") + } else message(paste("diagram: plotting", plotvar, " / n.balance")) } ## number of dimensions (T, P or chemical potentials that are varied) @@ -498,7 +500,7 @@ if(is.null(xlab)) xlab <- axis.label(eout$vars[1], basis=eout$basis) if(is.null(ylab)) ylab <- axis.label(eout$vars[2], basis=eout$basis) if(tplot) thermo.plot.new(xlim=xlim, ylim=ylim, xlab=xlab, ylab=ylab, - cex=cex, cex.axis=cex.axis, mar=mar, yline=yline, side=side) + cex=cex, cex.axis=cex.axis, mar=mar, yline=yline, side=side, ...) else plot(0, 0, type="n", xlim=xlim, ylim=ylim, xlab=xlab, ylab=ylab, ...) # add a title if(!is.null(main)) title(main=main) Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/R/examples.R 2017-10-10 15:22:41 UTC (rev 250) @@ -29,7 +29,7 @@ demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW", "lambda"), to.file=FALSE) { + "adenine", "DEW", "lambda", "TCA"), to.file=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { # say something so the user sees where we are Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/R/util.plot.R 2017-10-10 15:22:41 UTC (rev 250) @@ -165,12 +165,12 @@ return(invisible(list(xpoints=xpoints, y.oxidation=y.oxidation, y.reduction=y.reduction, swapped=swapped))) } -mtitle <- function(main, line=0, ...) { +mtitle <- function(main, line=0, spacing=1, ...) { # make a possibly multi-line plot title # useful for including expressions on multiple lines # 'line' is the margin line of the last (bottom) line of the title - l <- length(main) - for(i in 1:l) mtext(main[i], line=line+l-i, ...) + len <- length(main) + for(i in 1:len) mtext(main[i], line = line + (len - i)*spacing, ...) } # get colors for range of ZC values 20170206 Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/demo/00Index 2017-10-10 15:22:41 UTC (rev 250) @@ -21,3 +21,4 @@ adenine HKF parameters regressed from heat capacity and volume of aqueous adenine DEW Deep Earth Water (DEW) model for high pressures lambda Effects of lambda transtion on thermodynamic properties of quartz +TCA Standard Gibbs energies of steps of the tricarboxylic acid cycle Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-10 15:22:41 UTC (rev 250) @@ -132,7 +132,10 @@ # P = 5.0GPa (50000 bar) # fO2 = QFM - 2 # pH set by jadeite + kyanite + coesite (approximated here as constant) -# dissolved carbon 0.03, 0.2, 1, 4, 20 molal +# output from EQ3 calculations: +# dissolved carbon: 0.03, 0.2, 1, 4, 20 molal +# ionic strength: 0.39, 0.57, 0.88, 1.45, 2.49 +# activity coefficient (log gamma for singly charged species): -0.15, -0.18, -0.22, -0.26, -0.31 T <- seq(600, 1000, 5) Added: pkg/CHNOSZ/demo/TCA.R =================================================================== --- pkg/CHNOSZ/demo/TCA.R (rev 0) +++ pkg/CHNOSZ/demo/TCA.R 2017-10-10 15:22:41 UTC (rev 250) @@ -0,0 +1,95 @@ +# TCA.R 20171010 +# Reproduce Fig. 6 in Canovas and Shock, 2016: +# Plots of the standard partial molal Gibbs energy of reaction for each step in +# the citric acid cycle for temperatures to 500 degrees C and pressures to 5 kbar. + +data(thermo) + +# species in reactions +NADox <- "NAD(ox)-"; NADred <- "NAD(red)-2" +ADP <- "ADP-3"; ATP <- "ATP-4" +species <- list( + c("oxaloacetate-2", "pyruvate", "H2O", NADox, "citrate-3", NADred, "CO2", "H+"), + c("citrate-3", "cis-aconitate-3", "H2O"), + c("cis-aconitate-3", "H2O", "isocitrate-3"), + c("isocitrate-3", NADox, "a-ketoglutarate-2", NADred, "CO2"), + c("a-ketoglutarate-2", ADP, "HPO4-2", NADox, "succinate-2", ATP, NADred, "CO2"), + c("succinate-2", "fumarate-2", "H2"), + c("fumarate-2", "H2O", "malate-2"), + c("malate-2", NADox, "oxaloacetate-2", NADred, "H+"), + c("pyruvate", NADox, ADP, "HPO4-2", "H2O", "CO2", NADred, "H+", ATP, "H2") +) +# reaction coefficients +coeffs <- list( + c(-1, -1, -1, -1, 1, 1, 1, 1), + c(-1, 1, 1), + c(-1, -1, 1), + c(-1, -1, 1, 1, 1), + c(-1, -1, -1, -1, 1, 1, 1, 1), + c(-1, 1, 1), + c(-1, -1, 1), + c(-1, -1, 1, 1, 1), + c(-1, -4, -1, -1, -2, 3, 4, 2, 1, 1) +) +# species names +oxal <- quote(Oxaloacetate^-2) +pyr <- quote(Pyruvate^-"") +h2o <- quote(H[2]*O) +nox <- quote(NAD[ox]^-"") +cit <- quote(Citrate^-3) +nred <- quote(NAD[red]^-2) +co2 <- quote(CO[2*(italic(aq))]) +hplus <- quote(H^+"") +iso <- quote(Isocitrate^-3) +aco <- quote(italic(cis)*"-Aconitate"^-3) +ket <- quote(alpha*"-Ketoglutarate"^-2) +adp <- quote(ADP^-3) +hpo4 <- quote(HPO[4]^-2) +suc <- quote(Succinate^-2) +atp <- quote(ATP^-4) +fum <- quote(Fumarate^-2) +h2 <- quote(H[2*(italic(aq))]) +mal <- quote(Malate^-2) +sublist <- list(oxal=oxal, pyr=pyr, h2o=h2o, nox=nox, cit=cit, nred=nred, + co2=co2, hplus=hplus, aco=aco, iso=iso, ket=ket, adp=adp, + hpo4=hpo4, suc=suc, atp=atp, fum=fum, h2=h2, mal=mal) +# reaction titles +rtitle <- list( + c(substitute(" "*oxal + pyr + h2o + nox == "", sublist), substitute(cit + nred + co2 + hplus, sublist)), + substitute(cit == aco + h2o, sublist), + substitute(aco + h2o == iso*" ", sublist), + c(substitute(iso + nox == "", sublist), substitute(ket + nred + co2*" ", sublist)), + c(substitute(ket + adp + hpo4 + nox == "", sublist), substitute(suc + atp + nred + co2, sublist)), + substitute(suc == fum + h2, sublist), + substitute(fum + h2o == mal, sublist), + c(substitute(mal + nox == " ", sublist), substitute(oxal + nred + hplus * " ", sublist)), + c(substitute(pyr + 4*nox + adp + hpo4 + 2*h2o == " ", sublist), + substitute(3*co2 + 4*nred + 2*hplus + atp + h2 * " ", sublist)) +) +# set up plot +par(mfrow=c(3, 3)) +ylims <- list( + c(-10, 45), c(1, 6), c(-2.5, 7.5), + c(-35, 5), c(-9, 5), c(5, 28), + c(-1.5, 6), c(14, 18), c(20, 80) +) +# loop over reactions +for(i in seq_along(species)) { + thermo.plot.new(xlim=c(0, 500), ylim=ylims[[i]], xlab=axis.label("T"), + ylab=axis.label("DrG0", prefix="k"), mar=c(3.0, 3.5, 3.5, 2.0)) + # loop over isobars + for(P in seq(500, 5000, 500)) { + T <- seq(0, 500, 10) + if(P==500) T <- seq(0, 350, 10) + if(P==5000) T <- seq(100, 500, 10) + # calculate and plot standard Gibbs energy + sout <- subcrt(species[[i]], coeffs[[i]], T=T, P=P)$out + lines(T, sout$G/1000) + } + if(is.list(rtitle[[i]])) mtitle(as.expression(rtitle[[i]]), spacing = 1.6, cex=0.8) + else mtitle(as.expression(rtitle[[i]]), line=0.4, cex=0.8) +} +# make an overall title +opar <- par(xpd=NA) +text(-70, 284, "Citric Acid Cycle, after Canovas and Shock, 2016", font=2, cex=1.5) +par(opar) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/inst/NEWS 2017-10-10 15:22:41 UTC (rev 250) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-48 (2017-10-09) +CHANGES IN CHNOSZ 1.1.0-49 (2017-10-10) --------------------------------------- MAJOR CHANGES: @@ -117,6 +117,9 @@ - Add maxdiff() and expect_maxdiff() for calculating and testing the maximum absolute pairwise difference between two objects. +- Add demo TCA.R for standard Gibbs energies of steps of the + citric acid cycle (Canovas and Shock, 2016). + CLEANUP: - To save space, taxid_names.csv has been trimmed to hold only those Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-10 15:22:41 UTC (rev 250) @@ -18,7 +18,7 @@ "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW", "lambda"), + "adenine", "DEW", "lambda", "TCA"), to.file=FALSE) } @@ -58,6 +58,7 @@ \code{adenine} \tab * HKF parameters regressed from heat capacity and volume of aqueous adenine (Lowe et al., 2017) \cr \code{DEW} \tab * Deep Earth Water (DEW) model for high pressures (Sverjensky et al., 2014a and 2014b) \cr \code{lambda} \tab * Effects of lambda transition on thermodynamic properties of quartz (Berman, 1988) \cr + \code{TCA} \tab * Standard Gibbs energies of the tricarboxylic (citric) acid cycle (Canovas and Shock, 2016) \cr } } @@ -71,6 +72,8 @@ Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O?K{\s2}O?CaO?MgO?FeO?Fe{\s2}O{\s3}?Al{\s2}O{\s3}?SiO{\s2}?TiO{\s2}?H{\s2}O?CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445} +Canovas, P. A., III and Shock, E. L. (2016) Geobiochemistry of metabolism: Standard state thermodynamic properties of the citric acid cycle. \emph{Geochim. Cosmochim. Acta} \bold{195}, 293--322. \url{https://doi.org/10.1016/j.gca.2016.08.028} + Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V. (1964) Thermodynamic Equilibria In Prebiological Atmospheres. \emph{Science} \bold{146}, 1461--1464. \url{https://doi.org/10.1126/science.146.3650.1461} Dick, J. M. (2009) Calculation of the relative metastabilities of proteins in subcellular compartments of \emph{Saccharomyces cerevisiae}. \emph{BMC Syst. Biol.} \bold{3}:75. \url{https://doi.org/10.1186/1752-0509-3-75} Modified: pkg/CHNOSZ/man/util.plot.Rd =================================================================== --- pkg/CHNOSZ/man/util.plot.Rd 2017-10-09 15:16:40 UTC (rev 249) +++ pkg/CHNOSZ/man/util.plot.Rd 2017-10-10 15:22:41 UTC (rev 250) @@ -27,7 +27,7 @@ italic = FALSE, ...) water.lines(eout, which = c("oxidation","reduction"), lty = 2, lwd=1, col = par("fg"), plot.it = TRUE) - mtitle(main, line=0, ...) + mtitle(main, line=0, spacing=1, ...) ZC.col(z) } @@ -60,6 +60,7 @@ \item{plot.it}{logical, plot the lines?} \item{main}{character, text for plot title} \item{line}{numeric, margin line to place title} + \item{spacing}{numeric, spacing between multiple lines} \item{z}{numeric, set of values} } From noreply at r-forge.r-project.org Wed Oct 11 17:40:05 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 11 Oct 2017 17:40:05 +0200 (CEST) Subject: [CHNOSZ-commits] r251 - in pkg/CHNOSZ: . R inst man tests/testthat vignettes Message-ID: <20171011154006.1B5B1187FFB@r-forge.r-project.org> Author: jedick Date: 2017-10-11 17:40:05 +0200 (Wed, 11 Oct 2017) New Revision: 251 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/water.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/tests/testthat/test-nonideal.R pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: water(): add A_DH and B_DH Debye-Huckel coefficients Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-11 15:40:05 UTC (rev 251) @@ -1,6 +1,6 @@ Date: 2017-10-10 Package: CHNOSZ -Version: 1.1.0-49 +Version: 1.1.0-50 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/water.R =================================================================== --- pkg/CHNOSZ/R/water.R 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/R/water.R 2017-10-11 15:40:05 UTC (rev 251) @@ -20,10 +20,10 @@ if(length(P) < length(T)) P <- rep(P, length.out = length(T)) else if(length(T) < length(P)) T <- rep(T, length.out = length(P)) } - # turn 273.15 K to 273.16 K (needed for water.SUPCRT92 at Psat) - T[T == 273.15] <- 273.16 wopt <- get("thermo")$opt$water if(grepl("SUPCRT", wopt)) { + # change 273.15 K to 273.16 K (needed for water.SUPCRT92 at Psat) + if(identical(P, "Psat")) T[T == 273.15] <- 273.16 # get properties using SUPCRT92 w.out <- water.SUPCRT92(property, T, P) } @@ -49,7 +49,8 @@ "Speed", "alpha", "beta", "epsilon", "visc", "tcond", "surten", "tdiff", "Prndtl", "visck", "albe", "ZBorn", "YBorn", "QBorn", "daldT", "XBorn", - "V", "rho", "Psat", "E", "kT") + "V", "rho", "Psat", "E", "kT", + "A_DH", "B_DH") if(is.null(property)) return(available_properties) # check for availability of properties iprop <- match(property, available_properties) @@ -121,7 +122,12 @@ Psat=P.out E <- V*w.out$alpha kT <- V*w.out$beta - w.out <- cbind(w.out, data.frame(V=V, rho=rho, Psat=Psat, E=E, kT=kT)) + # A and B parameters in Debye-Huckel equation: + # Helgeson (1969) doi:10.2475/ajs.267.7.729 + # Manning (2013) doi:10.2138/rmg.2013.76.5 + A_DH <- 1.8246e6 * rho.out^0.5 / (w.out$epsilon * T)^1.5 + B_DH <- 50.29e8 * rho.out^0.5 / (w.out$epsilon * T)^0.5 + w.out <- cbind(w.out, data.frame(V=V, rho=rho, Psat=Psat, E=E, kT=kT, A_DH=A_DH, B_DH=B_DH)) } # tell the user about any problems if(any(err.out==1)) { @@ -143,7 +149,8 @@ available_properties <- c("A", "G", "S", "U", "H", "Cv", "Cp", "Speed", "epsilon", "YBorn", "QBorn", "XBorn", "NBorn", "UBorn", - "V", "rho", "Psat", "de.dT", "de.dP", "pressure") + "V", "rho", "Psat", "de.dT", "de.dP", "pressure", + "A_DH", "B_DH") if(is.null(property)) return(available_properties) # to get the properties of water via IAPWS-95 message(paste("water.IAPWS95: calculating", length(T), "values for"), appendLF=FALSE) @@ -292,6 +299,13 @@ my.rho <- rho.IAPWS95(T, P, get("thermo")$opt$IAPWS.sat) rho <- function() my.rho } + # get epsilon and A_DH, B_DH (so we calculate epsilon only once) + if(any(property %in% c("epsilon", "A_DH", "B_DH"))) { + my.epsilon <- epsilon() + epsilon <- function() my.epsilon + A_DH <- function() 1.8246e6 * (my.rho/1000)^0.5 / (my.epsilon * T)^1.5 + B_DH <- function() 50.29e8 * (my.rho/1000)^0.5 / (my.epsilon * T)^0.5 + } for(i in 1:length(property)) { if(property[i] %in% c("E", "kT", "alpha", "daldT", "beta")) { # E and kT aren't here yet... set them to NA @@ -305,7 +319,7 @@ w.out[, i] <- wnew } message("") - # use uppercase property names (including properties available in SUPCRT that might be NA here) + # include properties available in SUPCRT that might be NA here wprop <- unique(c(water.SUPCRT92(), available_properties)) iprop <- match(property, wprop) property[!is.na(iprop)] <- wprop[na.omit(iprop)] @@ -315,7 +329,7 @@ # get water properties from DEW model for use by subcrt() 20170925 water.DEW <- function(property = NULL, T = 373.15, P = 1000) { - available_properties <- c("G", "epsilon", "QBorn", "V", "rho", "beta") + available_properties <- c("G", "epsilon", "QBorn", "V", "rho", "beta", "A_DH", "B_DH") if(is.null(property)) return(available_properties) # we can't use Psat here if(identical(P, "Psat")) stop("Psat isn't supported in this implementation of the DEW model. Try setting P to at least 1000 bar.") @@ -331,16 +345,19 @@ out <- matrix(NA, ncol=length(property), nrow=ncond) out <- as.data.frame(out) colnames(out) <- property - # calculate rho if it's needed for any other properties - if(any(c("rho", "V", "QBorn", "epsilon", "beta") %in% property)) rho <- calculateDensity(pressure, temperature) + # calculate rho and epsilon if they're needed for any other properties + if(any(c("rho", "V", "QBorn", "epsilon", "beta", "A_DH", "B_DH") %in% property)) rho <- calculateDensity(pressure, temperature) + if(any(c("epsilon", "A_DH", "B_DH") %in% property)) epsilon <- calculateEpsilon(rho, temperature) # fill in columns with values if("rho" %in% property) out$rho <- rho*1000 # use kg/m^3 (like SUPCRT) if("V" %in% property) out$V <- 18.01528/rho if("G" %in% property) out$G <- calculateGibbsOfWater(pressure, temperature) if("QBorn" %in% property) out$QBorn <- calculateQ(rho, temperature) - if("epsilon" %in% property) out$epsilon <- calculateEpsilon(rho, temperature) + if("epsilon" %in% property) out$epsilon <- epsilon # divide drhodP by rho to get units of bar^-1 if("beta" %in% property) out$beta <- calculate_drhodP(rho, temperature) / rho + if("A_DH" %in% property) out$A_DH <- 1.8246e6 * rho^0.5 / (epsilon * T)^1.5 + if("B_DH" %in% property) out$B_DH <- 50.29e8 * rho^0.5 / (epsilon * T)^0.5 # use SUPCRT-calculated values below 100 degC and/or below 1000 bar ilow <- T < 373.15 | P < 1000 if(any(ilow)) { Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/inst/NEWS 2017-10-11 15:40:05 UTC (rev 251) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-49 (2017-10-10) +CHANGES IN CHNOSZ 1.1.0-50 (2017-10-11) --------------------------------------- MAJOR CHANGES: @@ -35,6 +35,10 @@ "percent carbon" plots for systems where the species have different carbon numbers. +- All three water options (SUPCRT92, IAPWS95, DEW) can be used to + calculate 'A_DH' and 'B_DH', i.e. A and B coefficients in the B-dot + (extended Debye-Huckel) equation of Helgeson, 1969. + - For minerals with phase transitions (states 'cr2' 'cr3' etc.) in thermo$obigt (i.e. the Helgeson minerals), it is now possible to use the minerals in basis(), species(), affinity() with proper accounting Modified: pkg/CHNOSZ/man/water.Rd =================================================================== --- pkg/CHNOSZ/man/water.Rd 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/man/water.Rd 2017-10-11 15:40:05 UTC (rev 251) @@ -83,6 +83,8 @@ \code{de.dP} \tab Pressure derivative \tab bar\eqn{^{-1}}{^-1} \tab * \tab NA \tab NA \cr \tab of dielectric constant \tab \tab \tab \tab \cr \code{P} \tab Pressure \tab bar \tab * \tab NA \tab NA \cr + \code{A_DH} \tab A Debye-Huckel parameter \tab kg\eqn{^{0.5}}{0.5} mol\eqn{^{-0.5}}{-0.5} \tab * \tab * \tab * \cr + \code{B_DH} \tab B Debye-Huckel parameter \tab kg\eqn{^{0.5}}{0.5} mol\eqn{^{-0.5}}{-0.5} cm\eqn{^{-1}}{-1} \tab * \tab * \tab * \cr } Call \code{water.SUPCRT92}, \code{water.IAPWS95}, or \code{water.DEW} with no arguments to list the available properties. @@ -104,6 +106,8 @@ The function also contains routines for calculating the Born functions as numerical derivatives of the static dielectric constant (from \code{water.AW90}). For compatibility with geochemical modeling conventions, the values of Gibbs energy, enthalpy and entropy output by \code{IAPWS95} are converted by \code{water.IAPWS95} to the triple point reference state adopted in \code{SUPCRT92} (Johnson and Norton, 1991; Helgeson and Kirkham, 1974). \code{water.IAPWS95} also accepts setting \code{P} to \samp{Psat}, with the saturation pressure calculated from \code{\link{WP02.auxiliary}}; by default the returned properties are for the liquid, but this can be changed to the vapor in \code{\link{thermo}$opt$IAPWS.sat}. + +\code{A_DH} and \code{B_DH} are solvent parameters in the \dQuote{B-dot} (extended Debye-Huckel) equation (Helgeson, 1969; Manning, 2013). } @@ -112,7 +116,7 @@ } \seealso{ -Equations for thermodynamic properties of species other than water are coded in \code{\link{hkf}} and \code{\link{cgl}}. +For calculating properties of reactions, \code{\link{subcrt}} coordinates the calculation of properties among \code{water} and \code{\link{hkf}} and \code{\link{cgl}} for other species. } \examples{\dontshow{data(thermo)} @@ -158,12 +162,16 @@ Helgeson, H. C. and Kirkham, D. H. (1974) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. I. Summary of the thermodynamic/electrostatic properties of the solvent. \emph{Am. J. Sci.} \bold{274}, 1089--1098. \url{http://www.ajsonline.org/cgi/content/abstract/274/10/1089} +Helgeson, H. C. (1969) Thermodynamics of hydrothermal systems at elevated temperatures and pressures. \emph{Am. J. Sci.} \bold{267}, 729--804. \url{https://doi.org/10.2475/ajs.267.7.729} + Johnson, J. W. and Norton, D. (1991) Critical phenomena in hydrothermal systems: state, thermodynamic, electrostatic, and transport properties of H\eqn{_2}{2}O in the critical region. \emph{Am. J. Sci.} \bold{291}, 541--648. \url{http://www.ajsonline.org/cgi/content/abstract/291/6/541} Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000\eqn{^{\circ}}{?}C. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{https://doi.org/10.1016/0098-3004(92)90029-Q} Levelt-Sengers, J. M. H., Kamgarparsi, B., Balfour, F. W. and Sengers, J. V. (1983) Thermodynamic properties of steam in the critical region. \emph{J. Phys. Chem. Ref. Data} \bold{12}, 1--28. \url{https://doi.org/10.1063/1.555676} +Manning, C. E. (2013) Thermodynamic modeling of fluid-rock interaction at mid-crustal to upper-mantle conditions \emph{Rev. Mineral. Geochem.} \bold{76}, 135--164. \url{https://doi.org/10.2138/rmg.2013.76.5} + Sverjensky, D. A., Harrison, B. and Azzolini, D. (2014) Water in the deep Earth: The dielectric constant and the solubilities of quartz and corundum to 60 kb and 1,200 \degC. \emph{Geochim. Cosmochim. Acta} \bold{129}, 125--145. \url{https://doi.org/10.1016/j.gca.2013.12.019} Wagner, W. and Pruss, A. (2002) The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. \emph{J. Phys. Chem. Ref. Data} \bold{31}, 387--535. \url{https://doi.org/10.1063/1.1461829} Modified: pkg/CHNOSZ/tests/testthat/test-nonideal.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-nonideal.R 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/tests/testthat/test-nonideal.R 2017-10-11 15:40:05 UTC (rev 251) @@ -1,7 +1,49 @@ context("nonideal") +# 20161219 test_that("loggam and logK values are consistent", { rxn1 <- subcrt(c("anhydrite", "Ca+2", "SO4-2"), c(-1, 1, 1), P=1, T=25, I=0) rxn2 <- subcrt(c("anhydrite", "Ca+2", "SO4-2"), c(-1, 1, 1), P=1, T=25, I=0.7) expect_equal(rxn1$out$logK, rxn2$out$loggam + rxn2$out$logK) }) + +# 20171011 +test_that("A and B parameters are calculated correctly", { + ## Psat + # values from Helgeson, 1967 "Solution chemistry and metamorphism" + # (chapter in http://www.worldcat.org/oclc/152725534) + T <- c(25, 50, 100, 200, 300, 350) + A <- c(0.5095, 0.5354, 0.6019, 0.8127, 1.2979, 1.9936) + B <- c(0.3284, 0.3329, 0.3425, 0.3659, 0.4010, 0.4300) + SUP <- water.SUPCRT92(c("A_DH", "B_DH"), T=convert(T, "K"), P="Psat") + IAP <- water.IAPWS95(c("A_DH", "B_DH"), T=convert(T, "K"), P="Psat") + expect_maxdiff(SUP$A_DH, A, 0.18) + expect_maxdiff(IAP$A_DH, A, 0.11) + expect_maxdiff(SUP$B_DH / 1e8, B, 0.012) + expect_maxdiff(IAP$B_DH / 1e8, B, 0.008) + + # values digitized from Fig. 10 of Manning et al., 2013 + # doi: 10.2138/rmg.2013.75.5 + ## 5 kbar + T5 <- c(25, seq(100, 1000, 100)) + A5 <- c(0.441, 0.49, 0.583, 0.685, 0.817, 0.983, 1.164, 1.409, 1.673, 1.938, 2.187) + B5 <- c(0.328, 0.336, 0.350, 0.363, 0.377, 0.391, 0.405, 0.421, 0.434, 0.445, 0.453) + SUP5 <- water.SUPCRT92(c("A_DH", "B_DH"), T=convert(T5, "K"), P=rep(5000, 11)) + IAP5 <- water.IAPWS95(c("A_DH", "B_DH"), T=convert(T5, "K"), P=rep(5000, 11)) + DEW5 <- water.DEW(c("A_DH", "B_DH"), T=convert(T5, "K"), P=rep(5000, 11)) + # DEW is the winner here + expect_maxdiff(SUP5$A_DH, A5, 0.47) + expect_maxdiff(IAP5$A_DH, A5, 0.26) + expect_maxdiff(DEW5$A_DH, A5, 0.14) + expect_maxdiff(SUP5$B_DH / 1e8, B5, 0.036) + expect_maxdiff(IAP5$B_DH / 1e8, B5, 0.021) + expect_maxdiff(DEW5$B_DH / 1e8, B5, 0.013) + + ## 30 kbar + T30 <- seq(700, 1000, 100) + A30 <- c(0.625, 0.703, 0.766, 0.815) + B30 <- c(0.386, 0.400, 0.409, 0.416) + DEW30 <- water.DEW(c("A_DH", "B_DH"), T=convert(T30, "K"), P=rep(30000, 4)) + expect_maxdiff(DEW30$A_DH, A30, 0.06) + expect_maxdiff(DEW30$B_DH / 1e8, B30, 0.024) +}) Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-11 15:40:05 UTC (rev 251) @@ -125,7 +125,7 @@ # Recent additions (late 2017) -* Mineral data using the [Berman (1988)]() equations are listed under **Solids** / **Berman**. +* Mineral data using the [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) equations are listed under **Solids** / **Berman**. * Aqueous species data intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under **Optional Data** / **DEW**. Modified: pkg/CHNOSZ/vignettes/obigt.bib =================================================================== --- pkg/CHNOSZ/vignettes/obigt.bib 2017-10-10 15:22:41 UTC (rev 250) +++ pkg/CHNOSZ/vignettes/obigt.bib 2017-10-11 15:40:05 UTC (rev 251) @@ -36,15 +36,15 @@ } @Article{AS01, - author = {Amend, Jan P. and Shock, Everett L.}, - journal = {FEMS Microbiology Reviews}, - title = {{E}nergetics of overall metabolic reactions of thermophilic and hyperthermophilic {A}rchaea and {B}acteria}, - year = {2001}, - volume = {25}, - number = {2}, - pages = {175--243}, - doi = {10.1111/j.1574-6976.2001.tb00576.x}, - issn = {0168-6445}, + author = {Amend, Jan P. and Shock, Everett L.}, + journal = {FEMS Microbiology Reviews}, + title = {{E}nergetics of overall metabolic reactions of thermophilic and hyperthermophilic {A}rchaea and {B}acteria}, + year = {2001}, + volume = {25}, + number = {2}, + pages = {175--243}, + doi = {10.1111/j.1574-6976.2001.tb00576.x}, + issn = {0168-6445}, } @Article{BH83, @@ -164,25 +164,25 @@ } @Article{HDNB78, - author = {Helgeson, Harold C. and Delany, Joan M. and Nesbitt, H. Wayne and Bird, Dennis K.}, - journal = {American Journal of Science}, - title = {{S}ummary and critique of the thermodynamic properties of rock-forming minerals}, - year = {1978}, - volume = {278A}, - pages = {1--229}, - url = {http://www.worldcat.org/oclc/13594862}, + author = {Helgeson, Harold C. and Delany, Joan M. and Nesbitt, H. Wayne and Bird, Dennis K.}, + journal = {American Journal of Science}, + title = {{S}ummary and critique of the thermodynamic properties of rock-forming minerals}, + year = {1978}, + volume = {278A}, + pages = {1--229}, + url = {http://www.worldcat.org/oclc/13594862}, } @Article{HOKR98, - author = {Helgeson, Harold C. and Owens, Christine E. and Knox, Annette M. and Richard, Laurent}, - journal = {Geochimica et Cosmochimica Acta}, - title = {{C}alculation of the standard molal thermodynamic properties of crystalline, liquid, and gas organic molecules at high temperatures and pressures}, - year = {1998}, - volume = {62}, - number = {6}, - pages = {985--1081}, - doi = {10.1016/S0016-7037(97)00219-6}, - size = {97 p.}, + author = {Helgeson, Harold C. and Owens, Christine E. and Knox, Annette M. and Richard, Laurent}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{C}alculation of the standard molal thermodynamic properties of crystalline, liquid, and gas organic molecules at high temperatures and pressures}, + year = {1998}, + volume = {62}, + number = {6}, + pages = {985--1081}, + doi = {10.1016/S0016-7037(97)00219-6}, + size = {97 p.}, } @Article{HRMNS09, @@ -239,14 +239,14 @@ } @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, @@ -726,7 +726,7 @@ title = {{W}ater in the deep {E}arth: {T}he dielectric constant and the solubilities of quartz and corundum to 60 kb and 1,200 $^\circ${C}}, year = {2014}, volume = {129}, - pages = {125-145}, + pages = {125--145}, doi = {10.1016/j.gca.2013.12.019}, issn = {0016-7037}, } @@ -782,7 +782,7 @@ year = {2002}, volume = {31}, number = {2}, - pages = {387 -- 535}, + pages = {387--535}, doi = {10.1063/1.1461829}, } @@ -828,7 +828,7 @@ year = {1988}, volume = {29}, number = {2}, - pages = {445}, + pages = {445--522}, doi = {10.1093/petrology/29.2.445}, } @@ -928,7 +928,7 @@ year = {2014}, volume = {132}, number = {Supplement C}, - pages = {375 - 390}, + pages = {375--390}, doi = {10.1016/j.gca.2014.01.030}, issn = {0016-7037}, } @@ -952,7 +952,7 @@ year = {1992}, volume = {56}, number = {9}, - pages = {3435 - 3467}, + pages = {3435--3467}, doi = {10.1016/0016-7037(92)90390-5}, issn = {0016-7037}, } From noreply at r-forge.r-project.org Thu Oct 12 10:21:01 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 12 Oct 2017 10:21:01 +0200 (CEST) Subject: [CHNOSZ-commits] r252 - in pkg/CHNOSZ: . R inst man Message-ID: <20171012082101.73F98188833@r-forge.r-project.org> Author: jedick Date: 2017-10-12 10:21:01 +0200 (Thu, 12 Oct 2017) New Revision: 252 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/nonideal.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/eos.Rd pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/man/water.Rd Log: add Bdot() for calculating Debye-Huckel/Helgeson extended term parameter Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-12 08:21:01 UTC (rev 252) @@ -1,6 +1,6 @@ -Date: 2017-10-10 +Date: 2017-10-12 Package: CHNOSZ -Version: 1.1.0-50 +Version: 1.1.0-51 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/NAMESPACE 2017-10-12 08:21:01 UTC (rev 252) @@ -59,7 +59,7 @@ # added 20170301 or later "GHS_Tr", "calculateDensity", "calculateGibbsOfWater", "calculateEpsilon", "calculateQ", "water.DEW", "berman", - "maxdiff", "expect_maxdiff" + "maxdiff", "expect_maxdiff", "Bdot" ) # Load shared objects @@ -67,7 +67,7 @@ # Imports from default packages importFrom("grDevices", "dev.cur", "dev.off", "extendrange", - "heat.colors", "png", "rainbow") + "heat.colors", "png", "rainbow", "topo.colors") importFrom("graphics", "abline", "axTicks", "axis", "barplot", "box", "contour", "image", "legend", "lines", "mtext", "par", "plot", "plot.new", "plot.window", "points", "rect", "text", "title") Modified: pkg/CHNOSZ/R/nonideal.R =================================================================== --- pkg/CHNOSZ/R/nonideal.R 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/R/nonideal.R 2017-10-12 08:21:01 UTC (rev 252) @@ -33,6 +33,12 @@ else if(prop=='S') return(- R * T * loggamma(eval(DD(A,'T',1)),Z,I,B)) else if(prop=='Cp') return(R * T^2 *loggamma(eval(DD(A,'T',2)),Z,I,B)) } + Helgeson <- function() { + # "distance of closest approach" of ions in NaCl solutions + # HKF81 Table 2 + acirc <- 3.72 # Angstrom + } + if(!is.numeric(species[[1]])) species <- info(species,'aq') proptable <- as.list(proptable) # which gamma function to use @@ -67,3 +73,247 @@ return(proptable) } +Bdot <- function(TC=25, P=1, showsplines="") { + # 20171012 calculate B-dot (bgamma) using P, T, points from: + # Helgeson, 1969 (doi:10.2475/ajs.267.7.729) + # Helgeson et al., 1981 (doi:10.2475/ajs.281.10.1249) + # Manning et al., 2013 (doi:10.2138/rmg.2013.75.5) + # T in degrees C + T <- TC + # are we at a pre-fitted constant pressure? + uP <- unique(P) + is1 <- identical(uP, 1) & all(T==25) + is500 <- identical(uP, 500) + is1000 <- identical(uP, 1000) + is2000 <- identical(uP, 2000) + is3000 <- identical(uP, 3000) + is4000 <- identical(uP, 4000) + is5000 <- identical(uP, 5000) + is10000 <- identical(uP, 10000) + is20000 <- identical(uP, 20000) + is30000 <- identical(uP, 30000) + is40000 <- identical(uP, 40000) + is50000 <- identical(uP, 50000) + is60000 <- identical(uP, 60000) + isoP <- is1 | is500 | is1000 | is2000 | is3000 | is4000 | is5000 | is10000 | is20000 | is30000 | is40000 | is50000 | is60000 + # values for Bdot x 100 from Helgeson (1969), Figure (P = Psat) + if(!isoP | showsplines != "") { + T0 <- c(23.8, 49.4, 98.9, 147.6, 172.6, 197.1, 222.7, 248.1, 268.7) + B0 <- c(4.07, 4.27, 4.30, 4.62, 4.86, 4.73, 4.09, 3.61, 1.56) + # we could use the values from Hel69 Table 2 but extrapolation of the + # their fitted spline function turns sharply upward above 300 degC + #T0a <- c(25, 50, 100, 150, 200, 250, 270, 300) + #B0a <- c(4.1, 4.35, 4.6, 4.75, 4.7, 3.4, 1.5, 0) + S0 <- splinefun(T0, B0) + } + # values for bgamma x 100 from Helgeson et al., 1981 Table 27 + if(is500 | !isoP | showsplines != "") { + T0.5 <- seq(0, 400, 25) + B0.5 <- c(5.6, 7.1, 7.8, 8.0, 7.8, 7.5, 7.0, 6.4, 5.7, 4.8, 3.8, 2.6, 1.0, -1.2, -4.1, -8.4, -15.2) + S0.5 <- splinefun(T0.5, B0.5) + if(is500) return(S0.5(T)) + } + if(is1000 | !isoP | showsplines != "") { + T1 <- seq(0, 500, 25) + B1 <- c(6.6, 7.7, 8.7, 8.3, 8.2, 7.9, 7.5, 7.0, 6.5, 5.9, 5.2, 4.4, 3.5, 2.5, 1.1, -0.6, -2.8, -5.7, -9.3, -13.7, -19.2) + S1 <- splinefun(T1, B1) + if(is1000) return(S1(T)) + } + if(is2000 | !isoP | showsplines != "") { + # 550 and 600 degC points from Manning et al., 2013 Fig. 11 + T2 <- c(seq(0, 500, 25), 550, 600) + B2 <- c(7.4, 8.3, 8.8, 8.9, 8.9, 8.7, 8.5, 8.1, 7.8, 7.4, 7.0, 6.6, 6.2, 5.8, 5.2, 4.6, 3.8, 2.9, 1.8, 0.5, -1.0, -3.93, -4.87) + S2 <- splinefun(T2, B2) + if(is2000) return(S2(T)) + } + if(is3000 | !isoP | showsplines != "") { + T3 <- seq(0, 500, 25) + B3 <- c(6.5, 8.3, 9.2, 9.6, 9.7, 9.6, 9.4, 9.3, 9.2, 9.0, 8.8, 8.6, 8.3, 8.1, 7.8, 7.5, 7.1, 6.6, 6.0, 5.4, 4.8) + S3 <- splinefun(T3, B3) + if(is3000) return(S3(T)) + } + if(is4000 | !isoP | showsplines != "") { + T4 <- seq(0, 500, 25) + B4 <- c(4.0, 7.7, 9.5, 10.3, 10.7, 10.8, 10.8, 10.8, 10.7, 10.6, 10.5, 10.4, 10.3, 10.2, 10.0, 9.8, 9.6, 9.3, 8.9, 8.5, 8.2) + S4 <- splinefun(T4, B4) + if(is4000) return(S4(T)) + } + if(is5000 | !isoP | showsplines != "") { + # 550 and 600 degC points from Manning et al., 2013 Fig. 11 + T5 <- c(seq(0, 500, 25), 550, 600) + B5 <- c(0.1, 6.7, 9.6, 11.1, 11.8, 12.2, 12.4, 12.4, 12.4, 12.4, 12.4, 12.3, 12.3, 12.2, 12.1, 11.9, 11.8, 11.5, 11.3, 11.0, 10.8, 11.2, 12.52) + S5 <- splinefun(T5, B5) + if(is5000) return(S5(T)) + } + # 10, 20, and 30 kb points from Manning et al., 2013 Fig. 11 + # here, one control point at 10 degC is added to make the splines curve down at low T + if(is10000 | !isoP | showsplines != "") { + T10 <- c(25, seq(300, 1000, 50)) + B10 <- c(12, 17.6, 17.8, 18, 18.2, 18.9, 21, 23.3, 26.5, 28.8, 31.4, 34.1, 36.5, 39.2, 41.6, 44.1) + S10 <- splinefun(T10, B10) + if(is10000) return(S10(T)) + } + if(is20000 | !isoP | showsplines != "") { + T20 <- c(25, seq(300, 1000, 50)) + B20 <- c(16, 21.2, 21.4, 22, 22.4, 23.5, 26.5, 29.2, 32.6, 35.2, 38.2, 41.4, 44.7, 47.7, 50.5, 53.7) + S20 <- splinefun(T20, B20) + if(is20000) return(S20(T)) + } + if(is30000 | !isoP | showsplines != "") { + T30 <- c(25, seq(300, 1000, 50)) + B30 <- c(19, 23.9, 24.1, 24.6, 25.2, 26.7, 30.3, 32.9, 36.5, 39.9, 43, 46.4, 49.8, 53.2, 56.8, 60) + S30 <- splinefun(T30, B30) + if(is30000) return(S30(T)) + } + # 40-60 kb points extrapolated from 10-30 kb points of Manning et al., 2013 + if(is40000 | !isoP | showsplines != "") { + T40 <- c(seq(300, 1000, 50)) + B40 <- c(25.8, 26, 26.4, 27.2, 28.9, 33, 35.5, 39.2, 43.2, 46.4, 49.9, 53.4, 57.1, 61.2, 64.4) + S40 <- splinefun(T40, B40) + if(is40000) return(S40(T)) + } + if(is50000 | !isoP | showsplines != "") { + T50 <- c(seq(300, 1000, 50)) + B50 <- c(27.1, 27.3, 27.7, 28.5, 30.5, 34.8, 37.3, 41.1, 45.5, 48.7, 52.4, 55.9, 59.8, 64.3, 67.5) + S50 <- splinefun(T50, B50) + if(is50000) return(S50(T)) + } + if(is60000 | !isoP | showsplines != "") { + T60 <- c(seq(300, 1000, 50)) + B60 <- c(28, 28.2, 28.6, 29.5, 31.6, 36.1, 38.6, 42.5, 47.1, 50.4, 54.1, 57.6, 61.6, 66.5, 69.7) + S60 <- splinefun(T60, B60) + if(is60000) return(S60(T)) + } + # show points and spline(T) curves + if(showsplines == "T") { + thermo.plot.new(c(0, 1000), c(-20, 70), xlab=axis.label("T"), ylab=expression(b[gamma]%*%100)) + points(T0, B0, pch=0) + points(T0.5, B0.5, pch=1) + points(T1, B1, pch=1) + points(T2[-c(22:23)], B2[-c(22:23)], pch=1) + points(T2[c(22:23)], B2[c(22:23)], pch=2) + points(T3, B3, pch=1) + points(T4, B4, pch=1) + points(T5[-c(22:23)], B5[-c(22:23)], pch=1) + points(T5[c(22:23)], B5[c(22:23)], pch=2) + points(T10[-1], B10[-1], pch=2) + points(T20[-1], B20[-1], pch=2) + points(T30[-1], B30[-1], pch=2) + points(T10[1], B10[1], pch=5) + points(T20[1], B20[1], pch=5) + points(T30[1], B30[1], pch=5) + points(T40, B40, pch=6) + points(T50, B50, pch=6) + points(T60, B60, pch=6) + col <- rev(topo.colors(13)) + T0 <- seq(0, 350, 5); lines(T0, S0(T0), col=col[1]) + T0.5 <- seq(0, 500, 5); lines(T0.5, S0.5(T0.5), col=col[2]) + T1 <- seq(0, 500, 5); lines(T1, S1(T1), col=col[3]) + T2 <- seq(0, 600, 5); lines(T2, S2(T2), col=col[4]) + T3 <- seq(0, 600, 5); lines(T3, S3(T3), col=col[5]) + T4 <- seq(0, 600, 5); lines(T4, S4(T4), col=col[6]) + T5 <- seq(0, 600, 5); lines(T5, S5(T5), col=col[7]) + T10 <- c(25, seq(100, 1000, 5)); lines(T10, S10(T10), col=col[8]) + T20 <- c(80, seq(100, 1000, 5)); lines(T20, S20(T20), col=col[9]) + T30 <- c(125, seq(200, 1000, 5)); lines(T30, S30(T30), col=col[10]) + T40 <- c(175, seq(300, 1000, 5)); lines(T40, S40(T40), col=col[11]) + T50 <- c(225, seq(300, 1000, 5)); lines(T50, S50(T50), col=col[12]) + T60 <- c(250, seq(300, 1000, 5)); lines(T60, S60(T60), col=col[13]) + legend("topleft", pch=c(0, 1, 2, 5, 6), + legend=c("Helgeson, 1969", "Helgeson et al., 1981", "Manning et al., 2013", "spline control point", "high-P extrapolation")) + legend("bottomright", col=c(NA, rev(col)), lty=1, + legend=c("kbar", "60", "50", "40", "30", "20", "10", "5", "4", "3", "2", "1", "0.5", "Psat")) + } else if(showsplines=="P") { + #thermo.plot.new(c(0, 60000), c(-20, 70), xlab=axis.label("P"), ylab=expression(b[gamma]%*%100)) + thermo.plot.new(c(0, 5), c(-20, 70), xlab="log P", ylab=expression(b[gamma]%*%100)) + # pressures that are used to make the isothermal splines (see below) + P25 <- c(1, 500, 1000, 2000, 3000, 4000, 5000) + P100 <- c(1, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000) + P200 <- c(15, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000) + P300 <- c(86, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + P400 <- c(500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + P500 <- c(1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + P600 <- c(2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + P700 <- c(10000, 20000, 30000, 40000, 50000, 60000) + P800 <- c(10000, 20000, 30000, 40000, 50000, 60000) + P900 <- c(10000, 20000, 30000, 40000, 50000, 60000) + P1000 <- c(10000, 20000, 30000, 40000, 50000, 60000) + # plot the pressure and B-dot values used to make the isothermal splines + points(log10(P25), Bdot(25, P25) * 100) + points(log10(P100), Bdot(100, P100) * 100) + points(log10(P200), Bdot(200, P200) * 100) + points(log10(P300), Bdot(300, P300) * 100) + points(log10(P400), Bdot(400, P400) * 100) + points(log10(P500), Bdot(500, P500) * 100) + points(log10(P600), Bdot(600, P600) * 100) + points(log10(P700), Bdot(700, P700) * 100) + points(log10(P800), Bdot(800, P800) * 100) + points(log10(P900), Bdot(900, P900) * 100) + points(log10(P1000), Bdot(1000, P1000) * 100) + # plot the isothermal spline functions + col <- tail(rev(rainbow(12)), -1) + P <- c(1, seq(50, 5000, 50)); lines(log10(P), Bdot(25, P) * 100, col=col[1]) + P <- c(1, seq(50, 20000, 50)); lines(log10(P), Bdot(100, P) * 100, col=col[2]) + P <- c(1, seq(50, 40000, 50)); lines(log10(P), Bdot(200, P) * 100, col=col[3]) + P <- c(1, seq(50, 60000, 50)); lines(log10(P), Bdot(300, P) * 100, col=col[4]) + P <- seq(500, 60000, 50); lines(log10(P), Bdot(400, P) * 100, col=col[5]) + P <- seq(1000, 60000, 50); lines(log10(P), Bdot(500, P) * 100, col=col[6]) + P <- seq(2000, 60000, 50); lines(log10(P), Bdot(600, P) * 100, col=col[7]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(700, P) * 100, col=col[8]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(800, P) * 100, col=col[9]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(900, P) * 100, col=col[10]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(1000, P) * 100, col=col[11]) + legend("topleft", col=c(NA, col), lty=1, legend=c("degrees C", 25, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000)) + legend("bottomright", pch=1, legend="points from iso-P splines") + } else { + # make T and P the same length + ncond <- max(length(T), length(P)) + T <- rep(T, length.out=ncond) + P <- rep(P, length.out=ncond) + # loop over P, T conditions + Bdot <- numeric() + lastT <- NULL + for(i in 1:length(T)) { + # make it fast: skip splines at 25 degC and 1 bar + if(T[i]==25 & P[i]==1) Bdot <- c(Bdot, 0.041) + else { + if(!identical(T[i], lastT)) { + # get the spline fits from particular pressures for each T + if(T[i] >= 700) { + PT <- c(10000, 20000, 30000, 40000, 50000, 60000) + B <- c(S10(T[i]), S20(T[i]), S30(T[i]), S40(T[i]), S50(T[i]), S60(T[i])) + } else if(T[i] >= 600) { + PT <- c(2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + B <- c(S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i]), S10(T[i]), S20(T[i]), S30(T[i]), S40(T[i]), S50(T[i]), S60(T[i])) + } else if(T[i] >= 500) { + PT <- c(1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + B <- c(S1(T[i]), S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i]), S10(T[i]), S20(T[i]), S30(T[i]), S40(T[i]), S50(T[i]), S60(T[i])) + } else if(T[i] >= 400) { + PT <- c(500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + B <- c(S0.5(T[i]), S1(T[i]), S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i]), S10(T[i]), S20(T[i]), S30(T[i]), S40(T[i]), S50(T[i]), S60(T[i])) + } else if(T[i] >= 300) { + # here the lowest P is Psat + PT <- c(86, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) + B <- c(S0(T[i]), S0.5(T[i]), S1(T[i]), S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i]), S10(T[i]), S20(T[i]), S30(T[i]), S40(T[i]), S50(T[i]), S60(T[i])) + } else if(T[i] >= 200) { + # drop highest pressures because we get into ice + PT <- c(16, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000) + B <- c(S0(T[i]), S0.5(T[i]), S1(T[i]), S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i]), S10(T[i]), S20(T[i]), S30(T[i]), S40(T[i])) + } else if(T[i] >= 100) { + PT <- c(1, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000) + B <- c(S0(T[i]), S0.5(T[i]), S1(T[i]), S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i]), S10(T[i]), S20(T[i])) + } else if(T[i] >= 0) { + PT <- c(1, 500, 1000, 2000, 3000, 4000, 5000) + B <- c(S0(T[i]), S0.5(T[i]), S1(T[i]), S2(T[i]), S3(T[i]), S4(T[i]), S5(T[i])) + } + # make a new spline as a function of pressure at this T + ST <- splinefun(PT, B) + # remember this T; if it's the same as the next one, we won't re-make the spline + lastT <- T[i] + } + Bdot <- c(Bdot, ST(P[i]) / 100) + } + } + return(Bdot) + } +} Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/inst/NEWS 2017-10-12 08:21:01 UTC (rev 252) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-50 (2017-10-11) +CHANGES IN CHNOSZ 1.1.0-51 (2017-10-12) --------------------------------------- MAJOR CHANGES: @@ -36,9 +36,15 @@ carbon numbers. - All three water options (SUPCRT92, IAPWS95, DEW) can be used to - calculate 'A_DH' and 'B_DH', i.e. A and B coefficients in the B-dot - (extended Debye-Huckel) equation of Helgeson, 1969. + calculate 'A_DH' and 'B_DH', i.e. A and B coefficients in the extended + Debye-Huckel equation of Helgeson, 1969. +- Add Bdot() to calculate the "B-dot" (or b_gamma) extended term + parameter for activity coefficients in NaCl solutions at high + temperature and pressure (Helgeson et al., 1981) including + high-pressure extrapolations > 10 kbar based on data from Manning et + al., 2013. + - For minerals with phase transitions (states 'cr2' 'cr3' etc.) in thermo$obigt (i.e. the Helgeson minerals), it is now possible to use the minerals in basis(), species(), affinity() with proper accounting Modified: pkg/CHNOSZ/man/eos.Rd =================================================================== --- pkg/CHNOSZ/man/eos.Rd 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/man/eos.Rd 2017-10-12 08:21:01 UTC (rev 252) @@ -85,7 +85,7 @@ \references{ - Helgeson, H. C., Kirkham, D. H. and Flowers, G. C. (1981) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600\eqn{^{\circ}}{?}C and 5 Kb. \emph{Am. J. Sci.} \bold{281}, 1249--1516. \url{http://www.ajsonline.org/cgi/content/abstract/281/10/1249} + Helgeson, H. C., Kirkham, D. H. and Flowers, G. C. (1981) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600\degC and 5 Kb. \emph{Am. J. Sci.} \bold{281}, 1249--1516. \url{https://doi.org/10.2475/ajs.281.10.1249} Helgeson, H. C., Owens, C. E., Knox, A. M. and Richard, L. (1998) Calculation of the standard molal thermodynamic properties of crystalline, liquid, and gas organic molecules at high temperatures and pressures. \emph{Geochim. Cosmochim. Acta} \bold{62}, 985--1081. \url{https://doi.org/10.1016/S0016-7037(97)00219-6} @@ -97,7 +97,7 @@ Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} - Tanger, J. C. IV and Helgeson, H. C. (1988) Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Revised equations of state for the standard partial molal properties of ions and electrolytes. \emph{Am. J. Sci.} \bold{288}, 19--98. \url{http://www.ajsonline.org/cgi/content/abstract/288/1/19} + Tanger, J. C. IV and Helgeson, H. C. (1988) Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Revised equations of state for the standard partial molal properties of ions and electrolytes. \emph{Am. J. Sci.} \bold{288}, 19--98. \url{https://doi.org/10.2475/ajs.288.1.19} } Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-10-12 08:21:01 UTC (rev 252) @@ -1,6 +1,7 @@ \encoding{UTF-8} \name{nonideal} \alias{nonideal} +\alias{Bdot} \title{Activity coefficients of aqueous species} \description{ Calculate activity coefficients and non-ideal contributions to apparent standard molal properties of aqueous species. @@ -8,13 +9,17 @@ \usage{ nonideal(species, proptable, IS, T) + Bdot(TC, P, showsplines = "") } \arguments{ \item{species}{names or indices of species for which to calculate nonideal properties} \item{proptable}{list of dataframes of species properties} \item{IS}{numeric, ionic strength(s) used in nonideal calculations, mol kg\eqn{^{-1}}{^-1}} - \item{T}{numeric, temperature (K) (\code{lines.water}, \code{nonideal})} + \item{T}{numeric, temperature (K)} + \item{TC}{numeric, temperature (\degC)} + \item{P}{numeric, pressure (bar)} + \item{showsplines}{character, show isobaric (\samp{T}) or isothermal (\samp{P}) splines} } \details{ @@ -25,6 +30,14 @@ 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{proptable}, or one to use single values throughout. The apparent molal properties that can be calculated include \code{G}, \code{H}, \code{S} and \code{Cp}; any columns in the dataframes of \code{proptable} with other names are left untouched. A column named \code{loggam} (logarithm of gamma, the activity coefficient) is appended to the output dataframe of species properties. + +\code{Bdot} calculates the \dQuote{B-dot} deviation function (Helgeson, 1969) or 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). +Furthermore, the 10 to 30 kb data were used to generate super-extrapolated values at 40, 50, and 60 kb, which may be encountered using the \code{\link{water.DEW}} calculations. +If all \code{P} correspond to one of the isobaric conditions, the values of \code{Bdot} at \code{T} are calculated by spline fits to the isobaric data. +Otherwise, particular (dependent on the \code{T}) isobaric spline fits are themselves used to construct isothermal splines for the given values of \code{T}; the isothermal splines are then used to generate the values of \code{Bdot} for the given \code{P}. +To see the splines, set \code{showsplines} to \samp{T} to make the first set (isobaric splines) along with the data points, or \samp{P} for examples of isothermal splines at even temperature intervals (here, the symbols are not data, but values generated from the isobaric splines). +This is a crude method of kriging the data, but produces fairly smooth interpolations without adding any external dependencies. } \section{Warning}{ @@ -100,10 +113,21 @@ a <- affinity(IS=c(0, 0.14), pH=c(6, 13), T=Ts[2]) d <- diagram(a, add=TRUE, names=NULL, col="red") par(opar) + +## data and splines used for calculating B-dot +## (extended term parameter) +Bdot(showsplines = "T") +Bdot(showsplines = "P") } \references{ Alberty, R. A. (2003) \emph{Thermodynamics of Biochemical Reactions}, John Wiley & Sons, Hoboken, New Jersey, 397 p. \url{http://www.worldcat.org/oclc/51242181} + +Helgeson, H. C. (1969) Thermodynamics of hydrothermal systems at elevated temperatures and pressures. \emph{Am. J. Sci.} \bold{267}, 729--804. \url{https://doi.org/10.2475/ajs.267.7.729} + +Helgeson, H. C., Kirkham, D. H. and Flowers, G. C. (1981) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600\degC and 5 Kb. \emph{Am. J. Sci.} \bold{281}, 1249--1516. \url{https://doi.org/10.2475/ajs.281.10.1249} + +Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5} } \concept{Secondary thermodynamic modeling} Modified: pkg/CHNOSZ/man/water.Rd =================================================================== --- pkg/CHNOSZ/man/water.Rd 2017-10-11 15:40:05 UTC (rev 251) +++ pkg/CHNOSZ/man/water.Rd 2017-10-12 08:21:01 UTC (rev 252) @@ -160,11 +160,11 @@ Haar, L., Gallagher, J. S. and Kell, G. S. (1984) \emph{NBS/NRC Steam Tables}. Hemisphere, Washington, D. C., 320 p. \url{http://www.worldcat.org/oclc/301304139} -Helgeson, H. C. and Kirkham, D. H. (1974) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. I. Summary of the thermodynamic/electrostatic properties of the solvent. \emph{Am. J. Sci.} \bold{274}, 1089--1098. \url{http://www.ajsonline.org/cgi/content/abstract/274/10/1089} +Helgeson, H. C. and Kirkham, D. H. (1974) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. I. Summary of the thermodynamic/electrostatic properties of the solvent. \emph{Am. J. Sci.} \bold{274}, 1089--1098. \url{https://doi.org/10.2475/ajs.274.10.1089} Helgeson, H. C. (1969) Thermodynamics of hydrothermal systems at elevated temperatures and pressures. \emph{Am. J. Sci.} \bold{267}, 729--804. \url{https://doi.org/10.2475/ajs.267.7.729} -Johnson, J. W. and Norton, D. (1991) Critical phenomena in hydrothermal systems: state, thermodynamic, electrostatic, and transport properties of H\eqn{_2}{2}O in the critical region. \emph{Am. J. Sci.} \bold{291}, 541--648. \url{http://www.ajsonline.org/cgi/content/abstract/291/6/541} +Johnson, J. W. and Norton, D. (1991) Critical phenomena in hydrothermal systems: state, thermodynamic, electrostatic, and transport properties of H\eqn{_2}{2}O in the critical region. \emph{Am. J. Sci.} \bold{291}, 541--648. \url{https://doi.org/10.2475/ajs.291.6.541} Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000\eqn{^{\circ}}{?}C. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{https://doi.org/10.1016/0098-3004(92)90029-Q} From noreply at r-forge.r-project.org Thu Oct 12 11:10:59 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 12 Oct 2017 11:10:59 +0200 (CEST) Subject: [CHNOSZ-commits] r253 - in pkg/CHNOSZ: . R man Message-ID: <20171012091059.DDE0E18789D@r-forge.r-project.org> Author: jedick Date: 2017-10-12 11:10:59 +0200 (Thu, 12 Oct 2017) New Revision: 253 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/nonideal.R pkg/CHNOSZ/man/EOSregress.Rd pkg/CHNOSZ/man/IAPWS95.Rd pkg/CHNOSZ/man/affinity.Rd pkg/CHNOSZ/man/anim.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/eos.Rd pkg/CHNOSZ/man/eqdata.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/man/subcrt.Rd pkg/CHNOSZ/man/swap.basis.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/man/util.formula.Rd pkg/CHNOSZ/man/util.protein.Rd pkg/CHNOSZ/man/util.units.Rd pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/man/wjd.Rd Log: Rd files: use \degC macro in more places Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-12 09:10:59 UTC (rev 253) @@ -1,6 +1,6 @@ Date: 2017-10-12 Package: CHNOSZ -Version: 1.1.0-51 +Version: 1.1.0-52 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/nonideal.R =================================================================== --- pkg/CHNOSZ/R/nonideal.R 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/R/nonideal.R 2017-10-12 09:10:59 UTC (rev 253) @@ -1,49 +1,55 @@ # CHNOSZ/nonideal.R # first version of function: 20080308 jmd # moved to nonideal.R from util.misc.R 20151107 +# added Helgeson method 20171012 -nonideal <- function(species,proptable,IS,T) { +nonideal <- function(species, proptable, IS, T, P) { thermo <- get("thermo") # generate nonideal contributions to thermodynamic properties # number of species, same length as proptable list # T in Kelvin, same length as nrows of proptables - # a function that does a lot of the work - loggamma2 <- function(Z,I,T,prop='log') { - # extended Debye-Huckel equation ('log') - # and its partial derivatives ('G','H','S','Cp') + + # function to calculate extended Debye-Huckel equation and derivatives using Alberty's parameters + Alberty <- function(Z, I, T, prop = "log") { + # extended Debye-Huckel equation ("log") + # and its partial derivatives ("G","H","S","Cp") # T in Kelvin - B <- 1.6 + B <- 1.6 # L^0.5 mol^-0.5 (Alberty, 2003 p. 47) # equation for A from Clarke and Glew, 1980 #A <- expression(-16.39023 + 261.3371/T + 3.3689633*log(T)- 1.437167*(T/100) + 0.111995*(T/100)^2) - # equation for alpha from Alberty, 2003 p. 48 - A <- alpha <- expression(1.10708 - 1.54508E-3 * T + 5.95584E-6 * T^2) + # equation for A (alpha) from Alberty, 2003 p. 48 + A <- expression(1.10708 - 1.54508E-3 * T + 5.95584E-6 * T^2) # from examples for deriv to take first and higher-order derivatives - DD <- function(expr,name, order = 1) { + DD <- function(expr, name, order = 1) { if(order < 1) stop("'order' must be >= 1") - if(order == 1) D(expr,name) + if(order == 1) D(expr, name) else DD(D(expr, name), name, order - 1) } # Alberty, 2003 Eq. 3.6-1 - loggamma <- function(a,Z,I,B) { - a * Z^2 * I^(1/2) / (1 + B * I^(1/2)) } + loggamma <- function(a, Z, I, B) - a * Z^2 * I^(1/2) / (1 + B * I^(1/2)) # TODO: check the following equations 20080208 jmd R <- 1.9872 # gas constant, cal K^-1 mol^-1 - if(prop=='log') return(loggamma(eval(A),Z,I,B)) - else if(prop=='G') return(R * T * loggamma(eval(A),Z,I,B)) - else if(prop=='H') return(R * T^2 * loggamma(eval(DD(A,'T',1)),Z,I,B)) - else if(prop=='S') return(- R * T * loggamma(eval(DD(A,'T',1)),Z,I,B)) - else if(prop=='Cp') return(R * T^2 *loggamma(eval(DD(A,'T',2)),Z,I,B)) + if(prop=="log") return(loggamma(eval(A), Z, I, B)) + else if(prop=="G") return(R * T * loggamma(eval(A), Z, I, B)) + else if(prop=="H") return(R * T^2 * loggamma(eval(DD(A, "T", 1)), Z, I, B)) + else if(prop=="S") return(- R * T * loggamma(eval(DD(A, "T", 1)), Z, I, B)) + else if(prop=="Cp") return(R * T^2 *loggamma(eval(DD(A, "T", 2)), Z, I, B)) } + + # function for Debye-Huckel equation with B-dot extended term parameter (Helgeson, 1969) Helgeson <- function() { # "distance of closest approach" of ions in NaCl solutions # HKF81 Table 2 acirc <- 3.72 # Angstrom } - if(!is.numeric(species[[1]])) species <- info(species,'aq') + # get species indices + if(!is.numeric(species[[1]])) species <- info(species, "aq") + iH <- info("H+") + ie <- info("e-") proptable <- as.list(proptable) - # which gamma function to use - #mlg <- get(paste('loggamma',which,sep='')) ndid <- 0 + # loop over species for(i in 1:length(species)) { myprops <- proptable[[i]] # get the charge from the chemical formula @@ -53,27 +59,26 @@ # don't do anything for neutral species if(Z==0) next # to keep unit activity coefficients of the proton and electron - if(species[i] == info("H+") & thermo$opt$ideal.H) next - if(species[i] == info("e-") & thermo$opt$ideal.e) next + if(species[i] == iH & get("thermo")$opt$ideal.H) next + if(species[i] == ie & get("thermo")$opt$ideal.e) next didit <- FALSE for(j in 1:ncol(myprops)) { - #if(colnames(myprops)[j]=='G') myprops[,j] <- myprops[,j] + R * T * mlg(Z,IS,convert(T,'C')) - cname <- colnames(myprops)[j] - if(cname %in% c('G','H','S','Cp')) { - myprops[,j] <- myprops[,j] + loggamma2(Z,IS,T,cname) + pname <- colnames(myprops)[j] + if(pname %in% c("G", "H", "S", "Cp")) { + myprops[,j] <- myprops[,j] + Alberty(Z, IS, T, pname) didit <- TRUE } } # append a loggam column if we did any nonideal calculations of thermodynamic properties - if(didit) myprops <- cbind(myprops,loggam=loggamma2(Z,IS,T)) + if(didit) myprops <- cbind(myprops, loggam = Alberty(Z, IS, T)) proptable[[i]] <- myprops if(didit) ndid <- ndid + 1 } - if(ndid > 0) message(paste('nonideal:',ndid,'species were nonideal')) + if(ndid > 0) message(paste("nonideal:", ndid, "species were nonideal")) return(proptable) } -Bdot <- function(TC=25, P=1, showsplines="") { +Bdot <- function(TC = 25, P = 1, showsplines = "") { # 20171012 calculate B-dot (bgamma) using P, T, points from: # Helgeson, 1969 (doi:10.2475/ajs.267.7.729) # Helgeson et al., 1981 (doi:10.2475/ajs.281.10.1249) Modified: pkg/CHNOSZ/man/EOSregress.Rd =================================================================== --- pkg/CHNOSZ/man/EOSregress.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/EOSregress.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -90,7 +90,7 @@ Here, \eqn{\sigma}{sigma} and \eqn{\xi}{xi} are calculated from a1, a2, a3 and a4 in \code{thermo$obigt} at the pressure indicated by \code{P} (default 1 bar). The original motivation for writing these functions was to explore alternatives or possible modifications to the revised Helgeson-Kirkham-Flowers equations applied to aqueous nonelectrolytes. -As pointed out by Schulte et al., 2001, the functional forms of the equations do not permit retrieving values of the solvation parameter (\eqn{\omega}{omega}) that closely represent the observed trends in both heat capacity and volume at high temperatures (above ca. 200 \eqn{^{\circ}}{?}C). +As pointed out by Schulte et al., 2001, the functional forms of the equations do not permit retrieving values of the solvation parameter (\eqn{\omega}{omega}) that closely represent the observed trends in both heat capacity and volume at high temperatures (above ca. 200 \degC). The examples below assume that the \eqn{\omega}{omega} parameter in the HKF functions is a constant (does not depend on T and P), as is appropriate for nonelectrolytes. For charged species, the variables \code{Cp_s_var} and \code{V_s_var} can be used in the regressions. Modified: pkg/CHNOSZ/man/IAPWS95.Rd =================================================================== --- pkg/CHNOSZ/man/IAPWS95.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/IAPWS95.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -23,7 +23,7 @@ The \code{IAPWS95} function returns values of thermodynamic properties in specific units (per gram). The IAPWS-95 formulation follows the triple point convention used in engineering (values of internal energy and entropy are taken to be zero at the triple point). -For \code{IAPWS95} the upper temperature limit of validity is 1000 \eqn{^{\circ}}{?}C, but extrapolation to much higher temperatures is possible (Wagner and Pruss, 2002). +For \code{IAPWS95} the upper temperature limit of validity is 1000 \degC, but extrapolation to much higher temperatures is possible (Wagner and Pruss, 2002). Valid pressures are from the greater of zero bar or the melting pressure at temperature to 10000 bar (with the provision for extrapolation to more extreme conditions). The function does not check these limits and will attempt calculations for any range of input parameters, but may return \code{NA} for properties that fail to be calculated at given temperatures and pressures and/or produce warnings or even errors when problems are encountered. } Modified: pkg/CHNOSZ/man/affinity.Rd =================================================================== --- pkg/CHNOSZ/man/affinity.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/affinity.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -35,7 +35,7 @@ For any arguments that refer to basis species, the numerical values are the logarithms of activity (or fugacity for gases) of that basis species. If \samp{T}, \samp{P}, and/or \samp{IS} are not among the \code{var}s, their constant values can be supplied in \code{T}, \code{P}, or \code{IS} (in mol kg\eqn{^{-1}}{^-1}). -The units of \samp{T} and \samp{P} are those set by \code{\link{T.units}} and \code{\link{P.units}} (on program start-up these are \eqn{^{\circ}}{?}C and bar, respectively). +The units of \samp{T} and \samp{P} are those set by \code{\link{T.units}} and \code{\link{P.units}} (on program start-up these are \degC and bar, respectively). \code{sout}, if provided, replaces the call to \code{\link{subcrt}}, which can greatly speed up the calculations if this intermediate result is stored by other functions. \code{exceed.Ttr} is passed to \code{\link{subcrt}} so that the properties of mineral phases beyond their transition temperatures can optionally be calculated. Modified: pkg/CHNOSZ/man/anim.Rd =================================================================== --- pkg/CHNOSZ/man/anim.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/anim.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -37,7 +37,7 @@ \code{anim.TCA} creates a series of figures showing how a logaH2O - logfO2 activity diagram for various species involved in the tricarboxylic acid (TCA) cycle changes as a function of pH. Alternatively, set \code{redox} to \code{list(H2=c(-20,0))} to draw a logaH2O - logaH2 diagram. -The diagrams are made at 25 \eqn{^{\circ}}{?}C unless \code{high.T} is TRUE, in which case high-temperature (100 \eqn{^{\circ}}{?}C) stability fields are overlaid. +The diagrams are made at 25 \degC unless \code{high.T} is TRUE, in which case high-temperature (100 \degC) stability fields are overlaid. \code{anim.carboxylase} animates equilibrium rank-activity diagrams along a combined temperature and logaH2 gradient, or makes a single plot on the default device (without conversion to animated GIF) if a single \code{temperature} is provided. The proteins in the calculation are 24 carboxylases from a variety of organisms. Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/data.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -62,19 +62,19 @@ \item \code{thermo$element} Dataframe containing the thermodynamic properties of elements taken from Cox et al., 1989 and Wagman et al., 1982. - The standard molal entropy (\eqn{S}(\code{Z})) at 25 \eqn{^{\circ}}{?}C and 1 bar for the \dQuote{element} of charge (\code{Z}) was calculated from \eqn{S}(H2,g) + 2\eqn{S}(\code{Z}) = 2\eqn{S}(H+), where the standard molal entropies of H2,g and H+ were taken from Cox et al., 1989. + The standard molal entropy (\eqn{S}(\code{Z})) at 25 \degC and 1 bar for the \dQuote{element} of charge (\code{Z}) was calculated from \eqn{S}(H2,g) + 2\eqn{S}(\code{Z}) = 2\eqn{S}(H+), where the standard molal entropies of H2,g and H+ were taken from Cox et al., 1989. The mass of \code{Z} is taken to be zero. Accessing this data frame using \code{\link{mass}} or \code{\link{entropy}} will select the first entry found for a given element; i.e., values from Wagman et al., 1982 will only be retrieved if the properties of the element are not found from Cox et al., 1989. \tabular{lll}{ \code{element} \tab character \tab Symbol of element\cr - \code{state} \tab character \tab Stable state of element at 25 \eqn{^{\circ}}{?}C and 1 bar\cr + \code{state} \tab character \tab Stable state of element at 25 \degC and 1 bar\cr \code{source} \tab character \tab Source of data\cr \code{mass} \tab numeric \tab Mass of element (in natural isotopic distribution;\cr \tab \tab referenced to a mass of 12 for \eqn{^{12}}{12}C)\cr \code{s} \tab numeric \tab Entropy of the compound of the element in its stable\cr - \tab \tab state at 25 \eqn{^{\circ}}{?}C and 1 bar (cal K\eqn{^{-1}}{^-1} mol\eqn{^{-1}}{^-1})\cr + \tab \tab state at 25 \degC and 1 bar (cal K\eqn{^{-1}}{^-1} mol\eqn{^{-1}}{^-1})\cr \code{n} \tab numeric \tab Number of atoms of the element in its stable\cr - \tab \tab compound at 25 \eqn{^{\circ}}{?}C and 1 bar + \tab \tab compound at 25 \degC and 1 bar } \item \code{thermo$obigt} @@ -98,13 +98,13 @@ See the vignette \emph{Thermodynamic data in CHNOSZ} for a complete description of the sources of data. In order to represent thermodynamic data for minerals with phase transitions, the higher-temperature phases of these minerals are represented as phase species that have states denoted by \samp{cr2}, \samp{cr3}, etc. -The standard molar thermodynamic properties at 25 \eqn{^{\circ}}{?}C and 1 bar (\eqn{T_r}{Pr} and \eqn{P_r}{Pr}) of the \samp{cr2} phase species of minerals were generated by first calculating those of the \samp{cr} (lowest-T) phase species at the transition temperature (\eqn{T_{tr}}{Ttr}) and 1 bar then taking account of the volume and entropy of transition (the latter can be retrieved by combining the former with the Clausius-Clapeyron equation and values of \eqn{(dP/dT)} of transitions taken from the \acronym{SUPCRT92} data file) to calculate the standard molar entropy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}, and taking account of the enthalpy of transition (\eqn{{\Delta}H^{\circ}}{DeltaH0}, taken from the \acronym{SUPCRT92} data file) to calculate the standard molar enthalpy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}. -The standard molar properties of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr} and 1 bar calculated in this manner were combined with the equations-of-state parameters of the species to generate values of the standard molar properties at 25 \eqn{^{\circ}}{?}C and 1 bar. +The standard molar thermodynamic properties at 25 \degC and 1 bar (\eqn{T_r}{Pr} and \eqn{P_r}{Pr}) of the \samp{cr2} phase species of minerals were generated by first calculating those of the \samp{cr} (lowest-T) phase species at the transition temperature (\eqn{T_{tr}}{Ttr}) and 1 bar then taking account of the volume and entropy of transition (the latter can be retrieved by combining the former with the Clausius-Clapeyron equation and values of \eqn{(dP/dT)} of transitions taken from the \acronym{SUPCRT92} data file) to calculate the standard molar entropy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}, and taking account of the enthalpy of transition (\eqn{{\Delta}H^{\circ}}{DeltaH0}, taken from the \acronym{SUPCRT92} data file) to calculate the standard molar enthalpy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}. +The standard molar properties of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr} and 1 bar calculated in this manner were combined with the equations-of-state parameters of the species to generate values of the standard molar properties at 25 \degC and 1 bar. This process was repeated as necessary to generate the standard molar properties of phase species represented by \samp{cr3} and \samp{cr4}, referencing at each iteration the previously calculated values of the standard molar properties of the lower-temperature phase species (i.e., \samp{cr2} and \samp{cr3}). A consequence of tabulating the standard molar thermodynamic properties of the phase species is that the values of \eqn{(dP/dT)} and \eqn{{\Delta}H^{\circ}}{DeltaH0} of phase transitions can be calculated using the equations of state and therefore do not need to be stored in the thermodynamic database. However, the transition temperatures (\eqn{T_{tr}}{Ttr}) generally can not be assessed by comparing the Gibbs energies of phase species and are tabulated in the database. -The identification of species and their standard molal thermodynamic properties at 25 \eqn{{^\circ}}{?}C and 1 bar are located in the first 12 columns of \code{thermo$obigt}: +The identification of species and their standard molal thermodynamic properties at 25 \degC and 1 bar are located in the first 12 columns of \code{thermo$obigt}: \tabular{lll}{ \code{name} \tab character \tab Species name\cr @@ -237,7 +237,7 @@ \references{ Cox, J. D., Wagman, D. D. and Medvedev, V. A., eds. (1989) \emph{CODATA Key Values for Thermodynamics}. Hemisphere Publishing Corporation, New York, 271 p. \url{http://www.worldcat.org/oclc/18559968} -Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000\eqn{^{\circ}}{?}C. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{https://doi.org/10.1016/0098-3004(92)90029-Q} +Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000\degC. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{https://doi.org/10.1016/0098-3004(92)90029-Q} Shock, E. L. et al. {1998} \emph{SLOP98.dat} (computer data file). http://geopig.asu.edu/supcrt92_data/slop98.dat, accessed on 2005-11-05. Current location: \url{http://geopig.asu.edu/?q=tools}. Modified: pkg/CHNOSZ/man/eos.Rd =================================================================== --- pkg/CHNOSZ/man/eos.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/eos.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -18,7 +18,7 @@ \item{parameters}{dataframe, species parameters as one or more rows from \code{thermo$obigt}} \item{T}{numeric, temperature(s) at which to calculate properties (K)} \item{P}{numeric, pressure(s) at which to calculate properties (bar)} - \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{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 \degC and 1 bar). Default is \code{c("n","s","o")}, for all contributions} \item{H2O.props}{character, properties to calculate for water} } @@ -45,7 +45,7 @@ } \section{Warning}{ -The temperature and pressure range of validity of the revised HKF equations of state for aqueous species corresponds to the stability region of liquid water or the supercritical fluid at conditions between 0 to 1000 \eqn{^{\circ}}{?}C and 1 to 5000 bar (Tanger and Helgeson, 1988; Shock and Helgeson, 1988). +The temperature and pressure range of validity of the revised HKF equations of state for aqueous species corresponds to the stability region of liquid water or the supercritical fluid at conditions between 0 to 1000 \degC and 1 to 5000 bar (Tanger and Helgeson, 1988; Shock and Helgeson, 1988). The \code{hkf} function does not check these limits and will compute properties as long as the requisite electrostatic properties of water are available. There are conceptually no temperature limits (other than 0 Kelvin) for the validity of the \code{cgl} equations of state. However, the actual working upper temperature limits correspond to the temperatures of phase transitions of minerals or to those temperatures beyond which extrapolations from experimental data become highly uncertain. These temperature limits are stored in the thermodynamic database for some minerals, but \code{cgl} ignores them; however, \code{\link{subcrt}} warns if they are exceeded. @@ -93,9 +93,9 @@ Robie, R. A. and Hemingway, B. S. (1995) \emph{Thermodynamic Properties of Minerals and Related Substances at 298.15 K and 1 Bar (\eqn{10^5} Pascals) Pressure and at Higher Temperatures}. U. S. Geol. Surv., Bull. 2131, 461 p. \url{http://www.worldcat.org/oclc/32590140} - Shock, E. L. and Helgeson, H. C. (1988) Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Correlation algorithms for ionic species and equation of state predictions to 5 kb and 1000\eqn{^{\circ}}{?}C. \emph{Geochim. Cosmochim. Acta} \bold{52}, 2009--2036. \url{https://doi.org/10.1016/0016-7037(88)90181-0} + Shock, E. L. and Helgeson, H. C. (1988) Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Correlation algorithms for ionic species and equation of state predictions to 5 kb and 1000\degC. \emph{Geochim. Cosmochim. Acta} \bold{52}, 2009--2036. \url{https://doi.org/10.1016/0016-7037(88)90181-0} - Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} + Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \degC and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} Tanger, J. C. IV and Helgeson, H. C. (1988) Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Revised equations of state for the standard partial molal properties of ions and electrolytes. \emph{Am. J. Sci.} \bold{288}, 19--98. \url{https://doi.org/10.2475/ajs.288.1.19} Modified: pkg/CHNOSZ/man/eqdata.Rd =================================================================== --- pkg/CHNOSZ/man/eqdata.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/eqdata.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -29,7 +29,7 @@ } - The result of the function is a data frame (returned invisibly), with columns \code{zi} (reaction progress), \code{T} (temperature in \eqn{^{\circ}}{?}C), \code{aH2O} (activity of water) and one column for each of the requested \code{species} or, for speciation of basis species, one column for each unique species found in all of the speciation summary blocks for that basis species. Values are listed as NA (not available) for species or phases that are not present in the EQ6 output at any of the increments of reaction progress. + The result of the function is a data frame (returned invisibly), with columns \code{zi} (reaction progress), \code{T} (temperature in \degC, \code{aH2O} (activity of water) and one column for each of the requested \code{species} or, for speciation of basis species, one column for each unique species found in all of the speciation summary blocks for that basis species. Values are listed as NA (not available) for species or phases that are not present in the EQ6 output at any of the increments of reaction progress. If \code{outfile} is TRUE, the result is saved in a file named like \samp{file}.\samp{property}.\code{csv}, in the same directory as \code{file}. The name of the \code{outfile} can be provided to override this naming scheme, or this argument can be set to FALSE or NULL, to turn off writing the result to a file. Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -92,7 +92,7 @@ Schulte, M. D. and Shock, E. L. (1995) Thermodynamics of Strecker synthesis in hydrothermal systems. \emph{Orig. Life Evol. Biosph.} \bold{25}, 161--173. \url{https://doi.org/10.1007/BF01581580} -Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} +Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \degC and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} Stumm, W. and Morgan, J. J. (1996) \emph{Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters}, John Wiley & Sons, New York, 1040 p. \url{http://www.worldcat.org/oclc/31754493} Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/extdata.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -35,12 +35,12 @@ Files in \code{cpetc} contain experimental and calculated thermodynamic and environmental data: \itemize{ - \item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Temperature in \eqn{^{\circ}}{?}C 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 \code{anintro.Rmd} for examples that uses this file. + \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 \code{anintro.Rmd} for examples that uses 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{RT71.csv} pH titration measurements for unfolded lysozyme (\samp{LYSC_CHICK}) taken from Roxby and Tanford, 1971. pH is in the first column, net charge in the second. See \code{\link{ionize.aa}} 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. Data were extracted from the figure using g3data (\url{http://www.frantz.fi/software/g3data.php}). 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 \code{eos-regress.Rmd} for examples that use these files. - \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{?}C), 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 \code{anintro.Rmd} for an example that uses this file. + \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 \code{anintro.Rmd} 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 \code{anintro.Rmd} 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 \code{anintro.Rmd} for an example that uses this file. } @@ -153,7 +153,7 @@ Shock, E. and Canovas, P. (2010) The potential for abiotic organic synthesis and biosynthesis at seafloor hydrothermal systems. \emph{Geofluids} \bold{10}, 161--192. \url{https://doi.org/10.1111/j.1468-8123.2010.00277.x} -Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} +Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \degC and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} Shock, E. L. and Schulte, M. D. (1998) Organic synthesis during fluid mixing in hydrothermal systems. \emph{J. Geophys. Res.} \bold{103}, 28513--28527. \url{https://doi.org/10.1029/98JE02142} Modified: pkg/CHNOSZ/man/ionize.aa.Rd =================================================================== --- pkg/CHNOSZ/man/ionize.aa.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/ionize.aa.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -14,8 +14,8 @@ \arguments{ \item{aa}{data frame, amino acid composition in the format of \code{thermo$protein}} \item{property}{character, property to calculate} - \item{T}{numeric, temperature in \eqn{^{\circ}}{?}C} - \item{P}{numeric, pressure in bar, or \samp{Psat} for vapor pressure of \H2O above 100 \eqn{^{\circ}}{?}C} + \item{T}{numeric, temperature in \degC} + \item{P}{numeric, pressure in bar, or \samp{Psat} for vapor pressure of \H2O above 100 \degC} \item{pH}{numeric, pH} \item{ret.val}{character, return the indicated value from intermediate calculations} \item{suppress.Cys}{logical, suppress (ignore) the ionization of the cysteine groups?} Modified: pkg/CHNOSZ/man/protein.info.Rd =================================================================== --- pkg/CHNOSZ/man/protein.info.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/protein.info.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -29,7 +29,7 @@ \item{regexp}{logical, find matches using regular expressions?} \item{normalize}{logical, return per-residue values (those of the proteins divided by their lengths)?} \item{state}{character, physical state} - \item{T}{numeric, temperature in \eqn{^{\circ}}{?}C} + \item{T}{numeric, temperature in \degC} \item{loga.protein}{numeric, decimal logarithms of reference activities of proteins} \item{digits}{integer, number of significant digits (see \code{\link{signif}})} } Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-12 08:21:01 UTC (rev 252) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-12 09:10:59 UTC (rev 253) @@ -82,7 +82,7 @@ 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. \code{subcrt} is modeled after the functionality of the \acronym{SUPCRT92} package (Johnson et al., 1992). [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 253 From noreply at r-forge.r-project.org Thu Oct 12 16:56:09 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 12 Oct 2017 16:56:09 +0200 (CEST) Subject: [CHNOSZ-commits] r254 - in pkg/CHNOSZ: . R data demo inst man tests/testthat vignettes Message-ID: <20171012145609.5AA6818848A@r-forge.r-project.org> Author: jedick Date: 2017-10-12 16:56:08 +0200 (Thu, 12 Oct 2017) New Revision: 254 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/nonideal.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/data/opt.csv pkg/CHNOSZ/demo/ORP.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/tests/testthat/test-affinity.R pkg/CHNOSZ/tests/testthat/test-nonideal.R pkg/CHNOSZ/vignettes/anintro.Rmd Log: nonideal(): add 'Helgeson' method Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-12 14:56:08 UTC (rev 254) @@ -1,6 +1,6 @@ Date: 2017-10-12 Package: CHNOSZ -Version: 1.1.0-52 +Version: 1.1.0-53 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/nonideal.R =================================================================== --- pkg/CHNOSZ/R/nonideal.R 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/R/nonideal.R 2017-10-12 14:56:08 UTC (rev 254) @@ -3,14 +3,24 @@ # moved to nonideal.R from util.misc.R 20151107 # added Helgeson method 20171012 -nonideal <- function(species, proptable, IS, T, P) { - thermo <- get("thermo") +nonideal <- function(species, speciesprops, IS, T, P, A_DH, B_DH, method=get("thermo")$opt$nonideal) { # generate nonideal contributions to thermodynamic properties - # number of species, same length as proptable list - # T in Kelvin, same length as nrows of proptables + # number of species, same length as speciesprops list + # T in Kelvin, same length as nrows of speciespropss + # arguments P, A_DH, B_DH are needed for Helgeson method only + # we can use this function to change the nonideal method option + if(identical(species, "Helgeson") | identical(species, "Alberty")) { + thermo <- get("thermo") + oldnon <- thermo$opt$nonideal + thermo$opt$nonideal <- species + assign("thermo", thermo, "CHNOSZ") + message("nonideal: setting method option to ", species) + return(invisible(oldnon)) + } + # function to calculate extended Debye-Huckel equation and derivatives using Alberty's parameters - Alberty <- function(Z, I, T, prop = "log") { + Alberty <- function(Z, I, T, prop = "loggamma") { # extended Debye-Huckel equation ("log") # and its partial derivatives ("G","H","S","Cp") # T in Kelvin @@ -29,7 +39,7 @@ loggamma <- function(a, Z, I, B) - a * Z^2 * I^(1/2) / (1 + B * I^(1/2)) # TODO: check the following equations 20080208 jmd R <- 1.9872 # gas constant, cal K^-1 mol^-1 - if(prop=="log") return(loggamma(eval(A), Z, I, B)) + if(prop=="loggamma") return(loggamma(eval(A), Z, I, B)) else if(prop=="G") return(R * T * loggamma(eval(A), Z, I, B)) else if(prop=="H") return(R * T^2 * loggamma(eval(DD(A, "T", 1)), Z, I, B)) else if(prop=="S") return(- R * T * loggamma(eval(DD(A, "T", 1)), Z, I, B)) @@ -37,21 +47,27 @@ } # function for Debye-Huckel equation with B-dot extended term parameter (Helgeson, 1969) - Helgeson <- function() { - # "distance of closest approach" of ions in NaCl solutions - # HKF81 Table 2 - acirc <- 3.72 # Angstrom + Helgeson <- function(Z, I, T, P, A_DH, B_DH, prop = "loggamma") { + # "distance of closest approach" of ions in NaCl solutions (HKF81 Table 2) + acirc <- 3.72e-8 # cm + loggamma <- - A_DH * Z^2 * I^0.5 / (1 + acirc * B_DH * I^0.5) + Bdot * I + R <- 1.9872 # gas constant, cal K^-1 mol^-1 + if(prop=="loggamma") return(loggamma) + else if(prop=="G") return(R * T * loggamma) } + # get B-dot if we're using the Helgeson method + if(method=="Helgeson") Bdot <- Bdot(convert(T, "C"), P) + # get species indices if(!is.numeric(species[[1]])) species <- info(species, "aq") iH <- info("H+") ie <- info("e-") - proptable <- as.list(proptable) + speciesprops <- as.list(speciesprops) ndid <- 0 # loop over species for(i in 1:length(species)) { - myprops <- proptable[[i]] + myprops <- speciesprops[[i]] # get the charge from the chemical formula # force a charge count even if it's zero mkp <- makeup(c("Z0", species[i]), sum=TRUE) @@ -64,18 +80,26 @@ didit <- FALSE for(j in 1:ncol(myprops)) { pname <- colnames(myprops)[j] - if(pname %in% c("G", "H", "S", "Cp")) { - myprops[,j] <- myprops[,j] + Alberty(Z, IS, T, pname) + if(method=="Alberty" & pname %in% c("G", "H", "S", "Cp")) { + myprops[, j] <- myprops[, j] + Alberty(Z, IS, T, pname) didit <- TRUE + } else if(method=="Helgeson" & pname %in% c("G", "H", "S", "Cp")) { + myprops[, j] <- myprops[, j] + Helgeson(Z, IS, T, P, A_DH, B_DH, pname) + didit <- TRUE } } # append a loggam column if we did any nonideal calculations of thermodynamic properties - if(didit) myprops <- cbind(myprops, loggam = Alberty(Z, IS, T)) - proptable[[i]] <- myprops + if(didit) { + if(method=="Alberty") myprops <- cbind(myprops, loggam = Alberty(Z, IS, T)) + else if(method=="Helgeson") { + myprops <- cbind(myprops, loggam = Helgeson(Z, IS, T, P, A_DH, B_DH)) + } + } + speciesprops[[i]] <- myprops if(didit) ndid <- ndid + 1 } if(ndid > 0) message(paste("nonideal:", ndid, "species were nonideal")) - return(proptable) + return(speciesprops) } Bdot <- function(TC = 25, P = 1, showsplines = "") { @@ -104,7 +128,7 @@ # values for Bdot x 100 from Helgeson (1969), Figure (P = Psat) if(!isoP | showsplines != "") { T0 <- c(23.8, 49.4, 98.9, 147.6, 172.6, 197.1, 222.7, 248.1, 268.7) - B0 <- c(4.07, 4.27, 4.30, 4.62, 4.86, 4.73, 4.09, 3.61, 1.56) + B0 <- c(4.07, 4.27, 4.30, 4.62, 4.86, 4.73, 4.09, 3.61, 1.56) / 100 # we could use the values from Hel69 Table 2 but extrapolation of the # their fitted spline function turns sharply upward above 300 degC #T0a <- c(25, 50, 100, 150, 200, 250, 270, 300) @@ -114,39 +138,39 @@ # values for bgamma x 100 from Helgeson et al., 1981 Table 27 if(is500 | !isoP | showsplines != "") { T0.5 <- seq(0, 400, 25) - B0.5 <- c(5.6, 7.1, 7.8, 8.0, 7.8, 7.5, 7.0, 6.4, 5.7, 4.8, 3.8, 2.6, 1.0, -1.2, -4.1, -8.4, -15.2) + B0.5 <- c(5.6, 7.1, 7.8, 8.0, 7.8, 7.5, 7.0, 6.4, 5.7, 4.8, 3.8, 2.6, 1.0, -1.2, -4.1, -8.4, -15.2) / 100 S0.5 <- splinefun(T0.5, B0.5) if(is500) return(S0.5(T)) } if(is1000 | !isoP | showsplines != "") { T1 <- seq(0, 500, 25) - B1 <- c(6.6, 7.7, 8.7, 8.3, 8.2, 7.9, 7.5, 7.0, 6.5, 5.9, 5.2, 4.4, 3.5, 2.5, 1.1, -0.6, -2.8, -5.7, -9.3, -13.7, -19.2) + B1 <- c(6.6, 7.7, 8.7, 8.3, 8.2, 7.9, 7.5, 7.0, 6.5, 5.9, 5.2, 4.4, 3.5, 2.5, 1.1, -0.6, -2.8, -5.7, -9.3, -13.7, -19.2) / 100 S1 <- splinefun(T1, B1) if(is1000) return(S1(T)) } if(is2000 | !isoP | showsplines != "") { # 550 and 600 degC points from Manning et al., 2013 Fig. 11 T2 <- c(seq(0, 500, 25), 550, 600) - B2 <- c(7.4, 8.3, 8.8, 8.9, 8.9, 8.7, 8.5, 8.1, 7.8, 7.4, 7.0, 6.6, 6.2, 5.8, 5.2, 4.6, 3.8, 2.9, 1.8, 0.5, -1.0, -3.93, -4.87) + B2 <- c(7.4, 8.3, 8.8, 8.9, 8.9, 8.7, 8.5, 8.1, 7.8, 7.4, 7.0, 6.6, 6.2, 5.8, 5.2, 4.6, 3.8, 2.9, 1.8, 0.5, -1.0, -3.93, -4.87) / 100 S2 <- splinefun(T2, B2) if(is2000) return(S2(T)) } if(is3000 | !isoP | showsplines != "") { T3 <- seq(0, 500, 25) - B3 <- c(6.5, 8.3, 9.2, 9.6, 9.7, 9.6, 9.4, 9.3, 9.2, 9.0, 8.8, 8.6, 8.3, 8.1, 7.8, 7.5, 7.1, 6.6, 6.0, 5.4, 4.8) + B3 <- c(6.5, 8.3, 9.2, 9.6, 9.7, 9.6, 9.4, 9.3, 9.2, 9.0, 8.8, 8.6, 8.3, 8.1, 7.8, 7.5, 7.1, 6.6, 6.0, 5.4, 4.8) / 100 S3 <- splinefun(T3, B3) if(is3000) return(S3(T)) } if(is4000 | !isoP | showsplines != "") { T4 <- seq(0, 500, 25) - B4 <- c(4.0, 7.7, 9.5, 10.3, 10.7, 10.8, 10.8, 10.8, 10.7, 10.6, 10.5, 10.4, 10.3, 10.2, 10.0, 9.8, 9.6, 9.3, 8.9, 8.5, 8.2) + B4 <- c(4.0, 7.7, 9.5, 10.3, 10.7, 10.8, 10.8, 10.8, 10.7, 10.6, 10.5, 10.4, 10.3, 10.2, 10.0, 9.8, 9.6, 9.3, 8.9, 8.5, 8.2) / 100 S4 <- splinefun(T4, B4) if(is4000) return(S4(T)) } if(is5000 | !isoP | showsplines != "") { # 550 and 600 degC points from Manning et al., 2013 Fig. 11 T5 <- c(seq(0, 500, 25), 550, 600) - B5 <- c(0.1, 6.7, 9.6, 11.1, 11.8, 12.2, 12.4, 12.4, 12.4, 12.4, 12.4, 12.3, 12.3, 12.2, 12.1, 11.9, 11.8, 11.5, 11.3, 11.0, 10.8, 11.2, 12.52) + B5 <- c(0.1, 6.7, 9.6, 11.1, 11.8, 12.2, 12.4, 12.4, 12.4, 12.4, 12.4, 12.3, 12.3, 12.2, 12.1, 11.9, 11.8, 11.5, 11.3, 11.0, 10.8, 11.2, 12.52) / 100 S5 <- splinefun(T5, B5) if(is5000) return(S5(T)) } @@ -154,44 +178,44 @@ # here, one control point at 10 degC is added to make the splines curve down at low T if(is10000 | !isoP | showsplines != "") { T10 <- c(25, seq(300, 1000, 50)) - B10 <- c(12, 17.6, 17.8, 18, 18.2, 18.9, 21, 23.3, 26.5, 28.8, 31.4, 34.1, 36.5, 39.2, 41.6, 44.1) + B10 <- c(12, 17.6, 17.8, 18, 18.2, 18.9, 21, 23.3, 26.5, 28.8, 31.4, 34.1, 36.5, 39.2, 41.6, 44.1) / 100 S10 <- splinefun(T10, B10) if(is10000) return(S10(T)) } if(is20000 | !isoP | showsplines != "") { T20 <- c(25, seq(300, 1000, 50)) - B20 <- c(16, 21.2, 21.4, 22, 22.4, 23.5, 26.5, 29.2, 32.6, 35.2, 38.2, 41.4, 44.7, 47.7, 50.5, 53.7) + B20 <- c(16, 21.2, 21.4, 22, 22.4, 23.5, 26.5, 29.2, 32.6, 35.2, 38.2, 41.4, 44.7, 47.7, 50.5, 53.7) / 100 S20 <- splinefun(T20, B20) if(is20000) return(S20(T)) } if(is30000 | !isoP | showsplines != "") { T30 <- c(25, seq(300, 1000, 50)) - B30 <- c(19, 23.9, 24.1, 24.6, 25.2, 26.7, 30.3, 32.9, 36.5, 39.9, 43, 46.4, 49.8, 53.2, 56.8, 60) + B30 <- c(19, 23.9, 24.1, 24.6, 25.2, 26.7, 30.3, 32.9, 36.5, 39.9, 43, 46.4, 49.8, 53.2, 56.8, 60) / 100 S30 <- splinefun(T30, B30) if(is30000) return(S30(T)) } # 40-60 kb points extrapolated from 10-30 kb points of Manning et al., 2013 if(is40000 | !isoP | showsplines != "") { T40 <- c(seq(300, 1000, 50)) - B40 <- c(25.8, 26, 26.4, 27.2, 28.9, 33, 35.5, 39.2, 43.2, 46.4, 49.9, 53.4, 57.1, 61.2, 64.4) + B40 <- c(25.8, 26, 26.4, 27.2, 28.9, 33, 35.5, 39.2, 43.2, 46.4, 49.9, 53.4, 57.1, 61.2, 64.4) / 100 S40 <- splinefun(T40, B40) if(is40000) return(S40(T)) } if(is50000 | !isoP | showsplines != "") { T50 <- c(seq(300, 1000, 50)) - B50 <- c(27.1, 27.3, 27.7, 28.5, 30.5, 34.8, 37.3, 41.1, 45.5, 48.7, 52.4, 55.9, 59.8, 64.3, 67.5) + B50 <- c(27.1, 27.3, 27.7, 28.5, 30.5, 34.8, 37.3, 41.1, 45.5, 48.7, 52.4, 55.9, 59.8, 64.3, 67.5) / 100 S50 <- splinefun(T50, B50) if(is50000) return(S50(T)) } if(is60000 | !isoP | showsplines != "") { T60 <- c(seq(300, 1000, 50)) - B60 <- c(28, 28.2, 28.6, 29.5, 31.6, 36.1, 38.6, 42.5, 47.1, 50.4, 54.1, 57.6, 61.6, 66.5, 69.7) + B60 <- c(28, 28.2, 28.6, 29.5, 31.6, 36.1, 38.6, 42.5, 47.1, 50.4, 54.1, 57.6, 61.6, 66.5, 69.7) / 100 S60 <- splinefun(T60, B60) if(is60000) return(S60(T)) } # show points and spline(T) curves if(showsplines == "T") { - thermo.plot.new(c(0, 1000), c(-20, 70), xlab=axis.label("T"), ylab=expression(b[gamma]%*%100)) + thermo.plot.new(c(0, 1000), c(-.2, .7), xlab=axis.label("T"), ylab=expression(b[gamma])) points(T0, B0, pch=0) points(T0.5, B0.5, pch=1) points(T1, B1, pch=1) @@ -229,12 +253,11 @@ legend("bottomright", col=c(NA, rev(col)), lty=1, legend=c("kbar", "60", "50", "40", "30", "20", "10", "5", "4", "3", "2", "1", "0.5", "Psat")) } else if(showsplines=="P") { - #thermo.plot.new(c(0, 60000), c(-20, 70), xlab=axis.label("P"), ylab=expression(b[gamma]%*%100)) - thermo.plot.new(c(0, 5), c(-20, 70), xlab="log P", ylab=expression(b[gamma]%*%100)) + thermo.plot.new(c(0, 5), c(-.2, .7), xlab="log P(bar)", ylab=expression(b[gamma])) # pressures that are used to make the isothermal splines (see below) P25 <- c(1, 500, 1000, 2000, 3000, 4000, 5000) P100 <- c(1, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000) - P200 <- c(15, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000) + P200 <- c(16, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000) P300 <- c(86, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) P400 <- c(500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) P500 <- c(1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 60000) @@ -244,30 +267,30 @@ P900 <- c(10000, 20000, 30000, 40000, 50000, 60000) P1000 <- c(10000, 20000, 30000, 40000, 50000, 60000) # plot the pressure and B-dot values used to make the isothermal splines - points(log10(P25), Bdot(25, P25) * 100) - points(log10(P100), Bdot(100, P100) * 100) - points(log10(P200), Bdot(200, P200) * 100) - points(log10(P300), Bdot(300, P300) * 100) - points(log10(P400), Bdot(400, P400) * 100) - points(log10(P500), Bdot(500, P500) * 100) - points(log10(P600), Bdot(600, P600) * 100) - points(log10(P700), Bdot(700, P700) * 100) - points(log10(P800), Bdot(800, P800) * 100) - points(log10(P900), Bdot(900, P900) * 100) - points(log10(P1000), Bdot(1000, P1000) * 100) + points(log10(P25), Bdot(25, P25)) + points(log10(P100), Bdot(100, P100)) + points(log10(P200), Bdot(200, P200)) + points(log10(P300), Bdot(300, P300)) + points(log10(P400), Bdot(400, P400)) + points(log10(P500), Bdot(500, P500)) + points(log10(P600), Bdot(600, P600)) + points(log10(P700), Bdot(700, P700)) + points(log10(P800), Bdot(800, P800)) + points(log10(P900), Bdot(900, P900)) + points(log10(P1000), Bdot(1000, P1000)) # plot the isothermal spline functions col <- tail(rev(rainbow(12)), -1) - P <- c(1, seq(50, 5000, 50)); lines(log10(P), Bdot(25, P) * 100, col=col[1]) - P <- c(1, seq(50, 20000, 50)); lines(log10(P), Bdot(100, P) * 100, col=col[2]) - P <- c(1, seq(50, 40000, 50)); lines(log10(P), Bdot(200, P) * 100, col=col[3]) - P <- c(1, seq(50, 60000, 50)); lines(log10(P), Bdot(300, P) * 100, col=col[4]) - P <- seq(500, 60000, 50); lines(log10(P), Bdot(400, P) * 100, col=col[5]) - P <- seq(1000, 60000, 50); lines(log10(P), Bdot(500, P) * 100, col=col[6]) - P <- seq(2000, 60000, 50); lines(log10(P), Bdot(600, P) * 100, col=col[7]) - P <- seq(10000, 60000, 50); lines(log10(P), Bdot(700, P) * 100, col=col[8]) - P <- seq(10000, 60000, 50); lines(log10(P), Bdot(800, P) * 100, col=col[9]) - P <- seq(10000, 60000, 50); lines(log10(P), Bdot(900, P) * 100, col=col[10]) - P <- seq(10000, 60000, 50); lines(log10(P), Bdot(1000, P) * 100, col=col[11]) + P <- c(1, seq(50, 5000, 50)); lines(log10(P), Bdot(25, P), col=col[1]) + P <- c(1, seq(50, 20000, 50)); lines(log10(P), Bdot(100, P), col=col[2]) + P <- c(1, seq(50, 40000, 50)); lines(log10(P), Bdot(200, P), col=col[3]) + P <- c(1, seq(50, 60000, 50)); lines(log10(P), Bdot(300, P), col=col[4]) + P <- seq(500, 60000, 50); lines(log10(P), Bdot(400, P), col=col[5]) + P <- seq(1000, 60000, 50); lines(log10(P), Bdot(500, P), col=col[6]) + P <- seq(2000, 60000, 50); lines(log10(P), Bdot(600, P), col=col[7]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(700, P), col=col[8]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(800, P), col=col[9]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(900, P), col=col[10]) + P <- seq(10000, 60000, 50); lines(log10(P), Bdot(1000, P), col=col[11]) legend("topleft", col=c(NA, col), lty=1, legend=c("degrees C", 25, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000)) legend("bottomright", pch=1, legend="points from iso-P splines") } else { @@ -316,7 +339,7 @@ # remember this T; if it's the same as the next one, we won't re-make the spline lastT <- T[i] } - Bdot <- c(Bdot, ST(P[i]) / 100) + Bdot <- c(Bdot, ST(P[i])) } } return(Bdot) Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-12 14:56:08 UTC (rev 254) @@ -466,10 +466,11 @@ iscgl <- iscgl.new isH2O <- isH2O.new - # the order of the properties - if(length(calcprop)>1) for(i in 1:length(out)) { - # keep state/loggam columns if they exists + # adjust the output order of the properties + for(i in 1:length(out)) { + # the calculated properties are first ipp <- match(calcprop, colnames(out[[i]])) + # move polymorph/loggam columns to end if('polymorph' %in% colnames(out[[i]])) ipp <- c(ipp,match('polymorph',colnames(out[[i]]))) if('loggam' %in% colnames(out[[i]])) ipp <- c(ipp,match('loggam',colnames(out[[i]]))) out[[i]] <- out[[i]][,ipp,drop=FALSE] @@ -492,9 +493,9 @@ # then to the user's units (outvert) from cal A <- outvert(convert(-A,'G',T=T),'cal') } - # the addition of properties + # loop over reaction coefficients for(i in 1:length(coeff)) { - # assemble state columns if they exist + # assemble polymorph columns separately if('polymorph' %in% colnames(out[[i]])) { sc <- as.data.frame(out[[i]]$polymorph) out[[i]] <- out[[i]][,-match('polymorph',colnames(out[[i]]))] @@ -502,13 +503,13 @@ if(is.null(morphcols)) morphcols <- sc else morphcols <- cbind(morphcols,sc) } - # include a zero loggam column if we need it - # for those species that are ideal + # include a zero loggam column if needed (for those species that are ideal) o.i <- out[[i]] if('loggam' %in% colnames(o.i)) if(!'loggam' %in% colnames(o)) o <- cbind(o,loggam=0) if('loggam' %in% colnames(o)) if(!'loggam' %in% colnames(o.i)) o.i <- cbind(o.i,loggam=0) + # the real addition of properties o <- o + o.i * coeff[i] } # output for reaction (stack on polymorph columns if exist) Modified: pkg/CHNOSZ/data/opt.csv =================================================================== --- pkg/CHNOSZ/data/opt.csv 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/data/opt.csv 2017-10-12 14:56:08 UTC (rev 254) @@ -1,2 +1,2 @@ -cutoff,E.units,T.units,P.units,state,water,G.tol,Cp.tol,V.tol,varP,IAPWS.sat,paramin,ideal.H,ideal.e -1E-10,cal,C,bar,aq,SUPCRT92,100,1,1,FALSE,liquid,1000,TRUE,TRUE +cutoff,E.units,T.units,P.units,state,water,G.tol,Cp.tol,V.tol,varP,IAPWS.sat,paramin,ideal.H,ideal.e,nonideal +1E-10,cal,C,bar,aq,SUPCRT92,100,1,1,FALSE,liquid,1000,TRUE,TRUE,Helgeson Modified: pkg/CHNOSZ/demo/ORP.R =================================================================== --- pkg/CHNOSZ/demo/ORP.R 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/demo/ORP.R 2017-10-12 14:56:08 UTC (rev 254) @@ -1,10 +1,12 @@ -# yell2010/orp.R 20100715 jmd +# CHNOSZ/demo/ORP.R +# first version 20100715 jmd + # calculate the temperature dependence of # potentials vs. standard hydrogen electrode (SHE) of various electrodes (Ag/AgCl) # and ORP standards (ZoBell, Light's, (tri)iodide) -# CHNOSZ provides functions subcrt() and convert() -# used in this example +# use the extended Debye-Huckel equation with Alberty's parameters +oldnon <- nonideal("Alberty") # Bard et al.'s fit to the potential # (Bard, Parson, Jordan, Standard Potentials In Aqueous Solution, 1985) @@ -167,3 +169,6 @@ # finally, make the plot figure() + +# reset the nonideality method to default +nonideal(oldnon) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/inst/NEWS 2017-10-12 14:56:08 UTC (rev 254) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-51 (2017-10-12) +CHANGES IN CHNOSZ 1.1.0-53 (2017-10-12) --------------------------------------- MAJOR CHANGES: @@ -19,7 +19,7 @@ - Usage of the DEW model is shown in the new demo DEW.R. This demo also depends on the Berman equations (above) and, for the last diagram, the - following two NEWS items: + following *two* NEWS items: - In equilibrate(), it is now possible to combine affinity calculations with changing activity of the balancing basis species (loga.balance). @@ -35,6 +35,11 @@ "percent carbon" plots for systems where the species have different carbon numbers. +- nonideal() now has two methods for calculating activity coefficients: + 'Helgeson', which utilizes the "B-dot" equation of Helgeson, 1969, + and 'Alberty' (the only method previously available). The 'Helgeson' + method depends on the following *two* NEWS items: + - All three water options (SUPCRT92, IAPWS95, DEW) can be used to calculate 'A_DH' and 'B_DH', i.e. A and B coefficients in the extended Debye-Huckel equation of Helgeson, 1969. Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-10-12 14:56:08 UTC (rev 254) @@ -4,34 +4,43 @@ \alias{Bdot} \title{Activity coefficients of aqueous species} \description{ -Calculate activity coefficients and non-ideal contributions to apparent standard molal properties of aqueous species. +Calculate activity coefficients and apparent (non-ideal) molal properties of aqueous species. } \usage{ - nonideal(species, proptable, IS, T) + nonideal(species, speciesprops, IS, T, P, A_DH, B_DH, method=get("thermo")$opt$nonideal) Bdot(TC, P, showsplines = "") } \arguments{ \item{species}{names or indices of species for which to calculate nonideal properties} - \item{proptable}{list of dataframes of species properties} + \item{speciesprops}{list of dataframes of species properties} \item{IS}{numeric, ionic strength(s) used in nonideal calculations, mol kg\eqn{^{-1}}{^-1}} \item{T}{numeric, temperature (K)} + \item{P}{numeric, pressure (bar); required for Helgeson method} + \item{A_DH}{numeric, A Debye-Huckel coefficient; required for Helgeson method} + \item{B_DH}{numeric, B Debye-Huckel coefficient; required for Helgeson method} + \item{method}{character, \samp{Alberty} or \samp{Helgeson}} \item{TC}{numeric, temperature (\degC)} - \item{P}{numeric, pressure (bar)} \item{showsplines}{character, show isobaric (\samp{T}) or isothermal (\samp{P}) splines} } \details{ -\code{nonideal} takes a list of dataframes (in \code{proptable}) containing the standard molal properties of the identified \code{species}. +\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 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 (H+) and electron (e-) are also bypassed by default; to apply the calculations to H+ and/or e-, change \code{\link{thermo}$opt$ideal.H} or \code{ideal.e} to FALSE. -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 lengths of \code{IS} and \code{T} supplied in the arguments should be equal to the number of rows of each dataframe in \code{proptable}, or one to use single values throughout. -The apparent molal properties that can be calculated include \code{G}, \code{H}, \code{S} and \code{Cp}; any columns in the dataframes of \code{proptable} with other names are left untouched. -A column named \code{loggam} (logarithm of gamma, the activity coefficient) is appended to the output dataframe of species properties. +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. -\code{Bdot} calculates the \dQuote{B-dot} deviation function (Helgeson, 1969) or extended term parameter (written as b_gamma; Helgeson et al., 1981) for activity coefficients in NaCl solutions at high temperature and pressure. +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{Helgeson}, the \dQuote{B-dot} equation (Helgeson, 1969; Helgeson et al., 1981; Manning, 2013) is used. +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. +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). + +\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). Furthermore, the 10 to 30 kb data were used to generate super-extrapolated values at 40, 50, and 60 kb, which may be encountered using the \code{\link{water.DEW}} calculations. If all \code{P} correspond to one of the isobaric conditions, the values of \code{Bdot} at \code{T} are calculated by spline fits to the isobaric data. @@ -46,51 +55,59 @@ Note that the first example below uses \code{loggam} returned by \code{subcrt}, therefore requiring a base of 10 for calculating gamma. } +\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). +For all affected species, a column named \code{loggam} (logarithm of gamma, the activity coefficient) is appended to the output dataframe of species properties. +} + \examples{\dontshow{data(thermo)} -### Examples following Alberty, 2003 +### Examples following Alberty, 2003 +### (page numbers given below) -## p. 273-276: activity coefficient (gamma) -## as a function of ionic strength and temperature +## the default method setting is Helgeson; +## change it to Alberty +oldnon <- nonideal("Alberty") + +## using nonideal() directly +# p. 273-276: activity coefficient (gamma) +# as a function of ionic strength and temperature +IS <- seq(0, 0.25, 0.005) T <- c(0, 25, 40) -col <- c("blue", "black", "red") -IS <- seq(0, 0.25, 0.0025) -thermo.plot.new(xlim=range(IS), ylim=c(0, 1), xlab=axis.label("IS"), ylab="gamma") +lty <- 1:3 +species <- c("H2PO4-", "HADP-2", "HATP-3", "ATP-4") +col <- rainbow(4) +thermo.plot.new(xlim = range(IS), ylim = c(0, 1), xlab = axis.label("IS"), ylab = "gamma") for(j in 1:3) { - s <- subcrt(c("H2PO4-", "HADP-2", "HATP-3", "ATP-4"), IS=IS, grid="IS", T=T[j]) - for(i in 1:4) lines(IS, 10^s$out[[i]]$loggam, col=col[j]) + # use subcrt to generate speciesprops + speciesprops <- subcrt(species, T = rep(T[j], length(IS)))$out + # use nonideal to calculate loggamma; this also adjusts G, H, S, Cp, but we don't use them here + nonidealprops <- nonideal(species, speciesprops, IS = IS, T = convert(T[j], "K")) + for(i in 1:4) lines(IS, exp(nonidealprops[[i]]$loggam), lty=lty[j], col=col[i]) } -text(0.125, 0.8, "Z = -1") -text(0.1, 0.42, "Z = -2") -text(0.075, 0.18, "Z = -3") -text(0.05, 0.08, "Z = -4") -title(main=paste("activity coefficient (gamma) of -1,-2,-3,-4", - "charged species at 0, 25, 40 deg C, after Alberty, 2003", - sep="\n"), cex.main=0.95) -legend("topright", lty=c(NA, 1, 1, 1), col=c(NA, "blue", "black", "red"), +t1 <- "activity coefficient (gamma) of -1,-2,-3,-4 charged species" +t2 <- quote("at 0, 25, and 40 "*degree*"C, after Alberty, 2003") +mtitle(as.expression(c(t1, t2))) +legend("topright", lty=c(NA, 1:3), bty="n", legend=c(as.expression(axis.label("T")), 0, 25, 40)) +legend("top", lty=1, col=col, bty="n", + legend = as.expression(lapply(species, expr.species))) -## p. 16 Table 1.3: apparent pKa of acetic acid with -## changing ionic strength -# we set this option to FALSE so that nonideal() will calculate activity -# coefficients for the proton (makes for better replication of the values -# in Alberty's book) +## 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 +# 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 -subcrt(c("acetic acid", "acetate", "H+"), c(-1, 1, 1), - IS=c(0, 0.1, 0.25), T=25, property="logK") -# note that *apparent* values equal *standard* values at IS=0 +(sres <- subcrt(c("acetate", "H+", "acetic acid"), c(-1, -1, 1), + IS=c(0, 0.1, 0.25), T=25, property="logK")) +# we're within 0.01 log of Alberty's pK values +Alberty_logK <- c(4.75, 4.54, 4.47) +stopifnot(maxdiff(sres$out$logK, Alberty_logK) < 0.01) # reset option to default thermo$opt$ideal.H <<- TRUE -## p. 95: basis and elemental stoichiometries of species -# (this example doesn't use activity coefficients) -basis(c("ATP-4", "H+", "H2O", "HPO4-2", "O2", "NH3")) -# cf Eq. 5.1-33: basis composition -species(c("ATP-4", "H+", "H2O", "HPO4-2", "ADP-3", "HATP-3", "HADP-2", - "H2PO4-")) - -### A different example - -# speciation of phosphate as a function of ionic strength +### An example using IS with affinity(): +## speciation of phosphate as a function of ionic strength opar <- par(mfrow=c(2, 1)) basis("CHNOPS+") Ts <- c(25, 100) @@ -99,21 +116,47 @@ a <- affinity(IS=c(0, 0.14), T=T) e <- equilibrate(a) if(T==25) diagram(e, ylim=c(-3.0, -2.6), legend.x=NULL) - else d <- diagram(e, ylim=c(-3.0, -2.6), add=TRUE, col="red") + else diagram(e, ylim=c(-3.0, -2.6), add=TRUE, col="red") } title(main="Non-ideality model for phosphate species") dp <- describe.property(c("pH", "T", "T"), c(7, Ts)) legend("topright", lty=c(NA, 1, 1), col=c(NA, "black", "red"), legend=dp) text(0.07, -2.76, expr.species("HPO4-2")) text(0.07, -2.90, expr.species("H2PO4-")) -# -# phosphate predominance f(IS,pH) +## phosphate predominance f(IS,pH) a <- affinity(IS=c(0, 0.14), pH=c(6, 13), T=Ts[1]) d <- diagram(a, fill=NULL) a <- affinity(IS=c(0, 0.14), pH=c(6, 13), T=Ts[2]) d <- diagram(a, add=TRUE, names=NULL, col="red") par(opar) + +### finished with Alberty equation, let's look at Helgeson +# this is the default setting, but is needed here because +# we set "Alberty" above +nonideal(oldnon) # same as nonideal("Helgeson") + +## activity coefficients for monovalent ions at 700 degC, 10 kbar +# after Manning, 2010, Fig. 7 +IS <- c(0.001, 0.01, 0.1, 1, 2, 2.79) +# we're above 5000 bar, so need to use IAPWS-95 or DEW +oldwat <- water("DEW") +wprop <- water(c("A_DH", "B_DH"), T=convert(700, "K"), P=10000) +water(oldwat) +# just use an empty table for a single species +speciesprops <- list(data.frame(G=rep(0, length(IS)))) +# choose any monovalent species +(nonidealprops <- nonideal("Na+", speciesprops, IS=IS, + T=convert(700, "K"), P=10000, A_DH=wprop$A_DH, B_DH=wprop$B_DH)) +# we get the nonideal Gibbs energy contribution and +# the activity coefficient; check values of the latter +Manning_gamma <- c(0.93, 0.82, 0.65, 0.76, 1.28, 2) +gamma <- 10^nonidealprops[[1]]$loggam +# we're getting progressively further from his values with +# higher IS; not sure why +stopifnot(maxdiff(gamma[1], Manning_gamma[1]) < 0.01) +stopifnot(maxdiff(gamma, Manning_gamma) < 0.23) + ## data and splines used for calculating B-dot ## (extended term parameter) Bdot(showsplines = "T") @@ -127,6 +170,8 @@ Helgeson, H. C., Kirkham, D. H. and Flowers, G. C. (1981) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600\degC and 5 Kb. \emph{Am. J. Sci.} \bold{281}, 1249--1516. \url{https://doi.org/10.2475/ajs.281.10.1249} +Manning, C. E. (2013) Thermodynamic modeling of fluid-rock interaction at mid-crustal to upper-mantle conditions. \emph{Rev. Mineral. Geochem.} \bold{76}, 135--164. \url{https://doi.org/10.2138/rmg.2013.76.5} + Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5} } Modified: pkg/CHNOSZ/man/water.Rd =================================================================== --- pkg/CHNOSZ/man/water.Rd 2017-10-12 09:10:59 UTC (rev 253) +++ pkg/CHNOSZ/man/water.Rd 2017-10-12 14:56:08 UTC (rev 254) @@ -170,7 +170,7 @@ [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 254 From noreply at r-forge.r-project.org Fri Oct 13 07:25:57 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 13 Oct 2017 07:25:57 +0200 (CEST) Subject: [CHNOSZ-commits] r255 - in pkg/CHNOSZ: . R demo inst man tests/testthat Message-ID: <20171013052557.45CAD1877CD@r-forge.r-project.org> Author: jedick Date: 2017-10-13 07:25:56 +0200 (Fri, 13 Oct 2017) New Revision: 255 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/nonideal.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/tests/testthat/test-nonideal.R Log: subcrt(): recognize 'Helgeson'/'Helgeson0' methods for activity coefficients Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-13 05:25:56 UTC (rev 255) @@ -1,6 +1,6 @@ -Date: 2017-10-12 +Date: 2017-10-13 Package: CHNOSZ -Version: 1.1.0-53 +Version: 1.1.0-54 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/nonideal.R =================================================================== --- pkg/CHNOSZ/R/nonideal.R 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/R/nonideal.R 2017-10-13 05:25:56 UTC (rev 255) @@ -7,15 +7,21 @@ # generate nonideal contributions to thermodynamic properties # number of species, same length as speciesprops list # T in Kelvin, same length as nrows of speciespropss - # arguments P, A_DH, B_DH are needed for Helgeson method only + # arguments P, A_DH, B_DH are needed for Helgeson/Helgeson0 methods only + mettext <- function(method) { + mettext <- paste(method, "method") + if(method=="Helgeson0") mettext <- "Helgeson method with B-dot = 0" + mettext + } + # we can use this function to change the nonideal method option - if(identical(species, "Helgeson") | identical(species, "Alberty")) { + if(identical(species, "Helgeson") | identical(species, "Helgeson0") | identical(species, "Alberty")) { thermo <- get("thermo") oldnon <- thermo$opt$nonideal thermo$opt$nonideal <- species assign("thermo", thermo, "CHNOSZ") - message("nonideal: setting method option to ", species) + message("nonideal: setting nonideal option to use ", mettext(species)) return(invisible(oldnon)) } @@ -39,7 +45,8 @@ loggamma <- function(a, Z, I, B) - a * Z^2 * I^(1/2) / (1 + B * I^(1/2)) # TODO: check the following equations 20080208 jmd R <- 1.9872 # gas constant, cal K^-1 mol^-1 - if(prop=="loggamma") return(loggamma(eval(A), Z, I, B)) + # 20171013 convert loggamma to common logarithm + if(prop=="loggamma") return(loggamma(eval(A), Z, I, B) / log(10)) else if(prop=="G") return(R * T * loggamma(eval(A), Z, I, B)) else if(prop=="H") return(R * T^2 * loggamma(eval(DD(A, "T", 1)), Z, I, B)) else if(prop=="S") return(- R * T * loggamma(eval(DD(A, "T", 1)), Z, I, B)) @@ -50,10 +57,12 @@ Helgeson <- function(Z, I, T, P, A_DH, B_DH, prop = "loggamma") { # "distance of closest approach" of ions in NaCl solutions (HKF81 Table 2) acirc <- 3.72e-8 # cm - loggamma <- - A_DH * Z^2 * I^0.5 / (1 + acirc * B_DH * I^0.5) + Bdot * I + if(method=="Helgeson") loggamma <- - A_DH * Z^2 * I^0.5 / (1 + acirc * B_DH * I^0.5) + Bdot * I + else if(method=="Helgeson0") loggamma <- - A_DH * Z^2 * I^0.5 / (1 + acirc * B_DH * I^0.5) R <- 1.9872 # gas constant, cal K^-1 mol^-1 if(prop=="loggamma") return(loggamma) - else if(prop=="G") return(R * T * loggamma) + else if(prop=="G") return(R * T * log(10) * loggamma) + # note the log(10) (=2.303) ... use natural logarithm to calculate G!!! } # get B-dot if we're using the Helgeson method @@ -83,7 +92,7 @@ if(method=="Alberty" & pname %in% c("G", "H", "S", "Cp")) { myprops[, j] <- myprops[, j] + Alberty(Z, IS, T, pname) didit <- TRUE - } else if(method=="Helgeson" & pname %in% c("G", "H", "S", "Cp")) { + } else if(grepl("Helgeson", method) & pname %in% c("G", "H", "S", "Cp")) { myprops[, j] <- myprops[, j] + Helgeson(Z, IS, T, P, A_DH, B_DH, pname) didit <- TRUE } @@ -91,14 +100,14 @@ # append a loggam column if we did any nonideal calculations of thermodynamic properties if(didit) { if(method=="Alberty") myprops <- cbind(myprops, loggam = Alberty(Z, IS, T)) - else if(method=="Helgeson") { + else if(grepl("Helgeson", method)) { myprops <- cbind(myprops, loggam = Helgeson(Z, IS, T, P, A_DH, B_DH)) } } speciesprops[[i]] <- myprops if(didit) ndid <- ndid + 1 } - if(ndid > 0) message(paste("nonideal:", ndid, "species were nonideal")) + if(ndid > 0) message("nonideal: calculated activity coefficients for ", ndid, " species (", mettext(method), ")") return(speciesprops) } Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-13 05:25:56 UTC (rev 255) @@ -56,10 +56,6 @@ # length checking if(do.reaction & length(species)!=length(coeff)) stop('coeff must be same length as the number of species.') - if(length(IS)>1) if(!identical(grid,'IS')) { - if(is.null(grid)) grid <- 'IS' - else stop('if you want length(IS) > 1, set grid=\'IS\'') - } if(!is.null(logact)) logact <- rep(logact,length.out=length(coeff)) # normalize temperature units if(!missing(T)) { @@ -100,6 +96,8 @@ # expansion of Psat and equivalence of argument lengths tpargs <- TP.args(T=T,P=P) T <- tpargs$T; P <- tpargs$P + if(length(newIS) > length(T)) T <- rep(T, length.out=length(newIS)) + if(length(newIS) > length(P)) P <- rep(P, length.out=length(newIS)) } # get species information @@ -181,8 +179,6 @@ isH2O <- reaction$name=='water' & reaction$state=='liq' isaq <- reaction$state=='aq' - #if(length(T)==1) T.text <- paste(T,units('T')) else T.text <- paste(length(T),'values of T') - #if(length(P)==1) P.text <- paste(P,units('P')) else P.text <- paste(length(P),'values of P') ut <- T if(identical(grid,'IS')) ut <- unique(ut) if(length(ut)==1) T.text <- paste(ut,'K') else { @@ -192,11 +188,10 @@ if(can.be.numeric(P)) P.text <- paste(round(as.numeric(P),2),'bar') else P.text <- "P" } else P.text <- 'P' - #} else P.text <- paste(length(P),'values of P') if(identical(P[[1]],'Psat')) P.text <- P if(any(c(isH2O,isaq))) P.text <- paste(P.text,' (wet)',sep='') if(length(species)==1 & convert==FALSE) { - # we don't think we want messages here + # no message produced here } else { message(paste('subcrt:',length(species),'species at',T.text,'and',P.text)) } @@ -280,12 +275,18 @@ si <- obigt2eos(thermo$obigt[inpho[isaq],], "aq", fixGHS = TRUE) # always get density H2O.props <- "rho" + # calculate A_DH and B_DH if we're using the B-dot (Helgeson) equation + if(any(IS != 0) & grepl("Helgeson", thermo$opt$nonideal)) H2O.props <- c(H2O.props, "A_DH", "B_DH") # get other properties for H2O only if it's in the reaction if(any(isH2O)) H2O.props <- c(H2O.props, eosprop) hkfstuff <- hkf(eosprop, parameters = si, T = T, P = P, H2O.props=H2O.props) p.aq <- hkfstuff$aq H2O.PT <- hkfstuff$H2O - if(any(IS != 0)) p.aq <- nonideal(inpho[isaq], p.aq, newIS, T) + # calculate activity coefficients if ionic strength is not zero + if(any(IS != 0)) { + if(grepl("Helgeson", thermo$opt$nonideal)) p.aq <- nonideal(inpho[isaq], p.aq, newIS, T, P, H2O.PT$A_DH, H2O.PT$B_DH) + else if(thermo$opt$nonideal=="Alberty") p.aq <- nonideal(inpho[isaq], p.aq, newIS, T) + } out <- c(out, p.aq) } else if(any(isH2O)) { # we're not using the HKF, but still want water @@ -544,13 +545,9 @@ } } } - # convert loggam to common logarithm and # put ionic strength next to any loggam columns for(i in 2:length(out)) { - if('loggam' %in% colnames(out[[i]])) { - out[[i]] <- cbind(out[[i]],IS=newIS) - out[[i]][, "loggam"] <- out[[i]][, "loggam"]/log(10) - } + if('loggam' %in% colnames(out[[i]])) out[[i]] <- cbind(out[[i]],IS=newIS) } # more fanagling for species if(!do.reaction) { Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-13 05:25:56 UTC (rev 255) @@ -139,7 +139,7 @@ T <- seq(600, 1000, 5) -## use DEW model +## activate DEW model data(thermo) water("DEW") # add species data for DEW @@ -167,12 +167,20 @@ ## add species species(c(inorganics, organics)) +## generate spline function for ionic strength +IS <- splinefun(seq(600, 1000, 100), c(0.39, 0.57, 0.88, 1.45, 2.49)) + +## use Debye-Huckel equation with B-dot set to zero +nonideal("Helgeson0") +## and calculate activity coefficient for the proton +thermo$opt$ideal.H <<- FALSE + ## calculate affinities on the T-logfO2 transect -a <- affinity(T=T, O2=QFM_2, P=50000) +a <- affinity(T=T, O2=QFM_2, P=50000, IS=IS(T)) ## use the total carbon molality as an approximation of total activity -molC <- splinefun(seq(600, 1000, 100), c(0.03, 0.2, 1, 4, 20))(T) -loga.C <- log10(molC) +molC <- splinefun(seq(600, 1000, 100), c(0.03, 0.2, 1, 4, 20)) +loga.C <- log10(molC(T)) ## calculate metastable equilibrium activities e <- equilibrate(a, loga.balance=loga.C) @@ -193,19 +201,27 @@ t2 <- "after Sverjensky et al., 2014b" mtitle(c(t1, t2)) -## additional checks -# check that we're within 0.1 of the QFM-2 values used by SSH14 +### additional checks + +## check that we're within 0.1 of the QFM-2 values used by SSH14 stopifnot(maxdiff(QFM_2[T %% 100 == 0], c(-17.0, -14.5, -12.5, -10.8, -9.4)) < 0.1) + # Here are the logKs of aqueous species dissociation reactions at 600 degC and 50000 bar, -# taken from the Supporting Information of the paper (p. 103-109): +# values from EQ3NR output in Supporting Information of the paper (p. 103-109): inorganic.logK <- c(24.4765, -9.0784, -5.3468, 0) organic.logK <- c(1.7878, 2.5648, 15.3182, 16.9743, 30.4088, 28.9185) # calculate equilibrium constants of the reactions in CHNOSZ; use a negative sign to change from formation to dissociation logK.calc <- -unlist(affinity(T=600, P=50000, property="logK")$values) logK.calc - c(inorganic.logK, organic.logK) -# check that we're within 0.021 of the logK values used by SSH14 +## check that we're within 0.021 of the logK values used by SSH14 stopifnot(maxdiff(logK.calc, c(inorganic.logK, organic.logK)) < 0.021) +## check that we get similar activity coefficients +# values for monovalent species from EQ3NR output +loggamma <- c(-0.15, -0.18, -0.22, -0.26, -0.31) +sres <- subcrt("propanoate", T=seq(600, 1000, 100), P=50000, IS=c(0.39, 0.57, 0.88, 1.45, 2.49)) +stopifnot(maxdiff(sres$out[[1]]$loggam, loggamma) < 0.004) + ########### ### all done! # reset the database and previous water computational option Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/inst/NEWS 2017-10-13 05:25:56 UTC (rev 255) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-53 (2017-10-12) +CHANGES IN CHNOSZ 1.1.0-54 (2017-10-13) --------------------------------------- MAJOR CHANGES: @@ -18,8 +18,8 @@ using water("DEW"), water("IAPWS"), etc. - Usage of the DEW model is shown in the new demo DEW.R. This demo also - depends on the Berman equations (above) and, for the last diagram, the - following *two* NEWS items: + depends on the Berman equations (above) and, for the last diagram in + the demo, the following *four* NEWS items: - In equilibrate(), it is now possible to combine affinity calculations with changing activity of the balancing basis species (loga.balance). @@ -35,10 +35,11 @@ "percent carbon" plots for systems where the species have different carbon numbers. -- nonideal() now has two methods for calculating activity coefficients: - 'Helgeson', which utilizes the "B-dot" equation of Helgeson, 1969, - and 'Alberty' (the only method previously available). The 'Helgeson' - method depends on the following *two* NEWS items: +- nonideal() now has three methods for calculating activity coefficients: + 'Helgeson' and 'Helgeson0', which utilize the "B-dot" equation of + Helgeson, 1969, and 'Alberty' (the only method previously available). + The 'Helgeson' method depends on the following *two* NEWS items (but + the 'Helgeson0' method omits the B-dot term): - All three water options (SUPCRT92, IAPWS95, DEW) can be used to calculate 'A_DH' and 'B_DH', i.e. A and B coefficients in the extended @@ -46,9 +47,9 @@ - Add Bdot() to calculate the "B-dot" (or b_gamma) extended term parameter for activity coefficients in NaCl solutions at high - temperature and pressure (Helgeson et al., 1981) including - high-pressure extrapolations > 10 kbar based on data from Manning et - al., 2013. + temperature and pressure (Helgeson et al., 1981), including + very high pressures (> 10 kbar) based on extrapolations from Manning + et al., 2013. - For minerals with phase transitions (states 'cr2' 'cr3' etc.) in thermo$obigt (i.e. the Helgeson minerals), it is now possible to use @@ -60,7 +61,7 @@ coesite. Calculations for other minerals still assume constant volume of each phase. -- calculations of the g function are now enabled for DEW (with +- Calculations of the g function are now enabled for DEW (with pressure derivative) and IAPWS-95 (no derivatives included). - water.lines() now works for diagrams of Eh, pe, logfO2, logaO2, Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-10-13 05:25:56 UTC (rev 255) @@ -20,7 +20,7 @@ \item{P}{numeric, pressure (bar); required for Helgeson method} \item{A_DH}{numeric, A Debye-Huckel coefficient; required for Helgeson method} \item{B_DH}{numeric, B Debye-Huckel coefficient; required for Helgeson method} - \item{method}{character, \samp{Alberty} or \samp{Helgeson}} + \item{method}{character, \samp{Alberty}, \samp{Helgeson}, or \samp{Helgeson0}} \item{TC}{numeric, temperature (\degC)} \item{showsplines}{character, show isobaric (\samp{T}) or isothermal (\samp{P}) splines} } @@ -35,9 +35,11 @@ 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{Helgeson}, the \dQuote{B-dot} equation (Helgeson, 1969; Helgeson et al., 1981; Manning, 2013) is used. +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. 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). \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. @@ -49,15 +51,9 @@ This is a crude method of kriging the data, but produces fairly smooth interpolations without adding any external dependencies. } -\section{Warning}{ -The logarithms of activity coefficients (\code{loggam}) returned by \code{nonideal} use the natural logarithm (cf. Alberty, 2003 Eq. 3.6-1). -To maintain consistency with the conventions used elsewhere in the package (i.e. for logarithms of equilibrium constants and of chemical activities), the values of \code{loggam} returned by \code{\link{subcrt}} are expressed using the common (base 10) logarithm. -Note that the first example below uses \code{loggam} returned by \code{subcrt}, therefore requiring a base of 10 for calculating gamma. -} - \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). -For all affected species, a column named \code{loggam} (logarithm of gamma, the activity coefficient) is appended to the output dataframe of species properties. +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. } \examples{\dontshow{data(thermo)} @@ -82,7 +78,7 @@ speciesprops <- subcrt(species, T = rep(T[j], length(IS)))$out # use nonideal to calculate loggamma; this also adjusts G, H, S, Cp, but we don't use them here nonidealprops <- nonideal(species, speciesprops, IS = IS, T = convert(T[j], "K")) - for(i in 1:4) lines(IS, exp(nonidealprops[[i]]$loggam), lty=lty[j], col=col[i]) + for(i in 1:4) lines(IS, 10^(nonidealprops[[i]]$loggam), lty=lty[j], col=col[i]) } t1 <- "activity coefficient (gamma) of -1,-2,-3,-4 charged species" t2 <- quote("at 0, 25, and 40 "*degree*"C, after Alberty, 2003") @@ -170,6 +166,8 @@ Helgeson, H. C., Kirkham, D. H. and Flowers, G. C. (1981) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600\degC and 5 Kb. \emph{Am. J. Sci.} \bold{281}, 1249--1516. \url{https://doi.org/10.2475/ajs.281.10.1249} +H?ckel, E. (1925). The theory of concentrated, aqueous solutions of strong electrolytes. \emph{Physikalische Zeitschrift} \bold{26}, 93--147. + Manning, C. E. (2013) Thermodynamic modeling of fluid-rock interaction at mid-crustal to upper-mantle conditions. \emph{Rev. Mineral. Geochem.} \bold{76}, 135--164. \url{https://doi.org/10.2138/rmg.2013.76.5} Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5} Modified: pkg/CHNOSZ/tests/testthat/test-nonideal.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-nonideal.R 2017-10-12 14:56:08 UTC (rev 254) +++ pkg/CHNOSZ/tests/testthat/test-nonideal.R 2017-10-13 05:25:56 UTC (rev 255) @@ -49,3 +49,25 @@ expect_maxdiff(DEW30$A_DH, A30, 0.06) expect_maxdiff(DEW30$B_DH / 1e8, B30, 0.024) }) + +#test_that("different methods give correct values of loggamma", { +# +#}) + +test_that("affinity transect incorporates IS correctly", { + basis("CHNOS+") + species("acetate") + # calculations at single combinations of logfO2 and IS + basis("O2", -80); a80_0 <- affinity() + basis("O2", -60); a60_1 <- affinity(IS=1) + # calculations on a transect with those endpoints + a <- affinity(O2=seq(-80, -60, length.out=4), IS=seq(0, 1, length.out=4)) + expect_equal(a$values[[1]][1], a80_0$values[[1]][1]) + expect_equal(a$values[[1]][4], a60_1$values[[1]][1]) + # 20171013: that was working fine, but how about a more complicated case involving T? + a25_0 <- affinity() + a50_1 <- affinity(T=50, IS=1) + a <- affinity(T=seq(25, 50, length.out=4), IS=seq(0, 1, length.out=4)) + expect_equal(a$values[[1]][1], a25_0$values[[1]][1]) + expect_equal(a$values[[1]][4], a50_1$values[[1]][1]) +}) From noreply at r-forge.r-project.org Fri Oct 13 09:31:39 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 13 Oct 2017 09:31:39 +0200 (CEST) Subject: [CHNOSZ-commits] r256 - in pkg/CHNOSZ: . R demo inst man Message-ID: <20171013073139.9F30A189227@r-forge.r-project.org> Author: jedick Date: 2017-10-13 09:31:38 +0200 (Fri, 13 Oct 2017) New Revision: 256 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/affinity.R pkg/CHNOSZ/R/nonideal.R pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/nonideal.Rd Log: affinity(): variables in arguments override buffers in thermo$basis Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-13 05:25:56 UTC (rev 255) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-13 07:31:38 UTC (rev 256) @@ -1,6 +1,6 @@ Date: 2017-10-13 Package: CHNOSZ -Version: 1.1.0-54 +Version: 1.1.0-55 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/affinity.R =================================================================== --- pkg/CHNOSZ/R/affinity.R 2017-10-13 05:25:56 UTC (rev 255) +++ pkg/CHNOSZ/R/affinity.R 2017-10-13 07:31:38 UTC (rev 256) @@ -7,6 +7,10 @@ #source("util.character.R") #source("util.list.R") #source("subcrt.R") +#source("buffer.R") +#source("util.args.R") +#source("util.data.R") +#source("species.R") affinity <- function(...,property=NULL,sout=NULL,exceed.Ttr=FALSE, return.buffer=FALSE,balance="PBB",iprotein=NULL,loga.protein=-3) { @@ -70,7 +74,10 @@ # buffer stuff buffer <- FALSE - ibufbasis <- which(!can.be.numeric(mybasis$logact)) + hasbuffer <- !can.be.numeric(mybasis$logact) + # however, variables specified in the arguments take precedence over the buffer 20171013 + isnotvar <- !rownames(mybasis) %in% args$vars + ibufbasis <- which(hasbuffer & isnotvar) if(!is.null(mybasis) & length(ibufbasis) > 0) { buffer <- TRUE message('affinity: loading buffer species') Modified: pkg/CHNOSZ/R/nonideal.R =================================================================== --- pkg/CHNOSZ/R/nonideal.R 2017-10-13 05:25:56 UTC (rev 255) +++ pkg/CHNOSZ/R/nonideal.R 2017-10-13 07:31:38 UTC (rev 256) @@ -62,7 +62,7 @@ R <- 1.9872 # gas constant, cal K^-1 mol^-1 if(prop=="loggamma") return(loggamma) else if(prop=="G") return(R * T * log(10) * loggamma) - # note the log(10) (=2.303) ... use natural logarithm to calculate G!!! + # note the log(10) (=2.303) ... use natural logarithm to calculate G } # get B-dot if we're using the Helgeson method Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-13 05:25:56 UTC (rev 255) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-13 07:31:38 UTC (rev 256) @@ -131,71 +131,52 @@ # T = 600, 700, 800, 900, 1000 degC # P = 5.0GPa (50000 bar) # fO2 = QFM - 2 -# pH set by jadeite + kyanite + coesite (approximated here as constant) -# output from EQ3 calculations: +# pH set by jadeite + kyanite + coesite +# output from EQ3NR calculations (SSH14 Supporting Information) # dissolved carbon: 0.03, 0.2, 1, 4, 20 molal # ionic strength: 0.39, 0.57, 0.88, 1.45, 2.49 -# activity coefficient (log gamma for singly charged species): -0.15, -0.18, -0.22, -0.26, -0.31 - +# pH: 3.80, 3.99, 4.14, 4.25, 4.33 T <- seq(600, 1000, 5) - ## activate DEW model data(thermo) water("DEW") # add species data for DEW inorganics <- c("methane", "CO2", "HCO3-", "CO3-2") organics <- c("formic acid", "formate", "acetic acid", "acetate", "propanoic acid", "propanoate") - # skip updating acetate because the new data from the DEW spreadsheet give different logK add.obigt("DEW", c(inorganics, organics[-4])) ## set basis species basis(c("Fe", "SiO2", "CO3-2", "H2O", "oxygen", "H+")) -# for the time being we use a constant pH -basis("H+", -4) - ## define a QFM buffer using Berman's equations for minerals mod.buffer("QFM_Berman", c("quartz", "fayalite", "magnetite"), "cr_Berman", 0) - -## calculate logfO2 as QFM minus 2 +## calculate logfO2 in QFM buffer basis("O2", "QFM_Berman") -a <- affinity(T=T, P=50000, return.buffer=TRUE) -QFM_2 <- a$O2 - 2 - -## now that we have QFM-2, remove QFM buffer for calculations below -basis("O2", 0) - +buf <- affinity(T=T, P=50000, return.buffer=TRUE) ## add species species(c(inorganics, organics)) - -## generate spline function for ionic strength -IS <- splinefun(seq(600, 1000, 100), c(0.39, 0.57, 0.88, 1.45, 2.49)) - +## generate spline functions from IS, pH, and molC values at every 100 degC +IS <- splinefun(T[!T%%100], c(0.39, 0.57, 0.88, 1.45, 2.49)) +pH <- splinefun(T[!T%%100], c(3.80, 3.99, 4.14, 4.25, 4.33)) +molC <- splinefun(T[!T%%100], c(0.03, 0.2, 1, 4, 20)) ## use Debye-Huckel equation with B-dot set to zero nonideal("Helgeson0") -## and calculate activity coefficient for the proton -thermo$opt$ideal.H <<- FALSE - -## calculate affinities on the T-logfO2 transect -a <- affinity(T=T, O2=QFM_2, P=50000, IS=IS(T)) - -## use the total carbon molality as an approximation of total activity -molC <- splinefun(seq(600, 1000, 100), c(0.03, 0.2, 1, 4, 20)) -loga.C <- log10(molC(T)) - -## calculate metastable equilibrium activities -e <- equilibrate(a, loga.balance=loga.C) - +## calculate affinities on the T-logfO2-pH-IS transect +a <- affinity(T=T, O2=buf$O2 - 2, IS=IS(T), pH=pH(T), P=50000) +## calculate metastable equilibrium activities using the total +## carbon molality as an approximation of total activity +e <- equilibrate(a, loga.balance=log10(molC(T))) ## make the diagram; don't plot names of low-abundance species names <- c(inorganics, organics) names[c(4, 5, 7, 9)] <- "" col <- rep("black", length(names)) col[c(1, 3, 6, 8, 10)] <- c("red", "darkgreen", "purple", "orange", "navyblue") -diagram(e, alpha="balance", names=names, col=col, ylim=c(0, 0.8)) +diagram(e, alpha="balance", ylab="carbon fraction", names=names, col=col, ylim=c(0, 0.8)) ## add legend and title ltxt1 <- "P = 50000 bar" ltxt2 <- substitute(logfO2=="QFM-2", list(logfO2=axis.label("O2"))) ltxt3 <- "pH = 4" +pH <- seq(3.8, 4.3, length.out=length(T)) legend("left", legend=as.expression(c(ltxt1, ltxt2, ltxt3)), bty="n") t1 <- "Aqueous carbon speciation" t2 <- "after Sverjensky et al., 2014b" @@ -217,8 +198,9 @@ stopifnot(maxdiff(logK.calc, c(inorganic.logK, organic.logK)) < 0.021) ## check that we get similar activity coefficients -# values for monovalent species from EQ3NR output +# activity coefficients for monovalent species from EQ3NR output loggamma <- c(-0.15, -0.18, -0.22, -0.26, -0.31) +# activity coefficients calculated in CHNOSZ sres <- subcrt("propanoate", T=seq(600, 1000, 100), P=50000, IS=c(0.39, 0.57, 0.88, 1.45, 2.49)) stopifnot(maxdiff(sres$out[[1]]$loggam, loggamma) < 0.004) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-13 05:25:56 UTC (rev 255) +++ pkg/CHNOSZ/inst/NEWS 2017-10-13 07:31:38 UTC (rev 256) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-54 (2017-10-13) +CHANGES IN CHNOSZ 1.1.0-55 (2017-10-13) --------------------------------------- MAJOR CHANGES: @@ -68,6 +68,9 @@ logfH2, or logaH2 vs pH, T, or P. It is possible to have T or P on either the x- or y-axis. +- Variables that are in the aguments to affinity() now override any + buffers previously specified using basis(). + DATABASE UPDATES: - Add data(OBIGT) command to reset only the thermodynamic database Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-10-13 05:25:56 UTC (rev 255) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-10-13 07:31:38 UTC (rev 256) @@ -29,7 +29,8 @@ \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 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 (H+) and electron (e-) are also bypassed by default; to apply the calculations to H+ and/or e-, change \code{\link{thermo}$opt$ideal.H} or \code{ideal.e} to FALSE. +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). From noreply at r-forge.r-project.org Sat Oct 14 09:02:09 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 14 Oct 2017 09:02:09 +0200 (CEST) Subject: [CHNOSZ-commits] r257 - in pkg/CHNOSZ: . demo inst Message-ID: <20171014070209.B04761886F2@r-forge.r-project.org> Author: jedick Date: 2017-10-14 09:02:09 +0200 (Sat, 14 Oct 2017) New Revision: 257 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/demo/lambda.R pkg/CHNOSZ/inst/NEWS Log: demo/lambda.R: calculate V using finite difference derivative (dGlambda/dP) Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-13 07:31:38 UTC (rev 256) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-14 07:02:09 UTC (rev 257) @@ -1,6 +1,6 @@ -Date: 2017-10-13 +Date: 2017-10-14 Package: CHNOSZ -Version: 1.1.0-55 +Version: 1.1.0-56 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-13 07:31:38 UTC (rev 256) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-14 07:02:09 UTC (rev 257) @@ -185,7 +185,7 @@ ### additional checks ## check that we're within 0.1 of the QFM-2 values used by SSH14 -stopifnot(maxdiff(QFM_2[T %% 100 == 0], c(-17.0, -14.5, -12.5, -10.8, -9.4)) < 0.1) +stopifnot(maxdiff((buf$O2-2)[!T%%100], c(-17.0, -14.5, -12.5, -10.8, -9.4)) < 0.1) # Here are the logKs of aqueous species dissociation reactions at 600 degC and 50000 bar, # values from EQ3NR output in Supporting Information of the paper (p. 103-109): Modified: pkg/CHNOSZ/demo/lambda.R =================================================================== --- pkg/CHNOSZ/demo/lambda.R 2017-10-13 07:31:38 UTC (rev 256) +++ pkg/CHNOSZ/demo/lambda.R 2017-10-14 07:02:09 UTC (rev 257) @@ -7,7 +7,8 @@ text(0.5, 0.5, "Effects of lambda transition in quartz, after Berman (1988) Figs. 1 and 2", cex=1.8) opar <- par(mar=c(4, 4.5, 1, 0.5), cex=0.8) -T <- convert(seq(0, 1400, 1), "K") +TC <- 0:1200 +T <- convert(TC, "K") labplot <- function(x) label.plot(x, xfrac=0.9, yfrac=0.1, paren=TRUE) # this sets the units used for making the axis labels @@ -19,25 +20,49 @@ # calculate properties at 1 kbar with and without transition Qz_1bar <- berman("quartz", T=T, units="J") Qz_1bar_notrans <- berman("quartz", T=T, calc.transition=FALSE, units="J") -# Fig. 1a: volume -plot(T, Qz_1bar$V, type="l", xlab=Tlab, ylab=Vlab, ylim=c(22.5, 24)) + +## Fig. 1a: volume +plot(TC, Qz_1bar$V, type="l", xlab=Tlab, ylab=Vlab, ylim=c(22.5, 24)) +# FIXME: why don't we get the curvature his plot for V shows? +# Should it be in the v4 parameter (but it's zero)?? +## add data points digitized from Fig. 3B of Helgeson et al., 1978 +## and Fig. 1a of Berman, 1988 +skinner <- list(T=c(550, 560, 570, 580, 590), V=c(23.44, 23.48, 23.54, 23.72, 23.72)) +robie <- list(T=575, V=23.72) +ghioroso <- list(T=c(0, 100, 200, 300, 400, 500, 575, 575, 675, 775, 875, 975), + V=c(22.7, 22.77, 22.85, 22.94, 23.1, 23.3, 23.5, 23.71, 23.69, 23.69, 23.71, 23.73)) +points(skinner$T, skinner$V, pch=19) +points(robie$T, robie$V) +points(ghioroso$T, ghioroso$V, pch=0) + +## calculate finite difference derivative of dGlambda/dP = Vlambda between 1 and 1.001 bar +Glambda_1bar <- Qz_1bar_notrans$G - Qz_1bar$G +Qz_1.001bar <- berman("quartz", T=T, P=1.001, units="J") +Qz_1.001bar_notrans <- berman("quartz", T=T, P=1.001, calc.transition=FALSE, units="J") +Glambda_1.001bar <- Qz_1.001bar_notrans$G - Qz_1.001bar$G +dGlambdadP <- (Glambda_1.001bar - Glambda_1bar) / 0.001 +# we're using Joules, so multiply by ten to get cm^3 +Vlambda <- -10 * dGlambdadP +VQz <- Qz_1bar$V + Vlambda +# above 848K, we have beta quartz +Qz_beta <- berman("quartz,beta", T=T, P=1, units="J") +VQz[T >= 848.15] <- Qz_beta$V[T >= 848.14] +lines(TC, VQz, lty=2) legend("topleft", legend="1 bar", bty="n") labplot("a") -# TODO: why don't we get the curvature his plot for V shows? -# Should it be in the v4 parameter (but it's zero)?? -# Fig. 1b: heat capacity -plot(T, Qz_1bar$Cp, type="l", xlab=Tlab, ylab=Cplab) -lines(T, Qz_1bar_notrans$Cp, lty=3) +## Fig. 1b: heat capacity +plot(TC, Qz_1bar$Cp, type="l", xlab=Tlab, ylab=Cplab) +lines(TC, Qz_1bar_notrans$Cp, lty=3) legend("topleft", legend="1 bar", bty="n") labplot("b") -# calculate properties at 10 kbar with and without transition +## calculate properties at 10 kbar with and without transition Qz_10bar <- berman("quartz", T=T, P=10000, units="J") Qz_10bar_notrans <- berman("quartz", T=T, P=10000, calc.transition=FALSE, units="J") -# Fig. 1c: heat capacity -plot(T, Qz_10bar$Cp, type="l", xlab=Tlab, ylab=Cplab) -lines(T, Qz_10bar_notrans$Cp, lty=3) +## Fig. 1c: heat capacity +plot(TC, Qz_10bar$Cp, type="l", xlab=Tlab, ylab=Cplab) +lines(TC, Qz_10bar_notrans$Cp, lty=3) legend("topleft", legend="10 kb", bty="n") labplot("c") Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-13 07:31:38 UTC (rev 256) +++ pkg/CHNOSZ/inst/NEWS 2017-10-14 07:02:09 UTC (rev 257) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-55 (2017-10-13) +CHANGES IN CHNOSZ 1.1.0-56 (2017-10-14) --------------------------------------- MAJOR CHANGES: @@ -7,7 +7,7 @@ thermodynamic properties of minerals using equations of Berman, 1988. - Calculations related to Berman's (1988) Figs. 1 and 2 for the lambda - transition of quartz are presented in the new demo lambda.R. + transition of quartz are available in the new demo lambda.R. - Add functions implementing the Deep Earth Water (DEW) model (Sverjensky et al., 2014): water.DEW() and its supporting functions @@ -22,11 +22,11 @@ the demo, the following *four* NEWS items: - In equilibrate(), it is now possible to combine affinity calculations - with changing activity of the balancing basis species (loga.balance). + with variable activity of the balancing basis species (loga.balance). For example, in the last plot of the DEW demo, the affinity transect involves simultaneously varying temperature and logfO2 (given as arguments to affinity()) as well as total concentration of carbon - (approximated by the loga.balance argument in equilibrate()). + (given by the loga.balance argument in equilibrate()). COMPUTATIONAL IMPROVEMENTS: @@ -35,15 +35,16 @@ "percent carbon" plots for systems where the species have different carbon numbers. -- nonideal() now has three methods for calculating activity coefficients: - 'Helgeson' and 'Helgeson0', which utilize the "B-dot" equation of - Helgeson, 1969, and 'Alberty' (the only method previously available). - The 'Helgeson' method depends on the following *two* NEWS items (but - the 'Helgeson0' method omits the B-dot term): +- nonideal() now has three methods for calculating activity + coefficients: 'Helgeson' and 'Helgeson0', which utilize the + Debye-Huckel equation with parameters as described by Helgeson, 1969, + and 'Alberty' (the only method previously available). The 'Helgeson' + method depends on the following *two* NEWS items (but the 'Helgeson0' + method omits the B-dot term): - All three water options (SUPCRT92, IAPWS95, DEW) can be used to calculate 'A_DH' and 'B_DH', i.e. A and B coefficients in the extended - Debye-Huckel equation of Helgeson, 1969. + Debye-Huckel equation as described by Helgeson, 1969. - Add Bdot() to calculate the "B-dot" (or b_gamma) extended term parameter for activity coefficients in NaCl solutions at high @@ -84,13 +85,14 @@ - add.obigt() gets new argument 'species' for selecting species to add. - Add DEW_aq.csv with aqueous species data from the DEW spreadsheet - (May 2017 version). Species with data unchanged from the default - database in CHNOSZ are not included. For the time being, only - selected species are fully referenced. + (May 2017 version). Species with data that do not differ from the + default database in CHNOSZ are not included. Currently, detailed + reference keys and descriptions (in thermo$refs) are given for + selected species only. - Add Berman_cr.csv with names and formulas for minerals whose - thermodynamic properties are calculated using the Berman 1988 - formulation. The state "cr_Berman" is used to distinguish these + thermodynamic properties are calculated using the Berman, 1988 + equations. The state "cr_Berman" is used to distinguish these minerals from the Helgeson data. The parameters themselves are stored in extdata/Berman/*.csv. @@ -114,24 +116,25 @@ OTHER CHANGES: - Add 'tol' argument to equil.reaction() (convergence tolerance for - uniroot). + uniroot()). - 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 + water at Pr and Tr and the logic for when to find derivatives of omega + are now calculated within the function, thereby simplifying the function call from subcrt(). - Add 'H2O.props' argument to hkf(). This lists the properties of water - to calculate (at P, T) so that the calculations aren't duplicated by - subcrt(). + to calculate (at P, T); these are now included in the results, in + order to avoid duplicating the calculations in subcrt(). - In water.* functions, rename the "diel" variable to "epsilon". -- Components of subcrt() output indicating the stable polymorph of a - mineral are now named 'polymorph', not 'state'. +- Components of subcrt() output indicating the stable polymorph of + minerals with phase transitions are now named 'polymorph', not + 'state'. - Add maxdiff() and expect_maxdiff() for calculating and testing the maximum absolute pairwise difference between two objects. From noreply at r-forge.r-project.org Sat Oct 14 17:09:28 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 14 Oct 2017 17:09:28 +0200 (CEST) Subject: [CHNOSZ-commits] r258 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20171014150928.44F221885EB@r-forge.r-project.org> Author: jedick Date: 2017-10-14 17:09:27 +0200 (Sat, 14 Oct 2017) New Revision: 258 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/obigt.Rmd Log: reduce size of obigt.html Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-14 07:02:09 UTC (rev 257) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-14 15:09:27 UTC (rev 258) @@ -1,6 +1,6 @@ Date: 2017-10-14 Package: CHNOSZ -Version: 1.1.0-56 +Version: 1.1.0-57 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-14 07:02:09 UTC (rev 257) +++ pkg/CHNOSZ/inst/NEWS 2017-10-14 15:09:27 UTC (rev 258) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-56 (2017-10-14) +CHANGES IN CHNOSZ 1.1.0-57 (2017-10-14) --------------------------------------- MAJOR CHANGES: @@ -14,7 +14,7 @@ calculateDensity(), calculateGibbsofWater(), calculateEpsilon(), calculateQ(). -- The computational setting for water (thermo$opt$par) can now be set +- The computational setting for water (thermo$opt$water) can now be set using water("DEW"), water("IAPWS"), etc. - Usage of the DEW model is shown in the new demo DEW.R. This demo also @@ -155,6 +155,11 @@ - Remove read.expr() and extdata/abundance/ISR+08.csv (protein abundance in E. coli). +- Reduce the size of obigt.html by ~450 KB. This was done by 1) using + rmarkdown with files in rmd/h/bootstrap-3.3.5/fonts/ replaced with + empty files (291 KB), and 2) changing the theme from "cosmo" to + "default" (151 KB). + CHANGES IN CHNOSZ 1.1.0 (2017-05-04) ------------------------------------ Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-14 07:02:09 UTC (rev 257) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-14 15:09:27 UTC (rev 258) @@ -1,11 +1,9 @@ --- title: "Thermodynamic data in [CHNOSZ](http://www.chnosz.net)" output: -# change to html_document for full version html_document: mathjax: null -# uncomment the next two lines for full version - theme: cosmo + theme: default css: obigt.css vignette: > %\VignetteIndexEntry{Thermodynamic data in CHNOSZ} @@ -15,8 +13,6 @@ # so that these appear in the bibliography nocite: | @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ, @JOH92, @WP02, @CWM89, @PRPG97, @TH88, @Kul06, @Sho09 -# 20170212: comment the csl line to build package on R-Forge, to avoid -# getting an error there (pandoc-citeproc: error while parsing the XML string) csl: elementa.csl --- @@ -125,17 +121,17 @@ # Recent additions (late 2017) -* Mineral data using the [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) equations are listed under **Solids** / **Berman**. +* Mineral data using the [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) equations are listed under [**Solids** / **Berman**](#berman-107). -* Aqueous species data intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under **Optional Data** / **DEW**. +* Aqueous species data intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under [**Optional Data** / **DEW**](#dew-199). -# Sources of data {.tabset .tabset-fade} +# Sources of data {.tabset .tabset-fade .tabset-sticky} Use the tabs below to select a section for viewing. Select "All at once" to show all sections. -## Aqueous species {.tabset .tabset-pills} +## Aqueous species {.tabset .tabset-pills .tabset-sticky} ### `r setfile("H2O_aq.csv")` ```{r H2O_aq, results="asis", echo=FALSE} @@ -181,7 +177,7 @@ ```{r reflist, results="asis", echo=FALSE} ``` -## Solids {.tabset .tabset-pills} +## Solids {.tabset .tabset-pills .tabset-sticky} ### `r setfile("inorganic_cr.csv")` ```{r inorganic_cr, results="asis", echo=FALSE} @@ -206,13 +202,13 @@ ```{r reflist, results="asis", echo=FALSE} ``` -## Liquids {.tabset .tabset-pills} +## Liquids {.tabset .tabset-pills .tabset-sticky} ### `r setfile("organic_liq.csv")` ```{r reflist, results="asis", echo=FALSE} ``` -## Gases {.tabset .tabset-pills} +## Gases {.tabset .tabset-pills .tabset-sticky} ### `r setfile("inorganic_gas.csv")` ```{r reflist, results="asis", echo=FALSE} @@ -222,7 +218,7 @@ ```{r reflist, results="asis", echo=FALSE} ``` -## Optional Data {.tabset .tabset-pills} +## Optional Data {.tabset .tabset-pills .tabset-sticky} ```{r Optional_Data, results="asis", echo=FALSE} cat("These files contain optional data updates that are not loaded by default (using `data(thermo)`). To load these data, run `add.obigt('CHNOSZ')` or `add.obigt('DEW')`.\n\n") From noreply at r-forge.r-project.org Mon Oct 16 16:30:48 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 16 Oct 2017 16:30:48 +0200 (CEST) Subject: [CHNOSZ-commits] r259 - in pkg/CHNOSZ: . R data demo inst inst/extdata/OBIGT man man/macros vignettes Message-ID: <20171016143049.0F0341890CF@r-forge.r-project.org> Author: jedick Date: 2017-10-16 16:30:48 +0200 (Mon, 16 Oct 2017) New Revision: 259 Added: pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/cgl.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/macros/macros.Rd pkg/CHNOSZ/man/subcrt.Rd pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: add SUPCRTBL data (aqueous SiO2 and Al species and As minerals) Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-16 14:30:48 UTC (rev 259) @@ -1,6 +1,6 @@ -Date: 2017-10-14 +Date: 2017-10-16 Package: CHNOSZ -Version: 1.1.0-57 +Version: 1.1.0-58 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/cgl.R =================================================================== --- pkg/CHNOSZ/R/cgl.R 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/R/cgl.R 2017-10-16 14:30:48 UTC (rev 259) @@ -47,8 +47,11 @@ } else { # use constant heat capacity if the coefficients are not available Cp <- PAR$Cp - CpdT <- PAR$Cp*(T - Tr) + intCpdT <- PAR$Cp*(T - Tr) intCpdlnT <- PAR$Cp*log(T / Tr) + # in case Cp is listed as NA, set the integrals to 0 at Tr + intCpdT[T==Tr] <- 0 + intCpdlnT[T==Tr] <- 0 } # volume and its integrals if(PAR$name %in% c("quartz", "coesite")) { @@ -73,7 +76,12 @@ if(property[i] == "V") values[, i] <- V if(property[i] == "E") values[, i] <- rep(NA, ncond) if(property[i] == "kT") values[, i] <- rep(NA, ncond) - if(property[i] == "G") values[, i] <- PAR$G - PAR$S*(T - Tr) + intCpdT - T*intCpdlnT + intVdP + if(property[i] == "G") { + # calculate S * (T - Tr), but set it to 0 at Tr (in case S is NA) + Sterm <- PAR$S*(T - Tr) + Sterm[T==Tr] <- 0 + values[, i] <- PAR$G - Sterm + intCpdT - T*intCpdlnT + intVdP + } if(property[i] == "H") values[, i] <- PAR$H + intCpdT + intVdP - T*intdVdTdP if(property[i] == "S") values[, i] <- PAR$S + intCpdlnT - intdVdTdP } Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/data/refs.csv 2017-10-16 14:30:48 UTC (rev 259) @@ -17,14 +17,15 @@ BH83,"T. S. Bowers and H. C. Helgeson",1983,"Geochim. Cosmochim. Acta 47, 1247-1275",rutile,https://doi.org/10.1016/0016-7037(83)90066-2 Hel85,"H. C. Helgeson",1985,"Am. J. Sci. 285, 845-855","ferrosilite and siderite",https://doi.org/10.2475/ajs.285.9.845 JH85,"K. J. Jackson and H. C. Helgeson",1985,"Econ. Geol. 80, 1365-1378","Sn minerals",https://doi.org/10.2113/gsecongeo.80.5.1365 -Ber88,"R. G. Berman",1988,"J. Petrol. 29, 445-522","minerals",https://doi.org/10.1093/petrology/29.2.445 +Ber88,"R. G. Berman",1988,"J. Petrol. 29, 445-522",minerals,https://doi.org/10.1093/petrology/29.2.445 SH88,"E. L. Shock and H. C. Helgeson",1988,"Geochim. Cosmochim. Acta 52, 2009-2036","ionic species",https://doi.org/10.1016/0016-7037(88)90181-0 SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183","inorganic neutral species",https://doi.org/10.1016/0016-7037(89)90341-4 -Ber90,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","annite",http://ammin.geoscienceworld.org/content/75/3-4/328 +Ber90,"R. G. Berman",1990,"Am. Mineral. 75, 328-344",annite,http://ammin.geoscienceworld.org/content/75/3-4/328 Ber90.1,"R. G. Berman",1990,"Am. Mineral. 75, 328-344","almandine and ilmenite: modified H and/or S",http://ammin.geoscienceworld.org/content/75/3-4/328 Eva90,"B. W. Evans",1990,"Lithos 25, 3-23","glaucophane and pumpellyite",https://doi.org/10.1016/0024-4937(90)90003-J SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O SH90.1,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","formic acid, formate, and propanoate",https://doi.org/10.1016/0016-7037(90)90429-O +BN91,"J. W. Ball and D. K. Nordstrom",1991,"User's manual for WATEQ4F, with revised thermodynamic data base and text cases for calculating speciation of major, trace, and redox elements in natural waters. USGS Open-File Report 91-183","arsenopyrite: G",https://pubs.er.usgs.gov/publication/ofr91183 SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H revisions for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.1,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","phlogopite: H and S modified by @Ber90, followed by G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.2,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","annite: G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 @@ -45,6 +46,7 @@ SK95,"E. L. Shock and C. M. Koretsky",1995,"Geochim. Cosmochim. Acta 59, 1497-1532","metal-organic acid complexes",https://doi.org/10.1016/0016-7037(95)00058-8 SK95.1,"E. L. Shock and C. M. Koretsky",1995,"Geochim. Cosmochim. Acta 59, 1497-1532","alanate, glycinate and their complexes not included in later slop files.",https://doi.org/10.1016/0016-7037(95)00058-8 Sho95,"E. L. Shock",1995,"Am. J. Sci. 295, 496-580","carboxylic acids",https://doi.org/10.2475/ajs.295.5.496 +DPS+96,"I. Diakonov, G. Pokrovski et al.",1996,"Geochim. Cosmochim. Acta 60, 197-211",NaAl(OH)4,http://dx.doi.org/10.1016/0016-7037(95)00403-3 AH97b,"J. P. Amend and H. C. Helgeson",1997,"J. Chem. Soc., Faraday Trans. 93, 1927-1941","amino acids GHS",https://doi.org/10.1039/A608126F DSM+97,"J. D. Dale, E. L. Shock et al.",1997,"Geochim. Cosmochim. Acta 61, 4017-4024",alkylphenols,https://doi.org/10.1016/S0016-7037(97)00212-3 DSM+97.1,"J. D. Dale, E. L. Shock et al.",1997,"Geochim. Cosmochim. Acta 61, 4017-4024","phenol, and cresol isomers",https://doi.org/10.1016/S0016-7037(97)00212-3 @@ -80,11 +82,16 @@ PS01,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","aqueous nonelectrolytes",https://doi.org/10.1016/S0016-7037(01)00678-0 PS01.1,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900","acetic acid, propanoic acid, and methane",https://doi.org/10.1016/S0016-7037(01)00678-0 Ric01,"L. Richard",2001,"Geochim. Cosmochim. Acta 65, 3827-3877","organic sulfur compounds",https://doi.org/10.1016/S0016-7037(01)00761-X +Ste01,"A. Stefansson",2001,"Chem. Geol. 172, 225-250",aqueous H4SiO4,http://dx.doi.org/10.1016/S0009-2541(00)00263-1 SSW01,"M. D. Schulte, E. L. Shock and R. H. Wood",2001,"Geochim. Cosmochim. Acta 65, 3919-3930","AsH3, CF4, CH3F, Cl2, ClO2, N2O, NF3, NO, PH3, and SF6",https://doi.org/10.1016/S0016-7037(01)00717-7 +TS01,"B. Tagirov and J. Schott",2001,"Geochim. Cosmochim. Acta 65, 3965-3992","aqueous Al species",http://dx.doi.org/10.1016/S0016-7037(01)00705-0 MGN03,"J. Majzlan, K.-D. Grevel and A. Navrotsky",2003,"Am. Mineral. 88, 855-859","goethite, lepidocrocite, and maghemite GHS",https://doi.org/10.2138/am-2003-5-614 +NA03,"D. K. Nordstrom and D. G. Archer",2003,"Arsenic thermodynamic data and environmental geochemistry. In Arsenic in Groundwater, eds. Welch and Stollenwerk, Kluwer","As-bearing minerals", MLS+03,"J. Majzlan, B. E. Lang et al.",2003,"Am. Mineral. 88, 846-854","goethite, lepidocrocite, and maghemite Cp",https://doi.org/10.2138/am-2003-5-613 +AS04,"J. Apps and N. Spycher",2004,"Data qualification for thermodynamic data used to support THC calculations. Bechtel SAIC Company, LLC. ANL-NBS-HS-000043 REV 00 (DOC.20041118.0004)",aqueous SiO2, MSB+04,"J. Majzlan, R. Stevens et al.",2004,"Phys. Chem. Mineral. 31, 518-531","hydronium jarosite",https://doi.org/10.1007/s00269-004-0405-z SR04,"M. D. Schulte and K. L. Rogers",2004,"Geochim. Cosmochim. Acta 68, 1087-1097","alkane thiols",https://doi.org/10.1016/j.gca.2003.06.001 +ZZX+05,"Y. Zhu et al.",2005,"J. Hazard. Mater. A120, 37-44","barium arsenate and barium hydrogen arsenate: G",https://doi.org/10.1016/j.jhazmat.2004.12.025 HPT06,"B. Hawrylak, R. Palepu and P. R. Tremaine",2006,"J. Chem. Thermodynamics 38, 988-1007","methyldiethanolamine and methyldiethanolammonium chloride HKF parameters",https://doi.org/10.1016/j.jct.2005.10.013 LH06a,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724","nucleic-acid bases, nucleosides, and nucleotides",https://doi.org/10.1016/j.gca.2006.04.010 LH06a.1,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724","citric acid and citrate",https://doi.org/10.1016/j.gca.2006.04.010 @@ -94,6 +101,7 @@ DLH06,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336","amino acid, protein, and organic groups",https://doi.org/10.5194/bg-3-311-2006 DLH06.1,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336","amino acids HKF parameters",https://doi.org/10.5194/bg-3-311-2006 DLH06.2,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336","Gly-X-Gly tripeptides",https://doi.org/10.5194/bg-3-311-2006 +LMR06,"D. Langmuir et al.",2006,"Geochim. Cosmochim. Acta 70, 2942-2956","scorodite and amorphous ferric arsenate: G",https://doi.org/10.1016/j.gca.2006.03.006 MNM+06,"J. Majzlan, A. Navrotsky et al.",2006,"Eur. J. Mineral. 18, 175-186","coquimbite, ferricopiapite, and rhomboclase",https://doi.org/10.1127/0935-1221/2006/0018-0175 Dic07,"J. M. Dick",2007,"Ph.D. Dissertation, Univ. of California","glutathione, cystine, and cystine sidechain", MA07,"L. Marini and M. Accornero",2007,"Environ. Geol. 52, 1343-1363","metal-arsenate and metal-arsenite complexes",https://doi.org/10.1007/s00254-006-0578-5 @@ -126,6 +134,8 @@ SLOP15.7,"E. L. Shock et al.",2015,"slop15.dat computer data file","hexanol, heptanol, and octanol: "Minor differences in Gibbs energy, entropy, omega, a1, a2, a3, a4 and c1 values compared to @SH90."",http://geopig.asu.edu/?q=tools CS16,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322","citric acid cycle metabolites",https://doi.org/10.1016/j.gca.2016.08.028 CS16.1,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322","citric acid species HKF a1--a4 parameters",https://doi.org/10.1016/j.gca.2016.08.028 +ZZL+16,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","data listed in spronsbl.dat",https://doi.org/10.1016/j.cageo.2016.02.013 +ZZL+16.1,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","As(α): V data listed in spronsbl.dat",https://doi.org/10.1016/j.cageo.2016.02.013 CHNOSZ.1,"J. M. Dick",2017,"CHNOSZ package documentation","GHS (Tr) of the phase that is stable at 298.15 K was combined with Htr and the Cp coefficients to calculate the metastable GHS (Tr) of the phases that are stable at higher temperatures.",http://chnosz.net CHNOSZ.2,"J. M. Dick",2017,"CHNOSZ package documentation","alanate and glycinate: GHS as used by @DLH06",http://chnosz.net CHNOSZ.3,"J. M. Dick",2017,"CHNOSZ package documentation","metal-amino acid complexes: GHS were recalculated by adding the differences between values from @AH97b and @DLH06 for alanate or glycinate to the properties of the complexes reported by @SK95.",http://chnosz.net Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/demo/00Index 2017-10-16 14:30:48 UTC (rev 259) @@ -1,23 +1,23 @@ -sources cross-check the reference list with the thermodynamic database -protein.equil chemical activities of two proteins in metastable equilibrium -affinity affinities of metabolic reactions and amino acid synthesis -NaCl equilibrium constant for aqueous NaCl dissociation -density density of H2O, inverted from IAPWS-95 equations -ORP temperature dependence of oxidation-reduction potential for redox standards -revisit coefficient of variation of metastable equilibrium activities of proteins -findit minimize the standard deviation of logarithms of activities of sulfur species +sources Cross-check the reference list with the thermodynamic database +protein.equil Chemical activities of two proteins in metastable equilibrium +affinity Affinities of metabolic reactions and amino acid synthesis +NaCl Equilibrium constant for aqueous NaCl dissociation +density Density of H2O, inverted from IAPWS-95 equations +ORP Temperature dependence of oxidation-reduction potential for redox standards +revisit Coefficient of variation of metastable equilibrium activities of proteins +findit Minimize the standard deviation of logarithms of activities of sulfur species ionize ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK -buffer minerals and aqueous species as buffers of hydrogen fugacity -protbuff chemical activities buffered by thiol peroxidases or sigma factors -yeastgfp subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams +buffer Minerals and aqueous species as buffers of hydrogen fugacity +protbuff Chemical activities buffered by thiol peroxidases or sigma factors +yeastgfp Subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams mosaic Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species -copper another example of mosaic(): complexation of copper with glycine species -solubility solubility of calcite or CO2(gas) as a function of pH +copper Another example of mosaic(): complexation of copper with glycine species +solubility Solubility of calcite or CO2(gas) as a function of pH wjd Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast dehydration log K of dehydration reactions; SVG file contains tooltips and links -bugstab formation potential of microbial proteins in colorectal cancer -Shh affinities of transcription factors relative to Sonic hedgehog -activity_ratios mineral stability plots with activity ratios on the axes +bugstab Formation potential of microbial proteins in colorectal cancer +Shh Affinities of transcription factors relative to Sonic hedgehog +activity_ratios Mineral stability plots with activity ratios on the axes adenine HKF parameters regressed from heat capacity and volume of aqueous adenine DEW Deep Earth Water (DEW) model for high pressures lambda Effects of lambda transtion on thermodynamic properties of quartz Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/inst/NEWS 2017-10-16 14:30:48 UTC (rev 259) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-57 (2017-10-14) +CHANGES IN CHNOSZ 1.1.0-58 (2017-10-16) --------------------------------------- MAJOR CHANGES: @@ -79,23 +79,27 @@ *everything* (the database and all computational and system settings). - In add.obigt(), using 'file' without a file suffix now can be used to - locate corresponding files (such as CHNOSZ_aq.csv or DEW_aq.csv) in - the extdata/OBIGT package directory. + locate corresponding files (such as DEW_aq.csv or SUPCRTBL.csv) in the + extdata/OBIGT package directory. - add.obigt() gets new argument 'species' for selecting species to add. -- Add DEW_aq.csv with aqueous species data from the DEW spreadsheet - (May 2017 version). Species with data that do not differ from the - default database in CHNOSZ are not included. Currently, detailed - reference keys and descriptions (in thermo$refs) are given for - selected species only. - - Add Berman_cr.csv with names and formulas for minerals whose thermodynamic properties are calculated using the Berman, 1988 equations. The state "cr_Berman" is used to distinguish these minerals from the Helgeson data. The parameters themselves are stored in extdata/Berman/*.csv. +- Add DEW_aq.csv with aqueous species data from the DEW spreadsheet + (May 2017 version). Species with data that do not differ from the + default database in CHNOSZ are not included. Currently, detailed + reference keys and descriptions (in thermo$refs) are given for + selected species only. [Optional Data; not loaded by data(thermo).] + +- Add SUPCRTBL.csv with mineral and aqueous species data from + spronsbl.dat (http://www.indiana.edu/~hydrogeo/supcrtbl.html), as + described by Zimmer et al., 2016. [Optional Data.] + - Update HKF parameters of adenine based on experimental heat capacity and volume data (Lowe et al., 2017). Add demo/adenine.R comparing the updates with the previous data (LaRowe and Helgeson, 2006). Added: pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv 2017-10-16 14:30:48 UTC (rev 259) @@ -0,0 +1,33 @@ +name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T +Al+3,NA,Al+3,aq,TS01,NA,25.Aug.06,-116510,NA,-81.203,-28.56,-45.3,-3.3984,-16.0789,12.0699,-2.1143,14.4295,-8.8523,2.7403,3 +Al(OH)4-,NA,Al(OH)4-,aq,TS01,NA,25.Aug.06,-312087,NA,24.748,23.06,46.3,8.4938,12.9576,0.657,-3.3147,55.7265,-11.4047,1.0403,-1 +AlOH+2,NA,AlOH+2,aq,TS01,NA,25.Aug.06,-166425,NA,-43.29,-8.97,-20.6,-0.4532,-8.8878,9.2434,-2.4116,15.4131,-4.8618,1.5897,2 +Al(OH)2+,NA,Al(OH)2+,aq,TS01,NA,25.Aug.06,-214987,NA,-6.584,9.76,3.86,2.4944,-1.6909,6.4146,-2.7091,16.7439,-1.0465,0.5324,1 +Al(OH)3,NA,Al(OH)3,aq,TS01,NA,25.Aug.06,-263321,NA,14.185,23.65,27.02,5.4624,5.556,3.5662,-3.0087,20.027,1.7829,0,0 +AlF+2,NA,AlF+2,aq,TS01,NA,25.Aug.06,-193374,NA,-52.413,-3.41,-17.74,0.0486,-7.6626,8.7618,-2.4622,21.3382,-3.7292,1.882,2 +AlF2+,NA,AlF2+,aq,TS01,NA,25.Aug.06,-268382,NA,-29.84,20.88,9.58,3.4523,0.648,5.4953,-2.8058,27.4906,1.2187,0.996,1 +AlF3,NA,AlF3,aq,TS01,NA,25.Aug.06,-341248,NA,-14.45,40.33,35.6,6.6365,8.4227,2.4395,-3.1272,29.8025,5.1806,0,0 +AlF4-,NA,AlF4-,aq,TS01,NA,25.Aug.06,-411835,NA,-6.691,45.3,57.74,10.3172,17.4096,-1.0929,-3.4987,48.4334,6.193,1.7229,-1 +Al(OH)2F2-,NA,Al(OH)2F2-,aq,TS01,NA,25.Aug.06,-361765,NA,45.062,34.18,52.02,9.3237,14.9838,-0.1394,-3.3984,1.8352,21.1478,1.1651,-1 +Al(OH)2F,NA,Al(OH)2F,aq,TS01,NA,25.Aug.06,-291441,NA,25.181,19.55,21.52,4.7098,3.7184,4.2885,-2.9327,17.6241,0.9477,0,0 +AlOHF2,NA,AlOHF2,aq,TS01,NA,25.Aug.06,-308085,NA,42.004,15.45,16.02,3.9572,1.8807,5.0108,-2.8567,15.2213,0.1126,0,0 +AlSO4+,NA,AlSO4+,aq,TS01,NA,25.Aug.06,-298759,NA,-46.724,106.7,-6.17,1.833,-3.3057,7.0494,-2.6423,90.7261,18.7002,2.4143,1 +NaAl(OH)3F,NA,NaAl(OH)3F,aq,TS01,NA,25.Aug.06,-398892,NA,71.594,28.2,48,8.3333,12.5657,0.811,-3.2985,22.6935,2.7097,0,0 +NaAl(OH)2F2,NA,NaAl(OH)2F2,aq,TS01,NA,25.Aug.06,-403511,NA,128.933,24.2,42.4,7.567,10.6947,1.5464,-3.2211,20.3493,1.8949,0,0 +NaAl(OH)4,NA,NaAl(OH)4,aq,TS01,DPS+96,25.Aug.06,-374611,-413601,48.8,32.2,53.6,9.1267,14.3411,0.1121,-3.3719,60.7157,-14.0523,0,0 +AlH3SiO4+2,NA,AlH3SiO4+2,aq,TS01,NA,25.Aug.06,-425860,NA,13.57,-71.9,-13.93,0.16,-7.23,8.61,-2.48,37.07,-49.66,0.88,2 +H4SiO4,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 +SiO2,NA,SiO2,aq,AS04,ZZL+16,16.Oct.17,-199539.9,-212179,11.12811,NA,NA,1.9,1.7,20,-2.7,32.22,-25.29001,0.3427103,0 +"arsenic,alpha",NA,As,cr,NA03,ZZL+16.1,16.Oct.17,0,0,8.515774378585085,5.838910133843212,12.96,NA,NA,NA,NA,NA,NA,NA,NA +arsenolite,NA,As2O3,cr,NA03,NA,16.Oct.17,-137748.56596558317,-157091.3001912046,25.664435946462714,23.154875717017205,NA,NA,NA,NA,NA,NA,NA,NA,NA +claudetite,NA,As2O3,cr,NA03,NA,16.Oct.17,-137793.97705544933,-156708.8910133843,27.09608030592734,23.178776290630974,NA,NA,NA,NA,NA,NA,NA,NA,NA +As2O5,NA,As2O5,cr,NA03,NA,16.Oct.17,-185172.08413001912,-219309.27342256214,25.20076481835564,27.70076481835564,NA,NA,NA,NA,NA,NA,NA,NA,NA +"realgar,alpha",NA,AsS,cr,NA03,NA,16.Oct.17,-7480.879541108986,-7600.38240917782,15.033460803059272,11.233269598470363,NA,NA,NA,NA,NA,NA,NA,NA,NA +"realgar,beta",NA,AsS,cr,NA03,NA,16.Oct.17,-7385.277246653919,-7409.177820267686,15.176864244741873,11.233269598470363,NA,NA,NA,NA,NA,NA,NA,NA,NA +orpiment,NA,As2S3,cr,NA03,NA,16.Oct.17,-20291.586998087954,-20506.692160611852,39.14913957934991,38.95793499043977,NA,NA,NA,NA,NA,NA,NA,NA,NA +"orpiment,amorphous",NA,As2S3,cr,NA03,NA,16.Oct.17,-18355.640535372848,-15989.483747609942,47.801147227533455,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +arsenopyrite,NA,FeAsS,cr,BN91,ZZL+16,16.Oct.17,-33843.21223709369,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +scorodite,NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-307619.5028680688,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"ferric arsenate,amorphous",NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-303771.51051625237,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"barium arsenate",NA,Ba3(AsO4)2,cr,ZZX+05,ZZL+16,16.Oct.17,-739749.0439770555,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"barium hydrogen arsenate",NA,BaHAsO4.H2O,cr,ZZX+05,ZZL+16,16.Oct.17,-367746.1759082218,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-16 14:30:48 UTC (rev 259) @@ -35,26 +35,26 @@ See the comments in the source code for more information about each demo. \tabular{ll}{ - \code{sources} \tab cross-check the reference list with the thermodynamic database \cr - \code{protein.equil} \tab chemical activities of two proteins in metastable equilibrium (Dick and Shock, 2011) \cr - \code{affinity} \tab affinities of metabolic reactions and amino acid synthesis (Amend and Shock, 1998, 2001) \cr - \code{NaCl} \tab * equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr - \code{density} \tab * density of \H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr - \code{ORP} \tab * temperature dependence of oxidation-reduction potential for redox standards \cr - \code{revisit} \tab * coefficient of variation of metastable equilibrium activities of proteins \cr - \code{findit} \tab * minimize the standard deviation of logarithms of activities of sulfur species \cr + \code{sources} \tab Cross-check the reference list with the thermodynamic database \cr + \code{protein.equil} \tab Chemical activities of two proteins in metastable equilibrium (Dick and Shock, 2011) \cr + \code{affinity} \tab Affinities of metabolic reactions and amino acid synthesis (Amend and Shock, 1998, 2001) \cr + \code{NaCl} \tab * Equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr + \code{density} \tab * Density of \H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr + \code{ORP} \tab * Temperature dependence of oxidation-reduction potential for redox standards \cr + \code{revisit} \tab * Coefficient of variation of metastable equilibrium activities of proteins \cr + \code{findit} \tab * Minimize the standard deviation of logarithms of activities of sulfur species \cr \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \cr - \code{buffer} \tab * minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr - \code{protbuff} \tab chemical activities buffered by thiol peroxidases or sigma factors \cr - \code{yeastgfp} \tab * subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams (Dick, 2009) \cr + \code{buffer} \tab * Minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr + \code{protbuff} \tab Chemical activities buffered by thiol peroxidases or sigma factors \cr + \code{yeastgfp} \tab * Subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams (Dick, 2009) \cr \code{mosaic} \tab * Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr - \code{copper} \tab * another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr - \code{solubility} \tab * solubility of calcite (cf. Manning et al., 2013) or \CO2 (cf. Stumm and Morgan, 1996) \cr + \code{copper} \tab * Another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr + \code{solubility} \tab * Solubility of calcite (cf. Manning et al., 2013) or \CO2 (cf. Stumm and Morgan, 1996) \cr \code{wjd} \tab * Gibbs energy minimization: prebiological atmospheres (Dayhoff et al., 1964) and cell periphery of yeast \cr - \code{dehydration} \tab * log K of dehydration reactions; SVG file contains tooltips and links \cr - \code{bugstab} \tab * formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr - \code{Shh} \tab * affinities of transcription factors relative to Sonic hedgehog (Dick, 2015) \cr - \code{activity_ratios} \tab * mineral stability plots with activity ratios on the axes \cr + \code{dehydration} \tab * \logK of dehydration reactions; SVG file contains tooltips and links \cr + \code{bugstab} \tab * Formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr + \code{Shh} \tab * Affinities of transcription factors relative to Sonic hedgehog (Dick, 2015) \cr + \code{activity_ratios} \tab * Mineral stability plots with activity ratios on the axes \cr \code{adenine} \tab * HKF parameters regressed from heat capacity and volume of aqueous adenine (Lowe et al., 2017) \cr \code{DEW} \tab * Deep Earth Water (DEW) model for high pressures (Sverjensky et al., 2014a and 2014b) \cr \code{lambda} \tab * Effects of lambda transition on thermodynamic properties of quartz (Berman, 1988) \cr Modified: pkg/CHNOSZ/man/macros/macros.Rd =================================================================== --- pkg/CHNOSZ/man/macros/macros.Rd 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/man/macros/macros.Rd 2017-10-16 14:30:48 UTC (rev 259) @@ -21,6 +21,7 @@ % other common variables \newcommand{\T}{\ifelse{latex}{\eqn{T}}{\ifelse{html}{\out{T}}{T}}} \newcommand{\P}{\ifelse{latex}{\eqn{P}}{\ifelse{html}{\out{P}}{P}}} +\newcommand{\logK}{\ifelse{latex}{\eqn{\log K}}{\ifelse{html}{\out{logK}}{log K}}} \newcommand{\logfO2}{\ifelse{latex}{\eqn{\log f_{\mathrm{O_{2}}}}}{\ifelse{html}{\out{logfO2}}{logfO2}}} \newcommand{\logfH2}{\ifelse{latex}{\eqn{\log f_{\mathrm{H_{2}}}}}{\ifelse{html}{\out{logfH2}}{logfH2}}} \newcommand{\logaH2O}{\ifelse{latex}{\eqn{\log a_{\mathrm{H_{2}O}}}}{\ifelse{html}{\out{logaH2O}}{logaH2O}}} Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-16 14:30:48 UTC (rev 259) @@ -97,7 +97,7 @@ Comparison of the output of \code{subcrt} with that of \acronym{SUPCRT92} indicates the two give similar values of properties for neutral aqueous species up to 1000 \degC and 5000 bar. Changes were made in CHNOSZ 0.9-9 to improve the calculation of the \eqn{g}{g}- and \eqn{f}{f}-functions (Shock et al., 1992) for the partial derivatives of the omega parameter which are used by the \code{\link{hkf}} function, so thermodynamic properties of charged aqueous species over the temperature range 0 to 1000 \degC are now mostly consistent with \acronym{SUPCRT92}. Note, however, that while \acronym{SUPCRT92} limits calculations at Psat to 350 \degC (\dQuote{beyond range of applicability of aqueous species equations}), there is no corresponding limit in place in \code{subcrt} (or \code{\link{hkf}}), so that inapplicable calculations will be performed up to the critical temperature (373.917 \degC) without any warning. -It is probably for this reason that there is a noticeable jump in the value of logK at Psat shown in the one of the examples (\code{demo("NaCl")}). +It is probably for this reason that there is a noticeable jump in the value of \logK at Psat shown in the one of the examples (\code{demo("NaCl")}). A known bug is misidentification of the stable polymorph of some minerals at high temperature; an example of this bug is shown in the \code{\link{stopifnot}} at the end of the skarn example below. } Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-14 15:09:27 UTC (rev 258) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-16 14:30:48 UTC (rev 259) @@ -12,7 +12,7 @@ bibliography: obigt.bib # so that these appear in the bibliography nocite: | - @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ, @JOH92, @WP02, @CWM89, @PRPG97, @TH88, @Kul06, @Sho09 + @SPRONS92, @SLOP98, @SLOP07, @SLOP15, @CHNOSZ, @JOH92, @WP02, @CWM89, @PRPG97, @TH88, @Kul06, @Sho09, @HP11 csl: elementa.csl --- @@ -39,8 +39,8 @@ dat <- read.csv(file, as.is=TRUE) ## exclude entries for phase transitions #dat <- dat[!dat$state %in% c("cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9"), ] - # the class of substance, followed by number of species - class <- gsub("_.*", "", csvfile) + # the class of substance (used as section header), followed by number of species + class <- gsub(".csv", "", gsub("_.*", "", csvfile)) substr(class, 1, 1) <- toupper(substr(class, 1, 1)) paste0("`", class, "` (", nrow(dat), ")") } @@ -107,13 +107,13 @@ ``` This [vignette](index.html), produced on `r Sys.Date()`, documents the sources of thermodynamic data in CHNOSZ version `r sessionInfo()$otherPkgs$CHNOSZ$Version`. +Running `data(thermo)` creates the default database, which is present in the R session as `thermo$obigt`. -The sections below correspond to CSV data files read by `data(thermo)`. +The sections below correspond to CSV data files that are stored in the `extdata/OBIGT` package directory and read by `data(thermo)` (except for Optional Data). In each section, the primary references (`ref1` in `thermo$obigt`) are listed in chronological order. Any secondary references (`ref2`) are listed with bullet points. Each reference is followed by the number of species, and a note (from `thermo$refs`). Symbols show whether the data were present in the earliest of the sprons92.dat (?), slop98.dat (\*), slop07.dat (?), or slop15.dat (?) datafiles for the SUPCRT92 package. -NOTE: URLs for the slop files and other data files cited below (`JUN92.bs`, `berman.dat`, and the DEW model spreadsheet) are given in the References. Any additional comments are placed at the beginning of the sections. Abbreviations used below are: Cp (heat capacity), GHS (standard Gibbs energy, enthalpy, entropy), HKF (Helgeson-Kirkham-Flowers equations), V (volume), T (temperature), P (pressure). @@ -121,17 +121,19 @@ # Recent additions (late 2017) -* Mineral data using the [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) equations are listed under [**Solids** / **Berman**](#berman-107). +* Mineral data using the [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) equations are listed under **Solids** / **Berman**. -* Aqueous species data intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under [**Optional Data** / **DEW**](#dew-199). +* Aqueous species data intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) model are listed under **Optional Data** / **DEW**. -# Sources of data {.tabset .tabset-fade .tabset-sticky} +* Updates included with [SUPCRTBL](http://www.indiana.edu/~hydrogeo/supcrtbl.html) are listed under **Optional Data** / **SUPCRTBL**. +# Sources of data {.tabset .tabset-fade} + Use the tabs below to select a section for viewing. Select "All at once" to show all sections. -## Aqueous species {.tabset .tabset-pills .tabset-sticky} +## Aqueous species {.tabset .tabset-pills} ### `r setfile("H2O_aq.csv")` ```{r H2O_aq, results="asis", echo=FALSE} @@ -177,7 +179,7 @@ ```{r reflist, results="asis", echo=FALSE} ``` -## Solids {.tabset .tabset-pills .tabset-sticky} +## Solids {.tabset .tabset-pills} ### `r setfile("inorganic_cr.csv")` ```{r inorganic_cr, results="asis", echo=FALSE} @@ -202,13 +204,13 @@ ```{r reflist, results="asis", echo=FALSE} ``` -## Liquids {.tabset .tabset-pills .tabset-sticky} +## Liquids {.tabset .tabset-pills} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 259 From noreply at r-forge.r-project.org Tue Oct 17 08:44:14 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 17 Oct 2017 08:44:14 +0200 (CEST) Subject: [CHNOSZ-commits] r260 - in pkg/CHNOSZ: . R data inst inst/extdata/OBIGT vignettes Message-ID: <20171017064414.5496B184262@r-forge.r-project.org> Author: jedick Date: 2017-10-17 08:44:12 +0200 (Tue, 17 Oct 2017) New Revision: 260 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: more SUPCRTBL data (aqueous As species and Al minerals) Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-17 06:44:12 UTC (rev 260) @@ -1,6 +1,6 @@ -Date: 2017-10-16 +Date: 2017-10-17 Package: CHNOSZ -Version: 1.1.0-58 +Version: 1.1.0-59 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/R/info.R 2017-10-17 06:44:12 UTC (rev 260) @@ -73,7 +73,7 @@ return(out) } -info.character <- function(species, state=NULL, check.protein=TRUE, grep.state=FALSE) { +info.character <- function(species, state=NULL, check.protein=TRUE) { # returns the rownumbers of thermo$obigt having an exact match of 'species' to # thermo$obigt$[species|abbrv|formula] or NA otherwise # a match to thermo$obigt$state is also required if 'state' is not NULL @@ -113,8 +113,7 @@ # special treatment for H2O: aq retrieves the liq if(species %in% c("H2O", "water") & state=="aq") state <- "liq" # the matches for both species and state - if(grep.state) matches.state <- matches.species & grepl(state, thermo$obigt$state) - else matches.state <- matches.species & state == thermo$obigt$state + matches.state <- matches.species & state == thermo$obigt$state if(!any(matches.state)) { # the requested state is not available for this species available.states <- thermo$obigt$state[matches.species] Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-17 06:44:12 UTC (rev 260) @@ -120,7 +120,7 @@ for(i in 1:length(species)) { mysearch <- species[i] if(can.be.numeric(mysearch)) mysearch <- thermo$obigt$name[as.numeric(mysearch)] - si <- info.character(mysearch, state[i], grep.state=TRUE) + si <- info.character(mysearch, state[i]) # that could have the side-effect of adding a protein; re-read thermo thermo <- get("thermo", "CHNOSZ") if(is.na(si[1])) stop('no info found for ',species[i],' ',state[i]) Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/data/refs.csv 2017-10-17 06:44:12 UTC (rev 260) @@ -10,6 +10,7 @@ RHF79,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","chlorargyrite, rutile, and titanite",http://pubs.er.usgs.gov/publication/b1452 RHF79.1,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","dickite, fluorphlogopite, halloysite, and pyrope",http://pubs.er.usgs.gov/publication/b1452 RHF79.2,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452",iron,http://pubs.er.usgs.gov/publication/b1452 +RHF79.3,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","gibbsite GHS",http://pubs.er.usgs.gov/publication/b1452 PB82,"L. N. Plummer and E. Busenberg",1982,"Geochim. Cosmochim. Acta 46, 1011-1040","aragonite and calcite",https://doi.org/10.1016/0016-7037(82)90056-4 WEP+82,"D. D. Wagman, W. H. Evans et al.",1982,"J. Phys. Chem. Ref. Data 11, Suppl. 2, 1-392","gases GHS",https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf WEP+82.1,"D. D. Wagman, W. H. Evans et al.",1982,"J. Phys. Chem. Ref. Data 11, Suppl. 2, 1-392",manganosite,https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf @@ -26,6 +27,7 @@ SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O SH90.1,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","formic acid, formate, and propanoate",https://doi.org/10.1016/0016-7037(90)90429-O BN91,"J. W. Ball and D. K. Nordstrom",1991,"User's manual for WATEQ4F, with revised thermodynamic data base and text cases for calculating speciation of major, trace, and redox elements in natural waters. USGS Open-File Report 91-183","arsenopyrite: G",https://pubs.er.usgs.gov/publication/ofr91183 +HRA91,"B. S. Hemingway et al.",1991,"Am. Mineral. 76, 445-457","bohemite",http://pubs.er.usgs.gov/publication/70016664 SHD91,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","G and H revisions for K- and Al-bearing silicates",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.1,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","phlogopite: H and S modified by @Ber90, followed by G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 SHD91.2,"D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo",1991,"Geochim. Cosmochim. Acta 55, 989-1004","annite: G and H revision for K-bearing silicates [after @SHD91]",https://doi.org/10.1016/0016-7037(89)90341-4 @@ -86,7 +88,8 @@ SSW01,"M. D. Schulte, E. L. Shock and R. H. Wood",2001,"Geochim. Cosmochim. Acta 65, 3919-3930","AsH3, CF4, CH3F, Cl2, ClO2, N2O, NF3, NO, PH3, and SF6",https://doi.org/10.1016/S0016-7037(01)00717-7 TS01,"B. Tagirov and J. Schott",2001,"Geochim. Cosmochim. Acta 65, 3965-3992","aqueous Al species",http://dx.doi.org/10.1016/S0016-7037(01)00705-0 MGN03,"J. Majzlan, K.-D. Grevel and A. Navrotsky",2003,"Am. Mineral. 88, 855-859","goethite, lepidocrocite, and maghemite GHS",https://doi.org/10.2138/am-2003-5-614 -NA03,"D. K. Nordstrom and D. G. Archer",2003,"Arsenic thermodynamic data and environmental geochemistry. In Arsenic in Groundwater, eds. Welch and Stollenwerk, Kluwer","As-bearing minerals", +NA03,"D. K. Nordstrom and D. G. Archer",2003,"Arsenic thermodynamic data and environmental geochemistry. In Arsenic in Groundwater, eds. Welch and Stollenwerk, Kluwer","As oxide and sulfide minerals", +NA03.1,"D. K. Nordstrom and D. G. Archer",2003,"Arsenic thermodynamic data and environmental geochemistry. In Arsenic in Groundwater, eds. Welch and Stollenwerk, Kluwer","aqueous As oxides and sulfides", MLS+03,"J. Majzlan, B. E. Lang et al.",2003,"Am. Mineral. 88, 846-854","goethite, lepidocrocite, and maghemite Cp",https://doi.org/10.2138/am-2003-5-613 AS04,"J. Apps and N. Spycher",2004,"Data qualification for thermodynamic data used to support THC calculations. Bechtel SAIC Company, LLC. ANL-NBS-HS-000043 REV 00 (DOC.20041118.0004)",aqueous SiO2, MSB+04,"J. Majzlan, R. Stevens et al.",2004,"Phys. Chem. Mineral. 31, 518-531","hydronium jarosite",https://doi.org/10.1007/s00269-004-0405-z @@ -135,7 +138,9 @@ CS16,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322","citric acid cycle metabolites",https://doi.org/10.1016/j.gca.2016.08.028 CS16.1,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322","citric acid species HKF a1--a4 parameters",https://doi.org/10.1016/j.gca.2016.08.028 ZZL+16,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","data listed in spronsbl.dat",https://doi.org/10.1016/j.cageo.2016.02.013 -ZZL+16.1,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","As(α): V data listed in spronsbl.dat",https://doi.org/10.1016/j.cageo.2016.02.013 +ZZL+16.1,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","As(α): V listed in spronsbl.dat",https://doi.org/10.1016/j.cageo.2016.02.013 +ZZL+16.2,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","Cp parameters listed in spronsbl.dat",https://doi.org/10.1016/j.cageo.2016.02.013 +ZZL+16.3,"K. Zimmer et al.",2016,"Comp. Geosci. 90, 97-111","dawsonite GHS",https://doi.org/10.1016/j.cageo.2016.02.013 CHNOSZ.1,"J. M. Dick",2017,"CHNOSZ package documentation","GHS (Tr) of the phase that is stable at 298.15 K was combined with Htr and the Cp coefficients to calculate the metastable GHS (Tr) of the phases that are stable at higher temperatures.",http://chnosz.net CHNOSZ.2,"J. M. Dick",2017,"CHNOSZ package documentation","alanate and glycinate: GHS as used by @DLH06",http://chnosz.net CHNOSZ.3,"J. M. Dick",2017,"CHNOSZ package documentation","metal-amino acid complexes: GHS were recalculated by adding the differences between values from @AH97b and @DLH06 for alanate or glycinate to the properties of the complexes reported by @SK95.",http://chnosz.net Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/inst/NEWS 2017-10-17 06:44:12 UTC (rev 260) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-58 (2017-10-16) +CHANGES IN CHNOSZ 1.1.0-59 (2017-10-17) --------------------------------------- MAJOR CHANGES: @@ -94,11 +94,12 @@ (May 2017 version). Species with data that do not differ from the default database in CHNOSZ are not included. Currently, detailed reference keys and descriptions (in thermo$refs) are given for - selected species only. [Optional Data; not loaded by data(thermo).] + selected species only. [Optional Data; not loaded by data(thermo)] -- Add SUPCRTBL.csv with mineral and aqueous species data from - spronsbl.dat (http://www.indiana.edu/~hydrogeo/supcrtbl.html), as - described by Zimmer et al., 2016. [Optional Data.] +- Add SUPCRTBL.csv with mineral and aqueous species data compiled by + Zimmer et al., 2016. Data were taken from original references or + from spronsbl.dat (http://www.indiana.edu/~hydrogeo/supcrtbl.html). + [Optional Data] - Update HKF parameters of adenine based on experimental heat capacity and volume data (Lowe et al., 2017). Add demo/adenine.R comparing Modified: pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv 2017-10-17 06:44:12 UTC (rev 260) @@ -1,4 +1,32 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T +"arsenic,alpha",NA,As,cr,NA03,ZZL+16.1,16.Oct.17,0,0,8.515774378585085,5.838910133843212,12.96,NA,NA,NA,NA,NA,NA,NA,NA +arsenolite,NA,As2O3,cr,NA03,NA,16.Oct.17,-137748.56596558317,-157091.3001912046,25.664435946462714,23.154875717017205,NA,NA,NA,NA,NA,NA,NA,NA,NA +claudetite,NA,As2O3,cr,NA03,NA,16.Oct.17,-137793.97705544933,-156708.8910133843,27.09608030592734,23.178776290630974,NA,NA,NA,NA,NA,NA,NA,NA,NA +As2O5,NA,As2O5,cr,NA03,NA,16.Oct.17,-185172.08413001912,-219309.27342256214,25.20076481835564,27.70076481835564,NA,NA,NA,NA,NA,NA,NA,NA,NA +"realgar,alpha",NA,AsS,cr,NA03,NA,16.Oct.17,-7480.879541108986,-7600.38240917782,15.033460803059272,11.233269598470363,NA,NA,NA,NA,NA,NA,NA,NA,NA +"realgar,beta",NA,AsS,cr,NA03,NA,16.Oct.17,-7385.277246653919,-7409.177820267686,15.176864244741873,11.233269598470363,NA,NA,NA,NA,NA,NA,NA,NA,NA +orpiment,NA,As2S3,cr,NA03,NA,16.Oct.17,-20291.586998087954,-20506.692160611852,39.14913957934991,38.95793499043977,NA,NA,NA,NA,NA,NA,NA,NA,NA +"orpiment,amorphous",NA,As2S3,cr,NA03,NA,16.Oct.17,-18355.640535372848,-15989.483747609942,47.801147227533455,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +arsenopyrite,NA,FeAsS,cr,BN91,ZZL+16,16.Oct.17,-33843.21223709369,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +scorodite,NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-307619.5028680688,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"ferric arsenate,amorphous",NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-303771.51051625237,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"barium arsenate",NA,Ba3(AsO4)2,cr,ZZX+05,ZZL+16,16.Oct.17,-739749.0439770555,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"barium hydrogen arsenate",NA,BaHAsO4.H2O,cr,ZZX+05,ZZL+16,16.Oct.17,-367746.1759082218,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +boehmite,NA,AlO2H,cr,HRA91,ZZL+16.2,17.Oct.17,-219502.86806883363,-238145.3154875717,8.888623326959847,12.97634,19.535,40.48757170172084,-4.1108986615678775,0.6962476099426387,-467.3996175908221,0,0,0,NA +gibbsite,NA,Al(OH)3,cr,RHF79.3,ZZL+16.2,17.Oct.17,-276025.1,-309065,16.35755,21.72251,31.956,22.179732313575524,45.276768642447415,0.3199569789674952,-247.20363288718926,0,0,0,NA +dawsonite,NA,NaAlCO3(OH)2,cr,ZZL+16.3,NA,17.Oct.17,-425979.9,-463456,32.91109,NA,NA,0,0,0,0,0,0,0,NA +H3AsO4,NA,H3AsO4,aq,NA03.1,NA,17.Oct.17,-183257.6481835564,-215929.7323135755,43.75478011472275,NA,NA,NA,NA,NA,NA,NA,NA,NA,0 +H2AsO4-,NA,H2AsO4-,aq,NA03.1,NA,17.Oct.17,-180126.67304015296,-217834.60803059273,26.85946462715105,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 +HAsO4-2,NA,HAsO4-2,aq,NA03.1,NA,17.Oct.17,-170585.56405353727,-217115.20076481835,-2.7294455066921604,NA,NA,NA,NA,NA,NA,NA,NA,NA,-2 +AsO4-3,NA,AsO4-3,aq,NA03.1,NA,17.Oct.17,-154483.74760994263,-212765.2963671128,-42.13910133843212,NA,NA,NA,NA,NA,NA,NA,NA,NA,-3 +H3AsO3,NA,H3AsO3,aq,NA03.1,NA,17.Oct.17,-152970.8413001912,-177428.29827915868,46.80449330783939,NA,NA,NA,NA,NA,NA,NA,NA,NA,0 +H2AsO3-,NA,H2AsO3-,aq,NA03.1,NA,17.Oct.17,-140454.11089866157,-170826.9598470363,26.957456978967496,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 +HAsO3-2,NA,HAsO3-2,aq,NA03.1,NA,17.Oct.17,-121271.51051625238,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-2 +AsO3-3,NA,AsO3-3,aq,NA03.1,NA,17.Oct.17,-100812.61950286807,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-3 +As3S4(HS)2-,NA,As3S4(HS)2-,aq,NA03.1,NA,17.Oct.17,-30019.12045889101,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 +AsS(OH)SH-,NA,AsS(OH)SH-,aq,NA03.1,NA,17.Oct.17,-58413.00191204589,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 +SiO2,NA,SiO2,aq,AS04,ZZL+16,16.Oct.17,-199539.9,-212179,11.12811,NA,NA,1.9,1.7,20,-2.7,32.22,-25.29001,0.3427103,0 +H4SiO4,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 Al+3,NA,Al+3,aq,TS01,NA,25.Aug.06,-116510,NA,-81.203,-28.56,-45.3,-3.3984,-16.0789,12.0699,-2.1143,14.4295,-8.8523,2.7403,3 Al(OH)4-,NA,Al(OH)4-,aq,TS01,NA,25.Aug.06,-312087,NA,24.748,23.06,46.3,8.4938,12.9576,0.657,-3.3147,55.7265,-11.4047,1.0403,-1 AlOH+2,NA,AlOH+2,aq,TS01,NA,25.Aug.06,-166425,NA,-43.29,-8.97,-20.6,-0.4532,-8.8878,9.2434,-2.4116,15.4131,-4.8618,1.5897,2 @@ -16,18 +44,55 @@ NaAl(OH)2F2,NA,NaAl(OH)2F2,aq,TS01,NA,25.Aug.06,-403511,NA,128.933,24.2,42.4,7.567,10.6947,1.5464,-3.2211,20.3493,1.8949,0,0 NaAl(OH)4,NA,NaAl(OH)4,aq,TS01,DPS+96,25.Aug.06,-374611,-413601,48.8,32.2,53.6,9.1267,14.3411,0.1121,-3.3719,60.7157,-14.0523,0,0 AlH3SiO4+2,NA,AlH3SiO4+2,aq,TS01,NA,25.Aug.06,-425860,NA,13.57,-71.9,-13.93,0.16,-7.23,8.61,-2.48,37.07,-49.66,0.88,2 -H4SiO4,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 -SiO2,NA,SiO2,aq,AS04,ZZL+16,16.Oct.17,-199539.9,-212179,11.12811,NA,NA,1.9,1.7,20,-2.7,32.22,-25.29001,0.3427103,0 -"arsenic,alpha",NA,As,cr,NA03,ZZL+16.1,16.Oct.17,0,0,8.515774378585085,5.838910133843212,12.96,NA,NA,NA,NA,NA,NA,NA,NA -arsenolite,NA,As2O3,cr,NA03,NA,16.Oct.17,-137748.56596558317,-157091.3001912046,25.664435946462714,23.154875717017205,NA,NA,NA,NA,NA,NA,NA,NA,NA -claudetite,NA,As2O3,cr,NA03,NA,16.Oct.17,-137793.97705544933,-156708.8910133843,27.09608030592734,23.178776290630974,NA,NA,NA,NA,NA,NA,NA,NA,NA -As2O5,NA,As2O5,cr,NA03,NA,16.Oct.17,-185172.08413001912,-219309.27342256214,25.20076481835564,27.70076481835564,NA,NA,NA,NA,NA,NA,NA,NA,NA -"realgar,alpha",NA,AsS,cr,NA03,NA,16.Oct.17,-7480.879541108986,-7600.38240917782,15.033460803059272,11.233269598470363,NA,NA,NA,NA,NA,NA,NA,NA,NA -"realgar,beta",NA,AsS,cr,NA03,NA,16.Oct.17,-7385.277246653919,-7409.177820267686,15.176864244741873,11.233269598470363,NA,NA,NA,NA,NA,NA,NA,NA,NA -orpiment,NA,As2S3,cr,NA03,NA,16.Oct.17,-20291.586998087954,-20506.692160611852,39.14913957934991,38.95793499043977,NA,NA,NA,NA,NA,NA,NA,NA,NA -"orpiment,amorphous",NA,As2S3,cr,NA03,NA,16.Oct.17,-18355.640535372848,-15989.483747609942,47.801147227533455,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -arsenopyrite,NA,FeAsS,cr,BN91,ZZL+16,16.Oct.17,-33843.21223709369,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -scorodite,NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-307619.5028680688,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -"ferric arsenate,amorphous",NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-303771.51051625237,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -"barium arsenate",NA,Ba3(AsO4)2,cr,ZZX+05,ZZL+16,16.Oct.17,-739749.0439770555,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -"barium hydrogen arsenate",NA,BaHAsO4.H2O,cr,ZZX+05,ZZL+16,16.Oct.17,-367746.1759082218,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +NaH2AsO4,NA,NaH2AsO4,aq,MA07,MA10,12.Sep.07,-240179,-272608,41.2,37.8,41.1,7.3772,10.2352,1.1421,-3.2022,27.9202,4.6622,-0.038,0 +KH2AsO4,NA,KH2AsO4,aq,MA07,MA10,12.Sep.07,-244935,-274352,54.5,21.9,52.4,8.9277,14.0226,-0.484,-3.3587,18.6125,1.4173,-0.038,0 +MgH2AsO4+,NA,MgH2AsO4+,aq,MA07,MA10,12.Sep.07,-290910,-332717,-10.4,50.7,18.3,4.5105,3.2335,4.1483,-2.9127,42.265,7.2899,0.7009,1 +CaH2AsO4+,NA,CaH2AsO4+,aq,MA07,MA10,12.Sep.07,-314170,-348007,18.5,45.8,22.2,4.8949,4.1724,3.7452,-2.9515,35.3597,6.2862,0.2639,1 +SrH2AsO4+,NA,SrH2AsO4+,aq,MA07,MA10,12.Sep.07,-315896,-347841,27.3,40.1,22.9,4.9488,4.3041,3.6887,-2.957,30.8142,5.1312,0.1301,1 +MnH2AsO4+,NA,MnH2AsO4+,aq,MA07,MA10,12.Sep.07,-236482,-270828,14.5,53.5,23.3,5.0617,4.5799,3.5702,-2.9684,40.4264,7.8583,0.3244,1 +FeH2AsO4+,NA,FeH2AsO4+,aq,MA07,MA10,12.Sep.07,-205693,-243719,1,44.9,17.6,4.3531,2.849,4.3134,-2.8968,37.3097,6.1166,0.5283,1 +CoH2AsO4+,NA,CoH2AsO4+,aq,MA07,MA10,12.Sep.07,-193388,-232357,-1.5,45.2,13.9,3.8628,1.6516,4.8275,-2.8473,37.7921,6.1625,0.5664,1 +NiH2AsO4+,NA,NiH2AsO4+,aq,MA07,MA10,12.Sep.07,-193146,-233785,-7.1,36.4,10,3.358,0.4185,5.3569,-2.7963,33.4496,4.375,0.6516,1 +CuH2AsO4+,NA,CuH2AsO4+,aq,MA07,MA10,12.Sep.07,-166866,-204382,4.1,49.9,14.9,3.9712,1.9164,4.7138,-2.8583,39.7683,7.1249,0.4813,1 +ZnH2AsO4+,NA,ZnH2AsO4+,aq,MA07,MA10,12.Sep.07,-215927,-255372,-0.3,50.7,15.3,4.0397,2.0836,4.642,-2.8652,40.8741,7.2945,0.5485,1 +PbH2AsO4+,NA,PbH2AsO4+,aq,MA07,MA10,12.Sep.07,-187896,-215577,44.7,34.1,25,5.1359,4.7611,3.4924,-2.9759,24.9084,3.9167,-0.1328,1 +AlH2AsO4+2,NA,AlH2AsO4+2,aq,MA07,MA10,12.Sep.07,-299978,-350717,-57,34.9,-7.1,1.4491,-4.244,7.3587,-2.6036,44.5413,4.0694,1.9508,2 +FeH2AsO4+2,NA,FeH2AsO4+2,aq,MA07,MA10,12.Sep.07,-189949,-235535,-39.9,66.2,1.1,2.4901,-1.7013,6.267,-2.7087,60.4374,10.4402,1.6927,2 +NaHAsO4-,NA,NaHAsO4-,aq,MA07,MA10,12.Sep.07,-234025,-272938,19.4,11,16.4,4.464,3.12,4.197,-2.908,24.8601,-0.79,1.3274,-1 +KHAsO4-,NA,KHAsO4-,aq,MA07,MA10,12.Sep.07,-238754,-275247,30.7,3.9,26.1,5.7282,6.2078,2.8713,-3.0357,19.1455,-2.2322,1.1561,-1 +MgHAsO4,NA,MgHAsO4,aq,MA07,MA10,12.Sep.07,-282655,-326456,-17.1,-3.4,-0.5,1.6885,-3.6591,7.1076,-2.6278,3.8675,-3.7233,-0.038,0 +CaHAsO4,NA,CaHAsO4,aq,MA07,MA10,12.Sep.07,-306038,-344341,3.5,-5.6,2,2.0228,-2.8426,6.757,-2.6615,2.5879,-4.1694,-0.038,0 +SrHAsO4,NA,SrHAsO4,aq,MA07,MA10,12.Sep.07,-307750,-344917,9.8,-8.1,2.4,2.0851,-2.6905,6.6917,-2.6678,1.1155,-4.6827,-0.038,0 +MnHAsO4,NA,MnHAsO4,aq,MA07,MA10,12.Sep.07,-229564,-268033,0.7,-2.1,2.7,2.1148,-2.618,6.6606,-2.6708,4.592,-3.4707,-0.038,0 +FeHAsO4,NA,FeHAsO4,aq,MA07,MA10,12.Sep.07,-196961,-237958,-8.9,-5.9,-0.9,1.6263,-3.8112,7.1729,-2.6215,2.3717,-4.2448,-0.038,0 +CoHAsO4,NA,CoHAsO4,aq,MA07,MA10,12.Sep.07,-187516,-229240,-10.7,-5.8,-3.2,1.3102,-4.5832,7.5044,-2.5896,2.4302,-4.2244,-0.038,0 +NiHAsO4,NA,NiHAsO4,aq,MA07,MA10,12.Sep.07,-185083,-227995,-14.7,-9.7,-5.7,0.9749,-5.4021,7.8559,-2.5557,0.1514,-5.0188,-0.038,0 +CuHAsO4,NA,CuHAsO4,aq,MA07,MA10,12.Sep.07,-160044,-200797,-6.7,-3.7,-2.6,1.3964,-4.3727,7.414,-2.5983,3.6572,-3.7966,-0.038,0 +ZnHAsO4,NA,ZnHAsO4,aq,MA07,MA10,12.Sep.07,-209827,-252128,-9.9,-3.4,-2.4,1.4251,-4.3025,7.3838,-2.6012,3.8733,-3.7213,-0.038,0 +PbHAsO4,NA,PbHAsO4,aq,MA07,MA10,12.Sep.07,-180119,-214509,22.2,-10.7,3.7,2.2585,-2.267,6.5099,-2.6853,-0.4328,-5.2225,-0.038,0 +AlHAsO4+,NA,AlHAsO4+,aq,MA07,MA10,12.Sep.07,-295884,-343378,-46.1,-37.3,-8.2,1.0572,-5.2011,7.7697,-2.564,-4.1613,-10.6336,1.242,1 +FeHAsO4+,NA,FeHAsO4+,aq,MA07,MA10,12.Sep.07,-188188,-232211,-34.7,-23.4,-4.9,1.4545,-4.2306,7.353,-2.6042,2.37,-7.8022,1.0694,1 +NaAsO4-2,NA,NaAsO4-2,aq,MA07,MA10,12.Sep.07,-223700,-253943,48.5,-38.4,-17,0.2824,-7.0935,8.5822,-2.4858,6.8433,-10.8648,2.5085,-2 +KAsO4-2,NA,KAsO4-2,aq,MA07,MA10,12.Sep.07,-228428,-249049,84,-45.5,-9.64,1.1121,-5.0669,7.712,-2.5696,-2.2416,-12.307,1.9714,-2 +MgAsO4-,NA,MgAsO4-,aq,MA07,MA10,12.Sep.07,-271474,-307316,9.64,-55,-25.98,-1.3284,-11.0278,10.2713,-2.3232,-12.33,-14.2311,1.3662,-1 +CaAsO4-,NA,CaAsO4-,aq,MA07,MA10,12.Sep.07,-294913,-323114,37.4,-57.2,-25.5,-1.3685,-11.1259,10.3134,-2.3191,-17.4821,-14.6772,1.0531,-1 +SrAsO4-,NA,SrAsO4-,aq,MA07,MA10,12.Sep.07,-296243,-323239,43.9,-59.7,-25.41,-1.3889,-11.1758,10.3349,-2.317,-19.8655,-15.1905,0.9562,-1 +MnAsO4-,NA,MnAsO4-,aq,MA07,MA10,12.Sep.07,-218289,-247805,30.7,-53.7,-25.37,-1.2541,-10.8464,10.1934,-2.3307,-14.5434,-13.9785,1.339,-1 +FeAsO4-,NA,FeAsO4-,aq,MA07,MA10,12.Sep.07,-186668,-218541,21.7,-57.5,-26.07,-1.3653,-11.1181,10.3101,-2.3194,-15.504,-14.7525,1.2932,-1 +CoAsO4-,NA,CoAsO4-,aq,MA07,MA10,12.Sep.07,-177190,-210481,17.6,-57.4,-26.53,-1.4073,-11.2205,10.3541,-2.3152,-14.8722,-14.7322,1.3555,-1 +NiAsO4-,NA,NiAsO4-,aq,MA07,MA10,12.Sep.07,-176304,-211320,11.8,-61.3,-27.01,-1.4432,-11.3083,10.3918,-2.3116,-16.3404,-15.5266,1.4434,-1 +CuAsO4-,NA,CuAsO4-,aq,MA07,MA10,12.Sep.07,-151743,-183607,23.1,-55.3,-26.4,-1.4178,-11.2463,10.3651,-2.3141,-14.418,-14.3044,1.2716,-1 +ZnAsO4-,NA,ZnAsO4-,aq,MA07,MA10,12.Sep.07,-200121,-233853,18.9,-55,-26.36,-1.3907,-11.1799,10.3366,-2.3169,-13.6104,-14.229,1.3358,-1 +PbAsO4-,NA,PbAsO4-,aq,MA07,MA10,12.Sep.07,-169793,-194437,54.9,-62.3,-25.16,-1.4108,-11.2291,10.3577,-2.3148,-22.9414,-15.7303,0.7904,-1 +AlAsO4,NA,AlAsO4,aq,MA07,MA10,12.Sep.07,-285558,-330011,-35.9,-60.2,-9.75,0.418,-6.7624,8.44,-2.4995,-29.3427,-15.3014,-0.038,0 +FeAsO4,NA,FeAsO4,aq,MA07,MA10,12.Sep.07,-177862,-218546,-23.5,-84.8,-13.09,-0.0391,-7.8787,8.9193,-2.4533,-43.7161,-20.3124,-0.038,0 +NaH2AsO3,NA,NaH2AsO3,aq,MA07,MA10,12.Sep.07,-203270,-228832,39.7,28.4,32.7,6.2236,7.4178,2.3518,-3.0857,22.4338,2.7495,-0.038,0 +AgH2AsO3,NA,AgH2AsO3,aq,MA07,MA10,12.Sep.07,-123526,-147071,44.3,25.8,33,6.2709,7.5332,2.3022,-3.0905,20.9088,2.2178,-0.038,0 +MgH2AsO3+,NA,MgH2AsO3+,aq,MA07,MA10,12.Sep.07,-251410,-286183,-11.3,41.3,9.9,3.3617,0.4276,5.353,-2.7967,36.9078,5.3772,0.7149,1 +CaH2AsO3+,NA,CaH2AsO3+,aq,MA07,MA10,12.Sep.07,-274922,-301872,17.1,36.4,13.8,3.7486,1.3726,4.9473,-2.8358,30.0706,4.3735,0.2853,1 +SrH2AsO3+,NA,SrH2AsO3+,aq,MA07,MA10,12.Sep.07,-275601,-300702,25.8,30.7,14.5,3.8032,1.506,4.89,-2.8413,25.5459,3.2185,0.1538,1 +BaH2AsO3+,NA,BaH2AsO3+,aq,MA07,MA10,12.Sep.07,-276315,-297936,40.1,25.6,19.9,4.4634,3.1185,4.1977,-2.908,20.5926,2.1872,-0.0628,1 +CuH2AsO3+,NA,CuH2AsO3+,aq,MA07,MA10,12.Sep.07,-134368,-164924,3,40.5,6.5,2.8237,-0.8865,5.9172,-2.7424,34.4453,5.2122,0.499,1 +PbH2AsO3+,NA,PbH2AsO3+,aq,MA07,MA10,12.Sep.07,-153138,-174063,42.8,24.7,16.5,3.9918,1.9667,4.6922,-2.8603,19.6811,2.0039,-0.1047,1 +AlH2AsO3+2,NA,AlH2AsO3+2,aq,MA07,MA10,12.Sep.07,-266611,-309612,-55.5,25.5,-15.6,0.2882,-7.0795,8.5761,-2.4864,38.8545,2.1567,1.929,2 +FeH2AsO3+2,NA,FeH2AsO3+2,aq,MA07,MA10,12.Sep.07,-154392,-192413,-39.1,56.8,-7.3,1.3321,-4.5295,7.4813,-2.5918,54.8314,8.5274,1.6797,2 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz 2017-10-16 14:30:48 UTC (rev 259) +++ pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz 2017-10-17 06:44:12 UTC (rev 260) @@ -1,4 +1,4 @@ -?7zXZ???F!t/?????? ]7I??b???9??????TB;q?"?q???cL;?"??b???-?y?bZ?/??3O7??????g?H -?_i?~??6?aA ?&6???B~GQC???k??]???????~???' ?SE?????T???3i???f?1??i??(V l{ m???????=???z/1(??,B???1 -?@?E?Uox????}?@??]3?-A??? Ia? ?s3?f?=u???m?*?[?4??????|r??s\???{??????E???HwB??X??Mq???%?y????O????-??j??i?5, -????????W????n??R???V??9}?? =K??lw?????z?f*?W ??? j1????/??>?w??????%?d>qrU???????:?D???=??Nt -+?rQ.??c?5l?/????_Tj}?)?*??#?>??m-_??T?3?0(???_v?q?c? -????x?z?=^??R-Q?????g,k=S??E?O???]?=??&???8g???dY???B}????D v@??E?!??* ?????U??? ?.?? ????2?>??:???[]??^?F????][???A??.~????Qv??????@]*@????lC?i????~r?#?Hy??????V????n?$1?d??hE????J? -??t -6n??5S??????2?@????8#???fy???U??c???=_????????,f>???? r?t???{?}a?@????Z??g0\:!?_jmu????Sm?? -????D????????-?]#????L????B????)???=x'6??[?J$F*:1?a]??????U??]?Rf'????????v??5edr???&?r#{|?);???cDC??0?k?{7>h??.??Qbz? ?%????]o?u?=?J???5??h?????A??????????'?oA?M" ?t?{? - -?i -?!?~H+?????6!????G?E??v???p?r:??#??rW!Z???;#?????Z? @?@uba? ??Z???[??%B?13?????????e#J]???p?T>??????(Nnc???dR?z!?lR?{?egd????#]?v??)+??0??D????+??l?????\?GK N?g???30pHR[??A?_?9?A&?#8?n?rYikl?S?_V?\?[M?O?I?n*?????|sGA$?tR????!"?)A???j??V5W?CJ??`?6?????dy??20??#?^W??ii@?????x????/??p`?m??;??R?6?,J;B_ at 6MHjo -??H:V?h,;bR?,^?????q??iq?#~?g^?y ?1???r???Iv??????q=?AAUP??`  ??????>B;T\?_?uNw?.z?6 P?/????{?@??u??????9xp?J5?4$?[~^??7?? -?pk.{??|/'?"6?V?P???SG]???K?HFZ@=??eg????5u???0?????? X????s|:])N?????? ?F?~?bR????9???????)?????F.?Ohe?2??z?? ?7 at 6?E?ts -??H??kQ?c?p?[,????? =???n?????l????:?0???????0???ge;o??T???3i???f?1??i??(V l{ m????????b&????k?2?????????&}??5[? +9????dm????C??}_:?ED4 ?F??-?lt,???&/P5????u???f}??'3?p??"?W??Q|?????F??s??V?F??.???v?|F????-?d|??P??p????)bq"YZ?j??????t??? +???e^:??e6??4w?nAu?L??????@v??SrfC???!???9????? ?%?"T?P??????v?&?z???R??5?gq????4N???E/????!+????cl?_???'?b)???Z??????_?????I??f??s??i??SO????+???Y??D!??????j?????&&?z??7??\??\?>??:?!?%?Z??1`?%?M??????????'????D?Qo?GDzIu?????E?s l]????? ND&rx???}dQG?GA?X???!q?o`BXm?-z-?j???8??`??(e??t?,9+`??l ??M?yc???B?;?_#MW M?????"??S?e?b?~k?w?Cf`c?e#3???\+?".?????:O\8? +??s??w??@Iq?????m0UJ??7 _?6L;??\?*H??2l[x$r??a??0ag?7??| +???]^qJ??2????B1{??"M?kj? ??>??C??p???????t?o???%?I?y??:?4?\???.????+d?W?t???????\??7h?U?\?y?D???b???u?3M ???? ?? ?l;?Z??31???e?%F??U;????)]??o9?F??????Y?@)?#]_%????????~l???H?`?????j&!?? ?BM?????O??k~??:???:? ?25:?? ?P????k??? ?w?X?_???????V0d?Y?#?V?|` E ?g???M9?????V?l(Rls?H??'?&hz??a?~?'V?B??|???qp??R?1?z?&OS??_m??h?J??K]???h?,?%?K???????C)????ml???gF>$0????!a?(?IE?Y??R?;????#W?>O??&?j_-,'[2??*???????mSUPCRTBL is a modification and data update for the SUPCRT92 package ([Zimmer et al., 2016](https://doi.org/10.1016/j.cageo.2016.02.013)). Data for SiO2(*aq*) were updated to reflect the higher observed solubility of quartz compared to the SUPCRT92 dataset, and other aqueous species and minerals relevant to environmental geochemistry were added.\n\n") -cat("NOTE 1: The SUPCRTBL modifications apply the [Holland and Powell (2011)](https://doi.org/10.1111/j.1525-1314.2010.00923.x) equations and dataset for minerals, which are not available in CHNOSZ. As an alternative to the default dataset of [Helgeson et al. (1978)](http://www.worldcat.org/oclc/13594862), CHNOSZ offers the [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) formulation (see the **Solids** / **Berman** section of this vignette).\n") [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 260 From noreply at r-forge.r-project.org Wed Oct 18 18:07:00 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 18 Oct 2017 18:07:00 +0200 (CEST) Subject: [CHNOSZ-commits] r261 - in pkg/CHNOSZ: . R data demo inst inst/extdata/OBIGT man vignettes Message-ID: <20171018160700.DB1F9188F6D@r-forge.r-project.org> Author: jedick Date: 2017-10-18 18:07:00 +0200 (Wed, 18 Oct 2017) New Revision: 261 Added: pkg/CHNOSZ/demo/go-IU.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/util.expression.Rd pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib Log: add demo/go-IU.R for diagrams using data in SUPCRTBL Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-18 16:07:00 UTC (rev 261) @@ -1,6 +1,6 @@ -Date: 2017-10-17 +Date: 2017-10-18 Package: CHNOSZ -Version: 1.1.0-59 +Version: 1.1.0-60 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-18 16:07:00 UTC (rev 261) @@ -118,9 +118,13 @@ sinfo <- numeric() newstate <- character() for(i in 1:length(species)) { - mysearch <- species[i] - if(can.be.numeric(mysearch)) mysearch <- thermo$obigt$name[as.numeric(mysearch)] - si <- info.character(mysearch, state[i]) + # get the species index for a named species + if(!can.be.numeric(species[i])) si <- info.character(species[i], state[i]) + else { + # check that a numeric argument is a rownumber of thermo$obigt + si <- as.numeric(species[i]) + if(!si %in% 1:nrow(thermo$obigt)) stop(paste(species[i], "is not a row number of thermo$obigt")) + } # that could have the side-effect of adding a protein; re-read thermo thermo <- get("thermo", "CHNOSZ") if(is.na(si[1])) stop('no info found for ',species[i],' ',state[i]) Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/R/util.expression.R 2017-10-18 16:07:00 UTC (rev 261) @@ -2,19 +2,21 @@ # write descriptions of chemical species, properties, reactions, conditions # modified from describe(), axis.label() 20120121 jmd -expr.species <- function(species, state="", log="", value=NULL) { +expr.species <- function(species, state="", log="", value=NULL, use.makeup=FALSE) { # make plotting expressions for chemical formulas # that include subscripts, superscripts (if charged) # and optionally designations of states +/- loga or logf prefix if(length(species) > 1) (stop("more than one species")) # convert to character so that "1", "2", etc. don't get converted to chemical formulas via makeup() species <- as.character(species) - # the counts of elements in the species: - # here we don't care too much if an "element" is a real element - # (listed in thermo$element), so we suppress warnings - elements <- suppressWarnings(try(makeup(species), TRUE)) - # if `species` can't be parsed as a chemical formula, we don't do the formula formatting - if(identical(class(elements), "try-error")) expr <- species + if(use.makeup) { + # the counts of elements in the species: + # here we don't care too much if an "element" is a real element + # (listed in thermo$element), so we suppress warnings + elements <- suppressWarnings(try(makeup(species), TRUE)) + } else elements <- split.formula(species) + # if species can't be parsed as a chemical formula, we don't do the formula formatting + if(identical(class(elements), "try-error") | !is.numeric(elements)) expr <- species else { # where we'll put the expression expr <- "" @@ -194,15 +196,18 @@ return(as.expression(desc)) } -describe.property <- function(property=NULL, value=NULL, digits=1, oneline=FALSE, ret.val=FALSE) { +describe.property <- function(property=NULL, value=NULL, digits=0, oneline=FALSE, ret.val=FALSE) { # make expressions for pressure, temperature, other conditions if(is.null(property) | is.null(value)) stop("property or value is NULL") propexpr <- valexpr <- character() for(i in 1:length(property)) { propexpr <- c(propexpr, expr.property(property[i])) - thisvalue <- format(round(value[i], digits), nsmall=digits) - thisunits <- expr.units(property[i]) - thisvalexpr <- substitute(a~b, list(a=thisvalue, b=thisunits)) + if(value[i]=="Psat") thisvalexpr <- quote(italic(P)[sat]) + else { + thisvalue <- format(round(as.numeric(value[i]), digits), nsmall=digits) + thisunits <- expr.units(property[i]) + thisvalexpr <- substitute(a~b, list(a=thisvalue, b=thisunits)) + } valexpr <- c(valexpr, as.expression(thisvalexpr)) } # with ret.val=TRUE, return just the value with the units (e.g. 55 degC) @@ -280,3 +285,54 @@ } lab } + +### unexported function ### + +split.formula <- function(formula) { + ## like makeup(), but split apart the formula based on + ## numbers (subscripts); don't scan for elemental symbols 20171018 + # if there are no numbers or charge, return the formula as-is + if(! (grepl("[0-9]", formula) | grepl("\\+[0-9]?$", formula) | grepl("-[0-9]?$", formula))) return(formula) + # first split off charge + # (assume that no subscripts are signed) + Z <- 0 + hascharge <- grepl("\\+[0-9]?$", formula) | grepl("-[0-9]?$", formula) + if(hascharge) { + # for charge, we match + or - followed by zero or more numbers at the end of the string + if(grepl("\\+[0-9]?$", formula)) { + fsplit <- strsplit(formula, "+", fixed=TRUE)[[1]] + if(is.na(fsplit[2])) Z <- 1 else Z <- as.numeric(fsplit[2]) + } + if(grepl("-[0-9]?$", formula)) { + fsplit <- strsplit(formula, "-")[[1]] + if(is.na(fsplit[2])) Z <- -1 else Z <- -as.numeric(fsplit[2]) + } + formula <- fsplit[1] + } + # to get strings, replace all numbers with placeholder (#), then split on that symbol + # the outer gsub is to replace multiple #'s with one + numhash <- gsub("#+", "#", gsub("[0-9]", "#", formula)) + strings <- strsplit(numhash, "#")[[1]] + # to get coefficients, replace all characters (non-numbers) with placeholder, then split + charhash <- gsub("#+", "#", gsub("[^0-9]", "#", formula)) + coeffs <- strsplit(charhash, "#")[[1]] + # if the first coefficient is empty, remove it + if(coeffs[1]=="") coeffs <- tail(coeffs, -1) else { + # if the first string is empty, treat the first coefficient as a leading string (e.g. in 2-octanone) + if(strings[1]=="") { + strings[2] <- paste0(coeffs[1], strings[2]) + coeffs <- tail(coeffs, -1) + strings <- tail(strings, -1) + } + } + # if we're left with no coefficients, just return the string + if(length(coeffs)==0 & Z==0) return(strings) + # if we're missing a coefficient, append one + if(length(coeffs) < length(strings)) coeffs <- c(coeffs, 1) + # use strings as names for the numeric coefficients + coeffs <- as.numeric(coeffs) + names(coeffs) <- strings + # include charge if it is not 0 + if(Z!=0) coeffs <- c(coeffs, Z=Z) + return(coeffs) +} Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/data/refs.csv 2017-10-18 16:07:00 UTC (rev 261) @@ -5,12 +5,13 @@ Kel60.3,"K. K. Kelley",1960,"U. S. Bureau of Mines Bull. 584","gypsum Cp",http://www.worldcat.org/oclc/693388901 Pan70,"L. B. Pankratz",1970,"U. S. Bureau of Mines Report of Investigations 7430",chlorargyrite,http://www.worldcat.org/oclc/14154245 PK70,"L. B. Pankratz and E. G. King",1970,"U. S. Bureau of Mines Report of Investigations 7435","bornite and chalcopyrite",http://www.worldcat.org/oclc/14154292 +FSR76,"M. J. Ferrante et al.",1976,"U. S. Bureau of Mines Report of Investigations 8129","dawsonite Cp (value at 25 °C as listed by @BPAH07; not present in spronsbl.dat)",http://www.worldcat.org/oclc/932914138 HDNB78,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","data for minerals (n = 167) and phase transitions",http://www.worldcat.org/oclc/13594862 HDNB78.1,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","litharge S, V, and Cp parameters",http://www.worldcat.org/oclc/13594862 -RHF79,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","chlorargyrite, rutile, and titanite",http://pubs.er.usgs.gov/publication/b1452 -RHF79.1,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","dickite, fluorphlogopite, halloysite, and pyrope",http://pubs.er.usgs.gov/publication/b1452 -RHF79.2,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452",iron,http://pubs.er.usgs.gov/publication/b1452 -RHF79.3,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452","gibbsite GHS",http://pubs.er.usgs.gov/publication/b1452 +RHF78,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1978,"U. S. Geological Survey Bull. 1452","chlorargyrite, rutile, and titanite",http://pubs.er.usgs.gov/publication/b1452 +RHF78.1,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1978,"U. S. Geological Survey Bull. 1452","dickite, fluorphlogopite, halloysite, and pyrope",http://pubs.er.usgs.gov/publication/b1452 +RHF78.2,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1978,"U. S. Geological Survey Bull. 1452",iron,http://pubs.er.usgs.gov/publication/b1452 +RHF78.3,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1978,"U. S. Geological Survey Bull. 1452","gibbsite GHS",http://pubs.er.usgs.gov/publication/b1452 PB82,"L. N. Plummer and E. Busenberg",1982,"Geochim. Cosmochim. Acta 46, 1011-1040","aragonite and calcite",https://doi.org/10.1016/0016-7037(82)90056-4 WEP+82,"D. D. Wagman, W. H. Evans et al.",1982,"J. Phys. Chem. Ref. Data 11, Suppl. 2, 1-392","gases GHS",https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf WEP+82.1,"D. D. Wagman, W. H. Evans et al.",1982,"J. Phys. Chem. Ref. Data 11, Suppl. 2, 1-392",manganosite,https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/demo/00Index 2017-10-18 16:07:00 UTC (rev 261) @@ -20,5 +20,6 @@ activity_ratios Mineral stability plots with activity ratios on the axes adenine HKF parameters regressed from heat capacity and volume of aqueous adenine DEW Deep Earth Water (DEW) model for high pressures -lambda Effects of lambda transtion on thermodynamic properties of quartz -TCA Standard Gibbs energies of steps of the tricarboxylic acid cycle +lambda Thermodynamic properties of lambda transition in quartz +TCA Standard Gibbs energies of steps of the citric acid cycle +go-IU Diagrams using thermodynamic data in the SUPCRTBL compilation Added: pkg/CHNOSZ/demo/go-IU.R =================================================================== --- pkg/CHNOSZ/demo/go-IU.R (rev 0) +++ pkg/CHNOSZ/demo/go-IU.R 2017-10-18 16:07:00 UTC (rev 261) @@ -0,0 +1,140 @@ +# CHNOSZ/demo/go-IU.R 20171018 +# diagrams using data from the SUPCRTBL compilation +# (BL = Bloomington campus of Indiana University) + +## set up plotting area +par(mfrow=c(2, 2)) + +## start with default database +data(thermo) + +########### +### plot 1: boehmite - kaolinite equilibrium +########### +## experimental data from Table 1 of Hemley et al., 1980 +# doi:10.2113/gsecongeo.75.2.210 +xT <- c(200, 200, 200, 200, 250, 250, 300, 300, 300, 300) +xlogaSiO2 <- -c(2.54, 2.59, 2.65, 2.77, 2.21, 2.32, 1.90, 1.95, 1.94, 1.90) +## set up basis species so that axis.label shows activity of SiO2 +basis(c("Al2O3","SiO2", "H2O", "O2")) +T <- 125:350 +thermo.plot.new(xlim=range(T), ylim=c(-3.5, -1.5), xlab = axis.label("T"), ylab=axis.label("SiO2")) +points(xT, xlogaSiO2) +basis(delete=TRUE) +## first calculation: CHNOSZ default (SiO2 from SHS89, kaolinite and boehmite from HDNB78) +r1 <- subcrt(c("boehmite", "H2O", "SiO2", "kaolinite"), c(-1, -0.5, -1, 0.5), T=T, P=1000, exceed.Ttr = TRUE) +# we need exceed.Ttr = TRUE because the T limit for boehmite is 500 K (Helgeson et al., 1978) +## second calculation: kaolinite from Berman, 1988 +Kln_Berman <- info("kaolinite", "cr_Berman") +r2 <- subcrt(c("boehmite", "H2O", "SiO2", Kln_Berman), c(-1, -0.5, -1, 0.5), T=T, P=1000, exceed.Ttr = TRUE) +## third calculation: boehmite from Hemingway et al., 1991 +add.obigt("SUPCRTBL", "boehmite") +r3 <- subcrt(c("boehmite", "H2O", "SiO2", Kln_Berman), c(-1, -0.5, -1, 0.5), T=T, P=1000) +## fourth calculation: SiO2 from Apps and Spycher, 2004 +add.obigt("SUPCRTBL", "SiO2") +r4 <- subcrt(c("boehmite", "H2O", "SiO2", Kln_Berman), c(-1, -0.5, -1, 0.5), T=T, P=1000) +## log activity of SiO2 is -ve logK +lines(T, -r1$out$logK) +lines(T, -r2$out$logK, lty=2) +lines(T, -r3$out$logK, lty=2, col="red") +lines(T, -r4$out$logK, col="red") +## add labels, legend, and title +text(182.5, -3.17, "SUPCRT92\n(CHNOSZ default)", srt=48, cex=0.7, font=2) +text(147, -3.1, "SUPCRTBL", srt=45.5, cex=0.7, font=2, col="red") +legend("topleft", lty=c(1, 2, 2, 1), col=c("black", "black", "red", "red"), bty="n", cex=0.9, + legend=c("Kln,Bhm:HDNB78; SiO2:SHS89", "Kln:Ber88", "+ Bhm:HRA91", "+ SiO2:AS04")) +legend("bottomright", pch=1, legend="Hemley et al., 1980", bty="n", cex=0.9) +mtitle(c("Kaolinite - Boehmite", "After Zhu and Lu, 2009 Fig. A1"), cex=0.95) +# doi:10.1016/j.gca.2009.03.015 + +########### +### plot 2: dawsonite solubility +########### +## experimental data from Benezeth et al., 2007 Table 5 +# doi:10.1016/j.gca.2007.07.003 +# (averages for each temperature in a single run) +T <- c(100.1, 100.1, 150.1, 100.1, 150.1, 99.8, 99.8, 200.7, 99.8, 50.1, 75.1, 100.3, 150.1) +logK <- -c(14.825, 14.735, 13.625, 14.79, 13.665, 14.725, 14.1775, 12.74, 14.4925, 16.8625, 15.61, 14.51, 13.455) +plot(T, logK, xlim=c(25, 250), ylim=c(-18, -10), xlab=axis.label("T"), ylab=axis.label("logK")) +# this gets us dawsonite and Al(OH)4- +add.obigt("SUPCRTBL") +T <- 0:250 +# calculation 1: dawsonite with non-zero Cp +species <- c("dawsonite", "H2O", "Al(OH)4-", "HCO3-", "Na+", "H+") +coeffs <- c(-1, -2, 1, 1, 1, 1) +Daw1 <- subcrt(species, coeffs, T=T) +# calculation 2: dawsonite with 0 Cp +mod.obigt("dawsonite", Cp=0) +Daw2 <- subcrt(species, coeffs, T=T) +## plot the calculated logKs +lines(T, Daw1$out$logK, col="red") +lines(T, Daw2$out$logK, col="red", lty=2) +## add labels, legend, and title +text(182.5, -3.17, "SUPCRT92\n(CHNOSZ default)", srt=43, cex=0.7, font=2) +text(145, -3.1, "SUPCRTBL", srt=41.5, cex=0.7, font=2, col="red") +legend("topleft", lty=1:2, col="red", bty="n", cex=0.9, + legend=c("Daw Cp != 0", "Daw Cp = 0")) +legend("bottomright", pch=1, legend="Ben\u00e9z\u00e9th et al., 2007", bty="n", cex=0.9) +mtitle(c("Dawsonite - aqueous species", "After Zimmer et al., 2016 Fig. 2"), cex=0.95) +# doi:10.1016/j.cageo.2016.02.013 + +########### +### plot 3: Eh-pH diagram for As-O-H-S +########### +add.obigt("SUPCRTBL") +#basis(c("Fe", "As", "H2O", "H2S", "H+", "e-")) +#basis(c("Fe", "H2S"), c(-6, -3)) +basis(c("As", "H2O", "H2S", "H+", "e-")) +basis(c("H2S"), c(-3)) +As_aq <- c("H3AsO4", "H2AsO4-", "HAsO4-2", "AsO4-3", "H3AsO3", "H2AsO3-", "HAsO3-2", "AsO3-3") +AsS_aq <- c("AsS(OH)HS-", "As3S4(HS)2-") +As_cr <- "As" +AsS_cr <- c("realgar,alpha", "realgar,beta", "orpiment", "orpiment,amorphous") +FeAs_cr <- c("arsenopyrite", "scorodite", "ferric arsenate,amorphous") +#species(c(As_aq, AsS_aq, As_cr, AsS_cr, FeAs_cr)) +species(c(As_aq, AsS_aq, As_cr, AsS_cr)) +species(c(As_aq, AsS_aq), -5) +## a simple diagram, but using only H2S at all pH +#a <- affinity(pH=c(0, 14), Eh=c(-1, 1.5)) +#diagram(a) +# the S basis species depends on pH +bases <- c("H2S", "HS-", "HSO4-", "SO4-2") +# calculate affinties of formation reactions using the speciated S basis species +res <- 300 +# we "blend" the transitions with pH, unlike LZ11's diagram where +# it appears the S-basis species are switched in an on/off fashion +m <- mosaic(bases, pH=c(2, 14, res), Eh=c(-0.6, 0.8, res), blend=TRUE) +# adjust colors and names +fill <- rev(heat.colors(nrow(species()))) +fill[11:15] <- "darkgrey" +m$A.species$species$name <- gsub(",alpha", "", m$A.species$species$name) +diagram(m$A.species, fill=fill) +dprop <- describe.property(c("T", "P"), c(25, 1)) +legend("topright", legend=dprop, bty="n") +t1 <- quote("As-O-H-S, "~list(sum(S)==10^-3*M, sum(As)==10^-5*M)) +t2 <- "After Lu and Zhu, 2011 Fig. 2b" +mtitle(as.expression(c(t1, t2)), cex=0.95) +# doi:10.1007/s12665-010-0652-x + +########### +### plot 4: aqueous Al species +########### +add.obigt("SUPCRTBL") +basis(c("Al+3", "F-", "H+", "O2", "H2O")) +Al <- "Al+3" +AlOH <- c("Al(OH)4-", "AlOH+2", "Al(OH)2+", "Al(OH)3") +AlF <- c("AlF+2", "AlF2+", "AlF3", "AlF4-") +AlOHF <- c("Al(OH)2F2-", "Al(OH)2F", "AlOHF2") +species(c(Al, AlOH, AlF, AlOHF), "aq") +a <- affinity(pH=c(0, 10), `F-`=c(-1, -9), T=200) +diagram(a, fill=cm.colors(nrow(species()))) +dprop <- describe.property(c("T", "P"), c(200, "Psat")) +legend("topright", legend=dprop, bty="n") +mtitle(c("Aqueous aluminum species", + "After Tagirov and Schott, 2001 Fig. 4d"), cex=0.95) +# doi:10.1016/S0016-7037(01)00705-0 + +########### +### clean up: restore thermodynamic database to default +########### +data(thermo) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/inst/NEWS 2017-10-18 16:07:00 UTC (rev 261) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-59 (2017-10-17) +CHANGES IN CHNOSZ 1.1.0-60 (2017-10-18) --------------------------------------- MAJOR CHANGES: @@ -23,7 +23,7 @@ - In equilibrate(), it is now possible to combine affinity calculations with variable activity of the balancing basis species (loga.balance). - For example, in the last plot of the DEW demo, the affinity transect + For example, in the last plot of the DEW demo, the calculation involves simultaneously varying temperature and logfO2 (given as arguments to affinity()) as well as total concentration of carbon (given by the loga.balance argument in equilibrate()). @@ -99,7 +99,7 @@ - Add SUPCRTBL.csv with mineral and aqueous species data compiled by Zimmer et al., 2016. Data were taken from original references or from spronsbl.dat (http://www.indiana.edu/~hydrogeo/supcrtbl.html). - [Optional Data] + The new demo/go-IU.R uses these data. [Optional Data] - Update HKF parameters of adenine based on experimental heat capacity and volume data (Lowe et al., 2017). Add demo/adenine.R comparing Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRTBL.csv 2017-10-18 16:07:00 UTC (rev 261) @@ -12,9 +12,9 @@ "ferric arsenate,amorphous",NA,FeAsO4.2H2O,cr,LMR06,ZZL+16,16.Oct.17,-303771.51051625237,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA "barium arsenate",NA,Ba3(AsO4)2,cr,ZZX+05,ZZL+16,16.Oct.17,-739749.0439770555,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA "barium hydrogen arsenate",NA,BaHAsO4.H2O,cr,ZZX+05,ZZL+16,16.Oct.17,-367746.1759082218,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -boehmite,NA,AlO2H,cr,HRA91,ZZL+16.2,17.Oct.17,-219502.86806883363,-238145.3154875717,8.888623326959847,12.97634,19.535,40.48757170172084,-4.1108986615678775,0.6962476099426387,-467.3996175908221,0,0,0,NA -gibbsite,NA,Al(OH)3,cr,RHF79.3,ZZL+16.2,17.Oct.17,-276025.1,-309065,16.35755,21.72251,31.956,22.179732313575524,45.276768642447415,0.3199569789674952,-247.20363288718926,0,0,0,NA -dawsonite,NA,NaAlCO3(OH)2,cr,ZZL+16.3,NA,17.Oct.17,-425979.9,-463456,32.91109,NA,NA,0,0,0,0,0,0,0,NA +boehmite,NA,AlO(OH),cr,HRA91,ZZL+16.2,17.Oct.17,-219502.86806883363,-238145.3154875717,8.888623326959847,12.97634,19.535,40.48757170172084,-4.1108986615678775,0.6962476099426387,-467.3996175908221,0,0,0,NA +gibbsite,NA,Al(OH)3,cr,RHF78.3,ZZL+16.2,17.Oct.17,-276025.1,-309065,16.35755,21.72251,31.956,22.179732313575524,45.276768642447415,0.3199569789674952,-247.20363288718926,0,0,0,NA +dawsonite,NA,NaAlCO3(OH)2,cr,ZZL+16.3,FSR76,17.Oct.17,-425979.9,-463456,32.91109,34.08222,NA,NA,NA,NA,NA,NA,NA,NA,NA H3AsO4,NA,H3AsO4,aq,NA03.1,NA,17.Oct.17,-183257.6481835564,-215929.7323135755,43.75478011472275,NA,NA,NA,NA,NA,NA,NA,NA,NA,0 H2AsO4-,NA,H2AsO4-,aq,NA03.1,NA,17.Oct.17,-180126.67304015296,-217834.60803059273,26.85946462715105,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 HAsO4-2,NA,HAsO4-2,aq,NA03.1,NA,17.Oct.17,-170585.56405353727,-217115.20076481835,-2.7294455066921604,NA,NA,NA,NA,NA,NA,NA,NA,NA,-2 @@ -24,7 +24,7 @@ HAsO3-2,NA,HAsO3-2,aq,NA03.1,NA,17.Oct.17,-121271.51051625238,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-2 AsO3-3,NA,AsO3-3,aq,NA03.1,NA,17.Oct.17,-100812.61950286807,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-3 As3S4(HS)2-,NA,As3S4(HS)2-,aq,NA03.1,NA,17.Oct.17,-30019.12045889101,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 -AsS(OH)SH-,NA,AsS(OH)SH-,aq,NA03.1,NA,17.Oct.17,-58413.00191204589,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 +AsS(OH)HS-,NA,AsS(OH)HS-,aq,NA03.1,NA,17.Oct.17,-58413.00191204589,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-1 SiO2,NA,SiO2,aq,AS04,ZZL+16,16.Oct.17,-199539.9,-212179,11.12811,NA,NA,1.9,1.7,20,-2.7,32.22,-25.29001,0.3427103,0 H4SiO4,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 Al+3,NA,Al+3,aq,TS01,NA,25.Aug.06,-116510,NA,-81.203,-28.56,-45.3,-3.3984,-16.0789,12.0699,-2.1143,14.4295,-8.8523,2.7403,3 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz 2017-10-17 06:44:12 UTC (rev 260) +++ pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv.xz 2017-10-18 16:07:00 UTC (rev 261) @@ -1,4 +1,4 @@ -?7zXZ???F!t/????S&%]7I??b???9??????TB;q?"?q???cL;?"??? @@ -27,55 +27,43 @@ ^????$}??p??????.?Ar>???( ?5????K?Sp,??????8A????~~x???? ?L(>O???@ -??"-=oI?b?1??o????:.?:?'?I?????&)??f"??1"?H??????;)i??;O????dH???????????9k ?s??~81Y?' ?,??o? - +????????????jH??e?????.?2???/?p'?~??s?S>??]?C8?? |?;r?t,?dq?EpC?Z???? ?q\??q?'???hs?)?\????+?n???G@??[?g=W?;?`oE8Pk??????w???8?s+??8?%?*???^???bd?Y"?\??{? ??&K*????z|f=fH%?:?+sun??E?{?#??Xo?4??{??ne^?X?F?kc? -???21??~B?s8?WY???6?9ma?% -?[Q*?[??????4?w?????D?D*? U?OFA??????s?????????": -?)Y??U?"???d????^~mR?????g??@?m???4????-$??J???e?? %???????+?;?'??Zqq???w?????D?? u??VI?,?B?T~[?{????c???[?'??>_?G?j?/?/o?6W 8???v??s??o?2&U G[?}????!A`????????*??AZ????O?$??$??????f?eT??A??/?uM?*??.A???x5}???M???????H?t?(???>R?f]^G8c[3??a??????F?n?a?%?@??O??l-,??~?+QS?????C?)?D.PX?????BW/ ?{l? - ?R?R? ?,??!h?{??5??qe???????"Qu?? ???C?#???BA~???@??1g9?w?"=?O!?ZY???>????.?oD?Enc-H?G???J??n?f1 -?C0?g'c????S#GB?Ko E??}????Q??WkgFX??- ??????? ?6U>?&J?w?/?! -???}Q????t??d6??? ??m???????0?r?s???l??A, -?<~g?? -?Jb??t?*lM8??9?R????y?????Z?k?R ?9??????)]K^Z?47??;???(%????D????%?????G?ot?S{????d?V2S?j???0???s??$?tN???uL?R?UV??Zu??d0???.?}?;????a=?*oI?s?9?4????g?d???N?mgG????OB?}????d?????1?,[????{?F ?z??:??? :m?n0` :???b?????l??k+,?i?x?\x??wy/?? -3??zko?j?{v3?$^??s7^??_?:C ?2?H???w:??I?{wxY?K?n;? -x?t;W{?fm? -? -D?Hm??,??7?0$O\??[ 8??dmR???m?x?O ?????????j??O[?L?`EIK_}? {?v -d?L??whkx>I?? -??D??T?G_???&9????L,?l????v?H ??K?X?2Ez#1?b?oRb??4?y??bw,v?????#?G(T|GM'?,:??\^????M??=w?b%?f???g??????W???]??g?\6??'A???^????Qg?ue?x 6??b???l7??p?"O?P???E????G???o{}~??C??a?b?-?\OK?d???3?c???&@??k?Cwa??????pY??????A??:>??3d?????????l7????78???&E3[??Nj???[=k??z??I????|?j? -??`??5\jy??kh??/eF45????E???# -??x?j0P|6???S??+??1??k?????Q!?BL??A?????v??ah!??R????K???g?@?~?'????|y+??d?W,We#??>4l?Z???GL`??,?"?X?????~H?.??? ?f?w? -???6?w??????e??*?.Ayq??cD?L??????v??:???&b????? -GQ?JK?f?C?A?k?!*1?_]?>?????k?t.?????6??B(`???heJty?|^????:?#????????9t>?Vy????`?h4??????&?????m?_7?=??J?A????Y[f???r?????d?b?[?IZ ?n?6?(??????;?KJl?}e??s9?e?k???^??c???U?l^?=9???5??z?????L?C????O? ??.??[]??g?j? ??? -???B?~?=??????S?47????e?)???a[??Z? ????-0??&E?c?{?W???hF?wl?????vR???~?????V ??M??.y???~???7 -P?>P?~b?< ??fZ?E?pV*?x?h?V??O=I???h/?d??w?U??_??????[???CZ?????Q?K?????b??X=_?xl?<? ????? -@????6????Mf{/?R? ?G?????M??pP??=??4?=c+?N??O??b?p$[3????*"?Yq??/? ??_?~?T??3]?$?E/3??)?(?k?K3TI?s ?????A?????w?D????:'?.???r{l??&???P???2MG`R???t ????F"F?????2u{S8???H ?U ?I -??m????p????~C??a??NH4?hb ?Pb?FN?[|"m?{?????`????k?????2??? ?CM? -?I#+C4???3???@.??/7u?jH??J??@???????+%Z?????????Ml?OD??[f^i?X??%6???-??t?q?X??^??K?##7?&?L? F?|Pn?PA?????????????K???W??P#?? ??????D ???z\?w[??_p4B7??gj7Y?Y???S t?ZL???\g??Bc?o?????3? -?????T{?? %d?.?#%??3???Ip?mTG???YjL????f??fW\?4@%f????!>??%?????h??{ ?`U -x?-???? ??r?G(????~?????h???e??e????a?????+??????\?na"pg ?????O at Fl?B?%~fnV???'?????L ???2d#l?6????f???.???@F?d????? ?Q???Oq?u?!y???f?^7??F?????\n????[I?m??n?` ?'???K??^?e"t([p^Ko??h?Br??K?}N???F?"??i"R??% -??*h.n?n,9??P???G?v?qp?.??0??/?l???H5????,?2??e??????Z??}???hG#??p.??u ???y????3??hw????E???c/??f?????rM?v?j*?]?)v[?3.?[?j??m????? ????:?????4???n^?~#Q????=??$~?;?k??????U?]???#?RoC??*??5???RR?????????2???El? -???w?wI`?e?r6uL?:?u4\??9?pD?f?????[h:?#c??k\??|j???E,?w?????w????????_K?o;b????NQ?????+j?????]`??? ??????+? ??2?7??t?h5????(?:]:R?????bU?4?$??aT ?N?>?kf:C?????A??mp???#???$?@??+??A?7???????8?T?\bn????Pk?h??????&?U?VI??d?M;K^?a?:?o??6!}[????g??J????C -f???????5??? ???c??hO???Zz?)?$nU0?4??bTW?O????}?P??%t? ??G?K???i????`@#?d?Sp?y?f??M&,"?b???C???'?k?p?A??I?x?????V ??_x?????Jk?+e???k?? --IN?;?lnp??5b??D _?4?D;??4??<=?;O??3??F???;?"??B??`0k?a?l,??p]k?q ??U???"S?b{C?V)(?+???k? ???D?b??B?N?^ c?3I/?%7"?5????W)+B??Y?ZY?M?]%???2??/?????0??{Y?I?{?0?%?}??m?????L??"?2???}E?6.6y??b?????U[????Hljp???1:L|???????????? ?u?w?????c?7???rg?>?LPa???CEiy?*Qa?bF????_N&R??N%?'???cj???,?j?????D\-??}d??X??0 ]2w?](??V???[M????l??p??e8?~? -??+??????$h???QB at C1=T???&?@??iA?G?u? F?X,A@???"XB?N??Cz???-??'?m?]?y?" -?h?!L? ?C????????z??Dh??n??3???7li?zU???9 -X?S???f? ????j?7????? -?c???_???4b????pk!a???n?'F|$_???X?/??m???????:I??7?c??'3v??????t?e??ZD ?b?"???k??l"9{q9P2?( -???]2WqjK1?|?t0 -??2?G?J/BS??G??n?B??x?D?u?TY9?^????X?K?B?^?h`??z?'!? ??????U??o?2????o^??????2&T;?X9@?? pW?;??????%?/^??Tk<(Oi?MZ????@????*?:???Rx?]I??FiAG(?pW?}c;? ?~M????A?L?'?ki38=S??y?D???G???[?]GM?9????^, ?????? ??J??V?F???b????z`S?Z????R?*?yu???wM^?K???L????????g?YZ \ No newline at end of file +??"-=oI?b?1??o????:.?:?'?I?????&)??????3????^?N??i????yx? ? ???E??Lz???????y?????S?hc??yf?8?Lw??a???H`????ea?e???uk rOx?#h??rU?G??????r?E?????> p?W?Rtcj?VD?L)ZI?????[???e@? ???h???w)??)?????{?M??\rO???????3?G0,?]?????W>??7{?!???? +?MF5?g????(tIh?W??4???%?1F??????c??????P^?Z9????n]w????*?!?%?? +z'?F??uu?j(?i??[?|???S??g + uR??u???,???un?~????/lvii???s?X??1u?-y:)???>'Z?P?as?l???q??[?"?u?|hdD ??0>a4?k^?S?w???`?j}mH???+? +?~????)?n??8(?wUIQU?$??j?#=p?t??p?%m????a??4?W????"\Y???O?u???E?B??,j???????.???W;^??t;????#?J??????)??O;??s?????9E??,??0? ?f)?I?qD?6???#b 8???3??aRg?>???*?n^?s??m}~??jx-????\?f?H??{n??5??p??X????IPd\???b?:?M???z*?Y???>?m? V+8?w?O??)%?Kf?N'???+?/???u??dM???#?/?p????]w?=? +??:7??f???E[!apL??D-?VI?5?7?!??/>N!9?k?P?D??9_??=??Z>I$?Z??P??z???i?e??z?>???????1???a??`r?Lb??|?q???y???:X???:??G,???^??W??N???? ?V?'?k????J.E7?;yg?c????u????8w$R/.?]w??Cj?1??b?c0X???].?????a?x +?h??kHJ~???P.M?;??SM??Bv???XSp2v ?FJ,?0?(U?c?P(^-"??????TjI!?????l????M??Gi??????e ?w?6_sNW???%??i?Px??'???`"?E???s,@??V[??$&?????j? #5v?)5U?v???bf?;?g|$^?`?RkI??{V??Q?ika~?=??9?J[B?I??E\?*?6???>p???k ?? ????*;Sh.;L??4?d???????????n?????wv+?'?i)???? ?@???y??)?`ue??r?G?/T-E??N??%?dR?Q jb:??l???/j?=M' ???}?????T}T?$?v?b[??Z!??????5i??#??2?S^????????:?E??R4 $?[???m=?0U ?6?NCu?U{?? ??NQ+??c?3?q???bq?????{????Z? +h?? +1o?\?y ??:?M??????JQ??.J?~?x?qu?wD???=M?t?!?y?? Author: jedick Date: 2017-10-20 17:05:27 +0200 (Fri, 20 Oct 2017) New Revision: 262 Removed: pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv pkg/CHNOSZ/inst/extdata/thermo/Ste01.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/activity_ratios.R pkg/CHNOSZ/demo/adenine.R pkg/CHNOSZ/demo/go-IU.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/man/subcrt.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: cleanup: remove OBIGT/CHNOSZ_aq.csv Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-20 15:05:27 UTC (rev 262) @@ -1,6 +1,6 @@ -Date: 2017-10-18 +Date: 2017-10-20 Package: CHNOSZ -Version: 1.1.0-60 +Version: 1.1.0-61 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/R/info.R 2017-10-20 15:05:27 UTC (rev 262) @@ -79,9 +79,8 @@ # a match to thermo$obigt$state is also required if 'state' is not NULL # (first occurence of a match to species is returned otherwise) thermo <- get("thermo") - # all matches for the species - matches.species <- thermo$obigt$name==species | - thermo$obigt$abbrv==species | thermo$obigt$formula==species + # find matches for species name, abbreviation or formula + matches.species <- thermo$obigt$name==species | thermo$obigt$abbrv==species | thermo$obigt$formula==species # since thermo$obigt$abbrv contains NAs, convert NA results to FALSE matches.species[is.na(matches.species)] <- FALSE # turn it in to no match if it's a protein in the wrong state @@ -126,11 +125,14 @@ matches.species <- matches.state } # all of the species that match - ispecies <- which(matches.species) - # we return only the first species that matches - ispecies.out <- ispecies[1] - # let user know if there is more than one state for this species - if(length(ispecies) > length(ispecies.out)) { + ispecies.out <- ispecies <- which(matches.species) + # processing for more than one match + if(length(ispecies) > 1) { + # if a single name matches, use that one (useful for distinguishing pseudo-H4SiO4 and H4SiO4) 20171020 + matches.name <- matches.species & thermo$obigt$name==species + if(sum(matches.name)==1) ispecies.out <- which(matches.name) + else ispecies.out <- ispecies[1] # otherwise, return only the first species that matches + # let user know if there is more than one state for this species mystate <- thermo$obigt$state[ispecies.out] ispecies.other <- ispecies[!ispecies %in% ispecies.out] otherstates <- thermo$obigt$state[ispecies.other] Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-20 15:05:27 UTC (rev 262) @@ -532,7 +532,8 @@ out[[i]] <- cbind(out[[i]],data.frame(logQ=logQ,A=A)) } # 20120114 only prepend T, P, rho columns if we have more than one T - if(length(T) > 1) { + # 20171020 or if the 'property' argument is missing (it's nice to see everything using e.g. subcrt("H2O", T=150)) + if(length(T) > 1 | missing(property)) { # 20090329 added checks for converting T, P units if(convert) T.out <- outvert(T,"K") else T.out <- T if(convert) P.out <- outvert(P,"bar") else P.out <- P Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/data/refs.csv 2017-10-20 15:05:27 UTC (rev 262) @@ -145,7 +145,7 @@ CHNOSZ.1,"J. M. Dick",2017,"CHNOSZ package documentation","GHS (Tr) of the phase that is stable at 298.15 K was combined with Htr and the Cp coefficients to calculate the metastable GHS (Tr) of the phases that are stable at higher temperatures.",http://chnosz.net CHNOSZ.2,"J. M. Dick",2017,"CHNOSZ package documentation","alanate and glycinate: GHS as used by @DLH06",http://chnosz.net CHNOSZ.3,"J. M. Dick",2017,"CHNOSZ package documentation","metal-amino acid complexes: GHS were recalculated by adding the differences between values from @AH97b and @DLH06 for alanate or glycinate to the properties of the complexes reported by @SK95.",http://chnosz.net -CHNOSZ.4,"J. M. Dick",2017,"CHNOSZ package documentation",pseudo-H4SiO4,http://chnosz.net +CHNOSZ.4,"J. M. Dick",2017,"CHNOSZ package documentation","pseudo-H4SiO4; GHS and HKF parameters calculated as shown in the vignette, [*Regressing thermodynamic data*](eos-regress.html)",http://chnosz.net CHNOSZ.5,"J. M. Dick",2017,"CHNOSZ package documentation","AuCl4- renamed to AuCl4-3",http://chnosz.net CHNOSZ.6,"J. M. Dick",2017,"CHNOSZ package documentation","dipeptides not included in slop files after slop98.dat",http://chnosz.net CHNOSZ.7,"J. M. Dick",2017,"CHNOSZ package documentation","charge of NpO2(Oxal), La(Succ)+, NH4(Succ)-, and NpO2(Succ) as listed by @PSK99",http://chnosz.net Modified: pkg/CHNOSZ/demo/activity_ratios.R =================================================================== --- pkg/CHNOSZ/demo/activity_ratios.R 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/demo/activity_ratios.R 2017-10-20 15:05:27 UTC (rev 262) @@ -10,8 +10,6 @@ ## Steinmann et al., 1994 (http://ccm.geoscienceworld.org/content/42/2/197) ## Garrels and Christ, p. 361 (http://www.worldcat.org/oclc/517586) ## https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-75.html -# make the pseudospecies H4SiO4 available for use as a basis species -add.obigt("CHNOSZ_aq", "pseudo-H4SiO4") basis(c("Al+3", "pseudo-H4SiO4", "K+", "H2O", "H+", "O2")) species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "K-feldspar")) a <- affinity(H4SiO4 = c(-6, -2, res), `K+` = c(-3, 6, res)) Modified: pkg/CHNOSZ/demo/adenine.R =================================================================== --- pkg/CHNOSZ/demo/adenine.R 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/demo/adenine.R 2017-10-20 15:05:27 UTC (rev 262) @@ -56,10 +56,10 @@ ) # error bars (arrows trick from https://stackoverflow.com/questions/13032777/scatter-plot-with-error-bars) arrows(AdH$T, AdH$Cp - AdH$Cp_SD, AdH$T, AdH$Cp + AdH$Cp_SD, length = 0.05, angle = 90, code = 3) -# get LH06 predictions using HKF model -# this version of adenine parameters has been superseded by LCT17 -# but are still available as optional data -add.obigt("CHNOSZ", "adenine-old") +# get LH06 predictions using HKF model; +# this version of adenine parameters has been superseded by LCT17, +# so we add them by hand +mod.obigt("adenine-old", formula="C5H5N5", a1=21.5046, a2=8.501, a3=-2.6632, a4=-5.3561, c1=87.88, c2=-15.87, omega=0.065) LH06 <- subcrt("adenine-old", T = TK)$out$adenine lines(TK, LH06$Cp, lty = 3) # density model (parameters from LCT17 Table 11) Modified: pkg/CHNOSZ/demo/go-IU.R =================================================================== --- pkg/CHNOSZ/demo/go-IU.R 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/demo/go-IU.R 2017-10-20 15:05:27 UTC (rev 262) @@ -40,12 +40,18 @@ lines(T, -r4$out$logK, col="red") ## add labels, legend, and title text(182.5, -3.17, "SUPCRT92\n(CHNOSZ default)", srt=48, cex=0.7, font=2) -text(147, -3.1, "SUPCRTBL", srt=45.5, cex=0.7, font=2, col="red") +text(154, -3.04, "circa SUPCRTBL", srt=45, cex=0.7, font=2, col="red") legend("topleft", lty=c(1, 2, 2, 1), col=c("black", "black", "red", "red"), bty="n", cex=0.9, - legend=c("Kln,Bhm:HDNB78; SiO2:SHS89", "Kln:Ber88", "+ Bhm:HRA91", "+ SiO2:AS04")) + legend=c("Kln,Bhm:HDNB78; SiO2(aq):SHS89", "Kln:Ber88 (SUPCRTBL uses HP11)", "+ Bhm:HRA91", "+ SiO2(aq):AS04")) legend("bottomright", pch=1, legend="Hemley et al., 1980", bty="n", cex=0.9) mtitle(c("Kaolinite - Boehmite", "After Zhu and Lu, 2009 Fig. A1"), cex=0.95) -# doi:10.1016/j.gca.2009.03.015 +# Zhu and Lu, 2009: doi:10.1016/j.gca.2009.03.015 +# Helgeson et al., 1978 (HDNB78): http://www.worldcat.org/oclc/13594862 +# Shock et al., 1989 (SHS89): doi:10.1016/0016-7037(89)90341-4 +# Berman, 1988 (Ber88): doi:10.1093/petrology/29.2.445 +# Holland and Powell, 2011 (HP11): 10.1111/j.1525-1314.2010.00923.x +# Hemingway et al., 1991 (HRA91): http://pubs.er.usgs.gov/publication/70016664 +# Apps and Spycher, 2004 (AS04): Bechtel SAIC Company, LLC ANL-NBS-HS-000043 REV 00 (DOC.20041118.0004) ########### ### plot 2: dawsonite solubility @@ -103,31 +109,31 @@ res <- 300 # we "blend" the transitions with pH, unlike LZ11's diagram where # it appears the S-basis species are switched in an on/off fashion -m <- mosaic(bases, pH=c(2, 14, res), Eh=c(-0.6, 0.8, res), blend=TRUE) +m <- mosaic(bases, pH=c(0, 14, res), Eh=c(-0.8, 0.8, res), blend=TRUE) # adjust colors and names fill <- rev(heat.colors(nrow(species()))) fill[11:15] <- "darkgrey" m$A.species$species$name <- gsub(",alpha", "", m$A.species$species$name) diagram(m$A.species, fill=fill) dprop <- describe.property(c("T", "P"), c(25, 1)) -legend("topright", legend=dprop, bty="n") +legend("bottomleft", legend=dprop, bty="n") t1 <- quote("As-O-H-S, "~list(sum(S)==10^-3*M, sum(As)==10^-5*M)) t2 <- "After Lu and Zhu, 2011 Fig. 2b" +# doi:10.1007/s12665-010-0652-x mtitle(as.expression(c(t1, t2)), cex=0.95) -# doi:10.1007/s12665-010-0652-x ########### ### plot 4: aqueous Al species ########### add.obigt("SUPCRTBL") basis(c("Al+3", "F-", "H+", "O2", "H2O")) +AlOH <- c("Al(OH)4-", "Al(OH)3", "Al(OH)2+", "AlOH+2") Al <- "Al+3" -AlOH <- c("Al(OH)4-", "AlOH+2", "Al(OH)2+", "Al(OH)3") AlF <- c("AlF+2", "AlF2+", "AlF3", "AlF4-") AlOHF <- c("Al(OH)2F2-", "Al(OH)2F", "AlOHF2") -species(c(Al, AlOH, AlF, AlOHF), "aq") +species(c(AlOH, Al, AlF, AlOHF), "aq") a <- affinity(pH=c(0, 10), `F-`=c(-1, -9), T=200) -diagram(a, fill=cm.colors(nrow(species()))) +diagram(a, fill=rev(cm.colors(nrow(species())))) dprop <- describe.property(c("T", "P"), c(200, "Psat")) legend("topright", legend=dprop, bty="n") mtitle(c("Aqueous aluminum species", Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/inst/NEWS 2017-10-20 15:05:27 UTC (rev 262) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-60 (2017-10-18) +CHANGES IN CHNOSZ 1.1.0-61 (2017-10-20) --------------------------------------- MAJOR CHANGES: @@ -105,10 +105,6 @@ and volume data (Lowe et al., 2017). Add demo/adenine.R comparing the updates with the previous data (LaRowe and Helgeson, 2006). -- Data file CHNOSZ_aq.csv is no longer added to the database by default. - It is now intended to hold optional data. Currently it contains - pseudo-H4SiO4 and adenine-old. - - 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). @@ -165,6 +161,9 @@ empty files (291 KB), and 2) changing the theme from "cosmo" to "default" (151 KB). +- Remove extdata/OBIGT/CHNOSZ_aq.csv and move the entry for + pseudo-H4SiO4 to inorganic_aq.csv. + CHANGES IN CHNOSZ 1.1.0 (2017-05-04) ------------------------------------ Deleted: pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv 2017-10-20 15:05:27 UTC (rev 262) @@ -1,3 +0,0 @@ -name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -pseudo-H4SiO4,NA,H4SiO4,aq,CHNOSZ.4,NA,18.Feb.17,-312565,-346409,51.4246,-40.0964,52.1998,89.2031,-176.5071,-452.1431,101.36051,67.0854,-52.0776,0.1215745,0 -adenine-old,NA,C5H5N5,aq,LH06a.2,NA,03.Mar.17,74770,31235,53.41,56.24,89.59,21.5046,8.501,-2.6632,-5.3561,87.88,-15.87,0.065,0 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_aq.csv.xz 2017-10-20 15:05:27 UTC (rev 262) @@ -1,4 +1,4 @@ -?7zXZ???F!t/??????"]7I??b???9??????TB;q?"?q???cL;?"??????)]??o9?F??????Y?@)?#]_%????????~l???H?`?????j&!?? ?BM?????O??k~??:???:? ?25:?? ?P????k??? ?w?X?_???????V0d?Y?#?V?|` E ?g???M9?????V?l(Rls?H??'?&hz??a?~?'V?B??|???qp??R?1?z?&OS??_m??h?J??K]???h?,?%?K???????C)????ml???gF>$0????!a?(?IE?Y??R?;????#W?>O??&?j_-,'[2??*???????m????)]??o9?F??????Y?@)?#]_%????????~l???H?`?????j&!?? ?BM?????O??k~??:???:? ?25:?? ?P????k??? ?w?X?_???????V0d?Y?#?V?|` E ?g???M9?????V?l(Rls?H??'?&hz??a?~?'V?B??|???qp??R?1?z?&OS??_m??h?J??K]???h?,?%?K???????C)????ml???gF>$0????!a?(?IE?Y??R?;????#W?>O??&?j??.e?bQ~:????????B;??gU??[c2B0? ???????#??:????p?? ?? ?0jTb????k(? ?#V'?|K?????????7??g?YZ \ No newline at end of file Deleted: pkg/CHNOSZ/inst/extdata/thermo/Ste01.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/Ste01.csv 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/inst/extdata/thermo/Ste01.csv 2017-10-20 15:05:27 UTC (rev 262) @@ -1,2 +0,0 @@ -name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -H4SiO4_Ste01,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/man/extdata.Rd 2017-10-20 15:05:27 UTC (rev 262) @@ -99,7 +99,7 @@ Files in \code{thermo} contain additional thermodynamic data and group additivity definitions: \itemize{ - \item \code{Ste01.csv} and \code{BZA10.csv} contain supplementary thermodynamic data taken from Stefansson (2001) and Bazarkina et al. (2010). They can be added to the database in the current session using \code{\link{add.obigt}}. See \code{\link{add.obigt}} and the vignette \code{eos-regress.Rmd} for examples that use these files. + \item \code{BZA10.csv} contains supplementary thermodynamic data taken from Bazarkina et al. (2010). The data can be added to the database in the current session using \code{\link{add.obigt}}. See \code{\link{add.obigt}} for an example that uses this file. \item \code{obigt_check.csv} contains the results of running \code{\link{check.obigt}} to check the internal consistency of entries in the primary and supplementary databases. \item \code{RH98_Table15.csv} Group stoichiometries for high molecular weight crystalline and liquid organic compounds taken from Table 15 of Richard and Helgeson, 1998. The first three columns have the \code{compound} name, \code{formula} and physical \code{state} (\samp{cr} or \samp{liq}). The remaining columns have the numbers of each group in the compound; the names of the groups (columns) correspond to species in \code{\link{thermo}$obigt}. The compound named \samp{5a(H),14a(H)-cholestane} in the paper has been changed to \samp{5a(H),14b(H)-cholestane} here to match the group stoichiometry given in the table. See \code{\link{RH2obigt}} for a function that uses this file. \item \code{DLEN67.csv} Standard Gibbs energies of formation, in kcal/mol, from Dayhoff et al., 1967, for nitrogen (N2) plus 17 compounds shown in Fig. 2 of Dayhoff et al., 1964, at 300, 500, 700 and 1000 K. See \code{demo("wjd")} and the vignette \code{wjd.Rmd} for examples that use this file. @@ -157,8 +157,6 @@ Shock, E. L. and Schulte, M. D. (1998) Organic synthesis during fluid mixing in hydrothermal systems. \emph{J. Geophys. Res.} \bold{103}, 28513--28527. \url{https://doi.org/10.1029/98JE02142} -Stef??nsson, A. (2001) Dissolution of primary minerals of basalt in natural waters. I. Calculation of mineral solubilities from 0??C to 350??C \emph{Chem. Geol.} \bold{172}, 225--250. \url{https://doi.org/10.1016/S0009-2541(00)00263-1} - Tai, S. L., Boer, V. M., Daran-Lapujade, P., Walsh, M. C., de Winde, J. H., Daran, J.-M. and Pronk, J. T. (2005) Two-dimensional transcriptome analysis in chemostat cultures: Combinatorial effects of oxygen availability and macronutrient limitation in \emph{Saccharomyces cerevisiae}. \emph{J. Biol. Chem.} \bold{280}, 437--447. \url{https://doi.org/10.1074/jbc.M410573200} YeastGFP project. Yeast GFP Fusion Localization Database, http://yeastgfp.ucsf.edu; Current location: \url{http://yeastgfp.yeastgenome.org} Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-10-20 15:05:27 UTC (rev 262) @@ -38,6 +38,7 @@ 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. +The distance of closest approach (the \dQuote{ion size parameter}) is set to 3.72 Angstrom, which is appropriate for NaCl-dominated solutions (Helgeson et al., 1981 Table 2). 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}. Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-20 15:05:27 UTC (rev 262) @@ -66,7 +66,7 @@ Minerals with polymorphic transitions (denoted by having states \samp{cr} (lowest T phase), \samp{cr2}, \samp{cr3} etc.) can be defined generically by \samp{cr} in the \code{state} argument with a character value for \code{species}. \code{subcrt} in this case simultaneously calculates the requested properties of all the phases of each such mineral (phase species) and, using the values of the transition temperatures calculated from those at P = 1 bar given in the thermodynamic database together with functions of the entropies and volumes of transitions (see \code{\link{dPdTtr}}), determines the stable phase of the mineral at any grid point and substitutes the properties of this phase at that point for further calculations. If individual phase species of minerals are specified (by \samp{cr}, \samp{cr2} etc. in \code{state}), and \code{exceed.Ttr} is \code{FALSE} (the default), the Gibbs energies of these minerals are assigned values of NA at conditions beyond their transition temperature, where another of the phases is stable. -If you set \code{exceed.Ttr} to \code{TRUE} while investigating the properties of phases of minerals identified generically (by \samp{cr}) the function will identify the stable phase on the basis not of the transition temperatures but of the calculated Gibbs energies of the phase species. +If you set \code{exceed.Ttr} to \code{TRUE} to calculate the properties of mineral polymorphs (i.e., using \samp{cr}) the function will identify the stable polymorph using the calculated Gibbs energies of the phase species instead of the tabulated transition temperatures. This is not generally advised, since the computed standard molal properties of a phase species lose their physical meaning beyond the transition temperatures of the phase. If \code{logact} is provided, the chemical affinities of reactions are calculated. Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-20 15:05:27 UTC (rev 262) @@ -1827,9 +1827,27 @@ browseURL(ref$URL) ## opens a link to worldcat.org ``` +## Optional data + +Thermodynamic properties of minerals in the default database are mostly taken from @HDNB78. +These are identified by the state `cr`, and `cr2`, `cr3`, etc. for higher-temperature polymorphs. +Optionally, thermodynamic properties of minerals can be calculated using the equations and dataset of @Ber88; these minerals are identified in the database by having the state `cr_Berman`. + +Two other optional datasets can be activated by using `add.obigt()`: + +`add.obigt("SUPCRTBL")` -- This loads updated thermodynamic parameters for aqueous SiO2, aluminum and arsenic species, and minerals, as compiled in the [SUPCRTBL package](http://www.indiana.edu/~hydrogeo/supcrtbl.html) [@ZZL_16]. +SUPCRTBL also includes modifications to SUPCRT92 for calculating thermodynamic properties of minerals using the @HP11 dataset, but that is not available in CHNOSZ. +Instead, the Berman mineral data can be used with similar results; see [`demo(go-IU)`](../demo/goIU.R). + +`add.obigt("DEW")` -- These are aqueous species, with modified parameters, that are intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model [@SHA14]. +You should also run `water("DEW")` to activate the equations in the model; then, they will be used by `subcrt()` and `affinity()`. +Examples are in [`demo(DEW)`](../demo/DEW.R). + +Detailed lists of sources for these Optional Data are in the vignette [*Thermodynamic data in CHNOSZ*](obigt.html) (look under **Solids** / **Berman**, **Optional Data** / **SUPCRTBL** and **Optional Data** / **DEW**). + ## Adding data -Use `add.obigt()` to add data from a user-specified file to the database in the current session. +You can also use `add.obigt()` to add data from a user-specified file to the database in the current session. The file must be a CSV (comma separated value) file with column headers that match those in the main database. To show the required format, take a look at `BZA10.csv`, a supplemental data file provided in CHNOSZ. Missing values are indicated by `NA`: Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-10-20 15:05:27 UTC (rev 262) @@ -1,5 +1,5 @@ --- -title: "Regressing Thermodynamic Data" +title: "Regressing thermodynamic data" subtitle: "EOSregress in [CHNOSZ](http://www.chnosz.net)" author: "Jeffrey M. Dick" date: "`r Sys.Date()`" @@ -386,15 +386,13 @@ We just made a new `r h4sio4` pseudospecies. In February 2017, the database in CHNOSZ was updated with a `pseudo-H4SiO4` that was made using this procedure. -This `pseudo-H4SiO4` can be activated using the `add.obigt()` function. -Data given for `r h4sio4` by @Ste01 (`H4SiO4_Ste01`) are contained in a supplemental file, which as well can be read using `add.obigt()`: +For comparison, the parameters of `r h4sio4` given by @Ste01, which are contained in an optional data file, can be read using `add.obigt()`: ```{r width180, include=FALSE} options(width = 180) ``` ```{r info_H4SiO4, message=FALSE} -add.obigt("CHNOSZ_aq", "pseudo-H4SiO4") -add.obigt(system.file("extdata/thermo/Ste01.csv", package = "CHNOSZ")) -info(info(c("new-H4SiO4", "pseudo-H4SiO4", "H4SiO4_Ste01"))) +add.obigt("SUPCRTBL", "H4SiO4") +info(info(c("new-H4SiO4", "pseudo-H4SiO4", "H4SiO4"))) ``` ```{r width80, include=FALSE} ``` @@ -403,21 +401,22 @@ s1 <- subcrt(c("pseudo-H4SiO4", "SiO2", "H2O"), c(-1, 1, 2)) plot(s1$out$T, s1$out$G, type = "l", ylim = c(-100, 600), xlab = axis.label("T"), ylab = axis.label("DG0")) -s2 <- subcrt(c("H4SiO4_Ste01", "SiO2", "H2O"), c(-1, 1, 2)) +s2 <- subcrt(c("H4SiO4", "SiO2", "H2O"), c(-1, 1, 2)) lines(s2$out$T, s2$out$G, lty = 2) abline(h = 0, lty = 3) legend("topright", legend = c("pseudo-H4SiO4 (CHNOSZ)", - "H4SiO4_Ste01", "\t(Stef??nsson, 2001)"), lty = c(1, 2, NA), bty = "n") + "H4SiO4 (Stef??nsson, 2001)"), lty = c(1, 2, NA), bty = "n") text(225, 250, describe.reaction(s1$reaction)) ``` -Let's compare CHNOSZ's `pseudo-H4SiO4` (with the same properties as the `new-H4SiO4` we just made) and `H4SiO4_Ste01` from Stef??nsson (2001) with the calculated properties of `r sio2` + 2 `r h2o` as a function of temperature: +Let's compare CHNOSZ's `pseudo-H4SiO4` (with the same properties as the `new-H4SiO4` we just made) and `H4SiO4` from Stef??nsson (2001) with the calculated properties of `r sio2` + 2 `r h2o` as a function of temperature: ```{r subcrt_H4SiO4, eval=FALSE} ``` -The large differences for `H4SiO4_Ste01` at low temperature agree with the comparison to Shock et al. (1989) shown in Figure 3 of Stef??nsson (2001). -Therefore, `H4SiO4_Ste01` should not be used _in CHNOSZ_ for making low-temperature mineral activity diagrams. -Instead, the pseudospecies with properties calculated here, `pseudo-H4SiO4`, is preferable for use _in CHNOSZ_---see `?transfer` and `demo(activity_ratios)`. +The large differences for `H4SiO4` at low temperature agree with the comparison to Shock et al. (1989) shown in Figure 3 of Stef??nsson (2001). +Therefore, Stef??nsson's `r h4sio4` should not be used with the _default_ database in CHNOSZ for making mineral activity diagrams. +Instead, the pseudospecies with properties calculated here, `pseudo-H4SiO4`, is preferable for use with the _default_ database in CHNOSZ---see `?transfer` and `demo(activity_ratios)`. +On the other hand, Stef??nsson's `r h4sio4` is compatible with `r sio2` in the _optional_ SUPCRTBL data file [@ZZL_16]. # Other possibilities Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-20 15:05:27 UTC (rev 262) @@ -242,14 +242,6 @@ ```{r optreflist, results="asis", echo=FALSE} ``` -### `r setfile("CHNOSZ_aq.csv")` -```{r CHNOSZ_aq, results="asis", echo=FALSE} -cat("The primary aqueous silica species in CHNSOZ is SiO2 ([Shock et al., 1989](https://doi.org/10.1016/0016-7037(89)90341-4)). The pseudospecies H4SiO4 is used to make activity diagrams with *a*H4SiO4 as a variable. The GHS and HKF parameters for this pseudospecies were calculated using CHNOSZ; see the vignette [*Regressing thermodynamic data*](eos-regress.html) for more information.
") -``` - -```{r optreflist, results="asis", echo=FALSE} -``` - ## All at once ### Aqueous species @@ -334,13 +326,6 @@ ```{r reflist2, results="asis", echo=FALSE} ``` -#### `r setfile("CHNOSZ_aq.csv")` -```{r CHNOSZ_aq, results="asis", echo=FALSE} -``` - -```{r reflist2, results="asis", echo=FALSE} -``` - # Total count of species `r length(used)` of `r nrow(thermo$obigt)` entries in `thermo$obigt` and `r length(optused)` optional data entries are documented here. Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-10-18 16:07:00 UTC (rev 261) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-10-20 15:05:27 UTC (rev 262) @@ -170,6 +170,16 @@ url = {http://www.worldcat.org/oclc/583263}, } + at Article{HDNB78, + author = {Helgeson, Harold C. and Delany, Joan M. and Nesbitt, H. Wayne and Bird, Dennis K.}, + journal = {American Journal of Science}, + title = {{S}ummary and critique of the thermodynamic properties of rock-forming minerals}, + year = {1978}, + volume = {278A}, + pages = {1--229}, + url = {http://www.worldcat.org/oclc/13594862}, +} + @Article{HKF81, author = {Helgeson, Harold C. and Kirkham, David H. and Flowers, George C.}, journal = {American Journal of Science}, @@ -204,14 +214,14 @@ } @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, @@ -431,30 +441,41 @@ } @Article{Ste01, - author = {Stef??nsson, Andri}, - journal = {Chemical Geology}, - title = {{D}issolution of primary minerals of basalt in natural waters. {I}. {C}alculation of mineral solubilities from 0??C to 350??{C}}, - year = {2001}, - volume = {172}, - pages = {225--250}, - doi = {10.1016/S0009-2541(00)00263-1}, + author = {Stef??nsson, Andri}, + journal = {Chemical Geology}, + title = {{D}issolution of primary minerals of basalt in natural waters. {I}. {C}alculation of mineral solubilities from 0??{C} to 350??{C}}, + year = {2001}, + volume = {172}, + pages = {225--250}, + doi = {10.1016/S0009-2541(00)00263-1}, } + at Article{SHA14, + author = {Sverjensky, Dimitri A. and Harrison, Brandon and Azzolini, David}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{W}ater in the deep {E}arth: {T}he dielectric constant and the solubilities of quartz and corundum to 60 kb and 1,200 $^\circ${C}}, + year = {2014}, + volume = {129}, + pages = {125--145}, + doi = {10.1016/j.gca.2013.12.019}, + issn = {0016-7037}, +} + @Article{TS01, - author = {Tagirov, Boris and Schott, Jacques}, - journal = {Geochimica et Cosmochimica Acta}, - title = {Aluminum speciation in crustal fluids revisited}, - year = {2001}, - volume = {65}, - number = {21}, - pages = {3965--3992}, - doi = {10.1016/S0016-7037(01)00705-0}, + author = {Tagirov, Boris and Schott, Jacques}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{A}luminum speciation in crustal fluids revisited}, + year = {2001}, + volume = {65}, + number = {21}, + pages = {3965--3992}, + doi = {10.1016/S0016-7037(01)00705-0}, } @Article{TH88, author = {Tanger, IV, John C. and Helgeson, Harold C.}, journal = {American Journal of Science}, - title = {Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: {R}evised equations of state for the standard partial molal properties of ions and electrolytes}, + title = {{C}alculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: {R}evised equations of state for the standard partial molal properties of ions and electrolytes}, year = {1988}, volume = {288}, number = {1}, @@ -469,7 +490,7 @@ year = {2002}, volume = {31}, number = {2}, - pages = {387 -- 535}, [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 262 From noreply at r-forge.r-project.org Sat Oct 21 05:56:26 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 21 Oct 2017 05:56:26 +0200 (CEST) Subject: [CHNOSZ-commits] r263 - in pkg/CHNOSZ: . vignettes Message-ID: <20171021035626.3E1A5189201@r-forge.r-project.org> Author: jedick Date: 2017-10-21 05:56:25 +0200 (Sat, 21 Oct 2017) New Revision: 263 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/obigt.Rmd Log: vignettes: link to demo index page instead individual demos' R code Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-20 15:05:27 UTC (rev 262) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-21 03:56:25 UTC (rev 263) @@ -1,6 +1,6 @@ -Date: 2017-10-20 +Date: 2017-10-21 Package: CHNOSZ -Version: 1.1.0-61 +Version: 1.1.0-62 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-20 15:05:27 UTC (rev 262) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-21 03:56:25 UTC (rev 263) @@ -275,7 +275,7 @@ A custom temperature-pressure grid can be specified. Here, we calculate the properties of `r h2o` on a *T*, *P* grid in the supercritical region, with conditions grouped by pressure: ```{marginfigure} -See also [`demo(density)`](../demo/density.R). +See also [`demo(density)`](../demo). ``` ```{r subcrt_water_grid} subcrt("water", T = c(400, 500, 600), P = c(200, 400, 600), grid = "P")$out$water @@ -322,7 +322,7 @@ Here we calculate properties for the dissolution of CO2: ```{marginfigure} Because of aqueous speciation, this doesn't give the _solubility_ of CO2. -For an example of a solubility calculation, see [`demo(solubility)`](../demo/solubility.R), which is based on a figure in Manning et al. (2013). +For an example of a solubility calculation, see [`demo(solubility)`](../demo), which is based on a figure in Manning et al. (2013). ``` ```{r subcrt_CO2} subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T = seq(0, 250, 50)) @@ -582,7 +582,7 @@ Mineral stability diagrams often depict activity ratios, e.g. log (*a*Ca+2/*a*H+2), on one or both axes. The variables used for potential calculations in CHNOSZ include only a single chemical activity, e.g. log *a*Ca+2. However, you can set pH = 0 to generate diagrams that are geometrically equivalent to those calculated using activity ratios, and use `ratlab()` to make the axes labels for the ratios. -See [`demo(activity_ratios)`](../demo/activity_ratios.R) for some examples. +See [`demo(activity_ratios)`](../demo) for some examples. ## Mosaic diagrams @@ -735,14 +735,14 @@ * more versatile (multiple activities can be buffered, e.g. both S2 and O2 by pyrite-pyrrhotite-magnetite); * the buffers are active in calculations of affinity of other species; * use `mod.buffer()` to change or add buffers in `thermo$buffer`; -* [`demo(buffer)`](../demo/buffer.R) uses it for mineral buffers (solid lines). +* [`demo(buffer)`](../demo) uses it for mineral buffers (solid lines). 2. Use the `what` argument of `diagram()` to solve for the activity of the indicated basis species: * more convenient (the buffers come from the currently defined species of interest), but only a single basis species can be buffered, and it's not used in the calculation of affinity; -* [`demo(buffer)`](../demo/buffer.R) uses it for aqueous organic species as buffers (dotted and dashed lines). +* [`demo(buffer)`](../demo) uses it for aqueous organic species as buffers (dotted and dashed lines). As an example of method 1, let's look at the pyrite-pyrrhotite-magnetite (PPM) buffer at 300 ?C. ```{marginfigure} -For other examples, see `?buffer` and [`demo(protbuff)`](../demo/protbuff.R) (hypothetical buffer made of proteins). +For other examples, see `?buffer` and [`demo(protbuff)`](../demo) (hypothetical buffer made of proteins). ``` Without the buffer, the basis species have default activities of zero. Under these conditions, the minerals are not in equilibrium, as shown by their different affinities of formation: @@ -780,7 +780,7 @@ ```{r PPM_affinity, eval=FALSE} ``` -Another example, based on Figure 6 of @SS95, is given in [`demo(buffer)`](../demo/buffer.R). +Another example, based on Figure 6 of @SS95, is given in [`demo(buffer)`](../demo). Here, values of log*f*H2 buffered by minerals or set by equilibrium with given activities of aqueous species are calculated using the two methods: ```{r demo_buffer, eval=FALSE} demo(buffer) @@ -853,7 +853,7 @@ The possible reactions between species are all balanced on 1 C. Therefore, although pH alters the total activity of C, in a system with ideal mixing the total activity of C doesn't affect the relative activities of these species. ```{marginfigure} -See [`demo(solubility)`](../demo/solubility.R) for calculations of the total activity of C in this ideal system; uncomment a line in the demo to run calculations for CO2 instead of calcite. +See [`demo(solubility)`](../demo) for calculations of the total activity of C in this ideal system; uncomment a line in the demo to run calculations for CO2 instead of calcite. ``` ## Groups of species @@ -1054,7 +1054,7 @@ Charged and uncharged sets of basis species are used to to activate and suppress the ionization calculations. The calculation of affinity for the ionized proteins returns multiple values (as a function of pH), but there is only one value of affinity returned for the nonionized proteins, so we need to use R's `as.numeric()` to avoid subtracting nonconformable arrays: -```{r protein_ionization, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Affinity of ionization of proteins. See [demo(ionize)](../demo/ionize.R) for ionization properties calculated as a function of temperature and pH.', cache=TRUE, pngquant=pngquant, timeit=timeit} +```{r protein_ionization, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Affinity of ionization of proteins. See [demo(ionize)](../demo) for ionization properties calculated as a function of temperature and pH.', cache=TRUE, pngquant=pngquant, timeit=timeit} ip <- pinfo(c("CYC_BOVIN", "LYSC_CHICK", "MYG_PHYCA", "RNAS1_BOVIN")) basis("CHNOS+") a_ion <- affinity(pH = c(0, 14), iprotein = ip) @@ -1319,7 +1319,7 @@ Next we use `diagram()` to plot the affinities. We set `balance = 1` to plot the values as they are---without that, `diagram()` divides the values by protein length, which we have already done! ```{marginfigure} -See [`demo(Shh)`](../demo/Shh.R) for a plot with more interpretive labels and comments. +See [`demo(Shh)`](../demo) for a plot with more interpretive labels and comments. ``` For this plot, we highlight and label the proteins with the highest relative affinity at some combination of `r logfO2` and log*a*`r h2o` along the transect. Those proteins are Olig2, Irx3, Nkx6.2, Dbx1, and Shh (numbers 2, 5, 7, 8, 1 in the set we have identified). @@ -1837,11 +1837,11 @@ `add.obigt("SUPCRTBL")` -- This loads updated thermodynamic parameters for aqueous SiO2, aluminum and arsenic species, and minerals, as compiled in the [SUPCRTBL package](http://www.indiana.edu/~hydrogeo/supcrtbl.html) [@ZZL_16]. SUPCRTBL also includes modifications to SUPCRT92 for calculating thermodynamic properties of minerals using the @HP11 dataset, but that is not available in CHNOSZ. -Instead, the Berman mineral data can be used with similar results; see [`demo(go-IU)`](../demo/goIU.R). +Instead, the Berman mineral data can be used with similar results; see [`demo(go-IU)`](../demo). `add.obigt("DEW")` -- These are aqueous species, with modified parameters, that are intended for use with the [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model [@SHA14]. You should also run `water("DEW")` to activate the equations in the model; then, they will be used by `subcrt()` and `affinity()`. -Examples are in [`demo(DEW)`](../demo/DEW.R). +Examples are in [`demo(DEW)`](../demo). Detailed lists of sources for these Optional Data are in the vignette [*Thermodynamic data in CHNOSZ*](obigt.html) (look under **Solids** / **Berman**, **Optional Data** / **SUPCRTBL** and **Optional Data** / **DEW**). @@ -1867,7 +1867,7 @@ Another use of `add.obigt()` is to add data from the file `CHNOSZ_aq.csv`, which holds provisional updates that aren't loaded by default (i.e., using `data(thermo)`). In this mode, only the name of the species is used as the argument. -Currently available species are `adenine-old` and `pseudo-H4SiO4` (see [`demo(adenine)`](../demo/adenine.R) and the vignette, [*Regressing thermodynamic data*](eos-regress.html)). +Currently available species are `adenine-old` and `pseudo-H4SiO4` (see [`demo(adenine)`](../demo) and the vignette, [*Regressing thermodynamic data*](eos-regress.html)). ## Modifying data Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-10-20 15:05:27 UTC (rev 262) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-10-21 03:56:25 UTC (rev 263) @@ -415,7 +415,7 @@ The large differences for `H4SiO4` at low temperature agree with the comparison to Shock et al. (1989) shown in Figure 3 of Stef?nsson (2001). Therefore, Stef?nsson's `r h4sio4` should not be used with the _default_ database in CHNOSZ for making mineral activity diagrams. -Instead, the pseudospecies with properties calculated here, `pseudo-H4SiO4`, is preferable for use with the _default_ database in CHNOSZ---see `?transfer` and `demo(activity_ratios)`. +Instead, the pseudospecies with properties calculated here, `pseudo-H4SiO4`, is preferable for use with the _default_ database in CHNOSZ---see `?transfer` and [`demo(activity_ratios)`](../demo). On the other hand, Stef?nsson's `r h4sio4` is compatible with `r sio2` in the _optional_ SUPCRTBL data file [@ZZL_16]. # Other possibilities Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-20 15:05:27 UTC (rev 262) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-21 03:56:25 UTC (rev 263) @@ -189,7 +189,8 @@ ```{r Berman_cr, results="asis", echo=FALSE} cat("This file gives the identifiying information for minerals whose properties are calculated using the formulation of [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445).\n") cat("To distinguish these minerals from the original set of mineral data in CHNOSZ (based on the compliation of [Helgeson et al., 1978](http://www.worldcat.org/oclc/13594862)), the physical states are listed as `cr_Berman`.\n") -cat("The actual data are stored separately (`extdata/Berman/*.csv`).
") +cat("The actual data are stored separately, as CSV files in `extdata/Berman/*.csv`.\n") +cat("To see the equations in use, run [`demo(lambda)`](../demo) to calculate properties of the lambda transition in quartz [@Ber88]; the Berman equations are also used in [`demo(DEW)`](../demo) and [`demo(go-IU)`](../demo).
") ``` ```{r reflist, results="asis", echo=FALSE} @@ -219,7 +220,8 @@ ### `r setfile("DEW_aq.csv")` ```{r DEW_aq, results="asis", echo=FALSE} -cat("The [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model extends the applicability of the revised HKF equations of state to 60 kbar. Accuracy of the thermodynamic calculations at these conditions is improved by revised correlations for the a1 HKF parameter, as described by [Sverjensky et al., 2014](https://doi.org/10.1016/j.gca.2013.12.019). The data here were taken from the May 2017 version of the DEW spreadsheet ([Dew Model, 2017](http://www.dewcommunity.org/resources.html)). The following species are present in the spreadsheet, but are not listed in `DEW_aq.csv` because the parameters are unchanged from the default database in CHNOSZ: B(OH)3, Br-, Ca+2, Cl-, Cs+, F-, H+, H2, He, I-, K+, Kr, Li+, Mg+2, Na+, Ne, O2, Rb+, Rn.
") +cat("The [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model extends the applicability of the revised HKF equations of state to 60 kbar. Accuracy of the thermodynamic calculations at these conditions is improved by revised correlations for the a1 HKF parameter, as described by [Sverjensky et al., 2014](https://doi.org/10.1016/j.gca.2013.12.019). The data here were taken from the May 2017 version of the DEW spreadsheet ([Dew Model, 2017](http://www.dewcommunity.org/resources.html)). The following species are present in the spreadsheet, but are not listed in `DEW_aq.csv` because the parameters are unchanged from the default database in CHNOSZ: B(OH)3, Br-, Ca+2, Cl-, Cs+, F-, H+, H2, He, I-, K+, Kr, Li+, Mg+2, Na+, Ne, O2, Rb+, Rn.\n\n") +cat("Run [`demo(DEW)`](../demo) for some examples.
") ``` ```{r optused, include=FALSE} @@ -236,7 +238,8 @@ cat("SUPCRTBL is a modification and data update for the SUPCRT92 package ([Zimmer et al., 2016](https://doi.org/10.1016/j.cageo.2016.02.013)). Data for SiO2(*aq*) were updated to reflect the higher observed solubility of quartz compared to the SUPCRT92 dataset, and other aqueous species and minerals relevant to environmental geochemistry were added. The data provided in CHNOSZ were taken from the original references cited below or, where indicated, from `spronsbl.dat` ([downloaded here](http://www.indiana.edu/~hydrogeo/SUPCRTBL_linux.zip); file dated 2016-03-01).\n\n") cat("NOTE 1: The SUPCRTBL modifications apply the [Holland and Powell (2011)](https://doi.org/10.1111/j.1525-1314.2010.00923.x) equations and dataset for minerals, which are not available in CHNOSZ. Instead, as an alternative to the default dataset of [Helgeson et al. (1978)](http://www.worldcat.org/oclc/13594862), CHNOSZ offers the dataset of [Berman (1988)](https://doi.org/10.1093/petrology/29.2.445) (see the **Solids** / **Berman** section of this vignette).\n") cat("NOTE 2: The minerals listed below are represented in the compilation of Zimmer et al. (2016) by constant volume and, where available, a 4-term heat capacity equation that, unlike the complete Holland and Powell formulation, **is** compatible with CHNOSZ.\n") -cat("NOTE 3: Although Zimmer et al. (2016) remark that properties of HSiO3- were recalculated, the values in `spronsbl.dat` are identical to those in [Sverjensky et al. (1997)](https://doi.org/10.1016/S0016-7037(97)00009-4). Those data are not included here (they are part of the default database of CHNOSZ).
") +cat("NOTE 3: Although Zimmer et al. (2016) remark that properties of HSiO3- were recalculated, the values in `spronsbl.dat` are identical to those in [Sverjensky et al. (1997)](https://doi.org/10.1016/S0016-7037(97)00009-4). Those data are not included here (they are part of the default database of CHNOSZ).\n\n") +cat("Run [`demo(go-IU)`](../demo) for some examples.
") ``` ```{r optreflist, results="asis", echo=FALSE} From noreply at r-forge.r-project.org Sat Oct 21 17:34:46 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 21 Oct 2017 17:34:46 +0200 (CEST) Subject: [CHNOSZ-commits] r264 - in pkg/CHNOSZ: . R tests/testthat vignettes Message-ID: <20171021153446.28FEA1892C2@r-forge.r-project.org> Author: jedick Date: 2017-10-21 17:34:45 +0200 (Sat, 21 Oct 2017) New Revision: 264 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/tests/testthat/test-basis.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/obigt.Rmd Log: mod.basis(): improve changing states of basis species Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-21 03:56:25 UTC (rev 263) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-21 15:34:45 UTC (rev 264) @@ -1,6 +1,6 @@ Date: 2017-10-21 Package: CHNOSZ -Version: 1.1.0-62 +Version: 1.1.0-63 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-10-21 03:56:25 UTC (rev 263) +++ pkg/CHNOSZ/R/basis.R 2017-10-21 15:34:45 UTC (rev 264) @@ -161,10 +161,19 @@ } thermo$basis$logact[ib] <- state[i] } else { - # look for a species with this name in the requested state - ispecies <- suppressMessages(info(thermo$obigt$name[thermo$basis$ispecies[ib]], state[i], check.it=FALSE)) - if(is.na(ispecies) | is.list(ispecies)) - stop(paste("state or buffer '", state[i], "' not found for ", thermo$obigt$name[thermo$basis$ispecies[ib]], "\n", sep="")) + # first, look for a species with the same _name_ in the requested state + myname <- thermo$obigt$name[thermo$basis$ispecies[ib]] + ispecies <- suppressMessages(info(myname, state[i], check.it=FALSE)) + if(is.na(ispecies) | is.list(ispecies)) { + # if that failed, look for a species with the same _formula_ in the requested state + myformula <- thermo$obigt$formula[thermo$basis$ispecies[ib]] + ispecies <- suppressMessages(info(myformula, state[i], check.it=FALSE)) + if(is.na(ispecies) | is.list(ispecies)) { + # if that failed, we're out of luck + if(myname==myformula) nametxt <- myname else nametxt <- paste(myname, "or", myformula) + stop(paste0("state or buffer '", state[i], "' not found for ", nametxt, "\n")) + } + } thermo$basis$ispecies[ib] <- ispecies thermo$basis$state[ib] <- state[i] } Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2017-10-21 03:56:25 UTC (rev 263) +++ pkg/CHNOSZ/R/subcrt.R 2017-10-21 15:34:45 UTC (rev 264) @@ -8,6 +8,7 @@ #source("info.R") #source("util.units.R") #source("util.data.R") +#source("species.R") subcrt <- function(species, coeff = 1, state = NULL, property = c("logK", "G", "H", "S", "V", "Cp"), T = seq(273.15, 623.15, 25), P = "Psat", grid = NULL, convert = TRUE, exceed.Ttr = FALSE, @@ -533,13 +534,15 @@ } # 20120114 only prepend T, P, rho columns if we have more than one T # 20171020 or if the 'property' argument is missing (it's nice to see everything using e.g. subcrt("H2O", T=150)) - if(length(T) > 1 | missing(property)) { + # 20171021 or if the 'property' argument is not missing, but is identical to the default (happens when auto-balancing reactions) + if(length(T) > 1 | missing(property) | identical(property, c("logK", "G", "H", "S", "V", "Cp"))) { # 20090329 added checks for converting T, P units if(convert) T.out <- outvert(T,"K") else T.out <- T if(convert) P.out <- outvert(P,"bar") else P.out <- P # try to stuff in a column of rho if we have aqueous species # watch out! supcrt-ish densities are in g/cc not kg/m3 - if('rho' %in% calcprop | (missing(property) & any(c(isaq,isH2O))) & (names(out)[i])!='polymorph') + if('rho' %in% calcprop | ( (missing(property) | identical(property, c("logK", "G", "H", "S", "V", "Cp"))) & + any(c(isaq,isH2O))) & (names(out)[i])!='polymorph') out[[i]] <- cbind(data.frame(T=T.out,P=P.out,rho=H2O.PT$rho/1000),out[[i]]) else out[[i]] <- cbind(data.frame(T=T.out,P=P.out,out[[i]])) Modified: pkg/CHNOSZ/tests/testthat/test-basis.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-basis.R 2017-10-21 03:56:25 UTC (rev 263) +++ pkg/CHNOSZ/tests/testthat/test-basis.R 2017-10-21 15:34:45 UTC (rev 264) @@ -31,10 +31,14 @@ expect_equal(basis(), b) }) -test_that("changing state maintains species name", { +test_that("modifying states of basis species is possible", { b1 <- basis(c("Al2O3", "quartz", "oxygen")) b2 <- basis("SiO2", "cr2") # we went from quartz cr to cr2, which is the next row in the database expect_equal(sum(b2$ispecies - b1$ispecies), 1) expect_error(basis("SiO2", "cr3"), "state or buffer 'cr3' not found for quartz") + # can we go from CO2(aq) to CO2(gas) back to CO2(aq)? + basis("CHNOS+") # first basis species is CO2(aq) + expect_equal(basis("CO2", "gas")$state[1], "gas") + expect_equal(basis("CO2", "aq")$state[1], "aq") }) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-21 03:56:25 UTC (rev 263) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-21 15:34:45 UTC (rev 264) @@ -1946,7 +1946,7 @@ As you get started writing your own code and functions that use CHNOSZ, it is not uncommon to encounter problems. For example, mixing data types can cause problems (the important difference between factor and character was mentioned [above](#adding-data)). -There are many tricks to learn; becoming familiar with functions like R's `lapply()`, `rbind()`, and `do.call()` will make your programming life easier. +There are many tricks to learn; becoming familiar with functions like R's `lapply()`, `rbind()`, and `do.call()` will make your programming life more productive and enjoyable. Some functions in CHNOSZ perform "sanity checks" on the arguments and will report errors if an inconsistency is detected. For example, unequal lengths of variables in the transect mode of `affinity()` (when the variables have more than 3 values) cause an error: Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-21 03:56:25 UTC (rev 263) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-21 15:34:45 UTC (rev 264) @@ -215,13 +215,13 @@ ## Optional Data {.tabset .tabset-pills} ```{r Optional_Data, results="asis", echo=FALSE} -cat("These files contain optional data updates that replace and/or may be inconsistent with other entries in the default database. Use e.g. `add.obigt('SUPCRTBL')` to load the data.\n\n") +cat("These files contain optional data updates that replace and/or may be inconsistent with other entries in the default database. Use e.g. `add.obigt('SUPCRTBL')` to load the data.\n\n") ``` ### `r setfile("DEW_aq.csv")` ```{r DEW_aq, results="asis", echo=FALSE} cat("The [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model extends the applicability of the revised HKF equations of state to 60 kbar. Accuracy of the thermodynamic calculations at these conditions is improved by revised correlations for the a1 HKF parameter, as described by [Sverjensky et al., 2014](https://doi.org/10.1016/j.gca.2013.12.019). The data here were taken from the May 2017 version of the DEW spreadsheet ([Dew Model, 2017](http://www.dewcommunity.org/resources.html)). The following species are present in the spreadsheet, but are not listed in `DEW_aq.csv` because the parameters are unchanged from the default database in CHNOSZ: B(OH)3, Br-, Ca+2, Cl-, Cs+, F-, H+, H2, He, I-, K+, Kr, Li+, Mg+2, Na+, Ne, O2, Rb+, Rn.\n\n") -cat("Run [`demo(DEW)`](../demo) for some examples.
") +cat("Besides using `add.obigt('DEW')` to load these data, you should also run `water('DEW')` to activate the DEW equations in CHNOSZ. See [`demo(DEW)`](../demo) for some examples.
") ``` ```{r optused, include=FALSE} From noreply at r-forge.r-project.org Mon Oct 23 17:12:51 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 23 Oct 2017 17:12:51 +0200 (CEST) Subject: [CHNOSZ-commits] r265 - in pkg/CHNOSZ: . demo inst man Message-ID: <20171023151251.27297189162@r-forge.r-project.org> Author: jedick Date: 2017-10-23 17:12:50 +0200 (Mon, 23 Oct 2017) New Revision: 265 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/go-IU.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/DEW.Rd pkg/CHNOSZ/man/EOSregress.Rd pkg/CHNOSZ/man/IAPWS95.Rd pkg/CHNOSZ/man/add.obigt.Rd pkg/CHNOSZ/man/add.protein.Rd pkg/CHNOSZ/man/affinity.Rd pkg/CHNOSZ/man/anim.Rd pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/berman.Rd pkg/CHNOSZ/man/buffer.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/eos.Rd pkg/CHNOSZ/man/eqdata.Rd pkg/CHNOSZ/man/equilibrate.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/findit.Rd pkg/CHNOSZ/man/info.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/man/makeup.Rd pkg/CHNOSZ/man/mosaic.Rd pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/man/objective.Rd pkg/CHNOSZ/man/palply.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/man/revisit.Rd pkg/CHNOSZ/man/species.Rd pkg/CHNOSZ/man/subcrt.Rd pkg/CHNOSZ/man/swap.basis.Rd pkg/CHNOSZ/man/taxonomy.Rd pkg/CHNOSZ/man/util.array.Rd pkg/CHNOSZ/man/util.blast.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/man/util.expression.Rd pkg/CHNOSZ/man/util.fasta.Rd pkg/CHNOSZ/man/util.formula.Rd pkg/CHNOSZ/man/util.list.Rd pkg/CHNOSZ/man/util.matrix.Rd pkg/CHNOSZ/man/util.misc.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/man/util.protein.Rd pkg/CHNOSZ/man/util.seq.Rd pkg/CHNOSZ/man/util.test.Rd pkg/CHNOSZ/man/util.units.Rd pkg/CHNOSZ/man/util.water.Rd pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/man/wjd.Rd pkg/CHNOSZ/man/yeast.Rd Log: reorganize concept index entries in Rd files Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-23 15:12:50 UTC (rev 265) @@ -1,6 +1,6 @@ -Date: 2017-10-21 +Date: 2017-10-23 Package: CHNOSZ -Version: 1.1.0-63 +Version: 1.1.0-64 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/go-IU.R =================================================================== --- pkg/CHNOSZ/demo/go-IU.R 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/demo/go-IU.R 2017-10-23 15:12:50 UTC (rev 265) @@ -117,7 +117,7 @@ diagram(m$A.species, fill=fill) dprop <- describe.property(c("T", "P"), c(25, 1)) legend("bottomleft", legend=dprop, bty="n") -t1 <- quote("As-O-H-S, "~list(sum(S)==10^-3*M, sum(As)==10^-5*M)) +t1 <- quote("As-O-H-S, "~list(Sigma*S==10^-3~M, Sigma*As==10^-5~M)) t2 <- "After Lu and Zhu, 2011 Fig. 2b" # doi:10.1007/s12665-010-0652-x mtitle(as.expression(c(t1, t2)), cex=0.95) @@ -132,7 +132,8 @@ AlF <- c("AlF+2", "AlF2+", "AlF3", "AlF4-") AlOHF <- c("Al(OH)2F2-", "Al(OH)2F", "AlOHF2") species(c(AlOH, Al, AlF, AlOHF), "aq") -a <- affinity(pH=c(0, 10), `F-`=c(-1, -9), T=200) +res <- 300 +a <- affinity(pH=c(0.5, 6.5, res), `F-`=c(-2, -9, res), T=200) diagram(a, fill=rev(cm.colors(nrow(species())))) dprop <- describe.property(c("T", "P"), c(200, "Psat")) legend("topright", legend=dprop, bty="n") Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/inst/NEWS 2017-10-23 15:12:50 UTC (rev 265) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-61 (2017-10-20) +CHANGES IN CHNOSZ 1.1.0-64 (2017-10-23) --------------------------------------- MAJOR CHANGES: @@ -164,6 +164,10 @@ - Remove extdata/OBIGT/CHNOSZ_aq.csv and move the entry for pseudo-H4SiO4 to inorganic_aq.csv. +- Reorganize concept index entries in Rd files: Main workflow, Extended + workflow, Thermodynamic data, Thermodynamic calculations, Water + properties, Protein properties, Other tools, Utility functions. + CHANGES IN CHNOSZ 1.1.0 (2017-05-04) ------------------------------------ @@ -508,7 +512,8 @@ species. See also new 'mosaic.R' demo. - Add thermo$opt$varP option for subcrt() to calculate Gibbs energies - of gases using a variable-pressure standard state. + of gases using a variable-pressure standard state. Thanks to Kirt + Robinson for the submitting the problem that led to this change. - Add 'solubility.R' demo, and add calcite solubility plot to anintro.Rnw. Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -11,12 +11,20 @@ \section{Getting Help}{ The major features of the package are outlined in the Overview given below, with links to specific help topics. See the vignette \emph{An Introduction to CHNOSZ} (\code{anintro.Rmd}) for more in-depth example of the usage the functions. -The help pages have been given either keywords or \dQuote{concept index entries} which are visible to \code{\link{help.search}} (aka \code{??}). -Use \code{??primary} to browse the most commonly used functions and \code{??secondary} to see other high-level, but less often-used functions. -\code{??protein} shows functions for working with proteins, and \code{??extra} lists functions with extra functionality (beyond the main workflow). -For help on the thermodynamic database, use \code{??"thermodynamic data"}. -Finally, \code{??utilities} (one of the standard \R keywords) can be used to locate utility functions in the package; these include useful tools for modifying the database, converting units, reading protein sequence files, parsing chemical formulas, etc. +Each help page (other than this one) has been given one of the following \dQuote{concept index entries}: +\itemize{ + \item Main workflow: \code{\link{info}}, \code{\link{subcrt}}, \code{\link{basis}}, \code{\link{species}}, \code{\link{affinity}}, \code{\link{equilibrate}}, \code{\link{diagram}} + \item Extended workflow: \code{\link{swap.basis}}, \code{\link{buffer}}, \code{\link{mosaic}}, \code{\link{objective}}, \code{\link{revisit}}, \code{\link{findit}}, \code{\link{anim}}, \code{\link{EOSregress}}, \code{\link{wjd}} + \item Thermodynamic data: \code{\link{data}}, \code{\link{extdata}}, \code{\link{add.obigt}}, \code{\link{util.data}} + \item Thermodynamic calculations: \code{\link{util.formula}}, \code{\link{makeup}}, \code{\link{util.units}}, \code{\link{eos}}, \code{\link{berman}}, \code{\link{nonideal}}, \code{\link{util.misc}} + \item Water properties: \code{\link{water}}, \code{\link{util.water}}, \code{\link{DEW}}, \code{\link{IAPWS95}} + \item Protein properties: \code{\link{protein}}, \code{\link{protein.info}}, \code{\link{add.protein}}, \code{\link{util.fasta}}, \code{\link{util.protein}}, \code{\link{util.seq}}, \code{\link{ionize.aa}}, \code{\link{yeast}} + \item Other tools: \code{\link{examples}}, \code{\link{eqdata}}, \code{\link{taxonomy}}, \code{\link{util.blast}} + \item Utility functions: \code{\link{util.expression}}, \code{\link{util.plot}}, \code{\link{util.array}}, \code{\link{util.matrix}}, \code{\link{util.list}}, \code{\link{util.test}}, \code{\link{palply}} } +These concept entries are visible to \code{\link{help.search}} (aka \code{??}). +For example, help pages related to thermodynamic data can be listed using \code{??"thermodynamic data"}. +} \section{Warning}{ All thermodynamic data and examples are provided on an as-is basis. Modified: pkg/CHNOSZ/man/DEW.Rd =================================================================== --- pkg/CHNOSZ/man/DEW.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/DEW.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -56,4 +56,4 @@ Zhang, Z. and Duan, Z. (2005) Prediction of the \emph{PVT} properties of water over wide range of temperatures and pressures from molecular dynamics simulation. \emph{Phys. Earth Planet. Inter.} \bold{149}, 335--354. \url{https://doi.org/10.1016/j.pepi.2004.11.003} } -\concept{Secondary thermodynamic modeling} +\concept{Water properties} Modified: pkg/CHNOSZ/man/EOSregress.Rd =================================================================== --- pkg/CHNOSZ/man/EOSregress.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/EOSregress.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -190,4 +190,4 @@ # not consistent with the high-T heat capacities } -\concept{Extra thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/IAPWS95.Rd =================================================================== --- pkg/CHNOSZ/man/IAPWS95.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/IAPWS95.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -46,4 +46,4 @@ Wagner, W. and Pruss, A. (2002) The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. \emph{J. Phys. Chem. Ref. Data} \bold{31}, 387--535. \url{https://doi.org/10.1063/1.1461829} } -\concept{Secondary thermodynamic modeling} +\concept{Water properties} Modified: pkg/CHNOSZ/man/add.obigt.Rd =================================================================== --- pkg/CHNOSZ/man/add.obigt.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/add.obigt.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -114,3 +114,5 @@ Sverjensky, D. A., Shock, E. L., and Helgeson, H. C. (1997) Prediction of the thermodynamic properties of aqueous metal complexes to 1000 ?C and 5 kbar. \emph{Geochim. Cosmochim. Acta} \bold{61}, 1359--1412. \url{https://doi.org/10.1016/S0016-7037(97)00009-4} } + +\concept{Thermodynamic data} Modified: pkg/CHNOSZ/man/add.protein.Rd =================================================================== --- pkg/CHNOSZ/man/add.protein.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/add.protein.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -66,4 +66,4 @@ \code{\link{protein}} for examples of affinity calculations and diagrams. } -\concept{Protein thermodynamic modeling} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/affinity.Rd =================================================================== --- pkg/CHNOSZ/man/affinity.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/affinity.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -96,4 +96,4 @@ Helgeson, H. C., Richard, L, McKenzie, W. F., Norton, D. L. and Schmitt, A. (2009) A chemical and thermodynamic model of oil generation in hydrocarbon source rocks. \emph{Geochim. Cosmochim. Acta} \bold{73}, 594--695. \url{https://doi.org/10.1016/j.gca.2008.03.004} } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/anim.Rd =================================================================== --- pkg/CHNOSZ/man/anim.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/anim.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -60,4 +60,4 @@ Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{https://doi.org/10.1371/journal.pone.0022782} } -\concept{Extra thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/basis.Rd =================================================================== --- pkg/CHNOSZ/man/basis.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/basis.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -110,4 +110,4 @@ basis("CO2", "gas") } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/berman.Rd =================================================================== --- pkg/CHNOSZ/man/berman.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/berman.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -109,4 +109,4 @@ Sverjensky, D. A., Hemley, J. J. and D'Angelo, W. M. (1991) Thermodynamic assessment of hydrothermal alkali feldspar-mica-aluminosilicate equilibria. \emph{Geochim. Cosmochim. Acta} \bold{55}, 989-1004. \url{https://doi.org/10.1016/0016-7037(91)90157-Z} } -\concept{Secondary thermodynamic modeling} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/buffer.Rd =================================================================== --- pkg/CHNOSZ/man/buffer.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/buffer.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -165,4 +165,4 @@ Garrels, R. M. (1960) \emph{Mineral Equilibria}. Harper & Brothers, New York, 254 p. \url{http://www.worldcat.org/oclc/552690} } -\concept{Secondary thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/diagram.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -264,4 +264,4 @@ Majzlan, J., Navrotsky, A., McClesky, R. B. and Alpers, C. N. (2006) Thermodynamic properties and crystal structure refinement of ferricopiapite, coquimbite, rhomboclase, and Fe2(SO4)3(H2O)5. \emph{Eur. J. Mineral.} \bold{18}, 175--186. \url{https://doi.org/10.1127/0935-1221/2006/0018-0175} } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/eos.Rd =================================================================== --- pkg/CHNOSZ/man/eos.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/eos.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -1,5 +1,6 @@ \encoding{UTF-8} \name{eos} +\alias{eos} \alias{hkf} \alias{cgl} \title{Equations of State} @@ -101,4 +102,4 @@ } -\concept{Secondary thermodynamic modeling} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/eqdata.Rd =================================================================== --- pkg/CHNOSZ/man/eqdata.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/eqdata.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -53,4 +53,4 @@ eqdata("rainbow2.6o",c("h+","sio2,aq","h2,aq"),"log act") } } -\concept{Extra thermodynamic modeling} +\concept{Other tools} Modified: pkg/CHNOSZ/man/equilibrate.Rd =================================================================== --- pkg/CHNOSZ/man/equilibrate.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/equilibrate.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -124,4 +124,4 @@ Dick, J. M. (2008) Calculation of the relative metastabilities of proteins using the CHNOSZ software package. \emph{Geochem. Trans.} \bold{9}:10. \url{https://doi.org/10.1186/1467-4866-9-10} } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -116,4 +116,4 @@ } -\concept{Extra thermodynamic modeling} +\concept{Other tools} Modified: pkg/CHNOSZ/man/findit.Rd =================================================================== --- pkg/CHNOSZ/man/findit.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/findit.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -76,4 +76,4 @@ \seealso{ \code{demo("findit")} and \code{test-findit.R} for examples. } -\concept{Secondary thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/info.Rd =================================================================== --- pkg/CHNOSZ/man/info.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/info.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -79,4 +79,4 @@ info(" H2O") } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/ionize.aa.Rd =================================================================== --- pkg/CHNOSZ/man/ionize.aa.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/ionize.aa.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -94,4 +94,4 @@ Privalov, P. L. and Makhatadze, G. I. (1990) Heat capacity of proteins. II. Partial molar heat capacity of the unfolded polypeptide chain of proteins: Protein unfolding effects. \emph{J. Mol. Biol.} \bold{213}, 385--391. \url{https://doi.org/10.1016/S0022-2836(05)80198-6} } -\concept{Protein thermodynamic modeling} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/makeup.Rd =================================================================== --- pkg/CHNOSZ/man/makeup.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/makeup.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -84,4 +84,4 @@ \seealso{ \code{\link{mass}}, \code{\link{entropy}}, \code{\link{basis}}, \code{\link{i2A}} } -\concept{Secondary thermodynamic modeling} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/mosaic.Rd =================================================================== --- pkg/CHNOSZ/man/mosaic.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/mosaic.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -79,4 +79,4 @@ Garrels, R. M. and Christ, C. L. (1965) \emph{Solutions, Minerals, and Equilibria}, Harper & Row, New York, 450 p. \url{http://www.worldcat.org/oclc/517586} } -\concept{Secondary thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -175,4 +175,4 @@ Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5} } -\concept{Secondary thermodynamic modeling} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/objective.Rd =================================================================== --- pkg/CHNOSZ/man/objective.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/objective.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -137,4 +137,4 @@ } -\concept{Secondary thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/palply.Rd =================================================================== --- pkg/CHNOSZ/man/palply.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/palply.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -29,4 +29,4 @@ Tests are in \file{tests/test-util.program.R}, and a \dQuote{real world} example is in \file{demos/density.R}. } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/protein.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -76,4 +76,4 @@ title(main="Bovine proteins, GSH/GSSG redox buffer") } -\concept{Protein thermodynamic modeling} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/protein.info.Rd =================================================================== --- pkg/CHNOSZ/man/protein.info.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/protein.info.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -188,4 +188,4 @@ Dick, J. M. (2014) Average oxidation state of carbon in proteins. \emph{J. R. Soc. Interface} \bold{11}, 20131095. \url{https://doi.org/10.1098/rsif.2013.1095} } -\concept{Protein thermodynamic modeling} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/revisit.Rd =================================================================== --- pkg/CHNOSZ/man/revisit.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/revisit.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -151,4 +151,4 @@ par(opar) } -\concept{Secondary thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/species.Rd =================================================================== --- pkg/CHNOSZ/man/species.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/species.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -70,4 +70,4 @@ species() # NULL } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/subcrt.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -280,6 +280,30 @@ Na <- expr.species("Na+") degC <- expr.units("T") title(main=substitute(H2O~and~Na~to~-20~degC, list(H2O=H2O, Na=Na, degC=degC))) + +## Calculations using a variable-pressure standard state +thermo$opt$varP <<- TRUE +# Calculate the boiling point of n-octane at 2 and 20 bar +# We need exceed.Ttr=TRUE because the liquid is metastable +# at high temperatures (also, the gas is metastable at low +# temperatures, but that doesn't produce NA in the output) +sout2 <- subcrt(rep("n-octane", 2), c("liq", "gas"), + c(-1, 1), T=seq(-50, 300, 0.1), P=2, exceed.Ttr=TRUE)$out +sout20 <- subcrt(rep("n-octane", 2), c("liq", "gas"), + c(-1, 1), T=seq(-50, 300, 0.1), P=20, exceed.Ttr=TRUE)$out +# find T with the Gibbs energy of reaction that is closest to zero +Tvap2 <- sout2$T[which.min(abs(sout2$G))] +Tvap20 <- sout20$T[which.min(abs(sout20$G))] +# the boiling point increases with pressure +stopifnot(Tvap20 > Tvap2) +# more precisely, the calculated boiling points should be near the +# empirical values (digitized from Fig. 1 of Helgeson et al., 1998) +Tvap_2bar <- 156 +Tvap_20bar <- 276 +stopifnot(abs(Tvap2 - Tvap_2bar) < 6) +stopifnot(abs(Tvap20 - Tvap_20bar) < 25) +# those comparisons would fail if varP were FALSE (the default) +thermo$opt$varP <<- FALSE } \references{ @@ -287,6 +311,8 @@ Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000\degC. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{https://doi.org/10.1016/0098-3004(92)90029-Q} + Helgeson, H. C., Owens, C. E., Knox, A. M. and Richard, L. (1998) Calculation of the standard molal thermodynamic properties of crystalline, liquid, and gas organic molecules at high temperatures and pressures. \emph{Geochim. Cosmochim. Acta} \bold{62}, 985--1081. \url{https://doi.org/10.1016/S0016-7037(97)00219-6} + LaRowe, D. E. and Helgeson, H. C. (2007) Quantifying the energetics of metabolic reactions in diverse biogeochemical systems: electron flow and ATP synthesis. \emph{Geobiology} \bold{5}, 153--168. \url{https://doi.org/10.1111/j.1472-4669.2007.00099.x} Schulte, M. D. and Shock, E. L. (1995) Thermodynamics of Strecker synthesis in hydrothermal systems. \emph{Orig. Life Evol. Biosph.} \bold{25}, 161--173. \url{https://doi.org/10.1007/BF01581580} @@ -294,4 +320,4 @@ Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \degC and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{https://doi.org/10.1039/FT9928800803} } -\concept{Primary thermodynamic modeling} +\concept{Main workflow} Modified: pkg/CHNOSZ/man/swap.basis.Rd =================================================================== --- pkg/CHNOSZ/man/swap.basis.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/swap.basis.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -92,4 +92,4 @@ stopifnot(all.equal(a1$values, a3$values)) } -\concept{Secondary thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/taxonomy.Rd =================================================================== --- pkg/CHNOSZ/man/taxonomy.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/taxonomy.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -91,4 +91,4 @@ sciname(id8,names=names) } -\concept{Extra thermodynamic modeling} +\concept{Other tools} Modified: pkg/CHNOSZ/man/util.array.Rd =================================================================== --- pkg/CHNOSZ/man/util.array.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.array.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -87,4 +87,4 @@ stopifnot(all.equal(a1$values,a3$values)) } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/util.blast.Rd =================================================================== --- pkg/CHNOSZ/man/util.blast.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.blast.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -114,4 +114,4 @@ Altschul, S. F., Madden, T. L., Schaffer, A. A., Zhang, J. H., Zhang, Z., Miller, W. and Lipman, D. J. (1997) Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. \emph{Nucleic Acids Res.} \bold{25}, 3389--3402. \url{https://doi.org/doi:10.1093/nar/25.17.3389} } -\keyword{utilities} +\concept{Other tools} Modified: pkg/CHNOSZ/man/util.data.Rd =================================================================== --- pkg/CHNOSZ/man/util.data.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.data.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -86,4 +86,4 @@ Richard, L. and Helgeson, H. C. (1998) Calculation of the thermodynamic properties at elevated temperatures and pressures of saturated and aromatic high molecular weight solid and liquid hydrocarbons in kerogen, bitumen, petroleum, and other organic matter of biogeochemical interest. \emph{Geochim. Cosmochim. Acta} \bold{62}, 3591--3636. \url{https://doi.org/10.1016/S0016-7037(97)00345-1} } -\keyword{utilities} +\concept{Thermodynamic data} Modified: pkg/CHNOSZ/man/util.expression.Rd =================================================================== --- pkg/CHNOSZ/man/util.expression.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.expression.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -156,4 +156,4 @@ text(3, 4.75, describe.reaction(reaction, iname=1:4)) } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/util.fasta.Rd =================================================================== --- pkg/CHNOSZ/man/util.fasta.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.fasta.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -100,4 +100,4 @@ } } -\keyword{utilities} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/util.formula.Rd =================================================================== --- pkg/CHNOSZ/man/util.formula.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.formula.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -112,4 +112,4 @@ Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{https://doi.org/10.1371/journal.pone.0022782} } -\keyword{utilities} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/util.list.Rd =================================================================== --- pkg/CHNOSZ/man/util.list.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.list.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -23,4 +23,4 @@ If \code{na.rm} is \code{TRUE}, values of \code{NA} are removed; if \code{pmin} is \code{TRUE} the function finds locations of the minimum values instead. } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/util.matrix.Rd =================================================================== --- pkg/CHNOSZ/man/util.matrix.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.matrix.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -42,4 +42,4 @@ stopifnot(tail(names(sc), 2)==c("C", "M")) } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/util.misc.Rd =================================================================== --- pkg/CHNOSZ/man/util.misc.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.misc.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -90,4 +90,4 @@ stopifnot(isTRUE(all.equal(sum(10^loga * length),1))) } -\keyword{utilities} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/util.plot.Rd =================================================================== --- pkg/CHNOSZ/man/util.plot.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.plot.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -93,4 +93,4 @@ } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/util.protein.Rd =================================================================== --- pkg/CHNOSZ/man/util.protein.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.protein.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -1,5 +1,6 @@ \encoding{UTF-8} \name{util.protein} +\alias{util.protein} \alias{group.formulas} \alias{MP90.cp} \title{Functions for Proteins (Other Calculations)} @@ -33,4 +34,4 @@ Makhatadze, G. I. and Privalov, P. L. (1990) Heat capacity of proteins. 1. Partial molar heat capacity of individual amino acid residues in aqueous solution: Hydration effect \emph{J. Mol. Biol.} \bold{213}, 375--384. \url{https://doi.org/10.1016/S0022-2836(05)80197-4} } -\concept{utilities} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/util.seq.Rd =================================================================== --- pkg/CHNOSZ/man/util.seq.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.seq.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -51,4 +51,4 @@ nucleic.formula(RNA.comp) # C40H42N32O11 } -\keyword{utilities} +\concept{Protein properties} Modified: pkg/CHNOSZ/man/util.test.Rd =================================================================== --- pkg/CHNOSZ/man/util.test.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.test.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -28,4 +28,4 @@ The function uses \code{\link[testthat]{expect}} to generate an expectation in the \CRANpkg{testthat} framework. } -\keyword{utilities} +\concept{Utility functions} Modified: pkg/CHNOSZ/man/util.units.Rd =================================================================== --- pkg/CHNOSZ/man/util.units.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.units.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -77,4 +77,4 @@ T.units("C") } -\keyword{utilities} +\concept{Thermodynamic calculations} Modified: pkg/CHNOSZ/man/util.water.Rd =================================================================== --- pkg/CHNOSZ/man/util.water.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/util.water.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -78,4 +78,4 @@ Wagner, W. and Pru?, A. (2002) The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. \emph{J. Phys. Chem. Ref. Data} \bold{31}, 387--535. \url{https://doi.org/10.1063/1.1461829} } -\concept{Secondary thermodynamic modeling} +\concept{Water properties} Modified: pkg/CHNOSZ/man/water.Rd =================================================================== --- pkg/CHNOSZ/man/water.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/water.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -177,4 +177,4 @@ Wagner, W. and Pruss, A. (2002) The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. \emph{J. Phys. Chem. Ref. Data} \bold{31}, 387--535. \url{https://doi.org/10.1063/1.1461829} } -\concept{Secondary thermodynamic modeling} +\concept{Water properties} Modified: pkg/CHNOSZ/man/wjd.Rd =================================================================== --- pkg/CHNOSZ/man/wjd.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/wjd.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -176,4 +176,4 @@ White, W. B., Johnson, S. M. and Dantzig, G. B. (1958) Chemical equilibrium in complex mixtures. \emph{J. Chem. Phys.} \bold{28}, 751--755. \url{https://doi.org/10.1063/1.1744264} } -\concept{Extra thermodynamic modeling} +\concept{Extended workflow} Modified: pkg/CHNOSZ/man/yeast.Rd =================================================================== --- pkg/CHNOSZ/man/yeast.Rd 2017-10-21 15:34:45 UTC (rev 264) +++ pkg/CHNOSZ/man/yeast.Rd 2017-10-23 15:12:50 UTC (rev 265) @@ -1,5 +1,6 @@ \encoding{UTF-8} \name{yeast} +\alias{yeast} \alias{yeast.aa} \alias{yeastgfp} \title{Composition, Localization, and Abundances of Proteins in Yeast} @@ -105,4 +106,4 @@ Tai, S. L., Boer, V. M., Daran-Lapujade, P., Walsh, M. C., de Winde, J. H., Daran, J.-M. and Pronk, J. T. (2005) Two-dimensional transcriptome analysis in chemostat cultures: Combinatorial effects of oxygen availability and macronutrient limitation in \emph{Saccharomyces cerevisiae}. \emph{J. Biol. Chem.} \bold{280}, 437--447. \url{https://doi.org/10.1074/jbc.M410573200} } -\concept{Protein thermodynamic modeling} +\concept{Protein properties} From noreply at r-forge.r-project.org Tue Oct 24 15:29:31 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 24 Oct 2017 15:29:31 +0200 (CEST) Subject: [CHNOSZ-commits] r266 - in pkg/CHNOSZ: . demo Message-ID: <20171024132931.629BF1895FA@r-forge.r-project.org> Author: jedick Date: 2017-10-24 15:29:31 +0200 (Tue, 24 Oct 2017) New Revision: 266 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/go-IU.R Log: demo/go-IU.R: add points calculated using SUPCRTBL Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-23 15:12:50 UTC (rev 265) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-24 13:29:31 UTC (rev 266) @@ -1,6 +1,6 @@ -Date: 2017-10-23 +Date: 2017-10-24 Package: CHNOSZ -Version: 1.1.0-64 +Version: 1.1.0-65 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/go-IU.R =================================================================== --- pkg/CHNOSZ/demo/go-IU.R 2017-10-23 15:12:50 UTC (rev 265) +++ pkg/CHNOSZ/demo/go-IU.R 2017-10-24 13:29:31 UTC (rev 266) @@ -38,11 +38,15 @@ lines(T, -r2$out$logK, lty=2) lines(T, -r3$out$logK, lty=2, col="red") lines(T, -r4$out$logK, col="red") +## add points calculated using the SUPCRTBL package +points(seq(125, 350, 25), -c(3.489, 3.217, 2.967, 2.734, 2.517, 2.314, 2.124, 1.946, 1.781, 1.628), pch=4, col="red") ## add labels, legend, and title text(182.5, -3.17, "SUPCRT92\n(CHNOSZ default)", srt=48, cex=0.7, font=2) text(154, -3.04, "circa SUPCRTBL", srt=45, cex=0.7, font=2, col="red") -legend("topleft", lty=c(1, 2, 2, 1), col=c("black", "black", "red", "red"), bty="n", cex=0.9, - legend=c("Kln,Bhm:HDNB78; SiO2(aq):SHS89", "Kln:Ber88 (SUPCRTBL uses HP11)", "+ Bhm:HRA91", "+ SiO2(aq):AS04")) +legend("topleft", lty=c(1, 2, 2, 1, 0), pch=c(NA, NA, NA, NA, 4), + col=c("black", "black", "red", "red", "red"), bty="n", cex=0.9, + legend=c("Kln,Bhm:HDNB78; SiO2(aq):SHS89", "Kln:Ber88 (SUPCRTBL uses HP11)", + "+ Bhm:HRA91", "+ SiO2(aq):AS04", "SUPCRTBL")) legend("bottomright", pch=1, legend="Hemley et al., 1980", bty="n", cex=0.9) mtitle(c("Kaolinite - Boehmite", "After Zhu and Lu, 2009 Fig. A1"), cex=0.95) # Zhu and Lu, 2009: doi:10.1016/j.gca.2009.03.015 @@ -75,11 +79,13 @@ ## plot the calculated logKs lines(T, Daw1$out$logK, col="red") lines(T, Daw2$out$logK, col="red", lty=2) +## add points calculated using the SUPCRTBL package +points(seq(25, 250, 25), c(-17.829, -16.523, -15.402, -14.425, -13.568, -12.815, -12.154, -11.581, -11.094, -10.699), pch=4, col="red") ## add labels, legend, and title text(182.5, -3.17, "SUPCRT92\n(CHNOSZ default)", srt=43, cex=0.7, font=2) text(145, -3.1, "SUPCRTBL", srt=41.5, cex=0.7, font=2, col="red") -legend("topleft", lty=1:2, col="red", bty="n", cex=0.9, - legend=c("Daw Cp != 0", "Daw Cp = 0")) +legend("topleft", lty=c(1, 2, 0), pch=c(NA, NA, 4), col="red", bty="n", cex=0.9, + legend=c("Daw Cp != 0", "Daw Cp = 0", "SUPCRTBL")) legend("bottomright", pch=1, legend="Ben\u00e9z\u00e9th et al., 2007", bty="n", cex=0.9) mtitle(c("Dawsonite - aqueous species", "After Zimmer et al., 2016 Fig. 2"), cex=0.95) # doi:10.1016/j.cageo.2016.02.013 From noreply at r-forge.r-project.org Wed Oct 25 17:50:57 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 25 Oct 2017 17:50:57 +0200 (CEST) Subject: [CHNOSZ-commits] r267 - in pkg/CHNOSZ: . demo inst man tests/testthat vignettes Message-ID: <20171025155057.77E0D1891F5@r-forge.r-project.org> Author: jedick Date: 2017-10-25 17:50:57 +0200 (Wed, 25 Oct 2017) New Revision: 267 Added: pkg/CHNOSZ/tests/testthat/test-logmolality.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: document activity-molality transformation in anintro.Rmd and test-logmolality.R Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-24 13:29:31 UTC (rev 266) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-25 15:50:57 UTC (rev 267) @@ -1,6 +1,6 @@ -Date: 2017-10-24 +Date: 2017-10-25 Package: CHNOSZ -Version: 1.1.0-65 +Version: 1.1.0-66 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick @@ -11,12 +11,11 @@ compositional biology. Thermodynamic properties are taken from a database for minerals and inorganic and organic aqueous species including biomolecules, or from amino acid group additivity for proteins. High-temperature properties are calculated using the - revised Helgeson-Kirkham-Flowers equations of state for aqueous species. Functions are + revised Helgeson-Kirkham-Flowers equations of state for aqueous species, and activity + coefficients can be calculated for specified ionic strength. Functions are provided to define a system using basis species, automatically balance reactions, - calculate the chemical affinities of reactions for selected species, and plot the results - on potential diagrams or equilibrium activity diagrams. Experimental features are - available to calculate activity coefficients for aqueous species or for multidimensional - optimization of thermodynamic variables using an objective function. + calculate the chemical affinities of formation reactions for selected species, calculate + equilibrium activities, and plot the results on chemical activity diagrams. License: GPL (>= 2) BuildResaveData: no VignetteBuilder: knitr Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-24 13:29:31 UTC (rev 266) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-25 15:50:57 UTC (rev 267) @@ -134,9 +134,8 @@ # pH set by jadeite + kyanite + coesite # output from EQ3NR calculations (SSH14 Supporting Information) # dissolved carbon: 0.03, 0.2, 1, 4, 20 molal -# ionic strength: 0.39, 0.57, 0.88, 1.45, 2.49 +# true ionic strength: 0.39, 0.57, 0.88, 1.45, 2.49 # pH: 3.80, 3.99, 4.14, 4.25, 4.33 -T <- seq(600, 1000, 5) ## activate DEW model data(thermo) water("DEW") @@ -151,33 +150,33 @@ mod.buffer("QFM_Berman", c("quartz", "fayalite", "magnetite"), "cr_Berman", 0) ## calculate logfO2 in QFM buffer basis("O2", "QFM_Berman") +T <- seq(600, 1000, 5); T100 <- seq(600, 1000, 100) buf <- affinity(T=T, P=50000, return.buffer=TRUE) ## add species species(c(inorganics, organics)) ## generate spline functions from IS, pH, and molC values at every 100 degC -IS <- splinefun(T[!T%%100], c(0.39, 0.57, 0.88, 1.45, 2.49)) -pH <- splinefun(T[!T%%100], c(3.80, 3.99, 4.14, 4.25, 4.33)) -molC <- splinefun(T[!T%%100], c(0.03, 0.2, 1, 4, 20)) +IS <- splinefun(T100, c(0.39, 0.57, 0.88, 1.45, 2.49)) +pH <- splinefun(T100, c(3.80, 3.99, 4.14, 4.25, 4.33)) +molC <- splinefun(T100, c(0.03, 0.2, 1, 4, 20)) ## use Debye-Huckel equation with B-dot set to zero nonideal("Helgeson0") ## calculate affinities on the T-logfO2-pH-IS transect -a <- affinity(T=T, O2=buf$O2 - 2, IS=IS(T), pH=pH(T), P=50000) +a <- affinity(T = T, O2 = buf$O2 - 2, IS = IS(T), pH = pH(T), P = 50000) ## calculate metastable equilibrium activities using the total ## carbon molality as an approximation of total activity -e <- equilibrate(a, loga.balance=log10(molC(T))) +e <- equilibrate(a, loga.balance = log10(molC(T))) ## make the diagram; don't plot names of low-abundance species names <- c(inorganics, organics) names[c(4, 5, 7, 9)] <- "" col <- rep("black", length(names)) col[c(1, 3, 6, 8, 10)] <- c("red", "darkgreen", "purple", "orange", "navyblue") -diagram(e, alpha="balance", ylab="carbon fraction", names=names, col=col, ylim=c(0, 0.8)) +diagram(e, alpha = "balance", ylab = "carbon fraction", names = names, col = col, ylim = c(0, 0.8), ylab="carbon fraction") ## add legend and title ltxt1 <- "P = 50000 bar" -ltxt2 <- substitute(logfO2=="QFM-2", list(logfO2=axis.label("O2"))) -ltxt3 <- "pH = 4" -pH <- seq(3.8, 4.3, length.out=length(T)) -legend("left", legend=as.expression(c(ltxt1, ltxt2, ltxt3)), bty="n") +ltxt2 <- substitute(logfO2=="QFM-2", list(logfO2 = axis.label("O2"))) +pH <- seq(3.8, 4.3, length.out = length(T)) +legend("left", legend = as.expression(c(ltxt1, ltxt2)), bty = "n") t1 <- "Aqueous carbon speciation" t2 <- "after Sverjensky et al., 2014b" mtitle(c(t1, t2)) @@ -192,7 +191,7 @@ inorganic.logK <- c(24.4765, -9.0784, -5.3468, 0) organic.logK <- c(1.7878, 2.5648, 15.3182, 16.9743, 30.4088, 28.9185) # calculate equilibrium constants of the reactions in CHNOSZ; use a negative sign to change from formation to dissociation -logK.calc <- -unlist(affinity(T=600, P=50000, property="logK")$values) +logK.calc <- -unlist(affinity(T = 600, P = 50000, property = "logK")$values) logK.calc - c(inorganic.logK, organic.logK) ## check that we're within 0.021 of the logK values used by SSH14 stopifnot(maxdiff(logK.calc, c(inorganic.logK, organic.logK)) < 0.021) @@ -201,7 +200,7 @@ # activity coefficients for monovalent species from EQ3NR output loggamma <- c(-0.15, -0.18, -0.22, -0.26, -0.31) # activity coefficients calculated in CHNOSZ -sres <- subcrt("propanoate", T=seq(600, 1000, 100), P=50000, IS=c(0.39, 0.57, 0.88, 1.45, 2.49)) +sres <- subcrt("propanoate", T = seq(600, 1000, 100), P = 50000, IS = c(0.39, 0.57, 0.88, 1.45, 2.49)) stopifnot(maxdiff(sres$out[[1]]$loggam, loggamma) < 0.004) ########### Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-24 13:29:31 UTC (rev 266) +++ pkg/CHNOSZ/inst/NEWS 2017-10-25 15:50:57 UTC (rev 267) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-64 (2017-10-23) +CHANGES IN CHNOSZ 1.1.0-66 (2017-10-25) --------------------------------------- MAJOR CHANGES: @@ -143,6 +143,11 @@ - Add demo TCA.R for standard Gibbs energies of steps of the citric acid cycle (Canovas and Shock, 2016). +- Add test-logmolality.R to demonstrate transformation of variables from + activity to molality in the main workflow; refer to this test and + describe these transformations in anintro.Rmd; remove "experimental" + labeling of activity coefficient calculations in CHNOSZ-package.Rd. + CLEANUP: - To save space, taxid_names.csv has been trimmed to hold only those Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-24 13:29:31 UTC (rev 266) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-25 15:50:57 UTC (rev 267) @@ -60,7 +60,7 @@ \item Buffer calculations - compute activities of basis species that are determined by a buffer of one or more species (e.g., pyrite-pyrrhotite-magnetite; acetic acid-\CO2) (\code{\link{buffer}}). - \item Activity coefficients (\bold{experimental}) - calculate activity coefficients of aqueous species using the extended Debye-H?ckel equation (\code{\link{nonideal}}). + \item Activity coefficients - calculate activity coefficients of aqueous species using the extended Debye-H?ckel equation (\code{\link{nonideal}}). \item Activity statistics (\bold{experimental}) - calculate summary statistics for equilibrium activities of species (\code{\link{revisit}}). Added: pkg/CHNOSZ/tests/testthat/test-logmolality.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-logmolality.R (rev 0) +++ pkg/CHNOSZ/tests/testthat/test-logmolality.R 2017-10-25 15:50:57 UTC (rev 267) @@ -0,0 +1,124 @@ +context("logmolality") + +test_that("non-zero ionic strength transforms variables from activity to molality", { + # what happens with activity coefficients when using subcrt() to calculate affinity, + # and in the rest of the main workflow of CHNOSZ? + # 20171025 + + # first get the activity coefficients of H+ and HCO3- + # the long way... + wprop <- water(c("A_DH", "B_DH"), P=1) + nonid <- nonideal(c("H+", "HCO3-"), subcrt(c("H+", "HCO3-"), T=25)$out, IS=1, T=298.15, P=1, A_DH=wprop$A_DH, B_DH=wprop$B_DH) + # here we have a small difference due to rounding of the expected value: + expect_maxdiff(nonid[[2]]$loggam, -0.1890084, 1e-7) + # the short way... + loggam <- subcrt(c("H+", "HCO3-"), T=25, IS=1)$out[[2]]$loggam + # we get that loggam(H+)=0 and loggam(HCO3-)=-0.189 + expect_equal(nonid[[2]]$loggam, loggam) + + ## take-home lesson 0: with default settings, + ## the activity coefficient of H+ is always 1 + + # how do activity coefficient affect the value of G? + # let's step back and look at the *standard Gibbs energy* at IS = 0 + 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 + # by an amount determined by the activity coefficient + expect_equal(out1[[2]]$G - out0[[2]]$G, -convert(loggam, "G")) + + ## take-home lesson 1.5: setting IS in subcrt() gives apparent 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) + logK <- subcrt(c("CO2", "H2O", "H+", "HCO3-"), c(-1, -1, 1, 1), T=25)$out$logK + # we get logK = -6.344694 (rounded) + expect_maxdiff(logK, -6.344694, 1e-6) + + # now, what is the affinity of the reaction at pH=7 and molalities of HCO3- and CO2 = 10^-3? + + ## case 1: ionic strength = 0, so gamma = 0 and activity = molality + # first calculate it by hand from 2.303RTlog(K/Q) + # logQ = (logaH+ + logaHCO3-) - (logaH2O + logaCO2) + logQ0 <- (-7 + -3) - (0 + -3) # i.e. 7 + # convert logs to energy according to G = -2.303RTlogK + # (we negate that to get affinity) + A0manual <- -convert(logK - logQ0, "G") + # now the subcrtmatic calculation with subcrt + A0subcrt <- subcrt(c("CO2", "H2O", "H+", "HCO3-"), c(-1, -1, 1, 1), T=25, logact=c(-3, 0, -7, -3))$out$A + # we get the same affinity! + expect_equal(A0subcrt, A0manual) + + ## case 1: ionic strength = 0, so activity = molality * gamma + logaHCO3 = -3 + loggam + logQ1 <- (-7 + logaHCO3) - (0 + -3) + A1manual <- -convert(logK - logQ1, "G") + A1subcrt <- subcrt(c("CO2", "H2O", "H+", "HCO3-"), c(-1, -1, 1, 1), T=25, logact=c(-3, 0, -7, -3), IS=1)$out$A + expect_equal(A1subcrt, A1manual) + + ## take-home lesson 1: using subcrt with IS not equal to zero, the "logact" + ## argument is logmolal in affinity calculations for charged aqueous species + + # now, calculate the affinities using affinity() + basis("CHNOS+") # pH=7, logaCO2 = -3 + species(c("CO2", "HCO3-")) # logactivities = -3 + + ## case 1: IS = 0 + a0 <- affinity() + # that gives us values in log units; convert to energy + # (HCO3- is species #2) + A0affinity <- -convert(a0$values[[2]], "G") + expect_equal(A0affinity[[1]], A0subcrt) + + ## case 2: IS = 1 + a1 <- affinity(IS=1) + A1affinity <- -convert(a1$values[[2]], "G") + expect_equal(A1affinity[[1]], A1subcrt) + + ## take-home lesson 2: using affinity() with IS not equal to zero, the "logact" + ## set by species() is logmolal in affinity calculations for charged aqueous species + + # now, swap HCO3- for CO2 in the basis + swap.basis("CO2", "HCO3-") + basis("HCO3-", -3) + a0 <- affinity() + a1 <- affinity(IS=1) + # look at HCO3 formation affinity: + # they're both zero at IS = 0 or 1 + expect_equal(a0$values[[2]][1], 0) + expect_equal(a1$values[[2]][1], 0) + # look at CO2 formation affinity: + ACO2_0affinity <- -convert(a0$values[[1]], "G") + ACO2_1affinity <- -convert(a1$values[[1]], "G") + # what's that?? we're looking at the reverse of the above + # reaction, i.e. H+ + HCO3- = CO2 + H2O + # so, logK = 6.345 + logKrev <- -logK + logQrev0 <- -logQ0 + logQrev1 <- -logQ1 + ACO2_0manual <- -convert(logKrev - logQrev0, "G") + ACO2_1manual <- -convert(logKrev - logQrev1, "G") + expect_equal(ACO2_0manual, ACO2_0affinity[[1]]) + expect_equal(ACO2_1manual, ACO2_1affinity[[1]]) + + ## take-home lesson 3: using affinity() with IS not equal to zero, the "logact" + ## set by basis() is logmolal in affinity calculations for charged aqueous species + + # now look at equilibrate() + e0 <- equilibrate(a0) + e1 <- equilibrate(a1) + # using the equilibrated values, calculate affinity of the reaction CO2 + H2O = H+ + HCO3- + # case 1: IS = 0 + logQeq0 <- (-7 + e0$loga.equil[[2]]) - (e0$loga.equil[[1]] + 0) + Aeq0 <- -convert(logK - logQeq0, "G") # zero! + expect_equal(Aeq0[[1]], 0) + # case 2: IS = 1 + # here, loga.equil is the *molality*, so we must multiply by loggam + logQeq1 <- (-7 + e1$loga.equil[[2]] + loggam) - (e1$loga.equil[[1]] + 0) + Aeq1 <- -convert(logK - logQeq1, "G") # zero! + expect_equal(Aeq1[[1]], 0) + + ## take-home lesson 4: using affinity() with IS not equal to zero, the "loga.equil" + ## returned by equilibrate() is logmolal for speciation calculations with charged aqueous species +}) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-24 13:29:31 UTC (rev 266) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-25 15:50:57 UTC (rev 267) @@ -796,8 +796,8 @@ CHNOSZ does not take account of all possible reactions in the speciation of a system. Instead, it assumes that the total activity of species in the system is set by the activity of *one* basis species. ```{marginfigure} -If activity coefficients are assumed to be zero, activities are equal to concentration and we can refer to "total activity". -`nonideal()` ([see below](#activity-coefficients)) is an experimental feature to deal with activity coefficients. +When activity coefficients are assumed to be zero, activities are equal to concentration and we can refer to "total activity". +If the ionic strength is specified, `nonideal()` ([see below](#activity-coefficients)) can be used to calculate activity coefficients. ``` This balanced, or conserved, basis species must be present (with a positive or negative coefficient) in the formation reactions of all species considered. @@ -981,6 +981,179 @@ For instance, the widespread rule of thumb for balancing mineral reactions on a chemical component is unrealistic for processes where volume is conserved [@MD98]. While choosing an inappropriate balance leads to infeasible models, consideration of the different possibilities might give insight into the conditions affecting the dynamics of some systems. +# Activity coefficients + +`nonideal()` uses the extended Debye--H?ckel equation as formulated by @HKF81 for NaCl-dominated solutions, or optionally using parameters described in Chapter 3 of @Alb03, to calculate activity coefficients of charged species. +The activity coefficients are calculated as a function of ionic strength (*I*), temperature, and charge of each species, without any other species-specific parameters. +Using the default `Helgeson` method, the extended term parameter ("B-dot") is derived from data of @Hel69 and Helgeson et al. (1981), and extrapolations of @MSS13. + +## Transformation of variables + +Following the main workflow of CHNOSZ, `nonideal()` normally does not need to be used directly. +Intead, invoke the calculations by setting the `IS` argument in `subcrt()` or `affinity()`. +There are a few things to remember when using activity coefficients: + +* H+ is assumed to behave ideally, so its activity coefficient is 1 for any ionic strength. You can calculate activity coefficients of H+ by setting `thermo$opt$ideal.H <<- FALSE`. + +* Using `subcrt()` with `IS` not equal to zero, calculated values of `G` are the **apparent** standard Gibbs energy at specified ionic strength. + +* Using `subcrt()` with `IS` not equal to zero, values in the `logact` argument stand for **log molality** of charged aqueous species in affinity calculations. + +* Using `affinity()` with `IS` not equal to zero, the following values stand for **log molality** of charged aqueous species: + + values of `logact` set by `basis()`; + + values of `logact` set by `species()`; + + value of `loga.equil` returned by `equilibrate()` + +In other words, the activation of activity coefficients transforms variables from activity to molality in the main workflow. +A simple but detailed example demonstrating each of the above tranformations is in `tests/testthat/test-logmolality.R`. + +Because it is not possible to dynamically change the names of arguments in the functions, the user should be aware of the effects mentioned above. +As another consequence, activities of basis species or equilibrium activities of species shown on diagrams should be relabeled as molalities when `IS` is used in the calculation of `affinity()`. + +## Biochemical example + +For the following calculations, we change the nonideality method to `Alberty`; this is a simpler formulation with parameters that are suitable for biochemical species at relatively low temperatures: +```{r Alberty} +oldnon <- nonideal("Alberty") +``` + +Let's take a look at calculated activity coefficients at two temperatures and their effect on the standard Gibbs energies of formation (?*G*?*f*) of species with different charge: +```{r subcrt_IS} +subcrt(c("MgATP-2", "MgHATP-", "MgH2ATP"), + T = c(25, 100), IS = c(0, 0.25), property = "G")$out +``` + +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. + +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+ and Mg+2 bound to ATP in solution as a function of pH or pMg (-log*a*Mg+2). + +Use `info()` to see what ATP species are available. +The sources of high-temperature thermodynamic data for these species are two papers by LaRowe and Helgeson [- at LH06a; - at LH06b]. +```{r info_ATP, results="hide"} +info(" ATP") +``` + +The plots for this system in Alberty's book were made for *I* = 0.25 M and *T* = 25 ?C. +As a demonstration of CHNOSZ's capabilities, we can assign a temperature of 100 ?C. +```{r T_100} +T <- 100 +``` + +Use the following commands to set the basis species, add the variously protonated ATP species, calculate the affinities of the formation reactions, equilibrate the system, and make a degree of formation (?) or mole fraction diagram. +This is similar to Figure 1.3 of Alberty (2003), but is calculated for *I* = 0 M and *T* = 100 ?C: +```{marginfigure} +To make the code more readable, commands for plotting titles and legends are not shown. +All of the commands are available in the source of this document. +``` + +```{r ATP, eval=FALSE, echo=2:6} +par(mfrow = c(1, 4), mar = c(3.1, 3.6, 2.1, 1.6), mgp = c(1.8, 0.5, 0)) +basis("MgCHNOPS+") +species(c("ATP-4", "HATP-3", "H2ATP-2", "H3ATP-", "H4ATP")) +a <- affinity(pH = c(3, 9), T = T) +e <- equilibrate(a) +d <- diagram(e, alpha = TRUE, tplot = FALSE) +title(main = describe.property("T", T)) +alphas <- do.call(rbind, d$plotvals) +nH <- alphas * 0:4 +Hlab <- substitute(italic(N)[H^`+`]) +plot(a$vals[[1]], colSums(nH), type = "l", xlab = "pH", ylab=Hlab, lty=2, col=2) +a <- affinity(pH = c(3, 9), IS = 0.25, T = T) +e <- equilibrate(a) +d <- diagram(e, alpha = TRUE, plot.it = FALSE) +alphas <- do.call(rbind, d$plotvals) +nH <- alphas * 0:4 +lines(a$vals[[1]], colSums(nH)) +legend("topright", legend = c("I = 0 M", "I = 0.25 M"), lty = 2:1, col = 2:1, cex = 0.8) +ATP.H <- substitute("ATP and H"^`+`) +title(main = ATP.H) +species(c("MgATP-2", "MgHATP-", "MgH2ATP", "Mg2ATP")) +Hplot <- function(pMg, IS = 0.25) { + basis("Mg+2", -pMg) + a <- affinity(pH = c(3, 9), IS = IS, T = T) + e <- equilibrate(a) + d <- diagram(e, alpha = TRUE, plot.it = FALSE) + alphas <- do.call(rbind, d$plotvals) + NH <- alphas * c(0:4, 0, 1, 2, 0) + lines(a$vals[[1]], colSums(NH), lty = 7 - pMg, col = 7 - pMg) +} +plot(c(3, 9), c(0, 2), type = "n", xlab = "pH", ylab = Hlab) +lapply(2:6, Hplot) +legend("topright", legend = paste("pMg = ", 2:6), lty = 5:1, col = 5:1, cex = 0.8) +ATP.H.Mg <- substitute("ATP and H"^`+`~"and Mg"^`+2`) +title(main = ATP.H.Mg) +Mgplot <- function(pH, IS = 0.25) { + basis("pH", pH) + a <- affinity(`Mg+2` = c(-2, -7), IS = IS, T = T) + e <- equilibrate(a) + d <- diagram(e, alpha = TRUE, plot.it = FALSE) + alphas <- do.call(rbind, d$plotvals) + NMg <- alphas * species()$`Mg+` + lines(-a$vals[[1]], colSums(NMg), lty = 10 - pH, col = 10 - pH) +} +Mglab <- substitute(italic(N)[Mg^`+2`]) +plot(c(2, 7), c(0, 1.2), type = "n", xlab = "pMg", ylab = Mglab) +lapply(3:9, Mgplot) +legend("topright", legend = paste("pH = ", 3:9), lty = 7:1, col = 7:1, cex = 0.8) +title(main = ATP.H.Mg) +``` + +Note that we have saved the numeric results of `diagram()`, i.e. the degrees of formation of the species (?). +With that, we can calculate and plot the average number of protons bound per ATP molecule. +To do so, we use R's `rbind()` and `do.call()` to turn `alpha` into a matrix, then multiply by the number of protons bound to each species, and sum the columns to get the total (i.e. average proton number, *N*H+): +```{r ATP, eval=FALSE, echo=8:11} +``` + +Adding the `IS` argument to `affinity()`, we can now plot *N*H+ at the given ionic strength. +Here we set `plot.it = FALSE` in `diagram()` because we use the computed ? to make our own plot. +This is similar to Figure 1.3 of Alberty (2003), but at higher temperature: +```{r ATP, eval=FALSE, echo=12:17} +``` + +Next, we add the Mg+2-complexed ATP species: +```{r ATP, eval=FALSE, echo=21} +``` + +Here is a function to calculate and plot *N*H+ for a given pMg: +```{r ATP, eval=FALSE, echo=22:30} +``` + +With that function in hand, we plot the lines corresponding to pMg = 2 to 6. +This is similar to Figure 1.4 of Alberty (2003): +```{r ATP, eval=FALSE, echo=31:32} +``` + +The next function calculates and plots the average number of Mg+2 bound to ATP (*N*Mg+2) for a given pH. +Here we multiply `alpha` by the number of Mg+2 in each species, and negate log*a*Mg+2 (the variable used in `affinity()`) to get pMg: +```{r ATP, eval=FALSE, echo=36:44} +``` + +Using that function, we plot the lines corresponding to pH = 3 to 9. +This is similar to Figure 1.5 of Alberty (2003): +```{r ATP, eval=FALSE, echo=45:47} +``` + +

+```{r ATP, fig.fullwidth=TRUE, fig.width=10, fig.height=2.5, dpi=ifelse(dpi==50, 50, 100), out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Binding of H+ and Mg+2 to ATP at 100 ?C and *I* = 0 M (first plot) or *I* = 0.25 M (third and fourth plots).", cache=TRUE, pngquant=pngquant, timeit=timeit} +``` +

+ +We have calculated the distribution of ATP species and average binding number of H+ and Mg+2 for given pH, pMg, ionic strength, and temperature. +Accounting for the distribution of chemical species lends itself to thermodynamic models for reactions between reactants that have multiple ionized and complexed states. +In contrast, Alberty (2003) and others propose models for biochemical reactions where the ionized and complexed species are combined into a single representation. +Those models invoke Legendre-transformed thermodynamic properties, such as transformed Gibbs energies that are tabulated for specified pH, pMg, and ionic strength. +Although the conceptual pathways are different, the two approaches lead to equivalent results concerning the energetics of the overall reactions and the conditions for equilibrium [@SVI12]. +The example here shows how the required calculations can be performed at the species level using conventional standard Gibbs energies for species referenced to infinite dilution (zero ionic strength). +The effects of ionic strength are modeled "on the fly" in CHNOSZ by setting the `IS` argument in `subcrt()` or `affinity()` to invoke the nonideality model on top of the standard Gibbs energies of species. + +Now that we're finished, we can reset the nonideality method to the default. +(This really isn't needed here, because there aren't any nonideality calculations below): +```{r oldnon} +nonideal(oldnon) +``` + # Proteins Proteins in CHNOSZ are handled a little bit differently from other species. @@ -1505,161 +1678,10 @@ ```{r bison_transferase, eval=FALSE, echo=12:15} ``` -# Experimental features +# Optimization of chemical activities -Some experimental features in CHNOSZ implement provisional algorithms and/or have not been extensively tested. +**NOTE: This is an experimental feature.** -## Activity coefficients - -`nonideal()` uses the extended Debye--H?ckel equation, described in Chapter 3 of @Alb03, to calculate activity coefficients of charged species. -The calculations can be invoked by setting the `IS` argument in `subcrt()` or `affinity()`. -The activity coefficients are calculated as a function of ionic strength (*I*), temperature, and charge of each species, without any other species-specific parameters. -Due to these assumptions, as well as the limited applicability of the implemented equations to very high *I* and/or *T*, `nonideal()` is presented as an experimental feature. - -For the following examples, we change the nonideality method to `Alberty`: -```{r Alberty} -oldnon <- nonideal("Alberty") -``` - -Let's take a look at calculated activity coefficients at two temperatures and their effect on the standard Gibbs energies of formation (?*G*?*f*) of species with different charge: -```{r subcrt_IS} -subcrt(c("MgATP-2", "MgHATP-", "MgH2ATP"), - T = c(25, 100), IS = c(0, 0.25), property = "G")$out -``` - -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. - -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+ and Mg+2 bound to ATP in solution as a function of pH or pMg (-log*a*Mg+2). - -Use `info()` to see what ATP species are available. -The sources of high-temperature thermodynamic data for these species are two papers by LaRowe and Helgeson [- at LH06a; - at LH06b]. -```{r info_ATP, results="hide"} -info(" ATP") -``` - -The plots for this system in Alberty's book were made for *I* = 0.25 M and *T* = 25 ?C. -As a demonstration of CHNOSZ's capabilities, we can assign a temperature of 100 ?C. -```{r T_100} -T <- 100 -``` - -Use the following commands to set the basis species, add the variously protonated ATP species, calculate the affinities of the formation reactions, equilibrate the system, and make a degree of formation (?) or mole fraction diagram. -This is similar to Figure 1.3 of Alberty (2003), but is calculated for *I* = 0 M and *T* = 100 ?C: -```{marginfigure} -To make the code more readable, commands for plotting titles and legends are not shown. -All of the commands are available in the source of this document. -``` - -```{r ATP, eval=FALSE, echo=2:6} -par(mfrow = c(1, 4), mar = c(3.1, 3.6, 2.1, 1.6), mgp = c(1.8, 0.5, 0)) -basis("MgCHNOPS+") -species(c("ATP-4", "HATP-3", "H2ATP-2", "H3ATP-", "H4ATP")) -a <- affinity(pH = c(3, 9), T = T) -e <- equilibrate(a) -d <- diagram(e, alpha = TRUE, tplot = FALSE) -title(main = describe.property("T", T)) -alphas <- do.call(rbind, d$plotvals) -nH <- alphas * 0:4 -Hlab <- substitute(italic(N)[H^`+`]) -plot(a$vals[[1]], colSums(nH), type = "l", xlab = "pH", ylab=Hlab, lty=2, col=2) -a <- affinity(pH = c(3, 9), IS = 0.25, T = T) -e <- equilibrate(a) -d <- diagram(e, alpha = TRUE, plot.it = FALSE) -alphas <- do.call(rbind, d$plotvals) -nH <- alphas * 0:4 -lines(a$vals[[1]], colSums(nH)) -legend("topright", legend = c("I = 0 M", "I = 0.25 M"), lty = 2:1, col = 2:1, cex = 0.8) -ATP.H <- substitute("ATP and H"^`+`) -title(main = ATP.H) -species(c("MgATP-2", "MgHATP-", "MgH2ATP", "Mg2ATP")) -Hplot <- function(pMg, IS = 0.25) { - basis("Mg+2", -pMg) - a <- affinity(pH = c(3, 9), IS = IS, T = T) - e <- equilibrate(a) - d <- diagram(e, alpha = TRUE, plot.it = FALSE) - alphas <- do.call(rbind, d$plotvals) - NH <- alphas * c(0:4, 0, 1, 2, 0) - lines(a$vals[[1]], colSums(NH), lty = 7 - pMg, col = 7 - pMg) -} -plot(c(3, 9), c(0, 2), type = "n", xlab = "pH", ylab = Hlab) -lapply(2:6, Hplot) -legend("topright", legend = paste("pMg = ", 2:6), lty = 5:1, col = 5:1, cex = 0.8) -ATP.H.Mg <- substitute("ATP and H"^`+`~"and Mg"^`+2`) -title(main = ATP.H.Mg) -Mgplot <- function(pH, IS = 0.25) { - basis("pH", pH) - a <- affinity(`Mg+2` = c(-2, -7), IS = IS, T = T) - e <- equilibrate(a) - d <- diagram(e, alpha = TRUE, plot.it = FALSE) - alphas <- do.call(rbind, d$plotvals) - NMg <- alphas * species()$`Mg+` - lines(-a$vals[[1]], colSums(NMg), lty = 10 - pH, col = 10 - pH) -} -Mglab <- substitute(italic(N)[Mg^`+2`]) -plot(c(2, 7), c(0, 1.2), type = "n", xlab = "pMg", ylab = Mglab) -lapply(3:9, Mgplot) -legend("topright", legend = paste("pH = ", 3:9), lty = 7:1, col = 7:1, cex = 0.8) -title(main = ATP.H.Mg) -``` - -Note that we have saved the numeric results of `diagram()`, i.e. the degrees of formation of the species (?). -With that, we can calculate and plot the average number of protons bound per ATP molecule. -To do so, we use R's `rbind()` and `do.call()` to turn `alpha` into a matrix, then multiply by the number of protons bound to each species, and sum the columns to get the total (i.e. average proton number, *N*H+): -```{r ATP, eval=FALSE, echo=8:11} -``` - -Adding the `IS` argument to `affinity()`, we can now plot *N*H+ at the given ionic strength. -Here we set `plot.it = FALSE` in `diagram()` because we use the computed ? to make our own plot. -This is similar to Figure 1.3 of Alberty (2003), but at higher temperature: -```{r ATP, eval=FALSE, echo=12:17} -``` - -Next, we add the Mg+2-complexed ATP species: -```{r ATP, eval=FALSE, echo=21} -``` - -Here is a function to calculate and plot *N*H+ for a given pMg: -```{r ATP, eval=FALSE, echo=22:30} -``` - -With that function in hand, we plot the lines corresponding to pMg = 2 to 6. -This is similar to Figure 1.4 of Alberty (2003): -```{r ATP, eval=FALSE, echo=31:32} -``` - -The next function calculates and plots the average number of Mg+2 bound to ATP (*N*Mg+2) for a given pH. -Here we multiply `alpha` by the number of Mg+2 in each species, and negate log*a*Mg+2 (the variable used in `affinity()`) to get pMg: -```{r ATP, eval=FALSE, echo=36:44} -``` - -Using that function, we plot the lines corresponding to pH = 3 to 9. -This is similar to Figure 1.5 of Alberty (2003): -```{r ATP, eval=FALSE, echo=45:47} -``` - -

-```{r ATP, fig.fullwidth=TRUE, fig.width=10, fig.height=2.5, dpi=ifelse(dpi==50, 50, 100), out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Binding of H+ and Mg+2 to ATP at 100 ?C and *I* = 0 M (first plot) or *I* = 0.25 M (third and fourth plots).", cache=TRUE, pngquant=pngquant, timeit=timeit} -``` -

- -We have calculated the distribution of ATP species and average binding number of H+ and Mg+2 for given pH, pMg, ionic strength, and temperature. -Accounting for the distribution of chemical species lends itself to thermodynamic models for reactions between reactants that have multiple ionized and complexed states. -In contrast, Alberty (2003) and others propose models for biochemical reactions where the ionized and complexed species are combined into a single representation. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 267 From noreply at r-forge.r-project.org Fri Oct 27 16:49:32 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 27 Oct 2017 16:49:32 +0200 (CEST) Subject: [CHNOSZ-commits] r268 - in pkg/CHNOSZ: . R demo man tests/testthat Message-ID: <20171027144932.D8DEB188CE4@r-forge.r-project.org> Author: jedick Date: 2017-10-27 16:49:32 +0200 (Fri, 27 Oct 2017) New Revision: 268 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/demo/DEW.R pkg/CHNOSZ/man/util.expression.Rd pkg/CHNOSZ/tests/testthat/test-logmolality.R Log: adjust plot labels Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-25 15:50:57 UTC (rev 267) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-27 14:49:32 UTC (rev 268) @@ -1,6 +1,6 @@ -Date: 2017-10-25 +Date: 2017-10-27 Package: CHNOSZ -Version: 1.1.0-66 +Version: 1.1.0-67 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-10-25 15:50:57 UTC (rev 267) +++ pkg/CHNOSZ/R/diagram.R 2017-10-27 14:49:32 UTC (rev 268) @@ -71,10 +71,11 @@ eout$values[[i]] / n.balance[i] }) plotvar <- eout$property - # we change 'A' to 'A/2.303RT' so the axis label is made correctly + # we change 'A' to 'A/(2.303RT)' so the axis label is made correctly + # 20171027 use parentheses to avoid ambiguity about order of operations if(plotvar=="A") { - plotvar <- "A/2.303RT" - message("diagram: plotting A/2.303RT / n.balance (maximum affinity method for 2-D diagrams)") + plotvar <- "A/(2.303RT)" + message("diagram: plotting A/(2.303RT) / n.balance (maximum affinity method for 2-D diagrams)") } else message(paste("diagram: plotting", plotvar, " / n.balance")) } @@ -145,7 +146,7 @@ ## identify predominant species predominant <- NA - if(plotvar %in% c("loga.equil", "alpha", "A/2.303RT")) { + if(plotvar %in% c("loga.equil", "alpha", "A/(2.303RT)")) { pv <- plotvals # some additional steps for affinity values, but not for equilibrated activities if(eout.is.aout) { @@ -274,6 +275,7 @@ # 20120521: use legend.x=NA to label lines rather than make legend if(is.na(legend.x)) { maxvals <- do.call(pmax, pv) + dy <- rep(dy, length.out=length(plotvals)) for(i in 1:length(plotvals)) { # y-values for this line myvals <- as.numeric(plotvals[[i]]) @@ -303,7 +305,7 @@ } } # also include y-offset (dy) and y-adjustment (labels bottom-aligned with the line) - text(xvalues[imax], plotvals[[i]][imax] + dy, labels=names[i], adj=c(thisadj, 0)) + text(xvalues[imax], plotvals[[i]][imax] + dy[i], labels=names[i], adj=c(thisadj, 0), cex=cex.names) } } else legend(x=legend.x, lty=lty, legend=names, col=col, cex=cex.names, lwd=lwd, ...) } Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-10-25 15:50:57 UTC (rev 267) +++ pkg/CHNOSZ/R/util.expression.R 2017-10-27 14:49:32 UTC (rev 268) @@ -99,10 +99,12 @@ # p for subscript italic P (in Cp) # 0 for degree sign (but not immediately following a number e.g. 2.303) # l for subscript small lambda + # ' for prime symbol (like "minute") if(thischar=='D') thisexpr <- substitute(Delta) if(thischar=='p') thisexpr <- substitute(a[italic(P)], list(a="")) if(thischar=='0' & !can.be.numeric(prevchar)) thisexpr <- substitute(degree) if(thischar=='l') thisexpr <- substitute(a[lambda], list(a="")) + if(thischar=="'") thisexpr <- substitute(minute) # put it together expr <- substitute(a*b, list(a=expr, b=thisexpr)) } Modified: pkg/CHNOSZ/demo/DEW.R =================================================================== --- pkg/CHNOSZ/demo/DEW.R 2017-10-25 15:50:57 UTC (rev 267) +++ pkg/CHNOSZ/demo/DEW.R 2017-10-27 14:49:32 UTC (rev 268) @@ -170,7 +170,7 @@ names[c(4, 5, 7, 9)] <- "" col <- rep("black", length(names)) col[c(1, 3, 6, 8, 10)] <- c("red", "darkgreen", "purple", "orange", "navyblue") -diagram(e, alpha = "balance", ylab = "carbon fraction", names = names, col = col, ylim = c(0, 0.8), ylab="carbon fraction") +diagram(e, alpha = "balance", ylab = "carbon fraction", names = names, col = col, ylim = c(0, 0.8)) ## add legend and title ltxt1 <- "P = 50000 bar" Modified: pkg/CHNOSZ/man/util.expression.Rd =================================================================== --- pkg/CHNOSZ/man/util.expression.Rd 2017-10-25 15:50:57 UTC (rev 267) +++ pkg/CHNOSZ/man/util.expression.Rd 2017-10-27 14:49:32 UTC (rev 268) @@ -70,6 +70,7 @@ \samp{p} \tab subscript italic P (for isobaric heat capacity) \cr \samp{0} \tab degree sign (for a standard-state property) \cr \samp{l} \tab subscript lambda \cr + \samp{'} \tab prime symbol \cr } A \samp{0} gets interpreted as a degree sign only if it does not immediately follow a number (so that e.g. \samp{2.303} can be included in an expression). Modified: pkg/CHNOSZ/tests/testthat/test-logmolality.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-logmolality.R 2017-10-25 15:50:57 UTC (rev 267) +++ pkg/CHNOSZ/tests/testthat/test-logmolality.R 2017-10-27 14:49:32 UTC (rev 268) @@ -16,8 +16,7 @@ # we get that loggam(H+)=0 and loggam(HCO3-)=-0.189 expect_equal(nonid[[2]]$loggam, loggam) - ## take-home lesson 0: with default settings, - ## the activity coefficient of H+ is always 1 + ## take-home message -1: with default settings, the activity coefficient of H+ is always 1 # how do activity coefficient affect the value of G? # let's step back and look at the *standard Gibbs energy* at IS = 0 @@ -28,7 +27,7 @@ # by an amount determined by the activity coefficient expect_equal(out1[[2]]$G - out0[[2]]$G, -convert(loggam, "G")) - ## take-home lesson 1.5: setting IS in subcrt() gives apparent standard Gibbs energy + ## take-home message 0: setting IS in subcrt() gives apparent 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) @@ -57,7 +56,7 @@ A1subcrt <- subcrt(c("CO2", "H2O", "H+", "HCO3-"), c(-1, -1, 1, 1), T=25, logact=c(-3, 0, -7, -3), IS=1)$out$A expect_equal(A1subcrt, A1manual) - ## take-home lesson 1: using subcrt with IS not equal to zero, the "logact" + ## take-home message 1: using subcrt with IS not equal to zero, the "logact" ## argument is logmolal in affinity calculations for charged aqueous species # now, calculate the affinities using affinity() @@ -76,7 +75,7 @@ A1affinity <- -convert(a1$values[[2]], "G") expect_equal(A1affinity[[1]], A1subcrt) - ## take-home lesson 2: using affinity() with IS not equal to zero, the "logact" + ## take-home message 2: using affinity() with IS not equal to zero, the "logact" ## set by species() is logmolal in affinity calculations for charged aqueous species # now, swap HCO3- for CO2 in the basis @@ -102,7 +101,7 @@ expect_equal(ACO2_0manual, ACO2_0affinity[[1]]) expect_equal(ACO2_1manual, ACO2_1affinity[[1]]) - ## take-home lesson 3: using affinity() with IS not equal to zero, the "logact" + ## take-home message 3: using affinity() with IS not equal to zero, the "logact" ## set by basis() is logmolal in affinity calculations for charged aqueous species # now look at equilibrate() @@ -119,6 +118,6 @@ Aeq1 <- -convert(logK - logQeq1, "G") # zero! expect_equal(Aeq1[[1]], 0) - ## take-home lesson 4: using affinity() with IS not equal to zero, the "loga.equil" + ## take-home message 4: using affinity() with IS not equal to zero, the "loga.equil" ## returned by equilibrate() is logmolal for speciation calculations with charged aqueous species }) From noreply at r-forge.r-project.org Sun Oct 29 06:49:01 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 29 Oct 2017 06:49:01 +0100 (CET) Subject: [CHNOSZ-commits] r269 - in pkg/CHNOSZ: . R man man/macros Message-ID: <20171029054901.BC0E31890BE@r-forge.r-project.org> Author: jedick Date: 2017-10-29 06:49:00 +0100 (Sun, 29 Oct 2017) New Revision: 269 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/macros/macros.Rd Log: use save.png argument name in examples() and demos() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-27 14:49:32 UTC (rev 268) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-29 05:49:00 UTC (rev 269) @@ -1,6 +1,6 @@ -Date: 2017-10-27 +Date: 2017-10-29 Package: CHNOSZ -Version: 1.1.0-67 +Version: 1.1.0-68 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-10-27 14:49:32 UTC (rev 268) +++ pkg/CHNOSZ/R/examples.R 2017-10-29 05:49:00 UTC (rev 269) @@ -2,7 +2,7 @@ # run examples from the help files, # and a function containing extra examples -examples <- function(do.png=FALSE) { +examples <- function(save.png=FALSE) { # run all the examples in CHNOSZ documentation .ptime <- proc.time() topics <- c("thermo", "examples", @@ -13,37 +13,37 @@ "diagram", "buffer", "nonideal", "add.protein", "protein", "ionize.aa", "yeast.aa", "anim", "objective", "revisit", "EOSregress", "wjd") plot.it <- FALSE - if(is.character(do.png)) - png(paste(do.png,"%d.png",sep=""),width=500,height=500,pointsize=12) - else if(do.png) plot.it <- TRUE + if(is.character(save.png)) + png(paste(save.png,"%d.png",sep=""),width=500,height=500,pointsize=12) + else if(save.png) plot.it <- TRUE for(i in 1:length(topics)) { if(plot.it) png(paste(topics[i],"%d.png",sep=""),width=500,height=500,pointsize=12) myargs <- list(topic=topics[i],ask=FALSE) do.call(example,myargs) if(plot.it) dev.off() } - if(is.character(do.png)) dev.off() + if(is.character(save.png)) dev.off() cat("Time elapsed: ", proc.time() - .ptime, "\n") } demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW", "lambda", "TCA"), to.file=FALSE) { + "adenine", "DEW", "lambda", "TCA"), save.png=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { # say something so the user sees where we are message("------------") - if(which[i]=="dehydration" & !to.file) { - message("demos: skipping dehydration demo as to.file is FALSE") + if(which[i]=="dehydration" & !save.png) { + message("demos: skipping dehydration demo as save.png is FALSE") next } else message(paste("demos: running '", which[i], "'", sep="")) - if(to.file & !which[i]=="dehydration") { + if(save.png & !which[i]=="dehydration") { if(which[i]=="bugstab") png(paste(which[i], "%d.png", sep=""), width=700, height=500, pointsize=12) else png(paste(which[i], "%d.png", sep=""), width=500, height=500, pointsize=12) } out <- demo(which[i], package="CHNOSZ", character.only=TRUE, echo=FALSE, ask=FALSE) - if(to.file & !which[i]=="dehydration") dev.off() + if(save.png & !which[i]=="dehydration") dev.off() } return(invisible(out)) } Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-27 14:49:32 UTC (rev 268) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-29 05:49:00 UTC (rev 269) @@ -7,26 +7,24 @@ Run the examples contained in each of the documentation topics. } \arguments{ - \item{do.png}{logical, generate PNG files for the plots?} + \item{save.png}{logical, generate PNG image files for the plots?} \item{which}{character, which example to run} - \item{to.file}{logical, generate image files for the plots?} } \usage{ - examples(do.png = FALSE) + examples(save.png = FALSE) demos(which = c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", "adenine", "DEW", "lambda", "TCA"), - to.file=FALSE) + save.png=FALSE) } \details{ \code{examples} runs all the examples in the documentation for the package. \code{\link{example}} is called for each topic with \code{ask} set to \code{FALSE} (so all of the figures are shown without prompting the user). -If \code{do.png} is TRUE, the plots in the examples are saved as \code{\link{png}} files having names beginning with the name of each of the help topics. \code{demos} is a function to run other examples that are provided as \code{\link{demo}s}. \code{\link{demo}} is called with settings to not echo the source code and to not ask before making each plot. @@ -46,7 +44,7 @@ \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \cr \code{buffer} \tab * Minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr \code{protbuff} \tab Chemical activities buffered by thiol peroxidases or sigma factors \cr - \code{yeastgfp} \tab * Subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams (Dick, 2009) \cr + \code{yeastgfp} \tab * Subcellular locations: \logfO2 - \logaH2O and \loga - \logfO2 diagrams (Dick, 2009) \cr \code{mosaic} \tab * Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr \code{copper} \tab * Another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr \code{solubility} \tab * Solubility of calcite (cf. Manning et al., 2013) or \CO2 (cf. Stumm and Morgan, 1996) \cr @@ -62,6 +60,8 @@ \code{go-IU} \tab * Diagrams using thermodynamic data in the SUPCRTBL compilation (Zimmer et al., 2016) \cr } +For either function, if \code{save.png} is TRUE, the plots are saved in \code{\link{png}} files whose names begin with the names of the help topics or demos. + } \references{ Modified: pkg/CHNOSZ/man/macros/macros.Rd =================================================================== --- pkg/CHNOSZ/man/macros/macros.Rd 2017-10-27 14:49:32 UTC (rev 268) +++ pkg/CHNOSZ/man/macros/macros.Rd 2017-10-29 05:49:00 UTC (rev 269) @@ -25,6 +25,7 @@ \newcommand{\logfO2}{\ifelse{latex}{\eqn{\log f_{\mathrm{O_{2}}}}}{\ifelse{html}{\out{logfO2}}{logfO2}}} \newcommand{\logfH2}{\ifelse{latex}{\eqn{\log f_{\mathrm{H_{2}}}}}{\ifelse{html}{\out{logfH2}}{logfH2}}} \newcommand{\logaH2O}{\ifelse{latex}{\eqn{\log a_{\mathrm{H_{2}O}}}}{\ifelse{html}{\out{logaH2O}}{logaH2O}}} +\newcommand{\loga}{\ifelse{latex}{\eqn{\log a}}{\ifelse{html}{\out{loga}}{log a}}} \newcommand{\ZC}{\ifelse{latex}{\eqn{Z_\mathrm{C}}}{\ifelse{html}{\out{ZC}}{ZC}}} % use \nH2O{̄} to call this macro (the html code can't be defined in the macro, % which interprets '#' followed by a number as a placeholder for an argument) From noreply at r-forge.r-project.org Mon Oct 30 04:40:14 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 30 Oct 2017 04:40:14 +0100 (CET) Subject: [CHNOSZ-commits] r270 - in pkg/CHNOSZ: . R demo inst man man/macros vignettes Message-ID: <20171030034014.8A9A8188604@r-forge.r-project.org> Author: jedick Date: 2017-10-30 04:40:13 +0100 (Mon, 30 Oct 2017) New Revision: 270 Added: pkg/CHNOSZ/demo/carboxylase.R Removed: pkg/CHNOSZ/R/anim.R pkg/CHNOSZ/man/anim.Rd Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/macros/macros.Rd pkg/CHNOSZ/man/util.array.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: remove anim.TCA(); move anim.carboxylase() to demo/carboxylase.R Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-30 03:40:13 UTC (rev 270) @@ -1,6 +1,6 @@ -Date: 2017-10-29 +Date: 2017-10-30 Package: CHNOSZ -Version: 1.1.0-68 +Version: 1.1.0-69 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/NAMESPACE 2017-10-30 03:40:13 UTC (rev 270) @@ -31,7 +31,6 @@ "protein.obigt", "hkf", "cgl", "which.pmax", "equil.boltzmann", "equil.reaction", "find.tp", "ionize.aa", "MP90.cp", "aasum", - "anim.carboxylase", "qqr", "RMSD", "CVRMSD", "spearman", "DGmix", "DDGmix", "DGtr", "ratlab", "EOSregress", "EOScoeffs", "EOSplot", "EOSvar", @@ -55,7 +54,7 @@ "EOSlab", "EOScalc", "basis.elements", "element.mu", "ibasis", "water.SUPCRT92", "eqdata", "plot_findit", - "nonideal", "anim.TCA", "uniprot.aa", "run.guess", + "nonideal", "uniprot.aa", "run.guess", # added 20170301 or later "GHS_Tr", "calculateDensity", "calculateGibbsOfWater", "calculateEpsilon", "calculateQ", "water.DEW", "berman", Deleted: pkg/CHNOSZ/R/anim.R =================================================================== --- pkg/CHNOSZ/R/anim.R 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/R/anim.R 2017-10-30 03:40:13 UTC (rev 270) @@ -1,202 +0,0 @@ -# CHNOSZ/anim.R -# functions to make various animations - -anim.TCA <- function(redox=list(O2=c(-95,-60)),high.T=FALSE, - nframes=100,pHlim=c(0,10),width = 420, height = 320) { - # tricarboxylic acids 20100701, 20110204 jmd - # we depend on an empty png directory - if(!"png" %in% dir()) stop("directory 'png' not present") - else if(length(dir("png")) > 0) stop("directory 'png' not empty") - # expand default logfO2 range if we're at high temperature - if(high.T & missing(redox)) redox <- list(O2=c(-100,-40)) - # the name of 'redox' should be either O2 or H2 - basis(c("CO2","H2O",names(redox),"H+")) - # load the species in order of increasing degree of ionization - species(c("pyruvic acid","oxaloacetic acid","malic acid", # Z = 0 - "fumaric acid","a-ketoglutaric acid","citric acid", - "pyruvate","H-oxaloacetate","H-malate","H-fumarate", # Z = -1 - "H-a-ketoglutarate","H2-citrate", - "oxaloacetate-2","malate-2","fumarate-2", # Z = -2 - "a-ketoglutarate-2","H-citrate-2", - "citrate-3"),rep("aq",18)) # Z = -3 - # start the plot device - multiple png figures - png(filename="png/Rplot%04d.png",width=width,height=height) - par(mar=c(3,3.5,1.5,1),mgp=c(1.9,1,0)) - # leadin/out frames - # the variable(s) that change with each frame - pH <- seq(pHlim[1],pHlim[2],length.out=nframes) - pHres <- length(pH) - pHlim <- range(pH) - baseres <- 128 - # calculate the affinity - redox[[1]] <- c(redox[[1]],baseres) - affargs <- c(redox,list(H2O=c(-10,10,baseres),pH=c(pHlim,pHres))) - a.cold <- do.call(affinity,affargs) - if(high.T) { - affargs <- c(affargs,list(T=100)) - a.hot <- do.call(affinity,affargs) - } - # put the movie together - nframes.in <- 15 - nframes.out <- 20 - iframes <- c(rep(1,nframes.in),1:length(pH),rep(pHres,nframes.out)) - for(i in 1:length(iframes)) { - print(paste("frame",i,"of",length(iframes),"at pH",pH[iframes[i]])) - # don't fill fields with heat colors if we're doing a high-T overlay - if(high.T) color <- "lightgrey" else color <- "heat" - # take a single O2-H2O slice along pH - diagram(slice.affinity(a.cold,3,iframes[i]),fill=color,cex=1.5) - ltext <- substitute(paste(italic(T)==x~degree*C),list(x=25)) - lcol <- "black" - # overlay the high-T diagram - if(high.T) { - ltext <- c(ltext,substitute(paste(italic(T)==x~degree*C),list(x=100))) - lcol <- c(lcol,"red") - diagram(slice.affinity(a.hot,3,iframes[i]),add=TRUE,col="red",cex=1.5) - } - if(high.T) legend("topleft",legend=as.expression(ltext),lty=1,col=lcol) - title(main=paste("TCA cycle reactants; pH =", - format(round(pH[iframes[i]],2))),cex.main=1) - } - # close the plot device - convert to movie - dev.off() - cat("anim.TCA: converting to animated GIF...\n") - outfile <- "TCA.gif" - # convert tool from imagemagick.org; -loop 0 for infinite loop - syscmd <- paste("convert -loop 0 -delay 10 png/*.png png/",outfile,sep="") - cat(paste(syscmd,"\n")) - # we need shell() on windows for the paths to include ImageMagick - if(.Platform$OS.type=="unix") sres <- system(syscmd) - else sres <- shell(syscmd) - if(sres==0) cat(paste("anim.TCA: animation is at png/",outfile,"\n",sep="")) - else { - cat("anim.TCA: error converting to animated GIF\n") - cat("anim.TCA: check that 'convert' tool from ImageMagick is in your PATH\n") - } -} - -anim.carboxylase <- function(T=25:125,ntop=5,lcex=0.8,width=420,height=320) { - # animate rank-activity diagrams over a temperature - # and logaH2 gradient, or plot a single one for a single temperature - # plot rank-activity diagrams for 24 carboxylases; - # 12 ribulose phosphate carboxylase - # 12 acetyl-coenzyme A carboxylase - # 6 of each type are nominally from mesophilic organisms - # and 6 from thermophilic organisms - # arranged here in order of increasing growth temperature - rubisco <- c("RBL_BRAJA","A6YF84_9PROT","A1E8R4_9CHLO","A8C9T6_9MYCO","A3EQE1_9BACT","A5CKC7_9CHRO", - "RBL_SYNJA","Q6JAI0_9RHOD","RBL_METJA","A3DND9_STAMF","A1RZJ5_THEPD","RBL_PYRHO") - rubisco.organisms <- c("a-proteobacterium-R","b-proteobacterium","Bracteacoccus","Mycobacterium", - "Leptospirillum","Cyanobium","Synechococcus","Cyanidiales", - "Methanococcus-R","Desulfurococcus","Thermofilum","Pyrococcus") - accoaco <- c("Q9F7M8_PRB01","ACCA_DEIRA","A6CDM2_9PLAN","A4AGS7_9ACTN","ACCA_CAUCR","A1VC70_DESVV", - "A6VIX9_METM7","Q2JSS7_SYNJA","A0GZU2_9CHLR","A7WGI1_9AQUI","Q05KD0_HYDTH","ACCA_AQUAE") - accoaco.organisms <- c("g-proteobacterium","Deinococcus","Planctomyces","Actinobacterium", - "a-proteobacterium-A","d-proteobacterium","Methanococcus-A","Synechococcus", - "Chloroflexus","Hydrogenobaculum","Hydrogenobacter","Aquifex") - # assemble them all - organisms <- c(rubisco.organisms,accoaco.organisms) - # new scheme 20090611: red for hot, blue for cold - # open for rubisco, filled for accoaco - col <- rep(c(rep("blue",6),rep("red",6)),2) - pch <- c(rep(c(0:2,5:7),2),rep(c(15:20),2)) - # how many frames do we want? - res <- length(T) - if(res==1) ido <- 1 - else { - # check for png directory - if(!"png" %in% dir()) stop("directory 'png' not present") - else if(length(dir("png")) > 0) stop("directory 'png' not empty") - # start the plot device - multiple png figures - png(filename="png/Rplot%04d.png",width=width,height=height) - # add counters for lead-in and lead-out frames - ido <- c(rep(1,15),1:res,rep(res,20)) - } - # set up system - basis(c("CO2","H2O","NH3","H2","H2S","H+"), - c("aq","liq","aq","aq","aq","aq"),c(-3,0,-4,-6,-7,-7)) - species(c(rubisco,accoaco)) - # equation for logaH2 as a function of temperature - # from Dick and Shock, 2011 - # http://dx.plos.org/10.1371/journal.pone.0022782 - get.logaH2 <- function(T) return(-11+T*3/40) - H2 <- get.logaH2(T) - # calculate affinities - if(res==1) { - basis("H2",H2) - a <- affinity(T=T) - } else a <- affinity(T=T,H2=H2) - # calculate activities - e <- equilibrate(a, normalize=TRUE) - # for each point make a rank plot - rank <- 1:length(e$loga.equil) - for(i in 1:length(ido)) { - # print some progress - if(i%%20 == 0) cat("\n") else cat(".") - # keep track of positions of previous points - loga <- numeric() - for(j in 1:length(e$loga.equil)) loga <- c(loga, e$loga.equil[[j]][ido[i]]) - if(i > 4) myrank4 <- myrank3 - if(i > 3) myrank3 <- myrank2 - if(i > 2) myrank2 <- myrank1 - if(i > 1) myrank1 <- myrank - order <- order(loga,decreasing=TRUE) - myrank <- rank(loga) - cex <- rep(1.2,24) - # show changes by increasing point size - # any points that changed on the step before the step - # before the step before? - if(i > 4) { - ichanged <- myrank3 != myrank4 - cex[ichanged[order]] <- cex[ichanged[order]] + 0.1 - } - # any points that changed on the step before the step before? - if(i > 3) { - ichanged <- myrank2 != myrank3 - cex[ichanged[order]] <- cex[ichanged[order]] + 0.2 - } - # any points that changed on the step before? - if(i > 2) { - ichanged <- myrank1 != myrank2 - cex[ichanged[order]] <- cex[ichanged[order]] + 0.3 - } - # any points that changed on this step? - if(i > 1) { - ichanged <- myrank != myrank1 - cex[ichanged[order]] <- cex[ichanged[order]] + 0.4 - } - plot(rank,loga[order],col=col[order],pch=pch[order], - ylab=expression(log~italic(a)),cex=cex,cex.main=1,cex.lab=1,cex.axis=1) - myT <- format(round(T,1))[ido[i]] - myH2 <- format(round(H2,2))[ido[i]] - title(main=substitute(list(X~degree*C, log*italic(a)[paste(H2)]==Y), - list(X=myT,Y=myH2))) - # legends showing highest and lowest few - legend("topright",legend=c(paste("top",ntop),organisms[order[1:ntop]]), - pch=c(NA,pch[order[1:ntop]]),col=c(NA,col[order[1:ntop]]), - pt.cex=c(NA,cex[1:ntop]),cex=lcex) - order <- order(loga) - legend("bottomleft",legend=c(paste("low",ntop),organisms[order[ntop:1]]), - pch=c(NA,pch[order[ntop:1]]),col=c(NA,col[order[ntop:1]]), - pt.cex=c(NA,cex[24:(24-ntop+1)]),cex=lcex) - } - # finish up animation stuff - if(res > 1) { - # finish progress report - cat("\n") - # close PNG plot device - dev.off() - # make animated GIF using ImageMagick - cat("anim.carboxylase: converting to animated GIF...\n") - outfile <- "carboxylase.gif" - syscmd <- paste("convert -loop 0 -delay 10 png/*.png png/", outfile, sep = "") - cat(paste(syscmd,"\n")) - if(.Platform$OS.type=="unix") sres <- system(syscmd) - else sres <- shell(syscmd) - if(sres==0) cat(paste("anim.carboxylase: animation is at png/",outfile,"\n",sep="")) - else { - cat("anim.carboxylase: error converting to animated GIF\n") - cat("anim.carboxylase: check that 'convert' tool from ImageMagick is in your PATH\n") - } - } -} Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/R/examples.R 2017-10-30 03:40:13 UTC (rev 270) @@ -11,7 +11,7 @@ "util.water", "taxonomy", "info", "protein.info", "hkf", "water", "IAPWS95", "subcrt", "makeup", "basis", "swap.basis", "species", "affinity", "equil.boltzmann", "diagram", "buffer", "nonideal", "add.protein", "protein", "ionize.aa", "yeast.aa", - "anim", "objective", "revisit", "EOSregress", "wjd") + "objective", "revisit", "EOSregress", "wjd") plot.it <- FALSE if(is.character(save.png)) png(paste(save.png,"%d.png",sep=""),width=500,height=500,pointsize=12) @@ -28,8 +28,8 @@ demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", - "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW", "lambda", "TCA"), save.png=FALSE) { + "copper", "solubility", "wjd", "bugstab", "Shh", "activity_ratios", + "adenine", "DEW", "lambda", "TCA", "go-IU"), save.png=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { # say something so the user sees where we are Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/demo/00Index 2017-10-30 03:40:13 UTC (rev 270) @@ -23,3 +23,4 @@ lambda Thermodynamic properties of lambda transition in quartz TCA Standard Gibbs energies of steps of the citric acid cycle go-IU Diagrams using thermodynamic data in the SUPCRTBL compilation +carboxylase Rank abundance distribution for RuBisCO and acetyl-CoA carboxylase Added: pkg/CHNOSZ/demo/carboxylase.R =================================================================== --- pkg/CHNOSZ/demo/carboxylase.R (rev 0) +++ pkg/CHNOSZ/demo/carboxylase.R 2017-10-30 03:40:13 UTC (rev 270) @@ -0,0 +1,129 @@ +# CHNOSZ/demo/carboxylase.R +# animate rank-activity diagrams over a temperature +# and logaH2 gradient, or plot a single one for a single temperature +# first version ca. 200903; packaged anim.carboxylase() 20110818; converted to demo 20171030 +T <- 25:125 +ntop <- 5 +lcex <- 0.8 +width <- 380 +height <- 380 +# plot rank-activity diagrams for 24 carboxylases; +# 12 ribulose phosphate carboxylase +# 12 acetyl-coenzyme A carboxylase +# 6 of each type are nominally from mesophilic organisms +# and 6 from thermophilic organisms +# arranged here in order of increasing growth temperature +rubisco <- c("RBL_BRAJA","A6YF84_9PROT","A1E8R4_9CHLO","A8C9T6_9MYCO","A3EQE1_9BACT","A5CKC7_9CHRO", + "RBL_SYNJA","Q6JAI0_9RHOD","RBL_METJA","A3DND9_STAMF","A1RZJ5_THEPD","RBL_PYRHO") +rubisco.organisms <- c("a-proteobacterium-R","b-proteobacterium","Bracteacoccus","Mycobacterium", + "Leptospirillum","Cyanobium","Synechococcus","Cyanidiales", + "Methanococcus-R","Desulfurococcus","Thermofilum","Pyrococcus") +accoaco <- c("Q9F7M8_PRB01","ACCA_DEIRA","A6CDM2_9PLAN","A4AGS7_9ACTN","ACCA_CAUCR","A1VC70_DESVV", + "A6VIX9_METM7","Q2JSS7_SYNJA","A0GZU2_9CHLR","A7WGI1_9AQUI","Q05KD0_HYDTH","ACCA_AQUAE") +accoaco.organisms <- c("g-proteobacterium","Deinococcus","Planctomyces","Actinobacterium", + "a-proteobacterium-A","d-proteobacterium","Methanococcus-A","Synechococcus", + "Chloroflexus","Hydrogenobaculum","Hydrogenobacter","Aquifex") +# assemble them all +organisms <- c(rubisco.organisms,accoaco.organisms) +# new scheme 20090611: red for hot, blue for cold +# open for rubisco, filled for accoaco +col <- rep(c(rep("blue",6),rep("red",6)),2) +pch <- c(rep(c(0:2,5:7),2),rep(c(15:20),2)) +# how many frames do we want? +res <- length(T) +if(res==1) ido <- 1 else { + # check for png directory + if(!"png" %in% dir()) stop("directory 'png' not present") + else if(length(dir("png")) > 0) stop("directory 'png' not empty") + # start the plot device - multiple png figures + png(filename="png/Rplot%04d.png",width=width,height=height) + # add counters for lead-in and lead-out frames + ido <- c(rep(1,15),1:res,rep(res,20)) +} +# set up system +basis(c("CO2","H2O","NH3","H2","H2S","H+"), + c("aq","liq","aq","aq","aq","aq"),c(-3,0,-4,-6,-7,-7)) +species(c(rubisco,accoaco)) +# equation for logaH2 as a function of temperature +# from Dick and Shock, 2011 +# http://dx.plos.org/10.1371/journal.pone.0022782 +get.logaH2 <- function(T) return(-11+T*3/40) +H2 <- get.logaH2(T) +# calculate affinities +if(res==1) { + basis("H2",H2) + a <- affinity(T=T) +} else a <- affinity(T=T,H2=H2) +# calculate activities +e <- equilibrate(a, normalize=TRUE) +# for each point make a rank plot +rank <- 1:length(e$loga.equil) +for(i in 1:length(ido)) { + # print some progress + if(i%%20 == 0) cat("\n") else cat(".") + # keep track of positions of previous points + loga <- numeric() + for(j in 1:length(e$loga.equil)) loga <- c(loga, e$loga.equil[[j]][ido[i]]) + if(i > 4) myrank4 <- myrank3 + if(i > 3) myrank3 <- myrank2 + if(i > 2) myrank2 <- myrank1 + if(i > 1) myrank1 <- myrank + order <- order(loga,decreasing=TRUE) + myrank <- rank(loga) + cex <- rep(1.2,24) + # show changes by increasing point size + # any points that changed on the step before the step + # before the step before? + if(i > 4) { + ichanged <- myrank3 != myrank4 + cex[ichanged[order]] <- cex[ichanged[order]] + 0.1 + } + # any points that changed on the step before the step before? + if(i > 3) { + ichanged <- myrank2 != myrank3 + cex[ichanged[order]] <- cex[ichanged[order]] + 0.2 + } + # any points that changed on the step before? + if(i > 2) { + ichanged <- myrank1 != myrank2 + cex[ichanged[order]] <- cex[ichanged[order]] + 0.3 + } + # any points that changed on this step? + if(i > 1) { + ichanged <- myrank != myrank1 + cex[ichanged[order]] <- cex[ichanged[order]] + 0.4 + } + plot(rank,loga[order],col=col[order],pch=pch[order], + ylab=expression(log~italic(a)),cex=cex,cex.main=1,cex.lab=1,cex.axis=1) + myT <- format(round(T,1))[ido[i]] + myH2 <- format(round(H2,2))[ido[i]] + title(main=substitute(list(X~degree*C, log*italic(a)[paste(H2)]==Y), + list(X=myT,Y=myH2))) + # legends showing highest and lowest few + legend("topright",legend=c(paste("top",ntop),organisms[order[1:ntop]]), + pch=c(NA,pch[order[1:ntop]]),col=c(NA,col[order[1:ntop]]), + pt.cex=c(NA,cex[1:ntop]),cex=lcex) + order <- order(loga) + legend("bottomleft",legend=c(paste("low",ntop),organisms[order[ntop:1]]), + pch=c(NA,pch[order[ntop:1]]),col=c(NA,col[order[ntop:1]]), + pt.cex=c(NA,cex[24:(24-ntop+1)]),cex=lcex) +} +# finish up animation stuff +if(res > 1) { + # finish progress report + cat("\n") + # close PNG plot device + dev.off() + # make animated GIF using ImageMagick + cat("anim.carboxylase: converting to animated GIF...\n") + outfile <- "carboxylase.gif" + syscmd <- paste("convert -loop 0 -delay 10 png/*.png png/", outfile, sep = "") + cat(paste(syscmd,"\n")) + if(.Platform$OS.type=="unix") sres <- system(syscmd) + else sres <- shell(syscmd) + if(sres==0) cat(paste("anim.carboxylase: animation is at png/",outfile,"\n",sep="")) + else { + cat("anim.carboxylase: error converting to animated GIF\n") + cat("anim.carboxylase: check that 'convert' tool from ImageMagick is in your PATH\n") + } +} Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/inst/NEWS 2017-10-30 03:40:13 UTC (rev 270) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-66 (2017-10-25) +CHANGES IN CHNOSZ 1.1.0-69 (2017-10-30) --------------------------------------- MAJOR CHANGES: @@ -173,6 +173,9 @@ workflow, Thermodynamic data, Thermodynamic calculations, Water properties, Protein properties, Other tools, Utility functions. +- Remove anim.TCA() and anim.carboxylase(); move the latter code to + demo/carboxylase.R. + CHANGES IN CHNOSZ 1.1.0 (2017-05-04) ------------------------------------ Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-10-30 03:40:13 UTC (rev 270) @@ -14,7 +14,7 @@ Each help page (other than this one) has been given one of the following \dQuote{concept index entries}: \itemize{ \item Main workflow: \code{\link{info}}, \code{\link{subcrt}}, \code{\link{basis}}, \code{\link{species}}, \code{\link{affinity}}, \code{\link{equilibrate}}, \code{\link{diagram}} - \item Extended workflow: \code{\link{swap.basis}}, \code{\link{buffer}}, \code{\link{mosaic}}, \code{\link{objective}}, \code{\link{revisit}}, \code{\link{findit}}, \code{\link{anim}}, \code{\link{EOSregress}}, \code{\link{wjd}} + \item Extended workflow: \code{\link{swap.basis}}, \code{\link{buffer}}, \code{\link{mosaic}}, \code{\link{objective}}, \code{\link{revisit}}, \code{\link{findit}}, \code{\link{EOSregress}}, \code{\link{wjd}} \item Thermodynamic data: \code{\link{data}}, \code{\link{extdata}}, \code{\link{add.obigt}}, \code{\link{util.data}} \item Thermodynamic calculations: \code{\link{util.formula}}, \code{\link{makeup}}, \code{\link{util.units}}, \code{\link{eos}}, \code{\link{berman}}, \code{\link{nonideal}}, \code{\link{util.misc}} \item Water properties: \code{\link{water}}, \code{\link{util.water}}, \code{\link{DEW}}, \code{\link{IAPWS95}} Deleted: pkg/CHNOSZ/man/anim.Rd =================================================================== --- pkg/CHNOSZ/man/anim.Rd 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/man/anim.Rd 2017-10-30 03:40:13 UTC (rev 270) @@ -1,63 +0,0 @@ -\encoding{UTF-8} -\name{anim.TCA} -\alias{anim} -\alias{anim.TCA} -\alias{anim.carboxylase} -\title{Functions to Make Animations} -\description{ - Make animated stability diagrams by creating a series of PNG files. -} - -\usage{ - anim.TCA(redox = list(O2 = c(-95, -60)), high.T = FALSE, - nframes = 100, pHlim = c(0,10), width = 420, height = 320) - anim.carboxylase(T = 25:125, ntop = 5, lcex = 0.8, width = 420, height = 320) -} - -\arguments{ - \item{redox}{list, redox variable and limits} - \item{high.T}{logical, overlay high-temperature diagram?} - \item{nframes}{numeric, number of frames to be animated} - \item{pHlim}{numeric, pH limits to use for animation} - \item{width}{numeric, width of plot device} - \item{height}{numeric, height of plot device} - \item{T}{numeric, temperature range for animation} - \item{ntop}{numeric, number of names to show in legend} - \item{lcex}{numeric, character expansion factor for legend} -} - -\details{ -These functions create a series of PNG figures that can be converted into an animated diagram. -The PNG files are created in the \samp{png} directory within the current working directory; the functions stop with an error if either this directory is not present or it is present but not empty. -After making the PNG files, they are converted to an animated GIF using the \samp{convert} tool from the ImageMagick software distribution (\url{http://www.imagemagick.org}), if it is available on the system. -The system command is called using \code{\link{system}}, or \code{shell} on Windows platforms. -When installing ImageMagick on Windows, be sure to leave the \sQuote{Add application directory to your system path} option checked; this will make the \samp{convert} command from ImageMagick available in the shell. - -To ensure the calculations are performed as intended, each function first removes any existing system definition by calling \code{data(thermo)}. - -\code{anim.TCA} creates a series of figures showing how a logaH2O - logfO2 activity diagram for various species involved in the tricarboxylic acid (TCA) cycle changes as a function of pH. -Alternatively, set \code{redox} to \code{list(H2=c(-20,0))} to draw a logaH2O - logaH2 diagram. -The diagrams are made at 25 \degC unless \code{high.T} is TRUE, in which case high-temperature (100 \degC) stability fields are overlaid. - -\code{anim.carboxylase} animates equilibrium rank-activity diagrams along a combined temperature and logaH2 gradient, or makes a single plot on the default device (without conversion to animated GIF) if a single \code{temperature} is provided. -The proteins in the calculation are 24 carboxylases from a variety of organisms. -There are 12 ribulose phosphate carboxylase and 12 acetyl-coenzyme A carboxylase; 6 of each type are from nominally mesophilic organisms and 6 from nominally thermophilic organisms, shown as blue and red symbols on the diagrams. -The activities of hydrogen at each temperature are calculated using \eqn{\log a_{\mathrm{H_{2}}_{\left(aq\right)}}=-11+3/\left(40\times T\left(^{\circ}C\right)\right)}{logaH2 = -11 + 3/40 * T(degC)}; this equation comes from a model of relative stabilities of proteins in a hot-spring environment (Dick and Shock, 2011). -} - -\examples{\dontshow{data(thermo)} -\dontrun{ -# animate a stability diagram with a high-temperature overlay -anim.TCA(high.T=TRUE) -# using H2 instead of O2 -anim.TCA(list(H2=c(-20,0))) } - -# using anim.carboxylase in non-animation mode -anim.carboxylase(T=100) -} - -\references{ -Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{https://doi.org/10.1371/journal.pone.0022782} -} - -\concept{Extended workflow} Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-30 03:40:13 UTC (rev 270) @@ -16,8 +16,8 @@ demos(which = c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", - "wjd", "dehydration", "bugstab", "Shh", "activity_ratios", - "adenine", "DEW", "lambda", "TCA"), + "wjd", "bugstab", "Shh", "activity_ratios", "adenine", + "DEW", "lambda", "TCA", "go-IU"), save.png=FALSE) } @@ -58,10 +58,20 @@ \code{lambda} \tab * Effects of lambda transition on thermodynamic properties of quartz (Berman, 1988) \cr \code{TCA} \tab * Standard Gibbs energies of the tricarboxylic (citric) acid cycle (Canovas and Shock, 2016) \cr \code{go-IU} \tab * Diagrams using thermodynamic data in the SUPCRTBL compilation (Zimmer et al., 2016) \cr + \code{carboxylase} \tab * Rank abundance distribution for RuBisCO and acetyl-CoA carboxylase \cr } For either function, if \code{save.png} is TRUE, the plots are saved in \code{\link{png}} files whose names begin with the names of the help topics or demos. +Two of the demos have external dependencies and are not automatically run by \code{demos}. +\samp{dehydration} creates an interactive SVG file; this demo depends on the \pkg{RSVGTipsDevice}, which is not available for Windows +\samp{carboxylase} creates an animated GIF; this demo requires that the ImageMagick \code{convert} commmand be available on the system (tested on Linux and Windows). + +\samp{carboxylase} animates diagrams showing rankings of calculated chemical activities along a combined \T and \logaH2 gradient, or makes a single plot on the default device (without conversion to animated GIF) if a single temperature (\code{T}) is specified in the code. +To run this demo, an empty directory named \samp{png} must be present (as a subdirectory of the R working directory). +The proteins in the calculation are 24 carboxylases from a variety of organisms. +There are 12 ribulose phosphate carboxylase and 12 acetyl-coenzyme A carboxylase; 6 of each type are from nominally mesophilic organisms and 6 from nominally thermophilic organisms, shown as blue and red symbols on the diagrams. +The activities of hydrogen at each temperature are calculated using \eqn{\log a_{\mathrm{H_{2}}_{\left(aq\right)}}=-11+3/\left(40\times T\left(^{\circ}C\right)\right)}{logaH2 = -11 + 3/40 * T(degC)}; this equation comes from a model of relative stabilities of proteins in a hot-spring environment (Dick and Shock, 2011). } \references{ Modified: pkg/CHNOSZ/man/macros/macros.Rd =================================================================== --- pkg/CHNOSZ/man/macros/macros.Rd 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/man/macros/macros.Rd 2017-10-30 03:40:13 UTC (rev 270) @@ -24,6 +24,7 @@ \newcommand{\logK}{\ifelse{latex}{\eqn{\log K}}{\ifelse{html}{\out{logK}}{log K}}} \newcommand{\logfO2}{\ifelse{latex}{\eqn{\log f_{\mathrm{O_{2}}}}}{\ifelse{html}{\out{logfO2}}{logfO2}}} \newcommand{\logfH2}{\ifelse{latex}{\eqn{\log f_{\mathrm{H_{2}}}}}{\ifelse{html}{\out{logfH2}}{logfH2}}} +\newcommand{\logaH2}{\ifelse{latex}{\eqn{\log a_{\mathrm{H_{2}}}}}{\ifelse{html}{\out{logaH2}}{logaH2}}} \newcommand{\logaH2O}{\ifelse{latex}{\eqn{\log a_{\mathrm{H_{2}O}}}}{\ifelse{html}{\out{logaH2O}}{logaH2O}}} \newcommand{\loga}{\ifelse{latex}{\eqn{\log a}}{\ifelse{html}{\out{loga}}{log a}}} \newcommand{\ZC}{\ifelse{latex}{\eqn{Z_\mathrm{C}}}{\ifelse{html}{\out{ZC}}{ZC}}} Modified: pkg/CHNOSZ/man/util.array.Rd =================================================================== --- pkg/CHNOSZ/man/util.array.Rd 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/man/util.array.Rd 2017-10-30 03:40:13 UTC (rev 270) @@ -31,7 +31,7 @@ \code{slice} extracts or assigns values from/to the \code{i}th slice(s) in the \code{d}th dimension of an array. Values are assigned to an array if \code{value} is not NULL. This function works by building an expression containing the extraction operator (\code{\link{[}}). - \code{slice.affinity} performs a slice operation on the \samp{values} element of the \samp{affinity} variable (which should be the output of \code{\link{affinity}}). This function is used e.g. by \code{\link{anim.TCA}} to extract slices that are the used to make frames of an animated stability diagram. + \code{slice.affinity} performs a slice operation on the \samp{values} element of the \samp{affinity} variable (which should be the output of \code{\link{affinity}}). \code{dimSums} sums an array along the \code{d}th dimension using only the \code{i}th slices in that dimension. If \code{i} is NULL, all slices in that dimension are summed together. For matrices, \code{dimSums(x,1)} has the same result as \code{\link{colSums}(x)} and \code{dimSums(x,2)} has the same result as \code{\link{rowSums}(x)}. } Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-29 05:49:00 UTC (rev 269) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-30 03:40:13 UTC (rev 270) @@ -2047,11 +2047,6 @@ `wjd()` implements a Gibbs energy minimization using the method of steepest descent described by @WJD58. See `?wjd` as well as the vignette, [*Winding journey down (in Gibbs energy)*](wjd.pdf). -## Animations - -A few functions have been written (see `?anim`) to make GIF animations of chemical activity diagrams from a series of PNG files. -The functions require the `convert` system command from [ImageMagick](http://www.imagemagick.org). - ## Group additivity and EQ3/6 output `RH2obigt()` implements a group additivity calculation of standard molal thermodynamic properties and equations of state parameters of crystalline and liquid organic molecules from @RH98. From noreply at r-forge.r-project.org Mon Oct 30 14:06:24 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 30 Oct 2017 14:06:24 +0100 (CET) Subject: [CHNOSZ-commits] r271 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20171030130625.046D3189286@r-forge.r-project.org> Author: jedick Date: 2017-10-30 14:06:24 +0100 (Mon, 30 Oct 2017) New Revision: 271 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: add "The basics" Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-30 03:40:13 UTC (rev 270) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-30 13:06:24 UTC (rev 271) @@ -1,6 +1,6 @@ Date: 2017-10-30 Package: CHNOSZ -Version: 1.1.0-69 +Version: 1.1.0-70 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-10-30 03:40:13 UTC (rev 270) +++ pkg/CHNOSZ/inst/NEWS 2017-10-30 13:06:24 UTC (rev 271) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.0-69 (2017-10-30) +CHANGES IN CHNOSZ 1.1.0-70 (2017-10-30) --------------------------------------- MAJOR CHANGES: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-30 03:40:13 UTC (rev 270) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-30 13:06:24 UTC (rev 271) @@ -94,7 +94,7 @@ timeit <- NULL ``` -# First steps +# Overview This document introduces the usage of CHNOSZ, a package for the [R software environment](http://r-project.org). For more information on R, see "[An Introduction to R](https://cran.r-project.org/manuals.html)" and the [contributed documentation](https://cran.r-project.org/other-docs.html) for R. @@ -175,8 +175,53 @@ data(thermo) ## clear system settings ``` -# Thermodynamic database and chemical formulas +# The basics +* Use `info()` to search the thermodynamic database + +```{r info_adenine} +info("adenine") +iadenine <- info("adenine") +info(iadenine) +``` + +* Use `thermo.refs()` to look up references +```{r refs_adenine} +thermo.refs(iadenine) +``` + +* Use `subcrt()` to calculate standard molal thermodynamic properties + +```{r bsad_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Nucleobase equal-activity diagram.", cache=TRUE, pngquant=pngquant, timeit=timeit} +basis("CHNOSe") +species(c("adenine", "cytosine", "guanine", "thymine", "uracil")) +a <- affinity(H2O = c(-12, -0), Eh = c(-0.5, 0), T = 100) +diagram(a) +``` + +```{r subcrt_adenine} +subcrt("adenine", T = 100) +``` + +```{r equil_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Nucleobase metastable equilibrium activities.", cache=TRUE, pngquant=pngquant, timeit=timeit} +basis("e-", 3.6) +a <- affinity(H2O = c(-12, 0), T = 100) +e <- equilibrate(a) +diagram(e, ylim=c(-8, 0)) +``` + +* Use `basis()``species()``affinity()``diagram()` (BSAD) to construct activity diagrams + +```{r bsad_adenine, eval=FALSE} +``` + +* Use `equilibrate()` to calculate equilibrium activities + +```{r equil_adenine, eval=FALSE} +``` + +# Thermodynamic database + An attempt has been made to provide a primary database (OBIGT) that has no major inconsistencies. As the database includes datasets from many sources, it can not be guaranteed to be fully internally consistent. For crucial problems, check not only the accuracy of entries in the database, but also the *suitability of the data* for your problem. From noreply at r-forge.r-project.org Tue Oct 31 05:26:56 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 31 Oct 2017 05:26:56 +0100 (CET) Subject: [CHNOSZ-commits] r272 - in pkg/CHNOSZ: . vignettes Message-ID: <20171031042656.7DDA01884B0@r-forge.r-project.org> Author: jedick Date: 2017-10-31 05:26:53 +0100 (Tue, 31 Oct 2017) New Revision: 272 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd Log: anintro.Rmd: colorize messages, test methane species index, add Feynman quote Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-30 13:06:24 UTC (rev 271) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-31 04:26:53 UTC (rev 272) @@ -1,6 +1,6 @@ Date: 2017-10-30 Package: CHNOSZ -Version: 1.1.0-70 +Version: 1.1.0-71 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-30 13:06:24 UTC (rev 271) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-31 04:26:53 UTC (rev 272) @@ -92,6 +92,13 @@ } }) timeit <- NULL + +## colorize messages 20171031 +## adapted from https://gist.github.com/yihui/2629886#file-knitr-color-msg-rnw +color_block = function(color) { + function(x, options) sprintf('
%s
', color, x) +} +knit_hooks$set(warning = color_block('magenta'), error = color_block('red'), message = color_block('blue')) ``` # Overview @@ -125,6 +132,8 @@ data(thermo) ``` +Note: In this document, syntax highlighting is applied to the *input* of the code chunks; *output* is in black text and *messages* are in blue text. + ## Getting help After CHNOSZ is installed, type `help.start()` to browse the R help documents, then choose "Packages" followed by "CHNOSZ". @@ -157,7 +166,7 @@ * `diagram()`: plot the results. Some functions in CHNOSZ do have side effects: they modify the `thermo` data object in the current R session. -In this document, the names of these functions are set in red text (not in the code chunks). +In this document, the names of these functions are set in red text (but not in the code chunks). Major functions with side effects are: * `basis()`: set the basis species and their chemical activities; @@ -177,20 +186,21 @@ # The basics -* Use `info()` to search the thermodynamic database +* Use `info()` to search the thermodynamic database. ```{r info_adenine} +info("aden ") info("adenine") iadenine <- info("adenine") info(iadenine) ``` -* Use `thermo.refs()` to look up references +* Use `thermo.refs()` to look up references. ```{r refs_adenine} thermo.refs(iadenine) ``` -* Use `subcrt()` to calculate standard molal thermodynamic properties +* Use `subcrt()` to calculate standard molal thermodynamic properties. ```{r bsad_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Nucleobase equal-activity diagram.", cache=TRUE, pngquant=pngquant, timeit=timeit} basis("CHNOSe") @@ -203,19 +213,19 @@ subcrt("adenine", T = 100) ``` -```{r equil_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Nucleobase metastable equilibrium activities.", cache=TRUE, pngquant=pngquant, timeit=timeit} +```{r equil_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Activities of nucleobases in metastable equilibrium.", cache=TRUE, pngquant=pngquant, timeit=timeit} basis("e-", 3.6) a <- affinity(H2O = c(-12, 0), T = 100) e <- equilibrate(a) -diagram(e, ylim=c(-8, 0)) +diagram(e, ylim = c(-8, 0)) ``` -* Use `basis()``species()``affinity()``diagram()` (BSAD) to construct activity diagrams +* Use `basis()``species()``affinity()``diagram()` (BSAD) to construct equal-activity (equipotential) diagrams. ```{r bsad_adenine, eval=FALSE} ``` -* Use `equilibrate()` to calculate equilibrium activities +* Use `equilibrate()` to calculate equilibrium activities. ```{r equil_adenine, eval=FALSE} ``` @@ -243,11 +253,19 @@ info("methane", "gas") ``` -Knowing that aqueous methane is species number 910 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters: -```{r info_910, message=FALSE} -info(910) +```{r info_methane_test, echo=FALSE, results="hide"} +# this prevents the vignette from compiling in case +# database updates cause the species index of methane to change +stopifnot(info("methane")==859) +# it is up to the editor of this vignette to ensure that number +# is used in the hard-coded examples below! ``` +Knowing that aqueous methane is species number 859 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters: +```{r info_859, message=FALSE} +info(859) +``` + This number can be used as an argument (`ispecies`) for other functions in CHNOSZ to uniquely identify any species; some commonly used functions also accept the species names. Liquid water is species number 1; it has NA entries in the database because specialized functions are used to compute its properties: ```{r info_info_water} @@ -279,21 +297,21 @@ ## Counting elements, chemical formulas, `ZC()` Continuing with the example of methane, let's look at its chemical formula: -```{r info_910_formula, message=FALSE} -info(910)$formula +```{r info_859_formula, message=FALSE} +info(859)$formula ``` We can use `makeup()` to count the elements in the formula, followed by `as.chemical.formula()` to rewrite the formula on one line: -```{r makeup_910} -makeup(910) -as.chemical.formula(makeup(910)) +```{r makeup_859} +makeup(859) +as.chemical.formula(makeup(859)) ``` For organic species, a calculation of the average oxidation state of carbon (`r zc`) is possible given the species index, chemical formula, or elemental count: -```{r ZC_910, message=FALSE} -ZC(910) -ZC(info(910)$formula) -ZC(makeup(910)) +```{r ZC_859, message=FALSE} +ZC(859) +ZC(info(859)$formula) +ZC(makeup(859)) ``` # Calculating thermodynamic properties @@ -2096,7 +2114,7 @@ `RH2obigt()` implements a group additivity calculation of standard molal thermodynamic properties and equations of state parameters of crystalline and liquid organic molecules from @RH98. -`eqdata()` reads data, including concentrations of aqueous species, numbers of moles of solid phases, and mineral saturation states (affinities), from an EQ6 output file [[@Wol92]](http://www.wipp.energy.gov/library/cra/2009_cra/references/Others/Wolery_1992_EQ36_A_Software_Package_for_Geochemical_Modeling_of_Aqueous_Systems_ERMS241375.pdf). +`eqdata()` reads data, including concentrations of aqueous species, numbers of moles of solid phases, and mineral saturation states (affinities), from an EQ6 output file [@Wol92]. ## NCBI taxonomy files @@ -2123,7 +2141,11 @@ > > `r tufte::quote_footer('--- Stephen Jay Gould')` +> "The real fun of life is this perpetual testing to realize how far out you can go with any potentialities." +> +> `r tufte::quote_footer('--- Richard P. Feynman')` + # Document history * 2010-09-30 Initial version. Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-10-30 13:06:24 UTC (rev 271) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-10-31 04:26:53 UTC (rev 272) @@ -68,6 +68,13 @@ pngquant <- "--speed=1 --quality=0-50" dpi <- 72 } + +## colorize messages 20171031 +## adapted from https://gist.github.com/yihui/2629886#file-knitr-color-msg-rnw +color_block = function(color) { + function(x, options) sprintf('
%s
', color, x) +} +knit_hooks$set(warning = color_block('magenta'), error = color_block('red'), message = color_block('blue')) ``` From noreply at r-forge.r-project.org Tue Oct 31 15:46:29 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 31 Oct 2017 15:46:29 +0100 (CET) Subject: [CHNOSZ-commits] r273 - in pkg/CHNOSZ: . man tests/testthat vignettes Message-ID: <20171031144629.737CC189312@r-forge.r-project.org> Author: jedick Date: 2017-10-31 15:46:29 +0100 (Tue, 31 Oct 2017) New Revision: 273 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/tests/testthat/test-logmolality.R pkg/CHNOSZ/vignettes/anintro.Rmd Log: test-logmolality.R: check value of loga.balance in equilibrate() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-10-31 04:26:53 UTC (rev 272) +++ pkg/CHNOSZ/DESCRIPTION 2017-10-31 14:46:29 UTC (rev 273) @@ -1,6 +1,6 @@ -Date: 2017-10-30 +Date: 2017-10-31 Package: CHNOSZ -Version: 1.1.0-71 +Version: 1.1.0-72 Title: Thermodynamic Calculations for Geobiochemistry Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-10-31 04:26:53 UTC (rev 272) +++ pkg/CHNOSZ/man/examples.Rd 2017-10-31 14:46:29 UTC (rev 273) @@ -64,7 +64,7 @@ For either function, if \code{save.png} is TRUE, the plots are saved in \code{\link{png}} files whose names begin with the names of the help topics or demos. Two of the demos have external dependencies and are not automatically run by \code{demos}. -\samp{dehydration} creates an interactive SVG file; this demo depends on the \pkg{RSVGTipsDevice}, which is not available for Windows +\samp{dehydration} creates an interactive SVG file; this demo depends on \CRANpkg{RSVGTipsDevice}, which is not available for Windows. \samp{carboxylase} creates an animated GIF; this demo requires that the ImageMagick \code{convert} commmand be available on the system (tested on Linux and Windows). \samp{carboxylase} animates diagrams showing rankings of calculated chemical activities along a combined \T and \logaH2 gradient, or makes a single plot on the default device (without conversion to animated GIF) if a single temperature (\code{T}) is specified in the code. Modified: pkg/CHNOSZ/tests/testthat/test-logmolality.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-logmolality.R 2017-10-31 04:26:53 UTC (rev 272) +++ pkg/CHNOSZ/tests/testthat/test-logmolality.R 2017-10-31 14:46:29 UTC (rev 273) @@ -120,4 +120,12 @@ ## take-home message 4: using affinity() with IS not equal to zero, the "loga.equil" ## returned by equilibrate() is logmolal for speciation calculations with charged aqueous species + + # finally, what is loga.balance? + a.balance <- 10^e1$loga.balance + m.total <- sum(10^unlist(e1$loga.equil)) + expect_equal(a.balance, m.total) + + ## take-home message 5: using affinity() with IS not equal to zero, the "loga.balance" + ## used by equilibrate() is the logarithm of total molality of the balancing basis species }) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-31 04:26:53 UTC (rev 272) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-10-31 14:46:29 UTC (rev 273) @@ -132,7 +132,8 @@ data(thermo) ``` -Note: In this document, syntax highlighting is applied to the *input* of the code chunks; *output* is in black text and *messages* are in blue text. +Note: Throughout this document, syntax highlighting is applied to the *input* of the code chunks. +Double hash marks (`##`) precede the *output*, where black text denotes *results* and blue text is used for *messages*. ## Getting help @@ -588,7 +589,7 @@ Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species. R's `unlist()` is used here to turn the list of values of affinity into a numeric object that can be printed in a couple of lines (note that the names correspond to `ispecies` above): ```{marginfigure} -The values returned by `affinity()` are dimensionless, i.e. *A*/2.303*RT*. +The values returned by `affinity()` are dimensionless, i.e. *A*/(2.303*RT*). ``` ```{r affinity} unlist(affinity()$values) @@ -707,7 +708,7 @@ For instance, we can use H2 or `r o2` in place of *e*-. To do that, let's write a function to swap those basis species and make a diagram. We use R's `do.call()` to construct the argument list for `mosaic()`; this way, the name of the `newvar` argument to our function indicates the chosen variable. -```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system.", pngquant=pngquant, timeit=timeit} +```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="The same chemical system projected into different sets of basis species.", pngquant=pngquant, timeit=timeit} mosaicfun <- function(newvar, T = 200) { swap.basis("e-", names(newvar)) if (names(newvar) == "O2") basis("O2", "gas") @@ -721,7 +722,7 @@ } par(mfrow = c(1, 3)) mosaicfun(list(Eh = c(-1, 1, res))) -mosaicfun(list(H2 = c(-15, 5, res))) +mosaicfun(list(H2 = c(-25, 10, res))) mosaicfun(list(O2 = c(-70, 0, res))) ``` @@ -762,7 +763,7 @@ That conversion requires temperature in Kelvin, which is obtained by conversion from ?C. We finish with a negation (affinity is negative Gibbs energy) and scaling from cal to kcal. ``` -Using R's `lapply()` to run `convert()` for each species, we convert the affinity from dimensionless values (*A*/2.303*RT*) to cal/mol, then kcal/mol. +Using R's `lapply()` to run `convert()` for each species, we convert the affinity from dimensionless values (*A*/(2.303*RT*)) to cal/mol, then kcal/mol. ```{r rainbow_affinity, message=FALSE} a <- affinity(T = rb$T, CO2 = rb$CO2, H2 = rb$H2, `NH4+` = rb$`NH4+`, H2S = rb$H2S, pH = rb$pH) @@ -1060,16 +1061,19 @@ * Using `subcrt()` with `IS` not equal to zero, calculated values of `G` are the **apparent** standard Gibbs energy at specified ionic strength. -* Using `subcrt()` with `IS` not equal to zero, values in the `logact` argument stand for **log molality** of charged aqueous species in affinity calculations. +* Using `subcrt()` with `IS` not equal to zero, values in the `logact` argument stand for **log molality** of aqueous species in affinity calculations. -* Using `affinity()` with `IS` not equal to zero, the following values stand for **log molality** of charged aqueous species: +* Using `affinity()` with `IS` not equal to zero, the following values stand for **log molality** of aqueous species: + values of `logact` set by `basis()`; - + values of `logact` set by `species()`; - + value of `loga.equil` returned by `equilibrate()` + + values of `logact` set by `species()`. -In other words, the activation of activity coefficients transforms variables from activity to molality in the main workflow. -A simple but detailed example demonstrating each of the above tranformations is in `tests/testthat/test-logmolality.R`. +* Using `equilibrate()` on the output of affinity calculated with `IS` not equal to zero, the following values stand for **log molality** of aqueous species: + + the value of `loga.balance` used by `equilibrate()` (i.e., logarithm of total molality of the balancing basis species); + + values of `loga.equil` returned by `equilibrate()`. +In other words, the activation of activity coefficients effects a transformation from activity to molality in the main workflow. +A simple but comprehensive series of calculations demonstrating these tranformations is in `tests/testthat/test-logmolality.R`. + Because it is not possible to dynamically change the names of arguments in the functions, the user should be aware of the effects mentioned above. As another consequence, activities of basis species or equilibrium activities of species shown on diagrams should be relabeled as molalities when `IS` is used in the calculation of `affinity()`. @@ -1572,7 +1576,7 @@ twc[[3]][ihigh] <- col names <- rep("", length(pname)) names[ihigh] <- c("Olig2", "Irx3", "Nkx6.2", "Dbx1", "Shh") -ylab <- substitute(italic(A) / 2.303 * italic(RT) * " relative to Shh") +ylab <- substitute(italic(A) / (2.303 * italic(RT)) * " relative to Shh") diagram(a, balance = 1, ylim = c(-0.5, 5), xlim = c(0.5, -5.5), lty = twc[[1]], lwd=twc[[2]], col = twc[[3]], ylab = ylab, names = names, adj = 0, dy = 0.1, format.names = FALSE)