[CHNOSZ-commits] r689 - in pkg/CHNOSZ: . R demo inst inst/tinytest
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 3 04:47:20 CET 2022
Author: jedick
Date: 2022-02-03 04:47:20 +0100 (Thu, 03 Feb 2022)
New Revision: 689
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/basis.R
pkg/CHNOSZ/R/berman.R
pkg/CHNOSZ/R/info.R
pkg/CHNOSZ/R/solubility.R
pkg/CHNOSZ/R/util.data.R
pkg/CHNOSZ/R/util.seq.R
pkg/CHNOSZ/demo/DEW.R
pkg/CHNOSZ/demo/Pourbaix.R
pkg/CHNOSZ/demo/sources.R
pkg/CHNOSZ/inst/TODO
pkg/CHNOSZ/inst/tinytest/test-berman.R
pkg/CHNOSZ/inst/tinytest/test-eos.R
pkg/CHNOSZ/inst/tinytest/test-mix.R
pkg/CHNOSZ/inst/tinytest/test-util.data.R
Log:
More use of info(..., check.it = FALSE) and fix demo/DEW.R
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/DESCRIPTION 2022-02-03 03:47:20 UTC (rev 689)
@@ -1,6 +1,6 @@
-Date: 2022-02-02
+Date: 2022-02-03
Package: CHNOSZ
-Version: 1.4.1-14
+Version: 1.4.1-15
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/basis.R
===================================================================
--- pkg/CHNOSZ/R/basis.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/R/basis.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -74,8 +74,8 @@
ina <- ispecies > nrow(thermo$OBIGT)
} else {
# get species indices using states from the argument, or default states
- if(!is.null(state)) ispecies <- suppressMessages(info(species, state, check.it=FALSE))
- else ispecies <- suppressMessages(info(species, check.it=FALSE))
+ if(!is.null(state)) ispecies <- suppressMessages(info(species, state))
+ else ispecies <- suppressMessages(info(species))
# check if we got all the species
ina <- is.na(ispecies)
# info() returns a list if any of the species had multiple approximate matches
@@ -156,7 +156,7 @@
# compatible with the basis definition
for(k in 1:length(ibuff)) {
ispecies <- suppressMessages(info(as.character(thermo$buffer$species)[ibuff[k]],
- as.character(thermo$buffer$state)[ibuff[k]], check.it=FALSE))
+ as.character(thermo$buffer$state)[ibuff[k]]))
bufmakeup <- makeup(ispecies)
inbasis <- names(bufmakeup) %in% colnames(basis())
if(FALSE %in% inbasis) {
@@ -169,11 +169,11 @@
} else {
# first, look for a species with the same _name_ in the requested state
myname <- thermo$OBIGT$name[thermo$basis$ispecies[ib]]
- ispecies <- suppressMessages(info(myname, state[i], check.it=FALSE))
+ ispecies <- suppressMessages(info(myname, state[i]))
if(is.na(ispecies) | is.list(ispecies)) {
# if that failed, look for a species with the same _formula_ in the requested state
myformula <- thermo$OBIGT$formula[thermo$basis$ispecies[ib]]
- ispecies <- suppressMessages(info(myformula, state[i], check.it=FALSE))
+ ispecies <- suppressMessages(info(myformula, state[i]))
if(is.na(ispecies) | is.list(ispecies)) {
# if that failed, we're out of luck
if(myname==myformula) nametxt <- myname else nametxt <- paste(myname, "or", myformula)
Modified: pkg/CHNOSZ/R/berman.R
===================================================================
--- pkg/CHNOSZ/R/berman.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/R/berman.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -56,7 +56,7 @@
# assign values to the variables used below
for(i in 1:ncol(dat)) assign(colnames(dat)[i], dat[irow, i])
# get the entropy of the elements using the chemical formula in thermo()$OBIGT
- if(is.null(thisinfo)) thisinfo <- info(info(name, "cr", check.it=FALSE))
+ if(is.null(thisinfo)) thisinfo <- info(info(name, "cr"), check.it = FALSE)
SPrTr_elements <- convert(entropy(thisinfo$formula), "J")
# check that G in data file is the G of formation from the elements --> Benson-Helgeson convention (DG = DH - T*DS)
if(check.G) {
Modified: pkg/CHNOSZ/R/info.R
===================================================================
--- pkg/CHNOSZ/R/info.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/R/info.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -206,6 +206,7 @@
# now perform consistency checks for GHS and EOS parameters if check.it=TRUE
# don't do it for the AkDi species 20190219
if(check.it & !"xi" %in% colnames(this)) {
+print(paste("check.it:", this$name))
# check GHS if they are all present
if(sum(naGHS)==0) calcG <- checkGHS(this)
# check tabulated heat capacities against EOS parameters
Modified: pkg/CHNOSZ/R/solubility.R
===================================================================
--- pkg/CHNOSZ/R/solubility.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/R/solubility.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -174,7 +174,7 @@
}
# add ions present in the species of interest
# instead of using aout$species$name, use info() to get formulas 20190309
- species.formulas <- suppressMessages(info(aout$species$ispecies)$formula)
+ species.formulas <- suppressMessages(info(aout$species$ispecies, check.it = FALSE)$formula)
for(i in 1:length(loga.equil)) {
species.ion <- species.formulas[i]
Z.species.ion <- makeup(species.ion)["Z"]
Modified: pkg/CHNOSZ/R/util.data.R
===================================================================
--- pkg/CHNOSZ/R/util.data.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/R/util.data.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -140,7 +140,7 @@
return(x[ix, ])
} else if(is.numeric(key)) {
# get the source keys for the indicated species
- sinfo <- suppressMessages(info(key))
+ sinfo <- suppressMessages(info(key, check.it = FALSE))
if(keep.duplicates) {
# output a single reference for each species 20180927
# (including duplicated references, and not including ref2)
Modified: pkg/CHNOSZ/R/util.seq.R
===================================================================
--- pkg/CHNOSZ/R/util.seq.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/R/util.seq.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -44,7 +44,7 @@
# we'll normally have at least one NA (U or A for DNA or RNA)
ina <- is.na(i.lett)
# the species indices of the bases, in the order appearing above
- i.base <- suppressMessages(info(names[!ina], check.it=FALSE))
+ i.base <- suppressMessages(info(names[!ina]))
# the chemical formula of bases
f.base <- get("thermo", CHNOSZ)$OBIGT$formula[i.base]
# loop over the base counts
Modified: pkg/CHNOSZ/demo/DEW.R
===================================================================
--- pkg/CHNOSZ/demo/DEW.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/demo/DEW.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -65,7 +65,7 @@
# a function to get the HKF parameters, calculate nonsolvation volume, plot points, labels, error bars, and correlation lines
plotfun <- function(species, col, pch, cex, dy, error, xlim, corrfun) {
# get HKF parameters
- par <- info(info(species))
+ par <- info(info(species), check.it = FALSE)
a1 <- par$a1 * 10
# get the nonsolvation volume
Vn <- unlist(hkf("V", par, contrib="n")$aq)
@@ -188,6 +188,8 @@
### additional checks
+# The maximum absolute pairwise difference between x and y
+maxdiff <- function(x, y) max(abs(y - x))
## check that we're within 0.1 of the QFM-2 values used by SSH14
stopifnot(maxdiff((buf$O2-2), c(-17.0, -14.5, -12.5, -10.8, -9.4)) < 0.1)
Modified: pkg/CHNOSZ/demo/Pourbaix.R
===================================================================
--- pkg/CHNOSZ/demo/Pourbaix.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/demo/Pourbaix.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -135,7 +135,7 @@
# but we use positions calculated with the first equisolubility line
# so that names are within the shrunken parts of the mineral fields)
# Create labels using chemical formulas instead of name of minerals
-formulas <- info(a_all$species$ispecies)$formula
+formulas <- info(a_all$species$ispecies, check.it = FALSE)$formula
formulas[a_all$species$state == "aq"] <- ""
diagram(a_all, fill = NA, names = formulas, bold = TRUE, cex.names = 1.2, lty = 0, add = TRUE)
Modified: pkg/CHNOSZ/demo/sources.R
===================================================================
--- pkg/CHNOSZ/demo/sources.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/demo/sources.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -24,8 +24,11 @@
tdata <- read.csv(system.file("extdata/OBIGT/AkDi.csv", package="CHNOSZ"), as.is=TRUE)
os9 <- gsub("\ .*", "", tdata$ref1)
os10 <- gsub("\ .*", "", tdata$ref2)
+tdata <- read.csv(system.file("extdata/OBIGT/GEMSFIT.csv", package="CHNOSZ"), as.is=TRUE)
+os11 <- gsub("\ .*", "", tdata$ref1)
+os12 <- gsub("\ .*", "", tdata$ref2)
# all of the thermodynamic data sources - some of them might be NA
-OBIGT.source <- unique(c(ps1, ps2, os1, os2, os3, os4, os5, os6, os7, os8, os9, os10))
+OBIGT.source <- unique(c(ps1, ps2, os1, os2, os3, os4, os5, os6, os7, os8, os9, os10, os11, os12))
OBIGT.source <- OBIGT.source[!is.na(OBIGT.source)]
# these all produce character(0) if the sources are all accounted for
print("missing these sources for thermodynamic properties:")
Modified: pkg/CHNOSZ/inst/TODO
===================================================================
--- pkg/CHNOSZ/inst/TODO 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/inst/TODO 2022-02-03 03:47:20 UTC (rev 689)
@@ -44,3 +44,7 @@
[20210722]
- Add pyrobitumen properties from Helgeson et al. (2009)
+
+[20220203]
+
+- Allow numeric values for bases in mosaic() (test-mix.R)
Modified: pkg/CHNOSZ/inst/tinytest/test-berman.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-berman.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/inst/tinytest/test-berman.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -30,7 +30,7 @@
# all of these except rutile (Robie et al., 1979) reference Helgeson et al., 1978
# NOTE: with check.it = TRUE (the default), this calculates Cp from the tabulated Maier-Kelley parameters
add.OBIGT("SUPCRT92")
-prop_Helgeson <- suppressMessages(info(icr))
+prop_Helgeson <- suppressMessages(info(icr, check.it = FALSE))
OBIGT()
# now we can compare Berman and Helgeson G, H, S, Cp, V
Modified: pkg/CHNOSZ/inst/tinytest/test-eos.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-eos.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/inst/tinytest/test-eos.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -101,7 +101,7 @@
# compare Gibbs energies at 25 degrees calculated with AkDi model to database values
iAkDi <- add.OBIGT("AkDi")
# remove hydroxides because they aren't in the default database (except B(OH)3(aq))
-iAkDi <- iAkDi[-grep("OH", info(iAkDi)$name)]
+iAkDi <- iAkDi[-grep("OH", info(iAkDi, check.it = FALSE)$name)]
# this would produce an error if any calculations failed
# (e.g. because gases corresponding to any aqueous species were unavailable)
sAkDi <- subcrt(iAkDi, T = 25)
@@ -108,7 +108,7 @@
GAkDi <- do.call(rbind, sAkDi$out)$G
# now get the parameters from default OBIGT
reset()
-GOBIGT <- info(iAkDi)$G
+GOBIGT <- info(iAkDi, check.it = FALSE)$G
# the differences are not that big, except for HCl(aq)
maxdiff <- function(x, y) max(abs(y - x))
expect_true(maxdiff(GAkDi, GOBIGT) < 300, info = info)
Modified: pkg/CHNOSZ/inst/tinytest/test-mix.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-mix.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/inst/tinytest/test-mix.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -57,8 +57,8 @@
iCu <- c(iCu.cr, iCu.aq)
# TODO: allow numeric values for bases in mosaic()
#mbornite <- mosaic(list(iFe, iCu), pH = pH, Eh = Eh, T = 300, predominant = list(dFe$predominant, dCu$predominant))
-Fe <- info(iFe)$name
-Cu <- info(iCu)$name
+Fe <- info(iFe, check.it = FALSE)$name
+Cu <- info(iCu, check.it = FALSE)$name
mbornite <- mosaic(list(Fe, Cu), pH = pH, Eh = Eh, T = 300, blend = FALSE)
if(plot.it) image(mbornite$A.species$values[[1]])
Modified: pkg/CHNOSZ/inst/tinytest/test-util.data.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-util.data.R 2022-02-02 04:15:37 UTC (rev 688)
+++ pkg/CHNOSZ/inst/tinytest/test-util.data.R 2022-02-03 03:47:20 UTC (rev 689)
@@ -59,7 +59,7 @@
rc <- read.csv(file)
expect_false("E_units" %in% colnames(rc), info = info)
inew <- add.OBIGT(file)
-expect_true(unique(info(inew)$E_units) == "cal", info = info)
+expect_true(unique(info(inew, check.it = FALSE)$E_units) == "cal", info = info)
info <- "add.OBIGT() gives an error for an incompatible file"
# test added 20191210
More information about the CHNOSZ-commits
mailing list