From 46fbf660b35e1ddde9591d3b2feeb60f9da31714 Mon Sep 17 00:00:00 2001 From: yann Date: Tue, 12 May 2020 10:55:33 +0200 Subject: [PATCH] Work : nettoyage --- Work.ipynb | 378 +---------------------------------------------------- 1 file changed, 7 insertions(+), 371 deletions(-) diff --git a/Work.ipynb b/Work.ipynb index ac6b513..23772b9 100644 --- a/Work.ipynb +++ b/Work.ipynb @@ -1065,57 +1065,6 @@ "$< \\phi_i | r | \\phi_i > = < \\phi_i | x | \\phi_i > + < \\phi_i | y | \\phi_i > + < \\phi_i | z | \\phi_i >$\n" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(*\n", - "(* Fonction calcul alpha Boys *)\n", - "\n", - "let n_ao = Mat.dim1 m_C ;;\n", - "let n_mo = Mat.dim2 m_C ;;\n", - "\n", - "let multipoles = \n", - " AOBasis.multipole ao_basis;;\n", - "\n", - "let m_alpha_boys multipoles = \n", - "\n", - " let phi_x_phi =\n", - " Multipole.matrix_x multipoles \n", - " |> MOBasis.mo_matrix_of_ao_matrix ~mo_coef \n", - " in \n", - " let phi_y_phi =\n", - " Multipole.matrix_y multipoles \n", - " |> MOBasis.mo_matrix_of_ao_matrix ~mo_coef \n", - " in\n", - " let phi_z_phi =\n", - " Multipole.matrix_y multipoles \n", - " |> MOBasis.mo_matrix_of_ao_matrix ~mo_coef\n", - " in \n", - "\n", - " let m_b12= \n", - " let b12 g = Mat.init_cols n_ao n_ao ( fun i j ->\n", - " (g.{i,i} -. g.{j,j}) *. g.{i,j})\n", - "\n", - " in \n", - " Mat.add (b12 phi_x_phi) ( Mat.add (b12 phi_y_phi) (b12 phi_z_phi))\n", - " in \n", - " let m_a12 =\n", - " let a12 g = Mat.init_cols n_ao n_ao ( fun i j -> \n", - " g.{i,j} *. g.{i,j} -. 0.25 *. (g.{i,i} -. g.{j,j} *. g.{i,i} -. g.{j,j}))\n", - " in\n", - " Mat.add (a12 phi_x_phi) ( Mat.add (a12 phi_y_phi) (a12 phi_z_phi))\n", - " in\n", - " Mat.init_cols n_ao n_ao ( fun i j ->\n", - " 0.25 *. asin(m_b12.{i,j} /. sqrt((m_a12.{i,j}**2.) +. (m_b12.{i,j}**2.) )));;\n", - "\n", - "\n", - "m_alpha_boys multipoles;;\n", - "*)" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -1706,12 +1655,7 @@ "\n", "(****************************)\n", "\n", - "f_alpha_boys m_C;;\n", - "\n", - "let phi_x_phi =\n", - " Multipole.matrix_x multipoles \n", - " |> MOBasis.mo_matrix_of_ao_matrix ~mo_coef ;;\n", - " " + "f_alpha_boys m_C;;" ] }, { @@ -1757,78 +1701,6 @@ "d_boys m_C;;" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(* Test méthode de calcul de alpha *)\n", - "let calcul_alpha_2 methode = \n", - "\n", - "let alpha_boys = f_alpha_boys m_C\n", - "in\n", - "let alpha_er = f_alpha m_C\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;;\n", - "\n", - "(*************************)\n", - "\n", - "(*\n", - "calcul_alpha_2 \"ER\" ;;\n", - "calcul_alpha_2 \"Boys\" ;;\n", - "let methode = \"ER\";;\n", - "let m_alpha = calcul_alpha_2 methode;;\n", - "*)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(* Test méthode de calcul du critère de convergence *)\n", - "let calcul_cc methode = \n", - "\n", - "let b_boys = d_boys m_C\n", - "in\n", - "let d_er = s_D m_C\n", - "in\n", - "let cc methode =\n", - " match methode with \n", - " | \"Boys\"\n", - " | \"boys\" -> b_boys\n", - " | \"ER\"\n", - " | \"er\" -> d_er\n", - " | _ -> invalid_arg \"Unknown method, please enter Boys or ER\"\n", - "\n", - "in \n", - "cc methode;;\n", - "\n", - "(*************************)\n", - "\n", - "(*\n", - "calcul_cc \"boys\";;\n", - "*)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -2117,6 +1989,7 @@ " (* Fonction de calcul de la nouvelle matrice de coef après rotation d'un angle alpha *)\n", " let new_m_C m_C methode =\n", " \n", + " (* Fonction de pattern matching en fonction de la méthode *)\n", " let alphad = m_alpha_d methode m_C \n", " in\n", " \n", @@ -2204,15 +2077,6 @@ "final_m_C m_C \"ER\" 1;;" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "final_m_C m_C \"Boys\" 10;;" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -2226,6 +2090,8 @@ "metadata": {}, "outputs": [], "source": [ + "(* Ancienne boucle\n", + "\n", "(* Localisation de Edminstion *)\n", "let n_rec_alpha = 10;;\n", "(* Calcul de la nouvelle matrice des coefficient après n rotation d'orbitales *)\n", @@ -2312,7 +2178,9 @@ "(*Util.debug_matrix \"new_alpha_m\" (f_alpha m_C);*)\n", "(*Util.debug_matrix \"m_new_m_C\" m_new_m_C;*)\n", "\n", - "final_m_C m_new_m_C (n-1);;" + "final_m_C m_new_m_C (n-1);;\n", + "\n", + "*)" ] }, { @@ -2325,13 +2193,6 @@ "final_m_C m_C 10;;" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -2826,83 +2687,6 @@ "*)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### test" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(*Test critère de convergence -> norme de alpha *)\n", - "\n", - "let norme m_alpha =\n", - " let vec_alpha = \n", - " Mat.as_vec m_alpha\n", - " in\n", - " let vec2_alpha = \n", - " Vec.sqr vec_alpha\n", - " in\n", - " let norme2 = Vec.sum vec2_alpha\n", - "in\n", - "sqrt(norme2);;\n", - "\n", - "\n", - "norme m_alpha;;" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(* Test choix méthode *)\n", - "type localisation = \n", - " | Boys\n", - " | Edminston \n", - "\n", - "let toto localisation = \n", - " match localisation with \n", - " | Boys -> 1. +. 1.\n", - " | Edminston -> 1. +. 2.;;\n", - "\n", - "\n", - "toto Boys ;;\n", - "\n", - "\n", - "let titi lo=\n", - "if lo=\"Boys\" then 1. else 2.;;\n", - "titi \"Boys\";;\n", - "\n", - "\n", - "let alpha localisation toto = \n", - "if localisation = 1 \n", - "then \n", - "\n", - "else \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Boys" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "metadata": {}, @@ -2910,147 +2694,6 @@ "# OLD ->" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "let ee_ints = AOBasis.ee_ints ao_basis;;\n", - "let m_C = MOBasis.mo_coef mo_basis;;\n", - "let n_ao = Mat.dim1 m_C ;;\n", - "\n", - "let sum a = \n", - " Array.fold_left (fun accu x -> accu +. x) 0. a\n", - ";;\n", - "\n", - "let i = 1;;\n", - "let j = 2;;\n", - " (*Calcul des intégrales*) \n", - "let integral_general g i j =\n", - "Array.map (fun a ->\n", - " let v = \n", - " Array.map (fun b ->\n", - " let u = \n", - " Array.map (fun e ->\n", - " let t = Array.map (fun f ->\n", - " (g a b e f i j) *. ERI.get_phys ee_ints a e b f\n", - " ) (Util.array_range 1 n_ao)\n", - " in sum t\n", - " ) (Util.array_range 1 n_ao)\n", - " in sum u\n", - " ) (Util.array_range 1 n_ao)\n", - " in sum v\n", - ") (Util.array_range 1 n_ao)\n", - "|> sum\n", - "\n", - "\n", - "let func_a12 = \n", - " integral_general (fun a b e f i j ->\n", - " m_C.{a,i} *. m_C.{b,i} *. m_C.{e,i} *. m_C.{f,j} \n", - " -. 0.25 *. ( m_C.{e,i} *. m_C.{f,i} -. m_C.{e,j} *. m_C.{f,j} ) \n", - " *. ( m_C.{a,i} *. m_C.{b,i} -. m_C.{a,j} *. m_C.{b,j} ) \n", - " )\n", - "\n", - "\n", - "let func_b12 = \n", - " integral_general (fun a b e f i j ->\n", - " ( m_C.{a,i} *. m_C.{b,i} -. m_C.{a,j} *. m_C.{b,j} ) *. m_C.{e,i} *. m_C.{f,j}\n", - " )\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "let i =1;;\n", - "let j = 2;;\n", - "let b12 = \n", - " integral_general (fun a b e f i j ->\n", - " ( m_C.{a,i} *. m_C.{b,i} -. m_C.{a,j} *. m_C.{b,j} ) *. m_C.{e,i} *. m_C.{f,j}\n", - " )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(*Calcul de alpha*)\n", - "let alpha = asin(func_b12 /. sqrt((func_a12)**2. +. (func_b12)**2.));;" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "(*Matrice b12*)\n", - "\n", - "let m_b12 = Mat.init_cols 10 10 (fun i j -> \n", - "integral_general (fun a b e f i j ->\n", - " ( m_C.{a,i} *. m_C.{b,i} -. m_C.{a,j} *. m_C.{b,j} ) *. m_C.{e,i} *. m_C.{f,j}\n", - " ) i j\n", - " )\n", - "\n", - "let vec_test = Mat.as_vec m_b12\n", - "|> iamax;;\n", - "\n", - " \n", - "let test = Mat.max2 m_b12;;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "$\\langle \\phi_i \\phi_j | \\phi_i \\phi_j \\rangle =\n", - "\\sum_a c_{ai} \\langle \\chi_a \\phi_j | \\phi_i \\phi_j \\rangle =\n", - "\\sum_a \\sum_b c_{ai} c_{bj} \\langle \\chi_a \\chi_b | \\phi_i \\phi_j \\rangle =$\n", - "$\\left(\\sum_a c_{ai} \\sum_b \\left(c_{bj} \\sum_e \\left(c_{ei} \\sum_f \\left(c_{fj} \\langle \\chi_a \\chi_b | \\chi_e \\chi_f \\rangle \\right)\\right)\\right)\\right) =$\n", - "$\\sum_a \\sum_b \\sum_e \\sum_f \\left( c_{ai} c_{bj} c_{ei} c_{fj} \\langle \\chi_a \\chi_b | \\chi_e \\chi_f \\rangle \\right) $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "$\\phi_i ^2 = \\left( \\sum_a c_{ai} \\chi_a \\right)^2$\n", - "$= \\sum_a c_{ai} \\sum_b c_{bi} \\chi_a \\chi_b$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "$\\phi_i ^2 - \\phi_j ^2 = \\left( \\sum_a c_{ai} \\chi_a \\right)^2 - \\left( \\sum_a c_{aj} \\chi_a \\right)^2$\n", - "$= \\sum_a c_{ai} \\sum_b c_{bi} \\chi_a \\chi_b - \\sum_a c_{aj} \\sum_b c_{bj} \\chi_a \\chi_b$" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "$[\\phi_i ^2 - \\phi_j ^2 | \\phi_i \\phi_j ] = [\\left( \\sum_a c_{ai} \\chi_i \\right)^2 - \\left( \\sum_a c_{aj} \\chi_j \\right)^2| \\phi_i \\phi_j ] $\n", - "$= \\sum_a c_{ai} \\sum_b c_{bi} [\\chi_a \\chi_b| \\phi_i \\phi_j ] - \\sum_a c_{aj} \\sum_b c_{bj} [ \\chi_a \\chi_b| \\phi_i \\phi_j ] $\n", - "$= \\left(\\sum_a c_{ai} \\sum_b c_{bi} - \\sum_a c_{aj} \\sum_b c_{bj} \\right) [ \\chi_a \\chi_b| \\phi_i \\phi_j ] $\n", - "$= \\left(\\sum_a c_{ai} \\sum_b c_{bi} - \\sum_a c_{aj} \\sum_b c_{bj} \\right) \\sum_e \\sum_f c_{ei} c_{fj} [ \\chi_a \\chi_b| \\chi_e \\chi_f ] $" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "$\\langle \\phi_i | x | \\phi_j \\rangle$\n", - "$=\\langle \\sum_a c_{ia} \\chi_a | x | \\sum_b c_{jb} \\chi_b\\rangle$\n", - "$=\\sum_a \\sum_b c_{jb} c_{ia} \\langle \\chi_a | x | \\chi_b\\rangle$" - ] - }, { "cell_type": "code", "execution_count": null, @@ -3060,13 +2703,6 @@ "let ints = MOBasis.ee_ints mo_basis in\n", "ERI.get_phys ints 1 2 1 2;;" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {