[CHNOSZ-commits] r747 - in pkg/CHNOSZ: . R demo inst inst/extdata/OBIGT man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 29 10:05:52 CEST 2022


Author: jedick
Date: 2022-09-29 10:05:52 +0200 (Thu, 29 Sep 2022)
New Revision: 747

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/info.R
   pkg/CHNOSZ/R/util.data.R
   pkg/CHNOSZ/demo/DEW.R
   pkg/CHNOSZ/demo/solubility.R
   pkg/CHNOSZ/inst/CHECKLIST
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/extdata/OBIGT/AD.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRT92.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_gas.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/organic_cr.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/organic_gas.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/organic_liq.csv
   pkg/CHNOSZ/man/add.OBIGT.Rd
   pkg/CHNOSZ/man/info.Rd
   pkg/CHNOSZ/man/thermo.Rd
Log:
Remove order-of-magnitude scaling of heat capacity coefficient in CGL model


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/DESCRIPTION	2022-09-29 08:05:52 UTC (rev 747)
@@ -1,6 +1,6 @@
 Date: 2022-09-29
 Package: CHNOSZ
-Version: 1.9.9-38
+Version: 1.9.9-39
 Title: Thermodynamic Calculations and Diagrams for Geochemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/R/info.R
===================================================================
--- pkg/CHNOSZ/R/info.R	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/R/info.R	2022-09-29 08:05:52 UTC (rev 747)
@@ -10,11 +10,12 @@
 #source("util.data.R")
 
 info <- function(species=NULL, state=NULL, check.it=TRUE) {
-  ## return information for one or more species in thermo()$OBIGT
+
+  ## Return information for one or more species in thermo()$OBIGT
   thermo <- get("thermo", CHNOSZ)
-  # that should give us the data, not the thermo() function 20190928
+  # That should give us the data, not the thermo() function 20190928
   if(is.function(thermo)) stop("CHNOSZ package data is not available; use reset() or library(CHNOSZ) to load it")
-  ## if no species are requested, summarize the available data  20101129
+  ## If no species are requested, summarize the available data  20101129
   if(is.null(species)) {
     message("info: 'species' is NULL; summarizing information about thermodynamic data...")
     message(paste("thermo()$OBIGT has", nrow(thermo$OBIGT[thermo$OBIGT$state=="aq", ]), "aqueous,",
@@ -25,10 +26,12 @@
       length(unique(thermo$protein$organism)), "organisms"))
     return()
   }
-  ## run info.numeric or info.character depending on the input type
+
+  ## Run info.numeric or info.character depending on the input type
   if(is.numeric(species)) {
+
     out <- lapply(species, info.numeric, check.it)
-    # if we have different states the column names could be different
+    # If we have different states the column names could be different
     if(length(unique(unlist(lapply(out, names)))) > ncol(thermo$OBIGT)) {
       # make them the same as thermo$OBIGT
       out <- lapply(out, function(row) {
@@ -35,44 +38,50 @@
         colnames(row) <- colnames(thermo$OBIGT); return(row)
       }) 
     }
-    # turn the list into a data frame
+    # Turn the list into a data frame
     out <- do.call(rbind, out)
-    # ensure that the rownames are numeric values (not names possibly inherited from retrieve()) 20190224
+    # Ensure that the rownames are numeric values (not names possibly inherited from retrieve()) 20190224
     if(!is.null(attr(species, "names"))) row.names(out) <- species
+
   } else {
-    # state and species should be same length
+
+    # State and species should be same length
     if(!is.null(state)) {
       lmax <- max(length(species), length(state))
       state <- rep(state, length.out=lmax)
       species <- rep(species, length.out=lmax)
     }
-    # loop over the species
+    # Loop over the species
     out <- sapply(seq_along(species), function(i) {
-      # first look for exact match
+      # First look for exact match
       ispecies <- info.character(species[i], state[i])
-      # if no exact match and it's not a protein, show approximate matches (side effect of info.approx)
+      # If no exact match and it's not a protein, show approximate matches (side effect of info.approx)
       if(identical(ispecies, NA) & !grepl("_", species[i])) ispecies.notused <- info.approx(species[i], state[i])
-      # do not accept multiple matches
+      # Do not accept multiple matches
       if(length(ispecies) > 1) ispecies <- NA
       return(ispecies)
     })
+
   }
-  ## all done!
+
+  ## All done!
   return(out)
 }
 
-### unexported functions ###
+### Unexported functions ###
 
-info.text <- function(ispecies) {
+info.text <- function(ispecies, withsource = TRUE) {
   # a textual description of species name, formula, source, e.g.
   # CO2 [CO2(aq)] (SSW01, SHS89, 11.Oct.07)
   this <- get("thermo", CHNOSZ)$OBIGT[ispecies, ]
+  out <- paste(this$name, " [", this$formula, "(", this$state, ")", "]", sep="")
+  if(!withsource) return(out)
   sourcetext <- this$ref1
   ref2 <- this$ref2
   if(!is.na(ref2)) sourcetext <- paste(sourcetext, ref2, sep=", ")
   date <- this$date
   if(!is.na(date)) sourcetext <- paste(sourcetext, date, sep=", ")
-  out <- paste(this$name, " [", this$formula, "(", this$state, ")", "] (", sourcetext, ")", sep="")
+  out <- paste(out, " (", sourcetext, ")", sep = "")
   return(out)
 }
 
@@ -176,8 +185,8 @@
 }
 
 info.numeric <- function(ispecies, check.it=TRUE) {
-  # from a numeric species index in 'ispecies' return the 
-  # thermodynamic properties and equations-of-state parameters
+  # From a numeric species index in 'ispecies' return the 
+  #   thermodynamic properties and equations-of-state parameters
   thermo <- get("thermo", CHNOSZ)
   # if we're called with NA, return an empty row
   if(is.na(ispecies)) {
@@ -186,7 +195,7 @@
     return(this)
   }
   this <- thermo$OBIGT[ispecies,]
-  # species indices must be in range
+  # Species indices must be in range
   ispeciesmax <- nrow(thermo$OBIGT)
   if(ispecies > ispeciesmax | ispecies < 1) 
     stop(paste("species index", ispecies, "not found in thermo()$OBIGT\n"))
@@ -195,6 +204,10 @@
   # Use new OBIGT2eos function here
   this <- OBIGT2eos(this, this$state)
 
+  # Stop with an informative message if species don't have a model 20220929
+  namodel <- is.na(this$model)
+  if(namodel) stop(paste("Species has NA model:", info.text(ispecies, FALSE)), call. = FALSE)
+
   if(tolower(this$model) == "berman") { # this is Berman
     # Get G, H, S, and V for minerals with Berman parameters 20220203
     Bermandat <- Berman()

Modified: pkg/CHNOSZ/R/util.data.R
===================================================================
--- pkg/CHNOSZ/R/util.data.R	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/R/util.data.R	2022-09-29 08:05:52 UTC (rev 747)
@@ -262,14 +262,15 @@
   # and among G, H, S values
   # 20110808 jmd replaces 'check=TRUE' argument of info()
   checkfun <- function(what) {
+    message(paste("check.OBIGT: checking", what))
     # looking at thermo$OBIGT
     if(what=="OBIGT") tdata <- get("thermo", CHNOSZ)$OBIGT
-    else if(what=="DEW") tdata <- read.csv(system.file("extdata/OBIGT/DEW.csv", package="CHNOSZ"), as.is=TRUE)
-    else if(what=="SLOP98") tdata <- read.csv(system.file("extdata/OBIGT/SLOP98.csv", package="CHNOSZ"), as.is=TRUE)
-    else if(what=="SUPCRT92") tdata <- read.csv(system.file("extdata/OBIGT/SUPCRT92.csv", package="CHNOSZ"), as.is=TRUE)
-    else if(what=="AS04") tdata <- read.csv(system.file("extdata/OBIGT/AS04.csv", package="CHNOSZ"), as.is=TRUE)
-    else if(what=="AD") tdata <- read.csv(system.file("extdata/OBIGT/AD.csv", package="CHNOSZ"), as.is=TRUE)
-    else if(what=="GEMSFIT") tdata <- read.csv(system.file("extdata/OBIGT/GEMSFIT.csv", package="CHNOSZ"), as.is=TRUE)
+    else if(what=="DEW") tdata <- read.csv(system.file("extdata/OBIGT/DEW.csv", package = "CHNOSZ"), as.is = TRUE)
+    else if(what=="SLOP98") tdata <- read.csv(system.file("extdata/OBIGT/SLOP98.csv", package = "CHNOSZ"), as.is = TRUE)
+    else if(what=="SUPCRT92") tdata <- read.csv(system.file("extdata/OBIGT/SUPCRT92.csv", package = "CHNOSZ"), as.is = TRUE)
+    else if(what=="AS04") tdata <- read.csv(system.file("extdata/OBIGT/AS04.csv", package = "CHNOSZ"), as.is = TRUE)
+    else if(what=="AD") tdata <- read.csv(system.file("extdata/OBIGT/AD.csv", package = "CHNOSZ"), as.is = TRUE)
+    else if(what=="GEMSFIT") tdata <- read.csv(system.file("extdata/OBIGT/GEMSFIT.csv", package = "CHNOSZ"), as.is = TRUE)
     ntot <- nrow(tdata)
     # where to keep the results
     DCp <- DV <- DG <- rep(NA,ntot)
@@ -318,8 +319,6 @@
   out$DCp <- round(out$DCp,2)
   out$DV <- round(out$DV,2)
   out$DG <- round(out$DG)
-  # how to make the file at extdata/thermo/OBIGT_check.csv
-  # write.csv(out,"OBIGT_check.csv",na="",row.names=FALSE)
   # return the results
   return(out)
 }
@@ -406,42 +405,45 @@
 # If fixGHS is TRUE a missing one of G, H or S for any species is calculated
 #   from the other two and the chemical formula of the species.
 # If toJoules is TRUE, convert parameters to Joules 20220325
-# This function is used by both info and subcrt when retrieving entries from the thermodynamic database.
+# This function is used by both info() and subcrt() when retrieving entries from the thermodynamic database.
 OBIGT2eos <- function(OBIGT, state, fixGHS = FALSE, toJoules = FALSE) {
-  # Remove scaling factors from EOS parameters and apply column names depending on the EOS
-  if(identical(state, "aq")) {
-    # Aqueous species with model = "AD" use the AD model 20210407
-    model <- OBIGT$model
-    model[is.na(model)] <- ""
-    isAD <- model == "AD"
-    # Remove scaling factors for the HKF species, but not for the AD species;
-    # protect this by an if statement to workaround error in subassignment to empty subset of data frame in R < 3.6.0
-    # (https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17483) 20190302
-    if(any(!isAD)) OBIGT[!isAD, 15:22] <- t(t(OBIGT[!isAD, 15:22]) * 10 ^ c(-1, 2, 0, 4, 0, 4, 5, 0))
-    # For AD species, set NA values in remaining columns (for display only)
-    if(any(isAD)) OBIGT[isAD, 18:21] <- NA
-    # If all of the species are AD, change the variable names
-    if(all(isAD)) colnames(OBIGT)[15:22] <- c("a", "b", "xi", "XX1", "XX2", "XX3", "XX4", "Z") 
-    else colnames(OBIGT)[15:22] <- c("a1", "a2", "a3", "a4", "c1", "c2", "omega", "Z") 
-  } else {
-    OBIGT[, 15:22] <- t(t(OBIGT[, 15:22]) * 10 ^ c(0, -3, 5, 0, -5, 0, 0, 0))
-    colnames(OBIGT)[15:22] <- c("a", "b", "c", "d", "e", "f", "lambda", "T")
-  }
+
+  # Figure out the model for each species 20220929
+  model <- OBIGT$model
+  model[is.na(model)] <- ""
+  isCGL <- model == "CGL"
+  isHKF <- model == "HKF"
+  isDEW <- model == "DEW"
+  isAD <- model == "AD"
+  # Remove scaling factors for the HKF and DEW species
+  #   protect this by an if statement to workaround error in subassignment to empty subset of data frame in R < 3.6.0
+  #   (https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17483) 20190302
+  is_HKF <- isHKF | isDEW
+  if(any(is_HKF)) OBIGT[is_HKF, 15:22] <- t(t(OBIGT[is_HKF, 15:22]) * 10 ^ c(-1, 2, 0, 4, 0, 4, 5, 0))
+  # For AD species, set NA values in unused columns
+  if(any(isAD)) OBIGT[isAD, 18:21] <- NA
+  # Change column names depending on the model
+  if(all(isAD)) colnames(OBIGT)[15:22] <- c("a", "b", "xi", "XX1", "XX2", "XX3", "XX4", "Z") 
+  else if(all(isHKF | isAD | isDEW)) colnames(OBIGT)[15:22] <- c("a1", "a2", "a3", "a4", "c1", "c2", "omega", "Z") 
+  else colnames(OBIGT)[15:22] <- c("a", "b", "c", "d", "e", "f", "lambda", "T")
+
   if(toJoules) {
     # Convert parameters from calories to Joules 20220325
     # [Was: convert parameters from Joules to calories 20190530]
-    ical <- OBIGT$E_units == "cal"
-    if(any(ical)) {
-      # We only convert column 20 for aqueous species (omega), not for cgl species (lambda)  20190903
-      if(identical(state, "aq")) OBIGT[ical, c(10:13, 15:21)] <- convert(OBIGT[ical, c(10:13, 15:21)], "J")
-      else OBIGT[ical, c(10:13, 15:20)] <- convert(OBIGT[ical, c(10:13, 15:20)], "J")
+    iscal <- OBIGT$E_units == "cal"
+    if(any(iscal)) {
+      OBIGT[iscal, c(10:13, 15:20)] <- convert(OBIGT[iscal, c(10:13, 15:20)], "J")
+      # We only convert the last column for aqueous species (HKF parameter: omega), not for CGL species (arbitrary exponent: lambda)  20190903
+      isaq <- OBIGT$state == "aq"
+      if(any(isaq)) OBIGT[iscal & isaq, 21] <- convert(OBIGT[iscal & isaq, 21], "J")
       # Also update the E_units column 20220325
-      OBIGT$E_units[ical] <- "J"
+      OBIGT$E_units[iscal] <- "J"
     }
   }
+
   if(fixGHS) {
     # Fill in one of missing G, H, S;
-    #   for use esp. by subcrt because NA for one of G, H or S precludes calculations at high T
+    #   for use esp. by subcrt() because NA for one of G, H or S precludes calculations at high T
     # Which entries are missing just one
     imiss <- which(rowSums(is.na(OBIGT[, 10:12])) == 1)
     if(length(imiss) > 0) {
@@ -455,5 +457,6 @@
       }
     }
   }
-  return(OBIGT)
+
+  OBIGT
 }

Modified: pkg/CHNOSZ/demo/DEW.R
===================================================================
--- pkg/CHNOSZ/demo/DEW.R	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/demo/DEW.R	2022-09-29 08:05:52 UTC (rev 747)
@@ -20,19 +20,19 @@
 thermo.refs(iSi)
 # Set temperature ranges for different pressures
 # data.frame is used to make P and T the same length
-PT0.5 <- data.frame(P=500, T=seq(200, 550, 10))
-PT1.0 <- data.frame(P=1000, T=seq(200, 700, 10))
-PT2.0 <- data.frame(P=2000, T=seq(200, 700, 10))
-PT5.0 <- data.frame(P=5000, T=seq(200, 850, 10))
-PT10.0 <- data.frame(P=10000, T=seq(200, 825, 10))
-PT20.0 <- data.frame(P=20000, T=seq(200, 800, 10))
+PT0.5 <- data.frame(P = 500, T = seq(200, 550, 10))
+PT1.0 <- data.frame(P = 1000, T = seq(200, 700, 10))
+PT2.0 <- data.frame(P = 2000, T = seq(200, 700, 10))
+PT5.0 <- data.frame(P = 5000, T = seq(200, 850, 10))
+PT10.0 <- data.frame(P = 10000, T = seq(200, 825, 10))
+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 <- suppressWarnings(subcrt(c("quartz", "SiO2"), c("cr", "aq"), c(-1, 1), P=PT$P, T=PT$T))$out$logK
+SiO2_logK <- suppressWarnings(subcrt(c("quartz", "SiO2"), c("cr", "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 <- suppressWarnings(subcrt(c("quartz", "Si2O4"), c("cr", "aq"), c(-2, 1), P=PT$P, T=PT$T))$out$logK
+Si2O4_logK <- suppressWarnings(subcrt(c("quartz", "Si2O4"), c("cr", "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")
+plot(c(200, 1000), c(-2.5, 0.5), type = "n", xlab = axis.label("T"), ylab = "log molality")
 for(P in unique(PT$P)) {
   icond <- PT$P == P
   SiO2_logm <- SiO2_logK[icond]
@@ -41,8 +41,8 @@
   lines(PT$T[icond], logm)
   # add text label
   lastT <- tail(PT$T[icond], 1)
-  Pkb <- paste(format(P/1000, nsmall=1), "kb")
-  text(lastT+25, tail(logm, 1), Pkb, adj=0)
+  Pkb <- paste(format(P/1000, nsmall = 1), "kb")
+  text(lastT+25, tail(logm, 1), Pkb, adj = 0)
 }
 t1 <- quote("Solubility of"~alpha*"-quartz")
 t2 <- "after Sverjensky et al., 2014a"
@@ -54,16 +54,18 @@
 ## after Figures 12B and 12C of Sverjensky et al., 2014a [SHA14]
 ###########
 
-# For this plot we don't need the DEW water model
+# We can't use the DEW water model at 25 degC
 reset()
 # 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
-add.OBIGT("DEW", c("CO3-2", "BO2-", "MgCl+", "SiO2", "HCO3-", "Si2O4"))
+iDEW <- add.OBIGT("DEW", c("CO3-2", "BO2-", "MgCl+", "SiO2", "HCO3-", "Si2O4"))
+# Override the check in subcrt() for the DEW water model 20220929
+lapply(iDEW, mod.OBIGT, model = "HKF")
 # Set up the plot
 V0nlab <- expression(Delta * italic(V) * degree[n]~~(cm^3~mol^-1))
 a1lab <- expression(italic(a)[1]%*%10~~(cal~mol~bar^-1))
-plot(c(-25, 50), c(-4, 12), type="n", xlab=V0nlab, ylab=a1lab)
+plot(c(-25, 50), c(-4, 12), type = "n", xlab = V0nlab, ylab = a1lab)
 # A function to get the HKF parameters, calculate nonsolvation volume, plot points, labels, error bars, and correlation lines
 plotfun <- function(species, col, pch, cex, dy, error, xlim, corrfun) {
   # Get HKF a1 parameter
@@ -71,10 +73,10 @@
   # Set omega to zero to calculate non-solvation volume 20220326
   mod.OBIGT(species, omega = 0)
   Vn <- do.call(rbind, subcrt(species, T = 25)$out)$V
-  points(Vn, a1, col=col, pch=pch, cex=cex)
-  for(i in 1:length(species)) text(Vn[i], a1[i]+dy, expr.species(species[i]))
-  arrows(Vn, a1 - error, Vn, a1 + error, length = 0.03, angle = 90, code = 3, col=col)
-  lines(xlim, corrfun(xlim), col=col)
+  points(Vn, a1, col = col, pch = pch, cex = cex)
+  for(i in 1:length(species)) text(Vn[i], a1[i] + dy, expr.species(species[i]))
+  arrows(Vn, a1 - error, Vn, a1 + error, length = 0.03, angle = 90, code = 3, col = col)
+  lines(xlim, corrfun(xlim), col = col)
 }
 # Monovalent ions: Na+, K+, Cl-, Br-
 monofun <- function(Vn) 2.0754 + 0.10871 * Vn
@@ -95,6 +97,7 @@
 
 # Clean up for next plot 
 OBIGT()
+water("DEW")
 
 ###########
 #### Plot 3: logfO2-pH diagram for aqueous inorganic and organic carbon species at high pressure
@@ -116,8 +119,8 @@
   # (from EQ3NR model for eclogite [Supporting Information of SSH14])
   e <- equilibrate(a, loga.balance = log10(0.03))
   diagram(e, fill = fill)
-  dp <- describe.property(c("     T", "     P"), c(T, P), digits=0)
-  legend("bottomleft", legend=dp, bty="n")
+  dp <- describe.property(c("     T", "     P"), c(T, P), digits = 0)
+  legend("bottomleft", legend = dp, bty = "n")
 }
 
 water("DEW")
@@ -157,7 +160,7 @@
 ## Calculate logfO2 in QFM buffer
 basis("O2", "QFM")
 T <- seq(600, 1000, 100)
-buf <- affinity(T=T, P=50000, return.buffer=TRUE)
+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
@@ -177,9 +180,9 @@
 col <- rep("black", length(names))
 col[c(1, 3, 6, 8, 10)] <- c("red", "darkgreen", "purple", "orange", "navyblue")
 if(packageVersion("CHNOSZ") > "1.1.3") {
-  diagram(e, alpha = "balance", names = names, col = col, ylim = c(0, 0.8), ylab="carbon fraction", spline.method="natural")
+  diagram(e, alpha = "balance", names = names, col = col, ylim = c(0, 0.8), ylab = "carbon fraction", spline.method = "natural")
 } else {
-  diagram(e, alpha = "balance", names = names, col = col, ylim = c(0, 0.8), ylab="carbon fraction")
+  diagram(e, alpha = "balance", names = names, col = col, ylim = c(0, 0.8), ylab = "carbon fraction")
 }
 
 ## Add legend and title

Modified: pkg/CHNOSZ/demo/solubility.R
===================================================================
--- pkg/CHNOSZ/demo/solubility.R	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/demo/solubility.R	2022-09-29 08:05:52 UTC (rev 747)
@@ -3,13 +3,13 @@
 # 20181031 use new vectorized, non-uniroot solubility(); add T-pH plots
 library(CHNOSZ)
 
-# for comparison with published CO2 solubility plot, see Fig. 4.5 in
-# Stumm and Morgan, 1996, Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters
-# (New York: John Wiley & Sons), 3rd edition
+# For comparison with published CO2 solubility plot, see Fig. 4.5 in
+#   Stumm and Morgan, 1996, Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters
+#   (New York: John Wiley & Sons), 3rd edition
 
-# for comparison with published calcite solubility plot, see Fig. 4A in
-# Manning et al., 2013, Reviews in Mineralogy & Geochemistry, v. 75, pp. 109-148
-# (doi: 10.2138/rmg.2013.75.5)
+# For comparison with published calcite solubility plot, see Fig. 4A in
+#   Manning et al., 2013, Reviews in Mineralogy & Geochemistry, v. 75, pp. 109-148
+#   (doi: 10.2138/rmg.2013.75.5)
 
 opar <- par(no.readonly = TRUE)
 layout(matrix(1:4, nrow = 2))

Modified: pkg/CHNOSZ/inst/CHECKLIST
===================================================================
--- pkg/CHNOSZ/inst/CHECKLIST	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/inst/CHECKLIST	2022-09-29 08:05:52 UTC (rev 747)
@@ -74,20 +74,20 @@
 - Run R_PAPERSIZE=letter R CMD Rd2pdf CHNOSZ/
   and fix any lines truncated by page margins
 
-*********************
-Vignettes for website
-*********************
+**********************************************
+Run tests that are skipped for routine testing
+**********************************************
 
+- Comment this line in test-AD.R:
+exit_file("Skipping tests so development builds on R-Forge work")
+
+*************************************************
+Making vignettes for website (https://chnosz.net)
+*************************************************
+
 - Use dpi <- 72 in anintro.Rmd
 
 - Use hires <- TRUE in multi-metal.Rmd
 
-- Run doc/mklinks.sh in installed directory (adds links to HTML renditions of
-  Rd files)
-
-*******
-Testing
-*******
-
-- Comment this line in test-AD.R:
-exit_file("Skipping tests so development builds on R-Forge work")
+- After making vignettes, run doc/mklinks.sh in installed directory
+  (this adds links to the HTML renditions of Rd files)

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2022-09-29 08:05:52 UTC (rev 747)
@@ -12,30 +12,35 @@
 % links to vignettes 20220723
 \newcommand{\viglink}{\ifelse{html}{\out{<a href="../CHNOSZ/doc/#1.html"><strong>#1.Rmd</strong></a>}}{\bold{#1.Rmd}}}
 
-\section{Changes in CHNOSZ version 1.9.9-36 (2022-09-20)}{
+\section{Changes in CHNOSZ version 1.9.9-39 (2022-09-29)}{
 
   \subsection{MAJOR USER-VISIBLE CHANGES}{
     \itemize{
 
+      \item Units of Joules instead of calories are now used by default for the
+      thermodynamic properties output by \code{subcrt()}. That is,
+      \code{E.units("J")} is the default setting. Scripts that implicitly
+      depend on the previous default setting of \code{E.units("cal")} may need
+      to be modified to produce expected output.
+
       \item A \code{model} column has been added to the OBIGT thermodynamic
       database. This specifies the model for calculating standard thermodynamic
       properties and will eventually supersede the heuristics for determining
-      the model to use based on values in other columns. Currently used models
-      are \samp{H2O} (water), \samp{HKF} (revised Helgeson-Kirkham-Flowers),
+      the model based on values in other columns. Currently used models are
+      \samp{H2O} (water), \samp{HKF} (revised Helgeson-Kirkham-Flowers),
       \samp{CGL} (heat capacity equation for crystalline, gas, and liquid
       species), \samp{Berman} (Berman equations), \samp{AD} (Akinfiev-Diamond),
-      and \samp{DEW} (Deep Earth Water model). All OBIGT data files that can be
-      read using \code{add.OBIGT()} must have this column; there is no
-      back-compatibility support for data files in the old format.
+      and \samp{DEW} (Deep Earth Water model, a variation of HKF). All OBIGT
+      data files that can be read using \code{add.OBIGT()} must have this
+      column; there is no back-compatibility support for data files in the old
+      format.
 
       \item Backward compatibility for OBIGT data files without an
       \code{E_units} column has been removed.
 
-      \item Units of Joules instead of calories are now used by default for the
-      thermodynamic properties output by \code{subcrt()}. That is,
-      \code{E.units("J")} is the default setting. Scripts that implicitly
-      depend on the previous default setting of \code{E.units("cal")} may need
-      to be modified to produce expected output.
+      \item Order-of-magnitude (OOM) scaling of heat capacity coefficients for
+      the CGL model in OBIGT data files has been removed. OOM scaling of HKF
+      (including DEW) model parameters is still in effect.
 
       \item Change license from GPL (>= 2) to GPL-3.
 
@@ -120,7 +125,7 @@
   \subsection{REMOVED FEATURES}{
     \itemize{
 
-      \item Remove exports of \code{cgl()}, \code{hkf()}, and \code{AD()}.
+      \item \code{cgl()}, \code{hkf()}, and \code{AD()} are no longer exported.
       \code{subcrt()} should be used for all calculations of thermodynamic
       properties.
 
@@ -177,8 +182,8 @@
       \item Add a \strong{zap} argument to \code{mod.OBIGT()} to clear
       parameters of preexisting species (used by \code{logB_to_OBIGT()}).
 
-      \item Change default for \code{affinity()} to \code{loga.protein = 0}
-      (was -3).
+      \item In \code{affinity()}, make \code{loga.protein = 0} the default
+      (changed from -3).
 
       \item Add tests \file{stack_mosaic.R} and \file{stack_solubility.R}
       (these create PDF files for visual inspection of results).

Modified: pkg/CHNOSZ/inst/extdata/OBIGT/AD.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/OBIGT/AD.csv	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/inst/extdata/OBIGT/AD.csv	2022-09-29 08:05:52 UTC (rev 747)
@@ -20,6 +20,6 @@
 B(OH)3,NA,B(OH)3,aq,AP14,NA,2019-02-22,AD,J,NA,NA,NA,NA,NA,-4.2561,4.0194,-1.057,NA,NA,NA,NA,NA
 Si(OH)4,NA,Si(OH)4,aq,AP14,NA,2019-02-22,AD,J,NA,NA,NA,NA,NA,0.9285,-0.9409,-1.8933,NA,NA,NA,NA,NA
 As(OH)3,NA,As(OH)3,aq,AP14,NA,2019-02-22,AD,J,NA,NA,NA,NA,NA,-9.903,7.6818,-1.23,NA,NA,NA,NA,NA
-B(OH)3,NA,B(OH)3,gas,AP14,NA,2019-02-22,CGL,cal,-222523.9,NA,66.589,NA,0,46.7734,-0.097,0.5932,-522.4665,0,0,0,1000
-Si(OH)4,NA,Si(OH)4,gas,AP14,NA,2019-02-22,CGL,cal,-296285.9,NA,82.784,NA,0,22.9685,37.6434,-4.4407,0,-2.7782,7.923E-09,3,1000
-As(OH)3,NA,As(OH)3,gas,AP14,NA,2019-02-22,CGL,cal,-143112.8,NA,73.599,NA,0,22.6338,-16.3623,-3.7213,0,-1.0194,2.7414E-09,3,1000
+B(OH)3,NA,B(OH)3,gas,AP14,NA,2019-02-22,CGL,cal,-222523.9,NA,66.589,NA,0,46.7734,-9.7E-05,59320,-522.4665,0,0,0,1000
+Si(OH)4,NA,Si(OH)4,gas,AP14,NA,2019-02-22,CGL,cal,-296285.9,NA,82.784,NA,0,22.9685,0.0376434,-444070,0,-2.7782E-05,7.923E-09,3,1000
+As(OH)3,NA,As(OH)3,gas,AP14,NA,2019-02-22,CGL,cal,-143112.8,NA,73.599,NA,0,22.6338,-0.0163623,-372130,0,-1.0194E-05,2.7414E-09,3,1000

Modified: pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRT92.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRT92.csv	2022-09-29 02:40:26 UTC (rev 746)
+++ pkg/CHNOSZ/inst/extdata/OBIGT/SUPCRT92.csv	2022-09-29 08:05:52 UTC (rev 747)
@@ -1,178 +1,178 @@
 name,abbrv,formula,state,ref1,ref2,date,model,E_units,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T
-aegerine,Agt,NaFe(SiO3)2,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,36.7,NA,64.37,46.16,19.31,-9.46,0,0,0,0,950
-aegerine,Agt,NaFe(SiO3)2,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-82.386,NA,34.6051,NA,64.37,52.42,10.01,-7.68,0,0,0,0,1050
-aegerine,Agt,NaFe(SiO3)2,cr3,HDNB78,OBIGT.1,1978-05-05,CGL,cal,478.346,NA,36.6502,NA,64.37,50.27,10.89,-7.68,0,0,0,0,1400
-akermanite,Ak,Ca2MgSi2O7,cr,HDNB78,SPRONS92.2,1990-03-15,CGL,cal,-879362,-926497,50.03,NA,92.81,60.09,11.4,-11.4,0,0,0,0,1700
-albite,Ab,Na(AlSi3)O8,cr,HDNB78,NA,1978-05-05,CGL,cal,-886308,-939680,49.51,NA,100.25,61.7,13.9,-15.01,0,0,0,0,473
-albite,Ab,Na(AlSi3)O8,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-886096.268,NA,53.9193,NA,100.25,81.88,3.554,-50.154,0,0,0,0,1200
-"albite,high",Hi-Ab,NaAlSi3O8,cr,HDNB78,NA,1978-05-05,CGL,cal,-884509,-937050,52.3,NA,100.43,61.7,13.9,-15.01,0,0,0,0,623
-"albite,high",Hi-Ab,NaAlSi3O8,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-884768.678,NA,50.4797,NA,100.43,64.17,13.9,-15.01,0,0,0,0,1400
-"albite,low",Lo-Ab,Na(AlSi3)O8,cr,HDNB78,NA,1978-05-05,CGL,cal,-886308,-939680,49.51,NA,100.07,61.7,13.9,-15.01,0,0,0,0,1400
-almandine,Alm,Fe3Al2Si3O12,cr,HDNB78,RH95.3,2020-07-06,CGL,cal,-1181142,-1258293,81.88,82.05,115.28,97.52,33.64,-18.73,0,0,0,0,848
-almandine,Alm,Fe3Al2Si3O12,cr2,HDNB78,OBIGT.1,2020-07-06,CGL,cal,-1181153.741,NA,78.21,NA,115.28,107.09,14.86,-10.63,0,0,0,0,1600
-"amesite,14A",14A-Am,Mg4Al2(Al2Si2)O10(OH)8,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,108.9,NA,205.4,172.59,34.98,-41.67,0,0,0,0,848
-"amesite,14A",14A-Am,Mg4Al2(Al2Si2)O10(OH)8,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,3.895,NA,110.1233,NA,205.4,169.4,41.24,-44.37,0,0,0,0,1000
-"amesite,7A",Ams-7A,Mg2Al(AlSi)O5(OH)4,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,52,NA,103,81.03,24.738,-20.23,0,0,0,0,1000
-"amorphous silica",Amor-Sl,SiO2,cr,HDNB78,NA,1978-05-05,CGL,cal,-202892,-214568,14.34,NA,29,5.93,47.2,-22.78,0,0,0,0,622
-analcime,Anl,NaAlSi2O6*H2O,cr,HDNB78,NA,1978-05-05,CGL,cal,-738098,-790193,56,NA,97.1,53.49,24.14,-8.88,0,0,0,0,1000
-"analcime,dehydrated",Dhyd-Anl,NaAlSi2O6,cr,HDNB78,NA,1978-05-05,CGL,cal,-674989,-714678,41.9,NA,89.1,42.09,24.14,-8.88,0,0,0,0,1000
-andalusite,And,Al2SiO5,cr,HDNB78,NA,1978-05-05,CGL,cal,-580587,-615866,22.2,NA,51.53,41.310833,6.292556,-12.392063,0,0,0,0,1043
-andradite,Adr,Ca3Fe2Si3O12,cr,HDNB78,SPRONS92.2,1990-03-15,CGL,cal,-1296819,-1380345,70.13,NA,131.85,113.532,15.636,-30.889,0,0,0,0,1100
-annite,Ann,KFe3(AlSi3)O10(OH)2,cr,HDNB78,NA,1978-05-05,CGL,cal,-1147156,-1232195,95.2,NA,154.32,106.43,29.77,-19.31,0,0,0,0,1000
-anorthite,An,Ca(Al2Si2)O8,cr,HDNB78,SPRONS92.2,1990-03-15,CGL,cal,-954078,-1007552,49.1,NA,100.79,63.311,14.794,-15.44,0,0,0,0,1700
-anthophyllite,Ath,Mg7Si8O22(OH)2,cr,HDNB78,NA,1978-05-05,CGL,cal,-2715430,-2888749,128.6,NA,264.4,180.682,60.574,-38.462,0,0,0,0,903
-anthophyllite,Ath,Mg7Si8O22(OH)2,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-2718479.297,NA,108.796,NA,264.4,197.542,41.614,-13.342,0,0,0,0,1258
-anthophyllite,Ath,Mg7Si8O22(OH)2,cr3,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-2719529.932,NA,105.9454,NA,264.4,199.522,41.614,-13.342,0,0,0,0,1800
-antigorite,Atg,Mg48Si34O85(OH)62,cr,HDNB78,NA,1978-05-05,CGL,cal,-15808020,-17070891,861.36,NA,1749.13,1228.45,513.76,-286.68,0,0,0,0,848
-antigorite,Atg,Mg48Si34O85(OH)62,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-15808027.845,NA,858.9133,NA,1749.13,1234.83,501.24,-281.28,0,0,0,0,1000
-aragonite,Arg,CaCO3,cr,HDNB78,PB82,1990-03-09,CGL,cal,-269683,-288531,21.56,NA,34.15,20.13,10.24,-3.34,0,0,0,0,600
-boehmite,Bhm,AlO(OH),cr,HDNB78,NA,1978-05-05,CGL,cal,-217250,-235078,11.58,NA,19.535,14.435,4.2,0,0,0,0,0,500
-brucite,Brc,Mg(OH)2,cr,HDNB78,NA,1978-05-05,CGL,cal,-199646,-221390,15.09,NA,24.63,24.147,4.0124,-6.11,0,0,0,0,900
-Ca-Al-pyroxene,Ca-Al-Px,CaAl(AlSi)O6,cr,HDNB78,SPRONS92.2,1990-03-15,CGL,cal,-742067,-783793,35,NA,63.5,54.13,6.42,-14.9,0,0,0,0,1400
-Ca-phillipsite,Ca-Php,Ca(Al2Si5)O14*5H2O,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,166.6,NA,265,145.82,52.67,-19.13,0,0,0,0,848
-Ca-phillipsite,Ca-Php,Ca(Al2Si5)O14*5H2O,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-3.895,NA,165.3767,NA,265,149.01,46.41,-16.43,0,0,0,0,1000
-calcite,Cal,CaCO3,cr,HDNB78,PB82,1990-03-09,CGL,cal,-269880,-288552,22.15,NA,36.934,24.98,5.24,-6.2,0,0,0,0,1200
-celadonite,Cln,K(MgAl)Si4O10(OH)2,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,74.9,NA,157.1,80.25,25.3,-18.54,0,0,0,0,1000
-chabazite,Cbz,Ca(Al2Si4)O12*6H2O,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,152.9,NA,247.76,146,44.47,-16.43,0,0,0,0,1000
-chalcedony,Cha,SiO2,cr,HDNB78,NA,1978-05-05,CGL,cal,-204276,-217282,9.88,NA,22.688,11.22,8.2,-2.7,0,0,0,0,848
-chloritoid,Cld,FeAl2SiO5(OH)2,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,42.1,NA,69.8,60.63,17.13,-13.63,0,0,0,0,1000
-chrysotile,Ctl,Mg3Si2O5(OH)4,cr,HDNB78,NA,1978-05-05,CGL,cal,-964871,-1043123,52.9,NA,108.5,75.82,31.6,-17.58,0,0,0,0,1000
-"clinochlore,14A",14A-Cnc,Mg5Al(AlSi3)O10(OH)8,cr,HDNB78,NA,1978-05-05,CGL,cal,-1961703,-2116964,111.2,NA,207.11,166.5,42.1,-37.47,0,0,0,0,900
-"clinochlore,7A",7A-Cnc,Mg5Al(AlSi3)O10(OH)8,cr,HDNB78,NA,1978-05-05,CGL,cal,-1957101,-2113197,106.5,NA,211.5,162.82,50.62,-40.88,0,0,0,0,848
-"clinochlore,7A",7A-Cnc,Mg5Al(AlSi3)O10(OH)8,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-1957104.895,NA,105.2767,NA,211.5,166.01,44.36,-38.18,0,0,0,0,900
-clinozoisite,Czo,Ca2Al3Si3O12(OH),cr,HDNB78,SPRONS92.2,1990-03-15,CGL,cal,-1549240,-1643781,70.64,NA,136.2,106.118,25.214,-27.145,0,0,0,0,700
-coesite,Cos,SiO2,cr,HDNB78,NA,1978-05-05,CGL,cal,-203541,-216614,9.65,NA,20.641,11,8.2,-2.7,0,0,0,0,848
-coesite,Cos,SiO2,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-203544.895,NA,8.4267,NA,20.641,14.19,1.94,0,0,0,0,0,2000
-"cordierite,dry",Crd,Mg2Al3(AlSi5)O18,cr,HDNB78,NA,1978-05-05,CGL,cal,-2061279,-2183199,97.33,NA,233.22,143.83,25.8,-38.6,0,0,0,0,1700
-"cordierite,hydrous",Hyd-Crd,Mg2Al3(AlSi5)O18*H2O,cr,HDNB78,NA,1978-05-05,CGL,cal,-2121350,-2255676,111.43,NA,241.22,155.23,25.8,-38.6,0,0,0,0,1700
-corundum,Crn,Al2O3,cr,HDNB78,NA,1978-05-05,CGL,cal,-374824,-397145,12.18,NA,25.575,27.49,2.82,-8.38,0,0,0,0,1800
-cristobalite,Crs,SiO2,cr,HDNB78,NA,1978-05-05,CGL,cal,-203895,-216755,10.372,NA,25.74,13.98,3.34,-3.81,0,0,0,0,543
-cristobalite,Crs,SiO2,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-203677.53,-216037.379,12.0495,NA,25.74,17.39,0.31,-9.89,0,0,0,0,2000
-"cristobalite,alpha",A-Crs,SiO2,cr,HDNB78,NA,1978-05-05,CGL,cal,-203895,-216755,10.372,NA,25.74,13.98,3.34,-3.81,0,0,0,0,1000
-"cristobalite,beta",B-Crs,SiO2,cr,HDNB78,NA,1978-05-05,CGL,cal,-203290,-215675,11.963,NA,27.38,17.39,0.31,-9.89,0,0,0,0,2000
-"cronstedtite,7A",7A-Csd,Fe2Fe(FeSi)O5(OH)4,cr,HDNB78,NA,1978-05-05,CGL,cal,NA,NA,73.5,NA,110.9,84.79,41.84,-12.476,0,0,0,0,950
-"cronstedtite,7A",7A-Csd,Fe2Fe(FeSi)O5(OH)4,cr2,HDNB78,OBIGT.1,1978-05-05,CGL,cal,-160.595,NA,69.3289,NA,110.9,97.3,23.24,-8.93,0,0,0,0,1050
-"cronstedtite,7A",7A-Csd,Fe2Fe(FeSi)O5(OH)4,cr3,HDNB78,OBIGT.1,1978-05-05,CGL,cal,957.096,NA,73.4065,NA,110.9,93.01,25,-8.93,0,0,0,0,1500
-cummingtonite,Cum,Mg7Si8O22(OH)2,cr,HDNB78,NA,2015-08-16,CGL,cal,NA,NA,127.5,NA,271.9,185.24,58.61,-41.66,0,0,0,0,800
-"daphnite,14A",Dph-14A,Fe5Al(AlSi3)O10(OH)8,cr,HDNB78,SLOP98.2,1978-05-05,CGL,cal,-1550482,-1695426,142.5,NA,213.42,176.21,43.76,-33.82,0,0,0,0,1000
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/chnosz -r 747


More information about the CHNOSZ-commits mailing list