import numpy as np
import matplotlib.pyplot as plt

# i0 = 1
i0 = 0.1
alpha = 0.5
n = 1
F = 96500
R = 8.314
T = 298
f = F/(R*T)
Es = 0.7
ial = 1
icl = -1

E = np.linspace(-3,3,10000)
#Pour les courants anodique/cathodique/totaux en transfert de charge limitant
ia = i0*np.exp(alpha*n*f*(E-Es))
ic = -i0*np.exp(-(1-alpha)*n*f*(E-Es))
i = ia + ic
#Pour la diffusion limitante
id = (ial*np.exp(n*f*(E-Es)) + icl)/(1+np.exp(n*f*(E-Es)))
#Pour un contrôle mixte
it = (i*id)/(i+id)

plt.grid()
plt.title("Courbe i = f(E) pour le couple du fer")
plt.xlabel("Potentiel E (V)")
plt.ylabel("Intensité du courant i (A)")
plt.xlim(-0.5,1.5)
plt.ylim(-2,2)
#Pour les courants anodique/cathodique/totaux en transfert de charge limitant
plt.plot(E,ia,label="courant anodique",color="b")
plt.plot(E,ic,label="courant cathodique",color="r")
plt.plot(E,i,label="courant total",color="g")
#Pour la diffusion limitante
plt.plot(E,id,label="palier de diffusion")
#Pour un contrôle mixte
plt.plot(E,it,label="mixte")
plt.legend()
plt.show()
