[CHNOSZ-commits] r800 - in pkg/CHNOSZ: . R inst inst/tinytest

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 22 01:56:37 CEST 2023


Author: jedick
Date: 2023-08-22 01:56:37 +0200 (Tue, 22 Aug 2023)
New Revision: 800

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/subcrt.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/tinytest/test-subcrt.R
Log:
Fix bug in subcrt() for exceed.Ttr not applied to automatically balanced reactions


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2023-08-09 04:02:36 UTC (rev 799)
+++ pkg/CHNOSZ/DESCRIPTION	2023-08-21 23:56:37 UTC (rev 800)
@@ -1,6 +1,6 @@
-Date: 2023-08-09
+Date: 2023-08-22
 Package: CHNOSZ
-Version: 2.0.0-19
+Version: 2.0.0-20
 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	2023-08-09 04:02:36 UTC (rev 799)
+++ pkg/CHNOSZ/R/subcrt.R	2023-08-21 23:56:37 UTC (rev 800)
@@ -266,7 +266,7 @@
           newcoeff <- c(coeff, as.numeric(bc[1, ]))
           newstate <- c(state, b.state)
           return(subcrt(species = newspecies, coeff = newcoeff, state = newstate,
-            property = property, T = outvert(T, "K"), P = P, grid = grid, convert = convert, logact = logact, exceed.Ttr = FALSE))
+            property = property, T = outvert(T, "K"), P = P, grid = grid, convert = convert, logact = logact, exceed.Ttr = exceed.Ttr))
         } else warnings <- c(warnings, paste("reaction among", paste(species, collapse = ","), "was unbalanced, missing", as.chemical.formula(miss)))
       } else warnings <- c(warnings, paste("reaction among", paste(species, collapse = ","), "was unbalanced, missing", as.chemical.formula(miss)))
     }

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2023-08-09 04:02:36 UTC (rev 799)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2023-08-21 23:56:37 UTC (rev 800)
@@ -12,7 +12,7 @@
 % links to vignettes 20220723
 \newcommand{\viglink}{\ifelse{html}{\out{<a href="../CHNOSZ/doc/#1.html"><strong>#1.Rmd</strong></a>}}{\bold{#1.Rmd}}}
 
-\section{Changes in CHNOSZ version 2.0.0-19 (2023-08-09)}{
+\section{Changes in CHNOSZ version 2.0.0-20 (2023-08-22)}{
 
     \itemize{
 
@@ -33,6 +33,9 @@
       appropriate argument names for basis species and adjusts the labels for
       the diagram (\dQuote{total C}, \dQuote{total S}, etc.).
 
+      \item Fix bug where \code{exceed.Ttr} argument in \code{subcrt()} was
+      stuck at FALSE for automatically balanced reactions.
+
     }
 
 }

Modified: pkg/CHNOSZ/inst/tinytest/test-subcrt.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-subcrt.R	2023-08-09 04:02:36 UTC (rev 799)
+++ pkg/CHNOSZ/inst/tinytest/test-subcrt.R	2023-08-21 23:56:37 UTC (rev 800)
@@ -223,6 +223,16 @@
 info <- "Arguments 2 and 3 can't both be character"
 expect_error(subcrt(c("hydrogen", "H2"), c("gas", "aq"), "G"), info = info)
 
+# Added on 20230818
+info <- "exceed.Ttr works for basis species in automatically balanced reactions"
+basis(c("gypsum", "SO4-2", "H2O", "H+", "O2"))
+# Defaults for subcrt() go above the temperature limit for gypsum, so use exceed.Ttr to calculate logK
+automatic_reaction <- subcrt("Ca+2", 1, exceed.Ttr = TRUE)$out
+expect_false(any(is.na(automatic_reaction$logK)), info = info)
+# Check that logK is identical for the reaction entered manually
+manual_reaction <- subcrt(c("gypsum", "Ca+2", "SO4-2", "H2O"), c(-1, 1, 1, 2), exceed.Ttr = TRUE)$out
+expect_equal(automatic_reaction$logK, manual_reaction$logK, info = info)
+
 # References
 
 # Amend, J. P. and Shock, E. L. (2001) 



More information about the CHNOSZ-commits mailing list