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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 8 10:42:37 CET 2022


Author: jedick
Date: 2022-02-08 10:42:37 +0100 (Tue, 08 Feb 2022)
New Revision: 703

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/basis.R
   pkg/CHNOSZ/inst/CHECKLIST
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/extdata/OBIGT/organic_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
Log:
OBIGT: Add pyrobitumen from Helgeson et al. (2009)


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/DESCRIPTION	2022-02-08 09:42:37 UTC (rev 703)
@@ -1,6 +1,6 @@
 Date: 2022-02-08
 Package: CHNOSZ
-Version: 1.4.1-28
+Version: 1.4.1-29
 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/basis.R
===================================================================
--- pkg/CHNOSZ/R/basis.R	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/R/basis.R	2022-02-08 09:42:37 UTC (rev 703)
@@ -1,10 +1,10 @@
 # CHNOSZ/basis.R
-# set up the basis species of a thermodynamic system
+# Set up the basis species of a thermodynamic system
 
 basis <- function(species=NULL, state=NULL, logact=NULL, delete=FALSE) {
   thermo <- get("thermo", CHNOSZ)
   oldbasis <- thermo$basis
-  ## delete the basis species if requested
+  ## Delete the basis species if requested
   if(delete | identical(species, "")) {
     thermo$basis <- NULL
     thermo$species <- NULL
@@ -11,38 +11,38 @@
     assign("thermo", thermo, CHNOSZ)
     return(invisible(oldbasis))
   }
-  ## return the basis definition if requested
+  ## Return the basis definition if requested
   if(is.null(species)) return(oldbasis)
-  ## from now on we need something to work with
+  ## From now on we need something to work with
   if(length(species)==0) stop("species argument is empty")
-  # is the species one of the preset keywords?
+  # Is the species one of the preset keywords?
   if(species[1] %in% preset.basis()) return(preset.basis(species[1]))
-  # the species names/formulas have to be unique
+  # The species names/formulas have to be unique
   if(!length(unique(species))==length(species)) stop("species names are not unique")
-  ## processing 'state' and 'logact' arguments
-  # they should be same length as species
+  ## Processing 'state' and 'logact' arguments
+  # They should be same length as species
   if(!is.null(state)) state <- rep(state, length.out=length(species))
   if(!is.null(logact)) logact <- rep(logact, length.out=length(species))
-  # results should be identical for
+  # Results should be identical for
   # basis(c('H2O','CO2','H2'), rep('aq',3), c(0,-3,-3))
   # basis(c('H2O','CO2','H2'), c(0,-3,-3), rep('aq',3))
-  # first of all, do we have a third argument?
+  # First of all, do we have a third argument?
   if(!is.null(logact)) {
-    # does the 3rd argument look like states?
+    # Does the 3rd argument look like states?
     if(is.character(logact[1])) {
-      # swap the arguments into their correct places
+      # Swap the arguments into their correct places
       tmp <- logact
       logact <- state
       state <- tmp
     }
   } else {
-    # if the second argument is numeric, treat it like logacts
+    # If the second argument is numeric, treat it like logacts
     if(is.numeric(state[1])) {
       logact <- state
       state <- NULL
     }
   }
-  ## processing 'species' argument
+  ## Processing 'species' argument
   # pH transformation
   if("pH" %in% species) {
     logact[species=="pH"] <- -logact[species=="pH"]
@@ -54,61 +54,61 @@
     if(!is.null(logact)) species[species=="pe"] <- "e-"
   }
   if("Eh" %in% species) {
-    # 20090209 should be careful with this conversion as it's only for 25 degC
-    # to be sure, just don't call species("Eh")
+    # 20090209 Should be careful with this conversion as it's only for 25 degC
+    # To be sure, just don't call species("Eh")
     if(!is.null(logact)) logact[species=="Eh"] <- -convert(logact[species=="Eh"],"pe")
     species[species=="Eh"] <- "e-"
   }
-  ## if all species are in the existing basis definition, 
+  ## If all species are in the existing basis definition, 
   ## *and* at least one of state or logact is not NULL
   ## modify the states and/or logacts of the existing basis species
   if(all(species %in% rownames(oldbasis)) | all(species %in% oldbasis$ispecies)) 
     if(!is.null(state) | !is.null(logact))
       return(mod.basis(species, state, logact))
-  ## we're on to making a new basis definition
+  ## We're on to making a new basis definition
   # use default logacts if they aren't present
   if(is.null(logact)) logact <- rep(0, length(species))
-  # if species argument is numeric, it's species indices
+  # If species argument is numeric, it's species indices
   if(is.numeric(species[1])) {
     ispecies <- species
     ina <- ispecies > nrow(thermo$OBIGT)
   } else {
-    # get species indices using states from the argument, or default states
+    # Get species indices using states from the argument, or default states
     if(!is.null(state)) ispecies <- suppressMessages(info(species, state))
     else ispecies <- suppressMessages(info(species))
-    # check if we got all the species
+    # Check if we got all the species
     ina <- is.na(ispecies)
     # info() returns a list if any of the species had multiple approximate matches
-    # we don't accept any of those
+    # We don't accept any of those
     if(is.list(ispecies)) ina <- ina | sapply(ispecies,length) > 1
   }
   if(any(ina)) stop(paste("species not available:", paste(species[ina], "(", state[ina], ")", sep="", collapse=" ")))
-  # load new basis species
+  # Load new basis species
   return(put.basis(ispecies, logact))
 }
 
 ### unexported functions ###
 
-# to add the basis to thermo()$OBIGT
+# To add the basis to thermo()$OBIGT
 put.basis <- function(ispecies, logact = rep(NA, length(ispecies))) {
   thermo <- get("thermo", CHNOSZ)
   state <- thermo$OBIGT$state[ispecies]
-  # make the basis matrix, revised 20120114
-  # get the elemental makeup of each species,
+  # Make the basis matrix, revised 20120114
+  # Get the elemental makeup of each species,
   # counting zero for any element that only appears in other species in the set
   comp <- makeup(ispecies, count.zero=TRUE)
-  # turn the list into a matrix
+  # Turn the list into a matrix
   comp <- sapply(comp, c)
-  # transpose to get put basis species on the rows
+  # Transpose to get put basis species on the rows
   comp <- t(comp)
-  # note, makeup(count.zero=TRUE) above gave elements (colnames) sorted alphabetically
+  # Note, makeup(count.zero=TRUE) above gave elements (colnames) sorted alphabetically
   # rownames identify the species
   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
+  # This is needed for affinity() to understand a 'pe' or 'Eh' variable
   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
+  # Now check it for validity of basis species
+  # The first test: matrix is square
   if( nrow(comp) > ncol(comp) ) {
     if("Z" %in% colnames(comp)) stop("the number of basis species is greater than the number of elements and charge")
     else stop("the number of basis species is greater than the number of elements")
@@ -117,29 +117,28 @@
     if("Z" %in% colnames(comp)) stop("the number of basis species is less than the number of elements and charge")
     else stop("the number of basis species is less than the number of elements")
   }
-  # the second test: matrix is invertible
+  # The second test: matrix is invertible
   if(inherits(tryCatch(solve(comp), error = identity), "error")) 
     stop("singular stoichiometric matrix")
-  # store the basis definition in thermo()$basis, including
+  # Store the basis definition in thermo()$basis, including
   # both numeric and character data, so we need to use a data frame
   comp <- cbind(as.data.frame(comp), ispecies, logact, state, stringsAsFactors=FALSE)
-  # ready to assign to the global thermo object
+  # Ready to assign to the global thermo object
   thermo$basis <- comp
   assign("thermo", thermo, CHNOSZ)
-  # remove the species since there's no guarantee the
-  # new basis includes all their elements
+  # Remove the species since there's no guarantee the new basis includes all their elements
   species(delete=TRUE)
   return(thermo$basis)
 }
 
-# modify the states or logact values in the existing basis definition
+# Modify the states or logact values in the existing basis definition
 mod.basis <- function(species, state=NULL, logact=NULL) {
   thermo <- get("thermo", CHNOSZ)
-  # the basis must be defined
+  # The basis must be defined
   if(is.null(thermo$basis)) stop("basis is not defined")
-  # loop over each species to modify
+  # Loop over each species to modify
   for(i in 1:length(species)) {
-    # which basis species are we looking at?
+    # Which basis species are we looking at?
     if(is.numeric(species)) {
       ib <- match(species[i], thermo$basis$ispecies)
       if(is.na(ib)) stop(paste(species[i],"is not a species index of one of the basis species"))
@@ -147,13 +146,12 @@
       ib <- match(species[i], rownames(thermo$basis))
       if(is.na(ib)) stop(paste(species[i],"is not a formula of one of the basis species"))
     }
-    # first modify the state
+    # First modify the state
     if(!is.null(state)) {
       if(state[i] %in% thermo$buffer$name) {
-        # this is the name of a buffer
+        # This is the name of a buffer
         ibuff <- which(as.character(thermo$buffer$name)==state[i])
-        # check that each species in the buffer is compositionally
-        # compatible with the basis definition
+        # Check that each species in the buffer is compositionally compatible with the basis definition
         for(k in 1:length(ibuff)) {
           ispecies <- suppressMessages(info(as.character(thermo$buffer$species)[ibuff[k]],
             as.character(thermo$buffer$state)[ibuff[k]]))
@@ -167,15 +165,15 @@
         }
         thermo$basis$logact[ib] <- state[i]
       } else {
-        # first, look for a species with the same _name_ in the requested state
+        # 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]))
         if(is.na(ispecies) | is.list(ispecies)) {
-          # if that failed, look for a species with the same _formula_ in the requested state
+          # 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]))
           if(is.na(ispecies) | is.list(ispecies)) {
-            # if that failed, we're out of luck
+            # 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"))
           }
@@ -184,27 +182,27 @@
         thermo$basis$state[ib] <- state[i]
       }
     } 
-    # then modify the logact
+    # Then modify the logact
     if(!is.null(logact)) {
-      # allow this to be non-numeric in case we're called by swap.basis() while a buffer is active  20181109
+      # Allow this to be non-numeric in case we're called by swap.basis() while a buffer is active  20181109
       if(can.be.numeric(logact[i])) thermo$basis$logact[ib] <- as.numeric(logact[i])
       else thermo$basis$logact[ib] <- logact[i]
     }
-    # assign the result to the CHNOSZ environment
+    # Assign the result to the CHNOSZ environment
     assign("thermo", thermo, CHNOSZ)
   }
   return(thermo$basis)
 } 
 
-# to load a preset basis definition by keyword
+# To load a preset basis definition by keyword
 preset.basis <- function(key=NULL) {
-  # the available keywords
+  # The available keywords
   basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "CHNOPSe", "MgCHNOPS+", "MgCHNOPSe", "FeCHNOS", "FeCHNOS+", "QEC4", "QEC", "QEC+", "QCa", "QCa+")
-  # just list the keywords if none is specified
+  # Just list the keywords if none is specified
   if(is.null(key)) return(basis.key)
-  # delete any previous basis definition
+  # Delete any previous basis definition
   basis("")
-  # match the keyword to the available ones
+  # 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"))
   if(ibase==1) species <- c("CO2", "H2O", "NH3", "H2S", "oxygen")
@@ -220,24 +218,24 @@
   else if(ibase==12) species <- c("glutamine", "glutamic acid", "cysteine", "H2O", "oxygen", "H+")
   else if(ibase==13) species <- c("glutamine", "cysteine", "acetic acid", "H2O", "oxygen")
   else if(ibase==14) species <- c("glutamine", "cysteine", "acetic acid", "H2O", "oxygen", "H+")
-  # get the preset logact
+  # Get the preset logact
   logact <- preset.logact(species)
-  # for QEC4, we use logact = -4 for the amino acids
+  # For QEC4, we use logact = -4 for the amino acids
   if(key=="QEC4") logact[1:3] <- -4
-  # load the species and return the result
+  # Load the species and return the result
   return(basis(species, logact))
 }
 
-# logarithms of activities for preset basis definitions
+# Logarithms of activities for preset basis definitions
 preset.logact <- function(species) {
   bases <- c("H2O", "CO2", "NH3", "H2S", "oxygen", "H+", "e-", "Fe2O3",
              "glutamine", "glutamic acid", "cysteine")
-  # values for QEC amino acids from Dick, 2017 (http://doi.org/10.1101/097667)
+  # Values for QEC amino acids from Dick, 2017 (http://doi.org/10.1101/097667)
   logact <- c(0, -3, -4, -7, -80, -7, -7, 0,
               -3.2, -4.5, -3.6)
   ibase <- match(species, bases)
   logact <- logact[ibase]
-  # any unmatched species gets a logarithm of activity of -3
+  # Any unmatched species gets a logarithm of activity of -3
   logact[is.na(logact)] <- -3
   return(logact)
 }

Modified: pkg/CHNOSZ/inst/CHECKLIST
===================================================================
--- pkg/CHNOSZ/inst/CHECKLIST	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/inst/CHECKLIST	2022-02-08 09:42:37 UTC (rev 703)
@@ -38,7 +38,7 @@
   (not used elsewhere in CHNOSZ, but helpful to see which
   species entries have self inconsistencies):
   co <- check.OBIGT()
-  write.csv(co, "OBIGT_check.csv", row.names=FALSE, na="")
+  write.csv(co, "OBIGT_check.csv", row.names = FALSE, na = "")
 
 ******************
 Updating vignettes

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2022-02-08 09:42:37 UTC (rev 703)
@@ -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.1-28 (2022-02-08)}{
+\section{Changes in CHNOSZ version 1.4.1-29 (2022-02-08)}{
 
   \subsection{PLANNED API CHANGE}{
     \itemize{
@@ -56,11 +56,15 @@
       \href{https://doi.org/10.2475/07.2017.01}{Miron et al. (2017)} to
       \file{GEMSFIT.csv}.
       
-      \item Fix formula of CaCl\s{2} in \file{DEW.csv}. Thanks to Grayson Boyer.
-
+      \item Add pyrobitumen (C\s{54}H\s{42}) from
+      \href{https://doi.org/10.1016/j.gca.2008.03.004}{Helgeson et al.  (2009)}
+      to \file{organic_cr.csv}.
+      
       \item Move Ar, Xe, CH\s{4}, and CO\s{2} from \file{organic_aq.csv} to
       \file{inorganic_aq.csv}.
 
+      \item Fix formula of CaCl\s{2} in \file{DEW.csv}. Thanks to Grayson Boyer.
+
       \item Remove \file{OldAA.csv} (superseded thermodynamic parameters for
       amino acids). This file is now available in the
       \href{https://github.com/jedick/JMDplots}{JMDplots} package.

Modified: pkg/CHNOSZ/inst/extdata/OBIGT/organic_cr.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/OBIGT/organic_cr.csv	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/inst/extdata/OBIGT/organic_cr.csv	2022-02-08 09:42:37 UTC (rev 703)
@@ -478,3 +478,4 @@
 leucylglycine,NA,C8H16N2O3,cr,LD12,NA,2011-09-12,cal,-112356.6,-205688.3,67.16,61.23,153.6,10.263,170.98,0,0,0,0,0,NA
 4-hydroxyproline,NA,C5H9NO3,cr,LD12,NA,2011-09-12,cal,-107504.8,-168212.2,40.2,50.02,95.34,-37.476,293.5,0,0,0,0,0,NA
 5-hydroxylysine,NA,C6H14N2O3,cr,LD12,NA,2011-09-12,cal,-118092.7,-204732.3,55.66,64.29,132.5,-37.763,342.26,0,0,0,0,0,NA
+pyrobitumen,NA,C54H42,cr,HRMNS09,NA,2022-02-08,cal,213538,46139,168.52,NA,596.9,-130.81,951,27.16,0,0,0,0,NA

Modified: pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/inst/extdata/OBIGT/refs.csv	2022-02-08 09:42:37 UTC (rev 703)
@@ -170,7 +170,7 @@
 PPB+08,"E. Perfetti et al.",2008,"Geochim. Cosmochim. Acta 72, 713-731","arsenopyrite, loellingite, and westerveldite",https://doi.org/10.1016/j.gca.2007.11.017
 PPB+08.1,"E. Perfetti et al.",2008,"Geochim. Cosmochim. Acta 72, 713-731","As(OH)<sub>3</sub> and AsO(OH)<sub>3</sub>",https://doi.org/10.1016/j.gca.2007.11.017
 GM09,"K.-D. Grevel and J. Majzlan",2009,"Geochim. Cosmochim. Acta 73, 6805-6815","kieserite, starkeyite, hexahydrite, and epsomite",https://doi.org/10.1016/j.gca.2009.08.005
-HRMNS09,"H. C. Helgeson, L. Richard et al.",2009,"Geochim. Cosmochim. Acta 73, 594-695",kerogens,https://doi.org/10.1016/j.gca.2008.03.004
+HRMNS09,"H. C. Helgeson, L. Richard et al.",2009,"Geochim. Cosmochim. Acta 73, 594-695","kerogens (C128, C292, C406, C415, C515) and pyrobitumen (C<sub>54</sub>H<sub>42</sub>)",https://doi.org/10.1016/j.gca.2008.03.004
 LRB09,"K. H. Lemke, R. J. Rosenbauer and D. K. Bird",2009,"Astrobiology 9, 141-146","diglycine and diketopiperazine",https://doi.org/10.1089/ast.2008.0166
 AML10,"M. Accornero, L. Marini and M. Lelli",2010,"Appl. Geochem. 25, 242-260","metal-chromate complexes",https://doi.org/10.1016/j.apgeochem.2009.11.010
 AML10.1,"M. Accornero, L. Marini and M. Lelli",2010,"Appl. Geochem. 25, 242-260","Np- and Am-chromate complexes",https://doi.org/10.1016/j.apgeochem.2009.11.010

Modified: pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv	2022-02-08 09:17:20 UTC (rev 702)
+++ pkg/CHNOSZ/inst/extdata/adds/OBIGT_check.csv	2022-02-08 09:42:37 UTC (rev 703)
@@ -280,11 +280,11 @@
 "OBIGT",2136,"carbazole","cr","cal",-43.39,,
 "OBIGT",2177,"triphenylene","cr","cal",,,541
 "OBIGT",2490,"deoxyadenosine","cr","cal",,,-2977
-"OBIGT",2648,"ethylene","gas","cal",-4.59,,
-"OBIGT",2658,"3,5-dimethylphenol","gas","cal",,,628
-"OBIGT",2968,"nonacontane","liq","cal",,,635
-"OBIGT",2975,"2-methyloctane","liq","cal",10,,
-"OBIGT",3388,"5,6-dithiadecane","liq","cal",2,,
+"OBIGT",2649,"ethylene","gas","cal",-4.59,,
+"OBIGT",2659,"3,5-dimethylphenol","gas","cal",,,628
+"OBIGT",2969,"nonacontane","liq","cal",,,635
+"OBIGT",2976,"2-methyloctane","liq","cal",10,,
+"OBIGT",3389,"5,6-dithiadecane","liq","cal",2,,
 "DEW",8,"AlO2(SiO2)-","aq","cal",,,-897
 "DEW",17,"BO(OH)","aq","cal",,,-1111
 "DEW",19,"CaHCO3+","aq","cal",,,-2971

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



More information about the CHNOSZ-commits mailing list