[CHNOSZ-commits] r604 - in pkg/CHNOSZ: . R inst man man/macros

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 26 05:02:05 CEST 2020


Author: jedick
Date: 2020-08-26 05:02:04 +0200 (Wed, 26 Aug 2020)
New Revision: 604

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/retrieve.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/macros/macros.Rd
   pkg/CHNOSZ/man/retrieve.Rd
Log:
Add T and P arguments to retrieve()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-08-21 08:00:20 UTC (rev 603)
+++ pkg/CHNOSZ/DESCRIPTION	2020-08-26 03:02:04 UTC (rev 604)
@@ -1,6 +1,6 @@
-Date: 2020-08-21
+Date: 2020-08-26
 Package: CHNOSZ
-Version: 1.3.6-77
+Version: 1.3.6-78
 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/retrieve.R
===================================================================
--- pkg/CHNOSZ/R/retrieve.R	2020-08-21 08:00:20 UTC (rev 603)
+++ pkg/CHNOSZ/R/retrieve.R	2020-08-26 03:02:04 UTC (rev 604)
@@ -6,7 +6,7 @@
 # 20190305 use c() for combination of elements, list() for chemical system,
 #          and add 'ligands' argument to retrieve element-bearing species
 
-retrieve <- function(elements = NULL, ligands = NULL, state = NULL, add.charge = TRUE, hide.groups = TRUE) {
+retrieve <- function(elements = NULL, ligands = NULL, state = NULL, T = NULL, P = "Psat", add.charge = TRUE, hide.groups = TRUE) {
   ## empty argument handling
   if(is.null(elements)) return(integer())
 
@@ -115,6 +115,12 @@
     ispecies <- ispecies[istate]
   }
 
+  # require non-NA Delta G0 at specific temperature 20200825
+  if(!is.null(T)) {
+    G <- sapply(suppressMessages(subcrt(ispecies, T = T, P = P))$out, "[[", "G")
+    ispecies <- ispecies[!is.na(G)]
+  }
+
   # assign names; use e- instead of (Z-1)
   names(ispecies) <- thermo()$OBIGT$formula[ispecies]
   names(ispecies)[names(ispecies)=="(Z-1)"] <- "e-"

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-08-21 08:00:20 UTC (rev 603)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-08-26 03:02:04 UTC (rev 604)
@@ -9,7 +9,7 @@
 \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.3.6-76 (2020-08-21)}{
+\section{Changes in CHNOSZ version 1.3.6-78 (2020-08-26)}{
 
   \subsection{MAJOR CHANGES}{
     \itemize{
@@ -223,6 +223,10 @@
       \item Add "QCa" as a keyword for preset species in basis() (glutamine,
         cysteine, acetic acid, \H2O, O\s{2}).
 
+      \item Add \strong{T} and \strong{P} arguments to \code{retrieve()} to
+      require that species have non-NA values of standard Gibbs energy at this
+      temperature and pressure.
+
       \item Convert this NEWS file to Rd format.
 
     }

Modified: pkg/CHNOSZ/man/macros/macros.Rd
===================================================================
--- pkg/CHNOSZ/man/macros/macros.Rd	2020-08-21 08:00:20 UTC (rev 603)
+++ pkg/CHNOSZ/man/macros/macros.Rd	2020-08-26 03:02:04 UTC (rev 604)
@@ -25,6 +25,7 @@
 % other common variables
 \newcommand{\T}{\ifelse{latex}{\eqn{T}}{\ifelse{html}{\out{<I>T</I>}}{T}}}
 \newcommand{\P}{\ifelse{latex}{\eqn{P}}{\ifelse{html}{\out{<I>P</I>}}{P}}}
+\newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{Δ<I>G</I>°}}{ΔG°}}}
 % italicize any letter
 \newcommand{\I}{\ifelse{latex}{\eqn{#1}}{\ifelse{html}{\out{<I>#1</I>}}{#1}}}
 \newcommand{\logK}{\ifelse{latex}{\out{log\,\emph{K}}}{\ifelse{html}{\out{log <i>K</i>}}{log K}}}

Modified: pkg/CHNOSZ/man/retrieve.Rd
===================================================================
--- pkg/CHNOSZ/man/retrieve.Rd	2020-08-21 08:00:20 UTC (rev 603)
+++ pkg/CHNOSZ/man/retrieve.Rd	2020-08-26 03:02:04 UTC (rev 604)
@@ -8,7 +8,7 @@
 
 \usage{
   retrieve(elements = NULL, ligands = NULL, state = NULL,
-    add.charge = TRUE, hide.groups = TRUE)
+    T = NULL, P = "Psat", add.charge = TRUE, hide.groups = TRUE)
 }
 
 \arguments{
@@ -15,6 +15,8 @@
   \item{elements}{character, combination of elements, or list, elements in a chemical system}
   \item{ligands}{character, elements present in any ligands}
   \item{state}{character, filter the result on these state(s).}
+  \item{T}{numeric, temperature where \DG0 of species must be not NA}
+  \item{P}{numeric, pressure where \DG0 of species must be not NA}
   \item{add.charge}{logical, add charge to the system?}
   \item{hide.groups}{logical, exclude groups from the result?}
 }
@@ -34,6 +36,9 @@
 If the electron is in the result, its name (\samp{e-}) is used instead of its chemical formula (\samp{(Z-1)}).
 An empty (length 0) integer value is returned if no \code{elements} are specified or no species are retrieved.
 
+Set \code{T} (and optionally \code{P}) to require that species have non-NA values of \DG0 at this temperature and pressure.
+These values are passed to \code{\link{subcrt}} and therefore have the units set in \code{\link{T.units}} and \code{\link{P.units}}.
+
 To speed up operation, the function uses a precalculated stoichiometric matrix for the default database, which is loaded with the package (see \code{\link{thermo}}).
 If the function detects a change to any chemical formulas in the database, it updates the stoichiometric matrix using \code{\link{i2A}}.
 }



More information about the CHNOSZ-commits mailing list