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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 20 08:33:14 CEST 2022


Author: jedick
Date: 2022-09-20 08:33:14 +0200 (Tue, 20 Sep 2022)
New Revision: 745

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/add.OBIGT.R
   pkg/CHNOSZ/R/info.R
   pkg/CHNOSZ/R/subcrt.R
   pkg/CHNOSZ/inst/tinytest/test-mod.OBIGT.R
Log:
mod.OBIGT(): Add test for multiple species, default 'model', and running info() afterward


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2022-09-20 02:33:43 UTC (rev 744)
+++ pkg/CHNOSZ/DESCRIPTION	2022-09-20 06:33:14 UTC (rev 745)
@@ -1,6 +1,6 @@
 Date: 2022-09-20
 Package: CHNOSZ
-Version: 1.9.9-36
+Version: 1.9.9-37
 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/add.OBIGT.R
===================================================================
--- pkg/CHNOSZ/R/add.OBIGT.R	2022-09-20 02:33:43 UTC (rev 744)
+++ pkg/CHNOSZ/R/add.OBIGT.R	2022-09-20 06:33:14 UTC (rev 745)
@@ -59,7 +59,8 @@
     # Fill in the columns
     newrows[, icol] <- args[inew, ]
     # Guess model from state 20220919
-    if(is.na(newrows$model)) newrows$model <- ifelse(newrows$state == "aq", "HKF", "CGL")
+    namodel <- is.na(newrows$model)
+    if(any(namodel)) newrows$model[namodel] <- ifelse(newrows$state[namodel] == "aq", "HKF", "CGL")
     # Now check the formulas
     e <- tryCatch(makeup(newrows$formula), error=function(e) e)
     if(inherits(e, "error")) {

Modified: pkg/CHNOSZ/R/info.R
===================================================================
--- pkg/CHNOSZ/R/info.R	2022-09-20 02:33:43 UTC (rev 744)
+++ pkg/CHNOSZ/R/info.R	2022-09-20 06:33:14 UTC (rev 745)
@@ -195,7 +195,7 @@
   # Use new OBIGT2eos function here
   this <- OBIGT2eos(this, this$state)
 
-  if(all(is.na(this[, 10:22])) & this$name != "water") {
+  if(tolower(this$model) == "berman") { # this is Berman
     # Get G, H, S, and V for minerals with Berman parameters 20220203
     Bermandat <- Berman()
     Bermandat <- Bermandat[Bermandat$name == this$name, ]

Modified: pkg/CHNOSZ/R/subcrt.R
===================================================================
--- pkg/CHNOSZ/R/subcrt.R	2022-09-20 02:33:43 UTC (rev 744)
+++ pkg/CHNOSZ/R/subcrt.R	2022-09-20 06:33:14 UTC (rev 745)
@@ -197,6 +197,7 @@
   if(length(unique(iphases))==length(iphases)) rownames(reaction) <- as.character(iphases)
   # Which are aqueous species
   isaq <- reaction$state == "aq"
+  # Save this test for debugging 20220920
   isaq.model <- toupper(reaction$model) %in% c("HKF", "AD", "DEW")
   stopifnot(all(isaq == isaq.model))
 

Modified: pkg/CHNOSZ/inst/tinytest/test-mod.OBIGT.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-mod.OBIGT.R	2022-09-20 02:33:43 UTC (rev 744)
+++ pkg/CHNOSZ/inst/tinytest/test-mod.OBIGT.R	2022-09-20 06:33:14 UTC (rev 745)
@@ -35,3 +35,8 @@
 T <- c(120, 150, 200, 250, 300)
 P <- "Psat"
 expect_error(logB_to_OBIGT(logB[1:2], species, coeff, T[1:2], P))
+
+# Test added 20220920
+info <- "Can add > 1 species; different states get different default models; info() works after mod.OBIGT"
+iC12C13 <- mod.OBIGT(c("X", "Y"), formula = c("C12", "C13"), state = c("aq", "cr"))
+expect_identical(info(iC12C13)$model, c("HKF", "CGL"))



More information about the CHNOSZ-commits mailing list