Skip to content

Commit

Permalink
Add optional data and update conditions in demo/contour.R
Browse files Browse the repository at this point in the history
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/chnosz/pkg/CHNOSZ@873 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
  • Loading branch information
jedick committed Feb 15, 2025
1 parent 8d29d79 commit 3b04e0b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 40 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Date: 2025-02-15
Package: CHNOSZ
Version: 2.1.0-44
Version: 2.1.0-45
Title: Thermodynamic Calculations and Diagrams for Geochemistry
Authors@R: c(
person("Jeffrey", "Dick", , "[email protected]", role = c("aut", "cre"),
Expand Down
89 changes: 53 additions & 36 deletions demo/contour.R
Original file line number Diff line number Diff line change
@@ -1,47 +1,64 @@
# CHNOSZ/demo/contour.R
# Gold solubility contours on logfO2-pH diagram
# After Williams-Jones et al., 2009, Fig. 3
# doi:10.2113/gselements.5.5.281
# After Williams-Jones et al. (2009) doi:10.2113/gselements.5.5.281
# and Ding et al. (2023) doi:10.1016/j.oregeorev.2022.105231
# with optional data from Tagirov et al. (2024) doi:10.1016/j.gca.2024.08.022
# 20181107 initial version
# 20190415 cleanup for demo
# 20250215 add IGEM data and adjust conditions to reproduce plot from Ding et al.

library(CHNOSZ)

# Define temperature (degrees C), pressure (bar), grid resolution
T <- 250
P <- 500
# Define plot resolution
res <- 600
# Define temperature (degrees C), pressure (bar)
T <- 250
P <- 300
# Define molality of NaCl and total S
m_NaCl <- 1
sum_S <- 0.01
# Define ranges of pH and logfO2
pH <- c(1, 10)
O2 <- c(-40, -30)
# Make smooth (TRUE) or sharp (FALSE) transitions between basis species
blend <- TRUE

# Set up system
basis(c("Au", "Cl-", "H2S", "H2O", "oxygen", "H+"))
iaq <- info(c("Au(HS)2-", "AuHS", "AuOH", "AuCl2-"))
species(iaq)
# This gets us close to total S = 0.01 m
basis("H2S", -2)
# Calculate solution composition for 1 mol/kg NaCl
NaCl <- NaCl(m_NaCl = 1, T = T, P = P)
basis("Cl-", log10(NaCl$m_Clminus))
# Calculate affinity with changing basis species
bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
m <- mosaic(bases, pH = c(2, 10, res), O2 = c(-41, -29, res), T = T, P = P, IS = NaCl$IS, blend = blend)
# Show predominance fields for S-species
diagram(m$A.bases, col = 8, col.names = 8, lty = 2, italic = TRUE)
# Show predominance fields for Au-species
# Plot multiple times to get deeper color
diagram(m$A.species, add=TRUE, col = 7, col.names = 7, lwd = 2, bold = TRUE)
diagram(m$A.species, add=TRUE, col = 7, col.names = 7, lwd = 2, bold = TRUE)
diagram(m$A.species, add=TRUE, col = 7, col.names = 7, lwd = 2, bold = TRUE)
for(i in 1:2) {

# Use the default database for the first diagram
if(i == 1) reset()
# Use IGEM data for the second diagram
if(i == 2) add.OBIGT("IGEM")

# Set up system
basis(c("Au", "Cl-", "H2S", "H2O", "oxygen", "H+"))
iaq <- retrieve("Au", c("H", "O", "S", "Cl"), state = "aq")
species(iaq)
basis("H2S", log10(sum_S))
# Calculate solution composition for given NaCl molality
NaCl <- NaCl(m_NaCl = m_NaCl, T = T, P = P)
basis("Cl-", log10(NaCl$m_Clminus))
# Calculate affinity with changing basis species across diagram
bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
m <- mosaic(bases, pH = c(pH, res), O2 = c(O2, res), T = T, P = P, IS = NaCl$IS, blend = blend)
# Show predominance fields for S-species
diagram(m$A.bases, col = 8, col.names = 8, lty = 3, italic = TRUE)
# Show predominance fields for Au-species
d <- diagram(m$A.species, col = 4, col.names = 4, lty = 2, bold = TRUE, add = TRUE)
# Add dot-dash line for water stability limit
water.lines(d, lty = 4)

# Calculate and plot solubility of Au (use named 'bases' argument to trigger mosaic calculation)
species("Au")
s <- solubility(iaq, bases = bases, pH = c(pH, res), O2 = c(O2, res), T = T, P = P, IS = NaCl$IS, blend = blend)
# Convert to ppb
s <- convert(s, "ppb")
diagram(s, levels = c(1, 10, 100, 1000), col = 1, add = TRUE)
# Add legend and title
dP <- describe.property(c("T", "P"), c(T, P))
lexpr <- lex(dP, lNaCl(m_NaCl), lS(sum_S))
legend("topright", lexpr, bty = "n")
if(i == 1) title(main = ("Gold solubility (ppb), after Ding et al., 2023 (default data)"), font.main = 1)
if(i == 2) title(main = ("Gold solubility (ppb), after Ding et al., 2023 (optional data)"), font.main = 1)

# Calculate and plot solubility of Au (use named 'bases' argument to trigger mosaic calculation)
species("Au")
s <- solubility(iaq, bases = bases, pH = c(2, 10, res), O2 = c(-41, -29, res), T = T, P = P, IS = NaCl$IS, blend = blend)
# Convert to ppb
s <- convert(s, "ppb")
diagram(s, levels = c(1, 10, 100, 1000), add = TRUE)
# Add legend and title
dP <- describe.property(c("T", "P"), c(250, 500))
legend("top", dP, bty = "n", inset = c(0, 0.06))
lx <- lex(lNaCl(1), lS(0.01))
legend("topright", lx, bty = "n", inset = c(0.1, 0.05))
title(main = ("Solubility of gold (ppb), after Williams-Jones et al., 2009, Fig. 3"), font.main = 1)
}
9 changes: 7 additions & 2 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
\newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{<I>C<sub>P</sub></I>}}{Cp}}}
\newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{&Delta;<I>G</I>&deg;}}{ΔG°}}}

\section{Changes in CHNOSZ version 2.1.0-44 (2025-02-15)}{
\section{Changes in CHNOSZ version 2.1.0-45 (2025-02-15)}{

\subsection{OBIGT DEFAULT DATA}{
\itemize{
Expand All @@ -39,7 +39,7 @@
\item Add Pd(HS)\s{4}\S{-2} and Pt(HS)\s{4}\S{-2} from
\href{https://doi.org/10.1016/j.gca.2024.12.019}{Laskar et al. (2024)}.

\item Add Sn chloride complexes and updated parameters for Sn\S{+2},
\item Add Sn chloride complexes and updated parameters for Sn\S{+2} and
Th\S{+4} from \href{https://doi.org/10.1016/j.gsf.2023.101624}{Liu et al.
(2023)}.

Expand Down Expand Up @@ -100,6 +100,11 @@
\item Revise \file{demo/sum_S.R} for log \emph{f}O\s{2} - log \emph{m} ΣS
diagram and add solubility contours for Fe and Au.

\item Update \file{demo/contour.R} to use conditions taken from
\href{https://doi.org/10.1016/j.oregeorev.2022.105231}{Ding et al.
(2023)} and optional data for Au species from IGEM RAS, including
polynuclear Au\s{2}S\s{2}\S{-2}.

}
}

Expand Down
4 changes: 3 additions & 1 deletion man/examples.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The demo(s) to run is/are specified by \code{which}; the default is to run them
\item{arsenic}{Another example of \code{\link{mosaic}}: Eh-pH diagram for the system As-O-H-S (Lu and Zhu, 2011)}
\item{solubility}{Solubility of calcite (cf. Manning et al., 2013) and \CO2 (cf. Stumm and Morgan, 1996)}
\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{contour}{Gold solubility contours on a log fO2 - pH diagram (Ding et al., 2023)}
\item{sphalerite}{Solubility of sphalerite (Akinfiev and Tagirov, 2014)}
\item{minsol}{Solubilities of multiple minerals}
\item{dehydration}{\logK of dehydration reactions; SVG file contains tooltips and links}
Expand Down Expand Up @@ -117,6 +117,8 @@ Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabili
Dick, J. M. (2015) Chemical integration of proteins in signaling and development. \emph{bioRxiv}. \doi{10.1101/015826}
Ding, Z., Sun, X., Hu, S., Chen, H., Li, D., Fu, Y., Xu, L., Wu, Z., and Huang, F.. (2023) Role of carbonaceous material in gold precipitation for orogenic gold deposits: A case study of the Bangbu gold deposit in southern Tibet, China. \emph{Ore Geol. Rev.} \bold{152}, 105231. \doi{10.1016/j.oregeorev.2022.105231}
Garrels, R. M. and Christ, C. L. (1965) \emph{Solutions, Minerals, and Equilibria}, Harper & Row, New York, 450 p. \url{https://www.worldcat.org/oclc/517586}
Guan, Q., Mei, Y., Etschmann, B., Testemale, D., Louvel, M. and Brugger, J. (2020) Yttrium complexation and hydration in chloride-rich hydrothermal fluids: A combined \emph{ab initio} molecular dynamics and \emph{in situ} X-ray absorption spectroscopy study. \emph{Geochim. Cosmochim. Acta} \bold{281}, 168--189. \doi{10.1016/j.gca.2020.04.015}
Expand Down

0 comments on commit 3b04e0b

Please sign in to comment.