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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 28 08:36:27 CET 2024


Author: jedick
Date: 2024-11-28 08:36:27 +0100 (Thu, 28 Nov 2024)
New Revision: 850

Added:
   pkg/CHNOSZ/demo/sum_S.R
Removed:
   pkg/CHNOSZ/demo/total_S.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/examples.R
   pkg/CHNOSZ/R/util.expression.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/examples.Rd
Log:
Rename and update demo/sum_S.R and use sum symbol in axis.label()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/DESCRIPTION	2024-11-28 07:36:27 UTC (rev 850)
@@ -1,6 +1,6 @@
-Date: 2024-11-17
+Date: 2024-11-28
 Package: CHNOSZ
-Version: 2.1.0-22
+Version: 2.1.0-23
 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	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/R/examples.R	2024-11-28 07:36:27 UTC (rev 850)
@@ -34,7 +34,7 @@
   "ORP", "ionize", "buffer", "protbuff", "glycinate",
   "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite", "minsol",
   "Shh", "saturation", "adenine", "DEW", "lambda", "potassium", "TCA", "aluminum",
-  "AD", "comproportionation", "Pourbaix", "E_coli", "yttrium", "rank.affinity", "uranyl"),
+  "AD", "comproportionation", "Pourbaix", "E_coli", "yttrium", "rank.affinity", "uranyl", "sum_S"),
   save.png = FALSE) {
   # Run one or more demos from CHNOSZ with ask = FALSE, and return the value of the last one
   out <- NULL

Modified: pkg/CHNOSZ/R/util.expression.R
===================================================================
--- pkg/CHNOSZ/R/util.expression.R	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/R/util.expression.R	2024-11-28 07:36:27 UTC (rev 850)
@@ -171,8 +171,8 @@
     desc <- expr.species(label, state = state, log = TRUE, molality = molality)
   } else if(label %in% colnames(basis)) {
     # Make a label for an element (total C, total S, etc.) 20230809
-    if(molality) desc <- bquote(log~italic(m)~"(total "*.(label)*")")
-    else desc <- bquote(log~italic(a)~"(total "*.(label)*")")
+    if(molality) desc <- bquote(log~italic(m)~sum(.(label)))
+    else desc <- bquote(log~italic(a)~sum(.(label)))
   } else {
     # The label is for a chemical property or condition
     # Make the label by putting a comma between the property and the units

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/demo/00Index	2024-11-28 07:36:27 UTC (rev 850)
@@ -9,7 +9,7 @@
 protbuff        Chemical activities buffered by thiol peroxidases or sigma factors
 glycinate       Metal-glycinate complexes
 mosaic          Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species
-total_S         Using total S as a variable; modified from mosaic.R
+sum_S           Mineral stabilities with the sum of S species and ionic strength
 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

Copied: pkg/CHNOSZ/demo/sum_S.R (from rev 849, pkg/CHNOSZ/demo/total_S.R)
===================================================================
--- pkg/CHNOSZ/demo/sum_S.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/sum_S.R	2024-11-28 07:36:27 UTC (rev 850)
@@ -0,0 +1,56 @@
+# CHNOSZ/demo/sum_S.R
+# 20240604 Fe-S-C-O-H log a (sum S) - pH      modified from mosaic.R
+# 20241127 Fe-S-O-H   logfO2 - log a (sum S)  added IS
+
+library(CHNOSZ)
+
+for(IS in c(0, 0.5)) {
+
+  # Define conditions
+  res <- 500
+  loga_S <- c(-6, 0, res)
+  logf_O2 <- c(-45, -20, res)
+  pH <- 5
+  T <- 300
+  P <- "Psat"
+  #IS <- 0
+  # Setup chemical system
+  # Use "oxygen" instead of "O2" to get the gas
+  basis(c("FeO", "SO4-2", "H2O", "H+", "oxygen"))
+  basis("pH", pH)
+  # Add aqueous species followed by minerals
+  species(c("Fe+2", "Fe+3", "HFeO2-"))
+  species(c("pyrrhotite", "pyrite", "hematite", "magnetite"), add = TRUE)
+
+  # List basis species to swap through
+  bases <- list( c("SO4-2", "HSO4-", "HS-", "H2S") )
+
+  # Start diagram for loga_Fe = -6
+  species(1:3, -6)
+  m1 <- mosaic(bases, "SO4-2" = loga_S, O2 = logf_O2, T = T, P = P, IS = IS)
+  diagram(m1$A.species, bold = TRUE)
+
+  # Overlay lines and labels for loga_Fe = -5
+  species(1:3, -5)
+  m2 <- mosaic(bases, "SO4-2" = loga_S, O2 = logf_O2, T = T, P = P, IS = IS)
+  d <- diagram(m2$A.species, add = TRUE, names = NA, fill = NA, lty = 3)
+
+  # Add dashed line for water stability limti
+  water.lines(d)
+
+  # Add legends and title
+  TP <- describe.property(c("T", "P"), c(T, P))
+  PI <- c(bquote(pH == .(pH)), bquote(italic(I) == .(IS)~mol~kg^-1))
+  legend1 <- lex(TP, PI)
+  legend("topright", legend1, bty = "n")
+
+  Fe <- c(
+    bquote(10^-5~italic(m)~Fe^"+2"),
+    bquote(10^-6~italic(m)~Fe^"+2")
+  )
+  legend2 <- lex(Fe)
+  legend("topleft", legend2, lty = c(3, 1), bty = "n")
+
+  title(main = "Fe-S-O-H with summed S and ionic strength", font.main = 1)
+
+}

Deleted: pkg/CHNOSZ/demo/total_S.R
===================================================================
--- pkg/CHNOSZ/demo/total_S.R	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/demo/total_S.R	2024-11-28 07:36:27 UTC (rev 850)
@@ -1,63 +0,0 @@
-# CHNOSZ/demo/total_S.R
-# 20240604 Use total S as a variable; modified from mosaic.R
-
-library(CHNOSZ)
-
-# Define conditions
-res <- 500
-pH <- c(0, 14, res)
-loga_S <- c(-6, -2, res)
-T <- 25
-P <- 1
-loga_C <- 0
-Eh <- -0.5
-# Define chemical system
-basis(c("FeO", "SO4-2", "CO3-2", "H2O", "H+", "e-"))
-basis("CO3-2", loga_C)
-basis("Eh", Eh)
-# Start with log(activity of aqueous Fe species) = -4
-species(c("Fe+2", "Fe+3", "HFeO2-"), -4)
-species(c("pyrrhotite", "pyrite", "hematite", "magnetite", "siderite"), add = TRUE)
-
-# Use two sets of changing basis species:
-#   speciate SO4-2, HSO4-, HS-, H2S as a function of Eh and pH
-#   speciate CO3-2, HCO3-, CO2 as a function of pH
-bases <- list(
-  c("SO4-2", "HSO4-", "HS-", "H2S"),
-  c("CO3-2", "HCO3-", "CO2")
-)
-
-# Make a diagram with dotted lines and aqueous species labels for log(activity of aqueous Fe species) = -4
-m4 <- mosaic(bases, pH = pH, "SO4-2" = loga_S, T = T, P = P)
-names.aq <- species()$name; names.aq[4:8] <- ""
-diagram(m4$A.species, lty = 3, names = names.aq, col.names = 4)
-
-# Overlay solid lines and mineral labels for log(activity of aqueous Fe species) = -6
-species(c("Fe+2", "Fe+3", "HFeO2-"), -6)
-m6 <- mosaic(bases, pH = pH, "SO4-2" = loga_S, T = T, P = P)
-names <- species()$name; names[1:3] <- ""
-diagram(m6$A.species, add = TRUE, names = names, bold = TRUE)
-
-# Replot the aqueous species labels for stronger contrast
-diagram(m4$A.species, lty = 3, names = names.aq, col.names = 4, add = TRUE, fill = NA)
-
-# Add legend and title
-TP <- describe.property(c("T", "P"), c(T, P))
-SC <- c(
-  bquote(Eh == .(Eh) ~ V),
-  bquote(sum("C(aq)") == 10^.(loga_C)~m)
-)
-legend1 <- lex(TP, SC)
-legend("topleft", legend1, bty = "n")
-
-Fe <- c(
-  bquote(10^-4~"m Fe"),
-  bquote(10^-6~"m Fe")
-)
-legend2 <- lex(Fe)
-legend("bottomleft", legend2, lty = c(3, 1), bty = "n")
-
-title(main = "Using total S as a variable; modified from mosaic.R", font.main = 1)
-
-## Reset the database if we changed it using mod.OBIGT()
-#reset()

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2024-11-28 07:36:27 UTC (rev 850)
@@ -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.1.0-21 (2024-11-17)}{
+\section{Changes in CHNOSZ version 2.1.0-22 (2024-11-28)}{
 
     \itemize{
 
@@ -56,6 +56,10 @@
       for uranyl species, after
       \href{https://doi.org/10.1016/j.gca.2024.04.023}{Migdisov et al. (2024)}.
 
+      \item Adjust \code{util.expression()} to show sum symbol in axis label,
+      rename \file{demo/total_S.R} to \file{demo/sum_S.R}, and add ionic
+      strength to demo.
+
     }
 
 }

Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd	2024-11-17 09:35:41 UTC (rev 849)
+++ pkg/CHNOSZ/man/examples.Rd	2024-11-28 07:36:27 UTC (rev 850)
@@ -19,7 +19,7 @@
     "contour", "sphalerite", "minsol", "Shh", "saturation",
     "adenine", "DEW", "lambda", "potassium", "TCA", "aluminum", "AD",
     "comproportionation", "Pourbaix", "E_coli", "yttrium", "rank.affinity",
-    "uranyl"),
+    "uranyl", "sum_S"),
     save.png = FALSE)
 }
 
@@ -67,6 +67,7 @@
     \item{rank.affinity}{Affinity ranking for proteins in yeast nutrient limitation (data from Tai et al., 2005)}
     \item{yttrium}{\code{\link{logB.to.OBIGT}} fits at 800 and 1000 bar and Y speciation in \code{\link{NaCl}} solution at varying pH (Guan et al., 2020)}
     \item{uranyl}{Total (carbonate|sulfate)-pH diagrams for uranyl species (Migdisov et al., 2024)}
+    \item{sum_S}{Mineral stabilities with the sum of S species and ionic strength}
   }
 
 For either function, if \code{save.png} is TRUE, the plots are saved in \code{\link{png}} files whose names begin with the names of the help topics or demos.



More information about the CHNOSZ-commits mailing list