Tolerance in HaltaFall
See also: Calculation failures,
and Preferences / Calculation options
In HaltaFall the calculations are perfomed
iteratively until the mass-balance equations (total concentrations)
are satisfied within a given maximum relative tolerance, by default
tolrel = 10−4
(that is, ±0.01%). This relative tolerance may be changed in SPANA
using the menu Preferences / Calculation options
(after setting the advanced program level in the
menu Preferences / General options).
HaltaFall
finds the solution for the total concentrations in loops. Depending on the chemical system
some loops are concentric, that is, first the componet in the inner loop is
solved, before a step is taken in the outer loop. In such cases it
helps to have a smaller tolrel for the
inner loops. For example, if tolrel = 10−4
in the outer loop, one might set tolrel = 3.16×10−5
in the inner loop. This is done automatically by the software.
The absolute tolerances are:
tolabs = tolrel × Totconc
For example, if the total concentration is Tolconc = 10−7
and tolrel = 10−4, then
tolabs = 10−11,
and the calculated total concentration
will be between (0.9999 and
1.0001) ×10−7.
Chemical components with zero total concentration
If Totconc = 0, then tolabs
can not be assigned using the method described above.
There are two types of components:
those for which Totconc can not be less
than zero (such as Ca2+), and those
that could have a negative total concentration (for example
H+ in an NaOH solution).
If the total concentration is zero, and it can not
be negative (such as for Ca2+),
the program sets the free concentration
to a very low value and the mass-balance equation does not
need to be solved.
If the total concentration is zero for a component such as H+,
that could have a negative concentration, the program assigns
tolabs = tolrel × Min(10−6, Totmin)
where Totmin is the minimum of the absolute
values of non-zero total concentrations in the chemical system.
For example, if there are three components, with
Totconc = 0.1,
10−4 and 0 (zero), respectively, then
Totmin = 10−4.
In such a case a value of 10−6 is used instead of
Totmin,
and if tolrel = 10−4,
then the calculated total concentration will be between
(+1.0 and −1.0) ×10−10.
Tolerance for activity coefficients
The default tolerance when iterating activity coefficients is ± 0.001,
but the user may request a value between ± 0.01 to
± 10−10. Note however that the tolerance used
during the calculations may be higher than the requested value if the mass-balance
tolerance is much higher, or if the concentrations are high.
For systems with large concentrations of ionic species, C[i],
the tolerance for activity coefficients is increased to:
tolLogF0 × max(C[i] × z[i]),
where tolLogF0 is the requested tolerance and z[i]
is the electric charge. For example, if the requested tolerance is
10−5 and highest
concentration is for Ca2+, and C[Ca2+]
= 12 mol/(kg H2O), then the tolerance used will be
= 10−5 × 12 × 2 = 2.4 10−4.
But the tolerance used is always less than 0.01.
Round-off errors
Round-off errors from one component may propagate to another
component, and the system might be difficult to solve numerically.
The programs will display a warning message. Round-off error problems
may occurr in systems where some components have large concentrations, some components very small
concentrations, and some components have zero total concentration.