[CHNOSZ-commits] r559 - in pkg/CHNOSZ: . R inst man tests/testthat vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 14 15:55:14 CEST 2020


Author: jedick
Date: 2020-07-14 15:55:14 +0200 (Tue, 14 Jul 2020)
New Revision: 559

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/affinity.R
   pkg/CHNOSZ/R/solubility.R
   pkg/CHNOSZ/R/util.affinity.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/equilibrate.Rd
   pkg/CHNOSZ/man/protein.Rd
   pkg/CHNOSZ/tests/testthat/test-affinity.R
   pkg/CHNOSZ/tests/testthat/test-diagram.R
   pkg/CHNOSZ/tests/testthat/test-revisit.R
   pkg/CHNOSZ/vignettes/anintro.Rmd
Log:
Change default resolution in affinity() to 256


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/DESCRIPTION	2020-07-14 13:55:14 UTC (rev 559)
@@ -1,6 +1,6 @@
 Date: 2020-07-14
 Package: CHNOSZ
-Version: 1.3.6-32
+Version: 1.3.6-33
 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/affinity.R
===================================================================
--- pkg/CHNOSZ/R/affinity.R	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/R/affinity.R	2020-07-14 13:55:14 UTC (rev 559)
@@ -237,7 +237,7 @@
     Eharg <- args.orig[[iEh]]
     if(length(Eharg) > 3) Ehvals <- Eharg
     else if(length(Eharg) == 3) Ehvals <- seq(Eharg[1], Eharg[2], length.out=Eharg[3])
-    else if(length(Eharg) == 2) Ehvals <- seq(Eharg[1], Eharg[2], length.out=128)
+    else if(length(Eharg) == 2) Ehvals <- seq(Eharg[1], Eharg[2], length.out=256)
     vals[[iEh]] <- Ehvals
   }
   # get pe and pH

Modified: pkg/CHNOSZ/R/solubility.R
===================================================================
--- pkg/CHNOSZ/R/solubility.R	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/R/solubility.R	2020-07-14 13:55:14 UTC (rev 559)
@@ -142,7 +142,7 @@
     # stop iterating if we reached the tolerance (or find.IS=FALSE)
     if(!find.IS | all(IS - IS.old < 1e-4)) break
     # on the first iteration, expand argument values for affinity() or mosaic()
-    # (e.g. convert pH = c(0, 14) to pH = seq(0, 14, 128) so that it has the same length as the IS values)
+    # (e.g. convert pH = c(0, 14) to pH = seq(0, 14, 256) so that it has the same length as the IS values)
     # we don't do this if aout$vals is NA 20190731
     if(niter==1 & !all(is.na(aout$vals))) {
       if(thisfun=="affinity") for(i in 1:length(aout$vals)) {

Modified: pkg/CHNOSZ/R/util.affinity.R
===================================================================
--- pkg/CHNOSZ/R/util.affinity.R	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/R/util.affinity.R	2020-07-14 13:55:14 UTC (rev 559)
@@ -300,8 +300,8 @@
     else message('affinity: pressure is ',outvert(P,'bar'),' ',P.units())
   }
   if(!IS.is.var & !identical(IS,0)) message('affinity: ionic strength is ',IS)
-  # default values for resolution
-  res <- 128
+  # default value for resolution
+  res <- 256
   # where we store the output
   what <- "A"
   vars <- character()

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-07-14 13:55:14 UTC (rev 559)
@@ -154,6 +154,8 @@
 
       \item TODO: OBIGT.Rmd: change "CHNOSZ" references to "OBIGT".
 
+      \item TODO: change default plot resolution from 128 to 256.
+
     }
   }
 

Modified: pkg/CHNOSZ/man/equilibrate.Rd
===================================================================
--- pkg/CHNOSZ/man/equilibrate.Rd	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/man/equilibrate.Rd	2020-07-14 13:55:14 UTC (rev 559)
@@ -137,7 +137,7 @@
 stopifnot(all.equal(pKa.equil, -logK, tolerance=1e-2))
 
 # equilibrate with mosaic: balancing on two elements (N and C)
-# thanks to Kirt Robinson for the feature request and test system
+# thanks to Kirt Robinson for the feature request and test case
 loga_N <- -4
 loga_C <- -3
 basis(c("CO2", "NH3", "O2", "H2O", "H+"))

Modified: pkg/CHNOSZ/man/protein.Rd
===================================================================
--- pkg/CHNOSZ/man/protein.Rd	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/man/protein.Rd	2020-07-14 13:55:14 UTC (rev 559)
@@ -54,7 +54,7 @@
 stopifnot(organisms[unique(which.pmax(e$loga.equil))] ==
   c("METFE", "METJA", "METVO", "HALJP"))
 # stability order close to logfO2=-83.1
-stopifnot(order(as.data.frame(e$loga.equil)[62,],
+stopifnot(order(as.data.frame(e$loga.equil)[124,],
   decreasing=TRUE)==c(2, 6, 7, 5, 3, 1, 9, 8, 10, 4))
 # reset thermodynamic database
 reset()

Modified: pkg/CHNOSZ/tests/testthat/test-affinity.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-affinity.R	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/tests/testthat/test-affinity.R	2020-07-14 13:55:14 UTC (rev 559)
@@ -53,7 +53,7 @@
   expect_equal(a$vars, c("pH", "Eh"))
   expect_equal(range(a$vals[[1]]), pH)
   expect_equal(range(a$vals[[2]]), Eh)
-  expect_equal(length(a$vals[[2]]), 128)
+  expect_equal(length(a$vals[[2]]), 256)
   # since Eh has to be reconstructed, check it's done correctly
   a129 <- affinity(pH=pH, Eh=c(Eh, 129))
   expect_equal(length(a129$vals[[2]]), 129)

Modified: pkg/CHNOSZ/tests/testthat/test-diagram.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-diagram.R	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/tests/testthat/test-diagram.R	2020-07-14 13:55:14 UTC (rev 559)
@@ -37,7 +37,7 @@
   d <- diagram(a, "CO2", plot.it=FALSE)
   # test that the result does in fact correspond to zero affinity of formation, how about for acetate?
   a <- affinity(O2=d$vals[[1]], CO2=d$plotvals[[4]])
-  expect_equal(a$values[[4]], array(numeric(128)))
+  expect_equal(a$values[[4]], array(numeric(256)))
 })
 
 test_that("'groups' and 'alpha' work as expected", {
@@ -55,7 +55,7 @@
   # ask for degrees of formation instead of logarithms of activities
   d <- diagram(e, alpha=TRUE, plot.it=FALSE)
   # we should find that the sum of alphas is one
-  expect_equal(Reduce("+", d$plotvals), array(rep(1, 128)), check.attributes=FALSE)
+  expect_equal(Reduce("+", d$plotvals), array(rep(1, 256)), check.attributes=FALSE)
 })
 
 test_that("'normalize' and 'as.residue' work as expected", {
@@ -94,8 +94,8 @@
   d <- diagram(e, plot.it = FALSE)
   # equilibrate() here with default "boltzmann" method produces
   # NaN at very high O2 + low H2 or very low O2 + high H2 
-  expect_equal(d$predominant[1, 128], as.numeric(NA))
-  expect_equal(d$predominant[128, 1], as.numeric(NA))
+  expect_equal(d$predominant[1, 256], as.numeric(NA))
+  expect_equal(d$predominant[256, 1], as.numeric(NA))
 })
 
 ## add the test but exclude it for now because plot.it=FALSE doesn't produce values for namesx 20190223

Modified: pkg/CHNOSZ/tests/testthat/test-revisit.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-revisit.R	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/tests/testthat/test-revisit.R	2020-07-14 13:55:14 UTC (rev 559)
@@ -52,10 +52,10 @@
   r1.qqr <- revisit(e1, "qqr", plot.it=FALSE)
   # the tests will alert us to significant numerical changes
   # but so far haven't been independently verified
-  expect_equal(r1.cv$optimum, 0.30576, tolerance=1e-5) 
-  expect_equal(r1.sd$optimum, 0.000284694, tolerance=1e-5) 
-  expect_equal(r1.shannon$optimum, 1.066651, tolerance=1e-5)
-  expect_equal(r1.qqr$optimum, 0.999783, tolerance=1e-5)
+  expect_equal(r1.cv$optimum, 0.29927, tolerance=1e-5) 
+  expect_equal(r1.sd$optimum, 0.00027671, tolerance=1e-5) 
+  expect_equal(r1.shannon$optimum, 1.067228, tolerance=1e-5)
+  expect_equal(r1.qqr$optimum, 0.9999584, tolerance=1e-5)
 })
 
 test_that("referenced objectives give expected results", {
@@ -66,7 +66,7 @@
   expect_equal(max(r1.spearman$H), 1)  # perfect rank correlation
   # where logarithm of activity of the 3rd species (glutamic acid) maximizes
   r1.logact <- revisit(e1, "logact", 3, plot.it=FALSE)
-  expect_equal(r1.logact$ixopt, 71)
+  expect_equal(r1.logact$ixopt, 141)
 })
 
 test_that("DGtr objective gives zero at equilibrium and >0 not at equilibrium", {

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2020-07-14 10:07:42 UTC (rev 558)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2020-07-14 13:55:14 UTC (rev 559)
@@ -715,7 +715,7 @@
 
 We use <span style="color:green">`mosaic()`</span> to generate and combine diagrams for each candidate basis species (H<sub>2</sub>S, HS<sup>-</sup>, HSO<sub>4</sub><sup>-</sup>, or SO<sub>4</sub><sup>-2</sup>) as a function of Eh and pH.
 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 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 256).
 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 dashed blue lines using <span style="color:green">`water.lines()`</span>:
 



More information about the CHNOSZ-commits mailing list