Work : boucle localisation avec cc (pas propre...)
This commit is contained in:
parent
189e25c72e
commit
91c04c99c6
134
Work.ipynb
134
Work.ipynb
@ -1293,37 +1293,6 @@
|
||||
"## Calculs : Localisation de Edminston"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(*\n",
|
||||
"(* Test méthode de calcul de alpha *)\n",
|
||||
"let calcul_alpha_2 methode = \n",
|
||||
"\n",
|
||||
"let alpha_boys = 1.\n",
|
||||
"in\n",
|
||||
"let alpha_er = 2.\n",
|
||||
"in\n",
|
||||
"let alpha methode =\n",
|
||||
" match methode with \n",
|
||||
" | \"Boys\"\n",
|
||||
" | \"boys\" -> alpha_boys\n",
|
||||
" | \"ER\"\n",
|
||||
" | \"er\" -> alpha_er\n",
|
||||
" | _ -> invalid_arg \"Unknown method, please enter Boys or ER\"\n",
|
||||
"\n",
|
||||
"in \n",
|
||||
"(alpha methode)**2.;;\n",
|
||||
"\n",
|
||||
"*)\n",
|
||||
"(*\n",
|
||||
"calcul_alpha_2 \"ER\";;\n",
|
||||
"*)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@ -1715,15 +1684,15 @@
|
||||
"\n",
|
||||
"let m_alpha_d methode m_C = \n",
|
||||
"\n",
|
||||
"let alpha_boys = f_alpha_boys m_C\n",
|
||||
"in\n",
|
||||
"let d_boys = d_boys m_C\n",
|
||||
"in\n",
|
||||
"let alpha_er = f_alpha m_C\n",
|
||||
"in\n",
|
||||
"let d_er = s_D m_C\n",
|
||||
"in\n",
|
||||
"let alpha methode =\n",
|
||||
" let alpha_boys = f_alpha_boys m_C\n",
|
||||
" in\n",
|
||||
" let d_boys = d_boys m_C\n",
|
||||
" in\n",
|
||||
" let alpha_er = f_alpha m_C\n",
|
||||
" in\n",
|
||||
" let d_er = s_D m_C\n",
|
||||
" in\n",
|
||||
" let alpha methode =\n",
|
||||
" match methode with \n",
|
||||
" | \"Boys\"\n",
|
||||
" | \"boys\" -> {m_alpha = alpha_boys; d = d_boys}\n",
|
||||
@ -1748,6 +1717,25 @@
|
||||
"*)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(* Test norme de alpha *)\n",
|
||||
"\n",
|
||||
"let norme m = \n",
|
||||
" let vec_m = Mat.as_vec m\n",
|
||||
" in\n",
|
||||
" let vec2 = Vec.sqr vec_m\n",
|
||||
"in sqrt(Vec.sum vec2);;\n",
|
||||
" \n",
|
||||
"(*\n",
|
||||
"norme_alpha m_alpha;;\n",
|
||||
"*)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@ -1914,7 +1902,7 @@
|
||||
"celle contenant i~ et j~ *)\n",
|
||||
" \n",
|
||||
"(* Matrice intérmédiare pour l'injection de ksi~ (i~ et j~) dans la matrice Phi *)\n",
|
||||
"let f_Psi_tilde m_Ksi_tilde indice_i indice_j = Mat.init_cols n_ao n_ao (fun i j -> \n",
|
||||
"let f_Psi_tilde m_Ksi_tilde indice_i indice_j = Mat.init_cols n_ao n_mo (fun i j -> \n",
|
||||
" if j=indice_i \n",
|
||||
" then m_Ksi_tilde.{i,1}\n",
|
||||
" else if j=indice_j then m_Ksi_tilde.{i,2}\n",
|
||||
@ -1922,7 +1910,7 @@
|
||||
";;\n",
|
||||
"\n",
|
||||
"(* Matrice intermédiaire pour supprimer ksi (i et j) dans la matrice Phi *) \n",
|
||||
"let f_Psi m_Ksi indice_i indice_j = Mat.init_cols n_ao n_ao (fun i j -> \n",
|
||||
"let f_Psi m_Ksi indice_i indice_j = Mat.init_cols n_ao n_mo (fun i j -> \n",
|
||||
" if j=indice_i \n",
|
||||
" then m_Ksi.{i,1}\n",
|
||||
" else if j=indice_j \n",
|
||||
@ -1974,11 +1962,11 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(* Localisation de Edminstion ou de Boys *)\n",
|
||||
"let n_rec_alpha = 10;;\n",
|
||||
"(* Calcul de la nouvelle matrice des coefficient après n rotation d'orbitales *)\n",
|
||||
"let rec final_m_C m_C methode epsilon n =\n",
|
||||
"\n",
|
||||
" Printf.printf \"%i\\n%!\" n;\n",
|
||||
"(* Calcul de la nouvelle matrice des coefficient après n rotation d'orbitales *)\n",
|
||||
"let rec final_m_C m_C methode epsilon n prev_norme_alpha prev_critere_D =\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%i\\n%!\" n;*)\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_C\" m_C;*)\n",
|
||||
"\n",
|
||||
@ -1996,15 +1984,22 @@
|
||||
" (* D critère à maximiser *)\n",
|
||||
" let critere_D = alphad.d \n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" Printf.printf \"%f\\n%!\" critere_D;\n",
|
||||
" \n",
|
||||
" (* Matrice des alphas *)\n",
|
||||
" let m_alpha = alphad.m_alpha\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" let norme_alpha = norme m_alpha\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (*Printf.printf \"%f\\n%!\" norme_alpha;*)\n",
|
||||
" \n",
|
||||
" (*Util.debug_matrix \"m_alpha\" m_alpha;*)\n",
|
||||
"\n",
|
||||
" (* alphaij contient le alpha max ainsi que ses indices i et j *)\n",
|
||||
" let n_rec_alpha = 10 (* Nombre ditération max pour réduire les valeurs de alpha *)\n",
|
||||
" in\n",
|
||||
" let alphaij = new_m_alpha m_alpha n_rec_alpha (* Fonction -> constante *)\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
@ -2018,13 +2013,13 @@
|
||||
" let indice_j = alphaij.indice_jj (* Fonction -> constante *)\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" Printf.printf \"%i %i\\n%!\" indice_i indice_j;\n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
"\n",
|
||||
" (* Matrice de rotaion *)\n",
|
||||
" let m_R = f_R alpha (* Fonction -> constante *)\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" Util.debug_matrix \"m_R\" m_R;\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
"\n",
|
||||
" (* Matrice qui va subir la rotation *)\n",
|
||||
" let m_Ksi = f_Ksi indice_i indice_j m_C (* Fonction -> constante *)\n",
|
||||
@ -2056,16 +2051,34 @@
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
" \n",
|
||||
" (* Matrice après rotation *)\n",
|
||||
" Mat.add m_Psi_tilde m_interm\n",
|
||||
" ( Mat.add m_Psi_tilde m_interm, norme_alpha, critere_D)\n",
|
||||
" in\n",
|
||||
" let m_new_m_C = new_m_C m_C methode (* Fonction -> constante *)\n",
|
||||
"\n",
|
||||
" let m_new_m_C , norme_alpha , critere_D = new_m_C m_C methode (* Fonction -> constante *)\n",
|
||||
" in\n",
|
||||
" let diff = prev_critere_D -. critere_D\n",
|
||||
" \n",
|
||||
" (*if epsilon <= 0.05\n",
|
||||
" then 0.1\n",
|
||||
" else if norme_alpha <= 0.0001 && epsilon >= 0.2\n",
|
||||
" then epsilon -. 0.2\n",
|
||||
" else if norme_alpha <= 0.001 && epsilon >= 0.1\n",
|
||||
" then epsilon -. 0.1\n",
|
||||
" else if norme_alpha <= 0.01 && epsilon >= 0.05\n",
|
||||
" then epsilon -. 0.05\n",
|
||||
" else epsilon *)\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
"in\n",
|
||||
"\n",
|
||||
"Printf.printf \"%f %f %f %f\\n%!\" epsilon prev_norme_alpha norme_alpha diff;\n",
|
||||
"(*Util.debug_matrix \"new_alpha_m\" (f_alpha m_C);*)\n",
|
||||
"Util.debug_matrix \"m_new_m_C\" m_new_m_C;\n",
|
||||
"(*Util.debug_matrix \"m_new_m_C\" m_new_m_C;*)\n",
|
||||
"\n",
|
||||
"final_m_C m_new_m_C methode epsilon (n-1);;"
|
||||
"if diff**2. < 0.000001**2.\n",
|
||||
" then m_new_m_C\n",
|
||||
" else\n",
|
||||
"\n",
|
||||
"final_m_C m_new_m_C methode epsilon (n-1) norme_alpha critere_D ;;"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -2075,10 +2088,17 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(* Calcul *)\n",
|
||||
"(* Fonction Matrice des coef Méthode(\"Boys\" ou \"ER\") Pas (=< 1.) *)\n",
|
||||
"final_m_C m_C \"ER\" 1. 20;;"
|
||||
"(* Fonction Matrice des coef Méthode(\"Boys\" ou \"ER\") Pas(=< 1.) Nombre d'itérations *)\n",
|
||||
"final_m_C m_C \"ER\" 1. 100 10. 0.;;"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
Loading…
Reference in New Issue
Block a user