[CHNOSZ-commits] r702 - in pkg/CHNOSZ: . R inst inst/tinytest vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 8 10:17:20 CET 2022
Author: jedick
Date: 2022-02-08 10:17:20 +0100 (Tue, 08 Feb 2022)
New Revision: 702
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/info.R
pkg/CHNOSZ/R/util.data.R
pkg/CHNOSZ/inst/CHECKLIST
pkg/CHNOSZ/inst/NEWS.Rd
pkg/CHNOSZ/inst/TODO
pkg/CHNOSZ/inst/tinytest/test-info.R
pkg/CHNOSZ/vignettes/anintro.Rmd
Log:
Include Cp in properties of Berman minerals returned by info()
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/DESCRIPTION 2022-02-08 09:17:20 UTC (rev 702)
@@ -1,6 +1,6 @@
-Date: 2022-02-07
+Date: 2022-02-08
Package: CHNOSZ
-Version: 1.4.1-27
+Version: 1.4.1-28
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/info.R
===================================================================
--- pkg/CHNOSZ/R/info.R 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/R/info.R 2022-02-08 09:17:20 UTC (rev 702)
@@ -6,7 +6,7 @@
# these functions expect arguments of length 1;
# info() handles longer arguments
-## if this file is interactively sourced, the following are also needed to provide unexported functions:
+## If this file is interactively sourced, the following are also needed to provide unexported functions:
#source("util.data.R")
info <- function(species=NULL, state=NULL, check.it=TRUE) {
@@ -200,7 +200,8 @@
Bermandat <- Berman()
Bermandat <- Bermandat[Bermandat$name == this$name, ]
this[, c("G", "H", "S", "V")] <- Bermandat[, c("GfPrTr", "HfPrTr", "SPrTr", "VPrTr")] * c(1, 1, 1, 10)
- }
+ isBerman <- TRUE
+ } else isBerman <- FALSE
# Identify any missing GHS values
naGHS <- is.na(this[9:11])
@@ -216,14 +217,19 @@
# Perform consistency checks for GHS and EOS parameters if check.it = TRUE
# Don't do it for the AD species 20190219
if(check.it & !"xi" %in% colnames(this)) {
- # check GHS if they are all present
+ # Check GHS if they are all present
if(sum(naGHS)==0) calcG <- checkGHS(this)
- # check tabulated heat capacities against EOS parameters
+ # Check tabulated heat capacities against EOS parameters
calcCp <- checkEOS(this, this$state, "Cp")
# fill in NA heat capacity
if(!is.na(calcCp) & is.na(this$Cp)) {
message("info.numeric: Cp of ", this$name, "(", this$state, ") is NA; set by EOS parameters to ", round(calcCp, 2), " ", this$E_units, " K-1 mol-1")
this$Cp <- as.numeric(calcCp)
+ } else if(isBerman) {
+ # Calculate Cp for Berman minerals 20220208
+ calcCp <- Berman(this$name)$Cp
+ if(this$E_units == "J") calcCp <- convert(calcCp, "J")
+ this$Cp <- calcCp
}
# check tabulated volumes - only for aq (HKF equation)
if(identical(this$state, "aq")) {
Modified: pkg/CHNOSZ/R/util.data.R
===================================================================
--- pkg/CHNOSZ/R/util.data.R 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/R/util.data.R 2022-02-08 09:17:20 UTC (rev 702)
@@ -160,11 +160,9 @@
}
checkEOS <- function(eos, state, prop, ret.diff=FALSE) {
- # compare calculated properties from equation-of-state
- # parameters with reference (tabulated) values
- # print message and return the calculated value
- # if tolerance is exceeded
- # or NA if the difference is within the tolerance
+ # Compare calculated properties from equation-of-state parameters with reference (tabulated) values.
+ # Print message and return the calculated value if tolerance is exceeded
+ # or NA if the difference is within the tolerance.
# 20110808 jmd
thermo <- get("thermo", CHNOSZ)
# get calculated value based on EOS
@@ -171,8 +169,8 @@
Theta <- 228 # K
if(identical(state, "aq")) {
if(prop=="Cp") {
- # value of X consistent with IAPWS95
- X <- -2.773788E-7
+ ## value of X consistent with IAPWS95
+ #X <- -2.773788E-7
# we use the value of X consistent with SUPCRT
X <- -3.055586E-7
refval <- eos$Cp
@@ -180,8 +178,8 @@
tol <- thermo$opt$Cp.tol
units <- paste(eos$E_units, "K-1 mol-1")
} else if(prop=="V") {
- # value of Q consistent with IAPWS95
- Q <- 0.00002483137
+ ## value of Q consistent with IAPWS95
+ #Q <- 0.00002483137
# value of Q consistent with SUPCRT92
Q <- 0.00002775729
refval <- eos$V
Modified: pkg/CHNOSZ/inst/CHECKLIST
===================================================================
--- pkg/CHNOSZ/inst/CHECKLIST 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/inst/CHECKLIST 2022-02-08 09:17:20 UTC (rev 702)
@@ -1,16 +1,16 @@
****************************
Release checklist for CHNOSZ
- (updated 2020-11-10)
+ (updated 2022-02-08)
****************************
- Run examples() and demos() and inspect their output (especially plots)
-- Run the package test with:
+- Run the package tests with:
suppressMessages(tinytest::test_package("CHNOSZ", at_home = TRUE))
- Check that uniprot.aa() works with current UniProt web pages
-- Check reverse dependencies on CRAN: canprot, ecipex, iemisc as of 2019-08-02
+- Check reverse dependencies on CRAN: canprot, accucor, ecipex, iemisc, LipidMS as of 2019-08-02
**********************
Updating data in OBIGT
@@ -18,7 +18,7 @@
- Add data to relevant csv file in extdata/OBIGT.
-- Add bibtex references to vignettes/OBIGT.bib
+- Add BibTeX references to vignettes/OBIGT.bib
(used in the OBIGT.Rmd vignette).
- Add references *and notes* to extdata/OBIGT/refs.csv
@@ -46,7 +46,7 @@
- Customize rmarkdown installation (in R local library)
- - to enable page offset from anchor position in OBIGT.Rmd:
+ - To enable page offset from anchor position in OBIGT.Rmd:
remove padding-top: 10px; from h2 in
rmarkdown/templates/html_vignette/resources/vignette.css
Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/inst/NEWS.Rd 2022-02-08 09:17:20 UTC (rev 702)
@@ -10,18 +10,17 @@
\newcommand{\s}{\ifelse{latex}{\eqn{_{#1}}}{\ifelse{html}{\out{<sub>#1</sub>}}{#1}}}
\newcommand{\S}{\ifelse{latex}{\eqn{^{#1}}}{\ifelse{html}{\out{<sup>#1</sup>}}{^#1}}}
-\section{Changes in CHNOSZ version 1.4.1-26 (2022-02-07)}{
+\section{Changes in CHNOSZ version 1.4.1-28 (2022-02-08)}{
\subsection{PLANNED API CHANGE}{
\itemize{
- \item It is expected that in the next major release of CHNOSZ (to be
- version 2.0.0), units of Joules instead of calories will be used by
- default for the thermodynamic properties output by \code{subcrt()}. That
- is, \code{E.units("J")} will be the default setting. User scripts that
- implicitly depend on the current default units setting of
- \code{E.units("cal")} will need to be modified to produce expected output
- after this change is made.
+ \item In the next major release of CHNOSZ (to be version 2.0.0), units of
+ Joules instead of calories will be used by default for the thermodynamic
+ properties output by \code{subcrt()}. That is, \code{E.units("J")} will
+ be the default setting. User scripts that implicitly depend on the
+ current default setting of \code{E.units("cal")} will need to be modified
+ to produce expected output after this change is made.
}
}
@@ -38,8 +37,8 @@
\item For minerals with thermodynamic parameters in the equations of
\href{https://doi.org/10.1093/petrology/29.2.445}{Berman (1988)},
\code{info()} with a numeric argument now lists values of \code{G},
- \code{H}, \code{S}, and \code{V} at 25 \degC and 1 bar (these were
- previously shown as \code{NA}). Thanks to Evgeniy Bastrakov for
+ \code{H}, \code{S}, \code{Cp}, and \code{V} at 25 \degC and 1 bar (these
+ were previously shown as \code{NA}). Thanks to Evgeniy Bastrakov for
suggesting both of these changes.
}
@@ -75,7 +74,7 @@
\item The \code{AkDi()} function has been renamed to \code{AD()}, and all
variables and data files likewise use the acronym \acronym{AD}. In
particular, the Akinfiev-Diamond model is activated for an aqueous
- species by setting \code{abbrv = "AD"} in \code{thermo()$OBIGT}.
+ species by using \code{abbrv = "AD"} in \code{thermo()$OBIGT}.
\item Names of functions, variables, and data files now use capitalized
\samp{Berman}, not \samp{berman}.
Modified: pkg/CHNOSZ/inst/TODO
===================================================================
--- pkg/CHNOSZ/inst/TODO 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/inst/TODO 2022-02-08 09:17:20 UTC (rev 702)
@@ -1,30 +1,30 @@
-[ - 20201110]
+[to 20201110]
-- make a site for community uploaded data
+- Make a site for community uploaded data
-- make separate directories for default and optional data files
+- Use separate directories for default and optional data files
-- diagram(): make error or warning for NA values of affinity
+- diagram(): produce error or warning for NA values of affinity
-- move protein.equil() example (previously in equilibrium.Rnw) to JMDplots.
+- Move protein.equil() example (previously in equilibrium.Rnw) to JMDplots.
-- add elements from Robie and Hemingway (1995).
+- Add elements from Robie and Hemingway (1995).
-- add check to mosaic() that 'stable' values have the right dimensions.
+- Add check to mosaic() that 'stable' values have the right dimensions.
-- move H2O92D.f and R wrapper to a separate package (so people
+- Move H2O92D.f and R wrapper to a separate package (so people
don't have to compile anything to install CHNOSZ updates).
-- add empty diagram -> exceed.Ttr hint to anintro.Rmd.
+- Add hint to anintro.Rmd to try exceed.Ttr = TRUE if there is a blank diagram.
-- replace CoCl2-4 example in anintro.Rmd with different species
-(CoCl2-4 has been added to OBIGT).
+- Replace CoCl4-2 example in anintro.Rmd with different species
+(CoCl4-2 has been added to OBIGT).
[20201113 - ]
-- add a demo to show user-added data with Berman equations
+- Add a demo to show user-added data with Berman equations
-- make swap.basis() work when DEW model is active
+- Make swap.basis() work when DEW model is active
[20210303]
Modified: pkg/CHNOSZ/inst/tinytest/test-info.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-info.R 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/inst/tinytest/test-info.R 2022-02-08 09:17:20 UTC (rev 702)
@@ -38,3 +38,14 @@
expect_equal(params$a, -8.8321, info = info)
expect_equal(params$b, 11.2684, info = info)
expect_equal(params$xi, -0.0850, info = info)
+
+# 20220208
+info <- "info() and subcrt() report consistent values for thermodynamic properties of Berman minerals"
+E.units("J")
+sout <- subcrt("K-feldspar", T = 25)$out[[1]]
+iout <- info(info("K-feldspar"))
+expect_equal(sout$G, iout$G, tolerance = 13, scale = 1)
+expect_equal(sout$H, iout$H)
+expect_equal(sout$S, iout$S, tolerance = 0.00009, scale = 1)
+expect_equal(sout$Cp, iout$Cp)
+expect_equal(sout$V, iout$V)
Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd 2022-02-07 09:27:29 UTC (rev 701)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd 2022-02-08 09:17:20 UTC (rev 702)
@@ -1352,6 +1352,19 @@
This example brings some other functions we haven't seen yet: <span style="color:green">`unitize()`</span> and <span style="color:green">`revisit()`</span>.
Here, we list the names and relative abundances of proteins taken from the YeastGFP study of @GHB_03.
There are six proteins identified in the ER-to-Golgi location; one has NA abundance, so it is excluded from the comparisons:
+
+```{marginfigure}
+This can be done programmatically using data from the YeastGFP study that are in the [JMDplots](https://github.com/jedick/JMDplots) package:
+<br>
+`y <- JMDplots::yeastgfp("ER.to.Golgi")`
+<br>
+`ina <- is.na(y[["abundance"]])`
+<br>
+`aa <- JMDplots::yeast.aa(y$protein[!ina])`
+<br>
+`ip <- add.protein(aa)`
+```
+
```{r yeastgfp}
protein <- c("YDL195W", "YHR098C", "YIL109C", "YLR208W", "YNL049C", "YPL085W")
abundance <- c(1840, 12200, NA, 21400, 1720, 358)
@@ -1363,14 +1376,6 @@
ip <- match(protein[!ina], thermo()$protein$protein)
```
-NOTE: It is more convenient to do this with functions and data that have been moved to the [JMDplots](https://github.com/jedick/JMDplots) package:
-```{r JMDplots, eval = FALSE}
-y <- JMDplots::yeastgfp("ER.to.Golgi")
-ina <- is.na(y$abundance)
-aa <- JMDplots::yeast.aa(y$protein[!ina])
-ip <- add.protein(aa)
-```
-
The YeastGFP study reported absolute abundances of molecules, but the thermodynamic calculations give relative chemical activities of the proteins.
In order to make a comparison between them, we use <span style="color:green">`unitize()`</span> to scale the abundances or activities of proteins (in logarithmic units) such that the total abundance or activity of residue equivalents is unity.
To do that, we must have the lengths of the proteins.
@@ -1593,7 +1598,7 @@
You should also run <span style="color:red">`water("DEW")`</span> to activate the equations in the model; then, they will be used by <span style="color:green">`subcrt()`</span> and <span style="color:green">`affinity()`</span>.
Examples are in [<span style="color:blue">`demo(DEW)`</span>](../demo).
-<span style="color:red">`add.OBIGT("GEMSFIT")`</span> -- This is a set of internally-conistent thermodynamic data for aqueous species in the system Ca-Mg-Na-K-Al-Si-O-H-C-Cl compiled using the GEMSFIT package [@MWKL17].
+<span style="color:red">`add.OBIGT("GEMSFIT")`</span> -- Thermodynamic data for aqueous species in the system Ca-Mg-Na-K-Al-Si-O-H-C-Cl obtained from global optimization of Gibbs energies with the GEMSFIT package [@MWKL17].
## Adding data
More information about the CHNOSZ-commits
mailing list