ORR.jl
Demonstration of oxygen reduction reaction
$$ 4(H^+⋅κH_2O) + O_2 + 4e^- \leftrightharpoons (2+4κ)H_2O$$
Negative potential: electrons available, protons attracted, water produced
Positive potential: electrons sucked away, protons pushed away, water destroyed
using GridVisualize
import CairoMakie
default_plotter!(CairoMakie)
CairoMakie.activate!(type="svg")
begin
using PlutoUI, HypertextLiteral
using LiquidElectrolytes
using Printf
using LessUnitful
using ExtendableGrids
using VoronoiFVM
using StaticArrays
using Interpolations
using Test
end
pkgdir(LiquidElectrolytes)
"/home/runner/work/LiquidElectrolytes.jl/LiquidElectrolytes.jl"
begin
mylog=RLog()
LiquidElectrolytes.rlog(x::Number)=mylog(x)
end
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
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 = "ne",
maxiters = 20,
damp_initial=0.1
)
(max_round = 4, tol_round = 1.0e-8, reltol = 1.0e-8, abstol = 1.0e-9, verbose = "ne", maxiters = 20, damp_initial = 0.1)
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
return 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+4κ[ihplus])*μ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
#celldata.pscale=1
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([-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.10592034819181619, -0.0, -0.026480087047954046, -0.0, -0.0], [-0.10630852567727113, -0.0, -0.026577131419317782, -0.0, -0.0], [-0.10669776722177376, -0.0, -0.02667444180544344, -0.0, -0.0], [-0.10747944383611178, -0.0, -0.026869860959027946, -0.0, -0.0], [-0.10826538052077979, -0.0, -0.027066345130194947, -0.0, -0.0], [-0.1094522777805381, -0.0, -0.027363069445134523, -0.0, -0.0], [-0.11072378381969537, -0.0, -0.027680945954923843, -0.0, -0.0], [-0.11179164946704852, -0.0, -0.02794791236676213, -0.0, -0.0], [-0.11268728686948287, -0.0, -0.028171821717370718, -0.0, -0.0], [-0.11358815128944047, -0.0, -0.028397037822360117, -0.0, -0.0] … [2.4942492515833696e-22, -0.0, 6.235623128958424e-23, -0.0, -0.0], [2.577027480299421e-22, -0.0, 6.442568700748553e-23, -0.0, -0.0], [-2.8869351353932876e-22, -0.0, -7.217337838483219e-23, -0.0, -0.0], [-2.6967761357354905e-22, -0.0, -6.741940339338726e-23, -0.0, -0.0], [-2.6800117680636505e-22, -0.0, -6.700029420159126e-23, -0.0, -0.0], [-2.379496599758113e-22, -0.0, -5.948741499395283e-23, -0.0, -0.0], [4.811506748580996e-22, -0.0, 1.202876687145249e-22, -0.0, -0.0], [1.25883747870148e-22, -0.0, 3.1470936967537e-23, -0.0, -0.0], [-1.7927659357042103e-22, -0.0, -4.481914839260526e-23, -0.0, -0.0], [2.306088653369898e-22, -0.0, 5.765221633424745e-23, -0.0, -0.0]], Any[[0.10592034828305542, 3.7847933997625678e-16, 0.026480087047963174, 0.7617236380571555, -7.476395101767722e-10], [0.10630852570595549, 8.159087533763664e-15, 0.026577131419320492, 0.7610760434265903, 2.583179086003654e-9], [0.10669776723450185, 3.876451052782772e-15, 0.026674441805444853, 0.7604279126882699, 2.508193742983793e-10], [0.10747944383693665, 9.756274457458707e-16, 0.026869860959028498, 0.7591300377543568, 9.802463875293377e-10], [0.10826538058178983, 1.38909336530223e-15, 0.027066345130201046, 0.7578300029375712, -1.093994085649417e-12], [0.10945227769600194, -5.985298758896433e-15, 0.0273630694451255, 0.7558758781637877, 1.2717792461116554e-9], [0.11072378379230939, -8.502217266379988e-15, 0.02768094595492118, 0.7537943715406009, 3.74539182992583e-10], [0.1117916495713132, 2.011757524181358e-15, 0.027947912366773256, 0.7520555106527625, 2.1288799386961565e-10], [0.11268728683440941, 1.363076184004652e-14, 0.028171821717366846, 0.7506034737924483, -8.851282463065843e-10], [0.1135881512296379, -2.2970585069352515e-15, 0.028397037822353664, 0.7491487065914347, -1.0837210770987783e-9] … [1.6370172682985423e-14, 1.5290510191332456e-9, -3.1571967262778085e-17, -1.0981730294897594, -1.8946489114239764e-10], [2.154548441858667e-15, 1.5966634236972828e-9, -5.374390169010949e-17, -1.10016720392229, -2.6117761172712974e-9], [-2.2204199792029375e-14, -1.9860493694065906e-9, -6.11544235390483e-17, -1.1021577789016823, 6.4791782216884906e-9], [-7.218508956294989e-15, -1.8288204728375313e-9, -8.960388854506346e-17, -1.1045417447992212, 3.736336377158382e-9], [2.1319426971726515e-15, -1.8116011801790736e-9, -3.1799649718998293e-17, -1.1073957452608345, -2.376268711889297e-9], [-1.0397823909621172e-14, -1.5855405877116324e-9, -1.0807327255335548e-16, -1.1100753568669306, -1.1816369039120571e-9], [1.2489788877087427e-15, 3.1424633561978573e-9, 8.977193988175864e-18, -1.1118581848317535, 1.9899270681103348e-10], [8.915546459027882e-15, 8.154046327034827e-10, -1.75694962051279e-17, -1.1136381648564977, -2.5136348852249053e-9], [-7.344493613775542e-15, -1.2006040606137617e-9, -3.9136987921296257e-17, -1.114527091107805, -1.5672794063966834e-9], [1.2409671326130109e-15, 1.498946744504711e-9, 7.762887554997827e-18, -1.1154153104193993, 6.303641494065226e-11]], Any[[-0.10592034828305545, -3.784793399756024e-16, -0.026480087047963174, -1.576227432579055e-6, 7.476395101769634e-10], [-0.10630852570595552, -8.15908753376297e-15, -0.02657713141932049, -1.5820046667675542e-6, -2.583179086003903e-9], [-0.10669776723450186, -3.876451052782784e-15, -0.026674441805444857, -1.5877977422492171e-6, -2.508193742984281e-10], [-0.10747944383693665, -9.756274457464175e-16, -0.026869860959028498, -1.5994314371869718e-6, -9.802463875294804e-10], [-0.10826538058178985, -1.389093365301234e-15, -0.027066345130201043, -1.6111285546760116e-6, 1.093994085624458e-12], [-0.10945227769600195, 5.985298758896919e-15, -0.027363069445125503, -1.6287932174652278e-6, -1.2717792461118341e-9], [-0.11072378379230939, 8.502217266379739e-15, -0.02768094595492118, -1.6477171682683677e-6, -3.745391829927074e-10], [-0.1117916495713132, -2.0117575241817393e-15, -0.027947912366773256, -1.6636103592351108e-6, -2.128879938694707e-10], [-0.1126872868344094, -1.3630761840046762e-14, -0.02817182171736685, -1.6769402820828335e-6, 8.851282463066374e-10], [-0.1135881512296379, 2.297058506935589e-15, -0.028397037822353664, -1.6903480256841119e-6, 1.083721077098972e-9] … [-1.6370172682986234e-14, -1.5290510191334839e-9, 3.157196726277806e-17, 8.749047408591306e-16, 1.8946489114226726e-10], [-2.1545484418574903e-15, -1.596663423697473e-9, 5.374390169010677e-17, 8.724340225433643e-16, 2.6117761172714355e-9], [2.2204199792028687e-14, 1.9860493694068396e-9, 6.115442353904463e-17, 8.520425553610832e-16, -6.4791782216894675e-9], [7.218508956294223e-15, 1.8288204728378434e-9, 8.960388854506486e-17, 8.547566897016029e-16, -3.736336377158524e-9], [-2.1319426971745227e-15, 1.8116011801794338e-9, 3.179964971899999e-17, 8.923403941387068e-16, 2.3762687118895774e-9], [1.0397823909621256e-14, 1.5855405877118845e-9, 1.080732725533552e-16, 8.693810316625133e-16, 1.1816369039122147e-9], [-1.2489788877100475e-15, -3.1424633561982953e-9, -8.977193988179976e-18, 8.927610910369288e-16, -1.989927068111109e-10], [-8.915546459027024e-15, -8.154046327035803e-10, 1.7569496205127342e-17, 9.048714982706003e-16, 2.5136348852253586e-9], [7.344493613774941e-15, 1.2006040606138477e-9, 3.913698792129556e-17, 8.813590440996728e-16, 1.5672794063969684e-9], [-1.2409671326119455e-15, -1.4989467445048e-9, -7.762887554995814e-18, 8.924416723037466e-16, -6.303641494052177e-11]], [[5013.512456603281 5002.471499893383 … 199.9693095061514 199.99999999999997; 4.9048453007890813e-48 1.1785757017894762e-42 … 99.98465374550244 99.99999999999999; … ; -1.0 -0.8938742377576455 … -2.252107131725807e-6 -1.576227432560103e-36; 0.41642130041703646 0.3651415688371003 … 2.189409366406542e-16 6.493716402620804e-50], [5013.388748399885 5002.296468460925 … 199.9691970327369 199.99999999999997; 5.820338985516538e-48 1.383422796040033e-42 … 99.98459750139601 99.99999999999999; … ; -0.9985343042859195 -0.8925016399178014 … -2.2603616197059386e-6 -1.5820046667834376e-36; 0.41571262070177306 0.3644794019493807 … 2.213571066961369e-16 -1.769556622347104e-49], [5013.26434407968 5002.120491398198 … 199.9690842510227 199.99999999999997; 6.906709749620425e-48 1.6238594002502575e-42 … 99.98454110309225 99.99999999999999; … ; -0.997068608571839 -0.8911291187364002 … -2.2686387416066937e-6 -1.5877977422632062e-36; 0.4150039582839259 0.36381729510525046 … 2.237976867298363e-16 7.58106184765676e-49], [5013.013430252607 5001.765678102597 … 199.96885776230815 199.99999999999997; 9.725611985993655e-48 2.2372964389403178e-42 … 99.98442784369828 99.99999999999999; … ; -0.9941372171436781 -0.8883843070759821 … -2.2852609160522412e-6 -1.5994314372063927e-36; 0.4135866857391171 0.36249326239530166 … 2.2875293940957733e-16 7.182955029359977e-49], [5012.759681163874 5001.4070150716025 … 199.96863003928786 199.99999999999997; 1.3695014987455653e-47 3.082355514758853e-42 … 99.9843139669588 99.99999999999999; … ; -0.9912058257155171 -0.8856398042374749 … -2.301973708385087e-6 -1.611128554709646e-36; 0.4121694835860335 0.361169472412996 … 2.338084222967799e-16 -6.238744358997966e-49], [5012.3736659923015 5000.861702475192 … 199.9682861391024 199.99999999999997; 2.2883927535540855e-47 4.984154756501266e-42 … 99.98414199365668 99.99999999999999; … ; -0.9868087385732757 -0.8815236322446071 … -2.327212904275602e-6 -1.6287932174505797e-36; 0.4100438141228597 0.3591842463275495 … 2.415834114544371e-16 -1.1691637554043732e-48], [5011.95634632836 5000.272569830177 … 199.96791772385424 199.99999999999997; 3.948368430342609e-47 8.304048645204541e-42 … 99.98395776088779 99.99999999999999; … ; -0.9821371496871446 -0.877151266018488 … -2.3542513656572596e-6 -1.6477171682536332e-36; 0.40778562182636874 0.35707569555478286 … 2.501018825989837e-16 9.719419332661443e-49], [5011.602806324615 4999.773795998033 … 199.967608312907 199.99999999999997; 6.220470838806768e-47 1.270594692718677e-41 … 99.98380303407193 99.99999999999999; … ; -0.9782441589487021 -0.8735082382009284 … -2.3769594901710978e-6 -1.6636103592552862e-36; 0.4059039379161467 0.355319054409018 … 2.5740892646288617e-16 -9.905448248429536e-49], [5011.3041143246155 4999.352626521528 … 199.96734880464422 199.99999999999997; 9.085057424882642e-47 1.8109897192791174e-41 … 99.98367326188236 99.99999999999999; … ; -0.975 -0.87047280853644 … -2.396005227892479e-6 -1.6769402820848365e-36; 0.4043359688473798 0.3538555264944463 … 2.636461312346615e-16 -6.782928962258913e-49], [5011.001663899878 4998.926363791582 … 199.967087781919 199.99999999999997; 1.3268806900798025e-46 2.581099833871187e-41 … 99.98354273221072 99.99999999999999; … ; -0.9717558410512979 -0.8674377691373997 … -2.4151621555859404e-6 -1.690348025672445e-36; 0.4027680927235594 0.35239231003564275 … 2.7002058678528915e-16 -1.2614793139898361e-48] … [5.341290029961883e-26 5.900380583721748e-26 … 199.99999999999034 199.99999999999997; 5035.532775727444 5033.937449802622 … 100.00000000000956 99.99999999999999; … ; 0.9717558410512979 0.8207284914650587 … 1.233675352235987e-15 8.634371365706236e-46; 0.8642225020752435 0.7174909473843158 … 8.671321245527741e-28 8.715504509284472e-49], [4.14934385655222e-26 4.582762110123849e-26 … 199.99999999999034 199.99999999999997; 5035.551660589028 5033.987909279231 … 100.00000000000962 99.99999999999999; … ; 0.975 0.8236857306921367 … 1.2382103438108849e-15 8.666111321706042e-46; 0.8673719760745565 0.7203606503550813 … 6.725272389949346e-28 6.755535772336461e-49], [3.223388389439791e-26 3.5593855973170294e-26 … 199.9999999999903 199.99999999999997; 5035.57011560381 5034.037323519708 … 100.00000000000966 99.99999999999999; … ; 0.9782441589487021 0.8266434872552975 … 1.24302785899812e-15 8.69982863243218e-46; 0.8705214692355923 0.7232308928525599 … -5.055027565855795e-28 -5.108386626782095e-49], [2.3807424688821067e-26 2.628287562283574e-26 … 199.99999999999022 199.99999999999997; 5035.591708022074 5034.095271284932 … 100.00000000000969 99.99999999999999; … ; 0.9821371496871446 0.8301934741199517 … 1.2485304677587189e-15 8.738340845092574e-46; 0.8743008859587152 0.7266758914157995 … -8.755404837924546e-28 -8.835140817832168e-49], [1.654977359909167e-26 1.8265480572505566e-26 … 199.9999999999902 199.99999999999997; 5035.616843742334 5034.162914159937 … 100.00000000000976 99.99999999999999; … ; 0.9868087385732757 0.8344544297926609 … 1.2542292157810691e-15 8.778225816981957e-46; 0.8788362212781804 0.7308109010703772 … 3.1572326292464507e-29 3.000972740939586e-50], [1.1753060448319142e-26 1.2968108518462336e-26 … 199.99999999999014 199.99999999999997; 5035.6397532965 5034.224746049451 … 100.0000000000098 99.99999999999999; … ; 0.9912058257155171 0.8384659738088577 … 1.2613410341973852e-15 8.828000728331724e-46; 0.8831050954530569 0.7347039380766746 … -1.369671055509874e-27 -1.3811827594133972e-48], [9.355281506584456e-27 1.0320658774517714e-26 … 199.99999999999014 199.99999999999997; 5035.654634046563 5034.26500319146 … 100.00000000000985 99.99999999999999; … ; 0.9941372171436781 0.8411408510426746 … 1.2655081058508591e-15 8.857165649312266e-46; 0.8859510296688072 0.7372998306433484 … -1.3930884392083111e-27 -1.4047773045145332e-48], [7.446680320740567e-27 8.21369444192969e-27 … 199.9999999999901 199.99999999999997; 5035.669208516396 5034.304505845642 … 100.00000000000988 99.99999999999999; … ; 0.997068608571839 0.8438161376473374 … 1.2710159710537577e-15 8.895714651290687e-46; 0.8887969780618713 0.7398961480898992 … -1.169913750636674e-28 -1.1965110518536677e-49], [6.643785777227634e-27 7.327473067413138e-27 … 199.99999999999005 199.99999999999997; 5035.6763828761805 5034.323978657083 … 100.00000000000988 99.99999999999999; … ; 0.9985343042859195 0.8451539338597688 … 1.272898220366406e-15 8.908888327443653e-46; 0.8902199574901141 0.741194465403441 … -5.457445203534375e-28 -5.514489100098623e-49], [5.9274584860714286e-27 6.5368723326876e-27 … 199.99999999999005 199.99999999999997; 5035.683483025372 5034.343268114123 … 100.0000000000099 99.99999999999999; … ; 1.0 0.8464918316922079 … 1.2749618030389482e-15 8.923331137787776e-46; 0.8916429403594364 0.742492888050262 … -5.968107029159838e-28 -6.0288320430844135e-49]])
Results
@bind vshow PlutoUI.Slider(range(extrema(result.voltages)...; length = 101),
show_value = true)
plot1d(result, celldata, vshow)
plot1d(result, celldata)
cplot(cell, result)
Plotting functions
curr (generic function with 1 method)
curr_h2o (generic function with 1 method)
function plotcurr(result)
scale = 1 / (mol / dm^3)
volts = result.voltages
vis = GridVisualizer(;
size = (600, 300),
tilte = "IV Curve",
xlabel = "Φ_WE/V",
ylabel = "I",
legend = :lt)
scalarplot!(vis,
volts,
curr(result.j_bulk, ihplus);
linestyle = :dash,
label = "H+, bulk",
color = :red)
scalarplot!(vis,
volts,
curr(result.j_we, ihplus);
color = :red,
clear = false,
linestyle = :solid,
label = "H+, we")
scalarplot!(vis,
volts,
curr(result.j_bulk, io2);
linestyle = :dash,
label = "O2, bulk",
color = :green,
clear = false)
scalarplot!(vis,
volts,
curr(result.j_we, io2);
color = :green,
clear = false,
linestyle = :solid,
label = "O2, we")
scalarplot!(vis,
volts,
curr(result.j_bulk, io2);
linestyle = :dash,
label = "O2, bulk",
color = :green,
clear = false)
scalarplot!(vis,
volts,
curr(result.j_we, io2);
color = :green,
clear = false,
linestyle = :solid,
label = "O2, we")
scalarplot!(vis,
volts,
curr_h2o(result.j_bulk) / 100;
linestyle = :dash,
label = "H2O/100, bulk",
color = :blue,
clear = false)
scalarplot!(vis,
volts,
curr_h2o(result.j_we) / 100;
color = :blue,
clear = false,
linestyle = :solid,
label = "H2O/100, we")
reveal(vis)
end
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))"
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([-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[[-1.3893035811008506e7, -0.0, -3.4732589527521264e6, -0.0, -0.0], [-1.7529170702339992e7, -0.0, -4.382292675584998e6, -0.0, -0.0], [-1.9153856283730105e7, -0.0, -4.788464070932526e6, -0.0, -0.0], [-1.7604514300334692e7, -0.0, -4.401128575083673e6, -0.0, -0.0], [-1.5666699366096565e7, -0.0, -3.9166748415241414e6, -0.0, -0.0], [-1.284678809117432e7, -0.0, -3.21169702279358e6, -0.0, -0.0], [-9.9842896262236e6, -0.0, -2.4960724065559e6, -0.0, -0.0], [-8.244452993002726e6, -0.0, -2.0611132482506814e6, -0.0, -0.0], [-7.160470768067691e6, -0.0, -1.7901176920169226e6, -0.0, -0.0], [-6.219010724149781e6, -0.0, -1.5547526810374453e6, -0.0, -0.0] … [5899.268971504411, -0.0, 1474.8172428761027, -0.0, -0.0], [5933.402033664548, -0.0, 1483.350508416137, -0.0, -0.0], [5967.5471858305145, -0.0, 1491.8867964576286, -0.0, -0.0], [6008.537076746157, -0.0, 1502.1342691865393, -0.0, -0.0], [6057.747164150282, -0.0, 1514.4367910375704, -0.0, -0.0], [6104.087389614713, -0.0, 1526.0218474036783, -0.0, -0.0], [6134.992362058512, -0.0, 1533.748090514628, -0.0, -0.0], [6165.906385236967, -0.0, 1541.4765963092418, -0.0, -0.0], [6181.366753882152, -0.0, 1545.341688470538, -0.0, -0.0], [6196.829341088725, -0.0, 1549.2073352721814, -0.0, -0.0]], Any[[0.4001518215433919, -2.8421709430403504e-15, 0.10003795535678531, -0.0, 2.168493328124228e-28], [0.400151821543389, -1.4210854715200715e-15, 0.10003795535678531, -0.0, 2.5313281726784213e-28], [0.40015182154338047, 2.6979042958558604e-28, 0.10003795535678531, -0.0, 2.894163017232617e-28], [0.4001518215433748, -5.684341886080397e-15, 0.10003795535678531, -0.0, 3.25699786178681e-28], [0.40015182154336915, -8.52651282912032e-15, 0.10003795535678531, -0.0, 3.6198327063410037e-28], [0.40015182154336915, -1.4210854715195374e-15, 0.10003795535678531, -0.0, 4.069354339766324e-28], [0.4001518215433748, -2.842170943039784e-15, 0.10003795535678531, -0.0, 4.518875973191637e-28], [0.40015182154337486, -1.136868377216096e-14, 0.10003795535678531, -0.0, 5.017378874230962e-28], [0.4001518215433719, -5.684341886079671e-15, 0.10003795535678531, -0.0, 5.57096774632592e-28], [0.4001518215433719, -9.94759830064056e-15, 0.10003795535678531, -0.0, 6.192570196764668e-28] … [-5899.268971504505, -1.9866774891850585e-12, -1474.817242876126, -0.0, -7.0308846845674355e-15], [-5933.402033664499, 1.0629719326968063e-12, -1483.3505084161243, -0.0, 8.768962393773484e-15], [-5967.54718583056, -4.1779912862680793e-13, -1491.88679645764, -0.0, 9.620248337957215e-15], [-6008.537076746094, 1.7053025658240294e-12, -1502.134269186524, -0.0, -3.018025624247911e-14], [-6057.7471641501215, 7.958078640512274e-13, -1514.4367910375292, -0.0, -1.7190187582203587e-14], [-6104.087389614749, -9.862333172348224e-13, -1526.0218474036876, -0.0, 6.641166296105934e-15], [-6134.992362058518, 6.963318810448117e-13, -1533.748090514628, -0.0, 1.3592901633924708e-14], [-6165.9063852368745, 4.0927261579791496e-13, -1541.4765963092184, -0.0, -1.2429206056259942e-15], [-6181.366753882079, 2.1884716261393746e-13, -1545.3416884705198, -0.0, 7.126583965663636e-16], [-6196.829341088559, 1.099920154956438e-12, -1549.2073352721402, -0.0, -1.2313487965669122e-15]], Any[[-0.40015182154339185, 2.8421709430401713e-15, -0.10003795535678532, -0.0, -2.168493328124161e-28], [-0.40015182154338896, 1.4210854715199634e-15, -0.10003795535678532, -0.0, -2.531328172678345e-28], [-0.4001518215433804, -2.2482535798798836e-28, -0.10003795535678532, -0.0, -2.894163017232527e-28], [-0.40015182154337475, 5.684341886080587e-15, -0.10003795535678532, -0.0, -3.256997861786711e-28], [-0.40015182154336904, 8.526512829121107e-15, -0.10003795535678532, -0.0, -3.619832706340895e-28], [-0.4001518215433691, 1.4210854715200888e-15, -0.10003795535678532, -0.0, -4.069354339766198e-28], [-0.40015182154337475, 2.842170943040323e-15, -0.1000379553567853, -0.0, -4.518875973191501e-28], [-0.4001518215433747, 1.136868377216152e-14, -0.1000379553567853, -0.0, -5.017378874230808e-28], [-0.40015182154337187, 5.6843418860807545e-15, -0.1000379553567853, -0.0, -5.570967746325755e-28], [-0.40015182154337187, 9.947598300641337e-15, -0.1000379553567853, -0.0, -6.192570196764479e-28] … [5899.2689715045035, 1.9866774891852516e-12, 1474.8172428761259, -0.0, 7.0308846845674095e-15], [5933.402033664499, -1.0629719326971472e-12, 1483.3505084161245, -0.0, -8.768962393773462e-15], [5967.547185830559, 4.1779912862694707e-13, 1491.88679645764, -0.0, -9.620248337957187e-15], [6008.537076746096, -1.7053025658242213e-12, 1502.1342691865243, -0.0, 3.018025624247903e-14], [6057.747164150123, -7.958078640513379e-13, 1514.4367910375295, -0.0, 1.7190187582203568e-14], [6104.08738961475, 9.862333172350315e-13, 1526.0218474036878, -0.0, -6.641166296105915e-15], [6134.992362058517, -6.96331881044897e-13, 1533.748090514628, -0.0, -1.359290163392467e-14], [6165.906385236874, -4.0927261579781125e-13, 1541.4765963092186, -0.0, 1.2429206056259828e-15], [6181.366753882079, -2.1884716261411568e-13, 1545.34168847052, -0.0, -7.126583965663641e-16], [6196.829341088557, -1.0999201549566439e-12, 1549.2073352721397, -0.0, 1.2313487965669081e-15]], [[197.66277647150835 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575418 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598444 -0.00017149082113939533 … -8.5096243904028e-6 -1.9168552639125154e-66; -4.3369866562483365e-36 -4.505144689350266e-36 … 3.346480713589967e-36 1.991364888915566e-60], [197.66277647150838 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575419 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598436 -0.00017149082113939528 … -8.509624390402776e-6 -1.9168552639125154e-66; -5.062656345356705e-36 -5.2588569735126905e-36 … 3.900511537234882e-36 1.991364888915566e-60], [197.6627764715084 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.8313882357542 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598428 -0.00017149082113939522 … -8.509624390402752e-6 -1.9168552639125154e-66; -5.788326034465074e-36 -6.012569257675115e-36 … 4.454542360879797e-36 1.991364888915566e-60], [197.66277647150844 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575422 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.0001723576702559842 -0.00017149082113939517 … -8.509624390402728e-6 -1.9168552639125154e-66; -6.513995723573443e-36 -6.766281541837539e-36 … 5.008573184524712e-36 1.991364888915566e-60], [197.66277647150847 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575423 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.0001723576702559841 -0.0001714908211393951 … -8.509624390402704e-6 -1.9168552639125212e-66; -7.239665412681812e-36 -7.519993825999963e-36 … 5.562604008169627e-36 -2.489206111144457e-60], [197.66277647150847 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575423 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598373 -0.00017149082113939476 … -8.509624390402677e-6 -1.9168552639125212e-66; -8.138708679532422e-36 -8.45407102463931e-36 … 6.261007684881621e-36 -2.489206111144457e-60], [197.66277647150847 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575423 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598335 -0.0001714908211393944 … -8.50962439040265e-6 -1.9168552639124798e-66; -9.037751946383032e-36 -9.388148223278657e-36 … 6.959411361593615e-36 -3.48488855560224e-60], [197.66277647150847 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575423 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598406 -0.00017149082113939517 … -8.509624390402642e-6 -1.9168552639124756e-66; -1.0034757748461651e-35 -1.042405262007076e-35 … 7.736618553938056e-36 -5.974094666746697e-60], [197.66277647150847 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575423 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.0001723576702559842 -0.00017149082113939536 … -8.509624390402635e-6 -1.9168552639124787e-66; -1.1141935492651538e-35 -1.1574457513487011e-35 … 8.602855672340529e-36 -6.471935888975589e-60], [197.66277647150847 197.67447194458703 … 199.8840497949383 199.99999999999997; 98.83138823575423 98.83723597229351 … 99.94202489746915 99.99999999999999; … ; -0.00017235767025598468 -0.00017149082113939587 … -8.509624390402627e-6 -1.9168552639124845e-66; -1.2385140393528998e-35 -1.286562785543189e-35 … 9.565942913008834e-36 -6.96977711120448e-60] … [2672.057357729257 2671.7709575558597 … 1159.0895542692128 199.99999999999997; 1336.0286788646285 1335.8854787779298 … 579.5447771346064 99.99999999999999; … ; 0.2356760287583935 0.2347305936587696 … 0.03489352482213155 2.8259385994168317e-61; 1.4061769369134822e-22 1.4061769370213343e-22 … 7.285381210594792e-24 7.337017649834047e-45], [2672.376006204457 2672.094576666195 … 1162.3850571628118 199.99999999999997; 1336.1880031022285 1336.0472883330974 … 581.1925285814059 99.99999999999999; … ; 0.23675670629801168 0.2358059151914379 … 0.034990599087868564 2.8422894283653285e-61; -1.7537924787546928e-22 -1.7537924791244714e-22 … -8.949246411079082e-24 -9.012657849995955e-45], [2672.687404200772 2672.4108656673698 … 1165.6679834859654 199.99999999999997; 1336.343702100386 1336.2054328336849 … 582.8339917429827 99.99999999999999; … ; 0.23783761630004496 0.23688146592829573 … 0.035087385252404006 2.8586460488135755e-61; -1.9240496675914374e-22 -1.924049667822549e-22 … -9.871756415105824e-24 -9.941719832948307e-45], [2673.0517439376467 2672.7809710743168 … 1169.5909917307 199.99999999999997; 1336.5258719688234 1336.3904855371584 … 584.79549586535 99.99999999999999; … ; 0.23913501151742803 0.23817242579072312 … 0.035203152016657024 2.8782815181375935e-61; 6.036051248495806e-22 6.036051248245436e-22 … 3.069886947644672e-23 3.0916442889214573e-44], [2673.475876210935 2673.2118756090777 … 1174.2749960724593 199.99999999999997; 1336.7379381054675 1336.6059378045388 … 587.1374980362297 99.99999999999999; … ; 0.2406923165537739 0.2397220024035097 … 0.035341535694690174 2.9018547246056234e-61; 3.438037516440714e-22 3.438037517214938e-22 … 1.714115315847951e-23 1.7262671607854203e-44], [2673.862449391446 2673.6046798137518 … 1178.6604161451523 199.99999999999997; 1336.931224695723 1336.8023399068759 … 589.3302080725762 99.99999999999999; … ; 0.2421585376595231 0.24118094334006893 … 0.03547125970753954 2.9240531753761702e-61; -1.3282332592211832e-22 -1.3282332583731722e-22 … -6.815090057353726e-24 -6.863351440689383e-45], [2674.113547850972 2673.859856440625 … 1181.5715342688927 199.99999999999997; 1337.056773925486 1336.9299282203126 … 590.7857671344464 99.99999999999999; … ; 0.24313624322465166 0.24215379235300105 … 0.03555746091788053 2.9388576460596772e-61; -2.7185803267849344e-22 -2.718580326634712e-22 … -1.3904509671948438e-23 -1.400304102395009e-44], [2674.3594799895104 2674.1098069808518 … 1184.472714634686 199.99999999999997; 1337.1797399947552 1337.0549034904259 … 592.236357317343 99.99999999999999; … ; 0.24411412658018342 0.24312681670809347 … 0.03564343906931918 2.9536664523346533e-61; 2.4858412112519672e-23 2.485841210019372e-23 … 1.389940840754722e-24 1.399797098537025e-45], [2674.480542068974 2674.232856091186 … 1185.9195937463282 199.99999999999997; 1337.240271034487 1337.116428045593 … 592.9597968731641 99.99999999999999; … ; 0.24460313438160014 0.2436133941008808 … 0.035686345057875525 2.9610724636093962e-61; -1.4253167931327283e-23 -1.4253167919386517e-23 … -6.905164089099724e-25 -6.954084726841055e-46], [2674.600352346024 2674.354638747275 … 1187.3640070966603 199.99999999999997; 1337.300176173012 1337.1773193736376 … 593.6820035483302 99.99999999999999; … ; 0.245092185976172 0.24410001468633036 … 0.035729195951220614 2.9684795376459762e-61; 2.4626975931338172e-23 2.4626975931723358e-23 … 1.2679302459716713e-24 1.2769136671184193e-45]])
Results
plotcurr(nresult)
plot1d(nresult,ncelldata, nvshow)
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