10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-06 22:23:42 +01:00

Improved F12 Notebook

This commit is contained in:
Anthony Scemama 2019-12-05 22:45:30 +01:00
parent e3a0b4a6c0
commit 2e6ccb1770

View File

@ -156,7 +156,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"let hf = HartreeFock.make ~guess:`Hcore simulation ;;\n", "let hf = HartreeFock.make ~guess:`Hcore ~max_scf:1 simulation ;;\n",
"\n", "\n",
"let mo_basis = MOBasis.of_hartree_fock hf" "let mo_basis = MOBasis.of_hartree_fock hf"
] ]
@ -865,22 +865,20 @@
"$i,j$ : orbital indices of MOs occupied in $|I\\rangle$.\n", "$i,j$ : orbital indices of MOs occupied in $|I\\rangle$.\n",
"\n", "\n",
"\\begin{align}\n", "\\begin{align}\n",
"\\sum_{a} \\left( \n", "\\sum_{a} \\sum_{i}\n",
" \\sum_{i} \\sum_{j}\n", " \\left( h_{ia} +\n",
" \\left(h_{ia} + \\langle i j || a j \\rangle \\right) \n", " \\sum_{j} \\langle i j || a j \\rangle +\n",
" \\left(f_{ai} + \\left[ a j || i j \\right] \\right) + \n", " \\sum_{\\bar{j}} \\langle i \\bar{j} | a \\bar{j} \\rangle \\right) \n",
" \\sum_{i} \\sum_{\\bar{j}}\n", " \\left( f_{ai} +\n",
" \\left(h_{ia} + \\langle i \\bar{j} | a \\bar{j} \\rangle \\right) \n", " \\sum_{j} \\left[ a j || i j \\right] + \n",
" \\left(f_{ai} + \\left[ a \\bar{j} | i \\bar{j} \\right] \\right) \n", " \\sum_{\\bar{j}} \\left[ a \\bar{j} | i \\bar{j} \\right] \\right) + \\\\\n",
" \\right) + \\\\\n", "\\sum_{\\bar{a}} \\sum_{\\bar{i}}\n",
"\\sum_{\\bar{a}} \\left(\n", " \\left( h_{ia} +\n",
" \\sum_{\\bar{i}} \\sum_{\\bar{j}}\n", " \\sum_{j} \\langle \\bar{i} j | \\bar{a} j \\rangle +\n",
" \\left(h_{\\bar{i}\\bar{a}} + \\langle \\bar{i} \\bar{j} || \\bar{a} \\bar{j} \\rangle \\right) \n", " \\sum_{\\bar{j}} \\langle \\bar{i} \\bar{j} || \\bar{a} \\bar{j} \\rangle \\right) \n",
" \\left(f_{\\bar{a}\\bar{i}} + \\left[ \\bar{a} \\bar{j} || \\bar{i} \\bar{j} \\right] \\right) + \n", " \\left( f_{ai} +\n",
" \\sum_{\\bar{i}} \\sum_{j}\n", " \\sum_{j} \\left[ \\bar{a} j | \\bar{i} j \\right] + \n",
" \\left(h_{\\bar{i}\\bar{a}} + \\langle \\bar{i} j | \\bar{a} j \\rangle \\right)\n", " \\sum_{\\bar{j}} \\left[ \\bar{a} \\bar{j} || \\bar{i} \\bar{j} \\right] \\right) \n",
" \\left(f_{\\bar{a}\\bar{i}} + \\left[ \\bar{a} j | \\bar{i} j \\right] \\right) \n",
" \\right) \n",
"\\end{align}" "\\end{align}"
] ]
}, },
@ -893,29 +891,28 @@
"let integral_value ki kj = \n", "let integral_value ki kj = \n",
" (* Alpha-Beta *)\n", " (* Alpha-Beta *)\n",
" let s, s' = Spin.(Alfa, Beta) in \n", " let s, s' = Spin.(Alfa, Beta) in \n",
" List.fold_left (fun accu j -> accu +. \n", " let mos_a, mos_b = mos_a ki, mos_b ki in\n",
" List.fold_left (fun accu a -> accu +.\n",
" List.fold_left (fun accu i -> accu +. \n", " List.fold_left (fun accu i -> accu +. \n",
" List.fold_left (fun accu a ->\n", " (h_one i a s +.\n",
" accu +.( (h_one i a s +. h_two i j a j s s') *. \n", " List.fold_left (fun accu j -> accu +. h_two i j a j s s ) 0. mos_a +. \n",
" (f_one a i s +. f_two a j i j s s') )\n", " List.fold_left (fun accu j -> accu +. h_two i j a j s s') 0. mos_b ) *. \n",
" +.( (h_one j a s' +. h_two i j i a s s') *. \n", " (f_one a i s +.\n",
" (f_one a j s' +. f_two i a i j s s') )\n", " List.fold_left (fun accu j -> accu +. f_two a j i j s s ) 0. mos_a +.\n",
" List.fold_left (fun accu j -> accu +. f_two a j i j s s') 0. mos_b )\n",
" ) 0. mos_a\n",
" ) 0. mos_cabs\n", " ) 0. mos_cabs\n",
" ) 0. (mos_a ki)\n",
" ) 0. (mos_b ki)\n",
" +.\n", " +.\n",
" (* Alpha-Alpha / Beta-Beta *)\n", " List.fold_left (fun accu a -> accu +.\n",
" List.fold_left (fun accu (mos,s) -> \n",
" let s' = s in accu +. \n",
" List.fold_left (fun accu j -> accu +. \n",
" List.fold_left (fun accu i -> accu +. \n", " List.fold_left (fun accu i -> accu +. \n",
" List.fold_left (fun accu a -> \n", " (h_one i a s +.\n",
" accu +.( (h_one i a s +. h_two i j a j s s') *. \n", " List.fold_left (fun accu j -> accu +. h_two i j a j s' s') 0. mos_b +. \n",
" (f_one a i s +. f_two a j i j s s') )\n", " List.fold_left (fun accu j -> accu +. h_two i j a j s' s ) 0. mos_a ) *. \n",
" (f_one a i s +.\n",
" List.fold_left (fun accu j -> accu +. f_two a j i j s' s ) 0. mos_a +.\n",
" List.fold_left (fun accu j -> accu +. f_two a j i j s' s') 0. mos_b )\n",
" ) 0. mos_b\n",
" ) 0. mos_cabs\n", " ) 0. mos_cabs\n",
" ) 0. mos\n",
" ) 0. mos\n",
" ) 0. [ (mos_a ki,Spin.Alfa) ; (mos_b ki,Spin.Beta)]\n",
" \n", " \n",
"let _ =\n", "let _ =\n",
" check 0 integral_value 0 1 1 1\n", " check 0 integral_value 0 1 1 1\n",
@ -1110,7 +1107,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# 4. *1 1 11*" "# 4. 1 1 11"
] ]
}, },
{ {
@ -1131,12 +1128,11 @@
"$j$ : orbital indices of MOs occupied both in $|I\\rangle$ and $|J\\rangle$.\n", "$j$ : orbital indices of MOs occupied both in $|I\\rangle$ and $|J\\rangle$.\n",
"\n", "\n",
"\\begin{align}\n", "\\begin{align}\n",
"\\sum_{a} \\sum_{j}\n", " \\sum_{a} \n",
" \\left( h_{ia} + \\langle i j || a j \\rangle \\right)\n", " \\left( h_{ia} +\\sum_{j} \\langle i j || a j \\rangle +\n",
" \\left( f_{ak} + \\left[ a j || k j \\right] \\right) + \n", " \\sum_{\\bar{j}} \\langle i \\bar{j} | a \\bar{j} \\rangle \\right)\n",
"\\sum_{\\bar{j}}\n", " \\left( f_{ak} +\\sum_{j} \\left[ a j || k j \\right] + \n",
" \\left( h_{ia} + \\langle i \\bar{j} | a \\bar{j} \\rangle \\right) \n", " \\sum_{\\bar{j}} \\left[ a \\bar{j} | k \\bar{j} \\right]\\right) \n",
" \\left( f_{ak} + \\left[ a \\bar{j} | k \\bar{j} \\right] \\right)\n",
"\\end{align}" "\\end{align}"
] ]
}, },
@ -1154,31 +1150,27 @@
" | _ -> assert false\n", " | _ -> assert false\n",
" in\n", " in\n",
"\n", "\n",
" let mos, mos' =\n", " let mos_i, mos_i' =\n",
" match s with\n", " match s with\n",
" | Spin.Alfa -> mos_a ki, mos_b ki\n", " | Spin.Alfa -> mos_a ki, mos_b ki\n",
" | Spin.Beta -> mos_b ki, mos_a ki\n", " | Spin.Beta -> mos_b ki, mos_a ki\n",
" in\n", " in\n",
" let mos_j, mos_j' =\n",
" match s with\n",
" | Spin.Alfa -> mos_a kj, mos_b kj\n",
" | Spin.Beta -> mos_b kj, mos_a kj\n",
" in\n",
"\n", "\n",
" let result = \n", " let result = \n",
" (* Alpha-Beta *)\n",
" List.fold_left (fun accu j ->\n",
" let s' = Spin.other s in\n", " let s' = Spin.other s in\n",
" accu +. List.fold_left (fun accu a ->\n", " List.fold_left (fun accu a -> accu +.\n",
" accu +. (h_one i a s +. h_two i j a j s s')\n", " (h_one i a s +. \n",
" *. (f_one a k s +. f_two a j k j s s')\n", " (List.fold_left (fun accu j -> accu +. h_two i j a j s s ) 0. mos_i ) +.\n",
" (List.fold_left (fun accu j -> accu +. h_two i j a j s s') 0. mos_i') ) *.\n",
" (f_one a k s +. \n",
" (List.fold_left (fun accu j -> accu +. f_two a j k j s s ) 0. mos_j ) +.\n",
" (List.fold_left (fun accu j -> accu +. f_two a j k j s s') 0. mos_j') ) \n",
" ) 0. mos_cabs\n", " ) 0. mos_cabs\n",
" ) 0. mos'\n",
" +.\n",
" (* Alpha-Alpha / Beta-Beta *)\n",
" List.fold_left (fun accu j ->\n",
" if j = i then accu else\n",
" let s' = s in\n",
" accu +. List.fold_left (fun accu a ->\n",
" accu +. (h_one i a s +. h_two i j a j s s')\n",
" *. (f_one a k s +. f_two a j k j s s')\n",
" ) 0. mos_cabs\n",
" ) 0. mos\n",
" in\n", " in\n",
" match phase with\n", " match phase with\n",
" | Phase.Pos -> result\n", " | Phase.Pos -> result\n",