[CHNOSZ-commits] r441 - in pkg/CHNOSZ: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 15 06:26:30 CEST 2019
Author: jedick
Date: 2019-04-15 06:26:29 +0200 (Mon, 15 Apr 2019)
New Revision: 441
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/affinity.R
pkg/CHNOSZ/R/eqdata.R
pkg/CHNOSZ/inst/NEWS
pkg/CHNOSZ/man/eqdata.Rd
Log:
eqdata(): add partial support for EQ3/6 version 8.0a
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2019-04-15 03:05:20 UTC (rev 440)
+++ pkg/CHNOSZ/DESCRIPTION 2019-04-15 04:26:29 UTC (rev 441)
@@ -1,6 +1,6 @@
Date: 2019-04-15
Package: CHNOSZ
-Version: 1.3.1-21
+Version: 1.3.1-22
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-04-15 03:05:20 UTC (rev 440)
+++ pkg/CHNOSZ/R/affinity.R 2019-04-15 04:26:29 UTC (rev 441)
@@ -259,6 +259,8 @@
vars[[iH]] <- "pH"
vals[[iH]] <- -args$vals[[iH]]
}
+ # use the variable names for the vals list 20190415
+ names(vals) <- vars
# content of return value depends on buffer request
if(return.buffer) return(c(tb, list(vars=vars, vals=vals)))
Modified: pkg/CHNOSZ/R/eqdata.R
===================================================================
--- pkg/CHNOSZ/R/eqdata.R 2019-04-15 03:05:20 UTC (rev 440)
+++ pkg/CHNOSZ/R/eqdata.R 2019-04-15 04:26:29 UTC (rev 441)
@@ -5,18 +5,65 @@
# 20110516 use grand summary of solid phases, handle data blocks
# with blank rows, add progress messages, get activity of water
# 20110805 add mineral saturation states and speciation summaries
+# 20190415 add detection of version 7 or 8
eqdata <- function(file, species, property="log act", outfile=TRUE) {
- # the available properties for different types of data:
- # solid phases, aqueous species, mineral saturation states, speciation summary
- props <- list(
- solid = c("product", "log moles", "moles", "grams", "volume, cc"),
- aqueous = c("species", "moles", "grams", "conc", "log conc", "log g", "log act"),
- mineral = c("affinity, kcal"),
- speciation = c("molal conc", "per cent")
- )
+ # first read the entire file
+ lines <- readLines(file)
+ cat(paste("eqdata: read", length(lines), "lines from", file, "\n"))
+ # detect version 7 or 8
+ # grep for "ersion" to match "version" or "Version"
+ vline <- lines[grep("ersion", lines)[1]]
+ version <- strsplit(vline, "ersion ")[[1]][2]
+ v <- substr(version, 1, 1)
+ if(!v %in% c("7", "8")) stop("EQ3/6 version", version, "is unsupported")
+ if(v=="7") {
+ # the available properties for different types of data:
+ # solid phases, aqueous species, mineral saturation states, speciation summary
+ props <- list(
+ solid = c("product", "log moles", "moles", "grams", "volume, cc"),
+ aqueous = c("species", "moles", "grams", "conc", "log conc", "log g", "log act"),
+ mineral = c("affinity, kcal"),
+ speciation = c("molal conc", "per cent")
+ )
+ # header lines that begin the result block for this data type
+ headers <- list(
+ # summary of solid product phases
+ #solid = " product log moles moles",
+ # grand summary of solid phases
+ solid = " phase/end-member log moles moles",
+ aqueous = " species moles grams",
+ mineral = " mineral affinity, kcal state",
+ speciation = paste("aqueous species accounting for 99% or more of",species)
+ )
+ # lines that let us know the data block has ended
+ enders <- list(
+ solid = "--- mineral saturation state summary ---",
+ aqueous = "--- major aqueous species contributing to mass balances ---",
+ mineral = "--- summary of gas species ---",
+ speciation = "- - - - - - - - - - - - - - - - - - - - - - -"
+ )
+ }
+
+ # This code does not completely support version 8.
+ # TODO: add headers for solid, mineral, and speciation blocks
+ # FIXME: getziT() does not work
+ if(v=="8") {
+ props <- list(
+ aqueous = c("Species", "Molality", "Log Molality", "Log Gamma", "Log Activity")
+ )
+ headers <- list(
+ aqueous = " Species Molality"
+ )
+ enders <- list(
+ aqueous = "Species with molalities less than"
+ )
+ # change the default property="log act" to "Log Activity"
+ if(property=="log act") property <- "Log Activity"
+ }
+
## process the 'property' argument to
## figure out the data type for the requested property
# match property to each list element of props
@@ -38,24 +85,7 @@
if(length(species) > 1)
stop("speciation data can only be had for a single basis species")
}
- # header lines that begin the result block for this data type
- headers <- list(
- # summary of solid product phases
- #solid = " product log moles moles",
- # grand summary of solid phases
- solid = " phase/end-member log moles moles",
- aqueous = " species moles grams",
- mineral = " mineral affinity, kcal state",
- speciation = paste("aqueous species accounting for 99% or more of",species)
- )
header <- headers[[itype]]
- # lines that let us know the data block has ended
- enders <- list(
- solid = "--- mineral saturation state summary ---",
- aqueous = "--- major aqueous species contributing to mass balances ---",
- mineral = "--- summary of gas species ---",
- speciation = "- - - - - - - - - - - - - - - - - - - - - - -"
- )
ender <- enders[[itype]]
## done processing 'property' argument
@@ -151,9 +181,6 @@
}
# put it all together
- # first read the entire file
- lines <- readLines(file)
- cat(paste("eqdata: read", length(lines), "lines from", file, "\n"))
# get the line numbers where the data blocks start
# without fixed=TRUE this fails for e.g. zn+2 !!
ihead <- grep(header, lines, fixed=TRUE)
Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS 2019-04-15 03:05:20 UTC (rev 440)
+++ pkg/CHNOSZ/inst/NEWS 2019-04-15 04:26:29 UTC (rev 441)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.3.1-21 (2019-04-15)
+CHANGES IN CHNOSZ 1.3.1-22 (2019-04-15)
---------------------------------------
- Add thermo/stoich.csv.xz (loaded as thermo()$stoich), containing a
@@ -31,6 +31,9 @@
- Add demo/contour.R for gold solubility contours on logfO2-pH diagram.
+- In the output of affinity(), the list of 'vals' (the values of the
+ input variables) now has names corresponding to the variables.
+
CHANGES IN CHNOSZ 1.3.1 (2019-03-02)
------------------------------------
Modified: pkg/CHNOSZ/man/eqdata.Rd
===================================================================
--- pkg/CHNOSZ/man/eqdata.Rd 2019-04-15 03:05:20 UTC (rev 440)
+++ pkg/CHNOSZ/man/eqdata.Rd 2019-04-15 04:26:29 UTC (rev 441)
@@ -6,7 +6,7 @@
Extract computational results for aqueous species, solid phases, mineral saturation states, or speciation summaries at each step of reaction progress in an EQ6 output file.
The results are written to a comma-separated value file that can be read by other programs.
The function has been tested with output files generated by EQ3/6 version 7.1 running on a Unix platform.
-Currently it does not work for files generated by later versions.
+Currently there is only partial support for version 8.0a (reading data from aqueous species blocks).
}
\usage{
More information about the CHNOSZ-commits
mailing list