[CHNOSZ-commits] r629 - in pkg/CHNOSZ: . R demo inst man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 13 06:06:17 CET 2020


Author: jedick
Date: 2020-11-13 06:06:17 +0100 (Fri, 13 Nov 2020)
New Revision: 629

Modified:
   pkg/CHNOSZ/NAMESPACE
   pkg/CHNOSZ/R/mix.R
   pkg/CHNOSZ/demo/mosaic.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/TODO
   pkg/CHNOSZ/man/add.OBIGT.Rd
   pkg/CHNOSZ/man/mix.Rd
   pkg/CHNOSZ/man/thermo.Rd
   pkg/CHNOSZ/vignettes/OBIGT.Rmd
   pkg/CHNOSZ/vignettes/mklinks.sh
   pkg/CHNOSZ/vignettes/multi-metal.Rmd
Log:
Rename flatten() to mash()


Modified: pkg/CHNOSZ/NAMESPACE
===================================================================
--- pkg/CHNOSZ/NAMESPACE	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/NAMESPACE	2020-11-13 05:06:17 UTC (rev 629)
@@ -58,7 +58,7 @@
   "CHNOSZ", "thermo", "reset", "OBIGT", "retrieve", "AkDi", "moles",
   "lNaCl", "lS", "lT", "lP", "lTP", "lex",
 # added 20200716 or later
-  "flatten", "mix", "rebalance"
+  "mash", "mix", "rebalance"
 )
 
 # Load shared objects

Modified: pkg/CHNOSZ/R/mix.R
===================================================================
--- pkg/CHNOSZ/R/mix.R	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/R/mix.R	2020-11-13 05:06:17 UTC (rev 629)
@@ -1,4 +1,4 @@
-# CHNOSZ/flatten.R
+# CHNOSZ/mix.R
 # Combine diagrams for two metals
 # 20200713 first version jmd
 
@@ -7,7 +7,7 @@
 
 # Function to combine two diagrams (simple overlay, no interaction) 20200717
 # -- makes new "species" from all combinations of those in d1 and d2
-flatten <- function(d1, d2) {
+mash <- function(d1, d2) {
   # It's just mixing d1 and d2 (two single-metal diagrams) without adding d3 (bimetal) 20200722
   mix(d1, d2)
 }

Modified: pkg/CHNOSZ/demo/mosaic.R
===================================================================
--- pkg/CHNOSZ/demo/mosaic.R	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/demo/mosaic.R	2020-11-13 05:06:17 UTC (rev 629)
@@ -2,7 +2,7 @@
 # 20141221 first version jmd
 # 20200819 revision:
 #   - comment out GC65 thermodynamic data
-#   - use flatten() to show S and C species together
+#   - use mash() to show S and C species together
 #   - reorder plot layers to make better use of transparency
 #   - add 'dy' argument to adjust positions of labels
 #   - add legend to show activity of aqueous Fe species
@@ -46,7 +46,7 @@
 ## Show the predominance fields for the sulfur and carbonate basis species
 dS <- diagram(m4$A.bases, italic = TRUE, plot.it = FALSE)
 dC <- diagram(m4$A.bases2, italic = TRUE, plot.it = FALSE)
-dSC <- flatten(dS, dC)
+dSC <- mash(dS, dC)
 diagram(dSC, lty = 3, col = 4, col.names = 4, add = TRUE)
 
 # Show lines for log(activity of aqueous Fe species) = -6

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-11-13 05:06:17 UTC (rev 629)
@@ -53,7 +53,7 @@
   \subsection{NEW FEATURES}{
     \itemize{
 
-      \item Add function \strong{flatten()} for combining two diagrams for
+      \item Add function \strong{mash()} for combining two diagrams for
       different systems (i.e., simple overlay of diagrams for two single-metal
       systems).
 
@@ -177,7 +177,7 @@
 
       \item New demo \samp{berman.R}, extracted from \samp{berman.Rd}.
 
-      \item Revise demo \samp{mosaic.R} to use \code{flatten()} to show S and C
+      \item Revise demo \samp{mosaic.R} to use \code{mash()} to show S and C
       species together, make better use of transparency, and \code{dy} argument
       to adjust positions of labels.
 

Modified: pkg/CHNOSZ/inst/TODO
===================================================================
--- pkg/CHNOSZ/inst/TODO	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/inst/TODO	2020-11-13 05:06:17 UTC (rev 629)
@@ -1,4 +1,4 @@
-[to 20201110]
+[ - 20201110]
 
 - make a site for community uploaded data
 
@@ -25,3 +25,7 @@
 
 - replace CoCl2-4 example in anintro.Rmd with different species
 (CoCl2-4 has been added to OBIGT).
+
+[20201113 - ]
+
+- add a demo to show user-added data with Berman equations

Modified: pkg/CHNOSZ/man/add.OBIGT.Rd
===================================================================
--- pkg/CHNOSZ/man/add.OBIGT.Rd	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/man/add.OBIGT.Rd	2020-11-13 05:06:17 UTC (rev 629)
@@ -42,7 +42,7 @@
 The name of the species to add or change must be supplied as the first argument of \code{...} or as a named argument (named \samp{name}).
 When adding new species, a chemical formula should be included along with the values of any of the thermodynamic properties.
 The formula is taken from the \samp{formula} argument, or if that is missing, is taken to be the same as the \samp{name} of the species.
-An error results if the formula is not valid (i.e. can not be parsed by\code{\link{makeup}}).
+An error results if the formula is not valid (i.e. can not be parsed by \code{\link{makeup}}).
 Additional arguments refer to the name of the property(s) to be updated and are matched to any part of compound column names in \code{\link{thermo}$OBIGT}, such as \samp{z} or \samp{T} in \samp{z.T}.
 Unless \samp{state} is specified as one of the properties, its value is taken from \code{thermo()$opt$state}.
 When adding species, properties that are not specified become NA, except for \samp{state}, which takes a default value from \code{thermo()$opt$state}, and \samp{z.T}, which for aqueous species is set to the charge calculated from the chemical formula (otherwise, NA charge for newly added species would trigger the \code{\link{AkDi}} model).

Modified: pkg/CHNOSZ/man/mix.Rd
===================================================================
--- pkg/CHNOSZ/man/mix.Rd	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/man/mix.Rd	2020-11-13 05:06:17 UTC (rev 629)
@@ -1,15 +1,15 @@
 \encoding{UTF-8}
 \name{mix}
-\alias{flatten}
+\alias{mash}
 \alias{rebalance}
 \alias{mix}
 \title{Combine Diagrams for Multi-Metal Systems}
 \description{
-  Combine diagrams for different systems by flattening or rebalancing two diagrams or mixing two diagrams with a third.
+  Combine diagrams for different systems by mashing or rebalancing two diagrams or mixing two diagrams with a third.
 }
 
 \usage{
-  flatten(d1, d2)
+  mash(d1, d2)
   rebalance(d1, d2, balance = NULL)
   mix(d1, d2, d3, parts = c(1, 1), .balance = NULL)
 }
@@ -28,12 +28,12 @@
 These functions make a new \code{\link{affinity}} object from the output of \code{\link{diagram}}.
 The result can be used to make a new diagram that shows the combined system.
 
-\code{flatten} creates a set of intersecting predominance fields for all possible combinations of species in \code{d1} and \code{d2}.
-The new names are formed from the \code{names} used in the source diagrams; for example if "Cp" and "Py" are predominant minerals at the same position in diagrams 1 and 2, the field for the flattened diagram will be labeled "Cp+Py".
+\code{mash} creates a set of intersecting predominance fields for all possible combinations of species in \code{d1} and \code{d2}.
+The new names are formed from the \code{names} used in the source diagrams; for example if "Cp" and "Py" are predominant minerals at the same position in diagrams 1 and 2, the field for the mashed diagram will be labeled "Cp+Py".
 The affinities are calculated by summing the formation reactions from the two diagrams to give equal parts of the balancing coefficients in \code{d1} and \code{d2} (that is, equal parts of two different metals).
 Note that the actual values of the affinities (and therefore the ratio between the metals) doesn't affect the resulting diagram because the affinities are assigned values of -Inf wherever one of the species is not predominant in the respective single-metal diagram.
 
-\code{mix} is an expanded form of \code{flatten} that allows combinations not only between two single-metal diagrams (\code{d1} and \code{d2}) but also between each of those diagrams and third diagram for bimetallic species (\code{d3}).
+\code{mix} is an expanded form of \code{mash} that allows combinations not only between two single-metal diagrams (\code{d1} and \code{d2}) but also between each of those diagrams and third diagram for bimetallic species (\code{d3}).
 All combinations of species in all crosses between the diagrams (\code{d1-d2}, \code{d1-d3}, \code{d2-d3}, \code{d3-d3}) are identified.
 The mole fractions of species in each combination are computed to satisfy the ratio of metals defined in \code{parts}.
 For example, if \code{d1} and \code{d2} are balanced on Fe\S{+2} and VO\s{4}\S{-3}, the species are combined by default to give equal parts of Fe and V.
@@ -54,7 +54,7 @@
 The \emph{returned} value of affinity are carried forward from those used to make the source diagrams (\samp{plotvals} in \code{d1} and \code{d2}), and therefore reflect the primary balancing coefficients.
 The returned values are assigned -Inf wherever that species is determined to not predominate according to the secondary balancing.
 
-Because \code{flatten} yields finite values of affinity for only a single species at any grid point, the final diagram can be made with any setting of \code{balance}.
+Because \code{mash} yields finite values of affinity for only a single species at any grid point, the final diagram can be made with any setting of \code{balance}.
 \code{mix} gives combinations of species that each have the amount of metals defined in \code{parts}, so it makes no difference whether the final diagram is balanced on either of the metals, or on formula units (\code{balance = 1}).
 However, for \code{rebalance}, \code{balance} in the final diagram should be set to \samp{1} to balance on formula units in order to preserve the primary balancing coefficients.
 
@@ -81,9 +81,9 @@
 species(c("covellite", "chalcocite", "tenorite", "cuprite"))
 aCu <- affinity(aFe)  # argument recall
 dCu <- diagram(aCu, xlab = xlab, main = "Cu-S-O-H")
-### flatten() diagram
-ac <- flatten(dFe, dCu)
-diagram(ac, xlab = xlab, main = "Cu-Fe-S-O-H with flatten()")
+### mash() diagram
+ac <- mash(dFe, dCu)
+diagram(ac, xlab = xlab, main = "Cu-Fe-S-O-H with mash()")
 ### rebalance() diagram
 ad <- rebalance(dFe, dCu)
 diagram(ad, xlab = xlab, balance = 1, main = "Cu-Fe-S-O-H with rebalance()")

Modified: pkg/CHNOSZ/man/thermo.Rd
===================================================================
--- pkg/CHNOSZ/man/thermo.Rd	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/man/thermo.Rd	2020-11-13 05:06:17 UTC (rev 629)
@@ -30,7 +30,7 @@
 }
 
 \arguments{
-  \item{...}{list, one or more arguments whose names correspond to the component() to modify}
+  \item{...}{list, one or more arguments whose names correspond to the setting to modify}
 }
 
 \format{

Modified: pkg/CHNOSZ/vignettes/OBIGT.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/OBIGT.Rmd	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/vignettes/OBIGT.Rmd	2020-11-13 05:06:17 UTC (rev 629)
@@ -232,7 +232,7 @@
 
 By convention, the standard Gibbs energy of formation, entropy, and heat capacity of the aqueous proton (H<sup>+</sup>) are 0 at all *T* and *P* ([e.g. Cox et al., 1989](https://www.worldcat.org/oclc/18559968)).
 The formation reaction of the proton can be expressed as &frac12;H<sub>2,(*g*)</sub> + Z = H<sup>+</sup>, where Z is the "element" of positive charge.
-Because the conventional standard Gibbs energy of this reaction is 0 at all *T*, the standard entropy of the reaction is also constrained to be zero (cf. [Puigdomenech et al., 1997](https://www.oecd-nea.org/dbtdb/pubs/book-pdf/427-494.pdf)).
+Because the conventional standard Gibbs energy of this reaction is 0 at all *T*, the standard entropy of the reaction is also constrained to be zero (cf. Puigdomenech et al., 1997).
 Therefore, the "element" of positive charge (Z) has zero thermodynamic properties except for an entropy, *S*°<sub>*T*<sub>r</sub></sub>, that is negative one-half that of H<sub>2,(*g*)</sub>.
 The standard entropy of the aqueous electron, which is a solely a pseudospecies defined by *e*<sup>-</sup> = -Z, is opposite that of Z.
 

Modified: pkg/CHNOSZ/vignettes/mklinks.sh
===================================================================
--- pkg/CHNOSZ/vignettes/mklinks.sh	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/vignettes/mklinks.sh	2020-11-13 05:06:17 UTC (rev 629)
@@ -109,7 +109,7 @@
 
 # add links to multi-metal.html 20200716
 sed -i 's/affinity()/<a href="..\/html\/affinity.html">affinity()<\/a>/g' multi-metal.html
-sed -i 's/flatten()/<a href="..\/html\/mix.html">flatten()<\/a>/g' multi-metal.html
+sed -i 's/mash()/<a href="..\/html\/mix.html">mash()<\/a>/g' multi-metal.html
 sed -i 's/diagram()/<a href="..\/html\/diagram.html">diagram()<\/a>/g' multi-metal.html
 sed -i 's/mosaic()/<a href="..\/html\/mosaic.html">mosaic()<\/a>/g' multi-metal.html
 sed -i 's/equilibrate()/<a href="..\/html\/equilibrate.html">equilibrate()<\/a>/g' multi-metal.html

Modified: pkg/CHNOSZ/vignettes/multi-metal.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/multi-metal.Rmd	2020-11-10 21:46:12 UTC (rev 628)
+++ pkg/CHNOSZ/vignettes/multi-metal.Rmd	2020-11-13 05:06:17 UTC (rev 629)
@@ -77,11 +77,11 @@
 Basic diagrams in CHNOSZ are made for reactions that are *balanced on an element* (see [Equilibrium in CHNOSZ](equilibrium.html)) and therefore represent minerals or aqueous species that all have one element, often a metal, in common.
 The package documentation has many examples of diagrams for a single metal appearing in different minerals or complexed with different ligands, but a common request is to make diagrams for multiple metals.
 This vignette describes some methods for constructing diagrams for multi-metal minerals and other multi-element systems.
-The methods are **flattening**, **mixing**, **mosaic stacking**, and **secondary balancing**.
+The methods are **mashing**, **mixing**, **mosaic stacking**, and **secondary balancing**.
 
-## Flattening
+## Mashing
 
-Flattening or simple overlay refers to independent calculations for two different systems that are displayed on the same diagram.
+Mashing or simple overlay refers to independent calculations for two different systems that are displayed on the same diagram.
 
 This example starts with a log*f*~O<sub>2</sub>~--pH base diagram for the C-O-H system then overlays a diagram for S-O-H.
 The second call to `affinity()` uses the argument recall feature, where the arguments after the first are taken from the previous command.
@@ -88,7 +88,7 @@
 This allows calculations to be run at the same conditions for a different system.
 This feature is also used in other examples in this vignette.
 
-```{r flatten, echo = 1:8, eval = FALSE}
+```{r mash, echo = 1:8, eval = FALSE}
 par(mfrow = c(1, 2))
 basis("CHNOS+")
 species(c("CH4", "CO2", "HCO3-", "CO3-2"))
@@ -97,14 +97,14 @@
 species(c("H2S", "HS-", "HSO4-", "SO4-2"))
 aS <- affinity(aC)  # argument recall
 dS <- diagram(aS, add = TRUE, col = 4, col.names = 4)
-aCS <- flatten(dC, dS)
+aCS <- mash(dC, dS)
 diagram(aCS)
 legend("topright", legend = lTP(25, 1), bty = "n")
 ```
 
-The second diagram is just like the first, except the function `flatten()` is used to label the fields with names of species from both systems, and a legend is added to indicate the temperature and pressure.
+The second diagram is just like the first, except the function `mash()` is used to label the fields with names of species from both systems, and a legend is added to indicate the temperature and pressure.
 
-```{r flatten, echo = 9:11,  results = "hide", message = FALSE, fig.width = 10, fig.height = 5, out.width = "100%"}
+```{r mash, echo = 9:11,  results = "hide", message = FALSE, fig.width = 10, fig.height = 5, out.width = "100%"}
 ```
 
 Note that these are predominance diagrams, so they show only the species with highest activity; there is in fact a distribution of activities of aqueous species that is not visible here.
@@ -114,7 +114,7 @@
 
 ## Mixing 1
 
-In simple terms, flattening two diagrams portrays the mixing together of the two systems.
+As shown above, mashing two diagrams is essentially a simple combination of the two systems.
 Although it is easy to make such a diagram, there is no interaction between the systems.
 If there is a possibility of forming bimetallic species, then additional considerations are needed to account for the stoichiometry of the mixture.
 The stoichiometry can be given as a fixed composition of both metals; then, all combinations of (mono- and/or bimetallic) species that satisfy this compositional constraint are used as the candidate "species" in the system.
@@ -507,10 +507,10 @@
 
 ## Mosaic Stacking 2
 
-The results of a mosaic stack can also be processed with `flatten()` to label each region with the minerals from both systems.
+The results of a mosaic stack can also be processed with `mash()` to label each region with the minerals from both systems.
 For this example, the speciation of aqueous sulfur is not considered; instead, the fugacity of S~2~ is a plotting variable.
 The stable Fe-bearing minerals (Fe-S-O-H) are used as the changing basis species to make the diagram for Cu-bearing minerals (Cu-Fe-S-O-H).
-Then, the two diagrams are flattened to show all minerals in a single diagram.
+Then, the two diagrams are mashed to show all minerals in a single diagram.
 Greener colors are used to indicate minerals with less S~2~ and more O~2~ in their formation reactions.
 
 <button id="B-stack2" onclick="ToggleDiv('stack2')">Show code</button>
@@ -541,8 +541,8 @@
 dCu <- diagram(mCu$A.species, names = abbrv, fill = fill)
 title("Cu-Fe-S-O-H")
 
-# Flatten the diagrams and adjust labels
-aFeCu <- flatten(dFe, dCu)
+# Mash the diagrams and adjust labels
+aFeCu <- mash(dFe, dCu)
 names <- aFeCu$species$name
 srt <- rep(0, length(names))
 srt[names %in% c("Mt+Cu", "Hm+Cu")] <- 90



More information about the CHNOSZ-commits mailing list