[CHNOSZ-commits] r739 - in pkg/CHNOSZ: . R man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 24 12:43:17 CEST 2022


Author: jedick
Date: 2022-07-24 12:43:17 +0200 (Sun, 24 Jul 2022)
New Revision: 739

Added:
   pkg/CHNOSZ/tests/stack_mosaic.R
   pkg/CHNOSZ/tests/stack_mosaic.pdf
   pkg/CHNOSZ/tests/stack_solubility.R
   pkg/CHNOSZ/tests/stack_solubility.pdf
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/mosaic.R
   pkg/CHNOSZ/R/solubility.R
   pkg/CHNOSZ/R/stack_mosaic.R
   pkg/CHNOSZ/man/solubility.Rd
Log:
Add tests: stack_mosaic.R and stack_solubility.R


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/DESCRIPTION	2022-07-24 10:43:17 UTC (rev 739)
@@ -1,6 +1,6 @@
-Date: 2022-07-23
+Date: 2022-07-24
 Package: CHNOSZ
-Version: 1.9.9-30
+Version: 1.9.9-31
 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/mosaic.R
===================================================================
--- pkg/CHNOSZ/R/mosaic.R	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/R/mosaic.R	2022-07-24 10:43:17 UTC (rev 739)
@@ -38,11 +38,23 @@
     otherargs <- list(...)
     allargs <- c(list(bases = bases, blend = blend, stable = stable), otherargs)
     out <- do.call(mosaic, allargs)
-    # Replace A.bases (affinity calculations for all groups of basis species) with backwards-compatbile A.bases
+    # Replace A.bases (affinity calculations for all groups of basis species) with backwards-compatible A.bases
     out$A.bases <- out$A.bases[[1]]
     return(out)
   }
 
+  if(length(stable) == 2) {
+    # Use only predominant basis species for mosaic stacking 20220723
+    stable2.orig <- stable2 <- stable[[2]]
+    # Why c(1, ?
+    # The first basis species should always be included (because it has to be swapped out for the others)
+    istable2 <- sort(unique(c(1, as.numeric(stable2))))
+    for(i in seq_along(istable2)) stable2[stable2.orig == istable2[i]] <- i
+    bases2 <- bases[[2]][istable2]
+    bases[[2]] <- bases2
+    stable[[2]] <- stable2
+  }
+
   # Save starting basis and species definition
   basis0 <- get("thermo", CHNOSZ)$basis
   species0 <- get("thermo", CHNOSZ)$species
@@ -104,6 +116,7 @@
     thislogact[icr] <- 0
     # Use loga_aq for log(activity) of mosaiced aqueous basis species 20220722
     if(!is.null(loga_aq)) {
+      if(length(loga_aq) != length(ibasis0)) stop("'loga_aq' should have same length as 'bases'")
       iaq <- grep("aq", states)
       # Loop over sets of mosaiced basis species
       for(j in 1:length(ibasis0)) {

Modified: pkg/CHNOSZ/R/solubility.R
===================================================================
--- pkg/CHNOSZ/R/solubility.R	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/R/solubility.R	2022-07-24 10:43:17 UTC (rev 739)
@@ -4,7 +4,7 @@
 # 20190117 add find.IS and test for dissociation reaction
 # 20210319 use vector of aqueous species as main argument (with back-compatibility for affinity output) and handle multiple minerals
 
-## if this file is interactively sourced, the following are also needed to provide unexported functions:
+## If this file is interactively sourced, the following are also needed to provide unexported functions:
 #source("equilibrate.R")
 #source("util.misc.R")
 #source("species.R")
@@ -28,7 +28,7 @@
     is.mosaic <- TRUE
     # For getting 'sout' from affinity(), drop arguments specific for mosaic()
     affargs <- ddd[-1]
-    affargs <- affargs[!names(affargs) %in% c("bases", "stable", "blend")]
+    affargs <- affargs[!names(affargs) %in% c("bases", "stable", "blend", "loga_aq")]
   }
 
   # Save current thermodynamic system settings

Modified: pkg/CHNOSZ/R/stack_mosaic.R
===================================================================
--- pkg/CHNOSZ/R/stack_mosaic.R	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/R/stack_mosaic.R	2022-07-24 10:43:17 UTC (rev 739)
@@ -18,9 +18,10 @@
   if(!is.null(loga_aq)) {
     iaq1 <- which(isp1$state == "aq")
     if(length(iaq1) > 0) species(iaq1, loga_aq)
-  }
+    loga_aq_arg <- c(NA, loga_aq)
+  } else loga_aq_arg <- NULL
   # Calculate affinity of species1 while speciating bases (e.g. aqueous S species)
-  mosaic1 <- mosaic(bases, loga_aq = c(NA, loga_aq), ...)
+  mosaic1 <- mosaic(bases, loga_aq = loga_aq_arg, ...)
   # Show predominance fields
   diagram1 <- diagram(mosaic1$A.species, names = names[[1]], col = col[[1]], col.names = col.names[[1]], fill = fill[[1]],
     dx = dx[[1]], dy = dy[[1]], srt = srt[[1]], lwd = lwd[[1]], lty = lty[[1]], plot.it = plot.it)
@@ -32,14 +33,9 @@
     iaq2 <- which(isp2$state == "aq")
     if(length(iaq2) > 0) species(iaq2, loga_aq)
   }
-  # Use only predominant species1 as basis species (to speed up calculation) 20210224
-  predom <- diagram1$predominant
-  ipredom <- sort(unique(as.numeric(predom)))
-  for(i in seq_along(ipredom)) predom[diagram1$predominant == ipredom[i]] <- i
-  species1.predom <- species1[ipredom]
   # Speciate bases again (NULL)
-  # Take the predominant members of species1 (predom)
-  mosaic2 <- mosaic(list(bases, species1.predom), stable = list(NULL, predom), loga_aq = c(NA, loga_aq), ...)
+  # Take the predominant members of species1 (diagram1$predominant)
+  mosaic2 <- mosaic(list(bases, species1), stable = list(NULL, diagram1$predominant), loga_aq = loga_aq_arg, ...)
 
   # Set colors
   col <- c(rep_len(col[[3]], length(species12)), rep_len(col[[2]], length(species2)))

Modified: pkg/CHNOSZ/man/solubility.Rd
===================================================================
--- pkg/CHNOSZ/man/solubility.Rd	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/man/solubility.Rd	2022-07-24 10:43:17 UTC (rev 739)
@@ -54,7 +54,7 @@
 The function perfoms some additional steps to calculate the solubility of something that dissociates (not just dissolves).
 For example, the dissolution of calcite (CaCO\s3), involves the release of both calcium ions and different forms of carbonate in solution, depending on the pH.
 The equilibrium calculation must take account of the \emph{total} activity of the shared ion (Ca\S{+2}), which is unknown at the start of the calculation.
-The solution is accomplished by recalculating the affinities, essentially working backward from the assumption that the dissociation didn't occur.
+The solution is found by recalculating the affinities, essentially working backward from the assumption that the dissociation didn't occur.
 The resulting activities correspond to equilibrium considering the system-wide activity of Ca\S{+2}.
 
 A \emph{not recommended} alternative is to set \code{dissociate} to a numeric value corresponding to the number of dissociated species (i.e. 2 for a 1:1 electrolyte).
@@ -67,7 +67,7 @@
 This works by calculating the ionic strength from the amounts of aqueous species formed, then re-running \code{affinity} with the calculated \code{IS} value.
 Note that for dissociation reactions, the ionic strength is calculated from both the ions present in the species definition and the counter ion, which should be the second basis species.
 The calculation is iterated until the ionic strength deviation at every point is lower than a preset tolerance (1e-4).
-Alternatively, speciation of counterions (e.g. ionized forms of carbonate or sulfate) can also be accomplished by using the \code{\link{mosaic}} function instead of \code{affinity}; this is used in the second example below.
+Alternatively, speciation of counterions (e.g. ionized forms of carbonate or sulfate) can also be performed by using the \code{\link{mosaic}} function instead of \code{affinity}; this is used in the second example below.
 }
 
 \section{Warning}{

Added: pkg/CHNOSZ/tests/stack_mosaic.R
===================================================================
--- pkg/CHNOSZ/tests/stack_mosaic.R	                        (rev 0)
+++ pkg/CHNOSZ/tests/stack_mosaic.R	2022-07-24 10:43:17 UTC (rev 739)
@@ -0,0 +1,195 @@
+# Test variations on stacked mosaic diagrams culminating with stack_mosaic() wrapper function
+# 20220722 v1 adapted from Mosaic Stacking 2 from multi-metal.Rmd
+
+library(CHNOSZ)
+
+# Use low resolution for routine package checking
+res <- 20
+## Increase resolution for nicer-looking PDF (the one kept in the test directory)
+#res <- 200
+# Define system
+pH <- c(0, 14, res)
+O2 <- c(-48, -33, res)
+T <- 200
+logmS <- -2
+m_NaCl <- 0.1
+logm_aq <- -6 # for both Fe- and Cu-bearing aq species
+# Define basis species
+S.aq <- c("H2S", "HS-", "HSO4-", "SO4-2")
+# Define minerals
+Fe.cr <- c("pyrite", "pyrrhotite", "magnetite", "hematite")
+Fe.abbrv <- c("Py", "Po", "Mag", "Hem")
+FeCu.cr <- c("chalcopyrite", "bornite")
+Cu.cr <- c("copper", "cuprite", "tenorite", "chalcocite", "covellite")
+FeCu.abbrv <- c("Ccp", "Bn", "Cu", "Cpr", "Tnr", "Cct", "Cv")
+# Define aqueous species
+iFe.aq <- retrieve("Fe", c("S", "O", "H", "Cl"), "aq")
+Fe.aq <- info(iFe.aq)$name
+iCu.aq <- retrieve("Cu", c("S", "O", "H", "Cl"), "aq")
+Cu.aq <- info(iCu.aq)$name
+nacl <- NaCl(T = T, P = "Psat", m_tot = m_NaCl)
+
+setup <- function() {
+  reset()
+  # Setup basis species
+  basis(c("Cu+", "pyrite", "H2S", "oxygen", "H2O", "H+", "Cl-"))
+  basis("H2S", logmS)
+  basis("Cl-", log10(nacl$m_Cl))
+}
+
+ref_Cu_craq <- function() {
+  # Load Cu-bearing minerals
+  species(Cu.cr)
+  # Add aqueous species 20210220
+  species(iCu.aq, logm_aq, add = TRUE)
+
+  mCu <- mosaic(list(S.aq), pH = pH, O2 = O2, T = T, IS = nacl$IS)
+  diagram(mCu$A.species)
+}
+
+ref_FeCu_cr <- function() {
+  # Load Fe-bearing minerals
+  species(Fe.cr)
+  mFe <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
+  dFe <- diagram(mFe$A.species, lwd = 0, names = FALSE, plot.it = FALSE)
+
+  # Load Cu-bearing minerals
+  species(c(FeCu.cr, Cu.cr))
+  # Mosaic with all Fe species as basis species
+  mFeCu <- mosaic(list(S.aq, Fe.cr), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant))
+
+  diagram(mFeCu$A.species)
+}
+
+setup_FeCu <- function() {
+  # Load Fe-bearing minerals
+  species(Fe.cr)
+  # Add aqueous species 20210220
+  species(iFe.aq, logm_aq, add = TRUE)
+  mFe <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
+  dFe <- diagram(mFe$A.species, lwd = 0, names = FALSE, plot.it = FALSE)
+
+  # Load Cu-bearing minerals
+  species(c(FeCu.cr, Cu.cr))
+  # Add aqueous species 20210220
+  species(iCu.aq, logm_aq, add = TRUE)
+  
+  # Return Fe diagram for stacked mosaic calculations
+  dFe
+}
+
+
+test_FeCu_old <- function() {
+  dFe <- setup_FeCu()
+
+  # NOTE: limitation in mosaic() when using both solid and aqueous basis species (i.e. c(Fe.cr, Fe.aq)):
+  #   Only the activity of the first-defined basis species is used for all basis species.
+  #   The first-defined basis species is pyrite (logact = 0), but logact < 0 for the aq Fe species.
+  # Workaround: Adjust standard Gibbs energies of aq Fe species to virtually change their activities
+  DG_J <- convert(-logm_aq, "G", T = convert(T, "K"))
+  # We should use calories here because the database values are in calories 20220604
+  stopifnot(all(info(iFe.aq)$E_units == "cal"))
+  DG_cal <- convert(DG_J, "cal")
+  G.orig <- info(iFe.aq)$G
+  G.new <- G.orig + DG_cal
+  mod.OBIGT(iFe.aq, G = G.new)
+
+  # Mosaic with all Fe species as basis species
+  mFeCu <- mosaic(list(S.aq, c(Fe.cr, Fe.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant))
+
+  diagram(mFeCu$A.species)
+}
+
+test_FeCu_new <- function() {
+  dFe <- setup_FeCu()
+
+  # Mosaic with all Fe species as basis species
+  # Use loga_aq argument to control the activity of aqueous species in mosaic calculation 20220722
+  # c(NA, logm_aq) means to use:
+  #   basis()'s value for logact of aqueous S species
+  #   logm_aq for logact of aqueous Fe species
+  mFeCu <- mosaic(list(S.aq, c(Fe.cr, Fe.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant), loga_aq = c(NA, logm_aq))
+
+  diagram(mFeCu$A.species)
+}
+
+test_FeCu_stack <- function() {
+  # Aqueous S species
+  bases <- S.aq
+  # Fe-bearing minerals
+  species1 <- Fe.cr
+  # Cu-bearing and FeCu-bearing minerals
+  species2 <- Cu.cr
+  species12 <- FeCu.cr
+
+  # Fe-bearing aqueous species
+  species1 <- c(species1, Fe.aq)
+  # Cu-bearing aqueous species
+  species2 <- c(species2, Cu.aq)
+
+  sm <- stack_mosaic(bases, species1, species2, species12, pH = pH, O2 = O2, T = T, IS = nacl$IS, loga_aq = logm_aq, plot.it = FALSE)
+  diagram(sm[[2]])
+}
+
+## Setup plot
+pdf("stack_mosaic.pdf", width = 8, height = 9)
+mat <- matrix(c(1,6,2, 6,3,6, 4,6,5), nrow = 3, byrow = TRUE)
+layout(mat, widths = c(2, 3, 2), heights = c(2, 3, 2, 3))
+par(mar = c(4, 4, 3, 1))
+
+## Run tests
+# This first one is a simple mosaic diagram (no stacking)
+setup()
+ref_Cu_craq()
+title("Cu\ncr+aq", font.main = 1)
+
+setup()
+ref_FeCu_cr()
+title("Fe-Cu\ncr", font.main = 1)
+
+T1result <- "(TODO: looks ok)"
+
+setup()
+d_FeCu_old <- test_FeCu_old()
+title("Fe-Cu\ncr+aq", font.main = 1)
+
+T2result <- "(TODO: looks ok)"
+T3result <- "(TODO: looks different)"
+
+setup()
+d_FeCu_new <- test_FeCu_new()
+title("Fe-Cu\ncr+aq", font.main = 1, xpd = NA)
+
+if(identical(d_FeCu_old$predominant, d_FeCu_new$predominant)) T4result <- "(OK)" else T4result <- "(FAILED)"
+
+setup()
+d_FeCu_stack <- test_FeCu_stack()
+title("Fe-Cu\ncr+aq", font.main = 1, xpd = NA)
+
+if(identical(d_FeCu_new$predominant, d_FeCu_stack$predominant)) T5result <- "(OK)" else T5result <- "(FAILED)"
+
+## Add arrows and text
+plot.new()
+text(0.5, 0.99, "mosaic()\nWITHOUT 'loga_aq'\n(pre-2.0.0)", font = 2, xpd = NA)
+
+arrows(0.35, 0.9, 0.65, 0.9)
+text(0.5, 0.93, paste0("Test 1: Cu mineral reactions unaffected\n", T1result))
+
+arrows(0.1, 0.72, 0.25, 0.65)
+text(0.05, 0.62, paste0("Test 2: aq reactions unaffected\n", T2result), xpd = NA)
+
+arrows(0.9, 0.72, 0.75, 0.65)
+text(0.9, 0.62, paste0("Test 3: cr reactions unaffected\n", T3result), xpd = NA)
+
+abline(h = 0.25, lty = 2, col = 8)
+text(0.4, 0.23, "mosaic()\nWITH 'loga_aq'", font = 2)
+lines(c(0.5, 0.5), c(0.15, 0.25), lty = 2, col = 8)
+text(0.6, 0.23, "stack_mosaic()", font = 2)
+
+arrows(0.25, 0.4, 0.1, 0.3)
+text(0.05, 0.35, paste0("Test 4: identical diagram\n", T4result), xpd = NA)
+
+arrows(0.35, 0.1, 0.65, 0.1)
+text(0.5, 0.05, paste0("Test 5: identical diagram\n", T5result))
+
+dev.off()

Added: pkg/CHNOSZ/tests/stack_mosaic.pdf
===================================================================
(Binary files differ)

Index: pkg/CHNOSZ/tests/stack_mosaic.pdf
===================================================================
--- pkg/CHNOSZ/tests/stack_mosaic.pdf	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/tests/stack_mosaic.pdf	2022-07-24 10:43:17 UTC (rev 739)

Property changes on: pkg/CHNOSZ/tests/stack_mosaic.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: pkg/CHNOSZ/tests/stack_solubility.R
===================================================================
--- pkg/CHNOSZ/tests/stack_solubility.R	                        (rev 0)
+++ pkg/CHNOSZ/tests/stack_solubility.R	2022-07-24 10:43:17 UTC (rev 739)
@@ -0,0 +1,144 @@
+# Make stacked mosaic diagrams and solubility contours
+# 20220723 jmd
+
+# - Is solubility() function basically correct?
+#   Check: Solubility contour (right column for each stack) coincides with mineral-aqueous stability boundary
+#   NOTE: Contour and aqueous species are both set to logarithm of activity = -6
+
+# - Are solubilities of bimetallic minerals (i.e. chalcopyrite) correct?
+#   Check: ???
+#   TODO: Is there a reference for the correct result?
+
+# - Is an Fe(first)-Cu stack the same as a Cu(first)-Fe stack?
+#   Check: Chalcopyrite field has consistent extents in Stack 2 (Diagram 4) and Stack 4 (Diagram 8)
+#   TODO: Chalcopyrite field doesn't change, but assemblages with other minerals are different
+
+# - Are solubilities correct for different stoichiometries?
+#   Check: Change chalcopyrite (Cu:Fe = 1:1) to bornite (Cu:Fe = 5:1)
+#   TODO: Solubility contours for bornite are incorrect
+
+# NOTE: Among these diagrams, I think that Diagrams 4 and 8 are likely to be
+# the most accurate depictions of the solubilities of Cu and Fe, respectively
+# (Bornite and chalcopyrite should both be present, after the solubility() calculations for bornite are fixed.)
+
+# This is a long test: don't run it for routine package checking
+if(FALSE) {
+
+library(CHNOSZ)
+reset()
+
+pdf("stack_solubility.pdf", width = 6, height = 9)
+par(mfrow = c(4, 2))
+
+# Define system
+res <- 200
+pH <- c(0, 14, res)
+O2 <- c(-48, -33, res)
+T <- 200
+logmS <- -2
+m_NaCl <- 0.1
+logm_aq <- -6 # for both Fe- and Cu-bearing aq species
+# Define basis species
+S.aq <- c("H2S", "HS-", "HSO4-", "SO4-2")
+# Define minerals
+Fe.cr <- c("pyrite", "pyrrhotite", "magnetite", "hematite")
+FeCu.cr <- c("chalcopyrite", "bornite")
+Cu.cr <- c("copper", "cuprite", "tenorite", "chalcocite", "covellite")
+# Define aqueous species
+iFe.aq <- retrieve("Fe", c("S", "O", "H", "Cl"), "aq")
+Fe.aq <- info(iFe.aq)$name
+iCu.aq <- retrieve("Cu", c("S", "O", "H", "Cl"), "aq")
+Cu.aq <- info(iCu.aq)$name
+# Apply NaCl concentration
+nacl <- NaCl(T = T, P = "Psat", m_tot = m_NaCl)
+
+### Setup basis species for Fe-Cu stacks
+reset()
+basis(c("Cu+", "pyrite", "H2S", "oxygen", "H2O", "H+", "Cl-"))
+basis("H2S", logmS)
+basis("Cl-", log10(nacl$m_Cl))
+
+## Diagram 1: Only Fe-bearing minerals
+species(Fe.cr)
+# Mosaic with S species as basis species
+mFe <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
+dFe <- diagram(mFe$A.species, col = 2)
+
+## Diagram 2: Cu- (and FeCu-) bearing minerals and aqueous species
+species(c("chalcopyrite", Cu.cr))
+species(Cu.aq, -6, add = TRUE)
+mFeCu <- mosaic(list(S.aq, Fe.cr), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant))
+diagram(mFeCu$A.species)
+
+## Diagram 2a: Overlay single solubility contour
+species(c("chalcopyrite", Cu.cr))
+sout1 <- solubility(iCu.aq, bases = list(S.aq, Fe.cr), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant))
+diagram(sout1, add = TRUE, col = 4, lwd = 2, levels = -6)
+
+mtext("Stack 1: Fe minerals only -> Cu(Fe) minerals and Cu aqueous", adj = 1.1, line = 1.1)
+
+## Diagram 3: Fe-bearing minerals and aqueous species
+species(Fe.cr)
+species(Fe.aq, -6, add = TRUE)
+mFe <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
+dFe <- diagram(mFe$A.species, col = 2)
+
+## Diagram 4: Cu- (and FeCu-) bearing minerals and aqueous species
+species(c("chalcopyrite", Cu.cr))
+species(Cu.aq, -6, add = TRUE)
+mFeCu <- mosaic(list(S.aq, c(Fe.cr, Fe.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant), loga_aq = c(NA, logm_aq))
+diagram(mFeCu$A.species)
+
+## Diagram 4a: Overlay single solubility contour
+species(c("chalcopyrite", Cu.cr))
+sout2 <- solubility(iCu.aq, bases = list(S.aq, c(Fe.cr, Fe.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant), loga_aq = c(NA, logm_aq))
+diagram(sout2, add = TRUE, col = 4, lwd = 2, levels = -6)
+
+mtext("Stack 2: Fe minerals and aqueous -> Cu(Fe) minerals and Cu aqueous", adj = 1, line = 1.1)
+
+### Setup basis species for Cu-Fe stacks
+reset()
+basis(c("Fe+2", "copper", "H2S", "oxygen", "H2O", "H+", "Cl-"))
+basis("H2S", logmS)
+basis("Cl-", log10(nacl$m_Cl))
+
+## Diagram 5: Only Cu-bearing minerals
+species(Cu.cr)
+mCu <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
+dCu <- diagram(mCu$A.species, col = 4)
+
+## Diagram 6: Fe- (and CuFe-) bearing minerals and aqueous species
+species(c("chalcopyrite", Fe.cr))
+species(Fe.aq, -6, add = TRUE)
+mCuFe <- mosaic(list(S.aq, Cu.cr), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dCu$predominant))
+diagram(mCuFe$A.species)
+
+## Diagram 6a: Overlay single solubility contour
+species(c("chalcopyrite", Fe.cr))
+sout3 <- solubility(iFe.aq, bases = list(S.aq, Cu.cr), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dCu$predominant))
+diagram(sout3, add = TRUE, col = 2, lwd = 2, levels = -6)
+
+mtext("Stack 3: Cu minerals only -> Fe(Cu) minerals and Fe aqueous", adj = 1.1, line = 1.1)
+
+## Diagram 7: Cu-bearing minerals and aqueous species
+species(Cu.cr)
+species(Cu.aq, -6, add = TRUE)
+mCu <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
+dCu <- diagram(mCu$A.species, col = 4)
+
+## Diagram 8: Fe- (and CuFe-) bearing minerals and aqueous species
+species(c("chalcopyrite", Fe.cr))
+species(Fe.aq, -6, add = TRUE)
+mCuFe <- mosaic(list(S.aq, c(Cu.cr, Cu.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dCu$predominant), loga_aq = c(NA, logm_aq))
+diagram(mCuFe$A.species)
+
+## Diagram 8a: Overlay single solubility contour
+species(c("chalcopyrite", Fe.cr))
+sout4 <- solubility(iFe.aq, bases = list(S.aq, c(Cu.cr, Cu.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dCu$predominant), loga_aq = c(NA, logm_aq))
+diagram(sout4, add = TRUE, col = 2, lwd = 2, levels = -6)
+
+mtext("Stack 4: Cu minerals and aqueous -> Fe(Cu) minerals and Fe aqueous", adj = 1, line = 1.1)
+
+dev.off()
+
+}

Added: pkg/CHNOSZ/tests/stack_solubility.pdf
===================================================================
(Binary files differ)

Index: pkg/CHNOSZ/tests/stack_solubility.pdf
===================================================================
--- pkg/CHNOSZ/tests/stack_solubility.pdf	2022-07-23 14:39:52 UTC (rev 738)
+++ pkg/CHNOSZ/tests/stack_solubility.pdf	2022-07-24 10:43:17 UTC (rev 739)

Property changes on: pkg/CHNOSZ/tests/stack_solubility.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property


More information about the CHNOSZ-commits mailing list