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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 3 08:37:08 CEST 2019


Author: jedick
Date: 2019-09-03 08:37:08 +0200 (Tue, 03 Sep 2019)
New Revision: 506

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/util.data.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/tests/testthat/test-util.data.R
Log:
obigt2eos(): don't apply units conversion to lambda


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-09-03 04:33:08 UTC (rev 505)
+++ pkg/CHNOSZ/DESCRIPTION	2019-09-03 06:37:08 UTC (rev 506)
@@ -1,6 +1,6 @@
 Date: 2019-09-03
 Package: CHNOSZ
-Version: 1.3.3-2
+Version: 1.3.3-3
 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/util.data.R
===================================================================
--- pkg/CHNOSZ/R/util.data.R	2019-09-03 04:33:08 UTC (rev 505)
+++ pkg/CHNOSZ/R/util.data.R	2019-09-03 06:37:08 UTC (rev 506)
@@ -420,7 +420,11 @@
   if(tocal) {
     # convert values from Joules to calories 20190530
     iJ <- obigt$E_units=="J"
-    if(any(iJ)) obigt[iJ, c(9:12, 14:20)] <- convert(obigt[iJ, c(9:12, 14:20)], "cal")
+    if(any(iJ)) {
+      # we only convert column 20 for aqueous species (omega), not for cgl species (lambda)  20190903
+      if(identical(state, "aq")) obigt[iJ, c(9:12, 14:20)] <- convert(obigt[iJ, c(9:12, 14:20)], "cal")
+      else obigt[iJ, c(9:12, 14:19)] <- convert(obigt[iJ, c(9:12, 14:19)], "cal")
+    }
   }
   if(fixGHS) {
     # fill in one of missing G, H, S

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-09-03 04:33:08 UTC (rev 505)
+++ pkg/CHNOSZ/inst/NEWS	2019-09-03 06:37:08 UTC (rev 506)
@@ -1,12 +1,15 @@
-CHANGES IN CHNOSZ 1.3.3-2 (2019-09-03)
+CHANGES IN CHNOSZ 1.3.3-3 (2019-09-03)
 --------------------------------------
 
 - describe.reaction(): revert the change of using a double arrow. The
   equals sign is much more portable.
 
-- OBIGT: Change data for dawsonite, scheelite, and ferberite to Joules
-  (original values).
+- OBIGT: Change data for dawsonite, scheelite, and ferberite from
+  calories to Joules (as originally reported).
 
+- Fix bug in unexported function obigt2eos(): lambda (exponent in heat
+  capacity equation) was incorrectly going through a units conversion.
+
 CHANGES IN CHNOSZ 1.3.3 (2019-08-02)
 ------------------------------------
 

Modified: pkg/CHNOSZ/tests/testthat/test-util.data.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-util.data.R	2019-09-03 04:33:08 UTC (rev 505)
+++ pkg/CHNOSZ/tests/testthat/test-util.data.R	2019-09-03 06:37:08 UTC (rev 506)
@@ -115,6 +115,20 @@
   E.units("cal")
 })
 
+test_that("obigt2eos() doesn't convert lambda for cr species", {
+  ## bug visible with change of ferberite data to J:
+  ## lambda (exponent on heat capacity term)
+  ## was incorrectly going through a units conversion  20190903
+  # this was working
+  mod.obigt("test_cal", formula = "C0", state = "cr", E_units = "cal", a = 10, b = 100, f = 1, lambda = 0)
+  mod.obigt("test_J", formula = "C0", state = "cr", E_units = "J", a = 41.84, b = 418.4, f = 4.184, lambda = 0)
+  expect_equal(subcrt("test_cal", T = 25)$out[[1]]$Cp, subcrt("test_J", T = 25)$out[[1]]$Cp)
+  # this wasn't working
+  mod.obigt("test_cal2", formula = "C0", state = "cr", E_units = "cal", a = 10, b = 100, f = 1, lambda = -1)
+  mod.obigt("test_J2", formula = "C0", state = "cr", E_units = "J", a = 41.84, b = 418.4, f = 4.184, lambda = -1)
+  expect_equal(subcrt("test_cal2", T = 25)$out[[1]]$Cp, subcrt("test_J2", T = 25)$out[[1]]$Cp)
+})
+
 # reference
 
 # Richard, L. and Helgeson, H. C. (1998) Calculation of the thermodynamic properties at elevated 



More information about the CHNOSZ-commits mailing list