[CHNOSZ-commits] r301 - in pkg/CHNOSZ: . R inst tests/testthat vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Dec 22 02:54:12 CET 2017
Author: jedick
Date: 2017-12-22 02:54:12 +0100 (Fri, 22 Dec 2017)
New Revision: 301
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/nonideal.R
pkg/CHNOSZ/inst/NEWS
pkg/CHNOSZ/tests/testthat/test-nonideal.R
pkg/CHNOSZ/vignettes/anintro.Rmd
Log:
nonideal(): fix bug grepping 'Zn' as charge
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2017-12-14 03:54:37 UTC (rev 300)
+++ pkg/CHNOSZ/DESCRIPTION 2017-12-22 01:54:12 UTC (rev 301)
@@ -1,6 +1,6 @@
-Date: 2017-12-14
+Date: 2017-12-21
Package: CHNOSZ
-Version: 1.1.3-7
+Version: 1.1.3-9
Title: Thermodynamic Calculations for Geobiochemistry
Authors at R: c(
person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),
Modified: pkg/CHNOSZ/R/nonideal.R
===================================================================
--- pkg/CHNOSZ/R/nonideal.R 2017-12-14 03:54:37 UTC (rev 300)
+++ pkg/CHNOSZ/R/nonideal.R 2017-12-22 01:54:12 UTC (rev 301)
@@ -80,8 +80,9 @@
# get the charge from the chemical formula
# force a charge count even if it's zero
mkp <- makeup(c("Z0", species[i]), sum=TRUE)
- Z <- mkp[grep("Z", names(mkp))]
- # don't do anything for neutral species
+ Z <- mkp[match("Z", names(mkp))]
+ # don't do anything for neutral species (Z absent from formula or equal to zero)
+ if(is.na(Z)) next
if(Z==0) next
# to keep unit activity coefficients of the proton and electron
if(species[i] == iH & get("thermo")$opt$ideal.H) next
Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS 2017-12-14 03:54:37 UTC (rev 300)
+++ pkg/CHNOSZ/inst/NEWS 2017-12-22 01:54:12 UTC (rev 301)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.3-7 (2017-12-14)
+CHANGES IN CHNOSZ 1.1.3-8 (2017-12-21)
--------------------------------------
- Lines in 1-D diagram()s can optionally be drawn as splines using the
@@ -18,6 +18,8 @@
- Fix a bug where subcrt()$reaction$coeffs was incorrect for reactions
involving minerals with phase transitions.
+- Fix bug in nonideal() where 'Zn' in formula was identified as charge.
+
CHANGES IN CHNOSZ 1.1.3 (2017-11-13)
------------------------------------
Modified: pkg/CHNOSZ/tests/testthat/test-nonideal.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-nonideal.R 2017-12-14 03:54:37 UTC (rev 300)
+++ pkg/CHNOSZ/tests/testthat/test-nonideal.R 2017-12-22 01:54:12 UTC (rev 301)
@@ -50,10 +50,6 @@
expect_maxdiff(DEW30$B_DH / 1e8, B30, 0.024)
})
-#test_that("different methods give correct values of loggamma", {
-#
-#})
-
test_that("affinity transect incorporates IS correctly", {
basis("CHNOS+")
species("acetate")
@@ -71,3 +67,11 @@
expect_equal(a$values[[1]][1], a25_0$values[[1]][1])
expect_equal(a$values[[1]][4], a50_1$values[[1]][1])
})
+
+# 20171221
+test_that("nonideality calculations work for Zn", {
+ # nonideal() had a bug where both Z and Zn were identified as the charge
+ # in the species formula, producing an error in this calculation
+ expect_type(subcrt(c("Zn+2", "Cl-", "ZnCl+"), c(-1, -1, 1), T=200, P=16, IS=0.05), "list")
+})
+
Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-12-14 03:54:37 UTC (rev 300)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-12-22 01:54:12 UTC (rev 301)
@@ -209,10 +209,10 @@
* Use <span style="color:green">`subcrt()`</span> to calculate standard molal thermodynamic properties.
-```{r bsad_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Nucleobase equal-activity diagram.", cache=TRUE, pngquant=pngquant, timeit=timeit}
+```{r bsad_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Nucleobase equal-activity diagram at <i>T</i> = 100 °C.", cache=TRUE, pngquant=pngquant, timeit=timeit}
basis("CHNOSe")
species(c("adenine", "cytosine", "guanine", "thymine", "uracil"))
-a <- affinity(H2O = c(-12, -0), Eh = c(-0.5, 0), T = 100)
+a <- affinity(H2O = c(-12, -0), Eh = c(-0.4, -0.2), T = 100)
diagram(a)
```
@@ -220,11 +220,11 @@
subcrt("adenine", T = 100)
```
-```{r equil_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Activities of nucleobases in metastable equilibrium.", cache=TRUE, pngquant=pngquant, timeit=timeit}
+```{r equil_adenine, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Activities of nucleobases in metastable equilibrium at <i>T</i> = 100 °C.", cache=TRUE, pngquant=pngquant, timeit=timeit}
basis("e-", 3.6)
a <- affinity(H2O = c(-12, 0), T = 100)
e <- equilibrate(a)
-diagram(e, ylim = c(-8, 0))
+diagram(e, ylim = c(-5, -1))
```
* Use <span style="color:red">`basis()`</span> – <span style="color:red">`species()`</span> – <span style="color:green">`affinity()`</span> – <span style="color:green">`diagram()`</span> (BSAD) to construct equal-activity (equipotential) diagrams.
More information about the CHNOSZ-commits
mailing list