chemsolve: Mass balance and charge solver

Description Usage Arguments Details Value Examples

View source: R/chemsolve.R

Description

Mass balance and charge balance solver for chemical equilibria at 0.5 kb. This is a wrapper function for chemsolve_generic and prods.

Usage

1
2
3
4
chemsolve(Tc = 400, Nat = 0.4, Kt = 0.2, Clt = 0.6, SO4t = 0.2,
  Cat = 0.1, Mgt = 0.1, start = c(1e-06, 1e-05, 0.3, 0.1, 0.3, 0.01,
  0.001, 0.02), maxitr = 100, exprod = NULL, exconstit = NULL,
  exnumz = NULL, excharges = NULL, exa = NULL, exK = NULL, bal = "Cl")

Arguments

Tc

Temperature (degrees C - between 300 and 400)

Nat

Sodium concentration (mol/kg); total

Kt

Potassium (mol/kg); total

Clt

Chloride (mol/kg); total

SO4t

Sulphate (mol/kg); total

Cat

Calcium (mol/kg); total

Mgt

Magnesium (mol/kg); total

start

Initial guess for the calculated equilbrium concentrations of the basis species (in the order of H+, OH-, Na+, K+, Cl-, SO42+, Ca2+, Mg2+).

maxitr

Maximum number of iterations

exprod

A vector of the names of the additional complex(es)

exconstit

A vector of the chemical symbol names of the the basis species that are constitute each of the the additional complexes

exnumz

A vector of the stiochiometry given by the equilibrium reaction for each of the additional complexes

excharges

A vector of the charge of the additional complex species

exa

A vector of the ion size parameters for the complexes of the additional complex species

exK

A vector of the log K of the dissociation constants of the additional complex species

bal

Species to balance against (Defaults to Cl, can also be set to NULL for none)

Details

A wrapper for the chemsolve_generic function that allow easy addition of product species. Use the generic function (chemsolve_generic) if new basis species need to be added or if the log K/temperature range is extended (up or down).
Normally total moles anions = total moles cations. The charge balance (without any speciation) is adjusted to zero by balancing against Cl- (default) as otherwise the calculation can be too sensitive to H+. The balancing species can be easily changed to any of the other basis species (or none).
Choose reasonable starting values; for H+, OH- and equilibrium concentrations of the basis species.
If negative concentrations are calculated, choose better initial starting values.
If bal = NULL and a large excess of chloride (or sulphate) is present this will simulate the addition of acid HCl. In this case use a higher starting concentration of H+.
To exclude a basis value set the basis concentration to zero and the concentrations of this and the derived species will be vanishing small and can be ignored. In the generic version of the program the basis species are simply left out.
The basis species are: Na+, K+, Mg2+, Ca2+, Cl-, SO42-. The default complexes are: NaCl°, KCl°, HCl°, KOH°, NaOH°, KSO4-, NaSO4-,HSO4-,CaSO4°,MgSO4°, MgCl+,CaCl+,CaCl2°,MgOH+,CaOH+. Additional complexes based on the existing basis species can easily be added (see example below).
To set up a problem in chemsolve or chemsolve_generic it is relatively trivial to set up and manipulate a sequence of commands in Excel and cut and past into R. Complex dissociation constants (log K) are from SupCrt 92 slop98.dat http://geopig.asu.edu/?q=tools
The Debye_Hückel parameters (A, B) equations are polynomial fits to data at 0.5 kb from tables in Helgeson & Kirkham (1974).
Note Bdot is not used.
Helgeson H. C. and Kirkham D. H. (1974) Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures: II. Debye-Hückel parameters for activity coefficients and relative partial molar properties American Journal of Science 274, 1199-1261.

Value

A list containing the concentrations, activity coefficients, and pH at equilibrium

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Add KHSO4° as an additional complex given the existing list of basis species and 
## calculate the equilibrium concentrations and pH at 400°C.
chemsolve(exprod =  c("KHSO4"), exconstit = c("K", "H", "SO4"),
exnumz =  c(3), excharges =  c(0), exa =  c(0),  exK =  c(-8.701), bal = "Cl")
## Determine the equilibria at a range of temperatures. 
## Additional complexes can be added per the previous example.
temps <- seq(300,400,10) #A vector of temperatures repeating every 10 degrees from 300 to 400
## Na concentration is changed slightly from the default. Further parameters can be added.
r <- lapply(temps,chemsolve,Nat=0.45) #Creates a list of the results
r[[1]] #Display results from first temperature
r[[10]] #Display the results of the 10th temperature

shearwavesplitter/EqSolvR documentation built on Feb. 5, 2020, 1:51 a.m.