Buffer Calculator - How it works

A buffer composed of a mixture of protonated anions HnA-(N-n) (n=0..N) has
dissociation constants

Kn =

[H3O+][Hn-1A-(N-n)-1]

n=1..N

[HnA-(N-n)]

At a given pH, these expressions give the relative ratios of each
component:

[HnA-(N-n)]

=

Kn+1

*

Kn+2

* ... *

KN

[HNA]

[H3O+]

[H3O+]

[H3O+]

The sum of [HnA-(N-n)] is the presumably known buffer strength [B], and
this fact is used to get the actual concentrations:

[HnA-(N-n)] =

[HnA-(N-n)] / [HNA]

* [B]

sum [HnA-(N-n)] / [HNA]

The relative ratios can be substituted into this equation to obtain each concentration as a function of the dissociation constants, [B], and pH.

To determine what ingredients to put in the buffer to obtain these
concentrations, the script uses the facts that positive ions must balance
negative ions, and that water dissociates with equilibrium constant

[OH-] = Kw/[H3O+].

For NaOH and MN-aHaA (M being a monovalent cation distinguishable from Na+) the charge balance is:

[H3O+] + [Na+] + (N-a)[B] =
[OH-] + sum (N-n) [HnA-(N-n)]

Note that [M+] = (N-a)[B]. The amount of NaOH added should result in the sodium ion concentration
[Na+] and the amount of buffering anions should result in a concentration equal to [B].

For MN-bHbA and HCl (A being an anion distinguishable from Cl-) the charge balance is:

[H3O+] + (N-b)[B] =
[OH-] + [Cl-] + sum (N-n) [HnA-(N-n)]

The amount of HCl added should equal [Cl-] and the amount of base should be
[B].

For MN-bHbA and MN-aHaA :

[H3O+] + x(N-b)[B] + (1-x)(N-a)[B] =
[OH-] + sum (N-n) [HnA-(N-n)]

where x[B] is the amount of acid to add and (1-x)[B] the amount of
base.

The sum in these equations is the number of bound protons:

[H+]bound = sum n[HnA-(N-n)]

subtracted from the total number of protons that can be bound, the
buffer capacity C:

[C] = sum N[HnA-(N-n)] = N[B]

Note: this is different from the minimum slope of the
titration curve,
as others define "buffer capacity".
A convenient parameter, the buffer load L, can be identified in each of
the charge balance equations:

L =

[H3O+] + [H+]bound - [OH-]

[C]

The buffer load is the total concentration of free and bound H, minus the
contribution to these from dissociated water (which can be reduced by
adding strong base), divided by the buffer capacity.

If only HnA is added to water, the buffer load is n/N. By
mixing different MN-nHnA's, intermediate buffer
loads can be obtained. The buffer load can also be adjusted by adding a
strong acid or base. The above equations can be rearranged to give
simple formulas that show how much.

For NaOH and MN-aHaA, the concentrations should be:

(a/N - L)[C] and [B]; this buffer works if L < a/N.

For MN-bHbA / HCl, the concentrations should be:

[B] and (L - b/N)[C]; this buffer works if L > b/N.

For MN-bHbA / MN-aHaA, the
concentrations should be:

(a/N - L)[C]

and

(L - b/N)[C]

; this buffer works if b/N < L < a/N.

(a-b)

(a-b)

The titration curve simply plots pH vs. NaOH added according to the
above equation, neglecting the volume added in a conventional
titration. Details of these calculations can be
seen in the source code.
Please note that pKa values, as well as the dissociation
constant of water Kw, can vary slightly as a function of
temperature, ionic strength, and other variables. As a result, the recipes
given here will not generally be as accurate as the output might
suggest.