mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-14 16:33:30 +01:00
MPI improved and 3-electron F12 optimized
This commit is contained in:
parent
13fcc8e6fa
commit
6e6ef8df2d
437
MOBasis/HF12.ml
437
MOBasis/HF12.ml
@ -259,10 +259,10 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
let two_e_ints = MOBasis.two_e_ints aux_basis in
|
||||
let h2 i j k l (s:Spin.t) (s':Spin.t) =
|
||||
if s' <> s then
|
||||
ERI.get_phys two_e_ints i j k l
|
||||
ERI.get_phys two_e_ints i j k l
|
||||
else
|
||||
(ERI.get_phys two_e_ints i j k l) -.
|
||||
(ERI.get_phys two_e_ints i j l k)
|
||||
(ERI.get_phys two_e_ints i j k l) -.
|
||||
(ERI.get_phys two_e_ints i j l k)
|
||||
in
|
||||
h2
|
||||
in
|
||||
@ -271,12 +271,12 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
let f12_ints = MOBasis.f12_ints aux_basis in
|
||||
let f2 i j k l (s:Spin.t) (s':Spin.t) =
|
||||
if s' <> s then
|
||||
0.375 *. F12.get_phys f12_ints i j k l +.
|
||||
0.125 *. F12.get_phys f12_ints i j l k
|
||||
0.375 *. F12.get_phys f12_ints i j k l +.
|
||||
0.125 *. F12.get_phys f12_ints i j l k
|
||||
else
|
||||
0.25 *. (
|
||||
(F12.get_phys f12_ints i j k l) -.
|
||||
(F12.get_phys f12_ints i j l k) )
|
||||
0.25 *. (
|
||||
(F12.get_phys f12_ints i j k l) -.
|
||||
(F12.get_phys f12_ints i j l k) )
|
||||
in
|
||||
f2
|
||||
in
|
||||
@ -289,55 +289,55 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
if Parallel.master then Printf.printf "Computing m_0111_1H_1F\n" ;
|
||||
let m_0111_1H_1F =
|
||||
Vec.init mo_num (fun i ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_one a i Spin.Alfa *. f_one a i Spin.Alfa ))
|
||||
sum mos_cabs (fun a ->
|
||||
h_one a i Spin.Alfa *. f_one a i Spin.Alfa ))
|
||||
in
|
||||
|
||||
if Parallel.master then Printf.printf "Computing m_0111_1H_2Fa\n" ;
|
||||
let m_0111_1H_2Fa, m_0111_2Ha_2Fa =
|
||||
|
||||
let m_0122_Haa =
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a k i j Spin.Alfa Spin.Alfa *. f_two a k i j Spin.Alfa Spin.Alfa
|
||||
) )
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a k i j Spin.Alfa Spin.Alfa *. f_two a k i j Spin.Alfa Spin.Alfa
|
||||
) )
|
||||
in
|
||||
|
||||
let m_0111_1H_2Fa =
|
||||
Mat.init_cols mo_num mo_num (fun i j ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_one a i Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Alfa +.
|
||||
h_two a j i j Spin.Alfa Spin.Alfa *. f_one a i Spin.Alfa
|
||||
) +.
|
||||
if i < j then 0. else
|
||||
begin
|
||||
sum mos_cabs (fun a ->
|
||||
sum mos_cabs (fun b -> if b >= a then 0. else
|
||||
h_two i j a b Spin.Alfa Spin.Alfa *. f_two a b i j Spin.Alfa Spin.Alfa
|
||||
)
|
||||
) +.
|
||||
sum mos_in (fun k -> m_0122_Haa.{i,j,k})
|
||||
end
|
||||
)
|
||||
Mat.init_cols mo_num mo_num (fun i j ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_one a i Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Alfa +.
|
||||
h_two a j i j Spin.Alfa Spin.Alfa *. f_one a i Spin.Alfa
|
||||
) +.
|
||||
if i < j then 0. else
|
||||
begin
|
||||
sum mos_cabs (fun a ->
|
||||
sum mos_cabs (fun b -> if b >= a then 0. else
|
||||
h_two i j a b Spin.Alfa Spin.Alfa *. f_two a b i j Spin.Alfa Spin.Alfa
|
||||
)
|
||||
) +.
|
||||
sum mos_in (fun k -> m_0122_Haa.{i,j,k})
|
||||
end
|
||||
)
|
||||
in
|
||||
|
||||
let m_0111_2Ha_2Fa =
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a j i j Spin.Alfa Spin.Alfa *.
|
||||
f_two a k i k Spin.Alfa Spin.Alfa
|
||||
) -. if i < j then 0. else m_0122_Haa.{i,j,k}
|
||||
)
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a j i j Spin.Alfa Spin.Alfa *.
|
||||
f_two a k i k Spin.Alfa Spin.Alfa
|
||||
) -. if i < j then 0. else m_0122_Haa.{i,j,k}
|
||||
)
|
||||
in m_0111_1H_2Fa, m_0111_2Ha_2Fa
|
||||
in
|
||||
|
||||
if Parallel.master then Printf.printf "Computing m_0111_1H_2Fb\n" ;
|
||||
let m_0111_1H_2Fb, m_0111_2Hb_2Fb =
|
||||
let m_0122_Hab =
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a k i j Spin.Alfa Spin.Beta *. f_two a k i j Spin.Alfa Spin.Beta
|
||||
) )
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a k i j Spin.Alfa Spin.Beta *. f_two a k i j Spin.Alfa Spin.Beta
|
||||
) )
|
||||
in
|
||||
|
||||
let m_0111_1H_2Fb =
|
||||
@ -374,8 +374,8 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
let m_0111_2Ha_2Fb =
|
||||
array_3_init mo_num mo_num mo_num (fun i j k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a j i j Spin.Alfa Spin.Alfa *.
|
||||
f_two a k i k Spin.Alfa Spin.Beta
|
||||
h_two a j i j Spin.Alfa Spin.Alfa *.
|
||||
f_two a k i k Spin.Alfa Spin.Beta
|
||||
)
|
||||
)
|
||||
in
|
||||
@ -387,57 +387,57 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
|
||||
(* Alpha *)
|
||||
let a =
|
||||
sum mos_i (fun i -> m_0111_1H_1F.{i})
|
||||
sum mos_i (fun i -> m_0111_1H_1F.{i})
|
||||
in
|
||||
|
||||
let b =
|
||||
if same then a else
|
||||
sum mos_i' (fun i -> m_0111_1H_1F.{i})
|
||||
if same then a else
|
||||
sum mos_i' (fun i -> m_0111_1H_1F.{i})
|
||||
in
|
||||
|
||||
let aa =
|
||||
sum mos_i (fun j ->
|
||||
sum mos_i (fun i -> m_0111_1H_2Fa.{i,j} ))
|
||||
sum mos_i (fun j ->
|
||||
sum mos_i (fun i -> m_0111_1H_2Fa.{i,j} ))
|
||||
in
|
||||
|
||||
let bb =
|
||||
if same then aa else
|
||||
sum mos_i' (fun j ->
|
||||
sum mos_i' (fun i -> m_0111_1H_2Fa.{i,j} ))
|
||||
sum mos_i' (fun i -> m_0111_1H_2Fa.{i,j} ))
|
||||
in
|
||||
|
||||
let ab =
|
||||
sum mos_i' (fun j ->
|
||||
sum mos_i (fun i -> m_0111_1H_2Fb.{i,j} ))
|
||||
sum mos_i (fun i -> m_0111_1H_2Fb.{i,j} ))
|
||||
in
|
||||
|
||||
let aaa =
|
||||
sum mos_i (fun k ->
|
||||
sum mos_i (fun j ->
|
||||
sum mos_i (fun i -> m_0111_2Ha_2Fa.{i,j,k} )))
|
||||
sum mos_i (fun k ->
|
||||
sum mos_i (fun j ->
|
||||
sum mos_i (fun i -> m_0111_2Ha_2Fa.{i,j,k} )))
|
||||
in
|
||||
|
||||
let bbb =
|
||||
if same then aaa else
|
||||
sum mos_i' (fun k ->
|
||||
sum mos_i' (fun j ->
|
||||
sum mos_i' (fun i -> m_0111_2Ha_2Fa.{i,j,k} )))
|
||||
sum mos_i' (fun k ->
|
||||
sum mos_i' (fun j ->
|
||||
sum mos_i' (fun i -> m_0111_2Ha_2Fa.{i,j,k} )))
|
||||
in
|
||||
|
||||
let baa =
|
||||
sum mos_i' (fun k ->
|
||||
sum mos_i (fun j ->
|
||||
sum mos_i (fun i ->
|
||||
m_0111_2Ha_2Fb.{i,j,k} +. m_0111_2Hb_2Fb.{i,j,k}
|
||||
)))
|
||||
sum mos_i' (fun k ->
|
||||
sum mos_i (fun j ->
|
||||
sum mos_i (fun i ->
|
||||
m_0111_2Ha_2Fb.{i,j,k} +. m_0111_2Hb_2Fb.{i,j,k}
|
||||
)))
|
||||
in
|
||||
|
||||
let bba =
|
||||
sum mos_i (fun k ->
|
||||
sum mos_i' (fun j ->
|
||||
sum mos_i' (fun i ->
|
||||
m_0111_2Ha_2Fb.{i,j,k} +. m_0111_2Hb_2Fb.{j,i,k}
|
||||
)))
|
||||
sum mos_i (fun k ->
|
||||
sum mos_i' (fun j ->
|
||||
sum mos_i' (fun i ->
|
||||
m_0111_2Ha_2Fb.{i,j,k} +. m_0111_2Hb_2Fb.{j,i,k}
|
||||
)))
|
||||
in
|
||||
|
||||
a +. b +. aa +. bb +. ab +. aaa +. baa +. bba +. bbb
|
||||
@ -446,7 +446,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
if Parallel.master then Printf.printf "Computing m_1111_1H_1F\n" ;
|
||||
let m_1111_1H_1F =
|
||||
Mat.init_cols mo_num mo_num (fun i k ->
|
||||
sum mos_cabs (fun a -> h_one a i Spin.Alfa *. f_one a k Spin.Alfa ))
|
||||
sum mos_cabs (fun a -> h_one a i Spin.Alfa *. f_one a k Spin.Alfa ))
|
||||
in
|
||||
|
||||
if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fa\n" ;
|
||||
@ -586,7 +586,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two a l i j Spin.Alfa Spin.Beta *.
|
||||
f_two a l k j Spin.Alfa Spin.Beta
|
||||
f_two a l k j Spin.Alfa Spin.Beta
|
||||
)
|
||||
)
|
||||
in
|
||||
@ -632,77 +632,77 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
|
||||
let f_1 ki kj =
|
||||
let i, k, s, phase =
|
||||
match Excitation.of_det ki kj with
|
||||
| Excitation.(Single (phase, { hole ; particle ; spin })) ->
|
||||
hole, particle, spin, phase
|
||||
| _ -> assert false
|
||||
match Excitation.of_det ki kj with
|
||||
| Excitation.(Single (phase, { hole ; particle ; spin })) ->
|
||||
hole, particle, spin, phase
|
||||
| _ -> assert false
|
||||
in
|
||||
|
||||
let mos_novirt, mos_novirt' =
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
in
|
||||
|
||||
let mos_ij, mos_ij' =
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
in
|
||||
|
||||
let mos_i, mos_i' =
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a ki, mos_b ki
|
||||
| Spin.Beta -> mos_b ki, mos_a ki
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a ki, mos_b ki
|
||||
| Spin.Beta -> mos_b ki, mos_a ki
|
||||
in
|
||||
|
||||
let mos_j, mos_j' =
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a kj, mos_b kj
|
||||
| Spin.Beta -> mos_b kj, mos_a kj
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a kj, mos_b kj
|
||||
| Spin.Beta -> mos_b kj, mos_a kj
|
||||
in
|
||||
|
||||
let result =
|
||||
m_1111_1H_1F.{i,k} +.
|
||||
sum mos_ij (fun j ->
|
||||
m_1111_1H_2Fa.{j,i,k}
|
||||
+. sum mos_i (fun l -> m_1111_2Ha_2Fa.{l,j,i,k})
|
||||
+. sum mos_i' (fun l -> m_1111_2Ha_2Fb.{l,j,i,k})
|
||||
+. sum mos_j (fun l -> m_1121_2Ha_2Fa.{l,j,i,k})
|
||||
+. sum mos_j' (fun l -> m_1121_2Ha_2Fb.{l,j,i,k})
|
||||
-. sum mos_novirt (fun l -> m_1122_va.{l,j,i,k})
|
||||
-. sum mos_ij (fun l -> m_1122_oa.{l,j,i,k} )
|
||||
) +.
|
||||
m_1111_1H_2Fa.{j,i,k}
|
||||
+. sum mos_i (fun l -> m_1111_2Ha_2Fa.{l,j,i,k})
|
||||
+. sum mos_i' (fun l -> m_1111_2Ha_2Fb.{l,j,i,k})
|
||||
+. sum mos_j (fun l -> m_1121_2Ha_2Fa.{l,j,i,k})
|
||||
+. sum mos_j' (fun l -> m_1121_2Ha_2Fb.{l,j,i,k})
|
||||
-. sum mos_novirt (fun l -> m_1122_va.{l,j,i,k})
|
||||
-. sum mos_ij (fun l -> m_1122_oa.{l,j,i,k} )
|
||||
) +.
|
||||
sum mos_ij' (fun j ->
|
||||
m_1111_1H_2Fb.{j,i,k}
|
||||
+. sum mos_i (fun l -> m_1111_2Hb_2Fa.{l,j,i,k})
|
||||
+. sum mos_i' (fun l -> m_1111_2Hb_2Fb.{l,j,i,k})
|
||||
+. sum mos_j (fun l -> m_1121_2Hb_2Fb.{l,j,i,k})
|
||||
+. sum mos_j' (fun l -> m_1121_2Hb_2Fa.{l,j,i,k})
|
||||
-. sum mos_novirt (fun l -> m_1122_v2.{l,j,i,k})
|
||||
-. sum mos_novirt' (fun l -> m_1122_v3.{l,j,i,k})
|
||||
-. sum mos_ij (fun l -> m_1122_o.{l,j,i,k})
|
||||
)
|
||||
m_1111_1H_2Fb.{j,i,k}
|
||||
+. sum mos_i (fun l -> m_1111_2Hb_2Fa.{l,j,i,k})
|
||||
+. sum mos_i' (fun l -> m_1111_2Hb_2Fb.{l,j,i,k})
|
||||
+. sum mos_j (fun l -> m_1121_2Hb_2Fb.{l,j,i,k})
|
||||
+. sum mos_j' (fun l -> m_1121_2Hb_2Fa.{l,j,i,k})
|
||||
-. sum mos_novirt (fun l -> m_1122_v2.{l,j,i,k})
|
||||
-. sum mos_novirt' (fun l -> m_1122_v3.{l,j,i,k})
|
||||
-. sum mos_ij (fun l -> m_1122_o.{l,j,i,k})
|
||||
)
|
||||
in
|
||||
match phase with
|
||||
| Phase.Pos -> result
|
||||
@ -884,75 +884,75 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
|
||||
let f_2 ki kj =
|
||||
let i, j, k, l, s, s', phase =
|
||||
match Excitation.of_det ki kj with
|
||||
| Excitation.(Double (phase, { hole ; particle ; spin }, {hole=hole' ; particle=particle' ; spin=spin' })) ->
|
||||
hole, hole', particle, particle', spin, spin', phase
|
||||
| _ -> assert false
|
||||
match Excitation.of_det ki kj with
|
||||
| Excitation.(Double (phase, { hole ; particle ; spin }, {hole=hole' ; particle=particle' ; spin=spin' })) ->
|
||||
hole, hole', particle, particle', spin, spin', phase
|
||||
| _ -> assert false
|
||||
in
|
||||
let mos_i, mos_i' =
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a ki, mos_b ki
|
||||
| Spin.Beta -> mos_b ki, mos_a ki
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a ki, mos_b ki
|
||||
| Spin.Beta -> mos_b ki, mos_a ki
|
||||
in
|
||||
|
||||
let mos_j, mos_j' =
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a kj, mos_b kj
|
||||
| Spin.Beta -> mos_b kj, mos_a kj
|
||||
match s with
|
||||
| Spin.Alfa -> mos_a kj, mos_b kj
|
||||
| Spin.Beta -> mos_b kj, mos_a kj
|
||||
in
|
||||
|
||||
let mos_ij, mos_ij' =
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logand i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
in
|
||||
|
||||
let mos_novirt, mos_novirt' =
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
let alfa =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.alfa ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.alfa kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
let beta =
|
||||
let i = Spindeterminant.bitstring @@ Determinant.beta ki in
|
||||
let j = Spindeterminant.bitstring @@ Determinant.beta kj in
|
||||
Bitstring.to_list (Bitstring.logor i j)
|
||||
in
|
||||
match s with
|
||||
| Spin.Alfa -> alfa, beta
|
||||
| Spin.Beta -> beta, alfa
|
||||
in
|
||||
|
||||
let result =
|
||||
if s = s' then
|
||||
m_2112_1H_2Fa.{i,j,k,l} +.
|
||||
sum mos_i (fun n -> m_2112_2Ha_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_i' (fun n -> m_2112_2Hb_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_j (fun n -> m_2121_2Ha_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_j' (fun n -> m_2121_2Ha_2Fb.{n,i,j,k,l} ) +.
|
||||
sum mos_ij (fun n -> m_2122_2Ha_2Fa_ij.{n,i,j,k,l} ) +.
|
||||
sum mos_ij' (fun n -> m_2122_2Ha_2Fa_ij2.{n,i,j,k,l} ) +.
|
||||
sum mos_novirt (fun n -> m_2122_2Ha_2Fa_nv.{n,i,j,k,l} )
|
||||
else
|
||||
m_2112_1H_2Fb.{i,j,k,l} +.
|
||||
sum mos_i (fun n -> m_2112_2Ha_2Fb.{n,i,j,k,l} ) +.
|
||||
sum mos_i' (fun n -> m_2112_2Ha_2Fb.{n,j,i,l,k} ) +.
|
||||
sum mos_j (fun n -> m_2121_2Hb_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_j' (fun n -> m_2121_2Hb_2Fa.{n,j,i,l,k} ) +.
|
||||
sum mos_novirt'(fun n -> m_2122_2Hb_2Fb_nv.{n,i,j,k,l} ) +.
|
||||
sum mos_novirt (fun n -> m_2122_2Hb_2Fb_nv2.{n,i,j,k,l} )+.
|
||||
sum mos_ij (fun n -> m_2122_2Hb_2Fb_ij.{n,i,j,k,l} ) +.
|
||||
sum mos_ij' (fun n -> m_2122_2Hb_2Fb_ij2.{n,i,j,k,l} )
|
||||
if s = s' then
|
||||
m_2112_1H_2Fa.{i,j,k,l} +.
|
||||
sum mos_i (fun n -> m_2112_2Ha_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_i' (fun n -> m_2112_2Hb_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_j (fun n -> m_2121_2Ha_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_j' (fun n -> m_2121_2Ha_2Fb.{n,i,j,k,l} ) +.
|
||||
sum mos_ij (fun n -> m_2122_2Ha_2Fa_ij.{n,i,j,k,l} ) +.
|
||||
sum mos_ij' (fun n -> m_2122_2Ha_2Fa_ij2.{n,i,j,k,l} ) +.
|
||||
sum mos_novirt (fun n -> m_2122_2Ha_2Fa_nv.{n,i,j,k,l} )
|
||||
else
|
||||
m_2112_1H_2Fb.{i,j,k,l} +.
|
||||
sum mos_i (fun n -> m_2112_2Ha_2Fb.{n,i,j,k,l} ) +.
|
||||
sum mos_i' (fun n -> m_2112_2Ha_2Fb.{n,j,i,l,k} ) +.
|
||||
sum mos_j (fun n -> m_2121_2Hb_2Fa.{n,i,j,k,l} ) +.
|
||||
sum mos_j' (fun n -> m_2121_2Hb_2Fa.{n,j,i,l,k} ) +.
|
||||
sum mos_novirt'(fun n -> m_2122_2Hb_2Fb_nv.{n,i,j,k,l} ) +.
|
||||
sum mos_novirt (fun n -> m_2122_2Hb_2Fb_nv2.{n,i,j,k,l} )+.
|
||||
sum mos_ij (fun n -> m_2122_2Hb_2Fb_ij.{n,i,j,k,l} ) +.
|
||||
sum mos_ij' (fun n -> m_2122_2Hb_2Fb_ij2.{n,i,j,k,l} )
|
||||
in
|
||||
|
||||
match phase with
|
||||
@ -963,56 +963,51 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
|
||||
|
||||
let f_3 ki kj =
|
||||
let i, j, m, k, l, n, s1, s2, s3, phase =
|
||||
match Excitation.of_det ki kj with
|
||||
| Excitation.(Triple (phase,
|
||||
{ hole=h1 ; particle=p1 ; spin=s1 },
|
||||
{ hole=h2 ; particle=p2 ; spin=s2 },
|
||||
{ hole=h3 ; particle=p3 ; spin=s3 }) ) ->
|
||||
h1, h2, h3, p1, p2, p3, s1, s2, s3, phase
|
||||
| _ -> assert false
|
||||
match Excitation.of_det ki kj with
|
||||
| Excitation.(Triple (phase,
|
||||
{ hole=h1 ; particle=p1 ; spin=s1 },
|
||||
{ hole=h2 ; particle=p2 ; spin=s2 },
|
||||
{ hole=h3 ; particle=p3 ; spin=s3 }) ) ->
|
||||
h1, h2, h3, p1, p2, p3, s1, s2, s3, phase
|
||||
| _ -> assert false
|
||||
in
|
||||
|
||||
let result =
|
||||
let open Spin in
|
||||
match s1, s2, s3 with
|
||||
| Alfa, Alfa, Alfa
|
||||
| Beta, Beta, Beta ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two i j a k s1 s2 *. f_two m a l n s3 s3
|
||||
+. h_two i j a n s1 s2 *. f_two m a k l s3 s2
|
||||
+. h_two i m a l s1 s3 *. f_two j a k n s2 s3
|
||||
+. h_two j m a k s2 s3 *. f_two i a l n s1 s3
|
||||
+. h_two j m a n s2 s3 *. f_two i a k l s1 s2
|
||||
-. h_two i j a l s1 s2 *. f_two m a k n s3 s3
|
||||
-. h_two i m a k s1 s3 *. f_two j a l n s2 s3
|
||||
-. h_two i m a n s1 s3 *. f_two j a k l s2 s2
|
||||
-. h_two j m a l s2 s3 *. f_two i a k n s1 s3 )
|
||||
| Alfa, Alfa, Beta
|
||||
| Beta, Beta, Alfa ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two i j a l s1 s2 *. f_two a m k n s1 s3
|
||||
+. h_two i m k a s1 s3 *. f_two j a l n s2 s3
|
||||
+. h_two j m a n s2 s3 *. f_two i a k l s1 s2
|
||||
+. h_two j m l a s2 s3 *. f_two i a k n s1 s3
|
||||
-. h_two i j a k s1 s2 *. f_two a m l n s1 s3
|
||||
-. h_two i m a n s1 s3 *. f_two j a k l s2 s2
|
||||
-. h_two i m l a s1 s3 *. f_two j a k n s2 s3
|
||||
-. h_two j m k a s2 s3 *. f_two i a l n s1 s3
|
||||
)
|
||||
| Alfa, Beta, Beta
|
||||
| Beta, Alfa, Alfa ->
|
||||
sum mos_cabs (fun a ->
|
||||
h_two i j a l s1 s2 *. f_two a m k n s1 s3
|
||||
+. h_two i m a n s1 s3 *. f_two a j k l s1 s2
|
||||
+. h_two i m k a s1 s3 *. f_two j a l n s2 s3
|
||||
+. h_two j m a n s2 s3 *. f_two i a k l s1 s2
|
||||
-. h_two i j a n s1 s2 *. f_two a m k l s1 s2
|
||||
-. h_two i j k a s1 s2 *. f_two m a l n s2 s3
|
||||
-. h_two i m a l s1 s3 *. f_two a j k n s1 s3
|
||||
-. h_two j m a l s2 s3 *. f_two i a k n s1 s3
|
||||
)
|
||||
| Beta, Alfa, Beta
|
||||
| Alfa, Beta, Alfa -> assert false (*TODO *)
|
||||
let open Spin in
|
||||
match s1, s2, s3 with
|
||||
| Alfa, Alfa, Alfa
|
||||
| Beta, Beta, Beta ->
|
||||
sum mos_cabs (fun a -> h_two a k i j s1 s2 *. f_two a m n l s3 s3)
|
||||
+. sum mos_cabs (fun a -> h_two a n i j s1 s2 *. f_two a m l k s2 s3)
|
||||
-. sum mos_cabs (fun a -> h_two a l i j s1 s2 *. f_two a m n k s3 s3)
|
||||
+. sum mos_cabs (fun a -> h_two a l i m s1 s3 *. f_two a j n k s3 s2)
|
||||
-. sum mos_cabs (fun a -> h_two a n i m s1 s3 *. f_two a j l k s2 s2)
|
||||
-. sum mos_cabs (fun a -> h_two a k i m s1 s3 *. f_two a j n l s3 s2)
|
||||
+. sum mos_cabs (fun a -> h_two a n j m s2 s3 *. f_two a i l k s2 s1)
|
||||
+. sum mos_cabs (fun a -> h_two a k j m s2 s3 *. f_two a i n l s3 s1)
|
||||
-. sum mos_cabs (fun a -> h_two a l j m s2 s3 *. f_two a i n k s3 s1)
|
||||
| Alfa, Alfa, Beta
|
||||
| Beta, Beta, Alfa ->
|
||||
sum mos_cabs (fun a -> h_two a l i j s1 s2 *. f_two a m k n s1 s3)
|
||||
-. sum mos_cabs (fun a -> h_two a k i j s1 s2 *. f_two a m l n s1 s3)
|
||||
+. sum mos_cabs (fun a -> h_two a l m j s3 s2 *. f_two a i n k s3 s1)
|
||||
-. sum mos_cabs (fun a -> h_two a k m j s3 s2 *. f_two a i n l s3 s1)
|
||||
+. sum mos_cabs (fun a -> h_two a k m i s3 s1 *. f_two a j n l s3 s2)
|
||||
-. sum mos_cabs (fun a -> h_two a l m i s3 s1 *. f_two a j n k s3 s2)
|
||||
+. sum mos_cabs (fun a -> h_two a n j m s2 s3 *. f_two a i l k s2 s1)
|
||||
-. sum mos_cabs (fun a -> h_two a n i m s1 s3 *. f_two a j l k s2 s2)
|
||||
| Alfa, Beta, Beta
|
||||
| Beta, Alfa, Alfa ->
|
||||
sum mos_cabs (fun a -> h_two a l i j s1 s2 *. f_two a m k n s1 s3)
|
||||
-. sum mos_cabs (fun a -> h_two a n i j s1 s2 *. f_two a m k l s1 s2)
|
||||
+. sum mos_cabs (fun a -> h_two a n i m s1 s3 *. f_two a j k l s1 s2)
|
||||
+. sum mos_cabs (fun a -> h_two a n j m s2 s3 *. f_two a i l k s2 s1)
|
||||
-. sum mos_cabs (fun a -> h_two a l i m s1 s3 *. f_two a j k n s1 s3)
|
||||
-. sum mos_cabs (fun a -> h_two a l j m s2 s3 *. f_two a i n k s3 s1)
|
||||
+. sum mos_cabs (fun a -> h_two a k m i s3 s1 *. f_two a j n l s3 s2)
|
||||
-. sum mos_cabs (fun a -> h_two a k j i s2 s1 *. f_two a m n l s3 s2)
|
||||
| Beta, Alfa, Beta
|
||||
| Alfa, Beta, Alfa -> assert false
|
||||
in
|
||||
match phase with
|
||||
| Phase.Pos -> result
|
||||
|
@ -127,14 +127,15 @@ module InterNode = struct
|
||||
|
||||
|
||||
let rank =
|
||||
if comm <> Mpi.comm_none then
|
||||
Mpi.comm_rank c
|
||||
else 0
|
||||
if Mpi.comm_is_null comm then 0 else
|
||||
Mpi.comm_rank comm
|
||||
|
||||
let master = rank = 0
|
||||
|
||||
let broadcast_generic broadcast x =
|
||||
if Mpi.comm_rank <> Mpi.comm_none then
|
||||
if Mpi.comm_is_null comm then
|
||||
Lazy.force x
|
||||
else
|
||||
begin
|
||||
let x =
|
||||
if master then Some (Lazy.force x)
|
||||
@ -143,18 +144,13 @@ module InterNode = struct
|
||||
match broadcast x 0 comm with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
else
|
||||
Lazy.force x
|
||||
end
|
||||
|
||||
let broadcast x = broadcast_generic Mpi.broadcast x
|
||||
(* TODO : temporary single-node fix
|
||||
let broadcast x = Lazy.force x
|
||||
*)
|
||||
|
||||
let barrier () =
|
||||
if comm <> Mpi.comm_none then
|
||||
if Mpi.comm_is_null comm then () else
|
||||
Mpi.barrier comm
|
||||
else ()
|
||||
|
||||
let _ = barrier ()
|
||||
|
||||
|
@ -2,7 +2,6 @@ let create ?(temp_dir="/dev/shm") data_type size_array =
|
||||
let filename =
|
||||
Parallel.Node.broadcast (lazy (Filename.temp_file ~temp_dir "4idx." ".tmp"))
|
||||
in
|
||||
Printf.printf "File:%s\n%!" filename;
|
||||
|
||||
if Parallel.Node.master then
|
||||
begin
|
||||
|
@ -54,7 +54,7 @@ let () =
|
||||
|
||||
let guess =
|
||||
match Command_line.get "guess" with
|
||||
| None -> `Huckel
|
||||
| None -> `Hcore
|
||||
| Some filename ->
|
||||
let s_guess = Simulation.of_filenames
|
||||
~charge ~multiplicity ~nuclei:nuclei_file filename in
|
||||
|
Loading…
Reference in New Issue
Block a user