General remarks

All physical quantities are assumed to be consistently represented through their values expressed in basic SI units (m, kg, s, A, K, mol, cd), supported by the LessUnitful.jl package built on top of Unitful.jl.

Electrolyte data

LiquidElectrolytes.ElectrolyteDataType
mutable struct ElectrolyteData <: AbstractElectrolyteData

Data for electrolyte. It is defined using Base.@kwdef Leading to keyword constructors like

    ElectrolyteData(nc=3,z=[-1,2,1])

Fields (for default values, see below):

  • nc::Int64: Number of ionic species.

  • na::Int64: Number of surface species

  • iϕ::Int64: Potential index in species list.

  • ip::Int64: Pressure index in species list

  • D::Vector{Float64}: Mobility coefficient

  • z::Vector{Int64}: Charge numbers of ions

  • M0::Float64: Molar weight of solvent

  • M::Vector{Float64}: Molar weights of ions

  • v0::Float64: Molar volume of solvent

  • v::Vector{Float64}: Molar volumes of ions

  • κ::Vector{Float64}: Solvation numbers of ions

  • c_bulk::Vector{Float64}: Bulk ion concentrations

  • ϕ_bulk::Float64: Bulk voltage

  • p_bulk::Float64: Bulk pressure

  • Γ_bulk::Int64: Bulk boundary number

  • ϕ_we::Float64: Working electrode voltage

  • Γ_we::Int64: Working electrode boundary number

  • T::Float64: Temperature

  • RT::Float64: Molar gas constant scaled with temperature

  • F::Float64: Faraday constant

  • ε::Float64: Dielectric permittivity of solvent

  • ε_0::Float64: Dielectric permittivity of vacuum

  • pscale::Float64: Pressure scaling factor

  • eneutral::Bool: Local electroneutrality switch

  • scheme::Symbol: Flux caculation scheme This allows to choose between

    • :μex (default): excess chemical potential (SEDAN) scheme, see sflux
    • :act : scheme based on reciprocal activity coefficients, see aflux
    • :cent : central scheme, see cflux.
  • solvepressure::Bool: Solve for pressure.

    This is true by default. Setting this to false can serve two purposes:

    • Take the pressure from the solution of a flow equation
    • Ignore the pressure contribution to the excess chemical potential
  • weights::Vector{Float64}: Species weights for norms in solver control.
  • edgevelocity::Union{Float64, Vector{Float64}}: Edge velocity projection.
  • model::Symbol: Electrolyte model
source

The default values for electrolyte data are those of an symmetric 0.1M aqueous binary electrolyte at 298.5K with solvation number κ=10, ion molar volumes and masses similar to those of water molecules and diffusion coefficients 2.0e-9 $m^2/s$. All values given in SI base units:

using LiquidElectrolytes
ElectrolyteData()
                  nc = 2
                  na = 0
                  iϕ = 3
                  ip = 4
                   D = [2.0e-9, 2.0e-9]
                   z = [1, -1]
                  M0 = 0.018015
                   M = [0.018015, 0.018015]
                  v0 = 1.8051e-5
                   v = [1.8051e-5, 1.8051e-5]
                   κ = [10.0, 10.0]
              c_bulk = [100.0, 100.0]
              ϕ_bulk = 0.0
              p_bulk = 0.0
              Γ_bulk = 2
                ϕ_we = 0.0
                Γ_we = 1
                   T = 298.15
                  RT = 2479.0
                   F = 96485.0
                   ε = 78.49
                 ε_0 = 8.8542e-12
              pscale = 1.0e9
            eneutral = false
              scheme = μex
       solvepressure = true
             weights = [1.8051e-5, 1.8051e-5, 1.0, 0.0]
        edgevelocity = 0.0
               model = DGL
LiquidElectrolytes.dlcap0Method
dlcap0(electrolyte)

Double layer capacitance at zero voltage for symmetric binary electrolyte.

Example

using LessUnitful
ely = ElectrolyteData(c_bulk=fill(0.01ufac"mol/dm^3",2))
round(dlcap0(ely),sigdigits=5) |> u"μF/cm^2"
# output

22.847 μF cm^-2
source
LiquidElectrolytes.debyelengthMethod
debyelength(electrolyte)

Debye length.

using LessUnitful
ely = ElectrolyteData(c_bulk=fill(0.01ufac"mol/dm^3",2))
round(debyelength(ely),sigdigits=5) |> u"nm"
# output

4.3018 nm
source
LiquidElectrolytes.chargedensityFunction
chargedensity(c,electrolyte)

Calculate charge density from vector of concentrations (in one grid point).

source
chargedensity(sol,electrolyte)

Calculate charge density vector from solution (on whole grid)

source
chargedensity(tsol,electrolyte)

Calculate charge densities from from time/voltage dependent solution solution (on whole grid)

source
LiquidElectrolytes.chemical_potentialFunction
 chemical_potential(c, barc, p, barv, electrolyte)

Calculate chemical potential of species with concentration c

\[ μ = \bar v(p-p_{ref}) + RT\log \frac{c}{\bar c}\]

source
LiquidElectrolytes.chemical_potentials!Function
chemical_potentials!(μ,u,electrolyte)

Calculate chemical potentials from concentrations.

Input:

  • μ: memory for result (will be filled)
  • u: local solution vector (concentrations, potential, pressure)

Returns μ0, μ: chemical potential of solvent and chemical potentials of ions.

using LessUnitful
ely = ElectrolyteData(c_bulk = fill(0.01ufac"mol/dm^3", 2))
μ0, μ = chemical_potentials!([0.0, 0.0], vcat(ely.c_bulk, [0, 0]), ely)
round(μ0, sigdigits = 5), round.(μ, sigdigits = 5)
# output

(-0.89834, [-21359.0, -21359.0])
Breaking change between v0.2 and 0.3

This function has been corrected in version 0.3. Before it used the molar volume $v$ instead of the effective molar volume $\bar v = v + κv_0$ to calculate the ion chemical potentials. Examples with κ=0 are not affected.

source
LiquidElectrolytes.iselectroneutralFunction
iselectroneutral(cx::Vector,celldata)

Check for electroneutrality of concentration vector

source
iselectroneutral(tsol::TransientSolution,celldata)

Check for electroneutrality of transient solution

source
LiquidElectrolytes.isincompressibleFunction
isincompressible(cx::Vector,celldata)

Check for incompressibility of concentration vector

source
isincompressible(tsol::TransientSolution,celldata)

Check for incompressibility of transient solution

source
LiquidElectrolytes.c0_barcFunction
c0_barc(u,electrolyte)

Calculate solvent concentration $c_0$ and summary concentration $\bar c$ from vector of concentrations c using the incompressibility constraint (assuming $κ_0=0$):

\[ \sum_{i=0}^N c_i (v_i + κ_iv_0) =1\]

This gives

\[ c_0v_0=1-\sum_{i=1}^N c_i (v_i+ κ_iv_0)\]

\[c_0= 1/v_0 - \sum_{i=1}^N c_i(\frac{v_i}{v_0}+κ_i)\]

Then we can calculate

\[ \bar c= \sum_{i=0}^N c_i\]

source

Poisson-Nernst-Planck system

LiquidElectrolytes.PNPSystemFunction
PNPSystem(grid;
         celldata=ElectrolyteData(),
         bcondition=(f, u, n, e)-> nothing,
         reaction=(f, u, n, e)-> nothing,
         kwargs...)

Create VoronoiFVM system for generalized Poisson-Nernst-Planck. Input:

  • grid: discretization grid
  • celldata: composite struct containing electrolyte data
  • bcondition: boundary condition
  • reaction : reactions of the bulk species
  • kwargs: Keyword arguments of VoronoiFVM.System
source
LiquidElectrolytes.chemical_potentialsFunction
chemical_potentials(solution, electrolyte)

Calculate chemical potentials from solution. Returns μ0, μ, where μ0 is the vector of solvent chemical potentials, and μ is the nc×nnodes matrix of solute chemical potentials.

source

Poisson-Boltzmann system

LiquidElectrolytes.PBSystemFunction
PBSystem(grid;
         celldata=ElectrolyteData(),
         bcondition=(f, u, n, e)-> nothing,
         kwargs...)

Create VoronoiFVM system generalized Poisson-Boltzmann. Input:

  • grid: discretization grid
  • celldata: composite struct containing electrolyte data
  • bcondition: boundary condition
  • kwargs: Keyword arguments of VoronoiFVM.System
source

Poisson-Nernst-Planck-Stokes system

Utilities

LiquidElectrolytes.RLogType
RLog(eps)

Functor struct for regularized logarithm. Smooth linear continuation for x<eps. This means we can calculate a "logarithm" of a small negative number. Objects of this type are meant to replace the logarithm function.

source
LiquidElectrolytes.RExpType
RExp(trunc)

Functor struct for regularized exponential. Linear continuation for x>trunc, returns 1/rexp(-x) for x<-trunc. Objects of this type are meant to replace the exponential function.

source