Environmental Engineering Reference
In-Depth Information
The complete code is included in the accompanying software under the name
'Speciation.m'.
In the input part of the M-file the tolerance, the maximum number of iterations,
and an initial guess are specified in a similar way as in the Newton M-file
(see Sidebar 8.1). In addition, the reaction matrix, the equilibrium constants for
the reactions, and the total concentrations are specified. All concentrations and
equilibrium constants are entered using their logarithmic values.
The execution part of the M-file is divided into two parts. In the first part, the
initialization is done for the iterations to be performed in the second part. In the first
part, the sub matrices S 1 and S 2 of the reaction matrix are determined to be used in
the computation of S and U. Total and species concentrations are converted from
logarithm to their real values. Error variable and iteration counter are already
introduced in the former example, see Sidebar 8.1.
Within the iteration the zero of the function
U
c
u
F
ð
c
Þ¼
(8.23)
S
log
ð
c
Þ
log
ð
K
Þ
Search WWH ::




Custom Search