Electrochemical cells
Cell Types
Abstract Types
AugmentedPoissonBoltzmann.SolverCore.AbstractAugmentedPBCell — Type
AbstractAugmentedPBCellAbstract base type for all modified Poisson-Boltzmann cell types. Provides a common interface for different cell configurations.
AugmentedPoissonBoltzmann.SolverCore.AbstractHalfCell — Type
AbstractHalfCell <: AbstractAugmentedPBCellAbstract type for half-cell configurations where only one electrode is modeled.
AugmentedPoissonBoltzmann.SolverCore.AbstractSymmetricCell — Type
AbstractSymmetricCell <: AbstractAugmentedPBCellAbstract type for symmetric cell configurations with two identical electrodes.
Concrete Cell Types
AugmentedPoissonBoltzmann.SolverCore.AppliedPotentialHalfCell — Type
AppliedPotentialHalfCell <: AbstractHalfCellHalf-cell configuration with applied potential boundary condition.
Fields
sys::VoronoiFVM.System: The finite volume system containing the discretization and physics
This cell type is used for simulations where the electrode potential is controlled (potentiostatic conditions). The potential is applied at one boundary while the other boundary is typically grounded.
AugmentedPoissonBoltzmann.SolverCore.AppliedPotentialSymmetricCell — Type
AppliedPotentialSymmetricCell <: AbstractAugmentedPBCellSymmetric cell configuration with applied potential.
Fields
sys::VoronoiFVM.System: The finite volume system containing the discretization and physics
This cell type represents a symmetric configuration where both electrodes are identical and a potential is applied across them.
AugmentedPoissonBoltzmann.SolverCore.SurfaceChargedHalfCell — Type
SurfaceChargedHalfCell <: AbstractHalfCellHalf-cell configuration with surface charge boundary condition.
Fields
sys::VoronoiFVM.System: The finite volume system containing the discretization and physics
This cell type is used for simulations where the electrode surface charge is specified rather than the potential.
AugmentedPoissonBoltzmann.SolverCore.SurfaceChargedSymmetricCell — Type
SurfaceChargedSymmetricCell <: AbstractSymmetricCellSymmetric cell configuration with surface charge boundary conditions.
Fields
sys::VoronoiFVM.System: The finite volume system containing the discretization and physics
This cell type represents a symmetric configuration where surface charges are specified at both electrodes. Ion conservation is enforced in this configuration.
Cell Constructors
AugmentedPoissonBoltzmann.SolverCore.AppliedPotentialHalfCell — Method
AppliedPotentialHalfCell(grid, data; dielectric_decrement=false, valuetype=Float64)Create a half-cell with applied potential boundary conditions.
Arguments
grid: Computational griddata::AugmentedPBData: Problem data containing physical parameters
Keyword Arguments
dielectric_decrement::Bool: Enable field-dependent dielectric decrement model (default: false)valuetype::Type: Floating point type for calculations (default: Float64)
Returns
AppliedPotentialHalfCell: Cell object ready for solving
Features
- Ion conservation is disabled
- Dense matrix storage for efficiency in small systems
- Suitable for potentiostatic simulations
- Boundary conditions: applied potential at one electrode, grounded at the other
Example
data = AugmentedPBData(z=[-1, 1], q=[0.0, 0.0])
set_molarity!(data, 0.1)
grid = simplexgrid(0:0.01:1)
cell = AppliedPotentialHalfCell(grid, data)
set_φ!(cell, 0.5) # Apply 0.5 V
sol = solve(cell)AugmentedPoissonBoltzmann.SolverCore.SurfaceChargedSymmetricCell — Method
SurfaceChargedSymmetricCell(grid, data; dielectric_decrement=false, valuetype=Float64)Create a symmetric cell with surface charge boundary conditions and ion conservation.
Arguments
grid: Computational grid (should have a boundary region at the center)data::AugmentedPBData: Problem data containing physical parameters
Keyword Arguments
dielectric_decrement::Bool: Enable field-dependent dielectric decrement model (default: false)valuetype::Type: Floating point type for calculations (default: Float64)
Returns
SurfaceChargedSymmetricCell: Cell object ready for solving
Features
- Boundary conditions: specified surface charges at both electrodes
- Ion conservation is enabled
- Sparse matrix storage of solution in ion-conserving systems
- Symmetric configuration with identical electrodes
Grid Requirements
The grid must have three boundary regions:
- Region 1: Left electrode
- Region 2: Right electrode
- Region 3: Center point (for pressure uniqueness and ion conservation constraints)
Example
data = AugmentedPBData(z=[-1, 1], q=[0.16, -0.16])
set_molarity!(data, 0.1)
X = range(0, 1e-9, length=21)
grid = simplexgrid(X)
bfacemask!(grid, [5e-10], [5e-10], 3) # Mark center
cell = SurfaceChargedSymmetricCell(grid, data)
sol = solve(cell)Solving and Initialization
VoronoiFVM.unknowns — Method
VoronoiFVM.unknowns(cell::AbstractAugmentedPBCell)Initialize and return the unknown vector for a given cell.
Arguments
cell::AbstractAugmentedPBCell: The cell configuration
Returns
- Initial unknown vector with appropriate structure and values
The unknowns include:
- Ion mole fractions (y_α for α = 1,...,N)
- Solvent mole fraction (y_0)
- Electric potential (φ)
- Pressure (p)
- Electric field strength (E)
- For ion-conserving cells: bulk ion concentrations at the domain center
Initial values are set to reasonable defaults (mole fractions ≈ 0.1 for ions, adjusted for solvent to maintain sum = 1).
CommonSolve.solve — Method
SciMLBase.solve(cell::AbstractAugmentedPBCell; inival=unknowns(cell), verbose="", damp_initial=0.1, kwargs...)Solve the modified Poisson-Boltzmann system for the given cell configuration.
Arguments
cell::AbstractAugmentedPBCell: The cell configuration to solve
Keyword Arguments
inival: Initial values for the unknowns (default:unknowns(cell))verbose::String: Verbosity level ("", "n" for newton info, etc.)damp_initial::Float64: Initial damping parameter for Newton solver (default: 0.1)kwargs...: Additional arguments passed to the VoronoiFVM solver
Returns
- Solution object containing the computed unknowns at all grid nodes
Uses a damped Newton method to solve the nonlinear system of equations.
Helper Functions
Data Access
AugmentedPoissonBoltzmann.SolverCore.apbdata — Function
apbdata(cell::AbstractAugmentedPBCell)Extract the AugmentedPBData structure from a cell.
Arguments
cell::AbstractAugmentedPBCell: The cell configuration
Returns
AugmentedPBData: The data structure containing physical parameters
Calculation Functions
AugmentedPoissonBoltzmann.SolverCore.calc_cmol — Method
calc_cmol(sol, cell::AbstractAugmentedPBCell)Calculate ion concentrations in mol/L from the solution.
Arguments
sol: Solution vector from the solvercell::AbstractAugmentedPBCell: The cell configuration
Returns
- Matrix of ion concentrations in mol/L (one row per species, one column per node)
AugmentedPoissonBoltzmann.SolverCore.calc_c0mol — Method
calc_c0mol(sol, cell::AbstractAugmentedPBCell)Calculate solvent concentration in mol/L from the solution.
Arguments
sol: Solution vector from the solvercell::AbstractAugmentedPBCell: The cell configuration
Returns
- Vector of solvent concentrations in mol/L (one value per node)
AugmentedPoissonBoltzmann.SolverCore.calc_χ — Method
calc_χ(sol, cell::AbstractAugmentedPBCell)Calculate electric susceptibility from the solution.
Arguments
sol: Solution vector from the solvercell::AbstractAugmentedPBCell: The cell configuration
Returns
- Vector of susceptibility values (one value per node)
Getter Functions
AugmentedPoissonBoltzmann.SolverCore.get_E — Function
get_E(sol, cell::AbstractAugmentedPBCell)Extract electric field strength from the solution.
Arguments
sol: Solution vector from the solvercell::AbstractAugmentedPBCell: The cell configuration
Returns
- Vector of electric field strengths in V/m (one value per node)
AugmentedPoissonBoltzmann.SolverCore.get_φ — Function
get_φ(sol, cell::AbstractAugmentedPBCell)Extract electric potential from the solution.
Arguments
sol: Solution vector from the solvercell::AbstractAugmentedPBCell: The cell configuration
Returns
- Vector of electric potentials in V (one value per node)
AugmentedPoissonBoltzmann.SolverCore.get_p — Function
get_p(sol, cell::AbstractAugmentedPBCell)Extract pressure from the solution.
Arguments
sol: Solution vector from the solvercell::AbstractAugmentedPBCell: The cell configuration
Returns
- Vector of pressures in Pa (one value per node)
Setter Functions
AugmentedPoissonBoltzmann.SolverCore.set_κ! — Function
set_κ!(cell::AbstractAugmentedPBCell, κ::Number)Set the ion solvation number for all ionic species.
Arguments
cell::AbstractAugmentedPBCell: The cell configurationκ::Number: Solvation number (number of solvent molecules per ion)
This sets the same solvation number for all ions in the system.
AugmentedPoissonBoltzmann.SolverCore.set_molarity! — Method
set_molarity!(cell::AbstractAugmentedPBCell, M)Set the bulk electrolyte molarity.
Arguments
cell::AbstractAugmentedPBCell: The cell configurationM: Molarity in mol/L
Updates the bulk ion concentrations and related parameters in the cell data.
AugmentedPoissonBoltzmann.SolverCore.set_φ! — Function
set_φ!(cell::AbstractAugmentedPBCell, φ::Number)Set the applied electrode potential.
Arguments
cell::AbstractAugmentedPBCell: The cell configurationφ::Number: Applied potential in V
Relevant for applied potential boundary conditions.
AugmentedPoissonBoltzmann.SolverCore.set_q! — Function
set_q!(cell::AbstractAugmentedPBCell, q::Number)Set the surface charge at the electrodes.
Arguments
cell::AbstractAugmentedPBCell: The cell configurationq::Number: Surface charge density in C/m²
Sets symmetric charges: +q at one electrode and -q at the other. Relevant for surface charge boundary conditions.
Analysis Functions
AugmentedPoissonBoltzmann.SolverCore.dlcapsweep — Function
dlcapsweep(cell::AppliedPotentialHalfCell; φ_max=1.0, δφ=1.0e-5, steps=51, damp_initial=1, kwargs...)Sweep electrode potential and calculate differential capacitance of the double layer.
Arguments
cell::AppliedPotentialHalfCell: Half-cell with applied potential
Keyword Arguments
φ_max::Float64: Maximum absolute potential in V (default: 1.0)δφ::Float64: Small potential increment for numerical derivative (default: 1.0e-5)steps::Int: Number of steps in the sweep (default: 51)damp_initial::Float64: Initial damping for Newton solver (default: 1)kwargs...: Additional arguments passed to the solver
Returns
volts::Vector: Applied potentials in Vdlcaps::Vector: Differential double layer capacitances in F/m²
Method
The differential capacitance is calculated as:
\[C_{dl} = \frac{dQ}{dφ} ≈ \frac{Q(φ + δφ) - Q(φ)}{δφ}\]
The sweep proceeds from φ = 0 to φ_max in both positive and negative directions, using parameter continuation for robustness.
Example
cell = AppliedPotentialHalfCell(grid, data)
volts, caps = dlcapsweep(cell, φ_max=0.5, steps=101)Boundary Conditions (Internal)
AugmentedPoissonBoltzmann.SolverCore.halfcell_applied_potential_bcondition! — Function
halfcell_applied_potential_bcondition!(y, u, bnode, data)Boundary condition callback for half-cell with applied potential.
Arguments
y: Boundary residual vectoru: Solution values at the boundary nodebnode: Boundary node informationdata::AugmentedPBData: Problem data
Applies:
- Dirichlet condition for φ at region 1 (working electrode): φ = data.φ
- Dirichlet condition for φ at region 2 (reference): φ = 0
- Dirichlet condition for pressure at region 2: p = 0
AugmentedPoissonBoltzmann.SolverCore.symmcell_surfacecharge_bcondition! — Function
symmcell_surfacecharge_bcondition!(y, u, bnode, data)Boundary condition callback for symmetric cell with surface charge.
Arguments
y: Boundary residual vectoru: Solution values at the boundary nodebnode: Boundary node informationdata::AugmentedPBData: Problem data
Applies:
- Neumann condition for φ at region 1 (left electrode): -∇φ·n = q[1]
- Neumann condition for φ at region 2 (right electrode): -∇φ·n = q[2]
- Dirichlet condition for pressure at region 3 (center): p = 0
The pressure condition at the domain center ensures uniqueness of the pressure solution.