[CHNOSZ-commits] r934 - in pkg/CHNOSZ: . R inst inst/tinytest man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Aug 22 05:21:38 CEST 2025
Author: jedick
Date: 2025-08-22 05:21:37 +0200 (Fri, 22 Aug 2025)
New Revision: 934
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/water.R
pkg/CHNOSZ/inst/NEWS.Rd
pkg/CHNOSZ/inst/tinytest/test-water.R
pkg/CHNOSZ/man/water.Rd
Log:
For IAPWS95, add 0.1 bar to Psat > 1 bar to prevent Born functions from exploding
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2025-08-01 03:35:56 UTC (rev 933)
+++ pkg/CHNOSZ/DESCRIPTION 2025-08-22 03:21:37 UTC (rev 934)
@@ -1,6 +1,6 @@
-Date: 2025-08-01
+Date: 2025-08-21
Package: CHNOSZ
-Version: 2.2.0-3
+Version: 2.2.0-4
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/water.R
===================================================================
--- pkg/CHNOSZ/R/water.R 2025-08-01 03:35:56 UTC (rev 933)
+++ pkg/CHNOSZ/R/water.R 2025-08-22 03:21:37 UTC (rev 934)
@@ -176,6 +176,8 @@
# Psat stuff
Psat <- function() {
P <- WP02.auxiliary("P.sigma", T)
+ # Add 0.1 bar (0.01 MPa) to Psat for stability of Born functions 20250821
+ P[P > 0.1] <- P[P > 0.1] + 0.01
# Convert Psat_floor from bar to MPa
if(is.numeric(Psat_floor)) P[P < Psat_floor / 10] <- Psat_floor / 10
return(convert(P, "bar"))
Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd 2025-08-01 03:35:56 UTC (rev 933)
+++ pkg/CHNOSZ/inst/NEWS.Rd 2025-08-22 03:21:37 UTC (rev 934)
@@ -15,7 +15,7 @@
\newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{<I>C<sub>P</sub></I>}}{Cp}}}
\newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{Δ<I>G</I>°}}{ΔG°}}}
-\section{Changes in CHNOSZ version 2.2.0-2 (2025-06-21)}{
+\section{Changes in CHNOSZ version 2.2.0-4 (2025-08-21)}{
\itemize{
@@ -23,6 +23,10 @@
logarithmic scales for x and y axes.
\item Fix bug preventing \code{mosaic()} from being used to form \H2O.
+
+ \item For IAPWS95 water model, add 0.1 bar (0.01 MPa) to values of Psat >
+ 1 bar computed from \code{WP02.auxiliary()} to prevent Born functions,
+ which are calculated as finite difference derivatives, from exploding.
}
Modified: pkg/CHNOSZ/inst/tinytest/test-water.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-water.R 2025-08-01 03:35:56 UTC (rev 933)
+++ pkg/CHNOSZ/inst/tinytest/test-water.R 2025-08-22 03:21:37 UTC (rev 934)
@@ -54,6 +54,17 @@
Tmax <- TC[max(which(Psat_floored > Psat))]
expect_equal(Tmax, 99.63, info = info)
+# Added 20250821
+info <- "IAPWS95 produces expected results for aqueous species (Born function) at Psat"
+water("SUPCRT92")
+sout_ref <- subcrt("H2")$out[[1]]
+water("IAPWS95")
+sout_test <- subcrt("H2")$out[[1]]
+expect_equal(sout_test$H, sout_ref$H, tolerance = 500, scale = 1, info = info)
+expect_equal(sout_test$S, sout_ref$S, tolerance = 1, scale = 1, info = info)
+expect_equal(sout_test$V, sout_ref$V, tolerance = 1, scale = 1, info = info)
+expect_equal(sout_test$Cp, sout_ref$Cp, tolerance = 40, scale = 1, info = info)
+
# Reference
# Fine, R. A. and Millero, F. J. (1973)
Modified: pkg/CHNOSZ/man/water.Rd
===================================================================
--- pkg/CHNOSZ/man/water.Rd 2025-08-01 03:35:56 UTC (rev 933)
+++ pkg/CHNOSZ/man/water.Rd 2025-08-22 03:21:37 UTC (rev 934)
@@ -106,7 +106,9 @@
\code{water.IAPWS95} provides for calculations at specific temperature and pressure; density, needed for \code{IAPWS95}, is inverted from pressure using \code{rho.IAPWS95}.
The function also contains routines for calculating the Born functions as numerical derivatives of the static dielectric constant (from \code{water.AW90}).
For compatibility with geochemical modeling conventions, the values of Gibbs energy, enthalpy and entropy output by \code{IAPWS95} are converted by \code{water.IAPWS95} to the triple point reference state adopted in \code{SUPCRT92} (Johnson and Norton, 1991; Helgeson and Kirkham, 1974).
+
\code{water.IAPWS95} also accepts setting \code{P} to \samp{Psat}, with the saturation pressure calculated from \code{\link{WP02.auxiliary}}; by default the returned properties are for the liquid, but this can be changed to the vapor in \code{\link{thermo}()$opt$IAPWS.sat}.
+NOTE: 0.1 bar (0.01 MPa) is added to values of \samp{Psat} > 1 bar computed from \code{WP02.auxiliary()} to prevent Born functions, which are calculated as finite difference derivatives, from exploding.
\code{A_DH} and \code{B_DH} are solvent parameters in the \dQuote{B-dot} (extended Debye-Huckel) equation (Helgeson, 1969; Manning, 2013).
}
More information about the CHNOSZ-commits
mailing list