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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 10 11:04:22 CET 2026


Author: jedick
Date: 2026-01-10 11:04:22 +0100 (Sat, 10 Jan 2026)
New Revision: 960

Added:
   pkg/CHNOSZ/inst/tinytest/test-mod.buffer.R
   pkg/CHNOSZ/inst/tinytest/test-util.water.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/inst/tinytest/test-diagram.R
Log:
Add tests for mod.buffer(), diagram(), and util.water.R


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2026-01-09 03:34:44 UTC (rev 959)
+++ pkg/CHNOSZ/DESCRIPTION	2026-01-10 10:04:22 UTC (rev 960)
@@ -1,6 +1,6 @@
-Date: 2026-01-09
+Date: 2026-01-10
 Package: CHNOSZ
-Version: 2.2.0-26
+Version: 2.2.0-27
 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/inst/tinytest/test-diagram.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-diagram.R	2026-01-09 03:34:44 UTC (rev 959)
+++ pkg/CHNOSZ/inst/tinytest/test-diagram.R	2026-01-10 10:04:22 UTC (rev 960)
@@ -139,7 +139,7 @@
 expect_equal(ana, and, info = info)
 
 # Tests added on 20260106
-info <- "Function works with 'dotted', 'lty.aq', and 'lty.cr' arguments"
+info <- "No error with 'dotted', 'lty.aq', and 'lty.cr' arguments"
 basis(c("Fe", "H2O", "H+", "e-"))
 species(c("Fe+2", "Fe+3", "magnetite", "hematite"))
 a <- affinity(pH = c(0, 12, 50), Eh = c(-1, 1, 50))
@@ -146,6 +146,11 @@
 expect_silent(diagram(a, dotted = 3), info = info)
 expect_silent(diagram(a, lty.cr = 2, lty.aq = 3), info = info)
 
+# Test added on 20260110
+info <- "No error with reversed axes"
+a <- affinity(pH = c(12, 0, 50), Eh = c(1, -1, 50))
+expect_silent(diagram(a), info = info)
+
 # Close the graphics device and remove the temporary PNG file
 dev.off()
 file.remove(pngfile)

Added: pkg/CHNOSZ/inst/tinytest/test-mod.buffer.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-mod.buffer.R	                        (rev 0)
+++ pkg/CHNOSZ/inst/tinytest/test-mod.buffer.R	2026-01-10 10:04:22 UTC (rev 960)
@@ -0,0 +1,32 @@
+# Load default settings for CHNOSZ
+reset()
+
+# Tests added on 20260110
+
+# Buffer + ionization: relative stabilities of E. coli sigma factors on a T-pH diagram
+# (sigma factors 24, 32, 38, 54, 70, i.e. RpoE, RpoH, RpoS, RpoN, RpoD)
+proteins <- c("RPOE", "RP32", "RPOS", "RP54", "RPOD")
+
+info <- "No error for proteins as buffers"
+
+# Define the buffer species
+expect_silent(mod.buffer("sigma", paste(proteins, "ECOLI", sep = "_")), info = info)
+# Get the bufferd activities of 4 basis species at 25 deg C and pH 7.4
+basis("CHNOS+")
+expect_silent(basis(c("CO2", "NH3", "H2S", "O2"), "sigma"), info = info)
+basis("pH", 7.4)
+expect_silent(logact <- affinity(return.buffer = TRUE, T = 25), info = info)
+
+info <- "Round-trip for diagram with activities buffered by proteins"
+
+# Set the activities of the basis species from the buffer
+basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact))
+species(paste(proteins, "ECOLI", sep = "_"))
+# Diagram the relative stabilities of proteins
+res <- 100
+a <- affinity(pH = c(5, 9, 100), T = c(20, 40, 100))
+d <- diagram(a, normalize = FALSE, plot.it = FALSE)
+# We should get out the T and pH given above
+tp <- find.tp(d$predominant)
+expect_equal(round(rev(a$vals$T)[median(tp[, 1])]), 25, info = info)
+expect_equal(round(a$vals$pH[median(tp[, 2])], 1), 7.4, info = info)

Added: pkg/CHNOSZ/inst/tinytest/test-util.water.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-util.water.R	                        (rev 0)
+++ pkg/CHNOSZ/inst/tinytest/test-util.water.R	2026-01-10 10:04:22 UTC (rev 960)
@@ -0,0 +1,30 @@
+# Load default settings for CHNOSZ
+reset()
+
+# Tests added on 20260110
+
+info <- "Expected results for WP02.auxiliary()"
+# Reference values for liquid and vapor density from WP02 Table 13.1
+expect_equal(round(WP02.auxiliary("rho.liquid", T = 273.16), 3), 999.793, tolerance = 0.005, scale = 1, info = info)
+expect_equal(round(WP02.auxiliary("rho.vapor", T = 273.16), 5), 0.00485, info = info)
+
+# TODO: This is a circular comparison - should find independent reference value somewhere
+expect_equal(round(WP02.auxiliary("dP.sigma.dT") * 1e8), 18898, info = info)
+
+info <- "Get expected density for water and steam"
+msg_info <- "Get expected message"
+
+# Some distance away from the saturation curve
+expect_message(rho_steam <- rho.IAPWS95(T = 373.15, P = 1.0, trace = 1), "steam", info = msg_info)
+expect_equal(round(rho_steam), 1, info = info)
+expect_message(rho_water <- rho.IAPWS95(T = 373.15, P = 1.1, trace = 1), "water", info = msg_info)
+expect_equal(round(rho_water), 958, info = info)
+
+# Closer to the saturation curve
+expect_message(rho_vapor <- rho.IAPWS95(T = 373.15, P = 1.0141, trace = 1), "close to saturation", info = msg_info)
+expect_equal(round(rho_vapor), 1, info = info)
+expect_message(rho_liquid <- rho.IAPWS95(T = 373.15, P = 1.0142, trace = 1), "close to saturation", info = msg_info)
+expect_equal(round(rho_liquid), 958, info = info)
+
+info <- "Warning for NA density"
+expect_warning(rho.IAPWS95(T = 1e15), "problems finding density", info = info)



More information about the CHNOSZ-commits mailing list