[CHNOSZ-commits] r661 - in pkg/CHNOSZ: . R inst inst/extdata/OBIGT inst/extdata/adds inst/extdata/thermo man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 22 10:35:24 CET 2021


Author: jedick
Date: 2021-03-22 10:35:23 +0100 (Mon, 22 Mar 2021)
New Revision: 661

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/R/thermo.R
   pkg/CHNOSZ/R/util.units.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/TODO
   pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv
   pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv
   pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv
   pkg/CHNOSZ/inst/extdata/thermo/stoich.csv.xz
   pkg/CHNOSZ/man/thermo.Rd
   pkg/CHNOSZ/vignettes/OBIGT.bib
Log:
Add 'no.organics' argument to OBIGT() and willemite to OBIGT/inorganic_cr.csv


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/DESCRIPTION	2021-03-22 09:35:23 UTC (rev 661)
@@ -1,6 +1,6 @@
 Date: 2021-03-21
 Package: CHNOSZ
-Version: 1.4.0-30
+Version: 1.4.0-31
 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/diagram.R
===================================================================
--- pkg/CHNOSZ/R/diagram.R	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/R/diagram.R	2021-03-22 09:35:23 UTC (rev 661)
@@ -47,7 +47,7 @@
   if(!(efun %in% c("affinity", "equilibrate") | grepl("solubilit", efun)))
     stop("'eout' is not the output from affinity(), equilibrate(), solubility(), or solubilities()")
   # For solubilities(), default type is loga.balance 20210303
-  if(identical(efun, "solubilities") & missing(type)) type <- "loga.balance"
+  if(grepl("solubilities", efun) & missing(type)) type <- "loga.balance"
 
   ## 'type' can be:
   #    'auto'                - property from affinity() (1D) or maximum affinity (affinity 2D) (aout) or loga.equil (eout)
@@ -203,7 +203,15 @@
         else if(as.residue) pv[[i]] <- pv[[i]] + eout$species$logact[i] / n.balance[i]
       }
     }
-    predominant <- which.pmax(pv)
+    if(grepl("solubilities", efun)) {
+      # For solubilites of multiple minerals, find the minimum value (most stable mineral) 20210321
+      mypv <- Map("-", pv)
+      predominant <- which.pmax(mypv)
+    } else {
+      # For all other diagrams, we want the maximum value (i.e. maximum affinity method)
+      predominant <- which.pmax(pv)
+    }
+
     # show water stability region
     if((is.null(limit.water) | isTRUE(limit.water)) & nd==2) {
       wl <- water.lines(eout, plot.it=FALSE)

Modified: pkg/CHNOSZ/R/thermo.R
===================================================================
--- pkg/CHNOSZ/R/thermo.R	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/R/thermo.R	2021-03-22 09:35:23 UTC (rev 661)
@@ -36,18 +36,25 @@
 }
 
 # load default thermodynamic data (OBIGT) in thermo
-OBIGT <- function() {
+OBIGT <- function(no.organics = FALSE) {
   # we only work if thermo is already in the CHNOSZ environment
   if(!"thermo" %in% ls(CHNOSZ)) stop("The CHNOSZ environment doesn't have a \"thermo\" object. Try running reset()")
   # create OBIGT data frame
-  sources_aq <- paste0(c("H2O", "inorganic", "organic", "biotic"), "_aq")
-  sources_cr <- paste0(c("inorganic", "organic", "Berman"), "_cr")
-  sources_liq <- paste0(c("organic"), "_liq")
-  sources_gas <- paste0(c("inorganic", "organic"), "_gas")
-  sources <- c(sources_aq, sources_cr, sources_gas, sources_liq)
+  if(no.organics) {
+    sources_aq <- paste0(c("H2O", "inorganic"), "_aq")
+    sources_cr <- paste0(c("inorganic", "Berman"), "_cr")
+    sources_gas <- paste0(c("inorganic"), "_gas")
+    sources <- c(sources_aq, sources_cr, sources_gas)
+  } else {
+    sources_aq <- paste0(c("H2O", "inorganic", "organic", "biotic"), "_aq")
+    sources_cr <- paste0(c("inorganic", "organic", "Berman"), "_cr")
+    sources_liq <- paste0(c("organic"), "_liq")
+    sources_gas <- paste0(c("inorganic", "organic"), "_gas")
+    sources <- c(sources_aq, sources_cr, sources_gas, sources_liq)
+  }
   OBIGTdir <- system.file("extdata/OBIGT/", package="CHNOSZ")
   # need explicit "/" for Windows
-  sourcefiles <- paste0(OBIGTdir, "/", c(sources_aq, sources_cr, sources_gas, sources_liq), ".csv")
+  sourcefiles <- paste0(OBIGTdir, "/", sources, ".csv")
   datalist <- lapply(sourcefiles, read.csv, as.is=TRUE)
   OBIGT <- do.call(rbind, datalist)
   # also read references file
@@ -60,7 +67,7 @@
   # place modified thermo in CHNOSZ environment
   assign("thermo", thermo, CHNOSZ)
   # give a summary of some of the data
-  message(paste("OBIGT: loading default database with",
+  message(paste("OBIGT: loading", ifelse(no.organics, "inorganic", "default"), "database with",
     nrow(thermo$OBIGT[thermo$OBIGT$state=="aq",]),
     "aqueous,", nrow(thermo$OBIGT), "total species"))
   # warn if there are duplicated species

Modified: pkg/CHNOSZ/R/util.units.R
===================================================================
--- pkg/CHNOSZ/R/util.units.R	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/R/util.units.R	2021-03-22 09:35:23 UTC (rev 661)
@@ -46,7 +46,7 @@
 
   # process a list value if it's the output from solubility 20190525
   if(is.list(value) & !is.data.frame(value)) {
-    if(!isTRUE(value$fun == "solubility")) stop("'value' is a list but is not the output from solubility()")
+    if(!isTRUE(value$fun %in% c("solubility", "solubilities"))) stop("'value' is a list but is not the output from solubility()")
     if(!is.character(units)) stop("please specify a character argument for the destination units (e.g. ppm or logppm)")
     # determine the element from 'balance' or 'in.terms.of', if it's available
     element <- value$in.terms.of

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2021-03-22 09:35:23 UTC (rev 661)
@@ -10,7 +10,7 @@
 \newcommand{\s}{\ifelse{latex}{\eqn{_{#1}}}{\ifelse{html}{\out{<sub>#1</sub>}}{#1}}}
 \newcommand{\S}{\ifelse{latex}{\eqn{^{#1}}}{\ifelse{html}{\out{<sup>#1</sup>}}{^#1}}}
 
-\section{Changes in CHNOSZ version 1.4.0-28 (2021-03-20)}{
+\section{Changes in CHNOSZ version 1.4.0-31 (2021-03-22)}{
 
   \subsection{NEW FEATURES}{
     \itemize{
@@ -23,9 +23,12 @@
       minimum) solubility for multiple minerals. Calculations for multiple
       minerals are also now used in \samp{demo/zinc.R}.
 
-      \item Restore \samp{lty.aq} and \samp{lty.cr} arguments to
+      \item Restore \strong{lty.aq} and \strong{lty.cr} arguments to
       \code{diagram()} to control plotting of aq-aq and cr-cr field boundaries.
 
+      \item Add \strong{no.organics} argument to \code{OBIGT()} to load the
+      thermodynamic database without organic species.
+
     }
   }
 
@@ -32,23 +35,29 @@
   \subsection{DATA UPDATES}{
     \itemize{
 
-      \item Use standard abbreviations for hematite (Hem) and magnetite (Mag) in
-      \samp{OBIGT/Berman_cr.csv}.
+      \item \samp{OBIGT/Berman_cr.csv}: Use standard abbreviations for hematite
+      (Hem) and magnetite (Mag).
 
-      \item Add properties of aqueous fatty acids and saccharides to
-      \samp{OBIGT/organic_aq.csv} and associated \samp{demo/E_coli.R} (Gibbs
-      energy of biomass synthesis in \emph{E. coli}, after
+      \item \samp{OBIGT/organic_aq.csv}: Add properties of aqueous fatty acids
+      and saccharides and add associated \samp{demo/E_coli.R} (Gibbs energy of
+      biomass synthesis in \emph{E. coli}, after
       \href{https://doi.org/10.1038/ismej.2015.227}{LaRowe and Amend, 2016}).
 
-      \item Add properties of aqueous Nb and Ta species
-      (\href{https://doi.org/10.1016/j.gca.2020.04.009}{Akinfiev et al., 2020})
-      to \samp{OBIGT/inorganic_aq.csv}.
+      \item \samp{OBIGT/inorganic_aq.csv}: Add properties of aqueous Nb and Ta
+      species from \href{https://doi.org/10.1016/j.gca.2020.04.009}{Akinfiev et
+        al., 2020}.
+      
+      \item \samp{OBIGT/inorganic_cr.csv}: Add willemite (Zn\s{2}SiO\s{4}) from
+      \href{https://doi.org/10.3133/b2131}{Robie and Hemingway, 1995} and
+      \href{https://doi.org/10.1007/978-3-662-02293-1}{Barin et al., 1977}
+      (heat capacity equation).
 
-      \item Rename \samp{CDC2_HUMAN} to \samp{CDK1_HUMAN} (UniProt:
-      \href{https://www.uniprot.org/uniprot/P06493}{P06493}) in
-      \samp{thermo/protein.csv}.
+      \item \samp{OBIGT/inorganic_cr.csv}: Move alunite here from
+      \samp{SUPCRT92.csv}.
 
-      \item Move alunite from \samp{SUPCRT92.csv} to \samp{inorganic_cr.csv}.
+      \item \samp{thermo/protein.csv}: Rename \samp{CDC2_HUMAN} to
+      \samp{CDK1_HUMAN} (UniProt:
+      \href{https://www.uniprot.org/uniprot/P06493}{P06493}).
 
     }
   }

Modified: pkg/CHNOSZ/inst/TODO
===================================================================
--- pkg/CHNOSZ/inst/TODO	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/inst/TODO	2021-03-22 09:35:23 UTC (rev 661)
@@ -67,10 +67,6 @@
 
 - Remove 'bases2' argument from mosaic() (old backward compatibility)
 
-[20210309]
-
-- Add argument to OBIGT() to exclude data files for organic species.
-
 [20210312]
 
 - Don't use z.T = NA to trigger AkDi model (makes the more common use case of

Modified: pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/inst/extdata/OBIGT/inorganic_cr.csv	2021-03-22 09:35:23 UTC (rev 661)
@@ -149,3 +149,4 @@
 Co-pentlandite,NA,Co9S8,cr,VC78,MP20,2020-10-06,cal,-199500,-203400,125,96.67,141.78,96.67,0,0,0,0,0,0,1107
 cobalt,NA,Co,cr,RH95,NA,2020-10-06,J,0,0,30.04,24.81,6.67,0,41.844,-1.5646,268.75,-1.6498,0,0,700
 wustite,NA,Fe0.947O,cr,RH95,NA,2020-11-10,J,-244900,-266300,56.6,48.13,12.04,-19.3,30.17,-25.33,1501,0,0,0,1652
+willemite,NA,Zn2SiO4,cr,RH95,BKK77,2021-03-22,J,-1523100,-1636700,131.4,123.3,52.42,144.892,36.945,-30.292,0,0,0,0,1785

Modified: pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv	2021-03-22 09:35:23 UTC (rev 661)
@@ -5,6 +5,7 @@
 Pan70,"L. B. Pankratz",1970,"U. S. Bureau of Mines Report of Investigations 7430",chlorargyrite,https://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",https://www.worldcat.org/oclc/14154292
 BK73,"I. Barin and O. Knacke",1973,"Thermochemical Properties of Inorganic Substances","scheelite Cp",https://www.worldcat.org/oclc/695258
+BKK77,"I. Barin, O. Knacke and O. Kubaschewski",1977,"Thermochemical Properties of Inorganic Substances: Supplement","willemite Cp",https://www.worldcat.org/oclc/695258
 HDNB78,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","data for minerals and phase transitions",https://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",https://www.worldcat.org/oclc/13594862
 HDNB78.2,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229","celestite V and Cp parameters",https://www.worldcat.org/oclc/13594862

Modified: pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv	2021-03-22 09:35:23 UTC (rev 661)
@@ -270,24 +270,25 @@
 "OBIGT",2037,"dawsonite","cr","J",,,19466
 "OBIGT",2039,"ferberite","cr","J",1.21,,
 "OBIGT",2052,"Co-pentlandite","cr","cal",,,-3630
-"OBIGT",2073,"octadecane","cr","cal",-2.63,,
-"OBIGT",2074,"nonadecane","cr","cal",-13.32,,
-"OBIGT",2075,"eicosane","cr","cal",-2.79,,
-"OBIGT",2076,"heneicosane","cr","cal",-8.61,,
-"OBIGT",2077,"docosane","cr","cal",-2.63,,
-"OBIGT",2078,"tricosane","cr","cal",-5.22,,
-"OBIGT",2079,"tetracosane","cr","cal",-2.02,,
-"OBIGT",2080,"pentacosane","cr","cal",-2.93,,
-"OBIGT",2081,"hexacosane","cr","cal",-1.29,,
-"OBIGT",2082,"heptacosane","cr","cal",-1.23,,
-"OBIGT",2134,"carbazole","cr","cal",-43.39,,
-"OBIGT",2175,"triphenylene","cr","cal",,,541
-"OBIGT",2488,"deoxyadenosine","cr","cal",,,-2977
-"OBIGT",2646,"ethylene","gas","cal",-4.59,,
-"OBIGT",2656,"3,5-dimethylphenol","gas","cal",,,628
-"OBIGT",2966,"nonacontane","liq","cal",,,635
-"OBIGT",2973,"2-methyloctane","liq","cal",10,,
-"OBIGT",3386,"5,6-dithiadecane","liq","cal",2,,
+"OBIGT",2055,"willemite","cr","J",-1.47,,
+"OBIGT",2074,"octadecane","cr","cal",-2.63,,
+"OBIGT",2075,"nonadecane","cr","cal",-13.32,,
+"OBIGT",2076,"eicosane","cr","cal",-2.79,,
+"OBIGT",2077,"heneicosane","cr","cal",-8.61,,
+"OBIGT",2078,"docosane","cr","cal",-2.63,,
+"OBIGT",2079,"tricosane","cr","cal",-5.22,,
+"OBIGT",2080,"tetracosane","cr","cal",-2.02,,
+"OBIGT",2081,"pentacosane","cr","cal",-2.93,,
+"OBIGT",2082,"hexacosane","cr","cal",-1.29,,
+"OBIGT",2083,"heptacosane","cr","cal",-1.23,,
+"OBIGT",2135,"carbazole","cr","cal",-43.39,,
+"OBIGT",2176,"triphenylene","cr","cal",,,541
+"OBIGT",2489,"deoxyadenosine","cr","cal",,,-2977
+"OBIGT",2647,"ethylene","gas","cal",-4.59,,
+"OBIGT",2657,"3,5-dimethylphenol","gas","cal",,,628
+"OBIGT",2967,"nonacontane","liq","cal",,,635
+"OBIGT",2974,"2-methyloctane","liq","cal",10,,
+"OBIGT",3387,"5,6-dithiadecane","liq","cal",2,,
 "DEW",8,"AlO2(SiO2)-","aq","cal",,,-897
 "DEW",17,"BO(OH)","aq","cal",,,-1111
 "DEW",19,"Ca(HCO3)+","aq","cal",,,-2971

Modified: pkg/CHNOSZ/inst/extdata/thermo/stoich.csv.xz
===================================================================
(Binary files differ)

Modified: pkg/CHNOSZ/man/thermo.Rd
===================================================================
--- pkg/CHNOSZ/man/thermo.Rd	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/man/thermo.Rd	2021-03-22 09:35:23 UTC (rev 661)
@@ -25,11 +25,12 @@
 
 \usage{
   reset()
-  OBIGT()
+  OBIGT(no.organics = FALSE)
   thermo(...)
 }
 
 \arguments{
+  \item{no.organics}{logical, exclude data files for organic and biotic species?}
   \item{...}{list, one or more arguments whose names correspond to the setting to modify}
 }
 
@@ -248,7 +249,7 @@
 }
 
 \examples{
-## where are the data files in CHNOSZ?
+## Where are the data files in CHNOSZ?
 system.file("extdata", package="CHNOSZ")
 # What files make up OBIGT?
 # Note: file names with _aq, _cr, _gas, or _liq
@@ -255,24 +256,24 @@
 # are used in the default database
 dir(system.file("extdata/OBIGT", package = "CHNOSZ"))
 
-## exploring thermo()$OBIGT
-# what physical states there are
+## Exploring thermo()$OBIGT
+# What physical states are present
 unique(thermo()$OBIGT$state)
-# formulas of ten random species
+# Formulas of ten random species
 n <- nrow(thermo()$OBIGT)
 thermo()$OBIGT$formula[runif(10)*n]
 
-## adding an element
+## Adding an element
 old <- thermo()$element
-# element symbol, state, source (can be anything),
+# Element symbol, state, source (can be anything),
 # mass, entropy, and number in compound
 Xprops <- data.frame(element = "X", state = "cr",
   source = "user", mass = 100, s = 100, n = 1)
 new <- rbind(old, Xprops)
 thermo(element = new)
-# now "X" is recognized as an element in other functions
+# Now "X" is recognized as an element in other functions
 mass("X10")
-# restore default settings to remove X
+# Restore default settings to remove X
 reset()
 }
 

Modified: pkg/CHNOSZ/vignettes/OBIGT.bib
===================================================================
--- pkg/CHNOSZ/vignettes/OBIGT.bib	2021-03-21 10:28:45 UTC (rev 660)
+++ pkg/CHNOSZ/vignettes/OBIGT.bib	2021-03-22 09:35:23 UTC (rev 661)
@@ -1475,6 +1475,15 @@
   doi       = {10.1021/acsearthspacechem.9b00016},
 }
 
+ at Book{BKK77,
+  author    = {Barin, Ihsan and Knacke, Ottmar and Kubaschewski, Oswald K.},
+  publisher = {Springer-Verlag},
+  title     = {Thermochemical Properties of Inorganic Substances: Supplement},
+  year      = {1977},
+  address   = {Berlin},
+  doi       = {10.1007/978-3-662-02293-1},
+}
+
 @Article{LA19,
   author    = {Douglas E. LaRowe and Jan P. Amend},
   journal   = {Geomicrobiology Journal},



More information about the CHNOSZ-commits mailing list