10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-22 04:13:33 +01:00

Working on f12 notebook

This commit is contained in:
Anthony Scemama 2019-12-05 16:16:00 +01:00
parent be8b2d8b2b
commit e3a0b4a6c0

View File

@ -284,6 +284,9 @@
"let mos_cabs = \n",
" Util.list_range (mo_num+1) aux_num\n",
" \n",
"let mos_abs = \n",
" Util.list_range 1 aux_num\n",
" \n",
"let mos_in = \n",
" Util.list_range 1 mo_num\n",
"\n",
@ -653,17 +656,18 @@
" [ List.map (fun hole -> \n",
" List.map (fun particle ->\n",
" Determinant.single_excitation Spin.Alfa hole particle ki\n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_a\n",
" ;\n",
" List.map (fun hole -> \n",
" List.map (fun particle ->\n",
" Determinant.single_excitation Spin.Beta hole particle ki\n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_b \n",
" ]\n",
" |> List.concat\n",
" |> List.concat\n",
" |> List.filter (fun x -> Determinant.is_none x = false)\n",
" |> List.map (fun x -> Determinant.set_phase Phase.Pos x)\n",
" in\n",
" \n",
@ -677,9 +681,9 @@
" if hole' > hole && particle' < particle then\n",
" Some (Determinant.double_excitation Spin.Alfa hole particle Spin.Alfa hole' particle' ki)\n",
" else None\n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_a \n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_a\n",
" ; \n",
" List.map (fun hole -> (* Beta-Beta *)\n",
@ -689,9 +693,9 @@
" if hole' > hole && particle' < particle then\n",
" Some (Determinant.double_excitation Spin.Beta hole particle Spin.Beta hole' particle' ki)\n",
" else None\n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_b \n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_b\n",
" ;\n",
" List.map (fun hole -> (* Alpha-Beta *)\n",
@ -699,9 +703,9 @@
" List.map (fun hole' -> \n",
" List.map (fun particle' ->\n",
" Some (Determinant.double_excitation Spin.Alfa hole particle Spin.Beta hole' particle' ki)\n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_b \n",
" ) mos_cabs\n",
" ) mos_abs\n",
" ) mos_a\n",
" ]\n",
" |> List.concat\n",
@ -760,10 +764,10 @@
" |> List.sort_uniq compare\n",
" \n",
" (* Filter out all determinants with incorrect numbers of electrons in the CABS *)\n",
" |> List.filter good_cabs\n",
" |> List.filter good_cabs \n",
" \n",
" (* Filter out all determinants with incorrect excitation numbers *)\n",
" |> List.filter good_lr\n",
" |> List.filter good_lr \n",
" \n",
" \n",
"let compute_HaaF ki alphas kj =\n",
@ -785,30 +789,48 @@
" | 0 -> det_I\n",
" | n -> Array.sub det_I 0 n\n",
" in\n",
" Printf.printf \"Checking...\\n%!\";\n",
" let result =\n",
" Printf.printf \"Checking ... \\n%!\";\n",
" let percent = ref 0 in\n",
" Array.mapi (fun i ki -> \n",
" let p = (10 * (i+1))/(Array.length det_list) in\n",
" if p <> !percent then\n",
" ( percent := p ; Printf.printf \" - %3d %%\\n%!\" (p*10) );\n",
" Array.mapi (fun j kj -> \n",
" if i > j then 0. else\n",
" if Determinant.degree ki kj <> exc then 0. else\n",
" if i > j then (0,0,0.,0.) else\n",
" if Determinant.degree ki kj <> exc then (0,0,0.,0.) else\n",
" let alphas = generate_alphas ki kj exc cabs lexc rexc in\n",
" let det_value =\n",
" compute_HaaF ki alphas kj\n",
" in\n",
" integral_value ki kj -. det_value \n",
" let int_value = \n",
" integral_value ki kj\n",
" in\n",
" (i,j,det_value,int_value)\n",
" ) det_list\n",
" ) det_list\n",
" |> Array.to_list\n",
" |> Array.concat\n",
" in\n",
" let error = \n",
" Array.fold_left (fun accu x -> accu +. x *. x) 0. result\n",
" /. (float_of_int @@ Array.length result)\n",
" let i,j,d,v = \n",
" let rec aux k imax jmax emax dmax vmax = \n",
" if k = -1 then\n",
" imax, jmax, dmax, vmax\n",
" else\n",
" let i, j, d, v = result.(k) in\n",
" let e = abs_float (d -. v) in\n",
" if e > emax then\n",
" aux (k-1) i j e d v\n",
" else\n",
" aux (k-1) imax jmax emax dmax vmax\n",
" in\n",
" aux (n-1) 0 0 0. 0. 0.\n",
" in\n",
" let error = abs_float (d -. v) in\n",
" if error < epsilon_float then\n",
" Printf.printf \"OK: %e\\n%!\" error\n",
" else\n",
" Printf.printf \"Failed: %e\\n%!\" error\n",
" Printf.printf \"Failed: (%d, %d) | %e %e | %e\\n%!\" i j d v error\n",
"\n",
" "
]
@ -817,7 +839,198 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 0 2 22"
"******"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. 0 1 11"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"0_1_11.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$i,j$ : orbital indices of MOs occupied in $|I\\rangle$.\n",
"\n",
"\\begin{align}\n",
"\\sum_{a} \\left( \n",
" \\sum_{i} \\sum_{j}\n",
" \\left(h_{ia} + \\langle i j || a j \\rangle \\right) \n",
" \\left(f_{ai} + \\left[ a j || i j \\right] \\right) + \n",
" \\sum_{i} \\sum_{\\bar{j}}\n",
" \\left(h_{ia} + \\langle i \\bar{j} | a \\bar{j} \\rangle \\right) \n",
" \\left(f_{ai} + \\left[ a \\bar{j} | i \\bar{j} \\right] \\right) \n",
" \\right) + \\\\\n",
"\\sum_{\\bar{a}} \\left(\n",
" \\sum_{\\bar{i}} \\sum_{\\bar{j}}\n",
" \\left(h_{\\bar{i}\\bar{a}} + \\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",
" \\sum_{\\bar{i}} \\sum_{j}\n",
" \\left(h_{\\bar{i}\\bar{a}} + \\langle \\bar{i} j | \\bar{a} j \\rangle \\right)\n",
" \\left(f_{\\bar{a}\\bar{i}} + \\left[ \\bar{a} j | \\bar{i} j \\right] \\right) \n",
" \\right) \n",
"\\end{align}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let integral_value ki kj = \n",
" (* Alpha-Beta *)\n",
" let s, s' = Spin.(Alfa, Beta) in \n",
" List.fold_left (fun accu j -> accu +. \n",
" List.fold_left (fun accu i -> accu +. \n",
" 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 i s +. f_two a j i j s s') )\n",
" +.( (h_one j a s' +. h_two i j i a s s') *. \n",
" (f_one a j s' +. f_two i a i j s s') )\n",
" ) 0. mos_cabs\n",
" ) 0. (mos_a ki)\n",
" ) 0. (mos_b ki)\n",
" +.\n",
" (* Alpha-Alpha / Beta-Beta *)\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 a -> \n",
" accu +.( (h_one i a s +. h_two i j a j s s') *. \n",
" (f_one a i s +. f_two a j i j s s') )\n",
" ) 0. mos_cabs\n",
" ) 0. mos\n",
" ) 0. mos\n",
" ) 0. [ (mos_a ki,Spin.Alfa) ; (mos_b ki,Spin.Beta)]\n",
" \n",
"let _ =\n",
" check 0 integral_value 0 1 1 1\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2. 0 1 22"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"0_1_22.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$i,j$ : orbital indices of MOs occupied in $|I\\rangle$.\n",
"\n",
"$k$ : orbital indices of MOs unoccupied in $|I\\rangle$.\n",
"\n",
"\\begin{align}\n",
"\\sum_{a} \\sum_{k} \\sum_{i} \\sum_{j<i}\n",
" \\langle i j || a k \\rangle \n",
" \\left[ a k || i j \\right] + \n",
"\\sum_{a} \\sum_{\\bar{k}} \\sum_{i} \\sum_{\\bar{j}}\n",
" \\langle i \\bar{j} | a \\bar{k} \\rangle \n",
" \\left[ a \\bar{k} | i \\bar{j} \\right] + \\\\\n",
"\\sum_{\\bar{a}} \\sum_{k} \\sum_{\\bar{i}} \\sum_{j}\n",
" \\langle \\bar{i} j | \\bar{a} k \\rangle \n",
" \\left[ \\bar{a} k | \\bar{i} j \\right] + \n",
"\\sum_{\\bar{a}} \\sum_{\\bar{k}} \\sum_{\\bar{i}} \\sum_{\\bar{j}<\\bar{i}}\n",
" \\langle \\bar{i} \\bar{j} || \\bar{a} \\bar{k} \\rangle \n",
" \\left[ \\bar{a} \\bar{k} || \\bar{i} \\bar{j} \\right] \n",
"\\end{align}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let integral_value ki kj = \n",
" (* mos unoccupied in both I and J *)\n",
" let mos_virt_a, mos_virt_b = \n",
" Array.init mo_num (fun i -> Some (i+1)) , \n",
" Array.init mo_num (fun i -> Some (i+1)) \n",
" in\n",
" List.iter (fun i -> mos_virt_a.(i-1) <- None) (mos_a ki);\n",
" List.iter (fun i -> mos_virt_a.(i-1) <- None) (mos_a kj);\n",
" List.iter (fun i -> mos_virt_b.(i-1) <- None) (mos_b ki);\n",
" List.iter (fun i -> mos_virt_b.(i-1) <- None) (mos_b kj);\n",
" \n",
" let mos_virt_a, mos_virt_b = \n",
" Array.to_list mos_virt_a |> Util.list_some,\n",
" Array.to_list mos_virt_b |> Util.list_some\n",
" in\n",
" \n",
" (* Alpha-Beta *)\n",
" let s, s' = Spin.(Alfa, Beta) in\n",
" List.fold_left (fun accu j -> accu +. \n",
" List.fold_left (fun accu i -> accu +. \n",
" List.fold_left (fun accu k -> accu +. \n",
" List.fold_left (fun accu a ->\n",
" accu +. h_two i j a k s s' *. f_two a k i j s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_virt_b\n",
" ) 0. (mos_a ki)\n",
" ) 0. (mos_b ki)\n",
" +.\n",
" List.fold_left (fun accu j -> accu +. \n",
" List.fold_left (fun accu i -> accu +. \n",
" List.fold_left (fun accu k -> accu +. \n",
" List.fold_left (fun accu a ->\n",
" accu +. h_two i j a k s s' *. f_two a k i j s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_virt_a\n",
" ) 0. (mos_b ki)\n",
" ) 0. (mos_a ki)\n",
" +.\n",
" (* Alpha-Alpha / Beta-Beta *)\n",
" List.fold_left (fun accu (mos_virt,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",
" if i < j then accu else\n",
" List.fold_left (fun accu k -> accu +. \n",
" List.fold_left (fun accu a -> \n",
" accu +. h_two i j a k s s' *. f_two a k i j s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_virt\n",
" ) 0. mos\n",
" ) 0. mos\n",
" ) 0. [ (mos_virt_a,mos_a ki,Spin.Alfa) ; (mos_virt_b,mos_b ki,Spin.Beta)]\n",
" \n",
"let _ =\n",
" check 0 integral_value 0 1 2 2\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3. 0 2 22"
]
},
{
@ -835,13 +1048,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"$i,j$ : orbital indices of MOs occupied in $|I\\rangle$.\n",
"$i,j$ : orbital indices of MOs occupied in $|I\\rangle$.\n",
"\n",
"$$\n",
"\\sum_{j} \\sum_{i<j} \\sum_{b}\\sum_{a<b}\n",
" \\langle i j || a b \\rangle \n",
" \\left[ ab || ij \\right]\n",
"$$"
"\\begin{align}\n",
"\\sum_{a} \\sum_{b>a} \\sum_{i} \\sum_{j<i}\n",
" \\langle i j || a b \\rangle \n",
" \\left[ a b || i j \\right] + \n",
"\\sum_{a} \\sum_{\\bar{b}} \\sum_{i} \\sum_{\\bar{j}}\n",
" \\langle i \\bar{j} | a \\bar{b} \\rangle \n",
" \\left[ a \\bar{b} | i \\bar{j} \\right] + \\\\\n",
"\\sum_{\\bar{a}} \\sum_{b} \\sum_{\\bar{i}} \\sum_{j}\n",
" \\langle \\bar{i} j | \\bar{a} b \\rangle \n",
" \\left[ \\bar{a} b | \\bar{i} j \\right] + \n",
"\\sum_{\\bar{a}} \\sum_{\\bar{b}>\\bar{a}} \\sum_{\\bar{i}} \\sum_{\\bar{j}<\\bar{i}}\n",
" \\langle \\bar{i} \\bar{j} || \\bar{a} \\bar{b} \\rangle \n",
" \\left[ \\bar{a} \\bar{b} || \\bar{i} \\bar{j} \\right] \n",
"\\end{align}"
]
},
{
@ -880,7 +1102,7 @@
" ) 0. [ (mos_a ki,Spin.Alfa) ; (mos_b ki,Spin.Beta)]\n",
" \n",
"let _ =\n",
" check 10 integral_value 0 2 2 2\n",
" check 100 integral_value 0 2 2 2\n",
" "
]
},
@ -888,7 +1110,156 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1 2 22"
"# 4. *1 1 11*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"1_1_11.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$|J\\rangle = \\hat{T}_{i}^{k}|I\\rangle$\n",
"\n",
"$j$ : orbital indices of MOs occupied both in $|I\\rangle$ and $|J\\rangle$.\n",
"\n",
"\\begin{align}\n",
"\\sum_{a} \\sum_{j}\n",
" \\left( h_{ia} + \\langle i j || a j \\rangle \\right)\n",
" \\left( f_{ak} + \\left[ a j || k j \\right] \\right) + \n",
"\\sum_{\\bar{j}}\n",
" \\left( h_{ia} + \\langle i \\bar{j} | a \\bar{j} \\rangle \\right) \n",
" \\left( f_{ak} + \\left[ a \\bar{j} | k \\bar{j} \\right] \\right)\n",
"\\end{align}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let integral_value ki kj = \n",
" let i, k, s, phase =\n",
" match Excitation.of_det ki kj with\n",
" | Excitation.(Single (phase, { hole ; particle ; spin })) ->\n",
" hole, particle, spin, phase\n",
" | _ -> assert false\n",
" in\n",
"\n",
" let mos, mos' =\n",
" match s with\n",
" | Spin.Alfa -> mos_a ki, mos_b ki\n",
" | Spin.Beta -> mos_b ki, mos_a ki\n",
" in\n",
"\n",
" let result = \n",
" (* Alpha-Beta *)\n",
" List.fold_left (fun accu j ->\n",
" let s' = Spin.other 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",
" +.\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",
" match phase with\n",
" | Phase.Pos -> result\n",
" | Phase.Neg -> -. result\n",
" \n",
"\n",
"let _ = check 50 integral_value 1 1 1 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let ki = det_I.(0)\n",
"let kj = det_I.(0)\n",
"\n",
"\n",
"let _ =\n",
" let alphas =\n",
" generate_alphas ki kj 0 1 2 2\n",
" in\n",
" compute_HaaF ki alphas kj\n",
"\n",
"let _ = integral_value ki kj"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 5. *1 1 12*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"1_1_12.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 6. *1 1 21*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"1_1_21.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 7. *1 1 22*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"1_1_22.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 8. 1 2 22 "
]
},
{
@ -923,42 +1294,232 @@
"outputs": [],
"source": [
"let integral_value ki kj = \n",
" let h, p, s, phase =\n",
" match Excitation.of_det ki kj with\n",
" | Excitation.(Single (phase, { hole ; particle ; spin })) ->\n",
" hole, particle, spin, phase\n",
" | _ -> assert false\n",
" let h, p, s, phase =\n",
" match Excitation.of_det ki kj with\n",
" | Excitation.(Single (phase, { hole ; particle ; spin })) ->\n",
" hole, particle, spin, phase\n",
" | _ -> assert false\n",
" in\n",
" \n",
" let mos, mos' =\n",
" match s with\n",
" | Spin.Alfa -> mos_a ki, mos_b ki\n",
" | Spin.Beta -> mos_b ki, mos_a ki\n",
" in\n",
"\n",
" (* Alpha-Beta *)\n",
" let s' = Spin.other s in\n",
" List.fold_left (fun accu j -> accu +. \n",
" List.fold_left (fun accu b -> accu +. \n",
" List.fold_left (fun accu a ->\n",
" accu +. h_two h j a b s s' *. f_two a b p j s s'\n",
" let mos, mos' =\n",
" match s with\n",
" | Spin.Alfa -> mos_a ki, mos_b ki\n",
" | Spin.Beta -> mos_b ki, mos_a ki\n",
" in\n",
"\n",
" let result = \n",
" (* Alpha-Beta *)\n",
" List.fold_left (fun accu j ->\n",
" let s' = Spin.other s in\n",
" accu +. List.fold_left (fun accu b ->\n",
" accu +. List.fold_left (fun accu a ->\n",
" accu +. h_two h j a b s s' *. f_two a b p j s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_cabs\n",
" ) 0. mos_cabs\n",
" ) 0. mos' \n",
" +.\n",
" (* Alpha-Alpha / Beta-Beta *)\n",
" let s' = s in \n",
" List.fold_left (fun accu j -> accu +. \n",
" List.fold_left (fun accu b -> accu +. \n",
" List.fold_left (fun accu a -> \n",
" if b > a then accu else\n",
" accu +. h_two h j a b s s' *. f_two a b p j s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_cabs\n",
" ) 0. mos \n",
" ) 0. mos' \n",
" +.\n",
" (* Alpha-Alpha / Beta-Beta *)\n",
" List.fold_left (fun accu j ->\n",
" let s' = s in \n",
" accu +. List.fold_left (fun accu b ->\n",
" accu +. List.fold_left (fun accu a -> \n",
" if b > a then accu else\n",
" accu +. h_two h j a b s s' *. f_two a b p j s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_cabs\n",
" ) 0. mos \n",
" in\n",
" match phase with\n",
" | Phase.Pos -> result\n",
" | Phase.Neg -> -. result\n",
" \n",
"\n",
"let _ = check 10 integral_value 1 2 2 2"
"let _ = check 50 integral_value 1 2 2 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 9. *2 1 12*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"2_1_12.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 10. *2 1 21*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"2_1_21.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 11. *2 1 22*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"2_1_22.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 12. 2 2 22"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"2_2_22.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$|J\\rangle = \\hat{T}_{ij}^{kl}|I\\rangle$\n",
"\n",
"$$\n",
"\\sum_{b}\\sum_{a<b}\n",
" \\langle i j || a b \\rangle \n",
" \\left[ ab || kj \\right]\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let integral_value ki kj = \n",
" let h, h', p, p', s, s', phase =\n",
" match Excitation.of_det ki kj with\n",
" | Excitation.(Double (phase,\n",
" { hole=h ; particle=p ; spin=s },\n",
" { hole=h'; particle=p'; spin=s'}) ) -> h, h', p, p', s, s', phase\n",
" | _ -> assert false\n",
" in\n",
"\n",
" let result = \n",
" if s <> s' then (* Alpha-Beta *)\n",
" List.fold_left (fun accu b ->\n",
" accu +. List.fold_left (fun accu a ->\n",
" accu +. h_two h h' a b s s' *. f_two a b p p' s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_cabs\n",
" else (* Alpha-Alpha / Beta-Beta *)\n",
" List.fold_left (fun accu b ->\n",
" accu +. List.fold_left (fun accu a -> \n",
" if b > a then accu else\n",
" accu +. h_two h h' a b s s' *. f_two a b p p' s s'\n",
" ) 0. mos_cabs\n",
" ) 0. mos_cabs\n",
" in\n",
" match phase with\n",
" | Phase.Pos -> result\n",
" | Phase.Neg -> -. result\n",
" \n",
"\n",
"let _ = check 100 integral_value 2 2 2 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 13. *3 1 2 2*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"png_image \"3_1_22.png\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$|J\\rangle = \\hat{T}_{ijm}^{kln}|I\\rangle$\n",
"\n",
"$$\n",
"\\sum_{a} \\langle i j || k a \\rangle \\left[ m a || n l \\right] \n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let integral_value ki kj = \n",
" let h1, h2, h3, p1, p2, p3, s1, s2, s3, phase =\n",
" match Excitation.of_det ki kj with\n",
" | Excitation.(Triple (phase,\n",
" { hole=h1 ; particle=p1 ; spin=s1 },\n",
" { hole=h2 ; particle=p2 ; spin=s2 },\n",
" { hole=h3 ; particle=p3 ; spin=s3 }) ) -> h1, h2, h3, p1, p2, p3, s1, s2, s3, phase\n",
" | _ -> assert false\n",
" in\n",
"\n",
"(*\n",
"123\n",
"213\n",
"231\n",
"321\n",
"312\n",
"132\n",
"*)\n",
"\n",
" let result = \n",
" List.fold_left (fun accu a -> accu +.\n",
" h_two h1 h2 p1 a s1 s2 *. f_two h3 a p3 p2 s3 s2 -.\n",
" h_two h2 h1 p2 a s2 s1 *. f_two h3 a p3 p1 s3 s1 +.\n",
" h_two h2 h3 p2 a s2 s3 *. f_two h1 a p1 p3 s1 s3 -.\n",
" h_two h3 h2 p3 a s3 s2 *. f_two h1 a p1 p2 s1 s2 +.\n",
" h_two h3 h1 p3 a s3 s1 *. f_two h2 a p2 p1 s2 s1 -.\n",
" h_two h1 h3 p1 a s1 s3 *. f_two h2 a p2 p3 s2 s3 \n",
" ) 0. mos_cabs\n",
" in\n",
" match phase with\n",
" | Phase.Pos -> result\n",
" | Phase.Neg -> -. result\n",
" \n",
"\n",
"let _ = check 100 integral_value 3 1 2 2"
]
},
{
@ -972,7 +1533,7 @@
"metadata": {
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"display_name": "OCaml 4.07.1",
"display_name": "OCaml default",
"language": "OCaml",
"name": "ocaml-jupyter"
},