10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 22:53:41 +01:00

Introduce Schwarz in F12

This commit is contained in:
Anthony Scemama 2020-02-06 18:56:34 +01:00
parent cd3304aef8
commit 2408ef9268

View File

@ -43,7 +43,7 @@ let array_3_init d1 d2 d3 fx =
done done
done) done)
; ;
if Parallel.master then Printf.printf "Broadcast d3\n" ; if Parallel.master then Printf.printf "Broadcast d3\n%!" ;
try Parallel.InterNode.broadcast (lazy result) try Parallel.InterNode.broadcast (lazy result)
with Invalid_argument _ -> with Invalid_argument _ ->
begin begin
@ -290,16 +290,52 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
let f_one = fun _ _ _ -> 0. in let f_one = fun _ _ _ -> 0. in
let s, s' = Spin.(Alfa, Beta) in
let m_3_Hschwarz_aa =
array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> let x = h_two a i j k s s in x *. x)
)
in
let m_3_Hschwarz_ab =
array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> let x = h_two a i j k s s' in x *. x)
)
in
let m_3_Fschwarz_aa =
array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> let x = f_two a i j k s s in x *. x)
)
in
let m_3_Fschwarz_ab =
array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> let x = f_two a i j k s s' in x *. x)
)
in
let eps = 1.e-15 in
let sum_schwarz i j k l m n s1 s2 s3 s4 =
if (s1 = s2 && m_3_Hschwarz_aa.{i,j,k} < eps ) ||
(s1 <> s2 && m_3_Hschwarz_ab.{i,j,k} < eps ) ||
(s3 = s4 && m_3_Fschwarz_aa.{l,m,n} < eps ) ||
(s3 <> s4 && m_3_Fschwarz_ab.{l,m,n} < eps )
then
Array.fold_left (fun accu a ->
accu +. h_two a i j k s1 s2 *. f_two a l m n s3 s4
) 0. mos_cabs
else
0.
in
(* Pre-compute dressed integrals *) (* Pre-compute dressed integrals *)
if Parallel.master then Printf.printf "Computing m_0111_1H_1F\n" ; if Parallel.master then Printf.printf "Computing m_0111_1H_1F\n%!" ;
let m_0111_1H_1F = let m_0111_1H_1F =
Vec.init mo_num (fun i -> Vec.init mo_num (fun i ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one a i Spin.Alfa *. f_one a i Spin.Alfa )) h_one a i Spin.Alfa *. f_one a i Spin.Alfa ))
in in
if Parallel.master then Printf.printf "Computing m_0111_1H_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_0111_1H_2Fa\n%!" ;
let m_0111_1H_2Fa, m_0111_2Ha_2Fa = let m_0111_1H_2Fa, m_0111_2Ha_2Fa =
let m_0122_Haa = let m_0122_Haa =
@ -337,7 +373,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
in m_0111_1H_2Fa, m_0111_2Ha_2Fa in m_0111_1H_2Fa, m_0111_2Ha_2Fa
in in
if Parallel.master then Printf.printf "Computing m_0111_1H_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_0111_1H_2Fb\n%!" ;
let m_0111_1H_2Fb, m_0111_2Hb_2Fb = let m_0111_1H_2Fb, m_0111_2Hb_2Fb =
let m_0122_Hab = let m_0122_Hab =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
@ -376,7 +412,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
m_0111_1H_2Fb, m_0111_2Hb_2Fb m_0111_1H_2Fb, m_0111_2Hb_2Fb
in in
if Parallel.master then Printf.printf "Computing m_0111_2Ha_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_0111_2Ha_2Fb\n%!" ;
let m_0111_2Ha_2Fb = let m_0111_2Ha_2Fb =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -449,13 +485,13 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
a +. b +. aa +. bb +. ab +. aaa +. baa +. bba +. bbb a +. b +. aa +. bb +. ab +. aaa +. baa +. bba +. bbb
in in
if Parallel.master then Printf.printf "Computing m_1111_1H_1F\n" ; if Parallel.master then Printf.printf "Computing m_1111_1H_1F\n%!" ;
let m_1111_1H_1F = let m_1111_1H_1F =
Mat.init_cols mo_num mo_num (fun i k -> 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 in
if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fa\n%!" ;
let m_1111_2Ha_2Fa = let m_1111_2Ha_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l=i then if l=i then
@ -471,7 +507,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1111_2Hb_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_1111_2Hb_2Fa\n%!" ;
let m_1111_2Hb_2Fa = let m_1111_2Hb_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l=i then if l=i then
@ -487,7 +523,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fb\n%!" ;
let m_1111_2Ha_2Fb = let m_1111_2Ha_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -499,7 +535,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1111_2Hb_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_1111_2Hb_2Fb\n%!" ;
let m_1111_2Hb_2Fb = let m_1111_2Hb_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -511,7 +547,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1121_2Ha_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_1121_2Ha_2Fa\n%!" ;
let m_1121_2Ha_2Fa = let m_1121_2Ha_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -521,7 +557,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1121_2Hb_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_1121_2Hb_2Fa\n%!" ;
let m_1121_2Hb_2Fa = let m_1121_2Hb_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -531,7 +567,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1121_2Ha_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_1121_2Ha_2Fb\n%!" ;
let m_1121_2Ha_2Fb = let m_1121_2Ha_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -541,7 +577,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1121_2Hb_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_1121_2Hb_2Fb\n%!" ;
let m_1121_2Hb_2Fb = let m_1121_2Hb_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -551,7 +587,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1122_va\n" ; if Parallel.master then Printf.printf "Computing m_1122_va\n%!" ;
let m_1122_va = let m_1122_va =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -561,7 +597,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1111_1H_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_1111_1H_2Fa\n%!" ;
let m_1111_1H_2Fa = let m_1111_1H_2Fa =
array_3_init mo_num mo_num mo_num (fun j i k -> array_3_init mo_num mo_num mo_num (fun j i k ->
sum mos_in (fun l -> m_1122_va.{l,j,i,k}) +. sum mos_in (fun l -> m_1122_va.{l,j,i,k}) +.
@ -577,7 +613,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1122_v2\n" ; if Parallel.master then Printf.printf "Computing m_1122_v2\n%!" ;
let m_1122_v2 = let m_1122_v2 =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -587,7 +623,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1122_v3\n" ; if Parallel.master then Printf.printf "Computing m_1122_v3\n%!" ;
let m_1122_v3 = let m_1122_v3 =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -597,7 +633,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1111_1H_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_1111_1H_2Fb\n%!" ;
let m_1111_1H_2Fb = let m_1111_1H_2Fb =
array_3_init mo_num mo_num mo_num (fun j i k -> array_3_init mo_num mo_num mo_num (fun j i k ->
sum mos_in (fun l -> m_1122_v2.{l,j,i,k} +. m_1122_v3.{l,j,i,k}) +. sum mos_in (fun l -> m_1122_v2.{l,j,i,k} +. m_1122_v3.{l,j,i,k}) +.
@ -614,7 +650,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1122_oa\n" ; if Parallel.master then Printf.printf "Computing m_1122_oa\n%!" ;
let m_1122_oa = let m_1122_oa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l > j then if l > j then
@ -626,7 +662,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_1122_o\n" ; if Parallel.master then Printf.printf "Computing m_1122_o\n%!" ;
let m_1122_o = let m_1122_o =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -719,7 +755,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
| Phase.Neg -> -. result | Phase.Neg -> -. result
in in
if Parallel.master then Printf.printf "Computing m_2112_1H_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_2112_1H_2Fa\n%!" ;
let m_2112_1H_2Fa = let m_2112_1H_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun i j k l -> array_4_init mo_num mo_num mo_num mo_num (fun i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -738,7 +774,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2112_1H_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_2112_1H_2Fb\n%!" ;
let m_2112_1H_2Fb = let m_2112_1H_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun i j k l -> array_4_init mo_num mo_num mo_num mo_num (fun i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -758,7 +794,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2112_2Ha_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_2112_2Ha_2Fa\n%!" ;
let m_2112_2Ha_2Fa = let m_2112_2Ha_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -768,7 +804,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2112_2Hb_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_2112_2Hb_2Fa\n%!" ;
let m_2112_2Hb_2Fa = let m_2112_2Hb_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -778,7 +814,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2112_2Ha_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_2112_2Ha_2Fb\n%!" ;
let m_2112_2Ha_2Fb = let m_2112_2Ha_2Fb =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -788,7 +824,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2121_2Ha_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_2121_2Ha_2Fa\n%!" ;
let m_2121_2Ha_2Fa = let m_2121_2Ha_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -798,7 +834,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2121_2Hb_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_2121_2Hb_2Fa\n%!" ;
let m_2121_2Hb_2Fa = let m_2121_2Hb_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -808,7 +844,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2121_2Ha_2Fb\n" ; if Parallel.master then Printf.printf "Computing m_2121_2Ha_2Fb\n%!" ;
let m_2121_2Ha_2Fb = let m_2121_2Ha_2Fb =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
@ -818,7 +854,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Ha_2Fa_ij\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Ha_2Fa_ij\n%!" ;
let m_2122_2Ha_2Fa_ij = let m_2122_2Ha_2Fa_ij =
let s = Spin.Alfa in let s = Spin.Alfa in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
@ -831,7 +867,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_ij\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_ij\n%!" ;
let m_2122_2Hb_2Fb_ij = let m_2122_2Hb_2Fb_ij =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
@ -843,7 +879,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_ij2\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_ij2\n%!" ;
let m_2122_2Hb_2Fb_ij2 = let m_2122_2Hb_2Fb_ij2 =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
@ -860,7 +896,7 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Ha_2Fa_ij2\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Ha_2Fa_ij2\n%!" ;
let m_2122_2Ha_2Fa_ij2 = let m_2122_2Ha_2Fa_ij2 =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
@ -871,21 +907,21 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Ha_2Fa_nv\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Ha_2Fa_nv\n%!" ;
let m_2122_2Ha_2Fa_nv = let m_2122_2Ha_2Fa_nv =
let s = Spin.Alfa in let s = Spin.Alfa in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> h_two a n i j s s *. f_two a n l k s s ) ) sum mos_cabs (fun a -> h_two a n i j s s *. f_two a n l k s s ) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv\n%!" ;
let m_2122_2Hb_2Fb_nv = let m_2122_2Hb_2Fb_nv =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> -. h_two a n i j s s' *. f_two a n k l s s' ) ) sum mos_cabs (fun a -> -. h_two a n i j s s' *. f_two a n k l s s' ) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv2\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv2\n%!" ;
let m_2122_2Hb_2Fb_nv2 = let m_2122_2Hb_2Fb_nv2 =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
@ -975,10 +1011,6 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
in in
let ncabs = Array.length mos_cabs in
let tmp_h = Mat.make0 ncabs 9 in
let tmp_f = Mat.make0 ncabs 9 in
let f_3 ki kj = let f_3 ki kj =
let i, j, m, k, l, n, s1, s2, s3, phase = let i, j, m, k, l, n, s1, s2, s3, phase =
match Excitation.of_det ki kj with match Excitation.of_det ki kj with
@ -1006,25 +1038,15 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
+. 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 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) -. sum mos_cabs (fun a -> h_two a l j m s2 s3 *. f_two a i n k s3 s1)
*) *)
Array.iteri (fun idx a -> tmp_f.{idx+1,7} <- f_two a i l k s2 s1) mos_cabs; sum_schwarz k i j m n l s1 s2 s3 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,5} <- f_two a j l k s2 s2) mos_cabs; +. sum_schwarz n i j m l k s1 s2 s2 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,2} <- f_two a m l k s2 s3) mos_cabs; -. sum_schwarz l i j m n k s1 s2 s3 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,9} <- f_two a i n k s3 s1) mos_cabs; +. sum_schwarz l i m j n k s1 s3 s3 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,4} <- f_two a j n k s3 s2) mos_cabs; -. sum_schwarz n i m j l k s1 s3 s2 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,3} <- f_two a m n k s3 s3) mos_cabs; -. sum_schwarz k i m j n l s1 s3 s3 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,8} <- f_two a i n l s3 s1) mos_cabs; +. sum_schwarz n j m i l k s2 s3 s2 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,6} <- f_two a j n l s3 s2) mos_cabs; +. sum_schwarz k j m i n l s2 s3 s3 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,1} <- f_two a m n l s3 s3) mos_cabs; -. sum_schwarz l j m i n k s2 s3 s3 s1
Array.iteri (fun idx a -> tmp_h.{idx+1,3} <- if tmp_f.{idx+1,3} = 0. then 0. else -. h_two a l i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,1} <- if tmp_f.{idx+1,1} = 0. then 0. else h_two a k i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,2} <- if tmp_f.{idx+1,2} = 0. then 0. else h_two a n i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,5} <- if tmp_f.{idx+1,5} = 0. then 0. else -. h_two a n i m s1 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,6} <- if tmp_f.{idx+1,6} = 0. then 0. else -. h_two a k i m s1 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,4} <- if tmp_f.{idx+1,4} = 0. then 0. else h_two a l i m s1 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,9} <- if tmp_f.{idx+1,9} = 0. then 0. else -. h_two a l j m s2 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,7} <- if tmp_f.{idx+1,7} = 0. then 0. else h_two a n j m s2 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,8} <- if tmp_f.{idx+1,8} = 0. then 0. else h_two a k j m s2 s3) mos_cabs;
dot (Mat.as_vec tmp_h) (Mat.as_vec tmp_f)
| Alfa, Alfa, Beta | Alfa, Alfa, Beta
| Beta, Beta, Alfa -> | Beta, Beta, Alfa ->
(* (*
@ -1037,23 +1059,14 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
+. 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 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) -. sum mos_cabs (fun a -> h_two a n i m s1 s3 *. f_two a j l k s2 s2)
*) *)
Array.iteri (fun idx a -> tmp_f.{idx+1,1} <- f_two a m k n s1 s3) mos_cabs; sum_schwarz l i j m k n s1 s2 s1 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,2} <- f_two a m l n s1 s3) mos_cabs; -. sum_schwarz k i j m l n s1 s2 s1 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,4} <- f_two a i n l s3 s1) mos_cabs; +. sum_schwarz l m j i n k s3 s2 s3 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,5} <- f_two a j n l s3 s2) mos_cabs; -. sum_schwarz k m j i n l s3 s2 s3 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,3} <- f_two a i n k s3 s1) mos_cabs; +. sum_schwarz k m i j n l s3 s1 s3 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,6} <- f_two a j n k s3 s2) mos_cabs; -. sum_schwarz l m i j n k s3 s1 s3 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,7} <- f_two a i l k s2 s1) mos_cabs; +. sum_schwarz n j m i l k s2 s3 s2 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,8} <- f_two a j l k s2 s2) mos_cabs; -. sum_schwarz n i m j l k s1 s3 s2 s2
Array.iteri (fun idx a -> tmp_h.{idx+1,1} <- if tmp_f.{idx+1,1} = 0. then 0. else h_two a l i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,2} <- if tmp_f.{idx+1,2} = 0. then 0. else -. h_two a k i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,3} <- if tmp_f.{idx+1,3} = 0. then 0. else +. h_two a l m j s3 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,4} <- if tmp_f.{idx+1,4} = 0. then 0. else -. h_two a k m j s3 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,5} <- if tmp_f.{idx+1,5} = 0. then 0. else +. h_two a k m i s3 s1) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,6} <- if tmp_f.{idx+1,6} = 0. then 0. else -. h_two a l m i s3 s1) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,7} <- if tmp_f.{idx+1,7} = 0. then 0. else +. h_two a n j m s2 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,8} <- if tmp_f.{idx+1,8} = 0. then 0. else -. h_two a n i m s1 s3) mos_cabs;
dot ~n:(8*ncabs) (Mat.as_vec tmp_h) (Mat.as_vec tmp_f)
| Alfa, Beta, Beta | Alfa, Beta, Beta
| Beta, Alfa, Alfa -> | Beta, Alfa, Alfa ->
(* (*
@ -1066,23 +1079,14 @@ let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
+. 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 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) -. sum mos_cabs (fun a -> h_two a k j i s2 s1 *. f_two a m n l s3 s2)
*) *)
Array.iteri (fun idx a -> tmp_f.{idx+1,6} <- f_two a i n k s3 s1) mos_cabs; sum_schwarz l i j m k n s1 s2 s1 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,4} <- f_two a i l k s2 s1) mos_cabs; -. sum_schwarz n i j m k l s1 s2 s1 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,5} <- f_two a j k n s1 s3) mos_cabs; +. sum_schwarz n i m j k l s1 s3 s1 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,1} <- f_two a m k n s1 s3) mos_cabs; +. sum_schwarz n j m i l k s2 s3 s2 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,2} <- f_two a m k l s1 s2) mos_cabs; -. sum_schwarz l i m j k n s1 s3 s1 s3
Array.iteri (fun idx a -> tmp_f.{idx+1,3} <- f_two a j k l s1 s2) mos_cabs; -. sum_schwarz l j m i n k s2 s3 s3 s1
Array.iteri (fun idx a -> tmp_f.{idx+1,7} <- f_two a j n l s3 s2) mos_cabs; +. sum_schwarz k m i j n l s3 s1 s3 s2
Array.iteri (fun idx a -> tmp_f.{idx+1,8} <- f_two a m n l s3 s2) mos_cabs; -. sum_schwarz k j i m n l s2 s1 s3 s2
Array.iteri (fun idx a -> tmp_h.{idx+1,1} <- if tmp_f.{idx+1,1} = 0. then 0. else h_two a l i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,2} <- if tmp_f.{idx+1,2} = 0. then 0. else -. h_two a n i j s1 s2) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,3} <- if tmp_f.{idx+1,3} = 0. then 0. else +. h_two a n i m s1 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,4} <- if tmp_f.{idx+1,4} = 0. then 0. else +. h_two a n j m s2 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,5} <- if tmp_f.{idx+1,5} = 0. then 0. else -. h_two a l i m s1 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,6} <- if tmp_f.{idx+1,6} = 0. then 0. else -. h_two a l j m s2 s3) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,7} <- if tmp_f.{idx+1,7} = 0. then 0. else +. h_two a k m i s3 s1) mos_cabs;
Array.iteri (fun idx a -> tmp_h.{idx+1,8} <- if tmp_f.{idx+1,8} = 0. then 0. else -. h_two a k j i s2 s1) mos_cabs;
dot ~n:(8*ncabs) (Mat.as_vec tmp_h) (Mat.as_vec tmp_f)
| Beta, Alfa, Beta | Beta, Alfa, Beta
| Alfa, Beta, Alfa -> assert false | Alfa, Beta, Alfa -> assert false
in in