Skip to content

Commit

Permalink
Rename some files in OBIGT/testing
Browse files Browse the repository at this point in the history
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/chnosz/pkg/CHNOSZ@858 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
  • Loading branch information
jedick committed Dec 25, 2024
1 parent 6e3ca6a commit 6802bba
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 73 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Date: 2024-12-24
Date: 2024-12-25
Package: CHNOSZ
Version: 2.1.0-30
Version: 2.1.0-31
Title: Thermodynamic Calculations and Diagrams for Geochemistry
Authors@R: c(
person("Jeffrey", "Dick", , "[email protected]", role = c("aut", "cre"),
Expand Down
4 changes: 2 additions & 2 deletions R/add.OBIGT.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ add.OBIGT <- function(file, species = NULL, force = TRUE) {
if(!file.exists(file)) {

# List all files in OBIGT and OBIGT/testing
OBIGT_files <- dir(system.file("extdata/OBIGT/", package = "CHNOSZ"), full.names = TRUE)
testing_files <- dir(system.file("extdata/OBIGT/testing", package = "CHNOSZ"), full.names = TRUE)
OBIGT_files <- dir(system.file("extdata/OBIGT", package = "CHNOSZ"), pattern = ".csv", full.names = TRUE)
testing_files <- dir(system.file("extdata/OBIGT/testing", package = "CHNOSZ"), pattern = ".csv", full.names = TRUE)
all_files <- c(OBIGT_files, testing_files)
# Match argument to file names without path or .csv suffix
all_names <- gsub(".csv", "", basename(all_files))
Expand Down
2 changes: 1 addition & 1 deletion R/examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ examples <- function(save.png = FALSE) {
cat("Time elapsed: ", proc.time() - .ptime, "\n")
}

demos <- function(which = c("sources", "protein.equil", "affinity", "NaCl", "density",
demos <- function(which = c("references", "protein.equil", "affinity", "NaCl", "density",
"ORP", "ionize", "buffer", "protbuff", "glycinate",
"mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite", "minsol",
"Shh", "saturation", "adenine", "DEW", "lambda", "potassium", "TCA", "aluminum",
Expand Down
2 changes: 1 addition & 1 deletion R/thermo.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ OBIGT <- function(no.organics = FALSE) {
# Create OBIGT data frame
OBIGT <- do.call(rbind, datalist)
# Also read references file
refs <- read.csv(file.path(OBIGTdir, "refs.csv"), as.is = TRUE)
refs <- read.csv(file.path(OBIGTdir, "../refs.csv"), as.is = TRUE)
# Get thermo from CHNOSZ environment
thermo <- get("thermo", CHNOSZ)
# Set OBIGT and refs
Expand Down
2 changes: 1 addition & 1 deletion demo/00Index
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources Cross-check the reference list with the thermodynamic database
references Cross-check the references in refs.csv with the thermodynamic database
protein.equil Chemical activities of two proteins in metastable equilibrium
affinity Affinities of metabolic reactions and amino acid synthesis
NaCl Equilibrium constant for aqueous NaCl dissociation
Expand Down
8 changes: 4 additions & 4 deletions demo/aluminum.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ basis(delete = TRUE)
# boehmite from Hemingway et al., 1991
r1 <- subcrt(c("boehmite", "H2O", "SiO2", "kaolinite"), c(-1, -0.5, -1, 0.5), T = T, P = 1000, exceed.Ttr = TRUE)
## Second calculation: get SiO2(aq) from Apps and Spycher, 2004
add.OBIGT("AS04")
add.OBIGT("SiO2")
r2 <- subcrt(c("boehmite", "H2O", "SiO2", "kaolinite"), c(-1, -0.5, -1, 0.5), T = T, P = 1000, exceed.Ttr = TRUE)
reset()
## Third calculation: get Si(OH)4 from Akinfiev and Plyasunov, 2014
Expand All @@ -48,7 +48,7 @@ points(seq(125, 350, 25), -c(3.489, 3.217, 2.967, 2.734, 2.517, 2.314, 2.124, 1.
title(main = describe.reaction(r4$reaction), cex.main = 1.1)
legend("bottomright", lty = c(0, 0, 1, 2, 3, 0), pch = c(1, 4, NA, NA, NA, NA), lwd = c(1, 1, 1.5, 1, 1, 0),
col = c("black", "red", "black", "red", "purple", NA), bty = "n", cex = 0.9,
legend = c("Hemley et al., 1980", "SUPCRTBL", "CHNOSZ", 'add.OBIGT("AS04")', 'add.OBIGT("AD")', ""))
legend = c("Hemley et al., 1980", "SUPCRTBL", "CHNOSZ", 'add.OBIGT("SiO2")', 'add.OBIGT("AD")', ""))
legend("bottomright", lty = 4, pch = NA, lwd = 1, col = "blue", legend = 'add.OBIGT("SUPCRT92")', bty = "n", cex = 0.9)
legend("topleft", c("Boehmite - Kaolinite", "After Zhu and Lu, 2009 Fig. A1"), bty = "n")
# Helgeson et al., 1978 (HDNB78): http://www.worldcat.org/oclc/13594862
Expand Down Expand Up @@ -105,7 +105,7 @@ sres <- subcrt(c("kaolinite", "OH-", "H2O", "Al(OH)4-", "SiO2"), c(-1, -2, -1, 2
pK <- -sres$out$logK
lines(invTK, pK, lwd = 1.5)
# Plot line: SiO2 from Apps and Spycher, 2004
add.OBIGT("AS04")
add.OBIGT("SiO2")
sres <- subcrt(c("kaolinite", "OH-", "H2O", "Al(OH)4-", "SiO2"), c(-1, -2, -1, 2, 2), T = T)
pK <- -sres$out$logK
lines(invTK, pK, col = "red", lty = 2)
Expand Down Expand Up @@ -133,7 +133,7 @@ par(xpd = FALSE)
legend("topright", c("Kaolinite solubility", "After Tutolo et al., 2014 Fig. 2"), bty = "n")
legend("bottomleft", lty = c(0, 0, 0, 1, 2, 3, 4), pch = c(1, NA, 4, NA, NA, NA, NA),
lwd = c(1, 1, 1, 1.5, 1, 1, 1), col = c("black", "black", "red", "black", "red", "purple", "blue"),
legend = c("Various sources \u2013", " see Tutolo et al., 2014", "SUPCRTBL", "CHNOSZ", 'add.OBIGT("AS04")', 'add.OBIGT("AD")', 'add.OBIGT("SUPCRT92")'),
legend = c("Various sources \u2013", " see Tutolo et al., 2014", "SUPCRTBL", "CHNOSZ", 'add.OBIGT("SiO2")', 'add.OBIGT("AD")', 'add.OBIGT("SUPCRT92")'),
bty = "n", cex = 0.9)

###########
Expand Down
36 changes: 36 additions & 0 deletions demo/references.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# CHNOSZ/demo/reference.R
## Cross-checking references
library(CHNOSZ)

# The available reference keys
available_refs <- thermo()$refs$key

# The used reference keys
# List all files in OBIGT and OBIGT/testing
OBIGT_files <- dir(system.file("extdata/OBIGT", package = "CHNOSZ"), pattern = ".csv", full.names = TRUE)
testing_files <- dir(system.file("extdata/OBIGT/testing", package = "CHNOSZ"), pattern = ".csv", full.names = TRUE)
all_files <- c(OBIGT_files, testing_files)
all_data <- lapply(all_files, read.csv)
all_data <- do.call(rbind, all_data)
used_refs <- na.omit(c(all_data$ref1, all_data$ref2))

# Print messages for unavailable and unused refs
unavailable_refs <- used_refs[!used_refs %in% available_refs]
unused_refs <- available_refs[!available_refs %in% used_refs]
if(length(unavailable_refs) > 0 | length(unused_refs) > 0) {

if(length(unavailable_refs) > 0) {
print("References used in database but not available in refs.csv:")
print(unique(unavailable_refs))
}

if(length(unused_refs) > 0) {
print("References available in refs.csv but not used in database:")
print(unique(unused_refs))
}

} else {

print("All references accounted for!")

}
40 changes: 0 additions & 40 deletions demo/sources.R

This file was deleted.

8 changes: 4 additions & 4 deletions inst/CHECKLIST
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
****************************
Release checklist for CHNOSZ
(updated 2024-02-11)
(updated 2024-12-25)
****************************

- Run examples() and demos() and inspect their output (especially plots)
Expand All @@ -19,11 +19,11 @@ Updating data in OBIGT
- Add BibTeX references to vignettes/OBIGT.bib
(used in the OBIGT.Rmd vignette).

- Add references and notes to extdata/OBIGT/refs.csv
- Add references and notes to extdata/refs.csv
(also used in the OBIGT.Rmd vignette and thermo.refs()).

- Check output of demo/sources.R to make sure all references
are cited (printed results should be character(0)).
- Check output of demo/references.R to cross-check references in refs.csv with
OBIGT files.

- Rebuild extdata/thermo/stoich.csv.xz after all data updates
(used in retrieve() to search the databse by element):
Expand Down
8 changes: 4 additions & 4 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
have been moved to \file{SLOP98.csv}.

\item Make new directory \file{OBIGT/testing} to hold optional data files
for testing (currently \file{AS04.csv}, \file{GEMSFIT.csv},
\file{IGEM24.csv}, and \file{KBJ24.csv}).
for testing (currently \file{SiO2.csv}, \file{GEMSFIT.csv},
\file{IGEM.csv}, and \file{Sandia.csv}).

\item Add \file{IGEM24.csv}: updated data for Au and Cu complexes and
\item Add \file{IGEM.csv}: updated data for Au and Cu complexes and
SO\s{4}\S{-2}-bearing species from researchers at IGEM RAS.

\item Add \file{KBJ24.csv}: Mg(OH)\s{2}-MgCl\s{2}-H\s{2}O phases from
\item Add \file{Sandia.csv}: Mg(OH)\s{2}-MgCl\s{2}-H\s{2}O phases from
\href{https://doi.org/10.1016/j.apgeochem.2024.106032}{Knight et al.
(2024)}.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion inst/extdata/OBIGT/refs.csv → inst/extdata/refs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,3 @@ RSS+24,"K. Robinson et al.",2024,"Geochim. Cosmochim. Acta 372, 62-80","alkylami
RSS+24.1,"K. Robinson et al.",2024,"Geochim. Cosmochim. Acta 372, 62-80","corrected V for tripropylaminium",https://doi.org/10.1016/j.gca.2024.03.013
TAT+24,"B. R. Tagirov, N. N. Akinfiev et al.",2024,"Geochim. Cosmochim. Acta","Au-(hydro)sulfide species and SO<sub>4</sub><sup>-2</sup>-bearing species",https://doi.org/10.1016/j.gca.2024.08.022
TAZ24,"B. R. Tagirov, N. N. Akinfiev and A. V. Zotov",2024,"Geol. Ore Deposits 66, 581--597","Au hydroxide and chloride complexes",https://doi.org/10.1134/S1075701524600403

6 changes: 3 additions & 3 deletions man/add.OBIGT.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
\name{add.OBIGT}
\alias{add.OBIGT}
\alias{mod.OBIGT}
\title{Functions to work with the thermodynamic database}
\title{Functions to Work with the Thermodynamic Database}
\description{
Add or modify species in the thermodynamic database.
}
Expand Down Expand Up @@ -135,11 +135,11 @@ OBIGT()
# Another use of add.OBIGT(): calculate Delta G of
# H4SiO4 = SiO2 + 2H2O using various sources of data for SiO2.
# First, get H4SiO4 from Stefansson, 2001
add.OBIGT("AS04", "H4SiO4")
add.OBIGT("SiO2", "H4SiO4")
T <- seq(0, 350, 10)
s1 <- subcrt(c("H4SiO4", "SiO2", "H2O"), c(-1, 1, 2), T = T)
# Now, get SiO2 from Apps and Spycher, 2004
add.OBIGT("AS04", "SiO2")
add.OBIGT("SiO2", "SiO2")
s2 <- subcrt(c("H4SiO4", "SiO2", "H2O"), c(-1, 1, 2), T = T)
# Plot logK from the first and second calculations
plot(T, s1$out$G, type = "l", xlab = axis.label("T"),
Expand Down
4 changes: 2 additions & 2 deletions man/examples.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

\usage{
examples(save.png = FALSE)
demos(which = c("sources", "protein.equil", "affinity", "NaCl",
demos(which = c("references", "protein.equil", "affinity", "NaCl",
"density", "ORP", "ionize", "buffer", "protbuff",
"glycinate", "mosaic", "copper", "arsenic", "solubility", "gold",
"contour", "sphalerite", "minsol", "Shh", "saturation",
Expand All @@ -32,7 +32,7 @@
The demo(s) to run is/are specified by \code{which}; the default is to run them in the order of the list below.

\describe{
\item{sources}{Cross-check the reference list with the thermodynamic database}
\item{references}{Cross-check the references in refs.csv with the thermodynamic database}
\item{protein.equil}{Chemical activities of two proteins in metastable equilibrium (Dick and Shock, 2011)}
\item{affinity}{Affinities of metabolic reactions and amino acid synthesis (Amend and Shock, 1998, 2001)}
\item{NaCl}{Equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992)}
Expand Down
9 changes: 5 additions & 4 deletions vignettes/OBIGT.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Except for Optional Data, all data are present in the default database, which is
Each section below corresponds to one of the CSV data files in the `extdata/OBIGT` package directory.
Clicking on a button opens that section, which contains a list of primary references (from column `ref1` in the file) in chronological order.
Any secondary references (`ref2`) are listed with bullet points under the primary reference.
Each citation is followed by the number of species, and a note taken from the file `extdata/OBIGT/refs.csv`.
Each citation is followed by the number of species, and a note taken from the file `extdata/refs.csv`.
Additional comments (from this vignette) are present for some sections.

Abbreviations: T (temperature), P (pressure), GHS (standard Gibbs energy, enthalpy, entropy), Cp (heat capacity), V (volume), HKF (<abbr title="Tanger and Helgeson, 1988">revised</abbr> <abbr title="Helgeson et al., 1981">Helgeson-Kirkham-Flowers</abbr> equations).
Expand Down Expand Up @@ -397,8 +397,9 @@ Most of the comments below were transcribed from the DEW spreadsheet. (Comments
## <a id="optional-Testing" class="anchor"></a> `r setfile("testing")`

These are optional data files used for testing purposes.
Load the data with e.g. `add.OBIGT("GEMSFIT")`.

<h3>AS04</h3>
<h3>SiO2</h3>

Aqueous SiO<sub>2</sub> from @AS04 and HSiO<sub>3</sub><sup>-</sup> modified to be consistent with it.
This file also has H<sub>4</sub>SiO<sub>4</sub> from an earlier publication [@Ste01] that is roughly consistent with the SiO<sub>2</sub> here.
Expand All @@ -408,11 +409,11 @@ See `demo(aluminum)` and the vignette [<span style="color:blue">*Regressing ther

Internally consistent dataset for aqueous species in the system Ca-Mg-Na-K-Al-Si-O-H-C-Cl obtained with the [GEMSFIT](https://doi.org/10.1016/j.apgeochem.2014.10.013) package [@MWKH16;@MWKL17].

<h3>IGEM24</h3>
<h3>IGEM</h3>

Updates for Au and Cu complexes and SO<sub>4</sub><sup>-2</sup>-bearing species from researchers at the Institute of Geology of Ore Deposits, Petrography, Mineralogy, and Geochemistry, Russian Academy of Sciences (IGEM RAS) [@AZ23;@TTA+23;@TAT+24;@TAZ24].

<h3>KBJ24</h3>
<h3>Sandia</h3>

Model for the Mg(OH)<sub>2</sub>-MgCl<sub>2</sub>-H<sub>2</sub>O system at 25 to 150 &deg;C from researchers at Sandia National Laboratories [@KBJ24].

Expand Down
2 changes: 1 addition & 1 deletion vignettes/anintro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ Examples are in [<span style="color:blue">`demo(DEW)`</span>](../demo).

<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].

<span style="color:red">`add.OBIGT("AS04")`</span> -- This file has data for aqueous `r sio2` from @AS04 and modified HSiO<sub>3</sub><sup>-</sup>.
<span style="color:red">`add.OBIGT("SiO2")`</span> -- This file has data for aqueous `r sio2` from @AS04 and modified HSiO<sub>3</sub><sup>-</sup>.
These data reflect a revised (higher) solubility of quartz compared to previous compilations, but are not included in the default database in order to maintain compatibility with existing data for minerals that are linked to the older aqueous `r sio2` data.
See [<span style="color:blue">`demo(aluminum)`</span>](../demo) for an example.

Expand Down
2 changes: 1 addition & 1 deletion vignettes/custom_data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ OPTIONAL but useful:

- `r abbrv` *may be* an abbreviation (e.g. Qtz for quartz). It is used by `r info_` (together with `r name` and `r formula`) to look up species in the database.
- `r date` is a timestamp for the data entry (YYYY-MM-DD format in the default OBIGT database).
- `r ref1` and `r ref2` are bibliographic reference keys. They have matching entries in `extdata/OBIGT/refs.csv`, which is used by `r thermo.refs_` to display references, and in `vignettes/OBIGT.bib`, which is used in the [<span style="color:blue">*OBIGT thermodynamic database*</span>](OBIGT.html) vignette to produce a reference list.
- `r ref1` and `r ref2` are bibliographic reference keys. They have matching entries in `extdata/refs.csv`, which is used by `r thermo.refs_` to display references, and in `vignettes/OBIGT.bib`, which is used in the [<span style="color:blue">*OBIGT thermodynamic database*</span>](OBIGT.html) vignette to produce a reference list.

`r NOTE`: Other functions in CHNOSZ do not depend on `r date`, `r ref1`, and `r ref2`, so you can put anything there that is convenient for you.

Expand Down
4 changes: 2 additions & 2 deletions vignettes/eos-regress.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ EOSplot(NaVdat, coefficients = coefficients, Z = 1, add = TRUE, lty = 2,
Some mineral stability diagrams use the activity of `r h4sio4` as a variable.
However, the primary species for dissolved silica in CHNOSZ is `r sio2`(aq).
As recommended by @WJ17, let us use data for `r sio2`(aq) from @AS04, which gives a higher solubility of quartz compared to values from @SHS89 that are loaded by default in the package:
```{r AS04, message=FALSE}
add.OBIGT("AS04")
```{r add_SiO2, message=FALSE}
add.OBIGT("SiO2")
```

The pseudo-reaction with zero properties, `r h4sio4` = `r sio2` + 2 `r h2o`, defines the properties of the pseudospecies `r h4sio4`.
Expand Down

0 comments on commit 6802bba

Please sign in to comment.