# -*- coding: utf-8 -*-
"""
Created on Thu Nov  2 14:43:40 2023

@author: cathe
"""

# 1- importation des bibliothèques
import numpy as np
import matplotlib.pyplot as plt

# 2- Définition des paramètres du problème
Ea = 50.5*10**3 #J.mol-1
A = 1.68*10**7 #min-1
n0 = 1.00 #mol/L
V= 900*10**-3 #L
C0=n0/V
ksi0 = 0.00 #mol/L
T0 = 298 #K
R= 8.314 #J/K/mol
t0 = 0#min temps initial
tf2 = 250#min temps final
N = 20#nombre de pas
Dt = (tf2 - t0)/N #min : pas du temps


# 3- fonction k
def k(T) :
    return xxx # attention bien mettre les () et les *

# 3- d_ksi
xxx 
xxx
#3-euler : avec une boucle 
t_euler=[t0]
ksi_euler=[ksi0]
for i in range(N) :
    xxx
    xxx    
#3- ksi par intégration de l'équa diff
t_abs=np.linspace(t0,tf2,N+1)
def ksi_int(T,t) :
    return xxx

# 4- tracé des courbes
plt.plot(t_abs,ksi_int(T0,t_abs),'-*g',label="solution exacte")
plt.plot(t_euler,ksi_euler,'-b',label='euler N={:.0f}'.format(N))
plt.grid() #parce que ça fait joli
plt.legend()
plt.title("cinétique d'ordre 1 isotherme")
plt.xlabel('t (min)')
plt.ylabel('avancement volumique (mol/L)')

    