[CHNOSZ-commits] r377 - in pkg/CHNOSZ: . R inst man tests/testthat vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 1 02:45:02 CET 2019


Author: jedick
Date: 2019-02-01 02:45:00 +0100 (Fri, 01 Feb 2019)
New Revision: 377

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/affinity.R
   pkg/CHNOSZ/R/util.affinity.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/affinity.Rd
   pkg/CHNOSZ/tests/testthat/test-affinity.R
   pkg/CHNOSZ/vignettes/obigt.Rmd
   pkg/CHNOSZ/vignettes/obigt.bib
Log:
affinity(): add 'return.sout' argument


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/DESCRIPTION	2019-02-01 01:45:00 UTC (rev 377)
@@ -1,6 +1,6 @@
-Date: 2019-01-28
+Date: 2019-02-01
 Package: CHNOSZ
-Version: 1.1.3-84
+Version: 1.1.3-85
 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/affinity.R
===================================================================
--- pkg/CHNOSZ/R/affinity.R	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/R/affinity.R	2019-02-01 01:45:00 UTC (rev 377)
@@ -13,7 +13,7 @@
 #source("species.R")
 
 affinity <- function(..., property=NULL, sout=NULL, exceed.Ttr=FALSE, exceed.rhomin=FALSE,
-  return.buffer=FALSE, balance="PBB", iprotein=NULL, loga.protein=-3) {
+  return.buffer=FALSE, return.sout=FALSE, balance="PBB", iprotein=NULL, loga.protein=-3) {
   # ...: variables over which to calculate
   # property: what type of energy
   #   (G.basis,G.species,logact.basis,logK,logQ,A)
@@ -111,6 +111,8 @@
     a <- aa$a
     sout <- aa$sout
 
+    if(return.sout) return(sout)
+
     # more buffer stuff
     if(buffer) {
       args$what <- "logact.basis"

Modified: pkg/CHNOSZ/R/util.affinity.R
===================================================================
--- pkg/CHNOSZ/R/util.affinity.R	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/R/util.affinity.R	2019-02-01 01:45:00 UTC (rev 377)
@@ -133,9 +133,16 @@
 
   ### function for calling subcrt
   sout.fun <- function(property="logK") {
-    if(!is.null(sout)) return(sout) else {
+    species <- c(mybasis$ispecies,myspecies$ispecies)
+    if(!is.null(sout)) {
+      # extract the needed species from a provided sout 20190131
+      isout <- match(species, sout$species$ispecies)
+      this.sout <- sout
+      this.sout$species <- this.sout$species[isout, ]
+      this.sout$out <- this.sout$out[isout]
+      return(this.sout) 
+    } else {
       ## subcrt arguments
-      species <- c(mybasis$ispecies,myspecies$ispecies)
       if("T" %in% vars) T <- vals[[which(vars=="T")]]
       if("P" %in% vars) P <- vals[[which(vars=="P")]]
       if("IS" %in% vars) IS <- vals[[which(vars=="IS")]]

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/inst/NEWS	2019-02-01 01:45:00 UTC (rev 377)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.3-84 (2019-01-28)
+CHANGES IN CHNOSZ 1.1.3-85 (2019-02-01)
 ---------------------------------------
 
 BUG FIXES
@@ -240,6 +240,9 @@
 
 - In affinity(), make invalid variable names an error.
 
+- Add 'return.sout' argument to affinity(), to return just the values
+  calculated with subcrt().
+
 CHANGES IN CHNOSZ 1.1.3 (2017-11-13)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/affinity.Rd
===================================================================
--- pkg/CHNOSZ/man/affinity.Rd	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/man/affinity.Rd	2019-02-01 01:45:00 UTC (rev 377)
@@ -8,7 +8,7 @@
 
 \usage{
   affinity(..., property=NULL, sout=NULL, exceed.Ttr=FALSE, exceed.rhomin = FALSE,
-    return.buffer=FALSE, balance="PBB", iprotein=NULL, loga.protein=-3)
+    return.buffer=FALSE, return.sout=FALSE, balance="PBB", iprotein=NULL, loga.protein=-3)
 }
 
 \arguments{
@@ -18,6 +18,7 @@
   \item{exceed.Ttr}{logical, allow \code{\link{subcrt}} to compute properties for phases beyond their transition temperature?}
   \item{exceed.rhomin}{logical, allow \code{\link{subcrt}} to compute properties of species in the HKF model below 0.35 g cm\S{-3}?}
   \item{return.buffer}{logical. If \code{TRUE}, and a \code{\link{buffer}} has been associated with one or more basis species in the system, return the values of the activities of the basis species calculated using the buffer. Default is \code{FALSE}.}
+  \item{return.sout}{logical, return only the values calculated with \code{\link{subcrt}}?}
   \item{balance}{character. This argument is used to identify a conserved basis species (or \samp{PBB}) in a chemical activity buffer. Default is \samp{PBB}.}
   \item{iprotein}{numeric, indices of proteins in \code{\link{thermo}$protein} for which to calculate properties}
   \item{loga.protein}{numeric, logarithms of activities of proteins identified in \code{iprotein}}

Modified: pkg/CHNOSZ/tests/testthat/test-affinity.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-affinity.R	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/tests/testthat/test-affinity.R	2019-02-01 01:45:00 UTC (rev 377)
@@ -174,6 +174,7 @@
 })
 
 test_that("argument recall is usable", {
+  # 20190127
   basis("CHNOS")
   species(c("CO2", "CH4"))
   a0 <- affinity(O2=c(-80, -60))
@@ -184,3 +185,18 @@
   # we don't test entire output here becuase a0 doesn't have a "T" argument
   expect_identical(a0$values, a3$values)
 })
+
+test_that("sout is processed correctly", {
+  # 20190201
+  basis("CHNOS+")
+  # previously, this test would fail when sout has
+  # more species than are used in the calculation
+  species(c("H2S", "CO2", "CH4"))
+  a0 <- affinity(T = c(0, 100))
+  sout <- a0$sout
+  # test the calculation with just CH4
+  species(1:2, delete = TRUE)
+  a1 <- affinity(T = c(0, 100))
+  a2 <- affinity(T = c(0, 100), sout = a0$sout)
+  expect_equal(a1$values, a2$values)
+})

Modified: pkg/CHNOSZ/vignettes/obigt.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/obigt.Rmd	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/vignettes/obigt.Rmd	2019-02-01 01:45:00 UTC (rev 377)
@@ -119,7 +119,7 @@
 
 * Data from SUPCRT92 which have been superseded by the Berman data are listed under **Optional Data** / **SUPCRT92**.
 
-* Superseded data from SLOP98 (aqueous Au species) are listed under **Optional Data** / **SLOP98**.
+* Superseded data from SLOP98 (aqueous SiO<sub>2</sub> and Al, As, and Au species) are listed under **Optional Data** / **SLOP98**.
 
 # Sources of data {.tabset .tabset-fade}
 
@@ -227,7 +227,7 @@
 
 ### `r setfile("SLOP98.csv")`
 ```{r SLOP98, results="asis", echo=FALSE}
-cat('These species, taken from the slop98 data file, were present in earlier versions of CHNOSZ but have been replaced by or are inconsistent with later updates. The data are kept here for comparative purposes. Use e.g. <span style="color:red">`add.obigt("SLOP98")`</span> to load the data.\n\n')
+cat('These species, taken from the slop98 data file, were present in earlier versions of CHNOSZ but have been replaced by or are inconsistent with later updates. The data are kept here for comparative purposes. Use <span style="color:red">`add.obigt("SLOP98")`</span> to load the data.\n\n')
 ```
 
 ```{r optreflist, results="asis", echo=FALSE}
@@ -235,7 +235,7 @@
 
 ### `r setfile("SUPCRT92.csv")`
 ```{r SUPCRT92, results="asis", echo=FALSE}
-cat("These minerals, taken from the SUPCRT92 database, were used by default in earlier versions of CHNOSZ but have since been superseded by the Berman dataset. They are kept as optional data for testing and comparison purposes. The minerals here include all of the silicates and Al-bearing minerals from [Helgeson et al., 1978](http://www.worldcat.org/oclc/13594862), as well as calcite, dolomite, hematite, and magnetite. Note that other minerals from SUPCRT92 (including native elements, sulfides, halides, sulfates, and selected carbonates and oxides that do not duplicate those in the Berman dataset) are still present in the default database (**inorganic_cr.csv**).\n\n")
+cat('These minerals, taken from the SUPCRT92 database, were present in earlier versions of CHNOSZ but have since been superseded by the Berman dataset. They are kept as optional data for testing and comparison purposes. The minerals here include all of the silicates and Al-bearing minerals from [Helgeson et al., 1978](http://www.worldcat.org/oclc/13594862), as well as calcite, dolomite, hematite, and magnetite. Use <span style="color:red">`add.obigt("SUPCRT92")`</span> to load the data. Note that other minerals from SUPCRT92, including native elements, sulfides, halides, sulfates, and selected carbonates and oxides that do not duplicate those in the Berman dataset, are still present in the default database (**inorganic_cr.csv**).\n\n')
 ```
 
 ```{r optreflist, results="asis", echo=FALSE}

Modified: pkg/CHNOSZ/vignettes/obigt.bib
===================================================================
--- pkg/CHNOSZ/vignettes/obigt.bib	2019-01-28 08:53:03 UTC (rev 376)
+++ pkg/CHNOSZ/vignettes/obigt.bib	2019-02-01 01:45:00 UTC (rev 377)
@@ -1177,16 +1177,16 @@
 }
 
 @Article{HP11,
-  author        = {Holland, T. J. B. and Powell, R.},
-  journal       = {Journal of Metamorphic Geology},
-  title         = {{A}n improved and extended internally consistent thermodynamic dataset for phases of petrological interest, involving a new equation of state for solids},
-  year          = {2011},
-  volume        = {29},
-  number        = {3},
-  pages         = {333--383},
-  doi           = {10.1111/j.1525-1314.2010.00923.x},
-  sn            = {0263-4929},
-  z9            = {2},
+  author    = {Holland, T. J. B. and Powell, R.},
+  journal   = {Journal of Metamorphic Geology},
+  title     = {{A}n improved and extended internally consistent thermodynamic dataset for phases of petrological interest, involving a new equation of state for solids},
+  year      = {2011},
+  volume    = {29},
+  number    = {3},
+  pages     = {333--383},
+  doi       = {10.1111/j.1525-1314.2010.00923.x},
+  sn        = {0263-4929},
+  z9        = {2},
 }
 
 @Article{HRA91,
@@ -1260,13 +1260,12 @@
   pages     = {9--70},
   doi       = {10.1144/SP402.4},
   issn      = {0305-8719},
-  publisher = {Geological Society of London},
 }
 
 @Article{WS00,
   author    = {Wood, Scott A. and Samson, Iain M.},
   journal   = {Economic Geology},
-  title     = {{T}he hydrothermal geochemistry of tungsten in granitoid environments: {I}. {R}elative solubilities of ferberite and scheelite as a function of {T}, {P}, p{H}, and m{N}a{C}l},
+  title     = {{T}he hydrothermal geochemistry of tungsten in granitoid environments: {I}. {R}elative solubilities of ferberite and scheelite as a function of {T}, {P}, p{H}, and $m_\text{NaCl}$},
   year      = {2000},
   volume    = {95},
   number    = {1},



More information about the CHNOSZ-commits mailing list