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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 21 06:18:34 CET 2020


Author: jedick
Date: 2020-12-21 06:18:34 +0100 (Mon, 21 Dec 2020)
New Revision: 632

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/demo/affinity.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/TODO
   pkg/CHNOSZ/man/diagram.Rd
   pkg/CHNOSZ/tests/testthat/test-mix.R
Log:
Change 'predominant.values' in diagram() to use 'plotvals' instead of 'eout$values'


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/DESCRIPTION	2020-12-21 05:18:34 UTC (rev 632)
@@ -1,6 +1,6 @@
-Date: 2020-11-26
+Date: 2020-12-21
 Package: CHNOSZ
-Version: 1.4.0-2
+Version: 1.4.0-3
 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	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/R/diagram.R	2020-12-21 05:18:34 UTC (rev 632)
@@ -716,16 +716,18 @@
 
   # even if plot=FALSE, return the diagram clipped to the water stability region (for testing) 20200719
   if(isTRUE(limit.water) & !is.null(H2O.predominant)) predominant <- H2O.predominant
-  # make a matrix with the affinities of predominant species 20200724
+
+  # Make a matrix with the affinities or activities of predominant species 20200724
   # (for calculating affinities of metastable species - multi-metal.Rmd example)
   predominant.values <- NA
   if(!identical(predominant, NA)) {
-    predominant.values <- eout$values[[1]]
+    predominant.values <- plotvals[[1]]
     predominant.values[] <- NA
     for(ip in na.omit(unique(as.vector(predominant)))) {
       ipp <- predominant == ip
       ipp[is.na(ipp)] <- FALSE
-      predominant.values[ipp] <- eout$values[[ip]][ipp]
+      # 20201219 Change eout$values to plotvals (return normalized affinities or equilibrium activities)
+      predominant.values[ipp] <- plotvals[[ip]][ipp]
     }
   }
 

Modified: pkg/CHNOSZ/demo/affinity.R
===================================================================
--- pkg/CHNOSZ/demo/affinity.R	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/demo/affinity.R	2020-12-21 05:18:34 UTC (rev 632)
@@ -79,7 +79,7 @@
 G.100.kJ <- convert(G.100.cal, "J")/1000
 # the average oxidation states of carbon
 Z.C <- ZC(thermo()$OBIGT$formula[thermo()$species$ispecies])
-# put everything together a la Table 3 in the paper
+# put everything together like Table 3 in the paper
 print(out <- data.frame(G.18=G.18.kJ, G.100=G.100.kJ, Z.C=Z.C))
 # make a plot; set units to get correct label
 E.units("J")

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-12-21 05:18:34 UTC (rev 632)
@@ -10,12 +10,22 @@
 \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-1 (2020-11-13)}{
+\section{Changes in CHNOSZ version 1.4.0-3 (2020-12-21)}{
 
   \itemize{
 
     \item Remove limSolve from Suggests in DESCRIPTION.
 
+    \item In the return value of \code{diagram()}, \code{predominant.values}
+    previously only contained affinities (extracted from the \code{values}
+    element of the \code{eout} argument). Now it has the values for the
+    predominant species extracted from the actual values used to make the plot
+    (the \code{plotvals} list in the output), i.e.  affinities divided by the
+    balancing coefficients if \code{eout} is the output of \code{affinity}, or
+    activities if \code{eout} is the output of \code{equilibrate}. Therefore it
+    can now be used to draw contours or a color image showing the activities of
+    the predominant species.
+
   }
 
 }

Modified: pkg/CHNOSZ/inst/TODO
===================================================================
--- pkg/CHNOSZ/inst/TODO	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/inst/TODO	2020-12-21 05:18:34 UTC (rev 632)
@@ -29,3 +29,11 @@
 [20201113 - ]
 
 - add a demo to show user-added data with Berman equations
+
+- make swap.basis() work when DEW model is active
+
+- Show species name in message: mod.OBIGT(5, G = 0)
+
+- Check that protein ionization calculations are not affected by E.units()
+
+- diagram(): scale predominant.values in output by balancing coefficients?

Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/man/diagram.Rd	2020-12-21 05:18:34 UTC (rev 632)
@@ -186,7 +186,7 @@
   To this are added the names of the plotted variable in \code{plotvar}, the labels used for species (which may be \code{\link{plotmath}} expressions if \code{format.names} is TRUE) in \code{names}, and the values used for plotting in a list named \code{plotvals}.
   For 1-D diagrams, \code{plotvals} usually corresponds to the chemical activities of the species (i.e. \code{eout$loga.equil}), or, if \code{alpha} is \code{TRUE}, their mole fractions (degrees of formation).
   For 2-D diagrams, \code{plotvals} corresponds to the values of affinity (from \code{eout$values}) divided by the respective balancing coefficients for each species.
-  For 2-D diagrams, the output also contains the matrices \code{predominant}, which identifies the predominant species in \code{eout$species} at each grid point, and \code{predominant.values}, which has the affinities of the predominant species.
+  For 2-D diagrams, the output also contains the matrices \code{predominant}, which identifies the predominant species in \code{eout$species} at each grid point, and \code{predominant.values}, which has the affinities of the predominant species divided by the balancing coefficients (if \code{eout} is the output of \code{affinity}) or the activities of the predominant species (if \code{eout} is the output of \code{equilibrate}).
   The rows and columns of these matrices correspond to the \emph{x} and \emph{y} variables, respectively.
   Finally, the output for 2-D diagrams contains a \code{lines} component, giving the \emph{x} and \emph{y} coordinates of the field boundaries computed using \code{\link{contourLines}}; the values are padded to equal length with NAs to faciliate exporting the results using \code{\link{write.csv}}.
 }

Modified: pkg/CHNOSZ/tests/testthat/test-mix.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-mix.R	2020-11-25 20:49:32 UTC (rev 631)
+++ pkg/CHNOSZ/tests/testthat/test-mix.R	2020-12-21 05:18:34 UTC (rev 632)
@@ -44,7 +44,8 @@
   abornite <- affinity(aFe)  # argument recall
   # Because of the 1) equal stoichiometry and 2) same basis species
   # used for bornite and the mix() diagram, subtracting these makes sense
-  abornite_vs_predominant.values <- abornite$values[[1]] - dFeCu15$predominant.values
+  # 20201221 But now we have to multiply by 5 because predominant.values is divided by the balancing coefficients
+  abornite_vs_predominant.values <- abornite$values[[1]] - 5 * dFeCu15$predominant.values
   if(plot.it) image(abornite_vs_predominant.values)
 
   # METHOD 2 (mosaic)



More information about the CHNOSZ-commits mailing list