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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 15 11:20:57 CEST 2019


Author: jedick
Date: 2019-04-15 11:20:57 +0200 (Mon, 15 Apr 2019)
New Revision: 443

Added:
   pkg/CHNOSZ/demo/arsenic.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/R/examples.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/demo/go-IU.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/diagram.Rd
   pkg/CHNOSZ/man/examples.Rd
   pkg/CHNOSZ/vignettes/obigt.Rmd
Log:
add demo/arsenic.R (Eh-pH diagram after Lu and Zhu, 2011)


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/DESCRIPTION	2019-04-15 09:20:57 UTC (rev 443)
@@ -1,6 +1,6 @@
 Date: 2019-04-15
 Package: CHNOSZ
-Version: 1.3.1-23
+Version: 1.3.1-24
 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	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/R/diagram.R	2019-04-15 09:20:57 UTC (rev 443)
@@ -550,7 +550,7 @@
       if(is.null(fill) | length(fill)==0) fill <- "transparent"
       else if(isTRUE(fill[1]=="rainbow")) fill <- rainbow(ngroups)
       else if(isTRUE(fill[1] %in% c("heat", "terrain", "topo", "cm"))) fill <- get(paste0(fill[1], ".colors"))(ngroups)
-      else if(getRversion() >= "3.6.0") {
+      else if(getRversion() >= "3.6.0" & length(fill)==1) {
         # choose an HCL palette 20190411
         # matching adapted from hcl.colors()
         fx <- function(x) tolower(gsub("[-, _, \\,, (, ), \\ , \\.]", "", x))

Modified: pkg/CHNOSZ/R/examples.R
===================================================================
--- pkg/CHNOSZ/R/examples.R	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/R/examples.R	2019-04-15 09:20:57 UTC (rev 443)
@@ -29,7 +29,7 @@
 
 demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", 
   "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "glycinate",
-  "mosaic", "copper", "solubility", "gold", "contour", "wjd", "bugstab", "Shh", "saturation",
+  "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "wjd", "bugstab", "Shh", "saturation",
   "adenine", "DEW", "lambda", "TCA", "go-IU", "bison", "AkDi"), save.png=FALSE) {
   # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one
   for(i in 1:length(which)) {

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/demo/00Index	2019-04-15 09:20:57 UTC (rev 443)
@@ -13,6 +13,7 @@
 glycinate       Metal-glycinate complexes
 mosaic          Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species
 copper          Another example of mosaic(): complexation of copper with glycine species
+arsenic         Another example of mosaic(): Eh-pH diagram for the system As-O-H-S
 solubility      Solubility of calcite and CO2(gas) as a function of pH
 gold            Solubility of gold
 contour         Gold solubility contours on log fO2 - pH diagram

Added: pkg/CHNOSZ/demo/arsenic.R
===================================================================
--- pkg/CHNOSZ/demo/arsenic.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/arsenic.R	2019-04-15 09:20:57 UTC (rev 443)
@@ -0,0 +1,40 @@
+# CHNOSZ/demo/arsenic.R
+# Eh-pH diagram for the system As-O-H-S,
+# after Lu and Zhu, 2011 (doi:10.1007/s12665-010-0652-x)
+
+# 20190415 extracted from go-IU.R; use retrieve()
+
+# define temperature (degrees C), pressure (bar), grid resolution
+res <- 500
+T <- 25
+P <- 1
+# change this to FALSE to make sharp transitions between the basis species,
+# giving a diagram with straight lines around the AsS(OH)HS- wedge
+blend <- TRUE
+
+# set basis species
+basis(c("As", "H2O", "H2S", "H+", "e-"))
+basis(c("H2S"), c(-3))
+# find and set formed species
+iaq <- retrieve("As", c("S", "O", "H"), "aq")
+icr <- retrieve("As", c("S", "O", "H"), "cr")
+species(c(iaq, icr))
+# set activities of aqueous species
+species(1:length(iaq), -5)
+
+# the possible S-bearing basis species
+bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+# calculate affinties of formation reactions using the speciated S basis species
+m <- mosaic(bases, pH = c(0, 14, res), Eh = c(-0.8, 0.8, res), T = T, P = 1, blend = blend)
+# adjust colors and names
+fill <- rev(heat.colors(nrow(species())))
+fill[which(species()$state == "cr")] <- "slategray3"
+m$A.species$species$name <- gsub(",alpha", "", m$A.species$species$name)
+# make the plot!
+diagram(m$A.species, fill = fill)
+# add legend and title
+dprop <- describe.property(c("T", "P"), c(T, P))
+legend("bottomleft", legend = dprop, bty = "n")
+t1 <- quote("As-O-H-S, "~list(Sigma*S == 10^-3~M, Sigma*As == 10^-5~M))
+t2 <- "After Lu and Zhu, 2011 Fig. 2b"
+mtitle(as.expression(c(t1, t2)), cex = 0.95)

Modified: pkg/CHNOSZ/demo/go-IU.R
===================================================================
--- pkg/CHNOSZ/demo/go-IU.R	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/demo/go-IU.R	2019-04-15 09:20:57 UTC (rev 443)
@@ -79,59 +79,6 @@
 # doi:10.1016/j.cageo.2016.02.013
 
 ###########
-### plot 3: Eh-pH diagram for As-O-H-S
-###########
-basis(c("As", "H2O", "H2S", "H+", "e-"))
-basis(c("H2S"), c(-3))
-As_aq <- c("H3AsO4", "H2AsO4-", "HAsO4-2", "AsO4-3", "H3AsO3", "H2AsO3-", "HAsO3-2", "AsO3-3")
-AsS_aq <- c("AsS(OH)HS-", "As3S4(HS)2-")
-As_cr <- "As"
-AsS_cr <- c("realgar,alpha", "realgar,beta", "orpiment", "orpiment,amorphous")
-FeAs_cr <- c("arsenopyrite", "scorodite", "ferric arsenate,amorphous")
-#species(c(As_aq, AsS_aq, As_cr, AsS_cr, FeAs_cr))
-species(c(As_aq, AsS_aq, As_cr, AsS_cr))
-species(c(As_aq, AsS_aq), -5)
-## a simple diagram, but using only H2S at all pH
-#a <- affinity(pH=c(0, 14), Eh=c(-1, 1.5))
-#diagram(a)
-# the S basis species depends on pH
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
-# calculate affinties of formation reactions using the speciated S basis species
-res <- 300
-# the default has blend = TRUE, unlike LZ11's diagram where
-# it appears the S-basis species are switched in an on/off fashion
-m <- mosaic(bases, pH=c(0, 14, res), Eh=c(-0.8, 0.8, res))
-# adjust colors and names
-fill <- rev(heat.colors(nrow(species())))
-fill[11:15] <- "darkgrey"
-m$A.species$species$name <- gsub(",alpha", "", m$A.species$species$name)
-diagram(m$A.species, fill=fill)
-dprop <- describe.property(c("T", "P"), c(25, 1))
-legend("bottomleft", legend=dprop, bty="n")
-t1 <- quote("As-O-H-S, "~list(Sigma*S==10^-3~M, Sigma*As==10^-5~M))
-t2 <- "After Lu and Zhu, 2011 Fig. 2b"
-# doi:10.1007/s12665-010-0652-x
-mtitle(as.expression(c(t1, t2)), cex=0.95)
-
-###########
-### plot 4: aqueous Al species
-###########
-basis(c("Al+3", "F-", "H+", "O2", "H2O"))
-AlOH <- c("Al(OH)4-", "Al(OH)3", "Al(OH)2+", "AlOH+2")
-Al <- "Al+3"
-AlF <- c("AlF+2", "AlF2+", "AlF3", "AlF4-")
-AlOHF <- c("Al(OH)2F2-", "Al(OH)2F", "AlOHF2")
-species(c(AlOH, Al, AlF, AlOHF), "aq")
-res <- 300
-a <- affinity(pH=c(0.5, 6.5, res), `F-`=c(-2, -9, res), T=200)
-diagram(a, fill=rev(cm.colors(nrow(species()))))
-dprop <- describe.property(c("T", "P"), c(200, "Psat"))
-legend("topright", legend=dprop, bty="n")
-mtitle(c("Aqueous aluminum species",
-         "After Tagirov and Schott, 2001 Fig. 4d"), cex=0.95)
-# doi:10.1016/S0016-7037(01)00705-0
-
-###########
 ### clean up: restore thermodynamic database to default
 ###########
 reset()

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/inst/NEWS	2019-04-15 09:20:57 UTC (rev 443)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.3.1-23 (2019-04-15)
+CHANGES IN CHNOSZ 1.3.1-24 (2019-04-15)
 ---------------------------------------
 
 - Add thermo/stoich.csv.xz (loaded as thermo()$stoich), containing a
@@ -38,6 +38,8 @@
   tick marks can be added using the 'grid' argument. Or, use
   thermo.axis() after diagram() to overlay a grid.
 
+- Add demo/arsenic.R (Eh-pH diagram after Lu and Zhu, 2011).
+
 CHANGES IN CHNOSZ 1.3.1 (2019-03-02)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/man/diagram.Rd	2019-04-15 09:20:57 UTC (rev 443)
@@ -264,6 +264,22 @@
 text(3, 22, describe.basis(thermo()$basis[2:3,], digits=2, oneline=TRUE))
 text(3, 21, describe.property(c("T", "P"), c(25, 1), oneline=TRUE))
 
+## aqueous Al species, after Tagirov and Schott, 2001
+# this uses a HCL palette for the fill colors
+basis(c("Al+3", "F-", "H+", "O2", "H2O"))
+AlOH <- c("Al(OH)4-", "Al(OH)3", "Al(OH)2+", "AlOH+2")
+Al <- "Al+3"
+AlF <- c("AlF+2", "AlF2+", "AlF3", "AlF4-")
+AlOHF <- c("Al(OH)2F2-", "Al(OH)2F", "AlOHF2")
+species(c(AlOH, Al, AlF, AlOHF), "aq")
+res <- 300
+a <- affinity(pH = c(0.5, 6.5, res), `F-` = c(-2, -9, res), T = 200)
+diagram(a, fill = "pastel")
+dprop <- describe.property(c("T", "P"), c(200, "Psat"))
+legend("topright", legend = dprop, bty = "n")
+mtitle(c("Aqueous aluminum species",
+         "After Tagirov and Schott, 2001 Fig. 4d"), cex = 0.95)
+
 ## Temperature-Pressure: kayanite-sillimanite-andalusite
 # cf. Fig. 49 of Helgeson et al., 1978
 # this is a system of one component (Al2SiO5), however:
@@ -300,6 +316,9 @@
   LaRowe, D. E. and Helgeson, H. C. (2007) Quantifying the energetics of metabolic reactions in diverse biogeochemical systems: electron flow and ATP synthesis. \emph{Geobiology} \bold{5}, 153--168. \url{https://doi.org/10.1111/j.1472-4669.2007.00099.x}
 
   Majzlan, J., Navrotsky, A., McClesky, R. B. and Alpers, C. N. (2006) Thermodynamic properties and crystal structure refinement of ferricopiapite, coquimbite, rhomboclase, and Fe\s{2}(SO\s{4})\s{3}(H\s{2}O)\s{5}. \emph{Eur. J. Mineral.} \bold{18}, 175--186. \url{https://doi.org/10.1127/0935-1221/2006/0018-0175}
+
+  Tagirov, B. and Schott, J. (2001) Aluminum speciation in crustal fluids revisited. \emph{Geochim. Cosmochim. Acta} \bold{65}, 3965--3992. \url{https://doi.org/10.1016/S0016-7037(01)00705-0}
+
 }
 
 \concept{Main workflow}

Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/man/examples.Rd	2019-04-15 09:20:57 UTC (rev 443)
@@ -16,8 +16,8 @@
   demos(which = c("sources", "protein.equil", "affinity", "NaCl",
     "density", "ORP", "revisit", "findit", "ionize", "buffer",
     "protbuff", "yeastgfp", "glycinate", "mosaic", "copper",
-    "solubility", "gold", "contour", "wjd", "bugstab", "Shh",
-    "saturation", "adenine", "DEW", "lambda", "TCA", "go-IU",
+    "arsenic", "solubility", "gold", "contour", "wjd", "bugstab",
+    "Shh", "saturation", "adenine", "DEW", "lambda", "TCA", "go-IU",
     "bison", "AkDi"),
     save.png=FALSE)
 }
@@ -46,6 +46,7 @@
     \code{glycinate} \tab Metal-glycinate complexes (Shock and Koretsky, 1995; Azadi et al., 2019) \cr
     \code{mosaic} \tab Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr
     \code{copper} \tab Another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr
+    \code{arsenic} \tab Another example of \code{\link{mosaic}}: Eh-pH diagram for the system As-O-H-S (Lu and Zhu, 2011) \cr
     \code{solubility} \tab Solubility of calcite (cf. Manning et al., 2013) and \CO2 (cf. Stumm and Morgan, 1996) \cr
     \code{gold} \tab Solubility of gold (Akinfiev and Zotov; 2001; Stef{\aacute}nsson and Seward, 2004; Williams-Jones et al., 2009) \cr
     \code{contour} \tab Gold solubility contours on log fO2 - pH diagram (Williams-Jones et al., 2009) \cr
@@ -120,6 +121,8 @@
 Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000\degC. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{https://doi.org/10.1016/0098-3004(92)90029-Q}
 
 Lowe, A. R., Cox, J. S. and Tremaine, P. R. (2017) Thermodynamics of aqueous adenine: Standard partial molar volumes and heat capacities of adenine, adeninium chloride, and sodium adeninate from \emph{T} = 278.15 K to 393.15 K. \emph{J. Chem. Thermodyn.} \bold{112}, 129--145. \url{https://doi.org/10.1016/j.jct.2017.04.005}
+
+Lu, P. and Zhu, C. (2011) Arsenic Eh--pH diagrams at 25\degC and 1 bar. \emph{Environ. Earth Sci.} \bold{62}, 1673--1683. \url{https://doi.org/10.1007/s12665-010-0652-x}
   
 Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{https://doi.org/10.2138/rmg.2013.75.5}
 

Modified: pkg/CHNOSZ/vignettes/obigt.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/obigt.Rmd	2019-04-15 06:46:07 UTC (rev 442)
+++ pkg/CHNOSZ/vignettes/obigt.Rmd	2019-04-15 09:20:57 UTC (rev 443)
@@ -211,7 +211,7 @@
 
 ### `r setfile("DEW_aq.csv")`
 ```{r DEW_aq, results="asis", echo=FALSE}
-cat("The [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model extends the applicability of the revised HKF equations of state to 60 kbar. Accuracy of the thermodynamic calculations at these conditions is improved by revised correlations for the <i>a</i><sub>1</sub> HKF parameter, as described by [Sverjensky et al., 2014](https://doi.org/10.1016/j.gca.2013.12.019). The data here were taken from the May 2017 version of the DEW spreadsheet ([Dew Model, 2017](http://www.dewcommunity.org/resources.html)). The following species are present in the spreadsheet, but are not listed in `DEW_aq.csv` because the parameters are unchanged from the default database in CHNOSZ: B(OH)<sub>3</sub>, Br<sup>-</sup>, Ca<sup>+2</sup>, Cl<sup>-</sup>, Cs<sup>+</sup>, F<sup>-</sup>, H<sup>+</sup>, H<sub>2</sub>, He, I<sup>-</sup>, K<sup>+</sup>, Kr, Li<sup>+</sup>, Mg<sup>+2</sup>, Na<sup>+</sup>, Ne, O<sub>2</sub>, Rb<sup>+</sup>, Rn.\n\n")
+cat("The [Deep Earth Water](http://www.dewcommunity.org/) (DEW) model extends the applicability of the revised HKF equations of state to 60 kbar. Accuracy of the thermodynamic calculations at these conditions is improved by revised correlations for the <i>a</i><sub>1</sub> HKF parameter, as described by [Sverjensky et al., 2014](https://doi.org/10.1016/j.gca.2013.12.019). The data here were taken from the May 2017 version of the DEW spreadsheet ([Dew Model, 2017](http://www.dewcommunity.org/resources.html)). The following species are present in the spreadsheet, but are not used here because the parameters are unchanged from the default database in CHNOSZ: B(OH)<sub>3</sub>, Br<sup>-</sup>, Ca<sup>+2</sup>, Cl<sup>-</sup>, Cs<sup>+</sup>, F<sup>-</sup>, H<sup>+</sup>, H<sub>2</sub>, He, I<sup>-</sup>, K<sup>+</sup>, Kr, Li<sup>+</sup>, Mg<sup>+2</sup>, Na<sup>+</sup>, Ne, O<sub>2</sub>, Rb<sup>+</sup>, Rn.\n\n")
 cat("Besides using <span style='color:red'>`add.obigt('DEW')`</span> to load these data, you should also run <span style='color:red'>`water('DEW')`</span> to activate the DEW equations in CHNOSZ. See [<span style='color:blue'>`demo(DEW)`</span>](../demo) for some examples.<hr>")
 ```
 



More information about the CHNOSZ-commits mailing list