The rapid and efficient exchange of ions between porous electrodes and
aqueous solutions is important in many applications, such as electrical energy
storage by super-capacitors, water desalination and purification by capacitive
deionization (or desalination), and capacitive extraction of renewable energy
from a salinity difference. Here, we present a unified mean-field theory for
capacitive charging and desalination by ideally polarizable porous electrodes
(without Faradaic reactions or specific adsorption of ions) in the limit of
thin double layers (compared to typical pore dimensions). We illustrate the
theory in the case of a dilute, symmetric, binary electrolyte using the
Gouy-Chapman-Stern (GCS) model of the double layer, for which simple formulae
are available for salt adsorption and capacitive charging of the diffuse part
of the double layer. We solve the full GCS mean-field theory numerically for
realistic parameters in capacitive deionization, and we derive reduced models
for two limiting regimes with different time scales: (i) In the
"super-capacitor regime" of small voltages and/or early times where the porous
electrode acts like a transmission line, governed by a linear diffusion
equation for the electrostatic potential, scaled to the RC time of a single
pore. (ii) In the "desalination regime" of large voltages and long times, the
porous electrode slowly adsorbs neutral salt, governed by coupled, nonlinear
diffusion equations for the pore-averaged potential and salt concentration