fromionimport*fromkandinskyimport*frommathimportcos,pidefremplir(energies,ne,deg=None,ev=False):"Range/remplit les OM, donne HO/BV. energies=coeff b (grand=bas) ou eV si ev=True."ifdegisNone:deg=[1]*len(energies)orbs=[]foriinrange(len(energies)):for_inrange(deg[i]):orbs.append(energies[i])orbs.sort(reverse=(notev))n=len(orbs);occ=[0]*n;reste=neforiinrange(n):met=min(2,reste);occ[i]=met;reste-=metifreste<=0:breakho=-1;bv=-1foriinrange(n):ifocc[i]>0:ho=iforiinrange(n):ifocc[i]<2:bv=i;breakforiinrange(n):tag=""ifi==ho:tag+=" HO"ifi==bv:tag+=" BV"e=round(orbs[i],3)print((str(e)+"eV")ifevelse ("a+ "+str(e)+"b"),occ[i],"e",tag)lab=(lambdax:str(round(x,3))+"eV")ifevelse (lambdax:"a+"+str(round(x,3))+"b")print("HO",lab(orbs[ho]),"| BV",lab(orbs[bv]))returnorbs,occ,ho,bvdefecart(mho,mbv):"Ecart HO-BV en |beta| = |mHO-mBV|. Petit ecart = interaction forte."e=abs(mho-mbv)print("ecart HO-BV=",round(e,3),"|b|")returnedefcouple(hoA,bvA,hoB,bvB):"2 partenaires: le plus petit ecart HO-BV domine (donne le donneur)."e1=abs(hoA-bvB);e2=abs(hoB-bvA)print("HO(A)-BV(B)=",round(e1,3),"|b|")print("HO(B)-BV(A)=",round(e2,3),"|b|")ife1<e2:print("-> HO(A)-BV(B) domine (A donneur)")else:print("-> HO(B)-BV(A) domine (B donneur)")defregio(coeffs):"Controle orbitalaire: attaque sur le plus gros |coefficient|."b=0foriinrange(len(coeffs)):ifabs(coeffs[i])>abs(coeffs[b]):b=iforiinrange(len(coeffs)):print("at",i+1,"|c|=",round(abs(coeffs[i]),3),"<<"ifi==belse"")print("-> attaque at",b+1)defcharge_max(ch):"Controle de charge: nucleophile sur l'atome le plus positif."b=0foriinrange(len(ch)):ifch[i]>ch[b]:b=iforiinrange(len(ch)):print("at",i+1,"q=",round(ch[i],3),"<<"ifi==belse"")print("-> nucleophile sur at",b+1)defrecouvrement(s0,ang):"Recouvrement hors axe: S=S0*cos(angle). cos90=0 => interaction nulle."S=s0*cos(ang*pi/180.0)print("S=S0*cos(",ang,")=",round(S,4))ifabs(S)<1e-9:print("-> NUL, pas d'interaction")returnSdefpick(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("FRONTIERES",["Remplissage HO/BV","Ecart HO-BV","Choix couple","Regio orbitalaire","Regio charge","Recouvrement cos","Console"])ifc==-1orc==6:print("ex: remplir([1.414,0,-1.414],2)")returnifc==0:print("Q: HO/BV, remplir un diagramme d'OM")u=int(_e("1=coeff beta, 2=eV? "))k=int(_e("Nb niveaux? "));E=[];D=[]foriinrange(k):E.append(_e("E"+str(i+1)+"? "))D.append(int(_e(" degen(1 si simple)? ")))remplir(E,int(_e("Nb e-? ")),D,u==2)elifc==1:print("Q: force de l'interaction (ecart HO-BV)")ecart(_e("m HO? "),_e("m BV? "))elifc==2:print("Q: quel couple? demande normale/inverse (Diels-Alder)")couple(_e("HO A? "),_e("BV A? "),_e("HO B? "),_e("BV B? "))elifc==3:print("Q: regiochimie, controle orbitalaire (gros coeff)")k=int(_e("Nb atomes? "));L=[]foriinrange(k):L.append(_e("c"+str(i+1)+"? "))regio(L)elifc==4:print("Q: regiochimie, controle de charge (plus positif)")k=int(_e("Nb atomes? "));L=[]foriinrange(k):L.append(_e("q"+str(i+1)+"? "))charge_max(L)elifc==5:print("Q: recouvrement nul? (symetrie / cosinus)")recouvrement(_e("S0? "),_e("angle deg? "))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.