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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 5 08:51:48 CET 2026


Author: jedick
Date: 2026-01-05 08:51:47 +0100 (Mon, 05 Jan 2026)
New Revision: 947

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/demo/arsenic.R
   pkg/CHNOSZ/demo/contour.R
   pkg/CHNOSZ/demo/gold.R
   pkg/CHNOSZ/demo/minsol.R
   pkg/CHNOSZ/demo/sum_S.R
   pkg/CHNOSZ/demo/uranyl.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/mosaic.Rd
   pkg/CHNOSZ/man/stack_mosaic.Rd
   pkg/CHNOSZ/man/util.plot.Rd
   pkg/CHNOSZ/vignettes/FAQ.Rmd
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/multi-metal.Rmd
Log:
Add SO2(aq) and S3- to basis species for mosaic calculations


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/DESCRIPTION	2026-01-05 07:51:47 UTC (rev 947)
@@ -1,6 +1,6 @@
-Date: 2025-12-28
+Date: 2026-01-05
 Package: CHNOSZ
-Version: 2.2.0-13
+Version: 2.2.0-14
 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/demo/arsenic.R
===================================================================
--- pkg/CHNOSZ/demo/arsenic.R	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/demo/arsenic.R	2026-01-05 07:51:47 UTC (rev 947)
@@ -6,7 +6,7 @@
 library(CHNOSZ)
 
 # Define temperature (degrees C), pressure (bar), grid resolution
-res <- 500
+res <- 400
 T <- 25
 P <- 1
 # Change this to FALSE to make sharp transitions between the basis species,
@@ -24,7 +24,7 @@
 species(1:length(iaq), -5)
 
 # The possible S-bearing basis species
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+bases <- c("H2S", "HS-", "S3-", "SO2", "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 name of realgar

Modified: pkg/CHNOSZ/demo/contour.R
===================================================================
--- pkg/CHNOSZ/demo/contour.R	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/demo/contour.R	2026-01-05 07:51:47 UTC (rev 947)
@@ -10,7 +10,7 @@
 library(CHNOSZ)
 
 # Define plot resolution
-res <- 600
+res <- 300
 # Define temperature (degrees C), pressure (bar)
 T <- 250
 P <- 300
@@ -39,7 +39,7 @@
   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")
+  bases <- c("H2S", "HS-", "S3-", "SO2", "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)

Modified: pkg/CHNOSZ/demo/gold.R
===================================================================
--- pkg/CHNOSZ/demo/gold.R	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/demo/gold.R	2026-01-05 07:51:47 UTC (rev 947)
@@ -23,7 +23,7 @@
 
 # Sulfur logfO2-pH diagrams showing redox and pH buffers at four temperatures 20181031
 sulfur <- function() {
-  species(c("H2S", "HS-", "HSO4-", "SO4-2"))
+  species(c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"))
   T <- c(200, 300, 400, 500)
   P <- 1000
   O2min <- c(-50, -40, -30, -25)
@@ -157,7 +157,7 @@
   iaq <- info(c("Au(HS)2-", "AuHS", "AuOH", "AuCl2-"))
   s <- solubility(iaq, T = seq(150, 550, 10), `Cl-` = log10(chl$m_Clminus), `K+` = log10(chl$m_Kplus), P = 1000, IS = chl$IS)
 #  # Uncomment to calculate solubility considering speciation of sulfur
-#  bases <- c("H2S", "HS-", "SO4-2", "HSO4-")
+#  bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 #  s <- solubility(iaq, bases = bases, T = seq(150, 550, 10), `Cl-` = log10(chl$m_Clminus), `K+` = log10(chl$m_Kplus), P = 1000, IS = chl$IS)
   # Make diagram and show total log molality
   diagram(s, type = "loga.equil", ylim = c(-10, -3), col = col, lwd = 2, lty = 1)

Modified: pkg/CHNOSZ/demo/minsol.R
===================================================================
--- pkg/CHNOSZ/demo/minsol.R	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/demo/minsol.R	2026-01-05 07:51:47 UTC (rev 947)
@@ -38,7 +38,7 @@
 species(iaq, logm_metal, add = TRUE)
 
 # Calculate affinities and make diagram
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 m <- mosaic(bases, pH = pH, O2 = O2, T = T, P = P, IS = NaCl$IS)
 d <- diagram(m$A.species, bold = TRUE)
 diagram(m$A.bases, add = TRUE, col = 8, col.names = 8, lty = 3, italic = TRUE)

Modified: pkg/CHNOSZ/demo/sum_S.R
===================================================================
--- pkg/CHNOSZ/demo/sum_S.R	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/demo/sum_S.R	2026-01-05 07:51:47 UTC (rev 947)
@@ -29,7 +29,7 @@
 species(c("pyrrhotite", "pyrite", "hematite", "magnetite"))
 
 # List basis species to swap through
-bases <- list( c("SO4-2", "HSO4-", "HS-", "H2S") )
+bases <- list( c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2") )
 # Calculate mosaic for Fe minerals
 m <- mosaic(bases, "SO4-2" = loga_S, O2 = logf_O2, T = T, P = P, IS = IS)
 

Modified: pkg/CHNOSZ/demo/uranyl.R
===================================================================
--- pkg/CHNOSZ/demo/uranyl.R	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/demo/uranyl.R	2026-01-05 07:51:47 UTC (rev 947)
@@ -41,7 +41,7 @@
 basis(c("Na+", "Cl-"), c(logm_Naplus, logm_Clminus))
 species(iaq, logm_U)
 species(icr, add = TRUE)
-bases <- c("SO4-2", "HSO4-", "HS-", "H2S")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 m <- suppressWarnings(mosaic(bases, pH = c(pH_lim, res), "SO4-2" = c(CS_lim, res), T = T, P = P, IS = IS))
 diagram(m$A.species)
 diagram(m$A.bases, add = TRUE, col = 8, lty = 2, col.names = 8, italic = TRUE)

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2026-01-05 07:51:47 UTC (rev 947)
@@ -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{Δ<I>G</I>°}}{ΔG°}}}
 
-\section{Changes in CHNOSZ version 2.2.0-13 (2025-12-28)}{
+\section{Changes in CHNOSZ version 2.2.0-14 (2026-01-05)}{
 
     \itemize{
 
@@ -43,6 +43,10 @@
 
       \item Add colors to \code{demo/NaCl.R}.
 
+      \item Add aqueous SO\s{2} and S\s{3}\S{-} to basis species for mosaic
+      calculations in examples, demos, and vignettes. Thanks to Evgeniy
+      Bastrakov for suggesting this change.
+
     }
 
 }

Modified: pkg/CHNOSZ/man/mosaic.Rd
===================================================================
--- pkg/CHNOSZ/man/mosaic.Rd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/man/mosaic.Rd	2026-01-05 07:51:47 UTC (rev 947)
@@ -66,33 +66,35 @@
 
 \examples{
 \dontshow{reset()}# Fe-minerals and aqueous species in Fe-S-O-H system
-# Speciate SO4-2, HSO4-, HS-, and H2S as a function of Eh and pH
+# Account for aqueous S speciation as a function of Eh and pH
 # After Garrels and Christ, 1965 Figure 7.20
 pH <- c(0, 14)
 Eh <- c(-1, 1)
 T <- 25
-basis(c("FeO", "SO4-2", "H2O", "H+", "e-"))
-basis("SO4-2", -6)
+basis(c("FeO", "H2S", "H2O", "H+", "e-"))
+basis("H2S", -6)
 species(c("Fe+2", "Fe+3"), -6)
 species(c("pyrrhotite", "pyrite", "hematite", "magnetite"), add = TRUE)
 # The basis species we'll swap through
-bases <- c("SO4-2", "HSO4-", "HS-", "H2S")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 # Calculate affinities using the relative abundances of the basis species
 # NOTE: set blend = FALSE for sharp transitions between the basis species
 # (looks more like the diagram in GC65)
-m1 <- mosaic(bases, pH = pH, Eh = Eh, T = T)
+res <- 120
+m1 <- mosaic(bases, pH = c(pH, res), Eh = c(Eh, res), T = T)
 # Make a diagram and add water stability lines
-d <- diagram(m1$A.species, lwd = 2)
+col <- ifelse(species()$state == "aq", 4, 1)
+d <- diagram(m1$A.species, lwd = 2, col = col, col.names = col)
 water.lines(d, col = "seagreen", lwd = 1.5)
 # Show lines for Fe(aq) = 10^-4 M
 species(c("Fe+2", "Fe+3"), -4)
 m2 <- mosaic(bases, pH = pH, Eh = Eh, T = T)
-diagram(m2$A.species, add = TRUE, names = FALSE)
+diagram(m2$A.species, add = TRUE, names = FALSE, fill = NA)
 title(main=paste("Iron oxides and sulfides in water, log(total S) = -6",
   "After Garrels and Christ, 1965", sep="\n"))
 legend("bottomleft", c("log(act_Fe) = -4", "log(act_Fe) = -6"), lwd = c(2, 1), bty = "n")
-# We could overlay the predominance fields for the basis species
-#diagram(m1$A.bases, add = TRUE, col = "blue", col.names = "blue", lty = 3)
+# Overlay the predominance fields for the basis species
+diagram(m1$A.bases, add = TRUE, col = 8, col.names = 8, lty = 3)
 }
 
 \references{

Modified: pkg/CHNOSZ/man/stack_mosaic.Rd
===================================================================
--- pkg/CHNOSZ/man/stack_mosaic.Rd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/man/stack_mosaic.Rd	2026-01-05 07:51:47 UTC (rev 947)
@@ -64,7 +64,7 @@
 # Define temperature (degrees C), pressure (bar), pH and logfO2 ranges
 T <- 200
 P <- "Psat"
-res <- 200
+res <- 150
 pH <- c(0, 14, res)
 O2 <- c(-48, -33, res)
 
@@ -78,7 +78,7 @@
 basis("Cl-", log10(NaCl$m_Clminus))
 
 # Define arguments for stack_mosaic: Speciate aqueous sulfur
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 # Calculate stabilities of Fe-bearing minerals first
 species1 <- c("pyrite", "pyrrhotite", "magnetite", "hematite")
 # Calculate stabilities of Cu-bearing and FeCu-bearing minerals second

Modified: pkg/CHNOSZ/man/util.plot.Rd
===================================================================
--- pkg/CHNOSZ/man/util.plot.Rd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/man/util.plot.Rd	2026-01-05 07:51:47 UTC (rev 947)
@@ -79,7 +79,7 @@
 
 \examples{
 basis(c("H2S", "H2O", "H+", "e-"))
-species(c("HS-", "H2S", "HSO4-", "SO4-2"))
+species(c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"))
 a <- affinity(pH = c(0, 12), Eh = c(-1, 1), T = 200)
 opar <- par(mfrow = c(2, 2))
 diagram(a, grid = "both")

Modified: pkg/CHNOSZ/vignettes/FAQ.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/FAQ.Rmd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/vignettes/FAQ.Rmd	2026-01-05 07:51:47 UTC (rev 947)
@@ -569,7 +569,7 @@
 
 ## BLOCK 3
 basis(c("Ni", "SiO2", "Fe2O3", "H2S", "H2O", "oxygen", "H+"))
-species(c("H2S", "HS-", "SO2", "HSO4-", "SO4-2", "S3-"))
+species(c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"))
 a <- affinity(pH = c(2, 10, res), O2 = c(-34, -22, res), T = T, P = P)
 e <- equilibrate(a, loga.balance = logm_S)
 diagram(e)
@@ -692,7 +692,7 @@
 # The first four lines are stand-ins to make this block runnable and get the right output from info();
 # the diagram actually shown in the vignette is made using the 'trisulfur' block above
 b <- basis("CHNOS+")
-s <- species(c("H2S", "HS-", "SO2", "HSO4-", "SO4-2", "S3-"))
+s <- species(c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"))
 res <- 10
 wt_percent_S <- logm_S <- 0
 ######## End of stand-in code ########
@@ -966,11 +966,11 @@
 The code below makes a diagram for the minerals shown in that figure:
 
 ```{r Fe-S-O-C, message = FALSE, results = "hide", fig.width = 5, fig.height = 5, out.width = "60%", fig.align = "center", pngquant = pngquant, cache = TRUE}
-basis(c("FeO", "SO4-2", "CO3-2", "H2O", "H+", "oxygen"))
-basis("SO4-2", -3)
+basis(c("FeO", "H2S", "CO3-2", "H2O", "H+", "oxygen"))
+basis("H2S", -3)
 basis("CO3-2", -0.6)
 species(c("hematite", "pyrite", "pyrrhotite", "magnetite", "siderite"))
-bases <- list( c("SO4-2", "HSO4-", "HS-", "H2S"), c("CO3-2", "HCO3-", "CO2") )
+bases <- list( c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"), c("CO3-2", "HCO3-", "CO2") )
 m <- mosaic(bases, pH = c(0, 14, 500), O2 = c(-57, -35, 500), T = 150, IS = 0.77)
 d <- diagram(m$A.species, fill = "terrain", dx = c(0, 0, 0, 0, 0.3))
 water.lines(d)

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2026-01-05 07:51:47 UTC (rev 947)
@@ -258,7 +258,7 @@
 # Setup the C-H-N-O-S basis system with electron
 basis("CHNOSe")
 # Define aqueous sulfur species
-species(c("SO4-2", "HSO4-", "HS-", "H2S"))
+species(c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"))
 # Calculate affinities on an Eh-pH grid
 a <- affinity(pH = c(0, 14), Eh = c(-0.8, 1.2))
 # Create an Eh-pH (Pourbaix) diagram
@@ -280,7 +280,7 @@
 basis("Cl-", -1)
 species(c("CuCl", "CuCl2-", "CuCl3-2", "CuCl+", "CuCl2", "CuCl3-", "CuCl4-2"))
 species(c("chalcocite", "tenorite", "cuprite", "copper"), add = TRUE)
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 m <- mosaic(bases, pH = c(0, 12), Eh = c(-1, 1), T = 200)
 a <- m$A.species
 diagram(a, lwd = 2, bold = species()$state == "cr")
@@ -434,7 +434,7 @@
 basis("H2S", log10(Stot))
 basis("Cl-", log10(m_Clminus))
 # Define basis species to swap through for mosaic calculation
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 
 # Get minerals and aqueous species
 icr <- info(c("hematite", "magnetite", "pyrite", "pyrrhotite"))
@@ -802,7 +802,7 @@
 basis("H2S", log10(Stot))
 basis("Cl-", log10(m_Clminus))
 # Define basis species to swap through for mosaic calculation
-bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 
 # Get minerals and aqueous species
 icr <- retrieve(metal, c("Cl", "S", "O", "H"), state = "cr")
@@ -1440,7 +1440,7 @@
 # Load aqueous species for relative stability calculation
 species(iaq)
 # Define basis species to swap through for mosaic calculation
-bases <- c("H2S", "HS-", "SO4-2", "HSO4-")
+bases <- c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2")
 m <- mosaic(bases = bases, pH = c(2, 8), O2 = c(-32, -24), T = T_fixed, P = P)
 a <- m$A.species
 fill <- adjustcolor(col, alpha.f = 0.5)

Modified: pkg/CHNOSZ/vignettes/multi-metal.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/multi-metal.Rmd	2025-12-28 04:38:30 UTC (rev 946)
+++ pkg/CHNOSZ/vignettes/multi-metal.Rmd	2026-01-05 07:51:47 UTC (rev 947)
@@ -134,7 +134,7 @@
 species(c("CH4", "CO2", "HCO3-", "CO3-2"))
 aC <- affinity(pH = c(0, 14), O2 = c(-75, -60))
 dC <- diagram(aC, dx = c(0, 1, 0, 0), dy = c(0, 1, 0, 0))
-species(c("H2S", "HS-", "HSO4-", "SO4-2"))
+species(c("H2S", "HS-", "S3-", "SO2", "HSO4-", "SO4-2"))
 aS <- affinity(aC)  # argument recall
 dS <- diagram(aS, add = TRUE, col = 4, col.names = 4, dx = c(0, -0.5, 0, 0))
 aCS <- mash(dC, dS)



More information about the CHNOSZ-commits mailing list