| Next|| Previous || Top |

RATES

This keyword data block is used to define mathematical rate expressions for kinetic reactions. General rate formulas are defined in the RATES data block and specific parameters for batch-reaction or transport kinetics are defined in KINETICS data blocks.

Example data block

Line 0: RATES 
Line 1a:     Calcite
Line 2a:     -start
Basic: 1   rem M = current number of moles of calcite
Basic: 2   rem M0 = number of moles of calcite initially present
Basic: 3   rem PARM(1) = A/V, cm^2/L 
Basic: 4   rem PARM(2) = exponent for M/M0
Basic: 10  si_cc = SI("Calcite")
Basic: 20  if (M <= 0 and si_cc < 0) then goto 200
Basic: 30    k1 = 10^(0.198 - 444.0 / TK )
Basic: 40    k2 = 10^(2.84 - 2177.0 / TK)
Basic: 50    if TC <= 25 then k3 = 10^(-5.86 - 317.0 / TK )
Basic: 60    if TC > 25 then k3  = 10^(-1.1 - 1737.0 / TK )
Basic: 70    t = 1
Basic: 80    if M0 > 0 then t = M/M0
Basic: 90    if t = 0 then t = 1
Basic: 100   area = PARM(1) * (t)^PARM(2)
Basic: 110   rf = k1*ACT("H+")+k2*ACT("CO2")+k3*ACT("H2O")
Basic: 120   rem 1e-3 converts mmol to mol
Basic: 130   rate = area * 1e-3 * rf * (1 - 10^(2/3*si_cc))
Basic: 140   moles = rate * TIME
Basic: 200 SAVE moles
Line 3a:     -end
Line 1b:     Pyrite
Line 2b:     -start
Basic: 1   rem  PARM(1) = log10(A/V, 1/dm)
Basic: 2   rem  PARM(2) = exp for (M/M0)
Basic: 3   rem  PARM(3) = exp for O2
Basic: 4   rem  PARM(4) = exp for H+
Basic: 10  if (M <= 0) then goto 200
Basic: 20  if (SI("Pyrite") >= 0) then goto 200
Basic: 30    lograte = -10.19 + PARM(1) + PARM(2)*LOG10(M/M0)
Basic: 40    lograte = lograte + PARM(3)*LM("O2") + PARM(4)*LM("H+")
Basic: 50    moles = (10^lograte) * TIME
Basic: 60    if (moles > M) then moles = M
Basic: 200 SAVE moles
Line 3b:     -end

Explanation

Line 0: RATES

RATES is the keyword for the data block. No other data are input on the keyword line.

Line 1: name of rate expression

name of rate expression --Alphanumeric character string that identifies the rate expression, no spaces are allowed.

Line 2: -start

-start--Identifier marks the beginning of a Basic program by which the moles of reaction for a time subinterval are calculated. Optional.

Basic: numbered Basic statement

numbered Basic statement --A valid Basic language statement that must be numbered. The statements are evaluated in numerical order. The sequence of statements must extrapolate the rate of reaction over the time subinterval given by the internally defined variable TIME. The last statement must be " SAVE expression ", where the value of expression is the moles of reaction that occur during time subinterval TIME. Statements and functions that are available through the Basic interpreter are listed in tables 8 and 9. Parameters defined in the KINETICS data block are also available through the array PARM.

Line 2: -end

-end--Identifier marks the end of a Basic program by which the number of moles of a reaction for a time subinterval is calculated. Note the hyphen is required to avoid a conflict with the keyword END.

Notes

A Basic interpreter (David Gillespie, Synaptics, Inc., San Jose, CA, written commun., 1997) distributed with the Linux operating system (Free Software Foundation, Inc.) is embedded in PHREEQC. The Basic interpreter is used during the integration of the kinetic reactions to evaluate the moles of reaction progress for a time subinterval. A Basic program for each kinetic reaction must be included in the input or database file. Each program must stand alone with its own set of variables and numbered statement lines. No data is passed between rate programs and there is no conflict using the same variable names or line numbers in separate rate programs. However, it is possible to transfer data among rates with the special Basic statements PUT and GET (see table 8). The programs are used to calculate the instantaneous rate of reaction and extrapolate that rate for a time subinterval given by the variable "TIME" (examples: calcite, line 140; pyrite line 50). TIME is a fraction of the time step that is defined in the KINETICS (for batch reactions), ADVECTION, or TRANSPORT data blocks. The total moles of reaction must be returned to the main program with a SAVE command (line 200 in each example). Note that not the rate, but the moles of reaction are returned, counted positive when the solution concentration of the reactant increases.

The first example estimates the rate of calcite dissolution or precipitation on the basis of a rate expression from Plummer and others (1978) as derived in equations 101 and 106. The forward rate is given by

, (155)

where brackets indicate activity and , , and are functions of temperature (Plummer and others, 1978). In a pure calcite-water system with fixed , the overall rate for calcite (forward rate minus backward rate) is approximated by

Table 6. --Description of Basic program for calcite kinetics given in example for RATES data block

Line
number

Function

1-4

Comments.

10

Calculate calcite saturation index.

20

If undersaturated and no moles of calcite, exit; moles=0 by default.

30-60

Calculate temperature dependence of constants k1, k2, and k3.

70-90

Calculate ratio of current moles of calcite to initial moles of calcite, set ratio to 1 if no moles of calcite are present.

100

Calculate surface area.

110

Calculate forward rate.

130

Calculate overall rate, factor of 1e-3 converts rate to moles from millimoles.

140

Calculate moles of reaction over time interval given by TIME. Note that the multiplication of the rate by TIME must be present in one of the Basic lines.

200

Return moles of reaction for time subinterval with "SAVE". A SAVE statement must always be present in a rate program.

, (156)

where is mmol cm -2 s -1 . Equation 156 is implemented in Basic for the first example above. Explanations of the Basic lines for this rate expression are given in table 6.

Table 7. --Description of Basic program for pyrite dissolution kinetics given in example for RATES data block

Line
number

Function

1-4

Comments.

10

Checks that pyrite is still available, otherwise exits with value of moles=0 by default.

20

Checks that the solution is undersaturated (the rate is for dissolution only), otherwise exits with value of moles=0.

30, 40

Calculate log of the rate of pyrite dissolution.

50

Calculate the moles of pyrite dissolution over time interval given by TIME.

60

Limits pyrite dissolution to remaining moles of pyrite.

200

Return moles of reaction for time subinterval with SAVE. A SAVE statement must always be present in a rate program.

The second example is for the dissolution of pyrite in the presence of dissolved oxygen from Williamson and Rimstidt (1994):

(157)

where parentheses indicate molality. This rate is based on detailed measurements in solutions of varying compositions and shows a square root dependence on the molality of oxygen and a small dependence on pH. This rate is applicable only for dissolution in the presence of oxygen and will be incorrect near equilibrium when oxygen is depleted. Explanations of the Basic lines for this rate expression are given in table 7.

Some special statements and functions have been added to the Basic interpreter to allow access to quantities that may be needed in rate expressions. These functions are listed table 8 and the Basic statements that are implemented in the interpreter are listed in table 9. Upper or lower case (case insensitive) may be used for statement, function, and variable names. String variable names must end with the character "$".

Table 8. --Special Basic statements and functions for PHREEQC

Special PHREEQC
Statement or Function

Explanation

ACT("HCO3-")

Activity of an aqueous, exchange, or surface species.

ALK

Alkalinity of solution.

CELL_NO

Cell number in TRANSPORT or ADVECTION calculations

CHARGE_BALANCE

Aqueous charge balance in equivalents.

DIST

Distance to midpoint of cell in TRANSPORT calculations, cell number in ADVECTION calculations, "-99" in all other calculations.

EQUI("Calcite")

Moles of a phase in the pure-phase (equilibrium-phase) assemblage.

EXISTS( i1 [ , i2, ... ])

Determines if a value has been stored with a PUT statement for the list of one or more subscripts.The function equals 1 if a value has been stored and 0 if no value has been stored. Values are stored in global storage with PUT and are accessible by any Basic program. See description of PUT for more details.

GAS("CO2(g)")

Moles of a gas component in the gas phase.

GET( i1 [ , i2, ... ])

Retrieves the value that is identified by the list of one or more subscripts.Value is zero if PUT has not been used to store a value for the set of subscripts. Values stored in global storage with PUT are accessible by any Basic program. See description of PUT for more details.

KIN("CH2O")

Moles of a kinetic reactant.

LA("HCO3-")

Log10 of activity of an aqueous, exchange, or surface species.

LM("HCO3-")

Log10 of molality of an aqueous, exchange, or surface species.

M

Current moles of reactant for which the rate is being calculated (see KINETICS).

M0

Initial moles of reactant for which the rate is being calculated (see KINETICS).

MISC1("Ca(x)Sr(1-x)SO4")

Mole fraction of component 2 at the beginning of the miscibility gap, returns 1.0 if there is no miscibility gap (see SOLID_SOLUTIONS).

MISC2("Ca(x)Sr(1-x)SO4")

Mole fraction of component 2 at the end of the miscibility gap, returns 1.0 if there is no miscibility gap (see SOLID_SOLUTIONS).

MOL("HCO3-")

Molality of an aqueous, exchange, or surface species.

MU

Ionic strength of the solution.

PARM( i )

Parameter array defined in KINETICS data block.

PERCENT_ERROR

Percent charge-balance error [100(cations-|anions|)/(cations + |anions|)].

PRINT

Write to output file.

PUNCH

Write to selected-output file.

PUT( x , i1 [ , i2, ... ])

Saves value of x in global storage that is identified by a sequence of one or more subscripts. Value of x can be retrieved with GET( i1, [ , i2, ... ]) and a set of subscripts can be tested to determine if a value has been stored with EXISTS( i1 [ , i2, ... ]). PUT may be used in RATES, USER_PRINT, or USER_PUNCH Basic programs to store a value. The value may be retrieved by any of these Basic programs. The value persists until overwritten using a PUT statement with the same set of subscripts, or until the end of the run. For a KINETICS data block, the Basic programs for the rate expressions are evaluated in the order in which they are defined in the input file.

RXN

Amount of reaction (moles) as defined in -steps in REACTION data block for a batch-reaction calculation, otherwise zero.

SAVE

Last statement of Basic program that returns the moles of kinetic reactant, counted positive when the solution concentration of the reactant increases.

SI("Calcite")

Saturation index of a phase, .

SIM_NO

Simulation number, equals one more than the number of END statements before current simulation.

SIM_TIME

Time (s) from the beginning of a kinetic batch-reaction or transport calculation.

SR("Calcite")

Saturation ratio of a phase, .

STEP_NO

Step number in batch-reaction calculations, or shift number in ADVECTION and TRANSPORT calculations.

S_S("MgCO3")

Current moles of a solid-solution component.

TC

Temperature in Celsius.

TK

Temperature in Kelvin.

TIME

Time interval for which moles of reaction are calculated in rate programs, automatically set in the time-step algorithm of the numerical integration method.

TOT("Fe(2)")

Total molality of element or element redox state. TOT("water") is total mass of water (kg).

TOTAL_TIME

Cumulative time (s) including all advective (for which -time_step is defined) and advective-dispersive transport simulations from the beginning of the run or from last -initial_time identifier.

The PRINT command in Basic programs is useful for debugging rate expressions. It can be used to write quantities to the output file to check that rates are calculated correctly. However, the PRINT command will write to the output file every time a rate is evaluated, which may be many times per time step. The sequence of information from PRINT statements in RATES definitions may be difficult to interpret because of the automatic time-step adjustment of the integration method.

Table 9. --Standard Basic statements and functions

[Character variables in Basic have "$" as the final character of the variable name]

Basic Statements and
Functions

Explanation

+, -, *, /

Add, subtract, multiply, and divide.

string1 + string2

String concatenation

a ^ b

Exponentiation, .

<, >, <=, >=, <>, =,

AND, OR, XOR, NOT

Relational and Boolean operators.

ABS( a )

Absolute value.

ARCTAN( a )

Arctangent function.

ASC( character )

Ascii value for character.

CHR$( number )

Convert Ascii value to character.

COS( a )

Cosine function.

DIM a ( n )

Dimension an array

DATA list

List of data.

EXP( a )

.

FOR i = n TO m STEP k

NEXT i

"For" loop.

GOTO line

Go to line number.

GOSUB line

Go to subroutine.

IF ( expr ) THEN statement ELSE statement

If, then, else statement (on one line; a `\' may be used to concatenate lines).

LEN( string )

Number of characters in string.

LOG( a )

Natural logarithm.

LOG10( a )

Base 10 logarithm.

MID$( string, n )

MID$( string, n, m )

Extract characters from position n to end of string.

Extract m characters from string starting at position n .

a MOD b

Returns remainder a / b .

ON expr GOTO line1 , line2 , ...

ON expr GOSUB line1 , line2 , ...

If the expression's value, rounded to an integer, is N , go to the N th line number in the list. If N is less than one or greater than the number of line numbers listed, execution continues at the next statement after the ON statement.

READ

Read from DATA statement.

REM

At beginning of line, line is a remark with no effect on the calculations.

RESTORE line

Set pointer to DATA statement of line for subsequent READ.

RETURN

Return from subroutine.

SGN( a )

Sign of a , +1 or -1.

SIN( a )

Sine function.

SQR( a )

a 2 .

SQRT( a )

.

STR$( a )

Convert number to a string.

TAN( a )

Tangent function.

VAL( string )

Convert string to number.

WHILE ( expression )

WEND

"While" loop.

Example problems

The keyword RATES is used in example problems 6C, 9 and 15.

Related keywords

ADVECTION, KINETICS, and TRANSPORT.


| Next|| Previous || Top |