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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun May 5 07:34:42 CEST 2019


Author: jedick
Date: 2019-05-05 07:34:41 +0200 (Sun, 05 May 2019)
New Revision: 458

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/mosaic.R
   pkg/CHNOSZ/demo/mosaic.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/mosaic.Rd
   pkg/CHNOSZ/tests/testthat/test-mosaic.R
Log:
mosaic(): rename 'e.bases' to 'E.bases'


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-05-05 02:49:37 UTC (rev 457)
+++ pkg/CHNOSZ/DESCRIPTION	2019-05-05 05:34:41 UTC (rev 458)
@@ -1,6 +1,6 @@
 Date: 2019-05-05
 Package: CHNOSZ
-Version: 1.3.2-5
+Version: 1.3.2-6
 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/mosaic.R
===================================================================
--- pkg/CHNOSZ/R/mosaic.R	2019-05-05 02:49:37 UTC (rev 457)
+++ pkg/CHNOSZ/R/mosaic.R	2019-05-05 05:34:41 UTC (rev 458)
@@ -104,7 +104,7 @@
   # calculate equilibrium mole fractions for each group of basis species
   group.fraction <- list()
   if(blend) {
-    e.bases <- list()
+    E.bases <- list()
     for(i in 1:length(A.bases)) {
       # this isn't needed (and doesn't work) if all the affinities are NA 20180925
       if(any(!sapply(A.bases[[1]]$values, is.na))) {
@@ -114,7 +114,7 @@
         a.tot <- Reduce("+", a.equil)
         group.fraction[[i]] <- lapply(a.equil, function(x) x / a.tot)
         # include the equilibrium activities in the output of this function 20190504
-        e.bases[[1]] <- e
+        E.bases[[i]] <- e
       } else {
         group.fraction[[i]] <- A.bases[[i]]$values
       }
@@ -176,6 +176,6 @@
   # for argument recall, include all arguments in output 20190120
   allargs <- c(list(bases = bases, blend = blend), list(...))
   # return the affinities for the species and basis species
-  if(blend) return(list(fun = "mosaic", args = allargs, A.species = A.species, A.bases = A.bases, e.bases = e.bases))
+  if(blend) return(list(fun = "mosaic", args = allargs, A.species = A.species, A.bases = A.bases, E.bases = E.bases))
   else return(list(fun = "mosaic", args = allargs, A.species = A.species, A.bases = A.bases))
 }

Modified: pkg/CHNOSZ/demo/mosaic.R
===================================================================
--- pkg/CHNOSZ/demo/mosaic.R	2019-05-05 02:49:37 UTC (rev 457)
+++ pkg/CHNOSZ/demo/mosaic.R	2019-05-05 05:34:41 UTC (rev 458)
@@ -33,10 +33,17 @@
 species(c("Fe+2", "Fe+3"), -4)
 m2 <- mosaic(bases, bases2, pH = pH, Eh = Eh, T = T)
 diagram(m2$A.species, add = TRUE, names = NULL)
-title(main=paste("Iron oxides, sulfides and carbonate in water, log(total S) = -6,",
-  "log(total C)=0, after Garrels and Christ, 1965", sep = "\n"))
-# overlay the carbonate basis species predominance fields
+# overlay the sulfur and carbonate basis species predominance fields
+d <- diagram(m1$A.bases, add = TRUE, col = "red", col.names = "red", lty = 3, limit.water = FALSE)
 d <- diagram(m1$A.bases2, add = TRUE, col = "blue", names = NULL, lty = 3, limit.water = FALSE)
 text(d$namesx, -0.8, as.expression(sapply(m1$A.bases2$species$name, expr.species)), col = "blue")
+# add legend and title
+dP <- describe.property(c("T", "P"), c(25, 1))
+legend("top", dP, bty = "n")
+dS <- expression(sum(S)*"(aq)" == 10^-6~italic(m))
+dC <- expression(sum(C)*"(aq)" == 1~italic(m))
+legend("topright", c(dS, dC), bty = "n")
+title(main=paste("Iron minerals, sulfur, and carbonate in water,",
+  "after Garrels and Christ, 1965, Figure 7.21", sep = "\n"), font.main = 1)
 # reset the database, as it was changed in this example
 reset()

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-05-05 02:49:37 UTC (rev 457)
+++ pkg/CHNOSZ/inst/NEWS	2019-05-05 05:34:41 UTC (rev 458)
@@ -7,14 +7,13 @@
   weighted by the mole fraction of the changing basis species, but they
   should be calculated using activities of basis species that are
   adjusted (i.e. lowered) according to their mole fractions. Previously,
-  constant activities were used for each changing basies species,
+  constant activities were used for each changing basis species,
   leading to an artificial inflation of affinities of species,
   especially near the transitions where the changing basis species are
   nearly equal in abundance.
 
-- The 'mixing' argument of mosaic() has been removed, as it no longer
-  provides correct results and is not needed with the improved handling
-  of activities of basis species.
+- The 'mixing' argument of mosaic() has been removed; it is no longer
+  needed with the improved handling of activities of basis species.
 
 OTHER CHANGES
 
@@ -21,7 +20,7 @@
 - Tests have been added to test-mosaic.R to check that activitives
   produced by mosaic() - equilibrate() and mosaic() - solubility()
   really are equilibrium activities, i.e. that the affinities of
-  reactions between species are equivalent to zero, especially near the
+  reactions between species are zero everywhere, in particular near the
   transitions of basis species.
 
 - In mosaic(), equilibrate groups of changing basis species using total
@@ -31,7 +30,7 @@
   species.
 
 - In mosaic(), include the result of equilibrate() for each group of
-  basis species in the output ('e.bases').
+  basis species in the output ('E.bases').
 
 - demo/aluminum.R: add calculations using Si(OH)4 from Akinfiev-Diamond
   model (SiO2 in these reactions is replaced by Si(OH)4 - 2 H2O).

Modified: pkg/CHNOSZ/man/mosaic.Rd
===================================================================
--- pkg/CHNOSZ/man/mosaic.Rd	2019-05-05 02:49:37 UTC (rev 457)
+++ pkg/CHNOSZ/man/mosaic.Rd	2019-05-05 05:34:41 UTC (rev 458)
@@ -43,7 +43,7 @@
 
 \value{
 A list containing \code{A.species} (affinities of formation of the species with changing basis species) and \code{A.bases} (affinities of formation of the basis species in terms of the first basis species), each having same structure as the list returned by \code{\link{affinity}}.
-If \code{blend} is TRUE, the output also contains \code{e.bases} (the output of \code{\link{equilibrate}} for each group of basis species)
+If \code{blend} is TRUE, the output also contains \code{E.bases} (the output of \code{\link{equilibrate}} for each group of basis species)
 If \code{bases2} is provided, the list also contains \code{A.bases2} (affinities of formation of the second group of basis species).
 }
 

Modified: pkg/CHNOSZ/tests/testthat/test-mosaic.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-mosaic.R	2019-05-05 02:49:37 UTC (rev 457)
+++ pkg/CHNOSZ/tests/testthat/test-mosaic.R	2019-05-05 05:34:41 UTC (rev 458)
@@ -61,15 +61,15 @@
   logK1 <- s1$out$logK
   # values of activities
   loga_acetic <- e$loga.equil[[2]]
-  loga_NH4 <- m$e.bases[[1]]$loga.equil[[2]]
+  loga_NH4 <- m$E.bases[[1]]$loga.equil[[2]]
   loga_acetamide <- e$loga.equil[[1]]
-  loga_H2O <- m$e.bases[[1]]$basis$logact[[4]]
-  loga_Hplus <- - m$e.bases[[1]]$vals$pH
+  loga_H2O <- m$E.bases[[1]]$basis$logact[[4]]
+  loga_Hplus <- - m$E.bases[[1]]$vals$pH
   logQ1 <- - loga_acetic - loga_NH4 + loga_acetamide + loga_H2O + loga_Hplus
   A1 <- logQ1 - logK1
   ## in CHNOSZ versions before 1.3.2-5 (20190505), the affinity was zero at the pH extremes,
   ## but peaked with a value of 0.3 (log10(2)) at pH 9.2 (equal activities of NH3 and NH4+)
-  #plot(m$e.bases[[1]]$vals$pH, A1, type = "l")
+  #plot(m$E.bases[[1]]$vals$pH, A1, type = "l")
   #title(main = describe.reaction(s1$reaction))
   expect_equivalent(A1, rep(0, length(A1)))
 })
@@ -100,7 +100,7 @@
   logK1 <- s1$out$logK
   # calculate logQ with the given or computed activities
   loga_Au <- m$A.bases$basis$logact[[1]]
-  loga_H2S <- m$e.bases[[1]]$loga.equil[[1]]
+  loga_H2S <- m$E.bases[[1]]$loga.equil[[1]]
   logf_O2 <- m$A.bases$basis$logact[[5]]
   loga_AuHS2minus <- s$loga.equil[[1]]
   loga_H2O <- m$A.bases$basis$logact[[4]]



More information about the CHNOSZ-commits mailing list