Newton algorithm
The methodology for computing chemical equilibrium is well established [13–19] and is always built on a Newton procedure. By incorporating the Nc mass action laws into the Nx conservation equation, one can obtain an Nx by Nx nonlinear system that must be iteratively solved. Here, we present the approach where mass action laws are written in a logarithmic form.
We define the logarithm of the components activity as:
This can be rewritten as a matrix formulation:
The mass action laws are then:
These can be rewritten by using the vector of species concentrations :
The conservation equations are:
Combining both equations, we obtain:
This nonlinear system is iteratively solved using a Newton procedure. At the nth iteration, the error is given by:
By computing the derivative of the error versus the logarithm of the components of the activity, we obtain the Jacobian matrix . By solving the linear system :
Then, a new value of the activity component is given by:
The procedure is repeated until the error is sufficiently small.

Possible algorithms

Historically, activity correction has been neglected when computing the Jacobian matrix. This approximation is justified if:
  1. The ionic strength is small enough so that the activity coefficients can be assumed to be equal to one (ideal solution).
  2. The changes in ionic strength are sufficiently small during one Newton iteration so that the activity coefficients can be assumed to be constant.
According to one of these hypotheses, the Jacobian matrix can be easily computed by:
This is because:
Neglecting the derivative of the activity coefficient, one obtains:
Alternatively: