Calculating the pH and titration curves of polyprotic acids#
← Previous | Oldest ↻ November 29, 2026 () by Anders Lervik | Category: chemistry Tagged: acids | chemistry | jupyter | python | titration
Introduction#
In a previous post, I calculated the pH in a solution of a weak acid by solving a cubic equation. For an acid that can donate more than one proton (a polyprotic acid), the same approach gives a polynomial of degree \(n + 2\) for an acid with \(n\) protons.
Instead of calculating the concentration of hydrogen ions for a given concentration of the acid, we can calculate the concentration of the acid that gives a certain concentration of hydrogen ions. This is an explicit equation. The same holds for titrations, where the volume of base needed to reach a given pH can be calculated directly.
This approach is well described in the literature on titration curves [1] [2] [3] [4] [5]. In this post, I go through the derivation for an \(n\)-protic acid and use it to calculate the titration curve for phosphoric acid. The figure below shows the pH as a function of \(V_\text{b}/V_\text{a}\), the volume of base added (\(V_\text{b}\)) divided by the volume of the acid solution (\(V_\text{a}\)). The dotted lines mark where one, two and three moles of base have been added per mole of acid:
The pH of a solution of an n-protic acid#
We consider a solution of an \(n\)-protic acid \(\text{H}_n\text{A}\) with total (analytical) concentration \([\text{H}_n\text{A}]_0\). Charges are omitted for the species. The acid \(\text{H}_n\text{A}\) is assumed to be neutral, so that \(\text{H}_{n-i}\text{A}\) has charge \(-i\).
Instead of calculating \([\text{H}^+]\) for a given concentration \([\text{H}_n\text{A}]_0\), we express \([\text{H}_n\text{A}]_0\) as an explicit function of \([\text{H}^+]\). This reversal of the dependent and independent variables goes back to Waser and Willis, and was developed into a general formalism by de Levie (1993, 1996). Asuero and Michałowski give a comprehensive review.
The acid has \(n\) dissociation equilibria,
with equilibrium constants
In addition, we have the autoionisation of water,
with \(K_\text{w} = [\text{H}^+] [\text{OH}^-]\).
We can express the concentrations of the different species in terms of \([\text{H}_n\text{A}]\):
where
The mass balance for A is
so that the concentrations are
where \(s = \sum_{j=0}^n r_j\). The charge balance is then
Solving for the total concentration gives
with \(\Delta = [\text{H}^+] - [\text{OH}^-] = [\text{H}^+] - K_\text{w} / [\text{H}^+]\).
We define \(F_\text{a}\) as the average number of protons released per acid molecule (the proton dissociation function of de Levie). With the concentration fractions \(x_i = r_i/s\),
In terms of the formation function \(\bar{n}\), the average number of protons bound to A, used by Asuero and Michałowski, \(F_\text{a} = n - \bar{n}\). The equation for the total concentration then takes the compact form
Special cases: monoprotic and diprotic acids#
For a monoprotic acid (\(n=1\)), with charges written out,
and the equation for the total concentration gives
The concentrations of the two acid species are then
and \([\text{OH}^-] = K_\text{w}/[\text{H}^+]\). The result \([\text{A}^-] = \Delta\) is the charge balance, \([\text{H}^+] = [\text{A}^-] + [\text{OH}^-]\).
For a diprotic acid (\(n=2\)),
and the equation for the total concentration gives
With \(D = [\text{H}^+]^2 + K_1 [\text{H}^+] + K_1 K_2\), the concentrations of the three acid species are
and \([\text{OH}^-] = K_\text{w}/[\text{H}^+]\). As a check, \([\text{HA}^-] + 2[\text{A}^{2-}] = \Delta\), which is the charge balance.
Calculating the concentration from the pH#
To turn the equations above into code, we start by importing numpy and scipy (for the numerics), and matplotlib and seaborn (for the plotting):
[1]:
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
from scipy.optimize import brentq
sns.set_theme(style="ticks", context="notebook", palette="colorblind")
%matplotlib inline
The methods below calculate \(r_i\), the fractions \(x_i\), the proton dissociation function \(F_\text{a}\), \(\Delta\), and finally the total concentration of the acid, \([\text{H}_n\text{A}]_0\). This is the sum of the concentrations of all the acid species, that is, the amount of acid dissolved per litre of solution. All the methods take the pH and the \(\text{p}K_\text{a}\) values as input:
[2]:
def dissociation_ratios(pH, pka):
"""Calculate r_0, r_1, ..., r_n for an n-protic acid.
Args:
pH: The pH (a number or an array).
pka: The pKa values of the acid (pKa1, pKa2, ...).
Returns:
An array where row i contains r_i.
"""
hydrogen = 10.0 ** (-np.asarray(pH, dtype=float))
ratios = [np.ones_like(hydrogen)]
for pk in pka:
ratios.append(ratios[-1] * 10.0 ** (-pk) / hydrogen)
return np.array(ratios)
def fractions(pH, pka):
"""Calculate the fractions x_i of the species H(n-i)A."""
ratios = dissociation_ratios(pH, pka)
return ratios / ratios.sum(axis=0)
def proton_function(pH, pka):
"""Calculate F_a, the average number of protons released per acid."""
x = fractions(pH, pka)
protons = np.arange(len(x)).reshape(-1, *([1] * (x.ndim - 1)))
return (protons * x).sum(axis=0)
def delta(pH, pkw=14.0):
"""Calculate [H+] - [OH-]."""
hydrogen = 10.0 ** (-np.asarray(pH, dtype=float))
return hydrogen - 10.0 ** (-pkw) / hydrogen
def total_concentration(pH, pka, pkw=14.0):
"""Calculate the total concentration of an acid from the pH.
The total concentration, [HnA]0, is the sum of the concentrations
of all the acid species: [HnA] + [H(n-1)A] + ... + [A].
"""
return delta(pH, pkw=pkw) / proton_function(pH, pka)
As a first test, we use the example from the post on weak acids: a weak acid with \(K_\text{a} = 4.0 \times 10^{-11}\) and a concentration of \(1.0 \times 10^{-3}\) M, where the pH was found to be 6.65. Here, we go the other way and calculate the concentration from the pH:
[3]:
pka_weak = [-np.log10(4.0e-11)]
concentration = total_concentration(6.65, pka_weak)
print(f"Concentration for pH = 6.65: {concentration:.2e} M")
Concentration for pH = 6.65: 1.00e-03 M
If we do want the pH for a given concentration, we have to solve the equation numerically. For an acid, the pH is below \(\text{p}K_\text{w}/2\) (the pH of pure water), and the concentration decreases monotonically with the pH in this range. There is then exactly one solution, and a bracketing method such as Brent’s method will find it:
[4]:
def calculate_pH(concentration, pka, pkw=14.0):
"""Calculate the pH of a solution of an n-protic acid.
Args:
concentration: The total concentration of the acid.
pka: The pKa values of the acid (pKa1, pKa2, ...).
pkw: The pKw of water.
Returns:
The pH of the solution.
"""
def objective(pH):
calculated = total_concentration(pH, pka, pkw=pkw)
return np.log10(calculated) - np.log10(concentration)
return brentq(objective, -2.0, 0.5 * pkw - 1.0e-9)
[5]:
pH = calculate_pH(1.0e-3, pka_weak)
print(f"Weak acid (1.0e-3 M): pH = {pH:.2f}")
pka_phosphoric = [2.14, 7.20, 12.37]
pH = calculate_pH(0.100, pka_phosphoric)
print(f"Phosphoric acid (0.100 M): pH = {pH:.2f}")
Weak acid (1.0e-3 M): pH = 6.65
Phosphoric acid (0.100 M): pH = 1.63
The fractions give us the concentrations of all the species, and we can check that they satisfy the charge balance. For 0.100 M phosphoric acid:
[6]:
x = fractions(pH, pka_phosphoric)
species = ["H₃PO₄", "H₂PO₄⁻", "HPO₄²⁻", "PO₄³⁻"]
for name, x_i in zip(species, x):
print(f"[{name}] = {0.100 * x_i:.3e} M")
negative_charge = 0.100 * sum(i * x_i for i, x_i in enumerate(x))
print(f"\nSum of i [H(3-i)A]: {negative_charge:.6e} M")
print(f"[H⁺] - [OH⁻]: {delta(pH):.6e} M")
[H₃PO₄] = 7.646e-02 M
[H₂PO₄⁻] = 2.354e-02 M
[HPO₄²⁻] = 6.310e-08 M
[PO₄³⁻] = 1.144e-18 M
Sum of i [H(3-i)A]: 2.353587e-02 M
[H⁺] - [OH⁻]: 2.353587e-02 M
We can draw the pH as a function of the total concentration \([\text{H}_n\text{A}]_0\) by selecting the pH values and calculating the corresponding concentrations. The figure below shows this for a monoprotic acid (acetic acid), a diprotic acid (carbonic acid) and a triprotic acid (phosphoric acid):
[7]:
acids = {
"Acetic acid": [4.76],
"Carbonic acid": [6.35, 10.33],
"Phosphoric acid": [2.14, 7.20, 12.37],
}
# Dash patterns (solid, dashed, dash-dotted and dotted) for the lines:
dashes = [(), (5, 3), (5, 2.5, 0.01, 2.5), (0.01, 2.2)]
fig, ax = plt.subplots(constrained_layout=True, figsize=(6, 4))
pH_grid = np.linspace(0.5, 6.99, 500)
for (name, pka), dash in zip(acids.items(), dashes):
ax.plot(
total_concentration(pH_grid, pka),
pH_grid,
lw=2,
label=name,
dashes=dash,
dash_capstyle="round",
)
ax.set(
xscale="log",
xlim=(1.0e-8, 1.0),
xlabel="$[\\mathrm{H}_n\\mathrm{A}]_0$ (M)",
ylabel="pH",
)
ax.legend(frameon=False, handlelength=3.2)
sns.despine(fig=fig)
Treating a polyprotic acid as monoprotic#
A common shortcut for a polyprotic acid is to ignore all but the first dissociation, and calculate the pH as if the acid were monoprotic. In the post on weak acids, I made a map showing when the approximate equation for a weak acid can be used. We can make a similar map for this shortcut.
We define the error as the difference between the pH calculated with only the first dissociation and the pH calculated with all the dissociations. We will use a diprotic acid as the example, and the error is thus
It will depend on the concentration, on how far apart the two dissociation constants are (\(\text{p}K_2 - \text{p}K_1\)), and on \(\text{p}K_1\) itself. The concentration is given as \(\text{pC} = -\log_{10} [\text{H}_2\text{A}]_0\). Here are maps of the error in the pH for three values of \(\text{p}K_1\):
[8]:
pC = np.linspace(0, 7, 141)
separation = np.linspace(0, 8, 161)
errors = {}
pH_exact = {}
for pk1 in (2.0, 4.0, 6.0):
pH_exact[pk1] = np.array(
[
[calculate_pH(10.0**-pC_i, [pk1, pk1 + i]) for pC_i in pC]
for i in separation
]
)
pH_monoprotic = np.array(
[calculate_pH(10.0**-pC_i, [pk1]) for pC_i in pC]
)
errors[pk1] = pH_monoprotic - pH_exact[pk1]
fig, axes = plt.subplots(
constrained_layout=True, ncols=3, sharey=True, figsize=(10, 3.8)
)
for ax, (pk1, error) in zip(axes, errors.items()):
im = ax.contourf(
pC, separation, error, levels=np.linspace(0, 0.31, 32), cmap="vlag"
)
lines = ax.contour(
pC, separation, error, levels=[0.01, 0.1], colors="w"
)
ax.clabel(lines, lines.levels, fontsize="small", fmt="%.2f")
ax.set(xlabel="pC", title=f"$\\mathrm{{p}}K_1 = {pk1:.0f}$")
axes[0].set(ylabel="$\\mathrm{p}K_2 - \\mathrm{p}K_1$")
fig.colorbar(im, ax=axes, label="Error in pH", ticks=[0, 0.1, 0.2, 0.3])
sns.despine(fig=fig)
The white lines show where the error is 0.01 and 0.1 pH units. The error is largest for dilute solutions of acids where the two constants are close. It is never larger than \(\log_{10} 2 \approx 0.30\), which is the case where the acid releases both its protons and the shortcut only counts one.
The second dissociation matters when \([\text{A}^{2-}]\) is not negligible compared to \([\text{HA}^-]\), and their ratio is \(K_2/[\text{H}^+]\). The error should therefore be given by how far the pH is from \(\text{p}K_2\). Here is the largest value of \(\text{p}K_2 - \text{pH}\) for which the error exceeds the two limits:
[9]:
print("pK1 Error > 0.01 when Error > 0.1 when")
for pk1, error in errors.items():
distance = pk1 + separation[:, np.newaxis] - pH_exact[pk1]
small, large = (distance[error > limit].max() for limit in (0.01, 0.1))
print(f"{pk1:3.0f} pK2 - pH < {small:.2f} pK2 - pH < {large:.2f}")
pK1 Error > 0.01 when Error > 0.1 when
2 pK2 - pH < 1.63 pK2 - pH < 0.52
4 pK2 - pH < 1.63 pK2 - pH < 0.52
6 pK2 - pH < 1.63 pK2 - pH < 0.52
The limits are the same for the three values of \(\text{p}K_1\). For a diprotic acid, the shortcut thus works when the pH is well below \(\text{p}K_2\). We can calculate the pH with \(K_1\) only and compare it with \(\text{p}K_2\). If the pH is more than about 1.6 units below \(\text{p}K_2\), the error is less than 0.01 pH units. If it is more than about 0.5 units below \(\text{p}K_2\), the error is less than 0.1. If it is closer to \(\text{p}K_2\) than this, we should redo the calculation with both dissociation constants.
Titration with a strong base#
We titrate a volume \(V_\text{a}\) of the acid (total concentration \([\text{H}_n\text{A}]_0\)) with a volume \(V_\text{b}\) of the strong base NaOH (concentration \([\text{NaOH}]_0\)). The volumes are assumed to be additive, so that the total volume is \(V_\text{a} + V_\text{b}\). After mixing, the total concentrations are
\(\text{Na}^+\) takes no part in the equilibria, so the distribution of the acid species is the same as before, with \([\text{H}_n\text{A}]_0^\prime\) in place of \([\text{H}_n\text{A}]_0\): \([\text{H}_{n-i}\text{A}] = [\text{H}_n\text{A}]_0^\prime\, r_i/s\). The charge balance becomes
Multiplying by \(V_\text{a} + V_\text{b}\) gives
and collecting the terms in \(V_\text{b}\) and \(V_\text{a}\) gives
with \(F_\text{a}\) and \(\Delta = [\text{H}^+] - [\text{OH}^-]\) as before. This is the same expression as given by de Levie (1993, 1996) and by Asuero and Michałowski, who write \(\alpha\) for our \(\Delta\).
As for the pure acid, we choose the pH, and this equation gives how much base is needed to reach it. For \(V_\text{b} = 0\) the numerator must vanish, and we recover the equation for the pure acid, \([\text{H}_n\text{A}]_0 F_\text{a} = \Delta\). If we instead want the pH for a given volume, the equation must be solved numerically. There is only one solution, since \(V_\text{b}/V_\text{a}\) increases monotonically with the pH.
Once \(V_\text{b}/V_\text{a}\) has been calculated, the total concentrations after mixing follow directly,
and each acid species is \([\text{H}_{n-i}\text{A}] = [\text{H}_n\text{A}]_0^\prime\, x_i\). Every concentration in the solution is therefore an explicit function of \([\text{H}^+]\). In contrast to the pure acid, the species cannot be written in terms of \(\Delta\) alone, since the charge balance now also contains \([\text{Na}^+]\).
For a monoprotic acid (\(n = 1\)),
The acid species are
and the charge balance gives the check \([\text{A}^-] = [\text{Na}^+] + \Delta\). For a diprotic acid (\(n = 2\)),
With \(D\) as before, the acid species are
and the charge balance gives the check \([\text{HA}^-] + 2[\text{A}^{2-}] = [\text{Na}^+] + \Delta\).
Example: titration of phosphoric acid#
The equation for \(V_\text{b}/V_\text{a}\) only needs the methods we already have:
[10]:
def titration_volume(pH, pka, acid, base, pkw=14.0):
"""Calculate the volume of base needed to reach a given pH.
Args:
pH: The pH (a number or an array).
pka: The pKa values of the acid (pKa1, pKa2, ...).
acid: The total concentration of the acid (before mixing).
base: The concentration of the strong base.
pkw: The pKw of water.
Returns:
The volume of base relative to the volume of acid, Vb/Va.
"""
difference = delta(pH, pkw=pkw)
return (acid * proton_function(pH, pka) - difference) / (base + difference)
We use phosphoric acid as the example (\(\text{p}K_1 = 2.14\), \(\text{p}K_2 = 7.20\), \(\text{p}K_3 = 12.37\)), with \([\text{H}_3\text{PO}_4]_0 = [\text{NaOH}]_0 = 0.100\) M and \(\text{p}K_\text{w} = 14.00\). The pH values are chosen on a fine grid, and \(V_\text{b}/V_\text{a}\) is calculated for each of them. The grid starts at the pH of the acid solution and ends just below the pH of the base (more on these limits below). The fractions \(x_i\) are calculated for the same grid:
[11]:
acid = 0.100
base = 0.100
pH_start = calculate_pH(acid, pka_phosphoric)
pH_base = 14.0 + np.log10(base)
pH_grid = np.linspace(pH_start, pH_base - 0.5, 2000)
volume = titration_volume(pH_grid, pka_phosphoric, acid, base)
x = fractions(pH_grid, pka_phosphoric)
fig, (ax1, ax2) = plt.subplots(
constrained_layout=True, nrows=2, sharex=True, figsize=(6, 7)
)
ax1.plot(volume, pH_grid, lw=2)
ax1.set(ylabel="pH", xlim=(0, 3.5), ylim=(0, 14))
labels = ["H$_3$PO$_4$", "H$_2$PO$_4^-$", "HPO$_4^{2-}$", "PO$_4^{3-}$"]
for label, x_i, dash in zip(labels, x, dashes):
ax2.plot(
volume, x_i, lw=2, label=label, dashes=dash, dash_capstyle="round"
)
ax2.set(xlabel="$V_\\mathrm{b} / V_\\mathrm{a}$", ylabel="Fraction")
ax2.legend(
frameon=False,
ncols=4,
loc="lower center",
bbox_to_anchor=(0.5, 1.0),
columnspacing=1.0,
handlelength=3.2,
)
for ax in (ax1, ax2):
for equivalence in (1, 2, 3):
ax.axvline(x=equivalence, ls=":", color="0.4", lw=1)
sns.despine(fig=fig)
The dotted lines mark \(V_\text{b}/V_\text{a} = 1\), \(2\) and \(3\). To find the pH at these points, we need the pH for a given volume, and for that we solve the equation numerically:
[12]:
def titration_pH(volume, pka, acid, base, pkw=14.0):
"""Calculate the pH after adding a volume (Vb/Va) of a strong base."""
def objective(pH):
return titration_volume(pH, pka, acid, base, pkw=pkw) - volume
return brentq(objective, -2.0, pkw + np.log10(base) - 1.0e-9)
for volume_i in (0, 1, 2, 3):
pH = titration_pH(volume_i, pka_phosphoric, acid, base)
print(f"Vb/Va = {volume_i}: pH = {pH:.2f}")
Vb/Va = 0: pH = 1.63
Vb/Va = 1: pH = 4.70
Vb/Va = 2: pH = 9.67
Vb/Va = 3: pH = 12.18
The curve starts at pH 1.63 and has steep parts at the first and second equivalence points (pH 4.70 at \(V_\text{b}/V_\text{a} = 1\) and pH 9.67 at \(V_\text{b}/V_\text{a} = 2\)). There is no visible third equivalence point. \(\text{PO}_4^{3-}\) is a fairly strong base (\(\text{p}K_\text{b} = 14.00 - 12.37 = 1.63\)), and only part of the \(\text{HPO}_4^{2-}\) has been converted at \(V_\text{b}/V_\text{a} = 3\), where the pH is 12.18. This is also seen in the fractions, where those of \(\text{HPO}_4^{2-}\) and \(\text{PO}_4^{3-}\) are of similar size at \(V_\text{b}/V_\text{a} = 3\).
[13]:
x = fractions(pH, pka_phosphoric)
for name, x_i in zip(species, x):
print(f"Fraction of {name} at Vb/Va = 3: {x_i:.3f}")
Fraction of H₃PO₄ at Vb/Va = 3: 0.000
Fraction of H₂PO₄⁻ at Vb/Va = 3: 0.000
Fraction of HPO₄²⁻ at Vb/Va = 3: 0.607
Fraction of PO₄³⁻ at Vb/Va = 3: 0.393
The fractions are more commonly shown as a function of the pH. They only depend on the pH and the \(\text{p}K_\text{a}\) values, so this figure is the same for all concentrations of the acid and the base:
[14]:
pH_range = np.linspace(0, 14, 1000)
fig, ax = plt.subplots(constrained_layout=True, figsize=(6, 3.5))
for label, x_i, dash in zip(
labels, fractions(pH_range, pka_phosphoric), dashes
):
ax.plot(
pH_range, x_i, lw=2, label=label, dashes=dash, dash_capstyle="round"
)
for volume_i in (1, 2, 3):
pH_i = titration_pH(volume_i, pka_phosphoric, acid, base)
ax.axvline(x=pH_i, ls=":", color="0.4", lw=1)
ax.set(xlabel="pH", ylabel="Fraction", xlim=(0, 14))
ax.legend(
frameon=False,
ncols=4,
loc="lower center",
bbox_to_anchor=(0.5, 1.0),
columnspacing=1.0,
handlelength=3.2,
)
sns.despine(fig=fig)
The dotted lines mark the pH at \(V_\text{b}/V_\text{a} = 1\), \(2\) and \(3\) for the titration above. Two neighbouring species have equal fractions when the pH is equal to one of the \(\text{p}K_\text{a}\) values. At the first two equivalence points, the solution is dominated by a single species (\(\text{H}_2\text{PO}_4^-\) and \(\text{HPO}_4^{2-}\)). At \(V_\text{b}/V_\text{a} = 3\), the pH (12.18) is close to \(\text{p}K_3 = 12.37\).
Physical limits#
The equation for \(V_\text{b}/V_\text{a}\) can be evaluated for any pH, but only part of the result is physically meaningful. Below the pH of the acid solution itself, the numerator is negative and \(V_\text{b}/V_\text{a} < 0\). When \([\text{OH}^-] - [\text{H}^+]\) approaches \([\text{NaOH}]_0\), that is, when the pH approaches that of the titrant, the denominator goes to zero and \(V_\text{b}/V_\text{a} \to \infty\). Mixing the two solutions can only give a pH between these two limits. Outside them, the equation gives a negative volume of the base (below the pH of the acid) or of the acid (above the pH of the base). Only the range between the two limits was plotted above. This point is also discussed by de Levie.
Here is the equation evaluated for all pH values between 0 and 14, with the two limits marked:
[15]:
pH_all = np.linspace(0, 14, 2801)
volume_all = titration_volume(pH_all, pka_phosphoric, acid, base)
# Do not draw a line across the singularity:
volume_all[np.abs(volume_all) > 50] = np.nan
fig, ax = plt.subplots(constrained_layout=True, figsize=(6, 4))
ax.plot(pH_all, volume_all, lw=2)
ax.axhline(y=0, color="0.4", lw=1)
ax.axvspan(pH_start, pH_base, color="0.9", zorder=0)
ax.axvline(x=pH_start, ls=":", color="0.4", lw=1)
ax.axvline(x=pH_base, ls=":", color="0.4", lw=1)
ax.set(
xlabel="pH",
ylabel="$V_\\mathrm{b} / V_\\mathrm{a}$",
xlim=(0, 14),
ylim=(-5, 10),
)
sns.despine(fig=fig)
print(f"The pH of the acid: {pH_start:.2f}")
print(f"The pH of the base: {pH_base:.2f}")
The pH of the acid: 1.63
The pH of the base: 13.00
Visibility of the equivalence point#
For phosphoric acid, we saw that the third equivalence point is not visible in the titration curve. We can use the equation for \(V_\text{b}/V_\text{a}\) to map out when an equivalence point is visible. We will only consider a monoprotic acid titrated with a strong base of the same concentration, and use the following measures:
The jump in pH around the equivalence point, here taken as the change in pH when \(V_\text{b}/V_\text{a}\) goes from 0.999 to 1.001 (that is, 0.1 % before and after the equivalence point). A large jump means that the equivalence point is easy to locate, for instance with an indicator.
Whether the titration curve has an inflection point at the equivalence point. The slope of the curve is the inverse of \(\text{d}V_\text{b}/\text{d}\text{pH}\), which we can calculate directly on a grid of pH values. There is an inflection point if this derivative has a local minimum.
[16]:
def equivalence_point(pka, concentration, window=0.001, points=6001):
"""Characterise the equivalence point for a monoprotic acid.
The acid is titrated with a strong base of the same concentration.
Args:
pka: The pKa of the acid.
concentration: The concentration of the acid (and the base).
window: The jump is calculated from 1 - window to 1 + window.
points: The number of pH values to consider.
Returns:
The jump in the pH, and True if there is an inflection point.
"""
pH = np.linspace(0.0, 14.0 + np.log10(concentration) - 1.0e-6, points)
volume = titration_volume(pH, [pka], concentration, concentration)
before, after = np.interp([1.0 - window, 1.0 + window], volume, pH)
derivative = np.gradient(volume, pH)[volume > 0]
minimum = (derivative[1:-1] < derivative[:-2]) & (
derivative[1:-1] < derivative[2:]
)
return after - before, minimum.any()
[17]:
pka_values = np.linspace(0, 14, 281)
pC = np.linspace(0, 5, 101)
jump = np.zeros((len(pka_values), len(pC)))
inflection = np.zeros_like(jump)
for i, pka_i in enumerate(pka_values):
for j, pC_j in enumerate(pC):
jump[i, j], inflection[i, j] = equivalence_point(pka_i, 10.0**-pC_j)
fig, ax = plt.subplots(constrained_layout=True, figsize=(7, 5))
im = ax.contourf(
pC, pka_values, jump, levels=np.linspace(0, 8, 33), cmap="viridis"
)
lines = ax.contour(pC, pka_values, jump, levels=[0.1, 1, 2, 4], colors="w")
ax.clabel(lines, lines.levels, fontsize="small", fmt="%.1f")
ax.contour(
pC, pka_values, inflection, levels=[0.5], colors="w", linestyles="--"
)
ax.text(2.6, 10.4, "No inflection point", color="w", rotation=-21)
ax.set(xlabel="pC", ylabel="$\\mathrm{p}K_\\mathrm{a}$")
fig.colorbar(im, ax=ax, label="Jump in pH", ticks=range(9))
sns.despine(fig=fig)
The solid lines show the size of the jump, and there is no inflection point above the dashed line. The lines are straight (for concentrations that are not too low), which means that the limits can be given as simple rules:
[18]:
print("pC Jump > 1 for pKa + pC < Inflection for C Ka / Kw >")
for pC_j in (1.0, 2.0, 3.0):
j = np.argmin(abs(pC - pC_j))
pka_jump = pka_values[jump[:, j] > 1.0].max()
pka_inflection = pka_values[inflection[:, j] > 0.5].max()
ratio = 10.0 ** (14.0 - pC_j - pka_inflection)
print(f"{pC_j:.0f} {pka_jump + pC_j:17.2f} {ratio:25.0f}")
pC Jump > 1 for pKa + pC < Inflection for C Ka / Kw >
1 6.75 63
2 6.75 63
3 6.60 63
The jump is larger than one pH unit when \(\text{p}K_\text{a} + \text{pC}\) is below about 6.7 (and somewhat lower for dilute solutions). For an acid with \(\text{p}K_\text{a} = 5\), the jump is 1.7 pH units in a 0.1 M solution and 0.3 pH units in a 0.001 M solution. For solutions more dilute than about \(10^{-3.2}\) M, the jump is smaller than one pH unit even for a strong acid.
There is no inflection point when \([\text{HA}]_0 K_\text{a}\) is smaller than about \(60 K_\text{w}\). This explains the missing third equivalence point for phosphoric acid. If we look at the last step on its own, as the titration of a 0.100 M solution of a monoprotic acid with \(\text{p}K_\text{a} = 12.37\), then \([\text{HA}]_0 K_\text{a} \approx 4 K_\text{w}\), which is far below the limit. The dilution by the base already added makes this number even smaller.
Comparison with calculating the pH directly#
The traditional approach is to calculate \([\text{H}^+]\) for a given \(V_\text{b}\). For a monoprotic acid, combining the acid equilibrium, the autoionisation of water, the charge balance and the mass balance gives
a cubic equation that must be solved for each point on the curve. For an \(n\)-protic acid the polynomial is of degree \(n + 2\). The equation for \(V_\text{b}/V_\text{a}\) gives the volume directly, and the expression keeps the same simple form for mixtures of acids and bases (see de Levie and Asuero and Michałowski).
As a final check, we can verify that the two approaches agree. Here, we solve the cubic equation for the titration of 0.100 M acetic acid with 0.100 M NaOH and compare with the pH found from the equation for \(V_\text{b}/V_\text{a}\):
[19]:
def cubic_pH(volume, pka, acid, base, pkw=14.0):
"""Calculate the pH for a monoprotic acid from the cubic equation."""
k1 = 10.0 ** (-pka)
kw = 10.0 ** (-pkw)
acid_mixed = acid / (1.0 + volume)
sodium = base * volume / (1.0 + volume)
roots = np.roots(
[
1.0,
sodium + k1,
-(kw + k1 * (acid_mixed - sodium)),
-k1 * kw,
]
)
# There is exactly one positive root:
hydrogen = max(root.real for root in roots if abs(root.imag) < 1e-12)
return -np.log10(hydrogen)
print("Vb/Va pH (cubic) pH (explicit equation)")
for volume_i in (0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5):
pH_cubic = cubic_pH(volume_i, 4.76, 0.100, 0.100)
pH_explicit = titration_pH(volume_i, [4.76], 0.100, 0.100)
print(f"{volume_i:5.2f} {pH_cubic:12.4f} {pH_explicit:12.4f}")
Vb/Va pH (cubic) pH (explicit equation)
0.00 2.8829 2.8829
0.25 4.2844 4.2844
0.50 4.7605 4.7605
0.75 5.2374 5.2374
1.00 8.7295 8.7295
1.25 12.0458 12.0458
1.50 12.3010 12.3010
Summary#
For an \(n\)-protic acid, the concentration that gives a certain pH is \([\text{H}_n\text{A}]_0 = \Delta/F_\text{a}\). In a titration with a strong base, the volume of base that gives a certain pH is \(V_\text{b}/V_\text{a} = ([\text{H}_n\text{A}]_0 F_\text{a} - \Delta) / ([\text{NaOH}]_0 + \Delta)\). Here, \(\Delta = [\text{H}^+] - [\text{OH}^-]\) and \(F_\text{a}\) is the average number of protons released per acid molecule. A titration curve can be drawn by selecting the pH values and calculating the volumes.
The maps show that a polyprotic acid can be treated as monoprotic (with an error below 0.01 pH units) if the pH is more than about 1.6 units below \(\text{p}K_2\). In the titration of a monoprotic acid with a strong base of the same concentration, there is no inflection point at the equivalence point when \([\text{HA}]_0 K_\text{a}\) is smaller than about \(60 K_\text{w}\).