[CHNOSZ-commits] r380 - in pkg/CHNOSZ: . R vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Feb 3 04:23:57 CET 2019
Author: jedick
Date: 2019-02-03 04:23:56 +0100 (Sun, 03 Feb 2019)
New Revision: 380
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/util.affinity.R
pkg/CHNOSZ/vignettes/anintro.Rmd
Log:
anintro.Rmd: fix to energy() for mosaic diagram with chalcocite (phase transitions)
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2019-02-02 11:54:46 UTC (rev 379)
+++ pkg/CHNOSZ/DESCRIPTION 2019-02-03 03:23:56 UTC (rev 380)
@@ -1,6 +1,6 @@
-Date: 2019-02-02
+Date: 2019-02-03
Package: CHNOSZ
-Version: 1.1.3-87
+Version: 1.1.3-88
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/util.affinity.R
===================================================================
--- pkg/CHNOSZ/R/util.affinity.R 2019-02-02 11:54:46 UTC (rev 379)
+++ pkg/CHNOSZ/R/util.affinity.R 2019-02-03 03:23:56 UTC (rev 380)
@@ -147,7 +147,13 @@
if("P" %in% vars) P <- vals[[which(vars=="P")]]
if("IS" %in% vars) IS <- vals[[which(vars=="IS")]]
s.args <- list(species=species,property=property,T=T,P=P,IS=IS,grid=grid,convert=FALSE,exceed.Ttr=exceed.Ttr,exceed.rhomin=exceed.rhomin)
- return(do.call("subcrt",s.args))
+ sout <- do.call("subcrt",s.args)
+ # species indices are updated by subcrt() for minerals with phase transitions
+ # e.g. i <- info("chalcocite"); subcrt(i, T=200)$species$ispecies == i + 1
+ # so we should keep the original species index to be able to find the species in a provided 'sout'
+ # (noted for Mosaic diagram section of anintro.Rmd 20190203)
+ sout$species$ispecies <- species
+ return(sout)
}
}
Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd 2019-02-02 11:54:46 UTC (rev 379)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd 2019-02-03 03:23:56 UTC (rev 380)
@@ -687,22 +687,22 @@
The key argument is `bases`, which identifies the candidate basis species, starting with the one in the current basis.
The other arguments, like those of <span style="color:green">`affinity()`</span>, specify the ranges of the variables; `res` indicates the grid resolution to use for each variable (the default is 128).
The first call to <span style="color:green">`diagram()`</span> plots the species of interest; the second adds the predominance fields of the basis species.
-We turn off the gray coloring beyond the water stability limits (`limit.water`) but plot the red dotted lines using <span style="color:green">`water.lines()`</span>:
+We turn off the gray coloring beyond the water stability limits (`limit.water`) but plot dashed blue lines using <span style="color:green">`water.lines()`</span>:
```{r copper_mosaic, fig.margin=TRUE, fig.width=4, fig.height=4, dpi=dpi, out.width="100%", message=FALSE, cache=TRUE, fig.cap="Copper minerals and aqueous complexes with chloride, 200 °C.", pngquant=pngquant, timeit=timeit}
T <- 200
res <- 300
bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
-m1 <- mosaic(bases, blend = TRUE, pH = c(0, 12, res), Eh=c(-1.2, 0.75, res), T=T)
+m1 <- mosaic(bases, pH = c(0, 12, res), Eh=c(-1.2, 0.75, res), T=T)
diagram(m1$A.species, lwd = 2, fill = NA, limit.water = FALSE)
diagram(m1$A.bases, add = TRUE, col = "red1", col.names = "red1", lty = 3,
limit.water = FALSE, italic = TRUE)
water.lines(m1$A.species, col = "blue1")
```
-The argument `blend = TRUE` is used to combine the diagrams according to the relative abundances of the basis species along with a mixing term (see <span style="color:blue">`?mosaic`</span>).
+The diagrams are combined according to the relative abundances of the different possible basis species listed in `bases` along with a term for the Gibbs energy of mixing (see <span style="color:blue">`?mosaic`</span>).
The smooth transitions between basis species can result in curved field boundaries, in this case around the chalcocite field.
-Without that argument, the diagrams would be combined using the dominant basis species, and all of the line segments would be straight.
+If we added the argument `blend = FALSE`, the diagrams would instead be assembled using the single predominant basis species at any point on the Eh-pH grid, and all of the line segments would be straight.
The reactions used to make this diagram are balanced on Cu, so that no Cu appears in reactions between any two other species (minerals or aqueous species).
If <span style="color:green">`diagram()`</span> is run with `balance = 1`, then the reactions are written for one mole of the mineral formulas on each side of the reaction, with the possibility of Cu appearing as an additional species to conserve the elements.
@@ -720,7 +720,7 @@
mosaicfun <- function(newvar, T = 200) {
swap.basis("e-", names(newvar))
if (names(newvar) == "O2") basis("O2", "gas")
- mosaicargs <- c(list(bases), blend=TRUE, pH=list(c(-2, 12, res)), newvar, T=T)
+ mosaicargs <- c(list(bases), pH = list(c(-2, 12, res)), newvar, T = T)
m1 <- do.call(mosaic, mosaicargs)
diagram(m1$A.species, lwd = 2, fill = "terrain",
limit.water = FALSE)
More information about the CHNOSZ-commits
mailing list