Let us assume we deal with ideal systems without interactions.
The gel phase and the supernatant solution phase are in thermodynamic equilibrium. The supernatant solution shall consist of different ion species $i$. The gel is in free swelling equilibrium and the total chemical potential of each ion species $i$ is constant throughout the supernatant phase and the gel phase:
$\mu_i^\mathrm{gel}=\mu_i^\mathrm{supernatant}$. Since the total chemical potential is constant we can just write $\mu_i$ and forget about the phase in which it was determined.
Under the assumption that gel phase is always electroneutral we obtain a Donnanpartitioning of ions: $c_i^\mathrm{gel} \neq c_i^\mathrm{supernatant}$ compare: https://en.wikipedia.org/wiki/Gibbs%E2%80%93Donnan_effect
The difference in concentration between the two phases is allowed (at same total chemical potential) because the total chemical potential not only has the ideal part but also an electric potential part (needed due to the electroneutrality constraint):
$\mu_i=\mu_i^0+kT\ln(c_i/c_0) +z_i e_0 \Psi$. Same total chemical potential at different ion concentration therefore gives rise to the Donnan potential (https://en.wikipedia.org/wiki/Donnan_potential):
$\mu_i^\mathrm{gel}=\mu_i^{supernatant} \Leftrightarrow \Psi^\mathrm{gel}-\Psi^\mathrm{supernatant}=\frac{kT\ln(c_i^\mathrm{supernatant}/c_i^\mathrm{gel})}{z_i e_0}$
Now the question is: Is pH constant (case 1) or is it different (case 2) in the gel phase and the supernatant solution phase.
If pH is defined based on the total chemical potential, then it is constant (because chemical potential is constant) and we have the same pH in the gel and in the supernatant phase: $pH=-\log_{10}(a_H)=-\log_{10}(\exp(\frac{\mu_H-\mu^0}{kT}))$
If we define pH based on the concentrations (or making use of the mean activity coefficient $\hat{\gamma}_i$=1, in which the Donnan Potential cancels), then the pH is different in the gel and in the supernatant phase: $pH^\mathrm{gel}=-\log_{10}(c_H^\mathrm{gel} \hat{\gamma}_H^\mathrm{gel}/c_0) \neq pH^\mathrm{supernatant} =-\log_{10}(c_H^\mathrm{supernatant} \hat{\gamma}_H^\mathrm{supernatant} /c_0),$ where $c_0$ is the standard concentration, i.e. 1mol/l and where the inequality arises from $c_H^\mathrm{gel} \neq c_H^\mathrm{supernatant} $ (due to Donnan partitioning and due to the mean activity coefficients $\hat{\gamma}_H^\mathrm{gel}=1=\hat{\gamma}_H^\mathrm{supernatant}$ for an ideal system.
What is correct? What would we measure when measuring the pH in the gel? Would we measure the same pH as in the supernatant phase (i.e. the first case is correct) or would we measure a pH different from the supernatant phase (i.e. the second case is correct?)
You can view the problem also from a different perspective: pH is defined by IUPAC (https://goldbook.iupac.org/terms/view/P04524) $pH=−\log_{10}[a_H]$, where $a_H$ is the relative activity https://goldbook.iupac.org/terms/view/A00115): $a_H=\exp(\mu_H-\mu_H^0)$
The question is do I need to use
- the total chemical potential in this definition of the activity or
- this definition of activity which you also find in literature (e.g. in this article "THE DONNAN EQUILIBRIUM" by Stell and Joslin, https://www.ncbi.nlm.nih.gov/pubmed/19431690):
$\mu_H=\mu_H^0+kT\ln(a_H)+z_H e_0 \Psi \Leftrightarrow a_H=\exp(\mu_H-\mu_H^0-z_H e_0\Psi)$ ?
In case 1) pH would be equal across both phases, in case 2) pH in both phases would be different: we could write $pH^\mathrm{gel}-pH^\mathrm{supernatant}=-\log_{10}(\exp(\mu_H^\mathrm{gel}-\mu_H^\mathrm{supernatant}-z_H e_0 (\Psi^\mathrm{gel}-\Psi^\mathrm{supernatant})) =-\log_{10}(\exp(-z_H e_0 (\Psi^\mathrm{gel}-\Psi^\mathrm{supernatant}))$