Learn R Programming

CHNOSZ (version 0.9-7)

EOSregress: Regress equations-of-state parameters for aqueous species

Description

Functions for fitting experimental volume and heat capacities using regression equations. Possible models include the Helgeson-Kirkham-Flowers (HKF) equations of state and other equations defined using any combination of terms derived from the temperature, pressure and thermodynamic and electrostatic properties of water.

Usage

EOSregress(exptdata, var = "", T.max = 9999)
  EOSvar(var, T, P)
  EOScalc(coefficients, T, P)
  EOSplot(exptdata, var = NULL, T.max = 9999, T.plot = NULL, 
    P = NULL, fun.legend = "topleft", coefficients = NULL)
  EOSlab(var, coeff = "")
  EOScoeffs(species, property)

Arguments

exptdata
dataframe, experimental data
var
character, name(s) of variables in the regression equations
T.max
numeric, maximum temperature for regression, in degrees Kelvin
T
numeric, temperature in degrees Kelvin
P
numeric, pressure in bars
T.plot
numeric, upper limit of temperature range to plot
fun.legend
character, where to place legend on plot
coefficients
dataframe, coefficients to use to make line on plot
coeff
numeric, value of equation of state parameter for plot legend
species
character, name of aqueous species
property
character, Cp or V

Value

  • For EOSregress, an object of class lm. EOSvar and EOScalc both return numeric values. EOScoeffs returns a data frame.

Details

EOSregress uses lm to regress the experimental heat capacity or volume data in exptdata, which is a data.frame with columns T (temperature in degrees Kelvin), P (pressure in bars), and Cp or V (heat capacity in cal/mol.K or volume in cm3/mol). Only data below the temperature of T.max are included in the regression. The regression formula is specified by a vector of names in var; these names correspond to variables identified below:

ll{ T $T$ (temperature) P $P$ (pressure) TTheta $(T-\Theta)$ ($\Theta$ = 228 K) invTTheta $1/(T-\Theta)$ TTheta2 $(T-\Theta)^2$ invTTheta2 $1/(T-\Theta)^2$ V $V$ (volume of water) E $E$ (isobaric expansivity of water) kT $\kappa_T$ (isothermal compressibility of water) alpha $\alpha$ (coefficient of isobaric expansivity of water) beta $\beta$ (coefficients of isothermal compressibility of water) X $X$ (Born function $X$) Q $Q$ (Born function $Q$) TX $TX$ (temperature times $X$) drho.dT $d\rho/dT$ (temperature derivative of density of water) V.kT $V\kappa_T$ (volume times isothermal compressibility of water) }

EOSvar takes as input var (one of the names of the variables listed above), and T (temperature in degrees Kelvin), P (pressure in bars). It returns the value of the variable at the specified temperature-pressure condition(s). This function is used by EOSregress to get the values of the variables used in the regression.

EOScalc calculates the predicted heat capacities or volumes using coefficients provided by the result of EOSregress, at the temperatures and pressures specified by T and P.

EOSplot takes a table of data in exptdata, runs EOSregress and EOSpred and plots the results. The experimental data are plotted as points, and the calculated values as a smooth line. The point symbols are filled circles where the calculated value is within 10% of the experimental value; open circles otherwise.

EOSlab produces labels for the variables listed above that can be used as.expressions in plots. The value of coeff is prefixed (using substitute) to the name of the variable.

EOScoeffs retrieves coefficients in the Helgeson-Kirkham-Flowers equations from the thermodynamic database (thermo$obigt) for the given aqueous species. If the property is Cp, the resulting dataframe has column names of (Intercept), invTTheta2 and TX, respectively holding the coefficients $c_1$, $c_2$ and $\omega$ in equation $Cp^\circ = c_1 + c_2/(T-\Theta)^2 + {\omega}TX$. If the property is V, the data frame has column names of (Intercept), invTTheta and Q, respectively holding the coefficients $\sigma$, $\xi$ and $-\omega$ in $V^\circ = \sigma + \xi/(T-\Theta) - {\omega}Q$.

The motivation for writing these functions is to explore alternatives or possible modifications to the revised Helgeson-Kirkham-Flowers equations applied to aqueous nonelectrolytes. As pointed out by Schulte et al., 2001, the functional forms of the equations do not permit retrieving values of the solvation parameter ($\omega$) that closely represent the observed trends in both heat capacity and volume at high temperatures (above ca. 200 degrees C).

References

Schulte, M. D., Shock, E. L. and Wood, R. H. (1995) The temperature dependence of the standard-state thermodynamic properties of aqueous nonelectrolytes. Geochim. Cosmochim. Acta 65, 3919--3930. http://dx.doi.org/10.1016/S0016-7037(01)00717-7

See Also

See lm for the details of the regression calculations.

Examples

Run this code
data(thermo)
  ## regress experimental heat capacities of CH4
  ## using revised Helgeson-Kirkham-Flowers equations
  # read the data from Hnedkovsky and Wood, 1997
  f <- system.file("extdata/cpetc/Cp.CH4.HW97.csv", package="CHNOSZ")
  d <- read.csv(f)
  # have to convert J to cal and MPa to bar
  d$Cp <- convert(d$Cp, "cal")
  d$P <- convert(d$P, "bar")
  # specify the terms in the HKF equations
  var <- c("invTTheta2", "TX")
  # perform regression, with a temperature limit
  EOSlm <- EOSregress(d, var, T.max=600)
  # the result is within 10% of the accepted
  # values of c1, c2 and omega for CH4(aq)
  CH4coeffs <- EOScoeffs("CH4", "Cp")
  dcoeffs <- EOSlm$coefficients - CH4coeffs
  stopifnot(all(abs(dcoeffs/CH4coeffs) < 0.1))
  ## make plots comparing the regressions
  ## here with the accepted EOS parameters of CH4
  par(mfrow=c(2,2))
  EOSplot(d, T.max=600)
  title("Cp of CH4(aq), fit to 600 K")
  legend("bottomleft", pch=1, legend="Hnedkovsky and Wood, 1997")
  EOSplot(d, coefficients=CH4coeffs)
  title("Cp from EOS parameters in database")
  EOSplot(d, T.max=600, T.plot=600)
  title("Cp fit to 600 K, plot to 600 K")
  EOSplot(d, coefficients=CH4coeffs, T.plot=600)
  title("Cp from EOS parameters in database")

  ## model experimental volumes of CH4
  ## using HKF equation and an exploratory one
  f <- system.file("extdata/cpetc/V.CH4.HWM96.csv", package="CHNOSZ")
  d <- read.csv(f)
  d$P <- convert(d$P, "bar")
  # the HKF equation
  varHKF <- c("invTTheta", "Q")
  # alpha is the expansivity coefficient of water
  varal <- c("invTTheta", "alpha")
  par(mfrow=c(2,2))
  # for both HKF and the expansivity equation
  # we'll fit up to a temperature limit
  EOSplot(d, varHKF, T.max=663, T.plot=625)
  legend("bottomright", pch=1, legend="Hnedkovsky et al., 1996")
  title("V of CH4(aq), HKF equation")
  EOSplot(d, varal, T.max=663, T.plot=625)
  title("V of CH4(aq), expansivity equation")
  EOSplot(d, varHKF, T.max=663)
  title("V of CH4(aq), HKF equation")
  EOSplot(d, varal, T.max=663)
  title("V of CH4(aq), expansivity equation")
  # note that the volume regression using the HKF gives
  # a result for omega (coefficient on Q) that is
  # not consistent with the high-T heat capacities

Run the code above in your browser using DataLab