import numpy as np
import matplotlib.pyplot as plt

# i0 = 1
i0 = 0.1
alpha = 0.9
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_charge = i0*np.exp(alpha*n*f*(E-Es))
ic_charge = -i0*np.exp(-(1-alpha)*n*f*(E-Es))
i_charge = ia_charge + ic_charge
#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_charge*id)/(i_charge+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_charge,label="courant anodique - charge",color="b")
#plt.plot(E,ic_charge,label="courant cathodique - charge",color="r")
plt.plot(E,i_charge,label="courant total - charge",color="g")
#Pour la diffusion limitante
plt.plot(E,id,label="courant total - matière")
#Pour un contrôle mixte
plt.plot(E,it,label="courant total - mixte")
plt.legend()
plt.show()
