BEM (Batch Equilibrium Model)

— model and program reference

Jürgen Prenzel Institute for Soil Science and Forest Nutrition Göttingen

program version 6 (unix)

Contents

1 Introduction 1

2 Chemical and mathematical definitions of model concepts 2 2.1 Single Equilibria . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2 Sequences of equilibria . . . . . . . . . . . . . . . . . . . . . . 5

3 The input files 5

3.1 m–files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.1 Chemical structures and thermodynamic parameters . 6 3.1.2 Size of the system and amounts of chemicals . . . . . 8 3.1.3 Defining a starting point . . . . . . . . . . . . . . . . . 9 3.1.4 Miscellaneous technical specifications . . . . . . . . . . 10

3.2 t–files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2.1 Specification of experimental steps . . . . . . . . . . . 11

4 Calling BEM 12

5 The output files 13 5.1 The results file name.r . . . . . . . . . . . . . . . . . . . . . 13

6 Program availability and installation 15

1 Introduction

BEM is a software for the calculation of coupled chemical equlibria. It has been designed to investigate models of soils and aquifers. The processes that may be included comprise acid / base reactions, complexation, dissolution / precipitation of salts, cation exchange and the solubility of carbon dioxide. Redox reactions are not included.

The program considers one or several reaction cells. In each cell the total concentrations of all reacting elements determine the equilibrium that BEM has to calculate. A dynamic change will result if in subsequent steps the total concentrations of one or more element changes. BEM includes several ways in which such change may be defined. A typical example is a titration experiment. But the dynamic is confined to sequences of equilibira. Reaction kinetics is not included.

Version 6 of BEM is newly designed. The programming language is now C. All input and output files have new formats. Older models can not be used directly. But there is a utilitiy program m5tom6 (written in perl) that translates older model files to the new format.

Section 2 defines the concepts that are the building blocks ready in BEM for use in specific models.

The user of BEM has to prepare one or more input files that specify the model he/she wants to run. The syntax of these files is explained in section 3.

2 Chemical and mathematical definitions of model concepts

2.1 Single Equilibria

The system for which a thermodynamic equilibrium is to be calculated is called a cell. Each cell has an aqueous liquid phase where θ defines the volume of liquid per cell (in L). It may also contain a mass of ρ kg in the solid phase and a volume of σ L as gas phase.

The basic chemical entities from which all reaction products may be formed are called elements. These elements are not necessarily chemical elements proper. Typically they are ions like Na^{+}or SO_{4}^{2−}.

Let 𝔼 be the set of elements. For each element i ∈ 𝔼 we denote its charge as z_{i}, its concentration in the liquid phase (in mol L^{−1}) as c_{i}, and its activity coefficient there as γ_{i}. It is assumed that c_{i} > 0 for all elements.

The elements H^{+} and OH^{−} are always included and it is assumed that the equilibrium equation

c_{H^{+}}γ_{H^{+}}c_{OH^{−}}γ_{OH^{−}} = K_{W}  (1)

holds.

Let 𝕃 be the set of complexes that are assumed to form in the liquid phase from the elements i ∈ 𝔼. Their concentrations in mol L^{−1}are denoted as c_{j} and their activity coefficients as γ_{j}. Each complex j ∈ 𝕃 is defined by a stoichiometric vector

l_{j} = (l_{ij}) i ∈ 𝔼

where l_{ij} is 0 for all elements which are not part of the complex. Acids are treated as complexes between H^{+} and their conjugated bases.

The equilibrium condition for the formation of a complex j ∈ 𝕃 then is

\frac{∏_{i∈𝔼}(c_{i}γ_{i})^{l_{ij}}}{c_{j}γ_{j}} = K_{j}  (2)

where K_{j} is the stability constant of k.

The ionic charge of a complex is z_{j} = ∑_{i∈𝔼}z_{i}l_{ij}. For the solution phase

the charge balance

0 = ∑_{i∈𝔼}z_{i}c_{i} + ∑_{j∈𝕃}z_{j}c_{j}  (3)

is imposed.

For species in the liquid phase m ∈ 𝔼 ∪ 𝕃 activity coefficients are calculated from the Davies’ equation

log_{10} γ_{m} = −0.5 z_{m}^{2} (\frac{\sqrt{I}}{1 + \sqrt{I}} − 0.3I)  (4)

where

I = 0.5 (∑_{i∈𝔼}z_{i}^{2}c_{i} + ∑_{j∈𝕃}z_{j}^{2}c_{j})

Let 𝕊 be the set of salts that may be present in the system. We denote the concentration of a salt k ∈ 𝕊 in the solid phase (in mol kg^{−1}) by c_{k}. A salt is defined by a stoichiometric vector in the same manner as a complex

s_{k} = (s_{ik}) i ∈ 𝔼

The ion activity product of a salt k ∈ 𝕊 is

Q_{k} = ∏_{i∈𝔼}(c_{i}γ_{i})^{s_{ik}}

The equilibrium condition for a salt then is, that either of two conditions must be true

(Q_{k} < K_{k} and c_{k} = 0)

or

(Q_{k} = K_{k} and c_{k} > 0)

(5) where K_{k} is the solubility product of k. Normally K_{k} is considered dependend on temperature and pressure but not on the amount and composition of the salt phase. In BEM it is possible to set

K_{k} = f(c_{k})

where f is a smooth function. The actual form of f is described below (section 3.1.1). f is called a solubility product function.

If a cation exchanger is present it is assumed that simple (uncomplexed) cations compete for the exchanger, but not cationic complexes. We denote the cation exchange capacity (in mol_{c} kg^{−1}) by t_{x} and the saturation by cation n by x_{n} where

∑_{n∈𝔼, z_{n}>0}x_{n} = 1  (6)

It is assumed that the exchange equilibrium is described by a set of selectivity coefficients

\frac{(c_{n}γ_{n})^{1/z_{n}} x_{H^{+}}}{(c_{H^{+}}γ_{H^{+}}) x_{n}} = K_{n}  (7)

where n ∈ 𝔼, z_{n} > 0, n ≠ H^{+} and K_{n} describes the equilibrium of the exchange of n against H^{+}.

The gas CO_{2} may be part of the chemical system. In this case the element CO_{3}^{2−} and its complex H_{2}CO_{3} must be defined for the liquid phase. The partial pressure (in bar) in the gas phase then is

P_{CO_{2}} = c_{H_{2}CO_{3}}/K_{H}  (8)

where K_{H} is the Henry constant for CO_{2}.

For each element, except for H^{+} and OH^{−}, there is an element balance

θ c_{i} + θ ∑_{j∈𝕃}l_{ij}c_{j} + ρ ∑_{k∈𝕊}s_{ik}c_{k} + (ρ x_{i} t_{x}/z_{i})_{z_{i}>0} = t_{i}  (9)

where i ∈ 𝔼\{H^{+}, OH^{−}} and t_{i} is the total amount of i (in mol) that is present in the cell.

If CO_{2} is considerd Eq. 9 is replaced by

θ c_{i} + θ ∑_{j∈𝕃}l_{ij}c_{j} + ρ ∑_{k∈𝕊}s_{ik}c_{k} + \frac{P_{CO_{2}} σ}{R T} = t_{i}  (9a)

where i = CO_{3}^{2−}, R is the gas constant and T the temperature.

It is possible to define an open system for CO_{2}. In this case there is no finite t_{CO_{3}} and Eq. 9a is replaced by

c_{H_{2}CO_{3}} = P_{CO_{2}} K_{H}  (9b)

Eq. 1 to 9 define the system of equations that has to be solved by BEM. The principal unknowns are the c_{i}, c_{j}, c_{k}, and x_{n} that appear in Eq. 9. All other variables may be considered model parameters. A set of values of the parameters determines the values of the unknowns for one particular equilibrium in one cell.

2.2 Sequences of equilibria

BEM can simulate chemical changes. This is achieved by calculating sequences of equilibria for given cells. The change is brought about by changes in parameters, mainly by changes in the total amount t_{i} that appear in Eq.

9. These changes are calculated asynchronously or decoupled from the equilibrium calculation. First an equilibrium is calculated. The results are used in the calculation of paramter changes and from that state a new equilibrium is calculated. This simple scheme is the reason for calling the program a batch equilibrium model. It resembles a procedure where a batch of chemicals is brought into a reaction vessel and allowed to react to equilibrium.

There are several ways in which BEM can calculate parameter changes. The most simple form simulates the addition of certain chemicals to the system. Another form is titration where a certain volume of solution with a known composition is added. It is also possible to remove a certain volume of solution after equilibration.

It is possible to consider several reaction cells simultaneously. In this case the solution output of one cell may be defined as input to another cell. With this feature soil columns can be simulated as sequence of mixing cells.

These possibilities will be described in detail below in section 3.2.

3 The input files

The definitions of particular models are submitted to BEM via one or several files. These are either m– or t–files, where m stands for model and t stands for titration or transport. M–files define single reaction cells with one single equilibrium. T–files define sequences of equilibria and networks of reaction cells. T–files make reference to one or several m–files.

The files are composed of lines, which in turn are composed of words. Words are seperated by one or more blank spaces. In the following description typescript indicates text that has to be written as shown or presents an explicit example. Italics indicate variable names. Variables have to be replaced by specific text.

The first word in a line specifies its type. Most line types can be repeated with additional specifications. If the description of a line ends in ⋯ this means that the pairs of variables and values on this line type may be put in any order on one or several lines of the same type.

The letter p indicates negative base 10 logarithm: pK = − log_{10}(K).

Lines starting with an “∗” are regarded as comments. Blank lines are also ignored.

3.1 m–files

In m–files the order of lines is not significant.

3.1.1 Chemical structures and thermodynamic parameters

elt–lines define the elements of the system

elt name charge

where name is the name of the element and charge is its ionic charge. name may consist of letters and numbers without intervening spaces. The case of the letters is significant where an element is referenced in other statements. The elements H (=H^{+}) and OH (=OH^{−}) are automatically defined and must not be defined by elt–lines.

cpl–lines define complexes.

cpl (e_{1})l_{1}(e_{2})l_{2} ⋯ (e_{n})l_{n} pK

where n is the number of components of the complex, e_{i} are element names and l_{i} are the corresponding stoichiometric coefficients. If l_{i} = 1, it may be omited. The parentheses around element names are mandatory. K is the stability constant, that is the equilibrium constant for the complete dissociation of the complex into the elements (Eq. 2). In case of multiproctic acids this differs from the usual notion of acidity constants which describe stepwise dissociation.

slt–lines define salts.

slt (e_{1})s_{1}(e_{2})s_{2} ⋯ (e_{n})s_{n} pK

where n is the number of components of the salt , e_{i} are element names and s_{i} are the corresponding stoichiometric coefficients. If s_{i} = 1, it may be omited. The parentheses around element names are mandatory. There may be no net charge of the salt. K is the solubility product constant for the salt (Eq. 5). The definition of a salt does not mean that it must be present in the system. The system may be undersaturated with respect to the salt.

If a solubility product function is to be used one has to write

slt (e_{1})s_{1}(e_{2})s_{2} ⋯ (e_{n})s_{n} spfun typ p_{1} p_{2} ⋯

where typ denotes the type of the function and the p_{i} are function parameters.

If typ = 1 we have pK = f(Δ_{S}) where Δ_{S} is the change of the concentration of the salt relative to the concentration specified in a cslt0–line (see section 3.1.2), and

f(x) = p_{1} + p_{2} e^{p_{3} x}

If typ = 2 we have pK = f(Δ_{S}) where Δ_{S} is the change of the concentration of the salt relative to the concentration specified in a cslt0–line (see section 3.1.2), and

f(p_{1}) = p_{2}, \frac{df}{dx}(p_{1}) = p_{3}, f(p_{4}) = p_{5}, \frac{df}{dx}(p_{4}) = p_{6}

Between p_{1} and p_{4} f is a cubic polynomial, outside of this interval it is linear.

A cation exchanger can be defined either directly or indirectly. A direct definition is accomplished by

xpksel e_{1} pK_{1} e_{2} pK_{2} ⋯

where e_{i} are the names of cationic elements, and K_{i} are the selectivity coefficents for exchange of e_{i} against H^{+} (Eq. 7). One pK must be supplied for each cationic element except H^{+}.

An indirect definition is written as combination of xeql– and xeqs–lines.

xeql istr I pH pH e_{1} c_{1} e_{2} c_{2} ⋯ xeqs H e_{1} q_{1} e_{2} q_{2} ⋯

where I, pH and c_{i} are the ionic strength, the pH, and concentrations of cations respectively. The concentrations (in μmol L^{−1}) must be supplied for the uncomplexed forms of all cationic elements excluding H^{+}. The specifications represent a hypothetical solution in equilibrium with the cation exchanger. q_{i} are cation concentrations in the exchanger (in mmol_{c} kg^{−1}) that would be in equilibrium with the solution defined by the xeql–lines. The xeqs–line defines the cation exchange capacity and xeql– and xeqs–lines together define the selectivity coefficients. One c_{i} must be supplied for each cationic element except H^{+} and one q_{i} must be supplied for each cationic element including H^{+}.

The specifications on xeql– and xeqs–lines may or may not represent the equilibrium that is actually calculated by BEM. If xeqs– and xeql–lines are used, a xpksel–line must not be used and vice versa.

If CO_{2} is to be included the following line is specified

     gas  CO2 pK

where K is the Henry constant (Eq. 8). A complete definition of the CO_{2}/H_{2}O system requires 4 lines like

     gas CO2 1.5
     elt CO3 -2
     cpl (H)(CO3) 10.3
     cpl (H)2(CO3) 16.7

where the thermodynamic constants may vary with temperature and source of data.

The dissociation constant of water is specified by

     pkw pK

where K is the constant K_{W} (Eq. 1). If this line is omitted, a default value of pK = 14 is used.

3.1.2 Size of the system and amounts of chemicals

Some specifications are combined on vls–lines.

vls name_{1} value_{1} name_{2} value_{2} ⋯

The size of the three phases of one reaction cell is specified as follows:

     vls   theta0 theta0 rho rho sigma sigma

where theta0 is the amount of solution in this cell for the first equilibrium. θ may change later if solution is added or removed. rho is the amount of solid phase in kg and sigma is the amount of gas phase in L in the system. rho and sigma remain constant even if a dynamic series of equilibria is calculated for the cell.

An open system for CO_{2} can be declared by

     vls   PCO2 pco2

where pco2 is the assumed partial pressure of CO_{2} in mbar. The use of this specification requires that a gas–CO2–line is also used.

The total amounts of elements (t_{i} in Eq. 9) are specified to BEM in three different ways: as solution concentrations, as salts, and as cation exchanger composition. It is important to stress that these specifications do not anticipate the equilibrium calculation. They may be thought of as specifications of separate phases (solution, salts, and cation exchanger) from which the system is to be made up.

ctl0–lines specify total element amounts as solution concentrations.

ctl0 e_{1} c_{1} e_{2} c_{2} ⋯

where c_{i} is the concentration (in μmol L^{−1}) of the element e_{i}, which may be any element except H^{+} or OH^{−}. If the charge balance in this specification is not zero the specification is implicitely complemented by H^{+} or OH^{−} to zero charge balance.

cslt0–lines specify total element amount as amount of salts to be added in the initial makeup of the system.

cslt0 s_{1} c_{1} s_{2} c_{2} ⋯

where c_{k} is the concentration (in mmol kg^{−1}) of the salt s_{k}.

If a cation exchanger is specified by a xpksel–line the corresponding cation exchange capacity and its saturation before equilibration with the system are specified by

xs0 cec cec e_{1} x_{1} e_{2} x_{2} ⋯

where cec is the cation exchange capacity in mmol_{c} kg^{−1}and the x_{i} are saturations (Eq. 6) by the corresponding cations e_{i}, which may be any cationic element except H^{+}. If the sum of cations specified is less than cec, a corresponding amount of H^{+}–saturation is assumed. If the sum is larger than cec a corresponding amount of OH^{−} is implicitely assumed to accompany the specified cations.

If the cation exchanger is specified by xeql– and xeqs–lines, the assumed saturation of the exchanger prior to equilibration is the one that is specified by the xeqs–line.

3.1.3 Defining a starting point

BEM uses a numerical optimization procedure to search for an equilibrium state in a multi–dimensional space. It needs a suitable starting point in this space, which is not too far from the equilibrium. The starting point therfore has to be an estimate of the equilibrium that is searched for. The choice of the starting point is often crucial for the success of the numerical procedure but it does not influence the location of the equilibrium point.

The specifications in this section may be omitted. In this case BEM prints a warning and uses default estimates. These may or may not lead to successful convergence of the search procedure.

Three estimates are supplied as follows

     vls   estph pH eststr I estxsh xsh

where pH is an estimate of the equilibrium pH, I is an estimate of the equillibrium ionic strength. If cation exchange is part of the model, xsh is specified as an estimate of the equilibrium saturation fraction of H^{+}.

In

estsng e_{1} c_{1} e_{2} c_{2} ⋯

the c_{i} are estimates (in μmol L^{−1}) for the concentrations of single (uncomplexed) elements e_{i} in the equilibrium solution. e_{i} may be any element except H^{+} or OH^{−}.

In

estslt s_{1} c_{1} s_{2} c_{2} ⋯

estimates (mmol kg^{−1}) are given for the amounts of salts in the equilibrium. It is very important that this estimate is correct with respect to the presence of salts. That means it must be estimated correctly for which s_{k} we have c_{k} = 0. Otherwise the procedure will not find an equilibrium in most cases.

3.1.4 Miscellaneous technical specifications

The specifications in this section may be omitted. Default values will be used in that case.

The solubility equilibrium of a salt does not depend on the amount of salt present (Eq. 5), as long as some salt is present. In its search for an equilibrium BEM uses a virtual amount of salt. Only after an equilibrium is found the real amount of salt is calculated. The virtual amount is called the working point for the salt. It must be large enough to leave some salt undissolved even if a strong tendency to dissoltion is inherent to the overall set of parameters. It must not be too large because the numerical procedure becomes slow if the different components of the element balance for one or more elements are very different in magnitude. BEM has a default mechanism to set the working points. Sometimes it is necessary or sometimes it makes the calculations faster if the user specifies them by

wptslt s_{1} c_{1} s_{2} c_{2} ⋯

where c_{i} is the working point (in mmol kg^{−1}) for salt s_{i}. Values between 1 and 10 have been found to be suitable. There is no stringent rule to this setting. Experimentation may be neccesary.

Run–lines are structured similar to vls–lines

run name_{1} value_{1} name_{2} value_{2} ⋯

Run–lines are used to specify some other technical parameters.

     run   itrace itr it1max it1 it2max it2
     run   relerr rer lsierr ser

itr influences the amount of output that BEM writes on standard output about the progress of the numerical procedure. itr = 0 means no output, itr = 1 means one line for each equilibrium found. itr = 3 or itr = 4 give more output which is designed for diagnostic purposes. The default is itr = 1. If the environment variable BEMLOG is set, this output goes to a file defined by BEMLOG.

it1 and it2 are maximum numbers for iterations. it1 limits iterations for certain intermediate steps and it2 limits the overall iterations for one equilibrium. Defaults are it1 = 5000 and it2 = 250000. The user can enhance these limits but often an equilibrium will not be found by prolonged trials because BEM is not able to solve the problem or the problem is ill defined.

rer defines the maximum allowed error in the equilibrium calculation. This refers to element balances, ionic strength, charge balance (relative to sum of cations), and sum of exchanger saturations. The default is rer = 10^{−6}.

If a the saturation state for a particular salt has to switch from saturation to undersaturation or vice virsa, BEM allows a certain amount of over– or undersaturation before the switch is executed. This is specified by ser in terms of the maximum allowable error in the natural logarithm of the saturation index in Eq. 5. The default is ser = 10^{−3}.

3.2 t–files

In t–files the order of lines is important. They consist of a preamble followed by step blocks. Step blocks contain cell blocks.

The preamble may contain define–lines and put–lines. By

define cell mfile

the t–file references an m–file mfile and gives the name cell to the mixing cell defined in that m–file. Several define–lines are used to reference several cells.

Put–lines define the output to the BEM results file. They are described in section 5.

The preamble ends at the first steps–line.

     steps n

starts a step block and n defines how often this step block is to be repeated. Several step blocks may follow one another in a t–file.

By

     cell cell

a cell block is started. cell refers to a name defined by a define–line in the preamble. In each step block there should be one cell block for each of the cells that have been defined.

3.2.1 Specification of experimental steps

This section describes the lines that may appear in cell blocks. Each specification simulates an operation that changes the total concentrations or other parameters which determine the equilibrium in all cells. They come in effect between calculations of equilibria. This means that calculated equilibrium in step n can influence the equilibrium n + 1. The first equilibrium of each cell is determined by the definitions in its m–file. We call this equilibrium step 0. The first step defined in the t–file uses the results of step 0 to calculate new parameters which lead then to the step 1 equilibrium.

By

ctin e_{1} c_{1} e_{2} c_{2} ⋯ The input of elements is simulated. This input is assumed not to change the volume of solution. c_{i} is an input of element e_{i} in μmol L^{−1}. It is expressed with respect to the liquid phase of the system. c_{i} may be negative, simulating a withdrawal of element e_{i}. e_{i} may be any element except H^{+} or OH^{−}. If the charge balance among the specified concentrations is not zero, the input is imlicitely complemented to zero charge balance by H^{+} or OH^{−}.

By

     vinp vol

an addition of water is simulated. The volume of the liquid phase is increased by vol mL. vol can also be negative when a removal of water is simulated.

By

vinp vol e_{1} c_{1} e_{2} c_{2} ⋯

an input of solution is simulated. The input comes from outside of the system of cells under condsideration. The input is of vol mL with concentrations of c_{i} of element e_{i} in μmol L^{−1}. e_{i} may be any element except H^{+} or OH^{−}. If the charge balance among the specified concentrations is not zero, the input is imlicitely complemented to zero charge balance by H^{+} or OH^{−}.

By

     vout vol

an output of vol mL of equilibrium solution is simulated.

By

vout vol to cell

again an output of vol mL of equilibrium solution is simulated. In this case the output goes to another cell, named cell, of the system of cells under consideration. This feature can be used to simulate a soil column as a chain of mixing cells.

By

     dpgas CO2 dp

the partial pressure of CO_{2} is increased by dp mbar. dp may also be negative.

4 Calling BEM

This section describes how the program BEM is called on a UNIX system.

The necessary input files can be prepared by any editor program (e.g. emacs). m–files should marked by the file extension .m and t–files should be marked by the file extrension .t. BEM puts all output files into the working directory.

M–files can be run by

     bem name.m

If BEM gets as parameter a filename ending in .m it tries to calculate the equilibrium defined in this file and prints the results to standard output. The results are displayed in a tabular format that describes the equilibrium completely.

T–files are invoked by

bem options name.t

In this case BEM will produce an output file name.r that contains the calculated results as specified by put–lines in the t–file.

The following options are recognized

-i Each of the equilibria is recorded in a file name.i for use by later runs of BEM with the -q option.

-p pp runs a preprocessor pp that prepares input files for BEM and then runs BEM.

-q The equilibria recorded in a file name.i are used as starting points for the searches of equilibria. This may result in quicker execution if the earlier run that produced the name.i file and the present one are similar.

-Q like -q option, but the old results are used only for the first equilibrium searched.

-s A tabular output with complete descriptions of each equilibrium is produced and put into the file name.s

5 The output files

5.1 The results file name.r

The format of these files is not suitable for the direkt study by humans but rather for the interpretation by programs. They contain comment lines and data lines. The comments start with #. The comments explain among other things the meaning of the columns in the data lines.

The data lines consist of space separated words. The first two words of each line mark the name of the cell as given in a define–line (p. 11) and the step as defined by the sequence of step blocks (p. 11) in the t–file. The following words display numeric results as defined by the put–lines in the t–file.

     put pH

puts the pH in the results file.

     put sng e

puts the equilibrium concentration (in μmol L^{−1}) of the single (uncomplexed) element e in the results file.

     put ctl e

puts the equilibrium analytical concentration (in μmol L^{−1}) of the element e in the results file. The analytical concentration is the total concentration in the liquid phase, including complexes.

     put cpl c

puts the equilibrium concentration (in μmol L^{−1}) of the complex c in the results file.

     put slt s

puts the equilibrium concentration (in mmol kg^{−1}) of the salt s in the results file.

     put xs% e

puts the equilibrium saturation of the cation exchanger (in %) by the element e in the results file.

     put p e

puts the equilibrium activity of element e in solution in logarithmic form in the results file. The form is

p(e_{i}) = − log_{10} (c_{i} γ_{i})

where c_{i} γ_{i} is the activity (cf. p. 3) of e_{i} in mol L^{−1}.

     put dcs e

puts the change in the amount sorbed (in mmol kg^{−1}) relative to the first step (step 0) of element e in the results file. The amount sorbed is the sum over all salts and the cation exchanger.

6 Program availability and installation

BEM is distributed as free software under the general public licence of the Free Software Foundation. The code will be placed on the internet on ftp.gwdg.de/pub/forest-soils/bem for transfer by anonymous ftp.

Version 6 is being developed under Linux on an intel 486 computer and is tested to run also on DEC Unix (former OSF1) on DEC alpha computers.

The program is written in ANSI C and uses a few POSIX.2 features in addition. The user interface is a shell script (bem.sh) that needs the bash or the korn (ksh) shell to run. This script is much simpler and shorter than the corresponding one in earlier program versions. It should be possible to adapt it to other shells.

Complemantary programs like preprocessors or interfaces to plot programs will be supplied as perl scripts.

To install BEM you must

1. Prepare a directory where BEM is to reside. In the following we assume that this is bhome.

2. Obtain by anonymous ftp a copy of the file bemnnn.tgz from

ftp.gwdg.de/pub/forest-soils/bem, where nnn indicates the pro-

gram version, and move it to bhome.

3. Run the GNU version of tar, e.g.

gtar -xzvf bemnnn.tgz

to unpack the files. If you dont have this program you can obtain the single files from the directory bemnnn at the same location.

4. Change directory to bhome/src, edit the first two lines of the script compile.sh to set the compiler name and and compile options, and run this script. If you have the GNU version of make (e.g. as gmake), you can edit makefile and run gmake instead.

5. edit the first two lines of the script bhome/sys/bem.sh. Change bash to ksh if you are running the korn shell and make the variable BEMDIR point to bhome.

6. Move to a directory in your PATH (e.g. $HOME/bin) and run

ln -s bhome/sys/bem.x bem

This step has to be repeated for each user if the link can not be placed in a system wide directory that is in PATH system wide like

/usr/local/bin

Index of terms in input files

m–file . . . . . . . . . . . . . . . . . . . . . . . . . 5 cec . . . . . . . . . . . . . . . . . . . . . . . 8 CO2 . . . . . . . . . . . . . . . . . . . . . . . 7 cpl . . . . . . . . . . . . . . . . . . . . . . . 6 cslt0 . . . . . . . . . . . . . . . . . . . . . 8 ctl0 . . . . . . . . . . . . . . . . . . . . . . 8 elt . . . . . . . . . . . . . . . . . . . . . . . 6 estslt . . . . . . . . . . . . . . . . . . . . 9 estsng . . . . . . . . . . . . . . . . . . . . 9 gas . . . . . . . . . . . . . . . . . . . . . . . 7 pkw . . . . . . . . . . . . . . . . . . . . . . . 7 run

it1max . . . . . . . . . . . . . . . . .10 it2max . . . . . . . . . . . . . . . . .10 itrace . . . . . . . . . . . . . . . . .10 lsierr . . . . . . . . . . . . . . . . .10 relerr . . . . . . . . . . . . . . . . .10

slt . . . . . . . . . . . . . . . . . . . . . . . 6 spfun . . . . . . . . . . . . . . . . . . . . . 6 vls

estph . . . . . . . . . . . . . . . . . . . 9 eststr . . . . . . . . . . . . . . . . . . 9 estxsh . . . . . . . . . . . . . . . . . . 9 PCO2 . . . . . . . . . . . . . . . . . . . . 8 rho . . . . . . . . . . . . . . . . . . . . . 8 sigma . . . . . . . . . . . . . . . . . . . 8 theta0 . . . . . . . . . . . . . . . . . . 8

wptslt . . . . . . . . . . . . . . . . . . .10 xeql . . . . . . . . . . . . . . . . . . . . . . 7 xeqs . . . . . . . . . . . . . . . . . . . . . . 7 xpksel . . . . . . . . . . . . . . . . . . . . 7 xs0 . . . . . . . . . . . . . . . . . . . . . . . 8

t–file . . . . . . . . . . . . . . . . . . . . . . . . . 11 cell . . . . . . . . . . . . . . . . . . . . . 11 ctin . . . . . . . . . . . . . . . . . . . . . 11 define . . . . . . . . . . . . . . . . . . .11 dpgas . . . . . . . . . . . . . . . . . . . . 12 put

cpl . . . . . . . . . . . . . . . . . . . . 14 ctl . . . . . . . . . . . . . . . . . . . . 14

dcs . . . . . . . . . . . . . . . . . . . . 14
p . . . . . . . . . . . . . . . . . . . . . . .14
pH . . . . . . . . . . . . . . . . . . . . . 13
slt . . . . . . . . . . . . . . . . . . . . 14
sng . . . . . . . . . . . . . . . . . . . . 14
xs% . . . . . . . . . . . . . . . . . . . . 14
steps . . . . . . . . . . . . . . . . . . . . 11
vinp . . . . . . . . . . . . . . . . . . . . . 12
vout . . . . . . . . . . . . . . . . . . . . . 12