[CHNOSZ-commits] r611 - in pkg/CHNOSZ: . R tests/testthat vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 3 03:02:49 CET 2020


Author: jedick
Date: 2020-11-03 03:02:47 +0100 (Tue, 03 Nov 2020)
New Revision: 611

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/buffer.R
   pkg/CHNOSZ/tests/testthat/test-buffer.R
   pkg/CHNOSZ/vignettes/multi-metal.Rmd
Log:
Fix 0-D matrix indexing in buffer() and add new test


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-10-14 01:02:11 UTC (rev 610)
+++ pkg/CHNOSZ/DESCRIPTION	2020-11-03 02:02:47 UTC (rev 611)
@@ -1,6 +1,6 @@
-Date: 2020-10-14
+Date: 2020-11-03
 Package: CHNOSZ
-Version: 1.3.6-84
+Version: 1.3.6-85
 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/buffer.R
===================================================================
--- pkg/CHNOSZ/R/buffer.R	2020-10-14 01:02:11 UTC (rev 610)
+++ pkg/CHNOSZ/R/buffer.R	2020-11-03 02:02:47 UTC (rev 611)
@@ -112,8 +112,7 @@
     logact.basis <- logact.basis[ilb]
   }
   #  say hello
-  #cat(paste("buffer: '",bufname,"', of ",length(is.buffer),
-  #' species, ',length(ibasis),' activity(s) requested.\n',sep=''))
+  #cat(paste("buffer: '",bufname,"', of ",length(is.buffer),' species, ',length(ibasis),' activity(s) requested.\n',sep=''))
   ibasisrequested <- ibasis
   # check and maybe add to the number of buffered activities
   ibasisadded <- numeric()
@@ -190,7 +189,8 @@
         }
       }
     }
-    B[[i]] <- b
+    # Force this to be matrix so indexing works at a single point (no variables defined in affinity()) 20201102
+    B[[i]] <- as.matrix(b)
   }
   # a place to put the results
   X <- rep(B[1],length(ibasis))

Modified: pkg/CHNOSZ/tests/testthat/test-buffer.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-buffer.R	2020-10-14 01:02:11 UTC (rev 610)
+++ pkg/CHNOSZ/tests/testthat/test-buffer.R	2020-11-03 02:02:47 UTC (rev 611)
@@ -34,5 +34,15 @@
   #D2 <- diagram(A2)
   expect_equivalent(unique(as.vector(A2$buffer[[1]])), logaSiO2[1])
 
+  # A test for 0 dimensions with a two-mineral buffer 20201103
+  # (buffer errored trying to index columns of non-matrix prior to 1.3.6-85)
+  T <- 400
+  P <- 1000
+  basis(c("Fe", "O2"), c("cr", "gas"))
+  basis("O2", "HM")
+  O2_HM <- affinity(T = T, P = P, return.buffer = TRUE)$O2
+  logfO2 <- subcrt(c("hematite", "magnetite"), c(-6, 4), T = T, P = P)$out$logK
+  expect_equal(O2_HM, logfO2)
+
 })
 

Modified: pkg/CHNOSZ/vignettes/multi-metal.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/multi-metal.Rmd	2020-10-14 01:02:11 UTC (rev 610)
+++ pkg/CHNOSZ/vignettes/multi-metal.Rmd	2020-11-03 02:02:47 UTC (rev 611)
@@ -263,7 +263,7 @@
 
 In these diagrams, changing the Fe:V ratio affects the fully reduced metallic species.
 In the 1:1 mixture, the FeV~3~ + Fe~3~V assemblage is predicted to be stable instead of FeV.
-This result is unlike Figure 1 of @SZS_17 but is consistent with the [MP page for FeV](https://doi.org/10.17188/1189535) where it shown to decompose to this assemblage.
+This result is unlike Figure 1 of @SZS_17 but is consistent with the [MP page for FeV](https://doi.org/10.17188/1189535) where it is shown to decompose to this assemblage.
 On the other hand, [FeV~3~ is stable](https://materialsproject.org/materials/mp-1079399/) in the 1:3 mixture.
 For an even higher proportion of V, the V + FeV~3~ assemblage is stable, which can be seen for instance in the Pourbaix diagram linked from the [MP page for FeV~5~O~12~](https://doi.org/10.17188/1305091).
 



More information about the CHNOSZ-commits mailing list