[CHNOSZ-commits] r234 - in pkg/CHNOSZ: . R data inst inst/extdata inst/extdata/Berman inst/extdata/OBIGT man man/macros tests/testthat vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Oct 2 06:45:02 CEST 2017
Author: jedick
Date: 2017-10-02 06:45:01 +0200 (Mon, 02 Oct 2017)
New Revision: 234
Added:
pkg/CHNOSZ/R/berman.R
pkg/CHNOSZ/inst/extdata/Berman/
pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv
pkg/CHNOSZ/man/berman.Rd
pkg/CHNOSZ/tests/testthat/test-berman.R
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/NAMESPACE
pkg/CHNOSZ/data/refs.csv
pkg/CHNOSZ/inst/NEWS
pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz
pkg/CHNOSZ/man/eos.Rd
pkg/CHNOSZ/man/extdata.Rd
pkg/CHNOSZ/man/macros/macros.Rd
pkg/CHNOSZ/vignettes/obigt.Rmd
pkg/CHNOSZ/vignettes/obigt.bib
Log:
add Berman (1988) equations and data for minerals
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/DESCRIPTION 2017-10-02 04:45:01 UTC (rev 234)
@@ -1,6 +1,6 @@
-Date: 2017-10-01
+Date: 2017-10-02
Package: CHNOSZ
-Version: 1.1.0-32
+Version: 1.1.0-33
Title: Thermodynamic Calculations for Geobiochemistry
Author: Jeffrey Dick
Maintainer: Jeffrey Dick <j3ffdick at gmail.com>
Modified: pkg/CHNOSZ/NAMESPACE
===================================================================
--- pkg/CHNOSZ/NAMESPACE 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/NAMESPACE 2017-10-02 04:45:01 UTC (rev 234)
@@ -58,7 +58,7 @@
"nonideal", "anim.TCA", "uniprot.aa", "run.guess",
# added 20170301 or later
"GHS_Tr", "calculateDensity", "calculateGibbsOfWater",
- "calculateEpsilon", "calculateQ", "water.DEW"
+ "calculateEpsilon", "calculateQ", "water.DEW", "berman"
)
# Load shared objects
Added: pkg/CHNOSZ/R/berman.R
===================================================================
--- pkg/CHNOSZ/R/berman.R (rev 0)
+++ pkg/CHNOSZ/R/berman.R 2017-10-02 04:45:01 UTC (rev 234)
@@ -0,0 +1,105 @@
+# CHNOSZ/berman.R 20170930
+# calculate thermodynamic properties of minerals using Berman formulation
+
+berman <- function(name, T = 298.15, P = 1) {
+ # reference temperature and pressure
+ Pr <- 1
+ Tr <- 298.15
+ file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ")
+ dat <- read.csv(file, as.is=TRUE)
+ # remove the multipliers
+ multexp <- c(0, 0, 0, 0, # Ber88 Table 2
+ 0, -2, -5, -7, # Table 3a
+ 6, 12, 6, 10, # Table 4
+ 0, 0, 0, 2, 5, 0, # Table 3b
+ 0, 0, 0, -3, -5, 2, 6, -4 # Table 5
+ )
+ dat[, 2:27] <- t(t(dat[, 2:27]) / 10^multexp)
+ # which row has data for this mineral?
+ irow <- which(dat$name == name)
+ # only the immediately following assign() call is needed for the function to work,
+ # but an explicit dummy assignment here is used to avoid "Undefined global functions or variables" in R CMD check
+ GfPrTr <- HfPrTr <- SPrTr <- Tmax <- Tmin <- VPrTr <-
+ d0 <- d1 <- d2 <- d3 <- d4 <- d5 <- k0 <- k1 <- k2 <- k3 <- v1 <- v2 <- v3 <- v4 <- NA
+ # assign values to the variables used below
+ for(i in 1:ncol(dat)) assign(colnames(dat)[i], dat[irow, i])
+ # check that G in data file is the G of formation from the elements --> Benson-Helgeson convention (DG = DH - T*DS)
+ # we get the entropy of the elements using the chemical formula in thermo$obigt
+ iname <- info(name, "cr_Berman", check.it=FALSE)
+ SPrTr_elements <- convert(entropy(info(iname)$formula), "J")
+ GfPrTr_calc <- HfPrTr - Tr * (SPrTr - SPrTr_elements)
+ Gdiff <- GfPrTr_calc - GfPrTr
+ if(abs(Gdiff) >= 1000) warning(paste0(name, ": GfPrTr(calc) - GfPrTr(table) is too big! == ",
+ round(GfPrTr_calc - GfPrTr), " J/mol"), call.=FALSE)
+ # (the tabulated GfPrTr is unused below)
+
+ ### thermodynamic properties ###
+ # calculate Cp and V (Berman, 1988 Eqs. 4 and 5)
+ Cp <- k0 + k1 * T^-0.5 + k2 * T^-2 + k3 * T^-3
+ P_Pr <- P - Pr
+ T_Tr <- T - Tr
+ V <- VPrTr * (1 + v1 * P_Pr + v2 * P_Pr^2 + v3 * T_Tr + v4 * T_Tr^2)
+ # calculate Ga (Ber88 Eq. 6) --> Berman-Brown convention (DG = DH - T*S)
+ Ga <- HfPrTr - T * SPrTr + k0 * ( (T - Tr) - T * (log(T) - log(Tr)) ) +
+ 2 * k1 * ( (T^0.5 - Tr^0.5) + T*(T^-0.5 - Tr^-0.5) ) -
+ k2 * ( (T^-1 - Tr^-1) - T / 2 * (T^-2 - Tr^-2) ) -
+ k3 * ( (T^-2 - Tr^-2) / 2 - T / 3 * (T^-3 - Tr^-3) ) +
+ VPrTr * ( (v1 / 2 - v2) * (P^2 - Pr^2) + v2 / 3 * (P^3 - Pr^3) +
+ (1 - v1 + v2 + v3 * (T - Tr) + v4 * (T - Tr)^2) * (P - Pr) )
+ # calculate Ha (symbolically integrated using sympy - expressions not simplified)
+ intCp <- T*k0 - Tr*k0 + k2/Tr - k2/T + k3/(2*Tr^2) - k3/(2*T^2) + 2.0*k1*T^0.5 - 2.0*k1*Tr^0.5
+ intVminusTdVdT <- -VPrTr + P*(VPrTr + VPrTr*v2 - VPrTr*v1 - Tr*VPrTr*v3 + VPrTr*v4*Tr^2 - VPrTr*v4*T^2) +
+ P^2*(VPrTr*v1/2 - VPrTr*v2) + VPrTr*v1/2 - VPrTr*v2/3 + Tr*VPrTr*v3 + VPrTr*v4*T^2 - VPrTr*v4*Tr^2 + VPrTr*v2*P^3/3
+ Ha <- HfPrTr + intCp + intVminusTdVdT
+ # calculate S (also symbolically integrated)
+ intCpoverT <- k0*log(T) - k0*log(Tr) - k3/(3*T^3) + k3/(3*Tr^3) + k2/(2*Tr^2) - k2/(2*T^2) + 2.0*k1*Tr^-0.5 - 2.0*k1*T^-0.5
+ intdVdT <- -VPrTr*(v3 + v4*(-2*Tr + 2*T)) + P*VPrTr*(v3 + v4*(-2*Tr + 2*T))
+ S <- SPrTr + intCpoverT - intdVdT
+
+ ### disorder thermodynamic properties ###
+ if(!is.na(Tmin) & !is.na(Tmax) & any(T > Tmin)) {
+ # starting disorder contributions are 0
+ Cpds <- Hds <- Sds <- Vds <- Gds <- 0
+ # the lower integration limit is Tmin
+ iTds <- T > Tmin
+ Tds <- T[iTds]
+ # the upper integration limit is Tmax
+ Tds[Tds > Tmax] <- Tmax
+ # Ber88 Eqs. 15, 16, 17, 18, 19
+ Cpds[iTds] <- d0 + d1 * Tds^-0.5 + d2 * Tds^-2 + d3 * Tds + d4 * Tds^2
+ Hds[iTds] <- d0 * (Tds - Tmin) + 2 * d1 * (Tds^-0.5 - Tmin^-0.5) -
+ d2 * (Tds^-1 - Tmin^-1) + d3 * (Tds^2 - Tmin^2) / 2 + d4 * (Tds^3 - Tmin^3) / 3
+ Sds[iTds] <- d0 * (log(Tds) - log(Tmin)) - 2 * d1 * (Tds^-0.5 - Tmin^-0.5) -
+ d2 * (Tds^-2 - Tmin^-2) / 2 + d3 * (Tds - Tmin) + d4 * (Tds^2 - Tmin^2) / 2
+ # we can't do this if d5 == 0 (dolomite and gehlenite)
+ if(d5 != 0) Vds <- Hds / d5
+ Gds <- Hds - T * Sds + Vds * (P - Pr)
+ # Gds above Tmax (Eq. 20)
+ ihigh <- T > Tmax
+ # note that Gds[ihigh] and Sds[ihigh] on the rhs were both calculated at Tmax (above)
+ Gds[ihigh] <- Gds[ihigh] - (T[ihigh] - Tmax) * Sds[ihigh]
+ # apply the disorder contributions
+ Ga <- Ga + Gds
+ Ha <- Ha + Hds
+ S <- S + Sds
+ V <- V + Vds
+ Cp <- Cp + Cpds
+ }
+
+ ### (for testing) use G = H - TS to check that integrals for H and S are written correctly
+ Ga_fromHminusTS <- Ha - T * S
+ if(!all.equal(Ga_fromHminusTS, Ga)) stop("incorrect integrals detected using DG = DH - T*S")
+
+ ### thermodynamic and unit conventions used in SUPCRT ###
+ # use entropy of the elements in calculation of G --> Benson-Helgeson convention (DG = DH - T*DS)
+ Gf <- Ga + Tr * SPrTr_elements
+ # convert J to cal
+ G <- convert(Gf, "cal")
+ H <- convert(Ha, "cal")
+ S <- convert(S, "cal")
+ Cp <- convert(Cp, "cal")
+ # convert J/bar to cm^3/mol
+ V <- V * 10
+
+ data.frame(T=T, P=P, G=G, H=H, S=S, Cp=Cp, V=V)
+}
Modified: pkg/CHNOSZ/data/refs.csv
===================================================================
--- pkg/CHNOSZ/data/refs.csv 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/data/refs.csv 2017-10-02 04:45:01 UTC (rev 234)
@@ -17,6 +17,7 @@
BH83,"T. S. Bowers and H. C. Helgeson",1983,"Geochim. Cosmochim. Acta 47, 1247-1275",rutile,https://doi.org/10.1016/0016-7037(83)90066-2
Hel85,"H. C. Helgeson",1985,"Am. J. Sci. 285, 845-855","ferrosilite and siderite",https://doi.org/10.2475/ajs.285.9.845
JH85,"K. J. Jackson and H. C. Helgeson",1985,"Econ. Geol. 80, 1365-1378","Sn minerals",https://doi.org/10.2113/gsecongeo.80.5.1365
+Ber88,"R. G. Berman",1988,"J. Petrol. 29, 445-522","minerals",https://doi.org/10.1093/petrology/29.2.445
SH88,"E. L. Shock and H. C. Helgeson",1988,"Geochim. Cosmochim. Acta 52, 2009-2036","ionic species",https://doi.org/10.1016/0016-7037(88)90181-0
SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183","inorganic neutral species",https://doi.org/10.1016/0016-7037(89)90341-4
SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945","organic species",https://doi.org/10.1016/0016-7037(90)90429-O
Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/inst/NEWS 2017-10-02 04:45:01 UTC (rev 234)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.0-32 (2017-10-01)
+CHANGES IN CHNOSZ 1.1.0-33 (2017-10-02)
---------------------------------------
MAJOR CHANGES:
@@ -11,8 +11,11 @@
- The computational setting for water (thermo$opt$par) can now be
set using water("DEW"), water("IAPWS"), etc.
-- Add demo DEW.R.
+- Usage of the DEW model is demonstrated in the new demo DEW.R.
+- Add berman() function and extdata/Berman/*.csv files for calculating
+ the thermodynamic properties using equations of Berman, 1988.
+
- Implement SUPCRT92's handling of variable volume for quartz and
coesite. Calculations for other minerals still assume constant
volume of each phase.
@@ -40,9 +43,10 @@
selected species are fully referenced.
- Add Berman_cr.csv with names and formulas for minerals whose
- thermodynamic properties are calculated using the Berman (1988)
+ thermodynamic properties are calculated using the Berman 1988
formulation. The state "cr_Berman" is used to distinguish these
- minerals from the Helgeson data.
+ minerals from the Helgeson data. The parameters themselves are
+ stored in extdata/Berman/*.csv.
- Data file CHNOSZ_aq.csv is no longer added to the database by default.
It is now intended to hold provisional updates. Updated heat capacity
Added: pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv (rev 0)
+++ pkg/CHNOSZ/inst/extdata/Berman/Ber88.csv 2017-10-02 04:45:01 UTC (rev 234)
@@ -0,0 +1,68 @@
+name,GfPrTr,HfPrTr,SPrTr,VPrTr,k0,k1,k2,k3,v1,v2,v3,v4,Tlambda,Tref,dTdP,l1,l2,DtH,Tmax,Tmin,d0,d1,d2,d3,d4,d5
+akermanite,-3663786,-3860441,212,9.252,387.06,-29.388,0,-4.079,-0.785,0,25.011,67.224,358,298,0,0,0,452,,,,,,,,
+albite,-3703293,-3921618,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,,
+"albite,high",-3703293,-3921618,224.412,10.083,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,,
+"albite,low",-3711715,-3935100,207.443,10.043,393.64,-24.155,-78.928,107.064,-1.945,4.861,26.307,32.407,,,,,,,,,,,,,,
+almandine,-4941728,-5265502,339.927,11.511,573.96,-14.831,-292.92,502.208,-0.558,0.321,18.613,74.539,,,,,,,,,,,,,,
+andalusite,-2441806,-2589972,91.434,5.147,236.48,-11.029,-75.268,93.644,-0.77,1.923,23.443,7.189,,,,,,,,,,,,,,
+anorthite,-4003221,-4228730,200.186,10.075,439.37,-37.341,0,-31.702,-1.272,3.176,10.918,41.985,,,,,,,,,,,,,,
+anthophyllite,-11342582,-12069032,535.195,26.56,1219.31,-57.665,-347.661,440.09,-1.259,0,27.06,31.325,,,,,,,,,,,,,,
+antigorite,-66076529,-71364156,3602.996,174.246,7394.51,0,-5483.63,8728.412,-1.978,4.944,24.965,39.444,,,,,,,,,,,,,,
+brucite,-834868,-925937,63.064,2.468,136.84,-5.371,-43.619,55.269,-2.023,6.726,32.854,10.94,,,,,,,,,,,,,,
+Ca-Al-pyroxene,-3122310,-3298767,140.751,6.356,310.7,-16.716,-74.553,94.878,-0.87,2.171,22.25,52.863,,,,,,,,,,,,,,
+calcite,-1128295,-1206819,91.725,3.69,178.19,-16.577,-4.827,16.66,-1.4,0,8.907,227.402,,,,,,,,,,,,,,
+chrysotile,-4035373,-4363356,220.134,10.72,610.02,-55.812,-18.573,19.547,-1.81,4.524,27.151,67.351,,,,,,,,,,,,,,
+clinochlore,-8250546,-8909590,435.154,21.147,1214.28,-112.171,0,-125.625,-1.819,0,26.452,0,,,,,,,,,,,,,,
+coesite,-852585,-907604,39.424,2.064,94.907,-7.673,-5.279,2.627,-1.037,3,7.396,43.605,,,,,,,,,,,,,,
+cordierite,-8651517,-9158727,417.97,23.311,954.39,-79.623,-23.173,-37.021,-1.158,0,3.003,18.017,,,,,,,,,,,,,,
+corundum,-1582199,-1675700,50.82,2.558,155.02,-8.284,-38.614,40.908,-0.385,0.375,21.342,47.18,,,,,,,,,,,,,,
+"cristobalite,alpha",-853918,-907753,43.394,2.587,83.51,-3.747,-24.554,28.007,-2.515,0,20.824,0,535,298,0.048,-14.216,44.142,0,,,,,,,,
+"cristobalite,beta",-853327,-906377,46.029,2.73,83.51,-3.747,-24.554,28.007,-1.1,5.535,3.189,0,,,,,,,,,,,,,,
+diaspore,-920806,-999378,35.308,1.776,143.24,-15.404,-3.231,6.463,-0.599,0,29.718,0,,,,,,,,,,,,,,
+diopside,-3026202,-3200583,142.5,6.62,305.41,-16.049,-71.66,92.184,-0.872,1.707,27.795,83.082,,,,,,,,,,,,,,
+dolomite,-2162354,-2325248,154.89,6.432,328.48,-25.544,-46.885,79.038,-1.07,0,14.23,363.778,,,,,,,1423,298,-9.42,0,3.85,1.732,5.02,0
+"enstatite,clino",-1458601,-1545926,66.325,3.131,139.96,-4.97,-44.002,53.571,-0.75,0.448,21.915,74.92,,,,,,,,,,,,,,
+enstatite,-1458181,-1545552,66.17,3.133,166.58,-12.006,-22.706,27.915,-0.749,0.447,24.656,74.67,,,,,,,,,,,,,,
+"enstatite,proto",-1456965,-1543959,67.438,3.242,166.58,-12.006,-22.706,27.915,-0.75,0.448,16.832,116.65,,,,,,,,,,,,,,
+fayalite,-1380154,-1479360,150.93,4.63,248.93,-19.239,0,-13.91,-0.73,0,26.546,79.482,,,,,,,,,,,,,,
+ferrosilite,-1117472,-1194375,95.882,3.296,169.06,-11.93,-20.971,29.253,-0.99,0,31.808,75.85,,,,,,,,,,,,,,
+forsterite,-2055023,-2174420,94.01,4.366,238.64,-20.013,0,-11.624,-0.791,1.351,29.464,88.633,,,,,,,,,,,,,,
+gehlenite,-3785954,-3988158,198.6,9.033,373.09,-22.768,-47.785,47.791,-0.996,2.488,24.926,5.664,,,,,,,1600,698,-221.74,0,172.91,36.95,-146.9,0
+grossular,-6270974,-6632859,255.15,12.538,573.43,-20.394,-188.872,231.931,-0.654,1.635,18.994,79.756,,,,,,,,,,,,,,
+hematite,-743681,-825627,87.437,3.027,146.86,0,-55.768,52.563,-0.479,0.304,38.31,1.65,955,298,0,-7.403,27.921,1287,,,,,,,,
+ilmenite,-1155320,-1231947,108.628,3.17,150,-4.416,-33.237,34.815,-0.584,1.23,27.248,29.968,,,,,,,,,,,,,,
+jadeite,-2846482,-3025118,133.574,6.034,311.29,-20.051,-53.503,66.257,-0.86,2.149,23.118,25.785,,,,,,,,,,,,,,
+kaolinite,-3799770,-4120327,203.7,9.952,523.23,-44.267,-22.443,9.231,-1.2,0,32,0,,,,,,,,,,,,,,
+kyanite,-2443370,-2594220,82.43,4.412,262.68,-20.014,-19.997,-6.318,-0.646,0,23.973,0,,,,,,,,,,,,,,
+lawsonite,-4509709,-4865666,229.176,10.144,728.67,-82.481,0,85.056,-0.769,1.922,26.283,0,,,,,,,,,,,,,,
+lime,-603350,-635090,37.75,1.676,58.79,-1.339,-11.471,10.298,-1.022,2.565,34.61,67.406,,,,,,,,,,,,,,
+magnesite,-1029875,-1113636,65.21,2.803,162.3,-11.093,-48.826,87.466,-0.89,2.212,18.436,415.968,,,,,,,,,,,,,,
+magnetite,-1014235,-1117403,146.114,4.452,207.93,0,-72.433,66.436,-0.582,1.751,30.291,138.47,848,298,0,-19.502,61.037,1565,,,,,,,,
+margarite,-5852244,-6236603,265.084,12.958,699.8,-55.871,-68.077,73.432,-1.155,2.886,21.019,124.556,,,,,,,,,,,,,,
+meionite,-13105915,-13849723,730,34.036,1511.35,-132.433,0,-75.161,-1.11,0,9.34,0,,,,,,,,,,,,,,
+merwinite,-4309707,-4537497,251.777,9.847,453.62,-32.5,0,-34.423,-0.551,1.381,29.376,87.235,,,,,,,,,,,,,,
+monticellite,-2132222,-2250027,108.3,5.148,226.34,-15.427,-11.797,-2.329,-0.904,2,27.863,76.339,,,,,,,,,,,,,,
+muscovite,-5596723,-5976740,293.157,14.087,651.49,-38.732,-185.232,274.247,-1.717,4.295,33.527,0,,,,,,,,,,,,,,
+paragonite,-5563572,-5944208,277.699,13.216,577.57,-14.728,-322.144,505.008,-1.973,4.933,39.424,59.701,,,,,,,,,,,,,,
+periclase,-569209,-601500,26.951,1.125,61.11,-2.962,-6.212,0.584,-0.622,1.511,37.477,3.556,,,,,,,,,,,,,,
+phlogopite,-5827224,-6207342,334.158,14.977,610.38,-20.838,-215.33,284.104,-1.697,0,34.447,0,,,,,,,,,,,,,,
+K-feldspar,-3745415,-3970791,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,1436,298,282.98,-4.83,36.21,-15.733,34.77,41.063
+"K-feldspar,high",-3738804,-3959704,229.157,10.896,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,,
+"K-feldspar,low",-3745415,-3970791,214.145,10.869,381.37,-19.41,-120.373,183.643,-1.805,5.112,15.145,54.85,,,,,,,,,,,,,,
+prehnite,-5820154,-6198606,288.634,14.016,716.05,-64.046,-21.825,26.85,-1.427,0,1.468,1128.353,,,,,,,,,,,,,,
+pyrope,-5936009,-6286548,266.359,11.316,640.72,-45.421,-47.019,0,-0.576,0.442,22.519,37.044,,,,,,,,,,,,,,
+pyrophyllite,-5266865,-5640781,239.4,12.76,665.93,-58.974,-49.799,66.181,-1.354,0,12.637,381.661,,,,,,,,,,,,,,
+quartz,-856288,-910700,41.46,2.269,80.01,-2.403,-35.467,49.157,-2.434,10.137,23.895,0,848,373,0.0237,-9.187,24.607,0,,,,,,,,
+"quartz,beta",-855033,-908627,44.207,2.37,80.01,-2.403,-35.467,49.157,-1.238,7.087,0,0,,,,,,,,,,,,,,
+rutile,-889497,-944750,50.46,1.882,77.84,0,-33.678,40.294,-0.454,0.584,25.716,15.409,,,,,,,,,,,,,,
+sillimanite,-2439265,-2586091,95.93,4.983,256.73,-18.872,-29.774,25.096,-0.753,0,13.431,0,,,,,,,,,,,,,,
+sphene,-2455134,-2596652,129.29,5.565,234.62,-10.403,-51.183,59.146,-0.59,0,25.2,0,,,,,,,,,,,,,,
+spinel,-2176537,-2300313,84.535,3.977,235.9,-17.666,-17.104,4.062,-0.489,0,21.691,50.528,,,,,,,,,,,,,,
+talc,-5517657,-5897387,261.24,13.61,664.11,-51.872,-21.472,-32.737,-1.699,5.665,29.447,0,,,,,,,,,,,,,,
+tremolite,-11578548,-12305578,551.15,27.268,1229.36,-64.019,-320.899,420.881,-1.392,3.481,24.374,98.338,,,,,,,,,,,,,,
+"tridymite,low",-854026,-907750,43.77,2.675,75.37,0,-59.581,95.825,-2.508,0,19.339,0,383,298,0,42.67,-144.575,130,,,,,,,,
+"tridymite,high",-853844,-907045,45.524,2.737,75.37,0,-59.581,95.825,-0.74,3.735,4.829,0,,,,,,,,,,,,,,
+wollastonite,-1546123,-1631500,81.81,3.983,149.07,-6.903,-36.593,48.435,-1.245,3.113,28.18,0,,,,,,,,,,,,,,
+pseudowollastonite,-1543085,-1627427,85.279,4.016,141.16,-4.172,-58.576,94.074,-1.245,3.113,28.18,0,,,,,,,,,,,,,,
+zoisite,-6494148,-6889488,297.576,13.588,749.17,-65.093,-23.805,12.486,-0.515,1.288,34.67,0,,,,,,,,,,,,,,
+clinozoisite,-6496497,-6894968,287.076,13.673,749.17,-65.093,-23.805,12.486,-0.515,1.288,34.67,0,,,,,,,,,,,,,,
Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Berman_cr.csv.xz
===================================================================
(Binary files differ)
Added: pkg/CHNOSZ/man/berman.Rd
===================================================================
--- pkg/CHNOSZ/man/berman.Rd (rev 0)
+++ pkg/CHNOSZ/man/berman.Rd 2017-10-02 04:45:01 UTC (rev 234)
@@ -0,0 +1,52 @@
+\encoding{UTF-8}
+\name{berman}
+\alias{berman}
+\title{Thermodynamic Properties of Minerals}
+\description{
+Calculate thermodynamic properties of minerals using the equations of Berman (1988).
+}
+
+\usage{
+ berman(name, T = 298.15, P = 1)
+}
+
+\arguments{
+ \item{name}{character, name of mineral}
+ \item{T}{numeric, temperature(s) at which to calculate properties (K)}
+ \item{P}{numeric, pressure(s) at which to calculate properties (bar)}
+}
+
+\details{
+This function calculates the thermodynamic properties of minerals at high \P and \T using equations given by Berman (1988).
+The \code{name} refers to a mineral that must be listed in \code{thermo$obigt} with the state \samp{cr_Berman}.
+This file also holds the chemical formula, which is required for calculating the entropies of the elements in the mineral.
+These entropies are used to convert the apparent Gibbs energies from the Berman-Brown convention to the the Benson-Helgeson convention.
+
+Becuase they use a different set of parameters than Helgeson et al., 1978 (see \code{\link{cgl}}), the standard state thermodynamic properties and parameters for the calculations are stored in files under \code{extdata/Berman}.
+}
+
+\examples{
+\dontshow{data(thermo)}
+# other than the formula, the parameters aren't stored in
+# thermo$obigt, so this shows NAs
+info(info("quartz", "cr_Berman"))
+# properties of alpha-quartz (aQz) at 298.15 K and 1 bar
+berman("quartz")
+# Gibbs energies of aQz and coesite at higher T and P
+T <- seq(200, 1300, 100)
+P <- seq(23000, 32000, length.out=length(T))
+G_aQz <- berman("quartz", T=T, P=P)$G
+G_Cs <- berman("coesite", T=T, P=P)$G
+# that is close to the univariant curve (Ber88 Fig. 4),
+# so the difference in G is close to 0
+DGrxn <- G_Cs - G_aQz
+stopifnot(all(abs(DGrxn) < 100))
+}
+
+\references{
+Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O–K{\s2}O–CaO–MgO–FeO–Fe{\s2}O{\s3}–Al{\s2}O{\s3}–SiO{\s2}–TiO{\s2}–H{\s2}O–CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445}
+
+Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K. (1978) Summary and critique of the thermodynamic properties of rock-forming minerals. \emph{Am. J. Sci.} \bold{278-A}, 1--229. \url{http://www.worldcat.org/oclc/13594862}
+}
+
+\concept{Secondary thermodynamic modeling}
Modified: pkg/CHNOSZ/man/eos.Rd
===================================================================
--- pkg/CHNOSZ/man/eos.Rd 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/man/eos.Rd 2017-10-02 04:45:01 UTC (rev 234)
@@ -42,8 +42,6 @@
For both \code{hkf} and \code{cgl}, if at least one equations-of-state parameter for a species is provided, any NA values of the other parameters are reset to zero.
If all equations-of-state parameters are NA, but values of \samp{Cp} and/or \samp{V} are available, those values are used in the integration of \samp{G}, \samp{H} and \samp{S} as a function of temperature.
-
-The \code{T} and \code{P} arguments should all be the same length; the functions perform no argument validating.
}
\section{Warning}{
Modified: pkg/CHNOSZ/man/extdata.Rd
===================================================================
--- pkg/CHNOSZ/man/extdata.Rd 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/man/extdata.Rd 2017-10-02 04:45:01 UTC (rev 234)
@@ -10,6 +10,15 @@
\details{
+ Files in \code{Berman} contain mineral data using the Berman formulation:
+ \itemize{
+ \item \code{Ber88.csv} lists thermodynamic data for minerals taken from Berman (1988).
+ These consist of standard state thermodyamic properties (Table 2 in the paper), parameters for calculating heat capacity (Table 3a), coefficients for calculation of mineral expansivities and compressibilities (Table 4), parameters describing polymorph transitions (Table 3b), and parameters describing temperature dependent disordering (Table 5).
+ The values are entered as shown in the source Tables, preserving units and multipliers.
+ \code{\link{berman}} removes these multipliers and, after calculation of thermodynamic properties at \P and \T, converts to units used by \code{\link{subcrt}}.
+ Following conventions used in data files for other software packages, the names of sanidine and microcline were changed to K-feldspar,high and K-feldspar,low.
+ }
+
Files in \code{abundance} contain protein abundance and microbial occurrence data:
\itemize{
\item \code{TBD+05.csv} lists genes with transcriptomic expression changes in carbon limitation stress response experiments in yeast (Tai et al., 2005). See \code{\link{yeast.aa}} for an example that uses this file.
@@ -24,7 +33,7 @@
}
- Files in \code{cpetc} contain heat capacity and other thermodynamic data and parameters:
+ Files in \code{cpetc} contain experimental and calculated thermodynamic and environmental data:
\itemize{
\item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Temperature in \eqn{^{\circ}}{°}C is in the first column, and heat capacities of the proteins in J mol\eqn{^{-1}}{^-1} K\eqn{^{-1}}{^-1} in the remaining columns. See \code{\link{ionize.aa}} and the vignette \code{anintro.Rmd} for examples that uses this file.
\item \code{RH95.csv} Heat capacity data for iron taken from Robie and Hemingway, 1995. Temperature in Kelvin is in the first column, heat capacity in J K\eqn{^{-1}}{^-1} mol\eqn{^{-1}}{^-1} in the second. See \code{\link{subcrt}} for an example that uses this file.
@@ -102,6 +111,8 @@
\references{
Bazarkina, E. F., Zotov, A. V. and Akinfiev, N. N. (2010) Pressure-dependent stability of cadmium chloride complexes: Potentiometric measurements at 1–1000 bar and 25°C. \emph{Geol. Ore Deposits} \bold{52}, 167--178. \url{https://doi.org/10.1134/S1075701510020054}
+Berman, R. G. (1988) Internally-consistent thermodynamic data for minerals in the system Na{\s2}O–K{\s2}O–CaO–MgO–FeO–Fe{\s2}O{\s3}–Al{\s2}O{\s3}–SiO{\s2}–TiO{\s2}–H{\s2}O–CO{\s2}. \emph{J. Petrol.} \bold{29}, 445-522. \url{https://doi.org/10.1093/petrology/29.2.445}
+
Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V. (1964) Thermodynamic Equilibria In Prebiological Atmospheres. \emph{Science} \bold{146}, 1461--1464. \url{https://doi.org/10.1126/science.146.3650.1461}
Dayhoff, M. O. and Lippincott, E. R., Eck, R. V. and Nagarajan (1967) Thermodynamic Equilibrium In Prebiological Atmospheres of C, H, O, N, P, S, and Cl. Report SP-3040, National Aeronautics and Space Administration. \url{http://ntrs.nasa.gov/search.jsp?R=19670017966}
@@ -116,17 +127,17 @@
Gattiker, A., Michoud, K., Rivoire, C., Auchincloss, A. H., Coudert, E., Lima, T., Kersey, P., Pagni, M., Sigrist, C. J. A., Lachaize, C., Veuthey, A.-L., Gasteiger, E. and Bairoch, A. (2003) Automatic annotation of microbial proteomes in Swiss-Prot. \emph{Comput. Biol. Chem.} \bold{27}, 49--58. \url{https://doi.org/10.1016/S1476-9271(02)00094-4}
-Gaucher, E. A., Thomson, J. M., Burgan, M. F. and Benner, S. A (2003) Inferring the palaeoenvironment of ancient bacteria on the basis of resurrected proteins. \emph{Nature} \bold{425}(6955), 285--288. \code{https://doi.org/10.1038/nature01977}
+Gaucher, E. A., Thomson, J. M., Burgan, M. F. and Benner, S. A (2003) Inferring the palaeoenvironment of ancient bacteria on the basis of resurrected proteins. \emph{Nature} \bold{425}(6955), 285--288. \url{https://doi.org/10.1038/nature01977}
-Ghaemmaghami, S., Huh, W., Bower, K., Howson, R. W., Belle, A., Dephoure, N., O'Shea, E. K. and Weissman, J. S. (2003) Global analysis of protein expression in yeast. \emph{Nature} \bold{425}(6959), 737--741. \code{https://doi.org/10.1038/nature02046}
+Ghaemmaghami, S., Huh, W., Bower, K., Howson, R. W., Belle, A., Dephoure, N., O'Shea, E. K. and Weissman, J. S. (2003) Global analysis of protein expression in yeast. \emph{Nature} \bold{425}(6959), 737--741. \url{https://doi.org/10.1038/nature02046}
-Huh, W. K., Falvo, J. V., Gerke, L. C., Carroll, A. S., Howson, R. W., Weissman, J. S. and O'Shea, E. K. (2003) Global analysis of protein localization in budding yeast. \emph{Nature} \bold{425}(6959), 686--691. \code{https://doi.org/10.1038/nature02026}
+Huh, W. K., Falvo, J. V., Gerke, L. C., Carroll, A. S., Howson, R. W., Weissman, J. S. and O'Shea, E. K. (2003) Global analysis of protein localization in budding yeast. \emph{Nature} \bold{425}(6959), 686--691. \url{https://doi.org/10.1038/nature02026}
HAMAP system. HAMAP FTP directory, \url{ftp://ftp.expasy.org/databases/hamap/}
-Hnědkovský, L., Wood, R. H. and Majer, V. (1996) Volumes of aqueous solutions of CH4, CO2, H2S, and NH3 at temperatures from 298.15 K to 705 K and pressures to 35 MPa. \emph{J. Chem. Thermodyn.} \bold{28}, 125--142. \url{https://doi.org/10.1006/jcht.1996.0011}
+Hnědkovský, L., Wood, R. H. and Majer, V. (1996) Volumes of aqueous solutions of \CH4, \CO2, \H2S, and \NH3 at temperatures from 298.15 K to 705 K and pressures to 35 MPa. \emph{J. Chem. Thermodyn.} \bold{28}, 125--142. \url{https://doi.org/10.1006/jcht.1996.0011}
-Hnědkovský, L. and Wood, R. H. (1997) Apparent molar heat capacities of aqueous solutions of CH4, CO2, H2S, and NH3 at temperatures from 304 K to 704 K at a pressure of 28 MPa. \emph{J. Chem. Thermodyn.} \bold{29}, 731--747. \url{https://doi.org/10.1006/jcht.1997.0192}
+Hnědkovský, L. and Wood, R. H. (1997) Apparent molar heat capacities of aqueous solutions of \CH4, \CO2, \H2S, and \NH3 at temperatures from 304 K to 704 K at a pressure of 28 MPa. \emph{J. Chem. Thermodyn.} \bold{29}, 731--747. \url{https://doi.org/10.1006/jcht.1997.0192}
Joint Genome Institute (2007) Bison Pool Environmental Genome. Protein sequence files downloaded from IMG/M (\url{http://img.jgi.doe.gov/cgi-bin/m/main.cgi?section=FindGenomes&page=findGenomes})
Modified: pkg/CHNOSZ/man/macros/macros.Rd
===================================================================
--- pkg/CHNOSZ/man/macros/macros.Rd 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/man/macros/macros.Rd 2017-10-02 04:45:01 UTC (rev 234)
@@ -13,6 +13,11 @@
\newcommand{\NH4plus}{\ifelse{latex}{\eqn{\mathrm{NH_{4}^{+}}}}{\ifelse{html}{\out{NH<sub>4</sub><sup>+</sup>}}{NH4+}}}
\newcommand{\H2}{\ifelse{latex}{\eqn{\mathrm{H_{2}}}}{\ifelse{html}{\out{H<sub>2</sub>}}{H2}}}
+% subscripted numbers
+\newcommand{\s2}{\ifelse{latex}{\eqn{_2}}{\ifelse{html}{\out{<sub>2</sub>}}{2}}}
+\newcommand{\s3}{\ifelse{latex}{\eqn{_3}}{\ifelse{html}{\out{<sub>3</sub>}}{3}}}
+\newcommand{\s4}{\ifelse{latex}{\eqn{_4}}{\ifelse{html}{\out{<sub>4</sub>}}{4}}}
+
% 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}}}
Added: pkg/CHNOSZ/tests/testthat/test-berman.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-berman.R (rev 0)
+++ pkg/CHNOSZ/tests/testthat/test-berman.R 2017-10-02 04:45:01 UTC (rev 234)
@@ -0,0 +1,69 @@
+# test-berman.R 20171001
+context("berman")
+
+# calculate properties for all available minerals at Tr,Pr
+file <- system.file("extdata/Berman/Ber88.csv", package="CHNOSZ")
+dat <- read.csv(file, as.is=TRUE)
+mineral <- unique(dat$name)
+prop_Berman <- NULL
+
+test_that("properties of all minerals are computed without warnings", {
+ # running this without error means that:
+ # - formulas for the minerals are found in thermo$obigt
+ # - there are no warnings for minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table)
+ expect_silent(properties <- lapply(mineral, berman))
+ # save the results so we can use them in the next tests
+ assign("prop_Berman", properties, inherits=TRUE)
+
+ ## - warnings are produced for 7 minerals with GfPrTr(calc) >= 1000 J/cal different from GfPrTr(table)
+ #expect_warning(Berman <- lapply(mineral, berman),
+ # "annite|dawsonite|dravite|fluortremolite|greenalite|siderite|Na-Fe-saponite.3W", all=TRUE)
+})
+
+# assemble a data frame for Berman properties
+prop_Berman <- do.call(rbind, prop_Berman)
+# find the mineral data using Helgeson formulation
+icr <- suppressMessages(info(mineral, "cr"))
+icr1 <- suppressMessages(info(mineral, "cr1"))
+# if there's no match for "cr", try to get "cr1" (lowest-temperature phase)
+icr[is.na(icr)] <- icr1[is.na(icr)]
+# all of these except rutile (Robie et al., 1979) reference Helgeson et al., 1978
+# NOTE: with check.it = TRUE (the default), this calculates Cp from the tabulated Maier-Kelley parameters
+prop_Helgeson <- suppressMessages(info(icr))
+
+# now we can compare Berman and Helgeson G, H, S, Cp, V
+# minerals with missing properties are not matched here
+# (i.e. fluorphlogopite, fluortremolite, glaucophane, and pyrope: no G and H in prop_Helgeson data)
+
+test_that("Berman and Helgeson properties have large differences for few minerals", {
+ # which minerals differ in DGf by more than 4 kcal/mol?
+ idiffG <- which(abs(prop_Berman$G - prop_Helgeson$G) > 4000)
+ expect_match(mineral[idiffG],
+ "anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite")
+ ## we find 9 of them, as follow:
+ #expect_match(mineral[idiffG],
+ # "anthophyllite|antigorite|Ca-Al-pyroxene|cordierite,dry|cordierite,hydrous|lawsonite|margarite|merwinite|paragonite")
+
+ # which minerals differ in DHf by more than 4 kcal/mol?
+ idiffH <- which(abs(prop_Berman$H - prop_Helgeson$H) > 4000)
+ # we get the above, plus phlogopite and clinozoisite:
+ expect_match(mineral[idiffH],
+ "anthophyllite|antigorite|Ca-Al-pyroxene|lawsonite|margarite|merwinite|phlogopite|clinozoisite")
+
+ # which minerals differ in S by more than 4 cal/K/mol?
+ idiffS <- which(abs(prop_Berman$S - prop_Helgeson$S) > 4)
+ expect_match(mineral[idiffS], "albite|almandine")
+ #expect_match(mineral[idiffS], "albite|almandine|annite|cordierite,hydrous|fluortremolite")
+
+ # which minerals differ in Cp by more than 4 cal/K/mol?
+ idiffCp <- which(abs(prop_Berman$Cp - prop_Helgeson$Cp) > 4)
+ expect_match(mineral[idiffCp], "antigorite|cristobalite,beta|K-feldspar")
+ #expect_match(mineral[idiffCp],
+ # "antigorite|cordierite,hydrous|cristobalite,beta|fluortremolite|glaucophane|greenalite|K-feldspar")
+
+ # which minerals differ in V by more than 1 cm^3/mol?
+ idiffV <- which(abs(prop_Berman$V - prop_Helgeson$V) > 1)
+ expect_match(mineral[idiffV], "anthophyllite|antigorite|chrysotile|merwinite")
+ #expect_match(mineral[idiffV],
+ # "anthophyllite|antigorite|chrysotile|cordierite,hydrous|glaucophane|greenalite|merwinite")
+})
Modified: pkg/CHNOSZ/vignettes/obigt.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-01 08:40:37 UTC (rev 233)
+++ pkg/CHNOSZ/vignettes/obigt.Rmd 2017-10-02 04:45:01 UTC (rev 234)
@@ -172,6 +172,16 @@
```{r reflist, results="asis", echo=FALSE}
```
+### `r setfile("Berman_cr.csv")`
+```{r Berman_cr, results="asis", echo=FALSE}
+cat("This file gives the identifiying information for minerals whose properties are calculated using the formulation of @Ber88.\n")
+cat("To distinguish these minerals from the original set of mineral data in CHNOSZ (based on the compliation of @HDNB78), the physical states are listed as `cr_Berman`.\n")
+cat("The actual data are stored separately (`extdata/Berman/*.csv`).<hr>")
+```
+
+```{r reflist, results="asis", echo=FALSE}
+```
+
## Liquids {.tabset .tabset-pills}
### `r setfile("organic_liq.csv")`
@@ -256,6 +266,13 @@
```{r reflist2, results="asis", echo=FALSE}
```
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/chnosz -r 234
More information about the CHNOSZ-commits
mailing list