[CHNOSZ-commits] r512 - in pkg/CHNOSZ: . R inst tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 11 03:09:53 CET 2019


Author: jedick
Date: 2019-11-11 03:09:53 +0100 (Mon, 11 Nov 2019)
New Revision: 512

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/subcrt.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/tests/testthat/test-subcrt.R
Log:
subcrt(): make properties of minerals not NA at transition temperature


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-10-24 03:32:37 UTC (rev 511)
+++ pkg/CHNOSZ/DESCRIPTION	2019-11-11 02:09:53 UTC (rev 512)
@@ -1,6 +1,6 @@
 Date: 2019-10-24
 Package: CHNOSZ
-Version: 1.3.3-8
+Version: 1.3.3-9
 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/subcrt.R
===================================================================
--- pkg/CHNOSZ/R/subcrt.R	2019-10-24 03:32:37 UTC (rev 511)
+++ pkg/CHNOSZ/R/subcrt.R	2019-11-11 02:09:53 UTC (rev 512)
@@ -357,11 +357,11 @@
             # so use iphases[i-1] here, not iphases[i]-1  20181107
             Ttr <- Ttr(iphases[i-1], iphases[i], P=P, dPdT = dPdTtr(iphases[i-1], iphases[i]))
             if(all(is.na(Ttr))) next
-            if(any(T < Ttr)) {
+            if(any(T <= Ttr)) {
               status.Ttr <- "(extrapolating G)"
               if(!exceed.Ttr) {
                 # put NA into the value of G
-                p.cgl[[ncgl[i]]]$G[T<Ttr] <- NA
+                p.cgl[[ncgl[i]]]$G[T <= Ttr] <- NA
                 status.Ttr <- "(using NA for G)"
               } 
               #message(paste('subcrt: some points below transition temperature for',myname, mystate, status.Ttr))
@@ -382,13 +382,13 @@
           }
         }
         if(any(is.na(Ttr))) next
-        if(!all(Ttr == 0) & any(T >= Ttr)) {
+        if(!all(Ttr == 0) & any(T > Ttr)) {
           status.Ttr <- "(extrapolating G)"
           if(!exceed.Ttr) {
-            p.cgl[[ncgl[i]]]$G[T >= Ttr] <- NA
+            p.cgl[[ncgl[i]]]$G[T > Ttr] <- NA
             status.Ttr <- "(using NA for G)"
           }
-          Tmax <- min(T[T >= Ttr])
+          Tmax <- min(T[T > Ttr])
           if(warn.above) message(paste("subcrt: temperature(s) of", Tmax, "K and above exceed limit for", myname, mystate, status.Ttr))
         }
       }

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-10-24 03:32:37 UTC (rev 511)
+++ pkg/CHNOSZ/inst/NEWS	2019-11-11 02:09:53 UTC (rev 512)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.3.3-8 (2019-10-24)
+CHANGES IN CHNOSZ 1.3.3-9 (2019-11-11)
 --------------------------------------
 
 - describe.reaction(): revert the change of using a double arrow. The
@@ -23,6 +23,11 @@
 - Move some carbonates from SUPCRT92 back into default database:
   artinite, azurite.
 
+- subcrt(): properties of minerals are now calculated including the
+  upper T limit (or transition temperature, for e.g. cr1 -> cr2).
+  Previously, properties were NA for temperature equal to the transition
+  temperature.
+
 CHANGES IN CHNOSZ 1.3.3 (2019-08-02)
 ------------------------------------
 

Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-subcrt.R	2019-10-24 03:32:37 UTC (rev 511)
+++ pkg/CHNOSZ/tests/testthat/test-subcrt.R	2019-11-11 02:09:53 UTC (rev 512)
@@ -66,6 +66,8 @@
   expect_equal(subcrt("acanthite")$out$acanthite$polymorph, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3))
   # the reaction coefficients in the output should be unchanged 20171214
   expect_equal(subcrt(c("bunsenite", "nickel", "oxygen"), c(-1, 1, 0.5))$reaction$coeff, c(-1, 1, 0.5)) 
+  # properties are NA only above (not at) the transition temperature 20191111
+  expect_equal(is.na(subcrt("rhodochrosite", T = c(699:701), P = 1, convert = FALSE)$out[[1]]$G), c(FALSE, FALSE, TRUE))
 })
 
 test_that("calculations for K-feldspar are consistent with SUPCRT92", {



More information about the CHNOSZ-commits mailing list