Physics API¶
Poisson-Boltzmann solver¶
edl_ml.physics.pb ¶
Poisson-Boltzmann solver for the diffuse layer of a symmetric electrolyte.
The full nonlinear one-dimensional Poisson-Boltzmann equation for a :math:z:z
symmetric electrolyte reads
.. math::
\frac{d^2 \psi}{dx^2} = \frac{2 z e n_0}{\epsilon_r \epsilon_0}
\sinh\!\left(\frac{z e \psi}{k_B T}\right),
with :math:\psi the electrostatic potential, :math:n_0 the bulk number
density of each ion, :math:z the valence, :math:T the temperature and
:math:\epsilon_r the relative permittivity of the solvent.
For a one-dimensional symmetric electrolyte in contact with a planar electrode there is a closed-form first integral
.. math::
\frac{d\psi}{dx} = -\,\mathrm{sgn}(\psi)\;\frac{2 k_B T \kappa}{z e}
\sinh\!\left(\frac{z e \psi}{2 k_B T}\right),
which lets us evaluate the diffuse-layer surface charge density analytically via Gauss's law while still integrating the full nonlinear ODE numerically to recover the spatial profile.
PBParameters
dataclass
¶
Input parameters to the Poisson-Boltzmann solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concentration_mol_l
|
float
|
Bulk electrolyte concentration in mol/L. |
required |
valence
|
int
|
Ionic valence :math: |
1
|
temperature_k
|
float
|
Absolute temperature in Kelvin. |
ROOM_TEMPERATURE
|
relative_permittivity
|
float
|
Relative permittivity of the solvent. |
WATER_PERMITTIVITY
|
psi_diffuse_v
|
float
|
Potential at the Stern / diffuse boundary, in volts. |
0.05
|
domain_debye_lengths
|
float
|
Length of the integration domain measured in Debye lengths. |
30.0
|
n_points
|
int
|
Number of points used to represent the solution on export. |
400
|
Source code in src/edl_ml/physics/pb.py
PBResult
dataclass
¶
Output of the Poisson-Boltzmann solver.
Attributes:
| Name | Type | Description |
|---|---|---|
x_m |
NDArray[float64]
|
Position array in metres, measured from the Stern / diffuse boundary. |
psi_v |
NDArray[float64]
|
Electrostatic potential in volts. |
field_v_m |
NDArray[float64]
|
Electric field :math: |
cation_density_m3 |
NDArray[float64]
|
Cation number density as a function of position, in 1/m³. |
anion_density_m3 |
NDArray[float64]
|
Anion number density as a function of position, in 1/m³. |
surface_charge_c_m2 |
float
|
Diffuse-layer surface charge density, in C/m² (Grahame equation). |
debye_length_m |
float
|
Debye screening length, in metres. |
Source code in src/edl_ml/physics/pb.py
debye_length ¶
debye_length(concentration_mol_l: float, valence: int = 1, temperature_k: float = ROOM_TEMPERATURE, relative_permittivity: float = WATER_PERMITTIVITY) -> float
Return the Debye screening length for a symmetric electrolyte.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concentration_mol_l
|
float
|
Bulk concentration of each ion in mol/L. |
required |
valence
|
int
|
Ionic valence. |
1
|
temperature_k
|
float
|
Temperature in Kelvin. |
ROOM_TEMPERATURE
|
relative_permittivity
|
float
|
Relative permittivity of the solvent. |
WATER_PERMITTIVITY
|
Returns:
| Type | Description |
|---|---|
float
|
Debye length in metres. |
Notes
The Debye length in a symmetric electrolyte is
.. math::
\kappa^{-1} = \sqrt{\frac{\epsilon_r \epsilon_0 k_B T}
{2 N_A e^2 z^2 c}}
where :math:c is the bulk concentration in mol/m³.
Source code in src/edl_ml/physics/pb.py
solve_poisson_boltzmann ¶
Solve the nonlinear Poisson-Boltzmann equation for the diffuse layer.
The first-integral formulation of the Gouy-Chapman equation is integrated
forward from x = 0 with psi(0) = psi_d. This formulation is
equivalent to the full second-order PB equation under the boundary
condition psi → 0 as x → infinity, and is numerically stable
because the bulk fixed point is attracting on forward integration. The
surface charge density is reported via the Grahame equation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
PBParameters
|
Solver parameters. |
required |
Returns:
| Type | Description |
|---|---|
PBResult
|
Potential, field and ion density profiles with the derived surface charge density and Debye length. |
Source code in src/edl_ml/physics/pb.py
Gouy-Chapman-Stern model¶
edl_ml.physics.gcs ¶
Gouy-Chapman-Stern composite double-layer model.
The Stern layer behaves as a molecular condenser with thickness equal to the closest approach of a hydrated ion to the electrode surface, and a dielectric permittivity significantly reduced compared with bulk water due to the orientation of water molecules near the interface.
The total differential capacitance is obtained by placing the Stern and diffuse-layer capacitances in series,
.. math::
\frac{1}{C_\text{dl}} = \frac{1}{C_H} + \frac{1}{C_d},
with :math:C_H = \epsilon_r^H \epsilon_0 / d_H the Helmholtz (Stern)
capacitance and :math:C_d the diffuse-layer capacitance from the
Gouy-Chapman model.
GCSParameters
dataclass
¶
Parameters defining a Gouy-Chapman-Stern electrode-electrolyte interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concentration_mol_l
|
float
|
Bulk electrolyte concentration, mol/L. |
required |
valence
|
int
|
Ionic valence :math: |
1
|
temperature_k
|
float
|
Temperature in Kelvin. |
ROOM_TEMPERATURE
|
stern_thickness_m
|
float
|
Thickness of the Stern (inner Helmholtz) layer, in metres. Typically 3–6 Å. |
3e-10
|
stern_permittivity
|
float
|
Relative permittivity of the Stern layer, dimensionless. For water the oriented interfacial value is ~6. |
6.0
|
bulk_permittivity
|
float
|
Relative permittivity of the bulk solvent, dimensionless. |
WATER_PERMITTIVITY
|
Source code in src/edl_ml/physics/gcs.py
stern_capacitance ¶
Return the Stern (Helmholtz) capacitance per unit area in F/m².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
GCSParameters
|
GCS parameters. |
required |
Returns:
| Type | Description |
|---|---|
float
|
:math: |
Source code in src/edl_ml/physics/gcs.py
diffuse_capacitance ¶
diffuse_capacitance(params: GCSParameters, psi_diffuse_v: float | NDArray[float64]) -> float | NDArray[np.float64]
Gouy-Chapman diffuse-layer differential capacitance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
GCSParameters
|
GCS parameters. Only the bulk-phase properties are used. |
required |
psi_diffuse_v
|
float | NDArray[float64]
|
Potential at the Stern / diffuse boundary, V. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
:math: |
Notes
The closed form is obtained by differentiating the Grahame equation with respect to the diffuse-layer potential.
Source code in src/edl_ml/physics/gcs.py
total_capacitance ¶
total_capacitance(params: GCSParameters, psi_diffuse_v: float | NDArray[float64]) -> float | NDArray[np.float64]
Series combination of the Stern and diffuse-layer capacitances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
GCSParameters
|
GCS parameters. |
required |
psi_diffuse_v
|
float | NDArray[float64]
|
Potential at the Stern / diffuse boundary, V. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
:math: |
Source code in src/edl_ml/physics/gcs.py
gouy_chapman_stern ¶
gouy_chapman_stern(params: GCSParameters, electrode_potentials_v: NDArray[float64], *, max_iter: int = 80, tol: float = 1e-10) -> tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]
Solve the self-consistent Gouy-Chapman-Stern problem.
The electrode potential :math:E relative to the point of zero charge is
split across the Stern and diffuse layers,
.. math::
E = \psi_H + \psi_d,\qquad \psi_H = \sigma / C_H,
with :math:\sigma given by the Grahame equation as a function of
:math:\psi_d. We solve the resulting nonlinear equation in
:math:\psi_d by bisection for each electrode potential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
GCSParameters
|
GCS parameters. |
required |
electrode_potentials_v
|
NDArray[float64]
|
Grid of electrode potentials in volts, relative to the point of zero charge. |
required |
max_iter
|
int
|
Maximum bisection iterations per potential. |
80
|
tol
|
float
|
Absolute tolerance on the residual |
1e-10
|
Returns:
| Type | Description |
|---|---|
surface_charge
|
Array of diffuse-layer surface charge densities, C/m². |
psi_diffuse
|
Array of diffuse-layer potentials, V. |
differential_capacitance
|
Array of total differential capacitances at each electrode potential, F/m². |
Source code in src/edl_ml/physics/gcs.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
Constants¶
edl_ml.physics.constants ¶
Physical constants used throughout the electric double layer model.
All constants are in SI units unless otherwise noted. Values follow CODATA 2018.
ELEMENTARY_CHARGE
module-attribute
¶
Elementary charge, C.
FARADAY
module-attribute
¶
Faraday constant, C/mol.
GAS_CONSTANT
module-attribute
¶
Ideal gas constant, J/(mol K).
ROOM_TEMPERATURE
module-attribute
¶
Reference temperature, K.
VACUUM_PERMITTIVITY
module-attribute
¶
Vacuum permittivity, F/m.
WATER_PERMITTIVITY
module-attribute
¶
Relative permittivity of water at 298.15 K (dimensionless).