Demonstration of oxygen reduction reaction

$$ 4H^+ + O_2 + 4e^- \leftrightharpoons 2H_2O$$

begin
    using PlutoUI, HypertextLiteral
    using LiquidElectrolytes
    using Printf
    using LessUnitful
    using ExtendableGrids
    using VoronoiFVM
    using GridVisualize
    using StaticArrays
    using Interpolations
    using Test
    if isdefined(Main,:PlutoRunner)
        import CairoMakie	
   	default_plotter!(CairoMakie)
 	CairoMakie.activate!(type="svg")
    end
end
pkgdir(LiquidElectrolytes)
"/home/runner/work/LiquidElectrolytes.jl/LiquidElectrolytes.jl"

Setup

Units

begin
    LessUnitful.@phconstants R N_A e
    @unitfactors nm cm μF mol dm s V
    const F = N_A * e
end;

Data

begin
    const vmin = -1V
    const vmax = 1V
    const vdelta = 0.025 * V
    const molarity = 0.1
    const nref = 0
    const κ = 10.0
    const vfac = 1
    const scheme = :μex
    const R0 = 5.0e-16mol / (cm^2 * s)

    const Δg = 0.0
    const β = 0.5
    const ϕ_we = 0.0
    const ihplus = 1
    const iso4 = 2
    const io2 = 3
    const z = [1, -2, 0]
    const allκ = [κ, κ, 0]
end;

Solver control

solver_control = (max_round = 4,
                  tol_round = 1.0e-8,
                  reltol = 1.0e-8,
                  abstol = 1.0e-9,
                  verbose = "",
                  maxiters = 20)
(max_round = 4, tol_round = 1.0e-8, reltol = 1.0e-8, abstol = 1.0e-9, verbose = "", maxiters = 20)

Reaction description

In the following reaction function, the balance with the solvent is fulfilled automatically via the incompressibility constraint. Any material which is removed via the boundary reaction is automatically replaced by solvent with the corresponding volume. So "ignoring the solvent" here is correct.

function halfcellbc(f, u, bnode, data)
    bulkbcondition(f, u, bnode, data)
    (; iϕ, eneutral, ϕ_we, Γ_we, RT) = data

    if bnode.region == Γ_we
        f .= 0.0
        if !eneutral
            boundary_dirichlet!(f, u, bnode; species = iϕ, region = Γ_we,
                                value = ϕ_we)
        end
        μh2o, μ = chemical_potentials!(MVector{4, eltype(u)}(undef), u, data)
        A = (4 * μ[ihplus] + μ[io2] - 2μh2o + Δg +
             4 * eneutral * F * (u[iϕ] - ϕ_we)) / (RT)
        r = rrate(R0, β, A)
        f[ihplus] -= 4 * r
        f[io2] -= r
    end
end
halfcellbc (generic function with 1 method)

Nernst-Planck halfcell

grid = let
    hmin = 1.0e-1 * nm * 2.0^(-nref)
    hmax = 1.0 * nm * 2.0^(-nref)
    L = 20.0 * nm
    X = geomspace(0, L, hmin, hmax)
    simplexgrid(X)
end
ExtendableGrids.ExtendableGrid{Float64, Int32}
      dim =       1
   nnodes =      52
   ncells =      51
  nbfaces =       2
begin
    celldata = ElectrolyteData(;
                               nc = 3,
                               z,
                               κ = allκ,
                               Γ_we = 1,
                               Γ_bulk = 2,
                               eneutral = false,
                               scheme)

    celldata.v .*= vfac
    celldata.weights[celldata.ip] = 0
    celldata.weights[1:(celldata.nc)] .= 0
    c_bulk = celldata.c_bulk
    c_bulk[io2] = 0.001 * mol / dm^3
    c_bulk[iso4] = molarity * mol / dm^3
    c_bulk[ihplus] = 2.0 * molarity * mol / dm^3
end
199.99999999999997
@test isincompressible(celldata.c_bulk, celldata)
Test Passed
@test iselectroneutral(celldata.c_bulk, celldata)
Test Passed
cell = PNPSystem(grid; bcondition = halfcellbc, celldata)
VoronoiFVM.System{Float64, Float64, Int32, Int64, Matrix{Int32}}(
  grid = ExtendableGrids.ExtendableGrid{Float64, Int32}(dim=1, nnodes=52, ncells=51,
  nbfaces=2),  
  physics = Physics(data=LiquidElectrolytes.ElectrolyteData, flux=pnpflux,
  storage=pnpstorage, reaction=_pnpreaction, breaction=halfcellbc, ),  
  num_species = 5)
result=LiquidElectrolytes.ivsweep(cell;store_solutions=true,
                                                voltages = vmin:vdelta:vmax,
                                                solver_control...)
IVSweepResult{Vector{Float64}, Vector{Any}, Vector{Any}, Vector{Matrix{Float64}}}([-1.0, -0.9985343042859195, -0.997068608571839, -0.9941372171436781, -0.9912058257155171, -0.9868087385732757, -0.9821371496871446, -0.9782441589487021, -0.975, -0.9717558410512979  …  0.9717558410512979, 0.975, 0.9782441589487021, 0.9821371496871446, 0.9868087385732757, 0.9912058257155171, 0.9941372171436781, 0.997068608571839, 0.9985343042859195, 1.0], Any[[-0.10458385803541877, -0.0, -0.02614596450885469, -0.0, -0.0], [-0.10497012170478917, -0.0, -0.026242530426197293, -0.0, -0.0], [-0.105356796968378, -0.0, -0.0263391992420945, -0.0, -0.0], [-0.10613470688883876, -0.0, -0.02653367672220969, -0.0, -0.0], [-0.10686978171282505, -0.0, -0.02671744542820626, -0.0, -0.0], [-0.10799521373857227, -0.0, -0.026998803434643066, -0.0, -0.0], [-0.10935206251699454, -0.0, -0.027338015629248636, -0.0, -0.0], [-0.11042599726343709, -0.0, -0.027606499315859272, -0.0, -0.0], [-0.11131777479919021, -0.0, -0.027829443699797552, -0.0, -0.0], [-0.11221483960040574, -0.0, -0.028053709900101434, -0.0, -0.0]  …  [2.53585863752015e-17, -0.0, 6.339646593800375e-18, -0.0, -0.0], [2.5358561013266726e-17, -0.0, 6.3396402533166815e-18, -0.0, -0.0], [2.5358585524770664e-17, -0.0, 6.339646381192666e-18, -0.0, -0.0], [1.3880964702561728e-16, -0.0, 3.470241175640432e-17, -0.0, -0.0], [8.214408626150417e-16, -0.0, 2.0536021565376042e-16, -0.0, -0.0], [4.503334658534364e-16, -0.0, 1.125833664633591e-16, -0.0, -0.0], [1.010817332947056e-17, -0.0, 2.52704333236764e-18, -0.0, -0.0], [1.0110374084604246e-17, -0.0, 2.5275935211510615e-18, -0.0, -0.0], [2.5343256382370785e-20, -0.0, 6.335814095592696e-21, -0.0, -0.0], [2.5325672670106772e-20, -0.0, 6.331418167526693e-21, -0.0, -0.0]], Any[[-0.10458385918919078, 2.2330235090214136e-15, -0.02614596479806858, -1.5563494001279353e-6, -2.85264113674733e-9], [-0.10497012285178188, 1.4919462679427726e-15, -0.026242530716296487, -1.5620982295838137e-6, -5.388943813803583e-10], [-0.1053574612863571, -5.258786901077008e-16, -0.026339365322976416, -1.5678630599562532e-6, 7.653006697777664e-10], [-0.10613536414631426, -1.2193371207950313e-15, -0.02653384103839605, -1.5794407498219303e-6, 1.682841436400943e-9], [-0.1069175710702325, -7.441535420313573e-15, -0.0267293927655776, -1.5910825188583305e-6, 3.947879445642719e-10], [-0.10809895787437825, -3.8051561257832257e-16, -0.027024739467166596, -1.6086654162836591e-6, 7.514608716115052e-10], [-0.10936472286371385, 7.422888487875066e-15, -0.027341180716946016, -1.6275041907008582e-6, -3.006710009154308e-11], [-0.11042789588539677, 9.941701606973849e-15, -0.027606973972182577, -1.6433277686579832e-6, -1.535522713096396e-11], [-0.11131968783536478, -2.571049820774619e-15, -0.02782992195716195, -1.6566006519208583e-6, -3.6499438883757814e-10], [-0.11221676710744077, 1.2975622651519963e-15, -0.028054191776709786, -1.6699522565725275e-6, -4.024824080523302e-10]  …  [-2.2171088701283292e-14, 2.0968542457922117e-10, 1.1823224690954476e-17, 8.482873829072008e-16, 2.679753338000572e-9], [-3.21302011815182e-14, 4.0484025021214835e-10, 4.300487917163787e-17, 8.508257936958125e-16, 3.9183496163654934e-10], [8.713300718891596e-16, 3.014406502188667e-11, 7.140555507989613e-17, 8.84624676672528e-16, -5.369632526757582e-10], [-2.992137845456048e-15, -2.955289346573426e-11, -2.7105054312137728e-17, 8.581863815892582e-16, -3.6462288776374556e-9], [-1.776595411301763e-15, -6.620268777624042e-11, 5.455705331947034e-17, 8.786072552499476e-16, 1.8672737444031742e-9], [1.859558527509178e-15, 1.534132820779641e-10, 5.684200939798413e-17, 8.864463782438574e-16, 2.953412995090292e-9], [2.2424771010478694e-15, 3.3342928418278697e-11, 1.732012970545637e-17, 9.071554746996025e-16, -9.331909949446857e-9], [-8.326856953959337e-15, -2.73630007541216e-11, 4.8471968626396e-17, 8.709270809324201e-16, -1.0945216739951265e-9], [1.1563048690418076e-14, -9.569163239575627e-11, -2.854433269611204e-17, 9.07242746677067e-16, 3.075671267669467e-9], [9.604621150925794e-16, 1.5533032637904478e-10, -3.046879155227365e-17, 8.675283332385586e-16, -2.750650143008844e-9]], [[5013.911482746134 5003.06000289368 … 199.96749337665622 199.99999999999997; 4.9049517699662784e-48 1.1841335812884591e-42 … 99.98374563458543 99.99999999999999; … ; -1.0 -0.893834457882783 … -2.2237054824904234e-6 -1.556349400105912e-36; 0.41672559826743477 0.365421587304004 … 2.26085719153662e-16 2.985932387289147e-49], [5013.789584718166 5002.887498159819 … 199.967373320638 199.99999999999997; 5.82046694465698e-48 1.3899457811413142e-42 … 99.98368559877764 99.99999999999999; … ; -0.9985343042859195 -0.8924618692448196 … -2.231919385877838e-6 -1.562098229575548e-36; 0.41601659922206286 0.36475908834867093 … 2.2860025759235846e-16 9.114754601229273e-49], [5013.666998868148 5002.714058822048 … 199.96725293058614 199.99999999999997; 6.906863526585837e-48 1.6315150056015086e-42 … 99.98362539590246 99.99999999999999; … ; -0.997068608571839 -0.891089357302792 … -2.240156151346736e-6 -1.567863059989139e-36; 0.41530761712004455 0.3640966490477266 … 2.3114045193942944e-16 -5.435090808815504e-48], [5013.419747026484 5002.364354262704 … 199.96701114783957 199.99999999999997; 9.725834035857164e-48 2.24784112048536e-42 … 99.98350448867785 99.99999999999999; … ; -0.9941372171436781 -0.8883445642344696 … -2.256698305935989e-6 -1.5794407498289872e-36; 0.4138897041398598 0.362771950251575 … 2.3629871665287664e-16 7.42735137494597e-47], [5013.169693586705 5002.010844698061 … 199.96676802739603 199.99999999999997; 1.3695335544035236e-47 3.0968789995322745e-42 … 99.98338291239942 99.99999999999999; … ; -0.9912058257155171 -0.8856000801406522 … -2.2733320166063667e-6 -1.5910825188614514e-36; 0.4124718601205646 0.361447492611302 … 2.415623522220992e-16 7.82457493280924e-47], [5012.789285724789 5001.473347094511 … 199.96640083657636 199.99999999999997; 2.2884483306094806e-47 5.007629217632798e-42 … 99.98319929251511 99.99999999999999; … ; -0.9868087385732757 -0.8814839365548223 … -2.2984543865120225e-6 -1.608665416254913e-36; 0.41034522515376426 0.3594612620698242 … 2.496594653844357e-16 -1.7531344113737065e-48], [5012.378008468575 5000.892630237528 … 199.9660074200364 199.99999999999997; 3.9484681005080103e-47 8.343141452071538e-42 … 99.98300255772399 99.99999999999999; … ; -0.9821371496871446 -0.8771116008964832 … -2.3253711482788625e-6 -1.62750419070525e-36; 0.40808600349034546 0.3573516401971196 … 2.585335763831124e-16 1.4957975187224847e-46], [5012.029571700739 5000.4009596753995 … 199.9656769718892 199.99999999999997; 6.220632935621035e-47 1.2765739657555363e-41 … 99.98283731113533 99.99999999999999; … ; -0.9782441589487021 -0.8734685988621701 … -2.347979809933505e-6 -1.6433277686387775e-36; 0.40620345892128745 0.35559410333979796 … 2.6614788387981237e-16 1.0331019962432582e-46], [5011.735180167599 4999.985772968418 … 199.96539979131904 199.99999999999997; 9.08530045511022e-47 1.8195093029750706e-41 … 99.98269870179648 99.99999999999999; … ; -0.975 -0.8704331909024456 … -2.3669440497935493e-6 -1.656600651923928e-36; 0.4046347706371962 0.35412982680779587 … 2.7264892869991995e-16 -1.1353265885152953e-47], [5011.437074140075 4999.5655512720805 … 199.96512096745326 199.99999999999997; 1.3269171183594148e-46 2.593238399276312e-41 … 99.98255927054211 99.99999999999999; … ; -0.9717558410512979 -0.8673981734097548 … -2.3860207663613233e-6 -1.6699522565406488e-36; 0.40306617346541057 0.3526658597245313 … 2.7929449542479965e-16 3.739344061428386e-47]  …  [5.921726001410017e-26 6.541124692039875e-26 … 199.99999999999037 199.99999999999997; 5035.588054475822 5034.097046274467 … 100.00000000000956 99.99999999999999; … ; 0.9717558410512979 0.8206278830655711 … 1.2304161383069715e-15 8.611560450847315e-46; 0.8653234570810244 0.718491022446694 … -2.4424315386182202e-25 -2.4597570291029384e-46], [4.600571623120834e-26 5.080776098339398e-26 … 199.99999999999034 199.99999999999997; 5035.605760064102 5034.144415687029 … 100.00000000000959 99.99999999999999; … ; 0.975 0.823585164477891 … 1.2346484111571585e-15 8.641181708533366e-46; 0.8684744498935378 0.7213623409675757 … -2.759363738261758e-25 -2.77893529299879e-46], [3.574170117819295e-26 3.946463692257165e-26 … 199.9999999999903 199.99999999999997; 5035.623060860346 5034.190798962196 … 100.00000000000963 99.99999999999999; … ; 0.9782441589487021 0.8265429634148846 … 1.2393890903370434e-15 8.674361251668932e-46; 0.8716254548450522 0.7242341912054483 … -5.376496081757519e-26 -5.414770989291002e-47], [2.640040729935482e-26 2.914350076384511e-26 … 199.9999999999903 199.99999999999997; 5035.643300540503 5034.245186001934 … 100.00000000000969 99.99999999999999; … ; 0.9821371496871446 0.8300930013751382 … 1.2464715316936452e-15 8.72393055589301e-46; 0.8754066764751527 0.7276811087977293 … -1.1920427176523218e-26 -1.2006662144270194e-47], [1.8353970457421757e-26 2.0255355633784108e-26 … 199.9999999999902 199.99999999999997; 5035.666858325377 5034.308663539097 … 100.00000000000972 99.99999999999999; … ; 0.9868087385732757 0.8343540187067412 … 1.2521535630371405e-15 8.763698529405979e-46; 0.8799441645128532 0.7318184066770255 … -5.5906953420822095e-25 -5.630331624590574e-46], [1.3035624666870315e-26 1.4382304133056087e-26 … 199.99999999999017 199.99999999999997; 5035.688326586089 5034.366679310261 … 100.00000000000978 99.99999999999999; … ; 0.9912058257155171 0.8383656210796151 … 1.2579561017284183e-15 8.804309921887447e-46; 0.8842150520436279 0.7357135831662676 … -2.2621944155068504e-26 -2.2784050719737115e-47], [1.0376893855796104e-26 1.1446929074194296e-26 … 199.99999999999014 199.99999999999997; 5035.702269516798 5034.404447332732 … 100.0000000000098 99.99999999999999; … ; 0.9941372171436781 0.8410405373751488 … 1.2621538032168412e-15 8.833689218043222e-46; 0.8870623217425481 0.7383108945416048 … 2.312061538893654e-26 2.328265211134053e-47], [8.260388213953819e-27 9.11060991521676e-27 … 199.99999999999014 199.99999999999997; 5035.7159241877525 5034.441503950936 … 100.00000000000985 99.99999999999999; … ; 0.997068608571839 0.8437158631538918 … 1.2674933957973672e-15 8.871060496636308e-46; 0.889909600369505 0.740908624940143 … -2.112889266556231e-25 -2.127880478811005e-46], [7.369992314172149e-27 8.12787204627829e-27 … 199.9999999999901 199.99999999999997; 5035.722645297014 5034.4597696678975 … 100.00000000000986 99.99999999999999; … ; 0.9985343042859195 0.8450536789913384 … 1.2700145949727788e-15 8.888706119472137e-46; 0.8913332429938722 0.742207646580481 … 4.6703225561177634e-27 4.7015909513424487e-48], [6.575572087187167e-27 7.251139987586847e-27 … 199.9999999999901 199.99999999999997; 5035.729296571117 5034.477862523521 … 100.00000000000989 99.99999999999999; … ; 1.0 0.8463915964716767 … 1.2717735711720287e-15 8.901017019337516e-46; 0.8927568878066594 0.7435067721486411 … 7.506305139911819e-27 7.557665383860087e-48]])

Results

@bind vshow PlutoUI.Slider(range(extrema(result.voltages)...; length = 101),
                           show_value = true)
-1.0
plot1d(result, celldata, vshow)
plot1d(result, celldata)

Plotting functions

curr (generic function with 1 method)
curr_h2o (generic function with 1 method)
plotcurr (generic function with 1 method)
function plot1d!(vis,result, celldata, vshow)
    vinter = linear_interpolation(result.voltages, [j[io2] for j in result.j_we])
    tsol=LiquidElectrolytes.voltages_solutions(result)

               sol = tsol(vshow)
            c0 = solventconcentration(sol, celldata)
            scale = 1.0 / (mol / dm^3)
        ishow=vinter(vshow)
            title = "Φ_we=$(round(vshow,digits=4)), I=$(round(vinter(vshow),sigdigits=4))"
    #    title = @sprintf("Φ_we=%+1.2f I=%+1.4f",vshow,ishow)
            
            scalarplot!(vis, grid, sol[io2, :] * scale.|>abs; color = :green, label = "O_2",title)
            scalarplot!(vis,
                        grid,
                        sol[iso4, :] * scale .|>abs;
                        color = :gray,
                        clear = false,
                        label = "SO4--")
            scalarplot!(vis,
                        grid,
                        sol[ihplus, :] * scale .|>abs;
                        color = :red,
                        clear = false,
                        label = "H+")
            scalarplot!(vis, grid, c0 * scale.|>abs; color = :blue, clear = false,
                        label = "H2O")	
end
plot1d! (generic function with 1 method)
function plot1d(result,celldata, vshow)
    vis = GridVisualizer(;
                         size = (600, 250),
                         yscale = :log,
                         limits = (1.0e-6, 100),
                         legend = :rt)
    
       
     plot1d!(vis,result,celldata,vshow)
     reveal(vis)
end
plot1d (generic function with 1 method)
function plot1d(result,celldata)
    vinter = linear_interpolation(result.voltages, [j[io2] for j in result.j_we])
    tsol=LiquidElectrolytes.voltages_solutions(result)
    vis = GridVisualizer(;
                         size = (600, 250),
                         yscale = :log,
                         limits = (1.0e-6, 100),
                         legend = :rt)
    
    video="orr.gif"
    vrange=range(extrema(result.voltages)...; length = 101)
    
    movie(vis,file="orr.mp4") do vis
   	for vshow in vrange
    plot1d!(vis,result,celldata,vshow)
        reveal(vis)
    end
    end
    isdefined(Main,:PlutoRunner) && LocalResource("orr.mp4")
end
plot1d (generic function with 2 methods)
cplot (generic function with 1 method)

Electroneutral case

begin
    ncelldata = deepcopy(celldata)
    ncelldata.eneutral = true
    ncell = PNPSystem(grid; bcondition = halfcellbc, celldata = ncelldata)
end
VoronoiFVM.System{Float64, Float64, Int32, Int64, Matrix{Int32}}(
  grid = ExtendableGrids.ExtendableGrid{Float64, Int32}(dim=1, nnodes=52, ncells=51,
  nbfaces=2),  
  physics = Physics(data=LiquidElectrolytes.ElectrolyteData, flux=pnpflux,
  storage=pnpstorage, reaction=_pnpreaction, breaction=halfcellbc, ),  
  num_species = 5)

nresult = LiquidElectrolytes.ivsweep(ncell;
                                                store_solutions=true,
                                                   voltages = vmin:vdelta:vmax,
                                                   solver_control...)
IVSweepResult{Vector{Float64}, Vector{Any}, Vector{Any}, Vector{Matrix{Float64}}}([-1.0, -0.9985343042859195, -0.997068608571839, -0.9941372171436781, -0.9912058257155171, -0.9868087385732757, -0.9821371496871446, -0.9782441589487021, -0.975, -0.9717558410512979  …  0.9717558410512979, 0.975, 0.9782441589487021, 0.9821371496871446, 0.9868087385732757, 0.9912058257155171, 0.9941372171436781, 0.997068608571839, 0.9985343042859195, 1.0], Any[[-0.3974475038882486, -0.0, -0.09936187597206216, -0.0, -0.0], [-0.39853197344879976, -0.0, -0.09963299336219994, -0.0, -0.0], [-0.38921088366632905, -0.0, -0.09730272091658226, -0.0, -0.0], [-0.392526838517166, -0.0, -0.0981317096292915, -0.0, -0.0], [-0.38044488208182986, -0.0, -0.09511122052045747, -0.0, -0.0], [-0.3722770627635735, -0.0, -0.09306926569089337, -0.0, -0.0], [-0.38018684554250254, -0.0, -0.09504671138562563, -0.0, -0.0], [-0.3877582162038787, -0.0, -0.09693955405096967, -0.0, -0.0], [-0.3876558388239668, -0.0, -0.0969139597059917, -0.0, -0.0], [-0.3879671002772168, -0.0, -0.0969917750693042, -0.0, -0.0]  …  [10730.52582833627, -0.0, 2682.6314570840673, -0.0, -0.0], [10792.088404183762, -0.0, 2698.0221010459404, -0.0, -0.0], [10853.65418907537, -0.0, 2713.4135472688426, -0.0, -0.0], [10927.540880112352, -0.0, 2731.885220028088, -0.0, -0.0], [11016.227920304098, -0.0, 2754.0569800760245, -0.0, -0.0], [11099.712353218094, -0.0, 2774.9280883045235, -0.0, -0.0], [11155.383747183418, -0.0, 2788.8459367958544, -0.0, -0.0], [11211.046585628494, -0.0, 2802.7616464071234, -0.0, -0.0], [11238.887667065348, -0.0, 2809.721916766337, -0.0, -0.0], [11266.724826480071, -0.0, 2816.6812066200177, -0.0, -0.0]], Any[[-0.400162542897698, -4.338734978715565e-29, -0.10004063572442394, -0.0, -1.141700318563306e-32], [-0.4001625428977179, -1.4210854715201857e-15, -0.10004063572442394, -0.0, -1.1417003185634656e-32], [-0.4001625428976781, 2.842170943040394e-15, -0.10004063572442395, -0.0, -1.1417003185629918e-32], [-0.4001625428977008, -5.684341886080835e-15, -0.10004063572442395, -0.0, -6.724586278416217e-32], [-0.400162542897698, -5.684341886080781e-15, -0.10004063572442395, -0.0, -1.1417003248988914e-32], [-0.4001625428976753, 1.847411112976267e-14, -0.10004063572442393, -0.0, -1.1417003248992543e-32], [-0.4001625428977207, -1.8474111129762628e-14, -0.10004063572442394, -0.0, -1.1417003329897829e-32], [-0.40016254289768943, 1.5631940186722164e-14, -0.10004063572442395, -0.0, -1.141700326924672e-32], [-0.4001625428976951, -4.26325641456054e-15, -0.10004063572442393, -0.0, -3.2352825618694745e-32], [-0.400162542897698, -4.26325641456057e-15, -0.10004063572442394, -0.0, 7.930489357836191e-32]  …  [10730.524995754111, -1.2358158366510031e-5, 2682.6312458489883, -0.0, 9.186846862887965e-21], [10792.084883005455, -5.197616151235737e-5, 2698.0212077573233, -0.0, -1.0652385514047497e-24], [10853.652617456079, -2.3070952306625414e-5, 2713.4131485962803, -0.0, -2.1371683421667135e-22], [10927.544004361995, 4.5562128491383395e-5, 2731.8860124810303, -0.0, 1.6420629634130605e-21], [11016.227634012268, -4.142463041034629e-6, 2754.056907467452, -0.0, -9.119939636608994e-25], [11099.714328270136, 2.8368995316441452e-5, 2774.9285891597824, -0.0, -1.0682371686774104e-24], [11155.379289221779, -6.372226569055816e-5, 2788.844806374878, -0.0, 3.658483453910858e-21], [11211.050507941249, 5.5795242280965246e-5, 2802.762640934123, -0.0, -2.030609650842676e-22], [11238.888064480321, 5.639654938249973e-6, 2809.7220175299944, -0.0, -2.7687756694726064e-24], [11266.727211185256, 3.375974402501939e-5, 2816.6818112362507, -0.0, 1.3453504678066286e-23]], [[197.49375246307167 197.50628876752927 … 199.87561744316838 199.99999999999997; 98.74687623153584 98.75314438376463 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480676825 -0.0001715683924250879 … -8.510031883760284e-6 -1.916906622630217e-65; -2.28340063712663e-40 -2.291352994650399e-40 … -1.49731817021571e-40 0.0], [197.49375246307153 197.50628876752918 … 199.87561744316838 199.99999999999997; 98.74687623153577 98.75314438376459 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480677657 -0.00017156839242509533 … -8.510031883759638e-6 -1.916906622630218e-65; -2.2834006371267095e-40 -2.291352994650399e-40 … 3.5121079287948074e-40 6.223015277861143e-61], [197.49375246307167 197.50628876752933 … 199.87561744316838 199.99999999999997; 98.74687623153584 98.75314438376466 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480677134 -0.00017156839242509045 … -8.510031883758993e-6 -1.9169066226302174e-65; -2.2834006371266593e-40 -2.291352994650399e-40 … -6.506744269226227e-40 -6.223015277861143e-61], [197.49375246307162 197.50628876752924 … 199.87561744316838 199.99999999999997; 98.74687623153581 98.75314438376462 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480676858 -0.00017156839242508804 … -8.510031883758347e-6 -1.9169066226302174e-65; -1.3449172556832063e-39 -1.3311612534993135e-39 … 3.5121079287948074e-40 5.056199913262178e-61], [197.49375246307156 197.50628876752916 … 199.87561744316838 199.99999999999997; 98.74687623153578 98.75314438376458 … 99.93780872158419 99.99999999999999; … ; -0.0001724360048067646 -0.0001715683924250844 … -8.510031883760138e-6 -1.916906622630217e-65; -2.283400649798261e-40 -2.2913529946504e-40 … -1.6525596467247262e-39 -1.8669045833583428e-60], [197.49375246307181 197.50628876752938 … 199.87561744316838 199.99999999999997; 98.74687623153591 98.75314438376469 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480677159 -0.00017156839242509053 … -8.510031883759492e-6 -1.916906622630217e-65; -2.283400649798328e-40 -2.2913529946504e-40 … 6.016820978300065e-40 6.223015277861143e-61], [197.49375246307153 197.50628876752916 … 199.87561744316838 199.99999999999997; 98.74687623153577 98.75314438376458 … 99.93780872158419 99.99999999999999; … ; -0.0001724360048067665 -0.0001715683924250858 … -8.510031883758847e-6 -1.916906622630218e-65; -2.283400665980994e-40 -2.2913529946504e-40 … -1.5273239942494633e-39 -1.8669045833583428e-60], [197.49375246307167 197.5062887675293 … 199.87561744316838 199.99999999999997; 98.74687623153584 98.75314438376465 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480677711 -0.00017156839242509677 … -8.510031883758202e-6 -1.916906622630217e-65; -2.2834006538493026e-40 -2.2913529946504e-40 … -5.254387744473598e-40 -3.500446093796893e-61], [197.49375246307164 197.5062887675293 … 199.87561744316838 199.99999999999997; 98.74687623153582 98.75314438376465 … 99.93780872158419 99.99999999999999; … ; -0.00017243600480677313 -0.0001715683924250919 … -8.510031883759992e-6 -1.916906622630217e-65; -6.4705651237388004e-40 -7.801482764821768e-40 … 4.764464453547436e-40 1.2446030555722286e-60], [197.49375246307162 197.5062887675292 … 199.87561744316835 199.99999999999997; 98.74687623153581 98.7531443837646 … 99.93780872158418 99.99999999999999; … ; -0.00017243600480677047 -0.00017156839242508958 … -8.510031883759348e-6 -1.9169066226302174e-65; 1.5860978715672083e-39 1.4239036315863704e-39 … -5.254387744473598e-40 0.0]  …  [3282.9629616106713 3282.9629614550126 … 1992.7342100892145 199.99999999999997; 1641.4814808053357 1641.4814807275063 … 996.3671050446072 99.99999999999999; … ; 0.3129654157858624 0.3115657915930756 … 0.040823658439965646 5.140264835156676e-61; 1.8373693725776136e-28 1.8373694958502368e-28 … 7.960799327571808e-29 -1.9602498125262596e-59], [3282.9629617674027 3282.962961628952 … 1998.6553627703647 199.99999999999997; 1641.4814808837014 1641.481480814476 … 999.3276813851824 99.99999999999999; … ; 0.31455075160327733 0.31314309790424755 … 0.04092188890210766 5.1697540288713075e-61; -2.1304771028194904e-32 -2.1305441522811264e-32 … -6.968919272053921e-30 0.0], [3282.962961905984 3282.9629617828436 … 2004.5490737743532 199.99999999999997; 1641.481480952992 1641.4814808914218 … 1002.2745368871766 99.99999999999999; … ; 0.3161362918556908 0.31472060764474524 … 0.04101983323927249 5.199246915995863e-61; -4.274336684333392e-30 -4.274332701146498e-30 … 5.139587026653441e-30 0.0], [3282.962962051262 3282.962961944283 … 2011.5855178879324 199.99999999999997; 1641.481481025631 1641.4814809721415 … 1005.7927589439662 99.99999999999999; … ; 0.31803920687758824 0.3166138847430825 … 0.04113699358855118 5.2346431889111616e-61; 3.2841259268263026e-29 3.284125892149219e-29 … -1.0365013365863295e-28 3.9204996250525193e-59], [3282.962962199506 3282.9629621091535 … 2019.9777448272612 199.99999999999997; 1641.481481099753 1641.4814810545768 … 1009.9888724136306 99.99999999999999; … ; 0.32032308393961767 0.31888619444082084 … 0.04127705686803677 5.277125532791377e-61; -1.8239879273218245e-32 -1.823993165227507e-32 … -2.1765207534409267e-32 1.6313136709690758e-55], [3282.9629623169603 3282.962962239895 … 2027.8258889053043 199.99999999999997; 1641.4814811584802 1641.4814811199476 … 1013.9129444526521 99.99999999999999; … ; 0.3224731331450364 0.3210253541599172 … 0.04140837103451125 5.31711829956127e-61; -2.136474337354847e-32 -2.1365345147799982e-32 … -2.2214625509987068e-32 2.402080858672722e-58], [3282.962962385051 3282.9629623157434 … 2033.030717986592 199.99999999999997; 1641.4814811925255 1641.4814811578717 … 1016.515358993296 99.99999999999999; … ; 0.3239066972440747 0.322451657637195 … 0.04149563828077301 5.3437836852279736e-61; 7.316966907821797e-29 7.316966963978055e-29 … 2.825217978660234e-29 4.276423536163071e-50], [3282.9629624459703 3282.9629623836413 … 2038.2138592700894 199.99999999999997; 1641.4814812229852 1641.4814811918206 … 1019.1069296350447 99.99999999999999; … ; 0.3253404179383102 0.32387811694864377 … 0.04158268784792731 5.370451865830956e-61; -4.061219301685374e-30 -4.061216794576329e-30 … -1.2143983402441103e-29 4.276423536147514e-50], [3282.9629624739796 3282.9629624148724 … 2040.7973304337704 199.99999999999997; 1641.4814812369898 1641.4814812074362 … 1020.3986652168852 99.99999999999999; … ; 0.32605733654009433 0.3245914045763822 … 0.04162613172750647 5.383786994198625e-61; -5.537551338945245e-32 -5.537554936600807e-32 … -1.266255754284866e-31 0.0], [3282.9629625004727 3282.962962444421 … 2043.3754196863742 199.99999999999997; 1641.4814812502364 1641.4814812222105 … 1021.6877098431871 99.99999999999999; … ; 0.3267742937311012 0.3253047306063508 … 0.04166952205422544 5.397122809313521e-61; 2.690700935613293e-31 2.690699685387807e-31 … 1.681826926224476e-31 3.340955887615245e-52]])

Results

plotcurr(nresult)
@bind nvshow PlutoUI.Slider(range(extrema(nresult.voltages)...; length = 101),
                            show_value = true)
-1.0

Comparison

let vis = GridVisualizer(;
                         size = (600, 400),
                         title = "IV Curve",
                         xlabel = "Φ_WE/V",
                         ylabel = "I/(A/m^2)",
                         legend = :lt,
                         )
    scalarplot!(vis,
                nresult.voltages,
                currents(nresult,io2);
                label = "O2,electroneutral",
                color = :green,
                clear = false,
                limits= [-5.0e4, 5.0e4])

    scalarplot!(vis, result.voltages, currents(result, io2); label = "O2,PNP", color = :red,
                clear = false)
    reveal(vis)
end