[CHNOSZ-commits] r558 - in pkg/CHNOSZ: . R demo inst man tests/testthat vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 14 12:07:42 CEST 2020


Author: jedick
Date: 2020-07-14 12:07:42 +0200 (Tue, 14 Jul 2020)
New Revision: 558

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/buffer.R
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/R/equilibrate.R
   pkg/CHNOSZ/R/mosaic.R
   pkg/CHNOSZ/R/species.R
   pkg/CHNOSZ/demo/affinity.R
   pkg/CHNOSZ/demo/copper.R
   pkg/CHNOSZ/demo/gold.R
   pkg/CHNOSZ/demo/mosaic.R
   pkg/CHNOSZ/demo/saturation.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/species.Rd
   pkg/CHNOSZ/tests/testthat/test-equilibrate.R
   pkg/CHNOSZ/tests/testthat/test-species.R
   pkg/CHNOSZ/vignettes/anintro.Rmd
Log:
Add 'add' argument to species()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/DESCRIPTION	2020-07-14 10:07:42 UTC (rev 558)
@@ -1,6 +1,6 @@
-Date: 2020-07-13
+Date: 2020-07-14
 Package: CHNOSZ
-Version: 1.3.6-31
+Version: 1.3.6-32
 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/buffer.R
===================================================================
--- pkg/CHNOSZ/R/buffer.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/R/buffer.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -74,8 +74,7 @@
         species <- as.character(thermo$buffers$species)[ib]
         state <- as.character(thermo$buffers$state)[ib]
         #ibuff <- info(species,state,quiet=TRUE)
-        #ispecies <- c(ispecies,species(ibuff))
-        ispecies <- c(ispecies, species(species, state, index.return=TRUE))
+        ispecies <- c(ispecies, species(species, state, index.return=TRUE, add = TRUE))
       }
       ispecies.new <- c(ispecies.new,list(ispecies))
       # make sure to set the activities

Modified: pkg/CHNOSZ/R/diagram.R
===================================================================
--- pkg/CHNOSZ/R/diagram.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/R/diagram.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -55,8 +55,14 @@
     if(!"loga.equil" %in% names(eout)) {
       eout.is.aout <- TRUE
       # get the balancing coefficients
-      if(type=="auto") n.balance <- balance(eout, balance)$n.balance
-      else n.balance <- rep(1, length(eout$values))
+      if(type=="auto") {
+        bal <- balance(eout, balance)
+        n.balance <- bal$n.balance
+        balance <- bal$balance
+      } else n.balance <- rep(1, length(eout$values))
+      # in case all coefficients are negative (for bimetal() examples) 20200713
+      # e.g. H+ for minerals with basis(c("Fe+2", "Cu+", "hydrogen sulfide", "oxygen", "H2O", "H+"))
+      if(all(n.balance < 0)) n.balance <- -n.balance
     }
   } else if(type %in% rownames(eout$basis)) {
     # to calculate the loga of basis species at equilibrium
@@ -94,6 +100,7 @@
       # normalizing the formulas is done below
       eout$values[[i]] / n.balance[i]
     })
+    names(plotvals) <- names(eout$values)
     plotvar <- eout$property
     # we change 'A' to 'A/(2.303RT)' so the axis label is made correctly
     # 20171027 use parentheses to avoid ambiguity about order of operations
@@ -659,7 +666,10 @@
       out2D <- list(namesx=pn$namesx, namesy=pn$namesy)
     } # end if(nd==2)
   } # end if(plot.it)
-  out <- c(eout, list(plotvar=plotvar, plotvals=plotvals, names=names, predominant=predominant))
+  outstuff <- list(plotvar=plotvar, plotvals=plotvals, names=names, predominant=predominant)
+  # include the balance name and coefficients if we diagrammed affinities 20200714
+  if(eout.is.aout) outstuff <- c(list(balance = balance, n.balance = n.balance), outstuff)
+  out <- c(eout, outstuff)
   if(!identical(predominant, NA) & is.null(dotted)) out <- c(out, list(lines=linesout))
   out <- c(out, out2D)
   return(invisible(out))

Modified: pkg/CHNOSZ/R/equilibrate.R
===================================================================
--- pkg/CHNOSZ/R/equilibrate.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/R/equilibrate.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -366,7 +366,7 @@
   if(is.numeric(balance[1])) {
     # a numeric vector
     n.balance <- rep(balance, length.out=length(aout$values))
-    message("balance: from numeric argument value")
+    message(paste0("balance: from supplied numeric argument (", balance, ")"))
   } else {
     # "length" for balancing on protein length
     if(identical(balance, "length")) {

Modified: pkg/CHNOSZ/R/mosaic.R
===================================================================
--- pkg/CHNOSZ/R/mosaic.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/R/mosaic.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -68,7 +68,7 @@
   # run subcrt() calculations for all basis species and formed species 20190131
   # this avoids repeating the calculations in different calls to affinity()
   # add all the basis species here - the formed species are already present
-  lapply(bases, species)
+  lapply(bases, species, add = TRUE)
   sout <- affinity(..., return.sout = TRUE)
 
   # calculate affinities of the basis species themselves
@@ -75,7 +75,6 @@
   A.bases <- list()
   for(i in 1:length(bases)) {
     message("mosaic: calculating affinities of basis species group ", i, ": ", paste(bases[[i]], collapse=" "))
-    species(delete = TRUE)
     mysp <- species(bases[[i]])
     # 20191111 include only aq species in total activity
     iaq <- mysp$state == "aq"

Modified: pkg/CHNOSZ/R/species.R
===================================================================
--- pkg/CHNOSZ/R/species.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/R/species.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -1,11 +1,12 @@
 # CHNOSZ/species.R
 # define species of interest 
 
-# to add to or alter the species definition
-species <- function(species=NULL, state=NULL, delete=FALSE, index.return=FALSE) {
+# Function to create or add to the species data frame
+species <- function(species=NULL, state=NULL, delete=FALSE, add=FALSE, index.return=FALSE) {
   # 20080925 default quiet=TRUE 20101003 default quiet=FALSE
   # 20120128 remove 'quiet' argument (messages can be hidden with suppressMessages())
   # 20120523 return thermo()$species instead of rownumbers therein, and remove message showing thermo()$species
+  # 20200714 add 'add' argument (by default, previous species are deleted)
   thermo <- get("thermo", CHNOSZ)
   ## argument processing
   # we can't deal with NA species
@@ -46,6 +47,11 @@
   }
   # if no species or states are given, just return the species list
   if(is.null(species) & is.null(state)) return(thermo$species)
+#  # delete the previous species definition unless add = TRUE 20200714
+#  if(!add) {
+#    thermo$species <- NULL
+#    assign("thermo", thermo, CHNOSZ)
+#  }
   # if no species are given use all of them if available
   if(is.null(species) & !is.null(thermo$species)) species <- 1:nrow(thermo$species)
   # parse state argument
@@ -105,7 +111,7 @@
     # "H2PO4-" looks better than "H2PO4."
     colnames(newspecies)[1:nrow(thermo$basis)] <- rownames(thermo$basis)
     # initialize or add to species data frame
-    if(is.null(thermo$species)) {
+    if(is.null(thermo$species) | !add) {
       thermo$species <- newspecies
       ispecies <- 1:nrow(thermo$species)
     } else {

Modified: pkg/CHNOSZ/demo/affinity.R
===================================================================
--- pkg/CHNOSZ/demo/affinity.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/demo/affinity.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -87,6 +87,5 @@
 # 9 amino acids have negative delta Gr under hydrothermal conditions
 # (cf. AS98 with 11; we are using more recent thermodynamic data)
 stopifnot(sum(out$G.100 < 0)==9)
-# reset units and species to run next examples
+# reset units to run next examples
 E.units("cal")
-species(delete=TRUE)

Modified: pkg/CHNOSZ/demo/copper.R
===================================================================
--- pkg/CHNOSZ/demo/copper.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/demo/copper.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -35,7 +35,7 @@
 basis(c("Cu+2", "H2O", "H+", "e-", "glycinium", "CO2"), c(999, 0, 999, 999, -1, 999))
 # add solids and aqueous species
 species(Cu_s)
-species(c(Cu_aq, CuGly), -4)
+species(c(Cu_aq, CuGly), -4, add = TRUE)
 names <- c(Cu_s, Cu_aq, CuGly)
 # mosaic diagram with speciate glycine as a function of pH
 m <- mosaic(bases=Gly, pH=c(0, 16, 500), Eh=c(-0.6, 1.0, 500))

Modified: pkg/CHNOSZ/demo/gold.R
===================================================================
--- pkg/CHNOSZ/demo/gold.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/demo/gold.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -21,7 +21,6 @@
 
 # sulfur logfO2-pH diagrams showing redox and pH buffers at four temperatures 20181031
 sulfur <- function() {
-  species(delete = TRUE)
   species(c("H2S", "HS-", "HSO4-", "SO4-2"))
   T <- c(200, 300, 400, 500)
   P <- 1000

Modified: pkg/CHNOSZ/demo/mosaic.R
===================================================================
--- pkg/CHNOSZ/demo/mosaic.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/demo/mosaic.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -16,7 +16,7 @@
 basis("SO4-2", -6)
 basis("CO3-2", 0)
 species(c("Fe+2", "Fe+3"), -6)
-species(c("pyrrhotite", "pyrite", "hematite", "magnetite", "siderite"))
+species(c("pyrrhotite", "pyrite", "hematite", "magnetite", "siderite"), add = TRUE)
 # two sets of changing basis species:
 # speciate SO4-2, HSO4-, HS-, H2S as a function of Eh and pH
 # speciate CO3-2, HCO3-, CO2 as a function of pH

Modified: pkg/CHNOSZ/demo/saturation.R
===================================================================
--- pkg/CHNOSZ/demo/saturation.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/demo/saturation.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -25,7 +25,6 @@
 
 # add saturation limits for specified CO2 fugacity
 basis("CO2", -1)
-species(delete = TRUE)
 species(c("calcite", "dolomite", "magnesite", "brucite"))
 # use argument recall feature to rerun affinity over the same range of conditions
 a <- affinity(a)

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-07-14 10:07:42 UTC (rev 558)
@@ -5,7 +5,7 @@
 % macros
 \newcommand{\H2O}{\ifelse{latex}{\eqn{\mathrm{H_{2}O}}}{\ifelse{html}{\out{H<sub>2</sub>O}}{H2O}}}
 
-\section{Changes in CHNOSZ version 1.3.6-31 (2020-07-13)}{
+\section{Changes in CHNOSZ version 1.3.6-32 (2020-07-14)}{
 
   \subsection{MAJOR CHANGES}{
     \itemize{
@@ -28,6 +28,13 @@
       \code{add.OBIGT()} and \code{mod.OBIGT()} replace the previous
       \code{add.obigt()} and \code{mod.obigt()}.
 
+      \item An \strong{add} argument has been added to \code{species()}. By
+      default, loading new species now causes any previous species definition
+      to be removed first. Therefore, \code{species(delete = TRUE)} is no
+      longer needed to clear the species definition in a series of calculations
+      for different species. To restore the previous behavior, where new
+      species are added to an existing definiton, set \samp{add = TRUE}.
+
     }
   }
 
@@ -145,6 +152,8 @@
 
       \item TODO: remove extdata/refseq (now in JMDplots).
 
+      \item TODO: OBIGT.Rmd: change "CHNOSZ" references to "OBIGT".
+
     }
   }
 

Modified: pkg/CHNOSZ/man/species.Rd
===================================================================
--- pkg/CHNOSZ/man/species.Rd	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/man/species.Rd	2020-07-14 10:07:42 UTC (rev 558)
@@ -7,33 +7,36 @@
 }
 
 \usage{
-  species(species = NULL, state = NULL, delete = FALSE, index.return = FALSE)
+  species(species = NULL, state = NULL, delete = FALSE, add = FALSE, index.return = FALSE)
 }
 
 \arguments{
   \item{species}{character, names or formulas of species to add to the species definition; numeric, rownumbers of species to modify or delete}
   \item{state}{character, physical states; numeric, logarithms of activities or fugacities}
-  \item{delete}{logical, delete the species identified by numeric values of \code{species} (all species if that argument is missing)?}  
+  \item{delete}{logical, delete the species identified by numeric values of \code{species} (or all species if that argument is missing)?}  
+  \item{add}{logical, delete a previous species definition instead of adding to it?}  
   \item{index.return}{logical, return the affected rownumbers of \code{thermo()$species} instead of its contents?}
 }
 
 \details{
 After defining the \code{\link{basis}} species of your system you can use \code{species} to identify the species of interest.
-A species is operationally a combination of a \code{name} and \code{state}, which are columns of the thermodynamic database in \code{\link{thermo}$OBIGT}.
-The function operates on one or more character values of \code{species}.
-For each first match of \code{species} (optionally restricted to a \code{state} among \samp{aq}, \samp{cr}, \samp{gas}, \samp{liq}) to the name of a species or a formula or abbreviation in the thermodynamic database, a row is added to \code{thermo()$species}.  
+A species is uniquely identified by a combination of a \code{name} and \code{state}, which are columns of the thermodynamic database in \code{\link{thermo}()$OBIGT}.
+For each match of \code{species} to the name, formula, or abbreviation of a species, and of \code{state} to the state (\samp{aq}, \samp{cr}, \samp{gas}, \samp{liq}), the species is added to the current species definition in \code{thermo()$species}.  
 
-The data frame in \code{thermo()$species} holds the identifying characteristics of the species as well as the stoichiometric reaction coefficients for the formation of each of the species from the basis species, the logarithms of activities or fugacities that are used by \code{\link{affinity}}.
-The default values for logarithms of activities are -3 for aqueous (\samp{aq}) species and 0 for others. 
-
-If \code{state} is \code{NULL} (the default), species in any state can be matched in the thermodynamic database.
+The \code{state} argument can be omitted, in which case the first matching species in any state is added (in many cases, this means the aqueous species).
 If there are multiple matches for a species, the one that is in the state given by \code{thermo()$opt$state} is chosen, otherwise the matching (or \eqn{n}{n}'th matching duplicate) species is used.
 Note that the \code{state}s of species representing phases of minerals that undergo phase transitions are coded as \samp{cr} (lowest-T phase), \samp{cr2}, \samp{cr3}, \code{...} (phases with increasing temperature).
 If \code{state} is \samp{cr} when one of these minerals is matched, all the phase species are added.
 
+The data frame in \code{thermo()$species} holds the species names and indices as well as the stoichiometric reaction coefficients for the formation reaction from the basis species and the logarithms of activities or fugacities that are used by \code{\link{affinity}}.
+The default values for logarithms of activities are -3 for aqueous (\samp{aq}) species and 0 for others. 
+
 To modify the logarithms of activities of species (logarithms of fugacities for gases) provide one or more numeric values of \code{species} referring to the rownumbers of the species dataframe, or \code{species} NULL, to modify all currently defined species.
-The values in \code{state}, if numeric, are interpreted as the logarithms of activities, or if character are interpreted as states to which the species should be changed.
-If \code{species} is numeric and \code{delete} is \code{TRUE}, the rows representing these species are deleted from the dataframe; if the only argument is \code{delete} and it is \code{TRUE}, all the species are removed.
+The values in \code{state}, if numeric, are interpreted as the logarithms of activities, or if character are interpreted as new states for the species.
+If \code{species} is numeric and \code{delete} is \code{TRUE}, these species are deleted from the dataframe; if the only argument is \code{delete} and it is \code{TRUE}, all the species are removed.
+
+By default, when identifying new species, any previous species definition is removed.
+Set \code{add} to TRUE to add species to an existing definition.
 }
 
 \value{
@@ -46,21 +49,24 @@
 }
 
 \examples{\dontshow{reset()}
-# set up the basis species
+# Set up the basis species
 basis("CHNOS")
-# add, modify, delete species
-species(c("CO2","NH3"))  # aqueous species
-species(c("CO2","NH3"),"gas")  # gases
-# delete the first couple of species
-species(1:2,delete=TRUE)
-# modify the logarithms of activities (actually
-# fugacities) of the remaining species
-species(1:2,c(-2,-5))
-# set the species to aqueous
-species(1:2,"aq")
-# delete all the species (returns the existing species
-# definition, then deletes the species)
-sd <- species(delete=TRUE)
+# Define some aqueous species
+species(c("CO2", "NH3"))
+# Add some gases
+species(c("CO2", "NH3"), "gas", add = TRUE)
+# Delete the aqueous species
+species(1:2, delete = TRUE)
+# Modify the "logact" value
+# (log10 of activity for aqueous species;
+#  log10 of fugacity for gases)
+species(1:2, c(-2, -5))
+# Change the state to aqueous
+species(1:2, "aq")
+# Load a new species definition (deletes the old one first)
+species(c("glycine", "alanine"))
+# Delete all the species
+species(delete = TRUE)
 
 # changing the elements in the basis definition
 # causes species to be deleted

Modified: pkg/CHNOSZ/tests/testthat/test-equilibrate.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-equilibrate.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/tests/testthat/test-equilibrate.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -6,13 +6,12 @@
 species("acetic acid")
 aone <- suppressMessages(affinity())
 # acids
-species(c("formic acid", "formate", "acetate"))
+species(c("formic acid", "formate", "acetate"), add = TRUE)
 aacid <- suppressMessages(affinity())
 # acids plus a sulfur species
-species("H2S")
+species("H2S", add = TRUE)
 aacidS <- suppressMessages(affinity())
 # proteins
-species(delete=TRUE)
 species(c("LYSC_CHICK", "MYG_PHYCA", "RNAS1_BOVIN", "CYC_BOVIN"))
 aprot <- suppressMessages(affinity())
 
@@ -25,7 +24,7 @@
   expect_message(equilibrate(aacid, loga.balance=-3), "loga.balance is -3")
   expect_error(equilibrate(aacid, balance="length"), "some species are not proteins")
   expect_error(equilibrate(aacidS), "no basis species is present in all formation reactions")
-  expect_message(equilibrate(aacidS, balance=1), "balance: from numeric argument value")
+  expect_message(equilibrate(aacidS, balance=1), "balance: from supplied numeric argument")
   expect_message(equilibrate(aacidS, balance=1), "n.balance is 1 1 1 1 1")
   expect_message(equilibrate(aacidS, balance=1), "loga.balance is -2.301029")
   expect_error(equilibrate(aacidS, balance="CO2"), "some species have no CO2 in the formation reaction")
@@ -166,7 +165,7 @@
   basis("CHNOS")
   basis("O2", -49.5)
   species(`n-alkane`)
-  species(`2-isoalkane`)
+  species(`2-isoalkane`, add = TRUE)
   # approximate conditions of Computer Experiment 27 (Helgeson et al., 2009, GCA)
   a <- affinity(T=150, P=830, exceed.Ttr=TRUE)
   # using full chemical formulas
@@ -198,7 +197,7 @@
   basis("O2", -35)
   basis("H+", -5)
   species(Cu_aq, -3)
-  species(Cu_cr)
+  species(Cu_cr, add = TRUE)
   a <- affinity("Cl-" = c(-3, 0, 200), "HS-" = c(-10, 0, 200), T = 325, P = 500)
   apredom <- diagram(a, plot.it = FALSE)$predominant
   e <- equilibrate(a)

Modified: pkg/CHNOSZ/tests/testthat/test-species.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-species.R	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/tests/testthat/test-species.R	2020-07-14 10:07:42 UTC (rev 558)
@@ -43,13 +43,13 @@
   # change its log fugacity to -5
   expect_equal(species(1, -5)$logact, -5)
   # add CO2, aq
-  expect_equal(nrow(species("CO2")), 2)
+  expect_equal(nrow(species("CO2", add = TRUE)), 2)
   # add alanine by index in thermo()$OBIGT
-  expect_equal(nrow(species(info("alanine"))), 3)
+  expect_equal(nrow(species(info("alanine"), add = TRUE)), 3)
   # if we just use an index, get only that species
   expect_equal(species(3)$name, "alanine")
   # we can add a species with the same name but different state
-  expect_equal(nrow(species("alanine", "cr")), 4)
+  expect_equal(nrow(species("alanine", "cr", add = TRUE)), 4)
   # we can modify the logact of a named species (only first match)
   expect_equal(species("alanine", -7)$logact[3], -7)
 })
@@ -59,6 +59,6 @@
   expect_equal(species("CO2", index.return=TRUE), 1)
   # here it's "touched" (but not added or modified)
   expect_equal(species("CO2", index.return=TRUE), 1)
-  expect_equal(species(c("H2O", "NH3"), index.return=TRUE), c(2, 3))
+  expect_equal(species(c("H2O", "NH3"), index.return=TRUE, add = TRUE), c(2, 3))
   expect_equal(species(1, "gas", index.return=TRUE), 1)
 })

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2020-07-13 02:30:55 UTC (rev 557)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2020-07-14 10:07:42 UTC (rev 558)
@@ -696,13 +696,14 @@
 
 Next we define the basis, and set the activities of the H<sub>2</sub>S and Cl<sup>-</sup> basis species.
 These represent the total activity of S and Cl in the system, which are distributed among the minerals and aqueous species.
-Four minerals and the aqueous copper chloride species are included:
+Aqueous copper chloride complexes and four minerals are added.
+Be sure to include `add = TRUE` in the second call to <span style="color:red">`species()`</span>; otherwise, the minerals would simply replace the previously added aqueous species.
 ```{r copper_setup, echo=TRUE, results="hide"}
 basis(c("Cu", "H2S", "Cl-", "H2O", "H+", "e-"))
 basis("H2S", -6)
 basis("Cl-", -0.7)
 species(c("CuCl", "CuCl2-", "CuCl3-2", "CuCl+", "CuCl2", "CuCl3-", "CuCl4-2"))
-species(c("chalcocite", "tenorite", "cuprite", "copper"))
+species(c("chalcocite", "tenorite", "cuprite", "copper"), add = TRUE)
 ```
 
 Note that chalcocite (Cu<sub>2</sub>S) undergoes phase transitions.
@@ -1006,11 +1007,11 @@
 In the database, the species in each group are ordered by carbon number, so we construct a sequence from the starting to ending `ispecies` for each group using R's `seq()` function, wrapped by the `seq2()` function we write here to make the code shorter:
 ```{r groups_species, message=FALSE}
 seq2 <- function(x) seq(x[1], x[2])
-ia <- species(seq2(info(c("methanol", "octanol"))), index.return = TRUE)
-ik <- species(seq2(info(c("acetone", "2-octanone"))), index.return = TRUE)
-ic <- species(seq2(info(c("acetic acid","n-dodecanoic acid"))),index.return=TRUE)
-ica <- species(seq2(info(c("acetate", "n-dodecanoate"))), index.return = TRUE)
-ie <- species(seq2(info(c("ethylene", "octene"))), index.return = TRUE)
+ia <- species(seq2(info(c("methanol", "octanol"))), index.return = TRUE, add = TRUE)
+ik <- species(seq2(info(c("acetone", "2-octanone"))), index.return = TRUE, add = TRUE)
+ic <- species(seq2(info(c("acetic acid","n-dodecanoic acid"))),index.return=TRUE, add = TRUE)
+ica <- species(seq2(info(c("acetate", "n-dodecanoate"))), index.return = TRUE, add = TRUE)
+ie <- species(seq2(info(c("ethylene", "octene"))), index.return = TRUE, add = TRUE)
 ```
 
 Now we read two data files that contain values of `r logfO2` and pH as a function of temperature, digitized from Figure 5 of Shock and Schulte (1998).
@@ -1204,7 +1205,7 @@
 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"))
+species(c("MgATP-2", "MgHATP-", "MgH2ATP", "Mg2ATP"), add = TRUE)
 Hplot <- function(pMg, IS = 0.25) {
   basis("Mg+2", -pMg)
   a <- affinity(pH = c(3, 9), IS = IS, T = T)



More information about the CHNOSZ-commits mailing list