2025-02-02 22:59:33 +01:00
|
|
|
#!/usr/bin env python3
|
2025-02-15 16:01:05 +01:00
|
|
|
from formulary import *
|
2025-02-02 22:59:33 +01:00
|
|
|
from scipy.constants import gas_constant, Avogadro, elementary_charge
|
|
|
|
|
|
|
|
Faraday = Avogadro * elementary_charge
|
|
|
|
|
|
|
|
@np.vectorize
|
2025-02-15 16:01:05 +01:00
|
|
|
def fbutler_volmer_anode(ac, z, eta, T):
|
2025-02-02 22:59:33 +01:00
|
|
|
return np.exp((1-ac)*z*Faraday*eta/(gas_constant*T))
|
|
|
|
|
|
|
|
@np.vectorize
|
2025-02-15 16:01:05 +01:00
|
|
|
def fbutler_volmer_cathode(ac, z, eta, T):
|
2025-02-02 22:59:33 +01:00
|
|
|
return -np.exp(-ac*z*Faraday*eta/(gas_constant*T))
|
|
|
|
|
|
|
|
def fbutler_volmer(ac, z, eta, T):
|
2025-02-15 16:01:05 +01:00
|
|
|
return fbutler_volmer_anode(ac, z, eta, T) + fbutler_volmer_cathode(ac, z, eta, T)
|
2025-02-02 22:59:33 +01:00
|
|
|
|
|
|
|
def butler_volmer():
|
|
|
|
fig, ax = plt.subplots(figsize=size_half_third)
|
2025-02-15 16:01:05 +01:00
|
|
|
ax.set_xlabel("$\\eta$ [V]")
|
|
|
|
ax.set_ylabel("$j/j_0$")
|
2025-02-02 22:59:33 +01:00
|
|
|
etas = np.linspace(-0.1, 0.1, 400)
|
|
|
|
T = 300
|
|
|
|
z = 1.0
|
|
|
|
# other a
|
2025-02-15 16:01:05 +01:00
|
|
|
ac2, ac3 = 0.2, 0.8
|
2025-02-02 22:59:33 +01:00
|
|
|
i2 = fbutler_volmer(0.2, z, etas, T)
|
|
|
|
i3 = fbutler_volmer(0.8, z, etas, T)
|
2025-02-15 16:01:05 +01:00
|
|
|
ax.plot(etas, i2, color="blue", linestyle="dashed", label=f"$\\alpha_\\text{{C}}={ac2}$")
|
|
|
|
ax.plot(etas, i3, color="green", linestyle="dashed", label=f"$\\alpha_\\text{{C}}={ac3}$")
|
2025-02-02 22:59:33 +01:00
|
|
|
# 0.5
|
|
|
|
ac = 0.5
|
2025-02-15 16:01:05 +01:00
|
|
|
irel_anode = fbutler_volmer_anode(ac, z, etas, T)
|
|
|
|
irel_cathode = fbutler_volmer_cathode(ac, z, etas, T)
|
|
|
|
ax.plot(etas, irel_anode, color="gray")
|
|
|
|
ax.plot(etas, irel_cathode, color="gray")
|
|
|
|
ax.plot(etas, irel_cathode + irel_anode, color="black", label=f"$\\alpha_\\text{{C}}=0.5$")
|
2025-02-02 22:59:33 +01:00
|
|
|
ax.grid()
|
|
|
|
ax.legend()
|
|
|
|
ylim = 6
|
|
|
|
ax.set_ylim(-ylim, ylim)
|
|
|
|
return fig
|
|
|
|
|
2025-02-15 16:01:05 +01:00
|
|
|
@np.vectorize
|
|
|
|
def ftafel_anode(ac, z, eta, T):
|
|
|
|
return 10**((1-ac)*z*Faraday*eta/(gas_constant*T*np.log(10)))
|
|
|
|
|
|
|
|
@np.vectorize
|
|
|
|
def ftafel_cathode(ac, z, eta, T):
|
|
|
|
return -10**(-ac*z*Faraday*eta/(gas_constant*T*np.log(10)))
|
|
|
|
|
|
|
|
def tafel():
|
|
|
|
i0 = 1
|
|
|
|
ac = 0.2
|
|
|
|
z = 1
|
|
|
|
T = 300
|
|
|
|
eta_max = 0.2
|
|
|
|
etas = np.linspace(-eta_max, eta_max, 400)
|
|
|
|
i = np.abs(fbutler_volmer(ac, z, etas ,T))
|
|
|
|
iright = i0 * np.abs(ftafel_cathode(ac, z, etas, T))
|
|
|
|
ileft = i0 * ftafel_anode(ac, z, etas, T)
|
|
|
|
|
|
|
|
fig, ax = plt.subplots(figsize=size_half_third)
|
|
|
|
ax.set_xlabel("$\\eta$ [V]")
|
|
|
|
ax.set_ylabel("$\\log_{10}\\left(\\frac{|j|}{j_0}\\right)$")
|
|
|
|
# ax.set_ylabel("$\\log_{10}\\left(|j|/j_0\\right)$")
|
|
|
|
ax.set_yscale("log")
|
|
|
|
# ax.plot(etas, linear, label="Tafel slope")
|
|
|
|
ax.plot(etas[etas >= 0], ileft[etas >= 0], linestyle="dashed", color="gray", label="Tafel Approximation")
|
|
|
|
ax.plot(etas[etas <= 0], iright[etas <= 0], linestyle="dashed", color="gray")
|
|
|
|
ax.plot(etas, i, label=f"Butler-Volmer $\\alpha_\\text{{C}}={ac:.1f}$")
|
|
|
|
ax.legend()
|
|
|
|
ax.grid()
|
|
|
|
return fig
|
|
|
|
|
2025-02-02 22:59:33 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
export(butler_volmer(), "ch_butler_volmer")
|
2025-02-15 16:01:05 +01:00
|
|
|
export(tafel(), "ch_tafel")
|
2025-02-02 22:59:33 +01:00
|
|
|
|
|
|
|
|