Chemical equilibrium
Minimization of Gibbs energy

At equilibrium, at a specified temperature and pressure, and with no external forces, the Gibbs free energy G is at a minimum:

where μ is the chemical potential of molecular species j, and N is the amount of molecular species j. It may be expressed in terms of thermodynamic activity as:

where μ j ⊖ {\displaystyle \mu _{j}^{\ominus }} is the chemical potential in the standard state, R is the gas constant T is the absolute temperature, and A is the activity.

For a closed system, no particles may enter or leave, although they may combine in various ways. The total number of atoms of each element will remain constant. This means that the minimization above must be subjected to the constraints:

where a is the number of atoms of element i in molecule j and b is the total number of atoms of element i, which is a constant, since the system is closed. If there are a total of k types of atoms in the system, then there will be k such equations. If ions are involved, an additional row is added to the a matrix specifying the respective charge on each molecule which will sum to zero.

This is a standard problem in optimisation, known as constrained minimisation. The most common method of solving it is using the method of Lagrange multipliers (although other methods may be used).

Define:

where the λ are the Lagrange multipliers, one for each element. This allows each of the N and λ to be treated independently, and it can be shown using the tools of multivariate calculus that the equilibrium condition is given by

(For proof see Lagrange multipliers.) This is a set of (m + k) equations in (m + k) unknowns (the N and the λ) and may, therefore, be solved for the equilibrium concentrations N as long as the chemical activities are known as functions of the concentrations at the given temperature and pressure. (In the ideal case, activities are proportional to concentrations.) (See Thermodynamic databases for pure substances.) Note that the second equation is just the initial constraints for minimization.

This method of calculating equilibrium chemical concentrations is useful for systems with a large number of different molecules. The use of k atomic element conservation equations for the mass constraint is straightforward, and replaces the use of the stoichiometric coefficient equations. The results are consistent with those specified by chemical equations. For example, if equilibrium is specified by a single chemical equation:,

where ν is the stoichiometric coefficient for the j th molecule (negative for reactants, positive for products) and R is the symbol for the j th molecule, a properly balanced equation will obey:

Multiplying the first equilibrium condition by ν and using the above equation yields:

As above, defining Δ G

where K is the equilibrium constant, and Δ G will be zero at equilibrium.

Analogous procedures exist for the minimization of other thermodynamic potentials.
change_case:capital_word_frequency[2], oulipo:avoid_letter[o]