[CHNOSZ-commits] r720 - in pkg/CHNOSZ: . R inst vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Apr 9 11:26:31 CEST 2022
Author: jedick
Date: 2022-04-09 11:26:30 +0200 (Sat, 09 Apr 2022)
New Revision: 720
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/mix.R
pkg/CHNOSZ/inst/NEWS.Rd
pkg/CHNOSZ/vignettes/OBIGT.Rmd
pkg/CHNOSZ/vignettes/customizing.Rmd
pkg/CHNOSZ/vignettes/multi-metal.Rmd
Log:
Use stringsAsFactors = FALSE to make mix() work with R < 4.0.0
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2022-04-07 06:54:29 UTC (rev 719)
+++ pkg/CHNOSZ/DESCRIPTION 2022-04-09 09:26:30 UTC (rev 720)
@@ -1,6 +1,6 @@
-Date: 2022-04-07
+Date: 2022-04-09
Package: CHNOSZ
-Version: 1.9.9-12
+Version: 1.9.9-13
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/mix.R
===================================================================
--- pkg/CHNOSZ/R/mix.R 2022-04-07 06:54:29 UTC (rev 719)
+++ pkg/CHNOSZ/R/mix.R 2022-04-09 09:26:30 UTC (rev 720)
@@ -149,7 +149,7 @@
else paste(d1$names[combs[i, 1]], d2$names[combs[i, 2]], sep="+")
})
}
- species <- cbind(species, ispecies, logact, state, name)
+ species <- cbind(species, ispecies, logact, state, name, stringsAsFactors = FALSE)
# Get affinities for each combination of species
v1 <- d1$values[combs[, 1]]
Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd 2022-04-07 06:54:29 UTC (rev 719)
+++ pkg/CHNOSZ/inst/NEWS.Rd 2022-04-09 09:26:30 UTC (rev 720)
@@ -10,7 +10,7 @@
\newcommand{\s}{\ifelse{latex}{\eqn{_{#1}}}{\ifelse{html}{\out{<sub>#1</sub>}}{#1}}}
\newcommand{\S}{\ifelse{latex}{\eqn{^{#1}}}{\ifelse{html}{\out{<sup>#1</sup>}}{^#1}}}
-\section{Changes in CHNOSZ version 1.9.9-10 (2022-04-06)}{
+\section{Changes in CHNOSZ version 1.9.9-12 (2022-04-07)}{
\subsection{MAJOR CHANGE}{
\itemize{
@@ -34,7 +34,7 @@
\item Add the following \emph{Disclaimer} to the Aqueous Inorganic
section of \strong{OBIGT.Rmd}: To make the database easier to maintain,
inorganic and organic species have been placed into separate data files,
- but some ambiguities surround the usage of these \emph{*-ic*} words in
+ but some ambiguities surround the usage of these \emph{-ic} words in
different contexts. In particular, while CH\s{4} (methane) is classified
in chemistry as an organic compound, in nature it can be derived from
living organisms or formed abiotically
@@ -82,6 +82,19 @@
}
}
+ \subsection{BUG FIXES}{
+ \itemize{
+
+ \item Add \code{stringsAsFactors = FALSE} to a \code{cbind()} call in
+ \code{mix()}, needed for \R < 4.0.0. Thanks to Xiaojia Jiang for the bug
+ report.
+
+ \item In \strong{multi-metal.Rmd}, work around absence of
+ \code{hcl.colors()} in \R < 3.6.0.
+
+ }
+ }
+
}
\section{Changes in CHNOSZ version 1.4.3 (2022-02-20)}{
Modified: pkg/CHNOSZ/vignettes/OBIGT.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/OBIGT.Rmd 2022-04-07 06:54:29 UTC (rev 719)
+++ pkg/CHNOSZ/vignettes/OBIGT.Rmd 2022-04-09 09:26:30 UTC (rev 720)
@@ -355,7 +355,7 @@
## <a id="optional-AS04" class="anchor"></a> `r setfile("AS04.csv")`
This file has data for aqueous SiO<sub>2</sub> from @AS04 and a HSiO<sub>3</sub><sup>-</sup> modified to be consistent with the SiO<sub>2</sub> here.
This file also has H<sub>4</sub>SiO<sub>4</sub> from an earlier publication [@Ste01] that is roughly consistent with the SiO<sub>2</sub> here.
-Use `add.OBIGT("AS04")` to load the data; see the vignette [*Regressing thermodynamic data*](eos-regress.html) for an example.
+Use `add.OBIGT("AS04")` to load the data; see `demo(aluminum)` for an example.
```{r optreflist, results="asis", echo=FALSE}
```
Modified: pkg/CHNOSZ/vignettes/customizing.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/customizing.Rmd 2022-04-07 06:54:29 UTC (rev 719)
+++ pkg/CHNOSZ/vignettes/customizing.Rmd 2022-04-09 09:26:30 UTC (rev 720)
@@ -317,7 +317,7 @@
### `r mod.OBIGT_` for aqueous species
Let's add data for CoCl<sub>4</sub><sup>-2</sup> from @LBT_11.
-The values are taken from Table 5 of that paper; as is common for parameters in the HKF model, they are reported in caloric units, and some of the values have multipliers, which are kept when entering the data.
+The values are taken from Table 5 of that paper; as is common for parameters in the HKF model, they are reported in caloric units.
The entry includes the date in ISO 8601 extended format (e.g. 2020-08-16); `Sys.Date()` is used in this example to get the current date.
```{r mod.OBIGT__CoCl4_ghs}
mod.OBIGT("CoCl4-2", formula = "CoCl4-2", state = "aq", ref1 = "LBT+11", E_units = "cal",
@@ -325,7 +325,7 @@
```
The function prints a message saying that the species was added, and returns the species index of the new species.
-Now let's modify the new species by adding the HKF coefficients.
+Now let's modify the new species by adding the HKF coefficients including the OOM multipliers, as they are usually given in publications.
The `z` at the end refers to the charge of the species, and is used only for calculating the "*g* function" in the revised HKF model, not for balancing reactions.
```{r mod.OBIGT__CoCl4_eos}
mod.OBIGT("CoCl4-2", a1 = 6.5467, a2 = 8.2069, a3 = 2.0130, a4 = -3.1183,
Modified: pkg/CHNOSZ/vignettes/multi-metal.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/multi-metal.Rmd 2022-04-07 06:54:29 UTC (rev 719)
+++ pkg/CHNOSZ/vignettes/multi-metal.Rmd 2022-04-09 09:26:30 UTC (rev 720)
@@ -360,7 +360,8 @@
# Overlay lines from diagram on color map
diagram(a11, fill = NA, names = FALSE, limit.water = FALSE)
opar <- par(usr = c(0, 1, 0, 1))
-col <- rev(hcl.colors(128, palette = "YlGnBu", alpha = 0.8))
+col <- rev(topo.colors(128)) # No hcl.colors() in R < 3.6.0
+if(getRversion() >= "3.6.0") col <- rev(hcl.colors(128, palette = "YlGnBu", alpha = 0.8))
image(aFeVO4_vs_stable, col = col, add = TRUE)
par(opar)
diagram(a11, fill = NA, add = TRUE, names = FALSE)
@@ -397,7 +398,7 @@
This is plotted as a color map in the second diagram.
(See the source of this vignette for the code used to make the scale bar.)
-```{r FeVO4, echo = 31:43, message = FALSE, results = "hide", fig.width = 11, fig.height = 5, out.width = "100%", pngquant = FALSE}
+```{r FeVO4, echo = 31:44, message = FALSE, results = "hide", fig.width = 11, fig.height = 5, out.width = "100%", pngquant = FALSE}
```
Now we locate the pH and Eh that maximize the affinity (that is, minimize Δ*G*~pbx~) of FeVO~4~ compared to the stable species.
@@ -411,7 +412,7 @@
points(pH, Eh, pch = 10, cex = 2, lwd = 2, col = "gold")
stable <- d11$names[d11$predominant[imax]]
text(pH, Eh, stable, adj = c(0.3, 2), cex = 1.2, col = "gold")
-range(aFeVO4_vs_stable[d11$predominant == d11$predominant[imax]])
+(Apbx <- range(aFeVO4_vs_stable[d11$predominant == d11$predominant[imax]]))
```
Although one point is drawn on the diagram, FeVO~4~ has the same Pourbaix energy difference with respect to the entire Fe~2~O~3~ + Fe~2~V~4~O~13~ field, as shown by the `range()` command (the values are dimensionless values of affinity, *A*/(*RT*) = -Δ*G*~pbx~/(*RT*)).
@@ -420,13 +421,13 @@
To calculate the energy above the hull "by hand", let's set up the basis species to be the stable decomposition products we just found.
O~2~ is also needed to make a square stoichiometric matrix (i.e. same number of elements and basis species), but it does not appear in the reaction to form FeVO~4~ from the basis species.
`subcrt()` is used to automatically balance the formation reaction for 1 mole of FeVO~4~ and calculate the standard Gibbs energy of the reaction.
-The `convert()` command divides this value by *-RT* (which yields `r logK` of the reaction), showing the same result as calculated above from the Pourbaix diagram.
-The value of Δ*G*° in J/mol is converted to eV/mol, and finally eV/atom.
+We first test that `r logK` of the reaction (calculated with `convert()`, which divides Δ*G*° by *-RT*) is the same as the dimensionless affinity for FeVO~4~ calculated above.
+Then, the value of Δ*G*° in J/mol is converted to eV/mol, and finally eV/atom.
-```{r hull, echo = 1:7, message = FALSE}
+```{r hull, message = FALSE}
b <- basis(c("Fe2O3", "Fe2V4O13", "O2"))
J_mol <- subcrt("FeVO4", 1, T = 25)$out$G
-#convert(cal_mol, "logK")
+stopifnot(all.equal(rep(convert(J_mol, "logK"), 2), Apbx))
eV_mol <- J_mol / 1.602176634e-19
eV_atom <- eV_mol / 6.02214076e23 / 6
round(eV_atom, 3)
More information about the CHNOSZ-commits
mailing list