fromionimport*fromkandinskyimport*frommathimportlog,expdefordre1(k):"Ordre 1 A->B: [A]=A0 exp(-kt), t1/2=ln2/k."print("ORDRE1 [A]=A0 exp(-kt)")print("t1/2=ln2/k=",round(log(2)/k,6))print("t90%=ln10/k=",round(log(10)/k,6))defk_de_K(ks,K):"Equilibre A<=>B: donne k1,k-1 depuis ks=k1+k-1 et K=k1/k-1."km=ks/(1.0+K);k1=K*kmprint("k1=",k1)print("k-1=",km)print("K=",round(k1/km,4),"somme=",k1+km)returnk1,kmdefK_eq(k1,km1):print("K=k1/k-1=",k1/km1)returnk1/km1defregression(ts,ys):n=len(ts);sx=sum(ts);sy=sum(ys)sxx=sum(t*tfortints);sxy=sum(ts[i]*ys[i]foriinrange(n))a=(n*sxy-sx*sy)/(n*sxx-sx*sx);b=(sy-a*sx)/nmy=sy/nst=sum((y-my)**2foryinys)se=sum((ys[i]-(a*ts[i]+b))**2foriinrange(n))r2=1-se/stifst>0else1.0print("pente=",a,"ord=",b,"R2=",round(r2,5))returna,b,r2defrelaxation(ts,vals,vinf,K=None):"Regresse ln(G-Ginf) vs t: pente=-(k1+k-1). G lineaire en c (alpha,absorbance...)."ys=[]forginvals:d=g-vinfifd<=0:print("!! G-Ginf<=0, retire ce point");returnys.append(log(d))a,b,r2=regression(ts,ys)ks=-aprint("k1+k-1=",ks)print("G0=",vinf+exp(b))ifKisnotNone:k_de_K(ks,K)returnksdefparalleles(k1,k2):"2 voies // ordre 1: keff=k1+k2, selectivite=k1/k2."print("keff=k1+k2=",k1+k2)print("select k1/k2=",round(k1/k2,4))print("t90%=",round(log(10)/(k1+k2),6))print("t1/2=",round(log(2)/(k1+k2),6))defpseudo(k,exc):print("k_app=k*[exc]=",k*exc)defpick(titre,opts):sel=0whileTrue:fill_rect(0,0,320,222,color(255,255,255))draw_string(titre,2,2,color(255,255,255),color(60,90,200))foriinrange(len(opts)):y=26+i*20ifi==sel:fill_rect(0,y,320,18,color(60,120,240))draw_string(opts[i],6,y,color(255,255,255),color(60,120,240))else:draw_string(opts[i],6,y)k=-1whilek==-1:ifkeydown(KEY_UP):k=0elifkeydown(KEY_DOWN):k=1elifkeydown(KEY_BACK):k=2elifkeydown(KEY_OK)orkeydown(KEY_EXE):k=3whilekeydown(KEY_UP)orkeydown(KEY_DOWN)orkeydown(KEY_BACK)orkeydown(KEY_OK)orkeydown(KEY_EXE):passifk==0:sel=(sel-1)%len(opts)elifk==1:sel=(sel+1)%len(opts)elifk==2:return-1else:returnseldef_e(m):returnfloat(input(m))defmenu():whileTrue:c=pick("CINETIQUE",["Ordre 1","Equilibre k1,k-1","Relaxation (donnees)","Paralleles","K (k1,k-1)","Pseudo-ordre","Console"])ifc==-1orc==6:print("ex: k_de_K(2.6e-3,1.76)")returnifc==0:print("Q: ordre 1 simple, demi-reaction")ordre1(_e("k? "))elifc==1:print("Q: trouver k1 et k-1 (on a K et la somme)")k_de_K(_e("k1+k-1? "),_e("K? "))elifc==2:print("Q: k depuis un suivi (polarimetrie/absorbance)")print("G lineaire en c (alpha, absorbance, conductivite)")p=int(_e("Nb points? "));ts=[];vs=[]foriinrange(p):ts.append(_e("t"+str(i+1)+"? "));vs.append(_e(" G? "))vinf=_e("Ginf? ");K=_e("K (0 si inconnu)? ")relaxation(ts,vs,vinf,KifKelseNone)elifc==3:print("Q: 2 voies paralleles, selectivite")paralleles(_e("k1? "),_e("k2? "))elifc==4:print("Q: constante d'equilibre K")K_eq(_e("k1? "),_e("k-1? "))elifc==5:print("Q: reactif en exces, ordre apparent")pseudo(_e("k? "),_e("[exces]? "))input("--OK--")menu()
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.