[CHNOSZ-commits] r735 - in pkg/CHNOSZ: . R demo man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 21 06:22:26 CEST 2022
Author: jedick
Date: 2022-07-21 06:22:25 +0200 (Thu, 21 Jul 2022)
New Revision: 735
Added:
pkg/CHNOSZ/demo/minsol.R
Removed:
pkg/CHNOSZ/demo/zinc.R
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/examples.R
pkg/CHNOSZ/demo/00Index
pkg/CHNOSZ/man/examples.Rd
Log:
Rename demo/zinc.R to minsol.R
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2022-07-15 03:12:50 UTC (rev 734)
+++ pkg/CHNOSZ/DESCRIPTION 2022-07-21 04:22:25 UTC (rev 735)
@@ -1,6 +1,6 @@
-Date: 2022-07-15
+Date: 2022-07-21
Package: CHNOSZ
-Version: 1.9.9-27
+Version: 1.9.9-28
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/examples.R
===================================================================
--- pkg/CHNOSZ/R/examples.R 2022-07-15 03:12:50 UTC (rev 734)
+++ pkg/CHNOSZ/R/examples.R 2022-07-21 04:22:25 UTC (rev 735)
@@ -32,7 +32,7 @@
demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density",
"ORP", "findit", "ionize", "buffer", "protbuff", "glycinate",
- "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite", "zinc",
+ "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite", "minsol",
"Shh", "saturation", "DEW", "lambda", "potassium", "TCA", "aluminum",
"AD", "comproportionation", "Pourbaix", "E_coli"), save.png=FALSE) {
# run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one
Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index 2022-07-15 03:12:50 UTC (rev 734)
+++ pkg/CHNOSZ/demo/00Index 2022-07-21 04:22:25 UTC (rev 735)
@@ -16,7 +16,7 @@
gold Solubility of gold
contour Gold solubility contours on a log fO2 - pH diagram
sphalerite Solubility of sphalerite
-zinc Solubilities of multiple minerals (zincite and sphalerite)
+minsol Solubilities of multiple minerals
dehydration log K of dehydration reactions; SVG file contains tooltips and links
Shh Affinities of transcription factors relative to Sonic hedgehog
saturation Equilibrium activity diagram showing activity ratios and mineral saturation limits
Copied: pkg/CHNOSZ/demo/minsol.R (from rev 734, pkg/CHNOSZ/demo/zinc.R)
===================================================================
--- pkg/CHNOSZ/demo/minsol.R (rev 0)
+++ pkg/CHNOSZ/demo/minsol.R 2022-07-21 04:22:25 UTC (rev 735)
@@ -0,0 +1,84 @@
+# CHNOSZ/demo/minsol.R
+# Make solubility diagram with multiple minerals
+# 20190530 jmd first version (plot_Zn.R)
+# 20201008 combine solubility contours for different minerals
+# 20201014 added to CHNOSZ
+# 20220715 Allow to change metals (renamed from zinc.R to minsol.R)
+
+library(CHNOSZ)
+opar <- par(no.readonly = TRUE)
+par(mfrow = c(2, 2))
+
+# System variables
+metal <- "Zn"
+res <- 300
+T <- 100
+P <- "Psat"
+Stot <- 1e-3
+pH <- c(0, 14, res)
+O2 <- c(-62, -40, res)
+# Mass fraction NaCl in saturated solution at 100 degC, from CRC handbook
+wNaCl <- 0.2805
+
+# Set up basis species
+basis(c(metal, "H2S", "Cl-", "oxygen", "H2O", "H+"))
+basis("H2S", log10(Stot))
+# Molality of NaCl
+mNaCl <- 1000 * wNaCl / (mass("NaCl") * (1 - wNaCl))
+# Estimate ionic strength and molality of Cl-
+sat <- NaCl(T = T, m_tot = mNaCl)
+basis("Cl-", log10(sat$m_Cl))
+
+# Add minerals and aqueous species
+icr <- retrieve(metal, c("Cl", "S", "O"), state = "cr")
+iaq <- retrieve(metal, c("Cl", "S", "O"), state = "aq")
+logm_metal <- -3
+species(icr)
+species(iaq, logm_metal, add = TRUE)
+
+# Calculate affinities and make diagram
+bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+m <- mosaic(bases, pH = pH, O2 = O2, T = T, P = P, IS = sat$IS)
+d <- diagram(m$A.species, bold = TRUE)
+diagram(m$A.bases, add = TRUE, col = "slategray", lwd = 2, lty = 3, names = NA)
+title(bquote(log * italic(m)[.(metal)*"(aq) species"] == .(logm_metal)))
+label.figure("A")
+
+# Add legend
+plot.new()
+l <- c(
+ lTP(T, P),
+ lNaCl(mNaCl),
+ lS(Stot)
+)
+legend("topleft", legend = lex(l), bty = "n", cex = 1.5)
+# Describe steps
+par(xpd = NA)
+legend("bottomleft", c("Predominance diagram: molality of aqueous", "species defines one solubility contour.",
+ "Take away aqueous species to see", "all possible minerals.",
+ "Calculate solubility for each mineral separately", "then find the minimum to plot solubilities", "of stable minerals across the diagram."),
+ pch = c("A", "", "B", "", "C", "", ""), inset = c(-0.1, 0), cex = 0.95)
+par(xpd = FALSE)
+
+# Make diagram for minerals only 20201007
+if(packageVersion("CHNOSZ") <= "1.3.6") species(delete = TRUE)
+species(icr)
+mcr <- mosaic(bases, pH = pH, O2 = O2, T = T, P = P, IS = sat$IS)
+diagram(mcr$A.species, col = 2)
+label.figure("B")
+
+# Calculate *minimum* solubility among all the minerals 20201008
+# (i.e. saturation condition for the solution)
+# Use solubility() 20210303
+s <- solubility(iaq, bases = bases, pH = pH, O2 = O2, T = T, P = P, IS = sat$IS, in.terms.of = metal)
+# Specify contour levels
+levels <- seq(-12, 9, 3)
+diagram(s, type = "loga.balance", levels = levels, contour.method = "flattest")
+
+# Show the mineral stability boundaries
+diagram(mcr$A.species, names = NA, add = TRUE, lty = 2, col = 2)
+title(paste("Solubilities of", length(icr), "minerals"), font.main = 1, line = 1.5)
+title(bquote(log[10]~"moles of"~.(metal)~"in solution"), line = 0.7)
+label.figure("C")
+
+par(opar)
Deleted: pkg/CHNOSZ/demo/zinc.R
===================================================================
--- pkg/CHNOSZ/demo/zinc.R 2022-07-15 03:12:50 UTC (rev 734)
+++ pkg/CHNOSZ/demo/zinc.R 2022-07-21 04:22:25 UTC (rev 735)
@@ -1,83 +0,0 @@
-# CHNOSZ/demo/zinc.R
-# Make Zn solubility diagram with multiple minerals
-# 20190530 jmd first version (plot_Zn.R)
-# 20201008 combine solubility contours for different minerals
-# 20201014 added to CHNOSZ
-
-library(CHNOSZ)
-opar <- par(no.readonly = TRUE)
-par(mfrow = c(2, 2))
-
-# System variables
-res <- 300
-T <- 100
-P <- "Psat"
-Stot <- 1e-3
-pH <- c(0, 14, res)
-O2 <- c(-62, -40, res)
-# Mass percent NaCl in saturated solution at 100 degC, from CRC handbook
-w2 <- 0.2805
-
-# Set up basis species
-basis(c("ZnO", "H2S", "Cl-", "oxygen", "H2O", "H+"))
-basis("H2S", log10(Stot))
-# Molality of NaCl in saturated solution
-m2 <- 1000 * w2 / (mass("NaCl") * (1 - w2))
-# Estimate ionic strength and molality of Cl-
-sat <- NaCl(T = 100, m_tot = m2)
-basis("Cl-", log10(sat$m_Cl))
-
-# Add minerals and aqueous species
-icr <- (c("sphalerite", "zincite"))
-iaq <- (c("ZnCl4-2", "ZnO2-2"))
-logm_Zn <- -3
-species(c(icr, iaq), c(0, 0, logm_Zn, logm_Zn))
-
-# Calculate affinities and make diagram
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
-m <- mosaic(bases, pH = pH, O2 = O2, T = T, P = P, IS = sat$IS)
-fill <- c("lightgoldenrod1", "goldenrod1", "skyblue", "skyblue")
-col.names <- c("red", "red", "blue", "blue")
-d <- diagram(m$A.species, fill = fill, col.names = col.names, bold = TRUE)
-diagram(m$A.bases, add = TRUE, col = "slategray", lwd = 2, lty = 3, names = NA)
-title(bquote(log * italic(m)["Zn(aq) species"] == .(logm_Zn)))
-label.figure("A")
-
-# Add legend
-plot.new()
-l <- c(
- lTP(T, P),
- lNaCl(m2),
- lS(Stot)
-)
-legend("topleft", legend = lex(l), bty = "n", cex = 1.5)
-# Describe steps
-par(xpd = NA)
-legend("bottomleft", c("Predominance diagram: molality of aqueous", "species defines one solubility contour.",
- "Take away aqueous species to see", "all possible minerals.",
- "Calculate solubility for each mineral separately", "then find the minimum to plot solubilities", "of stable minerals across the diagram."),
- pch = c("A", "", "B", "", "C", "", ""), inset = c(-0.1, 0), cex = 0.95)
-par(xpd = FALSE)
-
-# Make diagram for Zn minerals only 20201007
-if(packageVersion("CHNOSZ") <= "1.3.6") species(delete = TRUE)
-species(icr)
-mcr <- mosaic(bases, pH = pH, O2 = O2, T = T, P = P, IS = sat$IS)
-diagram(mcr$A.species, col = 2)
-label.figure("B")
-
-# Calculate *minimum* solubility among all the minerals 20201008
-# (i.e. saturation condition for the solution)
-# Use solubility() 20210303
-s <- solubility(iaq, bases = bases, pH = pH, O2 = O2, T = T, P = P, IS = sat$IS, in.terms.of = "Zn")
-# Specify contour levels
-levels <- seq(-12, 9, 3)
-diagram(s, type = "loga.balance", levels = levels, contour.method = "flattest")
-
-# Show the mineral stability boundaries
-diagram(mcr$A.species, names = NA, add = TRUE, lty = 2, col = 2)
-title("Solubilities of 2 minerals", font.main = 1, line = 1.5)
-title(bquote(log[10]~"moles of Zn in solution"), line = 0.7)
-label.figure("C")
-
-par(opar)
Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd 2022-07-15 03:12:50 UTC (rev 734)
+++ pkg/CHNOSZ/man/examples.Rd 2022-07-21 04:22:25 UTC (rev 735)
@@ -16,7 +16,7 @@
demos(which = c("sources", "protein.equil", "affinity", "NaCl",
"density", "ORP", "findit", "ionize", "buffer", "protbuff",
"glycinate", "mosaic", "copper", "arsenic", "solubility", "gold",
- "contour", "sphalerite", "zinc", "Shh", "saturation",
+ "contour", "sphalerite", "minsol", "Shh", "saturation",
"DEW", "lambda", "potassium", "TCA", "aluminum", "AD",
"comproportionation", "Pourbaix", "E_coli"),
save.png=FALSE)
@@ -49,7 +49,7 @@
\item{gold}{Solubility of gold (Akinfiev and Zotov; 2001; Stef{\aacute}nsson and Seward, 2004; Williams-Jones et al., 2009)}
\item{contour}{Gold solubility contours on a log fO2 - pH diagram (Williams-Jones et al., 2009)}
\item{sphalerite}{Solubility of sphalerite (Akinfiev and Tagirov, 2014)}
- \item{zinc}{Solubilities of multiple minerals (zincite and sphalerite)}
+ \item{minsol}{Solubilities of multiple minerals}
\item{dehydration}{\logK of dehydration reactions; SVG file contains tooltips and links}
\item{Shh}{Affinities of transcription factors relative to Sonic hedgehog (Dick, 2015)}
\item{saturation}{Equilibrium activity diagram showing activity ratios and mineral saturation limits (Bowers et al., 1984)}
More information about the CHNOSZ-commits
mailing list