[CHNOSZ-commits] r843 - in pkg/CHNOSZ: . demo
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jun 4 08:36:16 CEST 2024
Author: jedick
Date: 2024-06-04 08:36:15 +0200 (Tue, 04 Jun 2024)
New Revision: 843
Added:
pkg/CHNOSZ/demo/total_S.R
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/demo/00Index
Log:
Add demo/total_S.R
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2024-05-23 08:35:40 UTC (rev 842)
+++ pkg/CHNOSZ/DESCRIPTION 2024-06-04 06:36:15 UTC (rev 843)
@@ -1,6 +1,6 @@
-Date: 2024-05-22
+Date: 2024-06-04
Package: CHNOSZ
-Version: 2.1.0-15
+Version: 2.1.0-16
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/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index 2024-05-23 08:35:40 UTC (rev 842)
+++ pkg/CHNOSZ/demo/00Index 2024-06-04 06:36:15 UTC (rev 843)
@@ -9,6 +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
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
Added: pkg/CHNOSZ/demo/total_S.R
===================================================================
--- pkg/CHNOSZ/demo/total_S.R (rev 0)
+++ pkg/CHNOSZ/demo/total_S.R 2024-06-04 06:36:15 UTC (rev 843)
@@ -0,0 +1,63 @@
+# 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()
More information about the CHNOSZ-commits
mailing list