# This cell is deactivated in file, so it is not executed during CI.
begin
    using Pkg
    Pkg.activate(joinpath(@__DIR__, "..", "docs"))
    using Revise
    using CairoMakie
    using GridVisualize
    default_plotter!(CairoMakie)
    using Colors
    set_theme!(theme_dark())

end
begin
    using Test
    using LiquidElectrolytes
    using ExtendableGrids
    using LessUnitful
    using PlutoUI
    using VoronoiFVM
    using LinearAlgebra
end
PlutoUI.TableOfContents()

Implementing IR compensation

General data

Data according to "Simulation of the cyclic voltammetric response of an outer-sphere redox species with inclusion of electrical double layer structure and ohmic potential drop" by Levey et al, PCCP 2023, https://doi.org/10.1039/D3CP00098B.

begin
    scanrate = 100ufac"V/s"
    vmin = -0.5ufac"V"
    vmax = 0.1ufac"V"
    L = 1ufac"mm"
    nperiods = 2
    C_elec = 0.01ufac"mol/dm^3"
    C_O = 1.0e-3 * ufac"mol / dm^3"
    C_R = 1.0e-10 * ufac"mol / dm^3"
    ircompfactor = 0.95
    z = [3, 2, 1, -1]
    f_κ = 2

end;
begin
    const k0::Float64 = 13.5 * ufac"cm / s"
    const α = 0.45
    const E0::Float64 = -0.173ufac"V"
    const k0::Float64 = 13.5 * ufac"cm / s"
    const iO = 1
    const iR = 2
end;

Dielectric decrement: this is in the moment an experiemental feature due to lack of an implementation of a better model.

function ε_dec(x)
    if x[1] < 1.0e-9
        return 0.01
    else
        return 1.0
    end
end
ε_dec (generic function with 1 method)

Activity coefficient functions for testing; not used in the moment.

function pbi_gamma!(γ, c, p, electrolyte)
    sumc = zero(eltype(c))
    for i in 1:electrolyte.nc
        sumc += c[i]
    end
    g = 1.0 / (1.0 - sumc * electrolyte.v0)
    for i in 1:electrolyte.nc
        γ[i] = g
    end
    return nothing
end
pbi_gamma! (generic function with 1 method)
function pbo_gamma!(γ, c, p, electrolyte)
    (; cspecies) = electrolyte
    for ic in cspecies
        γ[ic] = 1
    end
    return nothing
end
pbo_gamma! (generic function with 1 method)

Electrolyte data for calculations without IR compensation

edata_unc = ElectrolyteData(;
    nc = 4,
    z,
    c_bulk = [C_O, C_R, C_elec, C_elec + z[1] * C_O + z[2] * C_R],
    κ = [10, 10, 10, 10.0] * f_κ,
    D = [
        7.5e-6,
        10.4e-6,
        2.0e-5,
        1.9e-5,
    ] * ufac"cm^2/s",
    ε = 80.0,
    T = 293.15 * ufac"K",
    # Position of "pseudo reference electrode" for pseudopotentiostat approach
    x_ref = [10.0 * ufac"nm"],
    # Dielectric decrement
    ε_dec,
    # Redox reaction function to be evaluated during ohmic drop compensation
    redoxreaction,
    # IR compensation factor used during ohmic drop compensation
    ircompfactor,

    # alternative activity coefficients
    # actcoeff! = pbi_gamma!,
)
ElectrolyteData(
nc = 4, 
cspecies = [1, 2, 3, 4], 
na = 0, 
sspecies = Int64[], 
iϕ = 5, 
ip = 6, 
iq = 7, 
icc = 8, 
D = [7.5e-10, 1.04e-9, 2.0e-9, 1.9e-9], 
z = [3, 2, 1, -1], 
M0 = 0.018015, 
M = [0.018015, 0.018015, 0.018015, 0.018015], 
v0 = 1.8051e-5, 
v = [1.8051e-5, 1.8051e-5, 1.8051e-5, 1.8051e-5], 
κ = [20.0, 20.0, 20.0, 20.0], 
actcoeff! = DGML_gamma!, 
redoxreaction = redoxreaction, 
ircompensation = :none, 
ircompfactor = 0.95, 
Ru = 0.0, 
C_gap = 1.0e15, 
ϕ_pzc = 0.0, 
c_bulk = [1.0, 1.0e-7, 10.0, 13.0], 
x_ref = [1.0e-8], 
Γ_we = 1, 
Γ_bulk = 2, 
ϕ_bulk = 0.0, 
p_bulk = 0.0, 
T = 293.15, 
ε = 80.0, 
ε_dec = ε_dec, 
rexp = exp, 
rlog = log, 
pscale = 1.0e9, 
eneutral = false, 
upwindflux! = μex_flux!, 
weights = [1.8051e-5, 1.8051e-5, 1.8051e-5, 1.8051e-5, 1.0, 0.0, 0.0, 0.0], 
solvepressure = true, 
F = 96485.0, 
ε_0 = 8.8542e-12, 
RT = 2437.4, 
Mrel = [21.0, 21.0, 21.0, 21.0], 
vrel = [21.0, 21.0, 21.0, 21.0], 
barv = [0.00037906, 0.00037906, 0.00037906, 0.00037906], 
tildev = [5.421e-20, 5.421e-20, 5.421e-20, 5.421e-20], 
γ_bulk = [1.0, 1.0, 1.0, 1.0], 
γk_cache = DiffCache, 
γl_cache = DiffCache, 
i_ref = 0, 
ϕ_we = 0.0, 
ϕ_we_set = Inf, 
edgevelocity = 0.0, 
nv = Float64[], 
scheme = :deprecated, 
)
@test iselectroneutral(edata_unc.c_bulk, edata_unc)
�[32m�[1mTest Passed�[22m�[39m

Estimate of uncompensated resistance based on bulk concentrations

R_u = L / LiquidElectrolytes.conductivity(edata_unc, edata_unc.c_bulk)
0.005088808471190595

Electrolyte data for calculations with IR compensation by the "pseudopotentionstat" approach.

begin
    edata_pts = deepcopy(edata_unc)
    edata_pts.ircompensation = :pseudopotentiostat
    edata_pts
end
ElectrolyteData(
nc = 4, 
cspecies = [1, 2, 3, 4], 
na = 0, 
sspecies = Int64[], 
iϕ = 5, 
ip = 6, 
iq = 7, 
icc = 8, 
D = [7.5e-10, 1.04e-9, 2.0e-9, 1.9e-9], 
z = [3, 2, 1, -1], 
M0 = 0.018015, 
M = [0.018015, 0.018015, 0.018015, 0.018015], 
v0 = 1.8051e-5, 
v = [1.8051e-5, 1.8051e-5, 1.8051e-5, 1.8051e-5], 
κ = [20.0, 20.0, 20.0, 20.0], 
actcoeff! = DGML_gamma!, 
redoxreaction = redoxreaction, 
ircompensation = :pseudopotentiostat, 
ircompfactor = 0.95, 
Ru = 0.0, 
C_gap = 1.0e15, 
ϕ_pzc = 0.0, 
c_bulk = [1.0, 1.0e-7, 10.0, 13.0], 
x_ref = [1.0e-8], 
Γ_we = 1, 
Γ_bulk = 2, 
ϕ_bulk = 0.0, 
p_bulk = 0.0, 
T = 293.15, 
ε = 80.0, 
ε_dec = ε_dec, 
rexp = exp, 
rlog = log, 
pscale = 1.0e9, 
eneutral = false, 
upwindflux! = μex_flux!, 
weights = [1.8051e-5, 1.8051e-5, 1.8051e-5, 1.8051e-5, 1.0, 0.0, 0.0, 0.0], 
solvepressure = true, 
F = 96485.0, 
ε_0 = 8.8542e-12, 
RT = 2437.4, 
Mrel = [21.0, 21.0, 21.0, 21.0], 
vrel = [21.0, 21.0, 21.0, 21.0], 
barv = [0.00037906, 0.00037906, 0.00037906, 0.00037906], 
tildev = [5.421e-20, 5.421e-20, 5.421e-20, 5.421e-20], 
γ_bulk = [1.0, 1.0, 1.0, 1.0], 
γk_cache = DiffCache, 
γl_cache = DiffCache, 
i_ref = 0, 
ϕ_we = 0.0, 
ϕ_we_set = Inf, 
edgevelocity = 0.0, 
nv = Float64[], 
scheme = :deprecated, 
)

Electrolyte data for calculations with IR compensation by ohmic drop compensation via the estimate of the uncompensated resistance.

begin
    edata_odr = deepcopy(edata_unc)
    edata_odr.ircompensation = :ohmicdrop
    edata_odr.Ru = R_u
    edata_odr
end
ElectrolyteData(
nc = 4, 
cspecies = [1, 2, 3, 4], 
na = 0, 
sspecies = Int64[], 
iϕ = 5, 
ip = 6, 
iq = 7, 
icc = 8, 
D = [7.5e-10, 1.04e-9, 2.0e-9, 1.9e-9], 
z = [3, 2, 1, -1], 
M0 = 0.018015, 
M = [0.018015, 0.018015, 0.018015, 0.018015], 
v0 = 1.8051e-5, 
v = [1.8051e-5, 1.8051e-5, 1.8051e-5, 1.8051e-5], 
κ = [20.0, 20.0, 20.0, 20.0], 
actcoeff! = DGML_gamma!, 
redoxreaction = redoxreaction, 
ircompensation = :ohmicdrop, 
ircompfactor = 0.95, 
Ru = 0.0050888, 
C_gap = 1.0e15, 
ϕ_pzc = 0.0, 
c_bulk = [1.0, 1.0e-7, 10.0, 13.0], 
x_ref = [1.0e-8], 
Γ_we = 1, 
Γ_bulk = 2, 
ϕ_bulk = 0.0, 
p_bulk = 0.0, 
T = 293.15, 
ε = 80.0, 
ε_dec = ε_dec, 
rexp = exp, 
rlog = log, 
pscale = 1.0e9, 
eneutral = false, 
upwindflux! = μex_flux!, 
weights = [1.8051e-5, 1.8051e-5, 1.8051e-5, 1.8051e-5, 1.0, 0.0, 0.0, 0.0], 
solvepressure = true, 
F = 96485.0, 
ε_0 = 8.8542e-12, 
RT = 2437.4, 
Mrel = [21.0, 21.0, 21.0, 21.0], 
vrel = [21.0, 21.0, 21.0, 21.0], 
barv = [0.00037906, 0.00037906, 0.00037906, 0.00037906], 
tildev = [5.421e-20, 5.421e-20, 5.421e-20, 5.421e-20], 
γ_bulk = [1.0, 1.0, 1.0, 1.0], 
γk_cache = DiffCache, 
γl_cache = DiffCache, 
i_ref = 0, 
ϕ_we = 0.0, 
ϕ_we_set = Inf, 
edgevelocity = 0.0, 
nv = Float64[], 
scheme = :deprecated, 
)

Sawtooth voltage control:

sawtooth = SawTooth(; scanrate, vmin, vmax)
SawTooth(-0.5, 0.1, 100.0, 0.0, 0.0, true)

Redox rection function using the rate expressions according to Landstorfer et al.:

function redoxreaction(f, u, bnode, data)
    (; ip, iϕ, v, v0, F, RT, κ) = data
    c0, barc = c0_barc(u, data)
    μR = chemical_potential(u[iR], barc, u[ip], v[iR] + κ[iR] * v0, data)
    μO = chemical_potential(u[iO], barc, u[ip], v[iO] + κ[iO] * v0, data)
    A = (μR - μO - F * E0) / RT
    j_O = rrate(k0, α, A)
    f[iO] -= j_O
    f[iR] += j_O
    return
end
redoxreaction (generic function with 1 method)

Half cell boundary condition. In order to accomodate the different types of IR compensation, we need to be careful when to call evaluate the redox reaction, and when to set the working electrode voltage.

function halfcellbc(f, u, bnode, data)
    (; Γ_we, Γ_bulk, ϕ_we, iϕ, ircompensation) = data
    bulkbcondition(f, u, bnode, data; region = Γ_bulk)
    if bnode.region == Γ_we
        if ircompensation == :none
            # With IR compensation, working electrode voltage is set by a generic
            # operator which adds the necessary compensation value to ϕ_we which is
            # internally defined by the sawtooth function
            potentialbcondition!(f, u, bnode, data, ϕ_we)
        end
        if ircompensation != :ohmicdrop
            # Ohmic drop compensation needs to evaluate the faradaic current, so the
            # reaction expression is invoked in the generic operator
            redoxreaction(f, u, bnode, data)
        end
    end
    return nothing
end
halfcellbc (generic function with 1 method)

Grid and simulation function

begin
    hmin = 0.01ufac"nm"
    hmax = L / 50
    X = geomspace(0, L, hmin, hmax)
    grid = simplexgrid(X)
end
ExtendableGrids.ExtendableGrid{Float64, Int32}
      dim =       1
   nnodes =     721
   ncells =     720
  nbfaces =       2
function simulate(
        grid, celldata;
        damp_initial = 0.5,
        tol_round = 1.0e-9,
        max_round = 3,
        kwargs...

    )

    pnpcell = PNPSystem(grid; bcondition = halfcellbc, celldata)
    cvresult = LiquidElectrolytes.cvsweep(
        pnpcell;
        voltages = sawtooth,
        nperiods,
        store_solutions = true,
        handle_exceptions = true,
        damp_initial,
        tol_round,
        max_round,
        kwargs...
    )
    return pnpcell, cvresult
end
simulate (generic function with 1 method)

Run simulations

cell_unc, cvresult_unc = simulate(grid, edata_unc)
(PNPSystem(VoronoiFVM.System{Float64, Float64, Int32, Int64, Matrix{Int32}}(
  grid = ExtendableGrids.ExtendableGrid{Float64, Int32}(dim=1, nnodes=721, ncells=720,
  nbfaces=2),  
  physics = Physics(data=LiquidElectrolytes.ElectrolyteData{typeof(LiquidElectrolytes.DG
  ML_gamma!), PreallocationTools.DiffCache{Vector{Float64}, Vector{Float64}},
  typeof(exp), typeof(log), typeof(LiquidElectrolytes.μex_flux!),
  typeof(Main.var"workspace#4".ε_dec), typeof(Main.var"workspace#4".redoxreaction)},
  flux=pnpflux!, storage=pnpstorage!, reaction=_pnpreaction!, breaction=halfcellbc,
  bstorage=pnpbstorage!, ),  
  num_species = 6)), CVSweepResult([0.0011999999999999789, 0.0026399999999999757, 0.0043680000000000385, 0.006441600000000047, 0.008929920000000036, 0.011915903999999977, 0.015499084799999951, 0.019798901759999987, 0.02495868211200003, 0.031150418534400037  …  -0.09202227762866644, -0.08002227762866654, -0.0680222776286667, -0.05602227762866685, -0.044022277628667006, -0.03301670822150038, -0.024762531166125257, -0.016508354110750134, -0.008254177055375012, 1.1102230246251565e-16], [1.2e-5, 2.6399999999999998e-5, 4.3679999999999995e-5, 6.441599999999999e-5, 8.929919999999999e-5, 0.00011915903999999998, 0.00015499084799999998, 0.00019798901759999997, 0.00024958682111999995, 0.0003115041853439999  …  0.023079777223713335, 0.023199777223713334, 0.023319777223713332, 0.02343977722371333, 0.02355977722371333, 0.023669832917784996, 0.023752374688338747, 0.023834916458892498, 0.02391745822944625, 0.024], Any[[3.300863552491151e-8, -3.300863552491151e-8, -0.0, -0.0, -0.0, -0.0], [9.28329856036969e-8, -9.28329856036969e-8, -0.0, -0.0, -0.0, -0.0], [1.788296201171713e-7, -1.788296201171713e-7, -0.0, -0.0, -0.0, -0.0], [2.916596170127184e-7, -2.916596170127184e-7, -0.0, -0.0, -0.0, -0.0], [4.3016367877235506e-7, -4.3016367877235506e-7, -0.0, -0.0, -0.0, -0.0], [5.896763695634189e-7, -5.896763695634189e-7, -0.0, -0.0, -0.0, -0.0], [7.604754516060687e-7, -7.604754516060687e-7, -0.0, -0.0, -0.0, -0.0], [9.270454471477231e-7, -9.270454471477231e-7, -0.0, -0.0, -0.0, -0.0], [1.0694122423055009e-6, -1.0694122423055009e-6, -0.0, -0.0, -0.0, -0.0], [1.1675773479696839e-6, -1.1675773479696839e-6, -0.0, -0.0, -0.0, -0.0]  …  [0.0001314602288228406, -0.0001314602288228406, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00014830730419427676, -0.00014830730419427676, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00016480894923828594, -0.00016480894923828594, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00018089553510213465, -0.00018089553510213465, -0.0, -0.0, -0.027755575615628914, -0.0], [0.0001964845928127973, -0.0001964845928127973, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00021020334039257072, -0.00021020334039257072, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00021995673382298132, -0.00021995673382298132, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00022947871602760518, -0.00022947871602760518, -0.0, -0.0, -0.027755575615628914, -0.0], [0.00023858030482130644, -0.00023858030482130644, -0.0, -0.0, -0.026020852139652106, -0.0], [0.0002471938540562818, -0.0002471938540562818, -0.0, -0.0, -0.02628868595826693, -0.0]], Any[[9.795142512487414e-8, 1.1030312945067563e-9, 8.804870585269537e-7, -1.0874001406951907e-6, 7.865046789317972e-10, -6.928014792656935e-19], [2.065908978606699e-7, 1.1041053706876746e-9, 1.8461840446102298e-6, -2.2800341523865934e-6, 1.6504765294164521e-9, 4.0014332652582497e-19], [3.2374464901360927e-7, 1.105264511347673e-9, 2.887564513847676e-6, -3.5661369775101957e-6, 2.5821952877279767e-9, -3.182881020921476e-17], [4.475027300810751e-7, 1.1064900377428581e-9, 3.987650980850378e-6, -4.924742124064398e-6, 3.5664369785770907e-9, 1.3538328461810355e-19], [5.749738366758727e-7, 1.1077535179445079e-9, 5.120742470508849e-6, -6.324108109949618e-6, 4.58019025435793e-9, -3.703775292414519e-20], [7.022575291814369e-7, 1.1090164010843195e-9, 6.252168438167572e-6, -7.721416970240888e-6, 5.592437844440599e-9, -2.171551861698356e-19], [8.246891482085213e-7, 1.1102325238955158e-9, 7.340463827221467e-6, -9.065460012888484e-6, 6.566130412391214e-9, -1.0987845811621264e-19], [9.375847945822289e-7, 1.111355374701159e-9, 8.3439941187068e-6, -1.030481814744737e-5, 7.463979451424426e-9, 4.975386104976796e-19], [1.0376799854781778e-6, 1.1123524391871967e-9, 9.233741099349516e-6, -1.1403654141926064e-5, 8.2600295424398e-9, -1.1259410081411188e-18], [1.1251382732782002e-6, 1.1132252896812553e-9, 1.0011158512588205e-5, -1.2363763210356547e-5, 8.955571194014609e-9, -1.48004254204034e-18]  …  [7.3020075232938645e-6, 1.1690362981800558e-9, 6.491734555596498e-5, -8.017282830838682e-5, 5.8079450445495e-8, -1.1145200609785355e-14], [8.093815752319693e-6, 1.1772182261611135e-9, 7.195574024657057e-5, -8.886523341281598e-5, 6.437661065923862e-8, 2.108133689159944e-15], [8.881173377438135e-6, 1.1853961192537695e-9, 7.895457420735381e-5, -9.750878099776661e-5, 7.06383774541539e-8, 5.97505883573495e-15], [9.662635516696551e-6, 1.1935544283496973e-9, 8.590100372995251e-5, -0.00010608760920569608, 7.685326386664483e-8, -7.2958365775029e-15], [1.0436601762346443e-5, 1.20167570913135e-9, 9.278080282357601e-5, -0.00011458414891675669, 8.300853000359669e-8, -1.2215357356854703e-14], [1.1138580341388873e-5, 1.209077215962891e-9, 9.902070287537698e-5, -0.00012229041453444938, 8.859127483070184e-8, -5.902925197085294e-15], [1.1659620774899426e-5, 1.2145927384664351e-9, 0.00010365224093080336, -0.00012801035576188533, 9.273506077949893e-8, 3.033530670181386e-16], [1.217458831684478e-5, 1.2200628001935277e-9, 0.00010822979723058854, -0.00013366362971279461, 9.683054166751885e-8, 6.24570055955964e-16], [1.2682745015748383e-5, 1.2254790639939512e-9, 0.00011274681212261737, -0.0001392421350479081, 1.0087185614966056e-7, -7.339004662495359e-15], [1.3183230002527497e-5, 1.2308317984280414e-9, 0.00011719563331802766, -0.00014473642127073527, 1.0485215538328922e-7, -1.246412305107118e-15]], Any[[-3.3008627529788256e-8, 3.300863551380299e-8, -1.1359877308251854e-13, -6.679838215527744e-14, -2.6370272371600205e-6, 6.928014792591618e-19], [-9.283301779161908e-8, 9.283298533844164e-8, -7.559511556228665e-15, 5.056930182489438e-14, -9.106004522570507e-6, -4.0014332707838246e-19], [-1.788295843045088e-7, 1.7882962072453096e-7, 1.6567252517101947e-14, -1.7827096373266346e-13, -2.1191811465392874e-5, 3.1828810204236917e-17], [-2.916596112425929e-7, 2.916596175142429e-7, -2.1765257815725778e-14, -8.203624123737747e-14, -4.1130878825401456e-5, -1.3538328765445134e-19], [-4.3016369843437994e-7, 4.3016367895224215e-7, -8.214478088627158e-14, 2.352089733037902e-13, -7.172327663610511e-5, 3.703775739258973e-20], [-5.896763678772655e-7, 5.896763695232336e-7, 6.854851125474067e-14, -1.4325017815832938e-14, -0.00011635989955155029, 2.1715518322089216e-19], [-7.604754478252203e-7, 7.604754515297904e-7, 6.51098691970128e-14, -8.056533210205365e-14, -0.00017901213536109266, 1.0987843554592405e-19], [-9.270454495015127e-7, 9.270454471322681e-7, 9.710636429075686e-15, -1.6692966521331294e-13, -0.0002642136720881904, -4.975386254534756e-19], [-1.0694122462793646e-6, 1.0694122421877601e-6, -1.211973873853616e-14, 5.466344235171162e-14, -0.000377141455999773, 1.1259411137144546e-18], [-1.1675773497186028e-6, 1.1675773474689074e-6, 1.0508378835063364e-14, 7.759897020472636e-14, -0.000524015743577731, 1.4800428082188554e-18]  …  [-0.0001314602288240745, 0.00013146022882274224, 3.88964847743839e-14, -2.8690510254017476e-14, 0.030187440032127394, 1.1145201291606572e-14], [-0.00014830730419490072, 0.00014830730419435013, -2.3305684639096658e-14, 1.1777173203678104e-14, 0.029761383787552335, -2.1081338154288326e-15], [-0.00016480894924159365, 0.0001648089492383489, -6.447790977352763e-15, -1.413891790105759e-14, 0.029317927502365667, -5.97505921451775e-15], [-0.0001808955350974476, 0.00018089553510197668, 3.5320609826673677e-14, -2.1145628650853787e-14, 0.02885382639778191, 7.295837053926954e-15], [-0.00019648459281621354, 0.00019648459281320166, -1.303567442791781e-14, 4.185359198972949e-14, 0.02836530457505434, 1.221535813390711e-14], [-0.00021020334039383, 0.0002102033403927695, -6.183844668966598e-14, -4.442615979954878e-14, 0.027892488753734818, 5.9029255408094106e-15], [-0.00021995673381901816, 0.00021995673382304903, 1.3451520171174625e-14, 8.389843724268542e-14, 0.027520664837620504, -3.033530662527151e-16], [-0.00022947871603193134, 0.00022947871602764752, 2.1854398716061874e-14, -7.524731705788046e-14, 0.027130891854070683, -6.245700680045478e-16], [-0.00023858030481564642, 0.0002385803048211307, -5.844459573418892e-15, -5.146002981376574e-15, 0.026721062112027707, 7.33900509630204e-15], [-0.0002471938540611257, 0.000247193854056346, 1.2447752247360389e-14, 3.390641717046505e-14, 0.026288685958259856, 1.2464123457094311e-15]], Any[2.636240732481093e-6, 9.104354046041087e-6, 2.1189229270105213e-5, 4.112731238842287e-5, 7.171869644585097e-5, 0.00011635430711370632, 0.00017900556923067893, 0.00026420620810873886, 0.00037713319597023086, 0.0005240067880065371  …  -0.030187498111577844, -0.029761448164163026, -0.029317998140743106, -0.02885390325104579, -0.02836538758358429, -0.027892577345009717, -0.027520757572681256, -0.027130988684612358, -0.02672116298388391, -0.026288790810415203], Any[6.57173967041568e-5, 6.0143731950259e-5, 5.414106843712703e-5, 4.7771157673113214e-5, 4.113419994009803e-5, 3.438316691242112e-5, 2.774422501518883e-5, 2.1534705727911847e-5, 1.6154478447062552e-5, 1.2016635637467205e-5  …  5.30735022981497e-5, 5.287046901996689e-5, 5.258024344092099e-5, 5.219482069926283e-5, 5.1703964655012164e-5, 5.1142739703887165e-5, 5.062316543832365e-5, 5.004370877224307e-5, 4.93935564494838e-5, 4.8660971955565645e-5], Any[0.2152528755259377, 0.4491745356638885, 0.6993562050963037, 0.9615202121102266, 1.2293991149622279, 1.4948375700558127, 1.7484817432872106, 1.9814945536207185, 2.1886006798277764, 2.3720905092949054  …  3.4289252267538304, 3.5504162284568164, 3.6954168618326686, 3.8674574141443125, 4.07096389551248, 4.2960997389801765, 4.504625595429061, 4.722080535152571, 4.965070387744687, 5.2382226667544955], [0.9985310557215158 0.9985397779883571 … 0.9999749409164599 1.0; 0.001059690377618689 0.0010596965380039996 … 2.1266873357285986e-5 1.0000000000000001e-7; … ; -5.320495507462065e-23 -7.355402747092829e-8 … -3.6093053055339393e-8 -1.2798977016612012e-42; 1.9951779588700983e-13 1.8360669599151128e-13 … 3.704734550311424e-29 1.5924501025464923e-54;;; 0.9881901664811303 0.9886181049252194 … 0.9999749409150699 1.0; 0.0010487158512353832 0.0010490189174312712 … 2.1266874521659654e-5 1.0000000000000001e-7; … ; 0.0011999999999999789 0.0011963543333825307 … 2.217871449626682e-5 7.864805913217845e-40; 4.901235028494444e-10 4.510688869454572e-10 … -1.3695718741357093e-23 -7.227081957771022e-49;;; 0.9627192090845003 0.9641597743760943 … 0.9999749409115727 1.0; 0.001021684369765665 0.0010227042561440599 … 2.126687745129502e-5 1.0000000000000001e-7; … ; 0.0026399999999999757 0.002627410464209802 … 4.654337754036382e-5 1.6504772220328606e-39; 5.844290072571767e-9 5.379526828052882e-9 … 1.1572232008120451e-23 4.1581930376670256e-49;;; … ;;; 2390.2519687572144 2192.3117124059268 … 0.9999750765031428 1.0; 2.5323445797162116 8.718569738932542 … 2.115407871297774e-5 1.0000000000000001e-7; … ; -0.016508354110750106 0.01690660990462921 … 0.002730616590414118 9.683054223288985e-38; 0.051043762416913725 0.028841406151880238 … 1.0900541113550694e-20 -2.4534078105158056e-50;;; 2381.9188312655574 2176.941946929796 … 0.9999750752607003 1.0; 2.523345907560272 8.46654392786533 … 2.115512421320464e-5 1.0000000000000001e-7; … ; -0.008254177055374986 0.024599220019334327 … 0.0028445814750867444 1.0087185715681535e-37; 0.049493698530376384 0.027777454163538884 … 1.1848218349928606e-20 2.8984452150100013e-50;;; 2372.7526460531894 2160.0250245115626 … 0.9999750739703852 1.0; 2.513475073768452 8.205744978871808 … 2.1156209802765048e-5 1.0000000000000001e-7; … ; 1.3731098842078258e-16 0.032261697645175474 … 0.0029568258236102305 1.048521600555311e-37; 0.04788429158549898 0.026681158891637635 … 1.2816254696646817e-20 -1.1913926270149597e-49]))
cell_pts, cvresult_pts = simulate(grid, edata_pts)
(PNPSystem(VoronoiFVM.System{Float64, Float64, Int32, Int64, Matrix{Int32}}(
  grid = ExtendableGrids.ExtendableGrid{Float64, Int32}(dim=1, nnodes=721, ncells=720,
  nbfaces=2),  
  physics = Physics(data=LiquidElectrolytes.ElectrolyteData{typeof(LiquidElectrolytes.DG
  ML_gamma!), PreallocationTools.DiffCache{Vector{Float64}, Vector{Float64}},
  typeof(exp), typeof(log), typeof(LiquidElectrolytes.μex_flux!),
  typeof(Main.var"workspace#4".ε_dec), typeof(Main.var"workspace#4".redoxreaction)},
  flux=pnpflux!, storage=pnpstorage!, reaction=_pnpreaction!, breaction=halfcellbc,
  bstorage=pnpbstorage!, generic_operator=pseudopotentiostat, ),  
  num_species = 6)), CVSweepResult([0.01631558431240769, 0.017711938962656923, 0.01936355743608538, 0.021358700223662312, 0.023787095888703355, 0.026756543506899128, 0.030399355335927254, 0.034879359714655354, 0.0404009919191095, 0.04722199287210715  …  0.27473022103356154, 0.274483297841884, 0.26771206187686736, 0.23937723973985298, 0.1953001474097031, 0.16413968375411914, 0.14996169029300727, 0.14369796434557205, 0.14101882463289114, 0.1407503402869129], [1.2e-5, 2.6399999999999998e-5, 4.3679999999999995e-5, 6.441599999999999e-5, 8.929919999999999e-5, 0.00011915903999999998, 0.00015499084799999998, 0.00019798901759999997, 0.00024958682111999995, 0.0003115041853439999  …  0.023134464839460137, 0.023254464839460136, 0.023374464839460134, 0.023494464839460133, 0.02361446483946013, 0.023710848629595098, 0.023783136472196324, 0.02385542431479755, 0.023927712157398775, 0.024], Any[[4.5498824365608483e-7, -4.5498824365608483e-7, -0.0, -0.0, -0.0, -0.0], [6.913910597539098e-7, -6.913910597539098e-7, -0.0, -0.0, -0.0, -0.0], [8.697961282472245e-7, -8.697961282472245e-7, -0.0, -0.0, -0.0, -0.0], [1.0141431908200494e-6, -1.0141431908200494e-6, -0.0, -0.0, -0.0, -0.0], [1.13084051529877e-6, -1.13084051529877e-6, -0.0, -0.0, -0.0, -0.0], [1.2209586593109334e-6, -1.2209586593109334e-6, -0.0, -0.0, -0.0, -0.0], [1.2834777210485316e-6, -1.2834777210485316e-6, -0.0, -0.0, -0.0, -0.0], [1.316740642715586e-6, -1.316740642715586e-6, -0.0, -0.0, -0.0, -0.0], [1.3194291303031404e-6, -1.3194291303031404e-6, -0.0, -0.0, -0.0, -0.0], [1.291366549818762e-6, -1.291366549818762e-6, -0.0, -0.0, -0.0, -0.0]  …  [0.0004701569925124866, -0.0004701569925124866, -0.0, -0.0, -0.0, -0.0], [0.0004244104036870944, -0.0004244104036870944, -0.0, -0.0, -0.0, -0.0], [0.00038462038460682915, -0.00038462038460682915, -0.0, -0.0, -0.0, -0.0], [0.00035086915497611063, -0.00035086915497611063, -0.0, -0.0, -0.0, -0.0], [0.00032236745349339404, -0.00032236745349339404, -0.0, -0.0, -0.0, -0.0], [0.0003020941450187459, -0.0003020941450187459, -0.0, -0.0, -0.0, -0.0], [0.00028827832130946254, -0.00028827832130946254, -0.0, -0.0, -0.0, -0.0], [0.0002758376977157173, -0.0002758376977157173, -0.0, -0.0, -0.0, -0.0], [0.00026451156601274675, -0.00026451156601274675, -0.0, -0.0, -0.0, -0.0], [0.00025414283511559555, -0.00025414283511559555, -0.0, -0.0, -0.0, -0.0]], Any[[1.3452732037000219e-6, 1.1154829402752508e-9, 1.1967940184133459e-5, -1.4780385161396516e-5, 1.0706290449872693e-8, 1.1420926339872426e-19], [1.3413606275087851e-6, 1.1154450004777878e-9, 1.193316134892564e-5, -1.4737433125432538e-5, 1.0675168725761555e-8, -4.92452510569138e-19], [1.3345344590175533e-6, 1.1153782270579414e-9, 1.1872483338600437e-5, -1.4662496518779467e-5, 1.0620885628303725e-8, 4.489011685303197e-19], [1.327523765640088e-6, 1.115309870557255e-9, 1.1810165339809798e-5, -1.4585533473278607e-5, 1.0565126534378544e-8, -3.6108388763039675e-19], [1.3221631991707236e-6, 1.115258210965743e-9, 1.1762515382037667e-5, -1.4526685956771785e-5, 1.0522496907751544e-8, -1.5962527015829616e-18], [1.3206659591148064e-6, 1.1152453400550784e-9, 1.1749206298788081e-5, -1.4510249220779103e-5, 1.0510586394109089e-8, 1.6452982390856916e-19], [1.3259510429266783e-6, 1.115300400785685e-9, 1.1796185511072841e-5, -1.4568268450302376e-5, 1.0552621413486525e-8, -3.171829870295216e-18], [1.3419714410870323e-6, 1.115462855416962e-9, 1.1938590946692019e-5, -1.474413896224341e-5, 1.0680024021605254e-8, -9.744013255051284e-19], [1.374169271122911e-6, 1.1157870752213199e-9, 1.2224797837512924e-5, -1.5097603909922732e-5, 1.093609910628877e-8, 7.848835946729213e-18], [1.4301814598885774e-6, 1.116349445517574e-9, 1.2722690599260901e-5, -1.5712500596713572e-5, 1.138155303426978e-8, 6.483405130065991e-19]  …  [3.2164072084266445e-5, 1.4418117719362998e-9, 0.0002859168755593802, -0.00035310686332090105, 2.558048924114883e-7, -5.9417583149849896e-15], [3.107122218261218e-5, 1.429354374183322e-9, 0.0002762024951531651, -0.0003411096196206359, 2.4711354109135094e-7, -8.76469133581913e-15], [2.9398015416277462e-5, 1.4102589891890378e-9, 0.000261329303133175, -0.00032274125264448116, 2.3380669606208863e-7, -1.2776281597570142e-15], [2.5805660324901574e-5, 1.3694852761313673e-9, 0.00022939674157092965, -0.0002833045939503478, 2.0523704409597564e-7, 2.9435304196487437e-16], [2.081260500742396e-5, 1.3138939008134944e-9, 0.00018501332926955497, -0.00022849115628730769, 1.6552777963810003e-7, -4.0557103191314543e-16], [1.7180377424385163e-5, 1.274326178460174e-9, 0.00015272636877608026, -0.0001886168158929832, 1.3664105105285606e-7, 1.1204155538544997e-16], [1.5274801359409897e-5, 1.2538804104036101e-9, 0.0001357876615053026, -0.0001676975415699851, 1.2148620565162762e-7, 2.4778746973387296e-17], [1.4073896454493766e-5, 1.241119847731398e-9, 0.0001251127935608548, -0.0001545140981247646, 1.1193554398669211e-7, 1.0828604020125647e-17], [1.3192114254830052e-5, 1.231814090769845e-9, 0.00011727461483564246, -0.00014483396073620853, 1.0492281912224653e-7, -2.0930581267476908e-18], [1.2524926200547533e-5, 1.2248127562549033e-9, 0.00011134396814365184, -0.00013750962220536453, 9.961675924814026e-8, 2.518980526425476e-18]], Any[[-4.5498822435342115e-7, 4.5498824369943947e-7, 2.710766435946128e-13, -8.764990550849325e-14, -3.5129116371847124e-5, -1.1420925323606538e-19], [-6.913910473974573e-7, 6.913910596086905e-7, -1.2375177448000103e-13, -3.3041361056159076e-14, -7.681841286417803e-5, 4.924525366396226e-19], [-8.697961482180321e-7, 8.697961282359785e-7, 1.2047268124228388e-13, -2.29656307263338e-13, -0.00012628785404106548, -4.489011784258023e-19], [-1.0141431797241041e-6, 1.0141431906791196e-6, -1.8192283786453312e-13, 1.5457772594481417e-13, -0.0001850416525254227, 3.610839796878939e-19], [-1.1308405210707384e-6, 1.1308405157206357e-6, 1.7573180798448156e-14, -1.2786370100464472e-13, -0.0002549717640555379, 1.5962527721557643e-18], [-1.2209586601509104e-6, 1.220958659595734e-6, 8.692449293993751e-14, 1.2420062909721235e-13, -0.0003385296649964147, -1.645298627410682e-19], [-1.2834777277721136e-6, 1.283477721256925e-6, -2.7980994799815806e-14, -3.0928986246583044e-14, -0.00043900087922543144, 3.1718297759003366e-18], [-1.3167406370901027e-6, 1.3167406427698175e-6, 1.817309018927512e-14, 1.0128995149680416e-13, -0.000560948236864514, 9.74401372102237e-19], [-1.3194291347641305e-6, 1.3194291304308982e-6, -1.3849644291108985e-14, -9.02711675483843e-14, -0.0007109372344050884, -7.848836435197207e-18], [-1.2913665475271619e-6, 1.2913665500209093e-6, 2.614587420266684e-14, 5.880411717458511e-14, -0.0008987436307814638, -6.483406724472145e-19]  …  [-0.0004701569925138835, 0.0004701569925124688, 1.8010820699437824e-14, -2.4169793770567605e-14, 0.013266885433620522, 5.941758634760724e-15], [-0.00042441040368455286, 0.0004244104036869553, -2.599998124783176e-14, -9.466006537645066e-15, 0.009954148557282844, 8.764691842294234e-15], [-0.00038462038460759253, 0.00038462038460703525, 6.536129059861451e-14, 2.697039640231491e-14, 0.006623715465996657, 1.2776282061871411e-15], [-0.00035086915497662335, 0.0003508691549761075, -2.024828872279616e-15, -1.9279445661463113e-14, 0.0038536281460387956, -2.943530401765595e-16], [-0.00032236745349462754, 0.0003223674534933275, -6.842879670017343e-14, -1.7692797097193513e-14, 0.002075511014453131, 4.0557106085223095e-16], [-0.00030209414501684726, 0.00030209414501907, 8.020355755401776e-14, 4.0275644147894085e-14, 0.0012312019195961446, -1.1204156322899998e-16], [-0.000288278321302288, 0.0002882783213089328, -2.2275150474149186e-14, -5.217267590174046e-14, 0.0008055236668491081, -2.4778748992073043e-17], [-0.00027583769772006854, 0.0002758376977161693, -6.621171167765783e-14, -1.799046480364941e-14, 0.000484603037498682, -1.0828603777407281e-17], [-0.000264511566014516, 0.0002645115660128604, 1.381220712890624e-14, -2.0269783030865685e-14, 0.00022531927312190793, 2.09305769815326e-18], [-0.0002541428351131186, 0.00025414283511633986, 3.421485913601002e-14, 1.3355625199523713e-13, 1.2504811590861144e-7, -2.518980526230478e-18]], Any[3.511841008139715e-5, 7.680773769545217e-5, 0.00012627723315543696, 0.00018503108739888763, 0.00025496124155862965, 0.000338519154410022, 0.0004389903266040186, 0.0005609375568404901, 0.0007109262983059814, 0.0008987322492284265  …  -0.01326714123851292, -0.009954395670823889, -0.006623949272692722, -0.0038538333830829, -0.0020756765422327624, -0.0012313385606471956, -0.0008056451530547618, -0.0004847149730426686, -0.0002254241959410302, -2.2466487515675163e-7], Any[0.000893262833487013, -1.2372792435486059e-6, -2.2188899670585043e-6, -1.7652113771166736e-6, -7.880639493657949e-7, 5.283978391312436e-7, 2.102153897032951e-6, 3.89376737511401e-6, 5.893914039459353e-6, 8.124385513032962e-6  …  -7.746131577092187e-5, -7.155876431029291e-5, -0.0001100667102194131, -0.00023734441322288642, -0.00033024890135528484, -0.00029904241737390845, -0.00020893844638428363, -0.00013136206484718092, -9.621438956761948e-5, -7.257379280062914e-5], Any[2.926534022043127, 2.8950921954204873, 2.862818024304676, 2.83342275479604, 2.810336056445394, 2.7983375949567164, 2.8039660235396617, 2.836102824164672, 2.9068822940758263, 3.033170957391125  …  25.6035258667405, 27.60621306407525, 27.75371998442639, 23.08429908008185, 14.817973673751148, 8.760165795547483, 5.8888658490026105, 4.439614857265803, 3.586920950622506, 3.1153168079476643], [0.9987452784271136 0.9987452785271563 … 0.9999749391260045 1.0; 0.001059917721314313 0.0010599177107772787 … 2.1268385717534613e-5 1.0000000000000001e-7; … ; -1.8072218782632523e-6 -1.8072225978549954e-6 … -3.6095631883750316e-8 -1.2799891496346117e-42; 1.7094700205914253e-23 1.552239175032807e-23 … 5.245409209833652e-30 1.2070343972488517e-58;;; 0.8662683761274791 0.8712819001696576 … 0.9999749391071128 1.0; 0.0009193235964257488 0.0009228722635865566 … 2.1268401544146478e-5 1.0000000000000001e-7; … ; 0.016315584313519624 0.016267008189930116 … 0.00030191663923366725 1.070628223264919e-38; 8.69776376635311e-8 8.011310374574563e-8 … 1.3766091403348585e-22 2.9267900450815326e-51;;; 0.7301186061382051 0.7393966802278726 … 0.9999749390845096 1.0; 0.0007748338804966122 0.0007813934946316244 … 2.126842048018326e-5 1.0000000000000001e-7; … ; 0.017711938962971376 0.017605690234004222 … 0.0003010391611977237 1.0675165936675547e-38; 4.159104663367177e-7 3.8343560971594656e-7 … 1.3671321431744644e-22 -6.820812785592981e-51;;; … ;;; 5.881863763503573 5.43790517422698 … 0.9999750573627093 1.0; 0.0062293812658026585 0.005915450633272113 … 2.1170470505321453e-5 1.0000000000000001e-7; … ; 0.1436979643454893 0.14436317632749918 … 0.0031565767816186204 1.1193553955428315e-37; 1.6551280996500473e-5 1.4830664518009912e-5 … 1.468227760717317e-20 -1.633303716578752e-52;;; 2.4941019098493604 2.4039791442396248 … 0.9999750562341724 1.0; 0.0026416823203780295 0.0025802531202766374 … 2.117141935587285e-5 1.0000000000000001e-7; … ; 0.14101882463296658 0.14132952516980216 … 0.002958818481740114 1.0492282181298132e-37; 3.5785093719192767e-6 3.2612360365133906e-6 … 1.2884508077653403e-20 -2.789999163948736e-52;;; 1.055030455298891 1.0550054245103526 … 0.9999750551619235 1.0; 0.0011175443154133396 0.0011199726968710306 … 2.1172320978954702e-5 1.0000000000000001e-7; … ; 0.14075034028644956 0.1407505130181919 … 0.0028091874701942237 9.961674843977038e-38; 1.045509576497804e-12 9.542638627438024e-13 … 1.1602748970529061e-20 -6.880451781884647e-52]))
cell_odr, cvresult_odr = simulate(grid, edata_odr)
(PNPSystem(VoronoiFVM.System{Float64, Float64, Int32, Int64, Matrix{Int32}}(
  grid = ExtendableGrids.ExtendableGrid{Float64, Int32}(dim=1, nnodes=721, ncells=720,
  nbfaces=2),  
  physics = Physics(data=LiquidElectrolytes.ElectrolyteData{typeof(LiquidElectrolytes.DG
  ML_gamma!), PreallocationTools.DiffCache{Vector{Float64}, Vector{Float64}},
  typeof(exp), typeof(log), typeof(LiquidElectrolytes.μex_flux!),
  typeof(Main.var"workspace#4".ε_dec), typeof(Main.var"workspace#4".redoxreaction)},
  flux=pnpflux!, storage=pnpstorage!, reaction=_pnpreaction!, breaction=halfcellbc,
  bstorage=pnpbstorage_ohmicdrop!, generic_operator=ohmicdropcompensation, ),  
  num_species = 8)), CVSweepResult([0.00996785123768729, 0.015050531578371072, 0.018068909393819117, 0.020497040185327754, 0.023031017761518006, 0.026003087500367353, 0.029615359074031913, 0.03404840431777578, 0.039506812096750644, 0.04624198241978304  …  0.26860911208160976, 0.2718142661154614, 0.27446457629530874, 0.27369841956665963, 0.25657393855098604, 0.22033126271709313, 0.1814347447797433, 0.1576603247641728, 0.14933128897557757, 0.14615674629377898], [1.2e-5, 2.6399999999999998e-5, 4.3679999999999995e-5, 6.441599999999999e-5, 8.929919999999999e-5, 0.00011915903999999998, 0.00015499084799999998, 0.00019798901759999997, 0.00024958682111999995, 0.0003115041853439999  …  0.02316853723464362, 0.02328853723464362, 0.023408537234643617, 0.023528537234643616, 0.02364640292598271, 0.023734802194487033, 0.023823201462991356, 0.0239111321171277, 0.023955566058563853, 0.024], Any[[-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0]  …  [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0]], Any[[8.215392115883005e-7, 1.1102200317235686e-9, 7.312464531066782e-6, -9.030880771972171e-6, 6.54108855151078e-9, -1.5976924136384927e-20, -0.0, -0.0], [1.1632559243020055e-6, 1.113615526441734e-9, 1.0349986575349228e-5, -1.2782215215555796e-5, 9.258712035445015e-9, 6.981549947418289e-20, -0.0, -0.0], [1.2843137784613347e-6, 1.114820902658972e-9, 1.1426070950204395e-5, -1.4111177835931593e-5, 1.022148023078913e-8, 5.098386100957404e-19, -0.0, -0.0], [1.3175868256029772e-6, 1.1151534368343128e-9, 1.172183530760803e-5, -1.4476446073688172e-5, 1.0486093333411185e-8, -1.0858203858631528e-19, -0.0, -0.0], [1.3218863917185601e-6, 1.1151979347135433e-9, 1.1760054228873373e-5, -1.4523646492134835e-5, 1.0520299900252221e-8, 1.704298791191536e-18, -0.0, -0.0], [1.32059612523339e-6, 1.1151871223185543e-9, 1.1748585013175745e-5, -1.4509481928547516e-5, 1.0510024642398574e-8, 5.885949027893537e-19, -0.0, -0.0], [1.3233355350840023e-6, 1.1152168431389095e-9, 1.1772935707396403e-5, -1.4539554993948645e-5, 1.0531818412398755e-8, 4.0826315914094626e-20, -0.0, -0.0], [1.3358355109529682e-6, 1.1153442256997254e-9, 1.1884048109167923e-5, -1.4676778660263102e-5, 1.0631230948419787e-8, 4.989325166439852e-18, -0.0, -0.0], [1.3638375554131422e-6, 1.115626618863398e-9, 1.2132958606443575e-5, -1.4984182652149017e-5, 1.0853924727380017e-8, -5.884676139190225e-18, -0.0, -0.0], [1.414783536915046e-6, 1.1161384196159974e-9, 1.2585817844093867e-5, -1.5543462950133822e-5, 1.1259081159719285e-8, 3.9222739910107334e-18, -0.0, -0.0]  …  [3.29775278388248e-5, 1.4510204796528913e-9, 0.0002931477113886196, -0.0003620369336575695, 2.622742096305541e-7, -4.035461737497067e-15, -0.0, -0.0], [3.215294501621633e-5, 1.4416512965625123e-9, 0.00028581796638411596, -0.00035298471057098615, 2.55716384891879e-7, -1.0777396307811234e-14, -0.0, -0.0], [3.12763720103845e-5, 1.4317059302748697e-9, 0.0002780260792282125, -0.0003433617427159685, 2.487450910503881e-7, -4.613738711050302e-15, -0.0, -0.0], [3.0079504584274128e-5, 1.4180900373290088e-9, 0.0002673870841832052, -0.00033022260161212565, 2.3922651414862433e-7, 5.7084450623101555e-15, -0.0, -0.0], [2.7368986036332282e-5, 1.3872141643997577e-9, 0.00024329319424591843, -0.0003004666887132519, 2.176700159062732e-7, 5.823319538047437e-16, -0.0, -0.0], [2.3142339373622662e-5, 1.3396888679556443e-9, 0.00020572240249344258, -0.00025406682576295417, 1.8405591569695176e-7, 3.6145121482434263e-17, -0.0, -0.0], [1.866701487198752e-5, 1.290430233751909e-9, 0.0001659411242375333, -0.00020493701590947944, 1.4846411884455006e-7, -7.907186928160726e-17, -0.0, -0.0], [1.5613899291578326e-5, 1.257490675108678e-9, 0.00013880191010553458, -0.0001714201332645096, 1.2418300511267345e-7, -4.2174616319901215e-17, -0.0, -0.0], [1.4416567830648836e-5, 1.2447232065190236e-9, 0.00012815880595124857, -0.00015827591806433282, 1.1466077316653718e-7, -2.741227257507644e-18, -0.0, -0.0], [1.3702434986267555e-5, 1.2371601673467884e-9, 0.00012181086518052176, -0.00015043622207339314, 1.0898135201347442e-7, -2.2001627697617245e-19, -0.0, -0.0]], Any[[-2.7951228477388066e-7, 2.7951225920365587e-7, 4.954763524787171e-14, 5.5696958072633425e-14, -2.149986866954933e-5, 1.5976927826709418e-20, -0.0, -0.0], [-5.52687139582339e-7, 5.526871411209521e-7, 4.1141692646001066e-13, -9.042260009869442e-14, -5.772604951535244e-5, -6.981551000939458e-20, -0.0, -0.0], [-7.771746108220638e-7, 7.771745942117127e-7, -3.570539690463375e-13, -2.0040255906291198e-13, -0.00010543625306927686, -5.098386398317822e-19, -0.0, -0.0], [-9.547642677523722e-7, 9.547642842055251e-7, -3.2429842231757045e-16, -6.774710966642086e-14, -0.00016385455192653446, 1.0858206615287344e-19, -0.0, -0.0], [-1.0934217153835254e-6, 1.0934217126868643e-6, 2.0888118945833808e-13, -1.0365551970090755e-13, -0.00023385937825364352, -1.7042989153929282e-18, -0.0, -0.0], [-1.1982164179519189e-6, 1.1982164121189455e-6, -2.2067430043395172e-13, 1.8688572756930637e-13, -0.0003174781968663151, -5.885949719476871e-19, -0.0, -0.0], [-1.27083394664456e-6, 1.2708339556251182e-6, -3.449385654224254e-14, -9.581895891422505e-15, -0.0004177863260769244, -4.0826185966064056e-20, -0.0, -0.0], [-1.3111203073792426e-6, 1.3111203045965712e-6, 8.153165608740156e-14, -3.7888579941655273e-14, -0.0005391748646355518, -4.989325546611619e-18, -0.0, -0.0], [-1.3186118052805114e-6, 1.3186118038467582e-6, 7.241361576668624e-14, -1.3370613278118788e-14, -0.0006879917140412846, 5.884676585804813e-18, -0.0, -0.0], [-1.2936905286141314e-6, 1.2936905284282632e-6, -9.380707270537948e-14, 6.026689902878003e-14, -0.0008736806725540078, -3.922274482608879e-18, -0.0, -0.0]  …  [-0.0005129254816919048, 0.0005129254816900831, 1.9043740109164764e-14, 8.033124946488224e-15, 0.017110321245025505, 4.035462049266416e-15, -0.0, -0.0], [-0.0004666176303280335, 0.0004666176303299965, 9.482215360123725e-15, -3.043762073981493e-14, 0.01399987112176761, 1.0777396943909411e-14, -0.0, -0.0], [-0.00042196041793640725, 0.00042196041793728995, -2.216629657603164e-14, 2.4618436629542106e-14, 0.010604450611755334, 4.613739010886771e-15, -0.0, -0.0], [-0.00038241501857661544, 0.00038241501857269746, -7.885673451030195e-15, -2.3682607524361243e-14, 0.007068048663621708, -5.708445367456997e-15, -0.0, -0.0], [-0.00034957018267863763, 0.00034957018268057244, -1.1404885282700894e-14, 4.475391411629115e-14, 0.003925907313547289, -5.823319819643443e-16, -0.0, -0.0], [-0.0003277258029606648, 0.0003277258029626105, 4.9775179637723266e-14, -5.549168980226171e-14, 0.0022073591797645764, -3.614512059295454e-17, -0.0, -0.0], [-0.0003079044580357398, 0.0003079044580322119, -2.218529721910445e-14, -2.5182519914832002e-14, 0.001192609619374529, 7.907187263755335e-17, -0.0, -0.0], [-0.0002900137147866279, 0.00029001371478995367, -2.04976010123592e-14, 5.1998227772187544e-14, 0.0006237589074503929, 4.217461805691392e-17, -0.0, -0.0], [-0.0002813670525049006, 0.00028136705249896696, -7.013253909907147e-14, -8.672256706157566e-14, 0.00041661036638168864, 2.741228050698956e-18, -0.0, -0.0], [-0.0002734061085785583, 0.0002734061085830877, 1.264864000214208e-13, 9.993232370081317e-14, 0.00024533821361651077, 2.20016277141698e-19, -0.0, -0.0]], Any[2.1493327580997825e-5, 5.7716790803316915e-5, 0.0001054260315890462, 0.00016384406583320104, 0.0002338488579537435, 0.00031746768684167196, 0.00041777579425851253, 0.0005391642334046046, 0.0006879808601165568, 0.0008736694134728484  …  -0.01711058351923502, -0.014000126838152495, -0.010604699356846395, -0.007068287890135858, -0.003926124983563201, -0.0022075432356802745, -0.0011927580834933756, -0.0006238830904555032, -0.00041672502715485557, -0.0002454471949685223], Any[0.0005457862404429267, 0.00018953223639505592, 5.660384801478137e-5, 1.3676652276955573e-5, 2.2980130585092184e-6, 5.831476055943698e-7, 1.5362428247560285e-6, 3.2407987512600177e-6, 5.2442994622325e-6, 7.469587801940775e-6  …  -3.7844094936060626e-5, -5.368833418276889e-5, -5.717446676782405e-5, -7.842927116590722e-5, -0.00018201529211303832, -0.0003793761632177577, -0.0004017620194515313, -0.0002752883105079101, -0.00021344268309837894, -0.0001269637032905956], Any[1.7879379213619573, 2.5155182793277144, 2.760951434359334, 2.8172277316818506, 2.813335588692068, 2.80037766069505, 2.799415184878212, 2.823107129334457, 2.8841659248977307, 2.9989738045780103  …  23.271745805926418, 25.920472342354387, 28.295229010884167, 29.47009555592114, 26.65884254250666, 19.44113087088379, 11.479565038903914, 6.469586728602982, 4.662158174699149, 3.854662149034473], [0.9985919859720159 0.9985982276356857 … 0.9999749404071854 1.0; 0.0010597550398041696 0.0010597594451672511 … 2.1267303531993036e-5 1.0000000000000001e-7; … ; -3.804795470767014e-8 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0;;; 0.9156187354575768 0.9188575739123138 … 0.9999749403956425 1.0; 0.0009716977165029648 0.0009739907863227868 … 2.1267313201926296e-5 1.0000000000000001e-7; … ; -2.1478221005745693e-5 0.0 … 0.0 0.0; 1.7866810875865018 0.0 … 0.0 0.0;;; 0.7897790596354628 0.7973068195489759 … 0.9999749403760385 1.0; 0.000838149031000476 0.0008434733730422403 … 2.1267329625199316e-5 1.0000000000000001e-7; … ; -5.7677234946163324e-5 0.0 … 0.0 0.0; 2.5138204125290025 0.0 … 0.0 0.0;;; … ;;; 8.770771242478055 7.932842703218731 … 0.9999750590298757 1.0; 0.009287998178999222 0.008692033378320562 … 2.1169045626771723e-5 1.0000000000000001e-7; … ; 0.0006238421559914908 0.0 … 0.0 0.0; 6.4685786438433555 0.0 … 0.0 0.0;;; 4.77979705102665 4.4671849720938726 … 0.9999750582728317 1.0; 0.005061993891363416 0.004842043696421175 … 2.1169682005664742e-5 1.0000000000000001e-7; … ; 0.0004167422816159653 0.0 … 0.0 0.0; 4.660848614411643 0.0 … 0.0 0.0;;; 2.6861960244364647 2.580738245972418 … 0.9999750575527755 1.0; 0.002844955497897294 0.0027727021076226926 … 2.1170287357113763e-5 1.0000000000000001e-7; … ; 0.0002455305108944298 0.0 … 0.0 0.0; 3.853175414734914 0.0 … 0.0 0.0]))

Plots

CVs and surface concentrations

plotcv(cvresult_unc, edata_unc)
plotcv(cvresult_pts, edata_pts)
plotcv(cvresult_odr, edata_odr)

Voltages and concentrations

t/s: 0.0048

xplotsol(grid, cvresult_pts.tsol(t), edata_pts; xcut = 1ufac"nm")
xplotsol(grid, cvresult_odr.tsol(t), edata_odr; xcut = 1ufac"nm")

Time dependent voltages

plotresult2(cvresult_unc, edata_unc)
plotresult2(cvresult_pts, edata_pts)
plotresult2(cvresult_odr, edata_odr)

Appendix: plot functions

function xplotsol(grid, sol, celldata; xcut = 10ufac"nm")
    !isdefined(Main, :PlutoRunner) && return

    X = grid[XCoordinates]
    (; iϕ) = celldata

    function pp(axl, axr)
        ylims!(axl, -0.5, 0.5)
        ylims!(axr, 1.0e-5, 10)
        lines!(
            axr, X / ufac"nm", sol[iO, :] / (ufac"mol / dm^3"),
            color = :red, label = "O"
        )
        lines!(
            axr, X / ufac"nm", sol[iR, :] / (ufac"mol / dm^3"),
            color = :blue, label = "R"
        )
        lines!(axl, X / ufac"nm", sol[iϕ, :], color = :green, label = "ϕ")
        return nothing
    end

    fig = Figure(size = (700, 300))
    Label(
        fig[0, 1:2],
        "ircomp=$(celldata.ircompensation) scanrate=$(sawtooth.scanrate)V/s, E=$(round(sol[iϕ, 1], sigdigits = 3))V, "
    )

    colgap!(fig.layout, 2)

    axl = Axis(fig[1, 1]; xscale = identity, xlabel = "x/nm", ylabel = "U/V")
    axr = Axis(
        fig[1, 1], yaxisposition = :right; xscale = identity,
        yticksvisible = false,
        yticklabelsvisible = false,
        yscale = log10
    )
    xlims!(axl, 0, xcut / ufac"nm")
    xlims!(axr, 0, xcut / ufac"nm")
    linkxaxes!(axl, axr)
    pp(axl, axr)
    axislegend(axl, position = :lt, backgroundcolor = RGBA(1, 1, 1, 0.5))

    axl = Axis(
        fig[1, 2]; xscale = log10, xlabel = "x/nm",
        yticksvisible = false,
        yticklabelsvisible = false,
    )
    axr = Axis(
        fig[1, 2], yaxisposition = :right; xscale = log10, ylabel = "c/(mol/dm^3)",
        yscale = log10
    )
    xlims!(axl, xcut / ufac"nm", X[end] / ufac"nm")
    xlims!(axr, xcut / ufac"nm", X[end] / ufac"nm")
    linkxaxes!(axl, axr)
    pp(axl, axr)
    axislegend(axr, position = :rt, backgroundcolor = RGBA(1, 1, 1, 0.5))
    return fig
end
xplotsol (generic function with 1 method)
function plotcv(cvresult, celldata)
    !isdefined(Main, :PlutoRunner) && return
    fig = Figure(size = (700, 300))
    ax = Axis(fig[1, 1], title="CV")
    j_we = -hcat(cvresult.j_we...)[1, :] * celldata.F
    lines!(ax, cvresult.voltages, j_we / ufac"mA/cm^2", label=L"I_F")
    lines!(ax, cvresult.voltages, cvresult.j_cap / ufac"mA/cm^2", label=L"I_C")
    lines!(ax, cvresult.voltages, (cvresult.j_cap + j_we) / ufac"mA/cm^2",label=L"I_F+I_C")

    axislegend(ax, position = :lt)

    c_O = [u[iO, :] |> maximum for u in cvresult.tsol.u[2:end]] / ufac"mol/dm^3"
    c_R = [u[iR, :] |> maximum for u in cvresult.tsol.u[2:end]] / ufac"mol/dm^3"

    ax2 = Axis(fig[1, 2], xlabel = "E/V", ylabel = L"c/(mol\cdot dm^{-3})",
              title= "Max concentration in DL")

    lines!(ax2, cvresult.voltages, c_O, color = :red, label = L"c_O(x_3)")
    lines!(
        ax2, cvresult.voltages, c_R,
        color = :blue, label = L"c_R(x_3)"
    )
    axislegend(ax2, position = :rt)
    Label(
        fig[0, 1:2],
        "ircomp=$(celldata.ircompensation) scanrate=$(sawtooth.scanrate)V/s"
    )

    return fig
end
plotcv (generic function with 1 method)
function plotresult2(cvresult, celldata)
    !isdefined(Main, :PlutoRunner) && return
    times = cvresult.tsol.t
    (; i_ref, iϕ) = celldata
    j_we = -hcat(cvresult.j_we...)[1, :] * celldata.F
    Ωdrop = (j_we + cvresult.j_cap) * R_u
    dlvolts = [ u[iϕ, 1] - u[iϕ, i_ref]    for u in cvresult.tsol.u]
    st = [sawtooth(t) for t in times]
    fig = Figure(size = (700, 400))
    Label(fig[0, 1:2], "IR compensation: $(celldata.ircompensation), scanrate=$(scanrate) V/s")
    ax1 = Axis(fig[1, 1], xlabel = "t/s", ylabel = "Δϕ/V")
    ax2 = Axis(fig[2, 1], xlabel = "t/s", ylabel = "Δϕ/V")

    lines!(ax1, times[2:end], cvresult.voltages, label = L"ϕ_0-ϕ_L")
    lines!(ax1, times, dlvolts, label = L"ϕ_0-ϕ_{DL}")
    Legend(fig[1, 2], ax1)

    lines!(
        ax2, times, st - dlvolts,
        label = L"ϕ_{sawtooth} - ϕ_{DL} "
    )
    scatter!(ax2, cvresult.times, Ωdrop, label = L"R_u\cdot (I_F+I_C)", markersize = 3, color = :red)
    Legend(fig[2, 2], ax2)
    return fig
end
plotresult2 (generic function with 1 method)
function checkir(cvresult, celldata; tol = 1.0e-11)
    times = cvresult.tsol.t
    (; i_ref, iϕ) = celldata
    dlvolts = [ u[iϕ, 1] - u[iϕ, i_ref]    for u in cvresult.tsol.u]
    st = [sawtooth(t) for t in times]
    return norm(dlvolts - st, Inf) < tol
end
checkir (generic function with 1 method)
@test checkir(cvresult_pts, edata_pts)
�[32m�[1mTest Passed�[22m�[39m
@test checkir(cvresult_odr, edata_odr; tol = 0.03)
�[32m�[1mTest Passed�[22m�[39m