Electrochemical cells

Cell Types

Abstract Types

Concrete Cell Types

AugmentedPoissonBoltzmann.SolverCore.AppliedPotentialHalfCellType
AppliedPotentialHalfCell <: AbstractHalfCell

Half-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.

source
AugmentedPoissonBoltzmann.SolverCore.AppliedPotentialSymmetricCellType
AppliedPotentialSymmetricCell <: AbstractAugmentedPBCell

Symmetric 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.

source
AugmentedPoissonBoltzmann.SolverCore.SurfaceChargedHalfCellType
SurfaceChargedHalfCell <: AbstractHalfCell

Half-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.

source
AugmentedPoissonBoltzmann.SolverCore.SurfaceChargedSymmetricCellType
SurfaceChargedSymmetricCell <: AbstractSymmetricCell

Symmetric 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.

source

Cell Constructors

AugmentedPoissonBoltzmann.SolverCore.AppliedPotentialHalfCellMethod
AppliedPotentialHalfCell(grid, data; dielectric_decrement=false, valuetype=Float64)

Create a half-cell with applied potential boundary conditions.

Arguments

  • grid: Computational grid
  • 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

  • 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)
source
AugmentedPoissonBoltzmann.SolverCore.SurfaceChargedSymmetricCellMethod
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)
source

Solving and Initialization

VoronoiFVM.unknownsMethod
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).

source
CommonSolve.solveMethod
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.

source

Helper Functions

Data Access

AugmentedPoissonBoltzmann.SolverCore.apbdataFunction
apbdata(cell::AbstractAugmentedPBCell)

Extract the AugmentedPBData structure from a cell.

Arguments

  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • AugmentedPBData: The data structure containing physical parameters
source

Calculation Functions

AugmentedPoissonBoltzmann.SolverCore.calc_cmolMethod
calc_cmol(sol, cell::AbstractAugmentedPBCell)

Calculate ion concentrations in mol/L from the solution.

Arguments

  • sol: Solution vector from the solver
  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • Matrix of ion concentrations in mol/L (one row per species, one column per node)
source
AugmentedPoissonBoltzmann.SolverCore.calc_c0molMethod
calc_c0mol(sol, cell::AbstractAugmentedPBCell)

Calculate solvent concentration in mol/L from the solution.

Arguments

  • sol: Solution vector from the solver
  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • Vector of solvent concentrations in mol/L (one value per node)
source
AugmentedPoissonBoltzmann.SolverCore.calc_χMethod
calc_χ(sol, cell::AbstractAugmentedPBCell)

Calculate electric susceptibility from the solution.

Arguments

  • sol: Solution vector from the solver
  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • Vector of susceptibility values (one value per node)
source

Getter Functions

AugmentedPoissonBoltzmann.SolverCore.get_EFunction
get_E(sol, cell::AbstractAugmentedPBCell)

Extract electric field strength from the solution.

Arguments

  • sol: Solution vector from the solver
  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • Vector of electric field strengths in V/m (one value per node)
source
AugmentedPoissonBoltzmann.SolverCore.get_φFunction
get_φ(sol, cell::AbstractAugmentedPBCell)

Extract electric potential from the solution.

Arguments

  • sol: Solution vector from the solver
  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • Vector of electric potentials in V (one value per node)
source
AugmentedPoissonBoltzmann.SolverCore.get_pFunction
get_p(sol, cell::AbstractAugmentedPBCell)

Extract pressure from the solution.

Arguments

  • sol: Solution vector from the solver
  • cell::AbstractAugmentedPBCell: The cell configuration

Returns

  • Vector of pressures in Pa (one value per node)
source

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.

source
AugmentedPoissonBoltzmann.SolverCore.set_molarity!Method
set_molarity!(cell::AbstractAugmentedPBCell, M)

Set the bulk electrolyte molarity.

Arguments

  • cell::AbstractAugmentedPBCell: The cell configuration
  • M: Molarity in mol/L

Updates the bulk ion concentrations and related parameters in the cell data.

source
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.

source
AugmentedPoissonBoltzmann.SolverCore.set_q!Function
set_q!(cell::AbstractAugmentedPBCell, q::Number)

Set the surface charge at the electrodes.

Arguments

  • cell::AbstractAugmentedPBCell: The cell configuration
  • q::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.

source

Analysis Functions

AugmentedPoissonBoltzmann.SolverCore.dlcapsweepFunction
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 V
  • dlcaps::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)
source

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 vector
  • u: Solution values at the boundary node
  • bnode: Boundary node information
  • data::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
source
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 vector
  • u: Solution values at the boundary node
  • bnode: Boundary node information
  • data::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.

source