Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Tracé du graphique quantités de matière en fonction de l'avancement
- version 02 : on n'utilise qu'une seule fonction pour calculer les quantités de matière
- @author: Julien Bernon, Lycée Louis Feuillade
- """
- from matplotlib import pyplot as plt #On importe d'abord ce qui permet de tracer des graphiques
- def f(x,k,n):
- return n-k*x
- def av_max(a,na,b,nb):
- xmax1=na/a
- xmax2=nb/b
- xmax=min(xmax1,xmax2)
- return xmax
- def generation(a,na,b,nb,c,nc,ini,fin,nb_pts):
- liste_x,liste_ya,liste_yb,liste_yc=[],[],[],[]
- for i in range(nb_pts):
- x=ini+i*(fin-ini)/nb_pts
- liste_x.append(x)
- #Pour calculer les quantités de matière, on n'utilise plus que la fonction f
- liste_ya.append(f(x,a,na))
- liste_yb.append(f(x,b,nb))
- liste_yc.append(f(x,-c,nc)) #Comme C est un réactif on met un signe - devant son coefficient stoechiométrique pour modéliser son apparition plutôt que sa disparition
- plt.plot(liste_x,liste_ya)
- plt.plot(liste_x,liste_yb)
- plt.plot(liste_x,liste_yc)
- plt.show()
- return True
- a,b,c,na,nb,nc=1,2,3,0.05,0.03,0.01
- xmax=av_max(a,na,b,nb)
- generation(a,na,b,nb,c,nc,0,xmax,100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement