10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-07-11 22:03:37 +02:00

Indentation

This commit is contained in:
Anthony Scemama 2018-02-03 19:01:30 +01:00
parent 687c023284
commit 5e87c5edef
4 changed files with 513 additions and 512 deletions

View File

@ -25,10 +25,6 @@ let zero_m ~maxm ~expo_pq_inv ~norm_pq_sq =
(** Compute all the integrals of a contracted class *) (** Compute all the integrals of a contracted class *)
(*
let contracted_class shell_a shell_b shell_c shell_d : float Zmap.t =
TwoElectronRRVectorized.contracted_class ~zero_m shell_a shell_b shell_c shell_d
*)
let contracted_class shell_a shell_b shell_c shell_d : float Zmap.t = let contracted_class shell_a shell_b shell_c shell_d : float Zmap.t =
TwoElectronRR.contracted_class ~zero_m shell_a shell_b shell_c shell_d TwoElectronRR.contracted_class ~zero_m shell_a shell_b shell_c shell_d
@ -41,9 +37,6 @@ let contracted_class_shell_pairs ?schwartz_p ?schwartz_q shell_p shell_q : float
let cutoff2 = cutoff *. cutoff let cutoff2 = cutoff *. cutoff
(*
type n_cls = { n : int ; cls : Z.t array }
*)
exception NullIntegral exception NullIntegral
(* (*
@ -94,8 +87,8 @@ let to_file ~filename basis =
print_int basis.(i).Contracted_shell.indice ; print_newline (); print_int basis.(i).Contracted_shell.indice ; print_newline ();
for j=0 to i do for j=0 to i do
let schwartz_p, schwartz_p_max = schwartz.(i).(j) in let schwartz_p, schwartz_p_max = schwartz.(i).(j) in
if (schwartz_p_max >= cutoff) then if (schwartz_p_max >= cutoff) then
icount := !icount + 1; icount := !icount + 1;
done; done;
done; done;
Printf.printf "%d shell pairs computed in %f seconds\n" !icount (Unix.gettimeofday () -. t0); Printf.printf "%d shell pairs computed in %f seconds\n" !icount (Unix.gettimeofday () -. t0);
@ -130,63 +123,71 @@ let to_file ~filename basis =
for l=0 to k do for l=0 to k do
let schwartz_q, schwartz_q_max = schwartz.(k).(l) in let schwartz_q, schwartz_q_max = schwartz.(k).(l) in
try try
if schwartz_p_max *. schwartz_q_max < cutoff2 then if schwartz_p_max *. schwartz_q_max < cutoff2 then
raise NullIntegral; raise NullIntegral;
let let
shell_q = shell_pairs.(k).(l) shell_q = shell_pairs.(k).(l)
in in
let swap = let swap =
Array.length shell_q < Array.length shell_p Array.length shell_q < Array.length shell_p
in in
(* Compute all the integrals of the class *) (* Compute all the integrals of the class *)
let cls = let cls =
if swap then if swap then
if Array.length shell_p < 2 then if Array.length shell_p < 2 then
contracted_class_shell_pairs ~schwartz_p:schwartz_q ~schwartz_q:schwartz_p shell_q shell_p contracted_class_shell_pairs
~schwartz_p:schwartz_q ~schwartz_q:schwartz_p
shell_q shell_p
else
contracted_class_shell_pairs_vec
~schwartz_p:schwartz_q ~schwartz_q:schwartz_p
shell_q shell_p
else else
contracted_class_shell_pairs_vec ~schwartz_p:schwartz_q ~schwartz_q:schwartz_p shell_q shell_p
else
if Array.length shell_q < 2 then if Array.length shell_q < 2 then
contracted_class_shell_pairs ~schwartz_p ~schwartz_q shell_p shell_q contracted_class_shell_pairs
~schwartz_p ~schwartz_q
shell_p shell_q
else else
contracted_class_shell_pairs_vec ~schwartz_p ~schwartz_q shell_p shell_q contracted_class_shell_pairs_vec
in ~schwartz_p ~schwartz_q
shell_p shell_q
in
(* Write the data in the output file *) (* Write the data in the output file *)
Array.iteri (fun i_c powers_i -> Array.iteri (fun i_c powers_i ->
let i_c = basis.(i).Contracted_shell.indice + i_c + 1 in let i_c = basis.(i).Contracted_shell.indice + i_c + 1 in
let xi = to_int_tuple powers_i in let xi = to_int_tuple powers_i in
Array.iteri (fun j_c powers_j -> Array.iteri (fun j_c powers_j ->
let j_c = basis.(j).Contracted_shell.indice + j_c + 1 in let j_c = basis.(j).Contracted_shell.indice + j_c + 1 in
let xj = to_int_tuple powers_j in let xj = to_int_tuple powers_j in
Array.iteri (fun k_c powers_k -> Array.iteri (fun k_c powers_k ->
let k_c = basis.(k).Contracted_shell.indice + k_c + 1 in let k_c = basis.(k).Contracted_shell.indice + k_c + 1 in
let xk = to_int_tuple powers_k in let xk = to_int_tuple powers_k in
Array.iteri (fun l_c powers_l -> Array.iteri (fun l_c powers_l ->
let l_c = basis.(l).Contracted_shell.indice + l_c + 1 in let l_c = basis.(l).Contracted_shell.indice + l_c + 1 in
let xl = to_int_tuple powers_l in let xl = to_int_tuple powers_l in
let key = let key =
if swap then if swap then
Zkey.of_int_tuple (Zkey.Twelve (xk,xl,xi,xj)) Zkey.of_int_tuple (Zkey.Twelve (xk,xl,xi,xj))
else
Zkey.of_int_tuple (Zkey.Twelve (xi,xj,xk,xl))
in
let value =
Zmap.find cls key
in
if (abs_float value > cutoff) then
(inn := !inn + 1;
eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} <- value;
)
else else
Zkey.of_int_tuple (Zkey.Twelve (xi,xj,xk,xl)) out := !out + 1;
in ) basis.(l).Contracted_shell.powers
let value = ) basis.(k).Contracted_shell.powers
Zmap.find cls key ) basis.(j).Contracted_shell.powers
in ) basis.(i).Contracted_shell.powers;
if (abs_float value > cutoff) then with NullIntegral -> ()
(inn := !inn + 1;
eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} <- value;
)
else
out := !out + 1;
) basis.(l).Contracted_shell.powers
) basis.(k).Contracted_shell.powers
) basis.(j).Contracted_shell.powers
) basis.(i).Contracted_shell.powers;
with NullIntegral -> ()
done; done;
done; done;
with NullIntegral -> () with NullIntegral -> ()
@ -197,15 +198,15 @@ let to_file ~filename basis =
(* Print ERIs *) (* Print ERIs *)
for i_c=1 to (Genarray.nth_dim eri_array 0) do for i_c=1 to (Genarray.nth_dim eri_array 0) do
for j_c=1 to (Genarray.nth_dim eri_array 2) do for j_c=1 to (Genarray.nth_dim eri_array 2) do
for k_c=1 to (Genarray.nth_dim eri_array 1) do for k_c=1 to (Genarray.nth_dim eri_array 1) do
for l_c=1 to (Genarray.nth_dim eri_array 3) do for l_c=1 to (Genarray.nth_dim eri_array 3) do
let value = eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} in let value = eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} in
if (value <> 0.) then if (value <> 0.) then
Printf.fprintf oc " %5d %5d %5d %5d%20.15f\n" i_c k_c j_c l_c value; Printf.fprintf oc " %5d %5d %5d %5d%20.15f\n" i_c k_c j_c l_c value;
done; done;
done;
done; done;
done;
done; done;
Printf.printf "In: %d Out:%d\n" !inn !out ; Printf.printf "In: %d Out:%d\n" !inn !out ;
close_out oc close_out oc

View File

@ -33,19 +33,19 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
Printf.printf "%d %d %d\n" angMom_c.(0) angMom_c.(1) angMom_c.(2) ; Printf.printf "%d %d %d\n" angMom_c.(0) angMom_c.(1) angMom_c.(2) ;
Printf.printf "%d %d %d\n" angMom_d.(0) angMom_d.(1) angMom_d.(2) ; Printf.printf "%d %d %d\n" angMom_d.(0) angMom_d.(1) angMom_d.(2) ;
Printf.printf "%f %f %f %f\n%f %f %f\n%f %f %f\n%f %f %f\n" expo_b expo_d Printf.printf "%f %f %f %f\n%f %f %f\n%f %f %f\n%f %f %f\n" expo_b expo_d
expo_inv_p expo_inv_q expo_inv_p expo_inv_q
(Coordinate.coord center_ab 0) (Coordinate.coord center_ab 1) (Coordinate.coord center_ab 2) (Coordinate.coord center_ab 0) (Coordinate.coord center_ab 1) (Coordinate.coord center_ab 2)
(Coordinate.coord center_cd 0) (Coordinate.coord center_cd 1) (Coordinate.coord center_cd 2) (Coordinate.coord center_cd 0) (Coordinate.coord center_cd 1) (Coordinate.coord center_cd 2)
(Coordinate.coord center_pq 0) (Coordinate.coord center_pq 1) (Coordinate.coord center_pq 2) (Coordinate.coord center_pq 0) (Coordinate.coord center_pq 1) (Coordinate.coord center_pq 2)
end; end;
(** Vertical recurrence relations *) (** Vertical recurrence relations *)
let rec vrr0 angMom_a totAngMom_a = let rec vrr0 angMom_a totAngMom_a =
if debug then if debug then
begin begin
let (x,y,z) = angMom_a in let (x,y,z) = angMom_a in
Printf.printf "vrr0: %d : %d %d %d\n" totAngMom_a x y z Printf.printf "vrr0: %d : %d %d %d\n" totAngMom_a x y z
end; end;
match totAngMom_a with match totAngMom_a with
| 0 -> zero_m_array | 0 -> zero_m_array
@ -55,47 +55,47 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
try Zmap.find map_1d key with try Zmap.find map_1d key with
| Not_found -> | Not_found ->
let result = let result =
let am, amm, amxyz, xyz = let am, amm, amxyz, xyz =
match angMom_a with match angMom_a with
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0 | (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1 | (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2 | (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
in in
if amxyz < 0 then empty else if amxyz < 0 then empty else
let v1 = let v1 =
vrr0 am (totAngMom_a-1) vrr0 am (totAngMom_a-1)
in in
let f1 = expo_inv_p *. (Coordinate.coord center_pq xyz) let f1 = expo_inv_p *. (Coordinate.coord center_pq xyz)
and f2 = expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz) and f2 = expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)
in in
if amxyz < 1 then if amxyz < 1 then
Array.init maxsze (fun m -> Array.init maxsze (fun m ->
if m = maxm then 0. else (f1 *. v1.(m+1) ) -. f2 *. v1.(m) ) if m = maxm then 0. else (f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
else else
let f3 = (float_of_int amxyz) *. expo_inv_p *. 0.5 in let f3 = (float_of_int amxyz) *. expo_inv_p *. 0.5 in
let v3 = let v3 =
vrr0 amm (totAngMom_a-2) vrr0 amm (totAngMom_a-2)
in in
Array.init maxsze (fun m -> Array.init maxsze (fun m ->
(if m = maxm then 0. else (if m = maxm then 0. else
(f1 *. v1.(m+1) ) -. f2 *. v1.(m) ) (f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
+. f3 *. (v3.(m) +. if m = maxm then 0. else +. f3 *. (v3.(m) +. if m = maxm then 0. else
expo_inv_p *. v3.(m+1)) expo_inv_p *. v3.(m+1))
) )
in Zmap.add map_1d key result; in Zmap.add map_1d key result;
result result
and vrr angMom_a angMom_c totAngMom_a totAngMom_c = and vrr angMom_a angMom_c totAngMom_a totAngMom_c =
if debug then if debug then
begin begin
let angMom_ax, angMom_ay, angMom_az = angMom_a in let angMom_ax, angMom_ay, angMom_az = angMom_a in
let angMom_cx, angMom_cy, angMom_cz = angMom_c in let angMom_cx, angMom_cy, angMom_cz = angMom_c in
Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c
angMom_ax angMom_ay angMom_az angMom_cx angMom_cy angMom_cz angMom_ax angMom_ay angMom_az angMom_cx angMom_cy angMom_cz
end; end;
match (totAngMom_a, totAngMom_c) with match (totAngMom_a, totAngMom_c) with
| (i,0) -> if (i>0) then vrr0 angMom_a totAngMom_a else zero_m_array | (i,0) -> if (i>0) then vrr0 angMom_a totAngMom_a else zero_m_array
@ -104,71 +104,71 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
try Zmap.find map_2d key with try Zmap.find map_2d key with
| Not_found -> | Not_found ->
let result =
let am, cm, cmm, axyz, cmxyz, xyz =
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_cx, angMom_cy, angMom_cz = angMom_c in
match angMom_c with
| (_,0,0) -> (* 321_984 *)
(angMom_ax-1, angMom_ay, angMom_az),
(angMom_cx-1, angMom_cy, angMom_cz),
(angMom_cx-2, angMom_cy, angMom_cz),
angMom_ax,angMom_cx-1, 0
| (_,_,0) -> (* 612_002 *)
(angMom_ax, angMom_ay-1, angMom_az),
(angMom_cx, angMom_cy-1, angMom_cz),
(angMom_cx, angMom_cy-2, angMom_cz),
angMom_ay,angMom_cy-1, 1
| _ -> (* 1_067_324 *)
(angMom_ax, angMom_ay, angMom_az-1),
(angMom_cx, angMom_cy, angMom_cz-1),
(angMom_cx, angMom_cy, angMom_cz-2),
angMom_az,angMom_cz-1, 2
in
if cmxyz < 0 then empty else
let f1 =
-. expo_d *. expo_inv_q *. (Coordinate.coord center_cd xyz)
in
let f2 =
expo_inv_q *. (Coordinate.coord center_pq xyz)
in
let result = let result =
let am, cm, cmm, axyz, cmxyz, xyz = if ( (abs_float f1 < cutoff) && (abs_float f2 < cutoff) ) then empty else
let angMom_ax, angMom_ay, angMom_az = angMom_a let v1 =
and angMom_cx, angMom_cy, angMom_cz = angMom_c in vrr angMom_a cm totAngMom_a (totAngMom_c-1)
match angMom_c with in
| (_,0,0) -> (* 321_984 *) Array.init maxsze (fun m ->
(angMom_ax-1, angMom_ay, angMom_az), f1 *. v1.(m) -. (if m = maxm then 0. else f2 *. v1.(m+1)) )
(angMom_cx-1, angMom_cy, angMom_cz), in
(angMom_cx-2, angMom_cy, angMom_cz), let result =
angMom_ax,angMom_cx-1, 0 if cmxyz < 1 then result else
| (_,_,0) -> (* 612_002 *) let f3 =
(angMom_ax, angMom_ay-1, angMom_az), (float_of_int cmxyz) *. expo_inv_q *. 0.5
(angMom_cx, angMom_cy-1, angMom_cz), in
(angMom_cx, angMom_cy-2, angMom_cz), if (abs_float f3 < cutoff) && (abs_float (f3 *. expo_inv_q) < cutoff) then result else
angMom_ay,angMom_cy-1, 1 (
| _ -> (* 1_067_324 *) let v3 =
(angMom_ax, angMom_ay, angMom_az-1), vrr angMom_a cmm totAngMom_a (totAngMom_c-2)
(angMom_cx, angMom_cy, angMom_cz-1), in
(angMom_cx, angMom_cy, angMom_cz-2), Array.init maxsze (fun m -> result.(m) +.
angMom_az,angMom_cz-1, 2 f3 *. (v3.(m) +. (if m=maxm then 0. else expo_inv_q *. v3.(m+1)) ))
in )
if cmxyz < 0 then empty else in
let f1 = let result =
-. expo_d *. expo_inv_q *. (Coordinate.coord center_cd xyz) if (axyz < 1) || (cmxyz < 0) then result else
in let f5 =
let f2 = (float_of_int axyz) *. expo_inv_p *. expo_inv_q *. 0.5
expo_inv_q *. (Coordinate.coord center_pq xyz) in
in if (abs_float f5 < cutoff) then result else
let result = let v5 =
if ( (abs_float f1 < cutoff) && (abs_float f2 < cutoff) ) then empty else vrr am cm (totAngMom_a-1) (totAngMom_c-1)
let v1 = in
vrr angMom_a cm totAngMom_a (totAngMom_c-1) Array.init (maxsze) (fun m ->
in result.(m) -. (if m = maxm then 0. else f5 *. v5.(m+1)))
Array.init maxsze (fun m -> in
f1 *. v1.(m) -. (if m = maxm then 0. else f2 *. v1.(m+1)) ) result
in in Zmap.add map_2d key result;
let result = result
if cmxyz < 1 then result else
let f3 =
(float_of_int cmxyz) *. expo_inv_q *. 0.5
in
if (abs_float f3 < cutoff) && (abs_float (f3 *. expo_inv_q) < cutoff) then result else
(
let v3 =
vrr angMom_a cmm totAngMom_a (totAngMom_c-2)
in
Array.init maxsze (fun m -> result.(m) +.
f3 *. (v3.(m) +. (if m=maxm then 0. else expo_inv_q *. v3.(m+1)) ))
)
in
let result =
if (axyz < 1) || (cmxyz < 0) then result else
let f5 =
(float_of_int axyz) *. expo_inv_p *. expo_inv_q *. 0.5
in
if (abs_float f5 < cutoff) then result else
let v5 =
vrr am cm (totAngMom_a-1) (totAngMom_c-1)
in
Array.init (maxsze) (fun m ->
result.(m) -. (if m = maxm then 0. else f5 *. v5.(m+1)))
in
result
in Zmap.add map_2d key result;
result
@ -179,88 +179,88 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
totAngMom_a totAngMom_b totAngMom_c = totAngMom_a totAngMom_b totAngMom_c =
if debug then if debug then
begin begin
let angMom_ax, angMom_ay, angMom_az = angMom_a let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_bx, angMom_by, angMom_bz = angMom_b and angMom_bx, angMom_by, angMom_bz = angMom_b
and angMom_cx, angMom_cy, angMom_cz = angMom_c in and angMom_cx, angMom_cy, angMom_cz = angMom_c in
Printf.printf "hrr0: %d %d %d : %d %d %d %d %d %d %d %d %d\n" Printf.printf "hrr0: %d %d %d : %d %d %d %d %d %d %d %d %d\n"
totAngMom_a totAngMom_b totAngMom_c totAngMom_a totAngMom_b totAngMom_c
angMom_ax angMom_ay angMom_az angMom_ax angMom_ay angMom_az
angMom_bx angMom_by angMom_bz angMom_bx angMom_by angMom_bz
angMom_cx angMom_cy angMom_cz angMom_cx angMom_cy angMom_cz
end; end;
match totAngMom_b with match totAngMom_b with
| 0 -> (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0) | 0 -> (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
| 1 -> | 1 ->
let angMom_ax, angMom_ay, angMom_az = angMom_a in let angMom_ax, angMom_ay, angMom_az = angMom_a in
let ap, xyz = let ap, xyz =
match angMom_b with match angMom_b with
| (1,_,_) -> (angMom_ax+1,angMom_ay,angMom_az), 0 | (1,_,_) -> (angMom_ax+1,angMom_ay,angMom_az), 0
| (_,1,_) -> (angMom_ax,angMom_ay+1,angMom_az), 1 | (_,1,_) -> (angMom_ax,angMom_ay+1,angMom_az), 1
| _ -> (angMom_ax,angMom_ay,angMom_az+1), 2 | _ -> (angMom_ax,angMom_ay,angMom_az+1), 2
in in
let v1 = let v1 =
vrr ap angMom_c (totAngMom_a+1) totAngMom_c vrr ap angMom_c (totAngMom_a+1) totAngMom_c
in in
let f2 = let f2 =
(Coordinate.coord center_ab xyz) (Coordinate.coord center_ab xyz)
in in
if (abs_float f2 < cutoff) then v1.(0) else if (abs_float f2 < cutoff) then v1.(0) else
let v2 = let v2 =
vrr angMom_a angMom_c totAngMom_a totAngMom_c vrr angMom_a angMom_c totAngMom_a totAngMom_c
in
v1.(0) +. f2 *. v2.(0)
| _ ->
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_bx, angMom_by, angMom_bz = angMom_b in
let bxyz, xyz =
match angMom_b with
| (_,0,0) -> angMom_bx, 0
| (_,_,0) -> angMom_by, 1
| (_,_,_) -> angMom_bz, 2
in in
if (bxyz < 1) then 0. else v1.(0) +. f2 *. v2.(0)
let ap, bm = | _ ->
match xyz with let angMom_ax, angMom_ay, angMom_az = angMom_a
| 0 -> (angMom_ax+1,angMom_ay,angMom_az),(angMom_bx-1,angMom_by,angMom_bz) and angMom_bx, angMom_by, angMom_bz = angMom_b in
| 1 -> (angMom_ax,angMom_ay+1,angMom_az),(angMom_bx,angMom_by-1,angMom_bz) let bxyz, xyz =
| _ -> (angMom_ax,angMom_ay,angMom_az+1),(angMom_bx,angMom_by,angMom_bz-1) match angMom_b with
| (_,0,0) -> angMom_bx, 0
| (_,_,0) -> angMom_by, 1
| (_,_,_) -> angMom_bz, 2
in
if (bxyz < 1) then 0. else
let ap, bm =
match xyz with
| 0 -> (angMom_ax+1,angMom_ay,angMom_az),(angMom_bx-1,angMom_by,angMom_bz)
| 1 -> (angMom_ax,angMom_ay+1,angMom_az),(angMom_bx,angMom_by-1,angMom_bz)
| _ -> (angMom_ax,angMom_ay,angMom_az+1),(angMom_bx,angMom_by,angMom_bz-1)
in
let h1 =
hrr0 ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
in
let f2 =
(Coordinate.coord center_ab xyz)
in
if (abs_float f2 < cutoff) then h1 else
let h2 =
hrr0 angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in in
let h1 = h1 +. f2 *. h2
hrr0 ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
in
let f2 =
(Coordinate.coord center_ab xyz)
in
if (abs_float f2 < cutoff) then h1 else
let h2 =
hrr0 angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in
h1 +. f2 *. h2
and hrr angMom_a angMom_b angMom_c angMom_d and hrr angMom_a angMom_b angMom_c angMom_d
totAngMom_a totAngMom_b totAngMom_c totAngMom_d = totAngMom_a totAngMom_b totAngMom_c totAngMom_d =
if debug then if debug then
begin begin
let angMom_ax, angMom_ay, angMom_az = angMom_a in let angMom_ax, angMom_ay, angMom_az = angMom_a in
let angMom_bx, angMom_by, angMom_bz = angMom_b in let angMom_bx, angMom_by, angMom_bz = angMom_b in
let angMom_cx, angMom_cy, angMom_cz = angMom_c in let angMom_cx, angMom_cy, angMom_cz = angMom_c in
let angMom_dx, angMom_dy, angMom_dz = angMom_d in let angMom_dx, angMom_dy, angMom_dz = angMom_d in
Printf.printf "hrr : %d %d %d %d : %d %d %d %d %d %d %d %d %d %d %d %d\n" Printf.printf "hrr : %d %d %d %d : %d %d %d %d %d %d %d %d %d %d %d %d\n"
totAngMom_a totAngMom_b totAngMom_c totAngMom_d totAngMom_a totAngMom_b totAngMom_c totAngMom_d
angMom_ax angMom_ay angMom_az angMom_ax angMom_ay angMom_az
angMom_bx angMom_by angMom_bz angMom_bx angMom_by angMom_bz
angMom_cx angMom_cy angMom_cz angMom_cx angMom_cy angMom_cz
angMom_dx angMom_dy angMom_dz angMom_dx angMom_dy angMom_dz
end; end;
match (totAngMom_b, totAngMom_d) with match (totAngMom_b, totAngMom_d) with
| (_,0) -> if (totAngMom_b = 0) then | (_,0) -> if (totAngMom_b = 0) then
(vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0) (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
else else
hrr0 angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c hrr0 angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
| (_,_) -> | (_,_) ->
let (angMom_cx, angMom_cy, angMom_cz) = angMom_c let (angMom_cx, angMom_cy, angMom_cz) = angMom_c
and (angMom_dx, angMom_dy, angMom_dz) = angMom_d in and (angMom_dx, angMom_dy, angMom_dz) = angMom_d in
@ -342,45 +342,45 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
in in
let zero_m_array = let zero_m_array =
zero_m ~maxm ~expo_pq_inv ~norm_pq_sq zero_m ~maxm ~expo_pq_inv ~norm_pq_sq
in in
begin begin
match Contracted_shell.(totAngMom shell_a, totAngMom shell_b, match Contracted_shell.(totAngMom shell_a, totAngMom shell_b,
totAngMom shell_c, totAngMom shell_d) with totAngMom shell_c, totAngMom shell_d) with
| Angular_momentum.(S,S,S,S) -> | Angular_momentum.(S,S,S,S) ->
let integral = let integral =
zero_m_array.(0) zero_m_array.(0)
in in
contracted_class.(0) <- contracted_class.(0) +. coef_prod *. integral contracted_class.(0) <- contracted_class.(0) +. coef_prod *. integral
| _ -> | _ ->
let d = shell_q.(cd).Shell_pair.j in let d = shell_q.(cd).Shell_pair.j in
let map_1d = Zmap.create (4*maxm) in let map_1d = Zmap.create (4*maxm) in
let map_2d = Zmap.create (Array.length class_indices) in let map_2d = Zmap.create (Array.length class_indices) in
let norm_coef_scale_q = shell_q.(cd).Shell_pair.norm_coef_scale in let norm_coef_scale_q = shell_q.(cd).Shell_pair.norm_coef_scale in
let norm_coef_scale = let norm_coef_scale =
Array.map (fun v1 -> Array.map (fun v1 ->
Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q
) norm_coef_scale_p ) norm_coef_scale_p
|> Array.to_list |> Array.to_list
|> Array.concat |> Array.concat
in in
(* (*
let monocentric = let monocentric =
shell_p.(ab).Shell_pair.monocentric && shell_p.(ab).Shell_pair.monocentric &&
shell_q.(cd).Shell_pair.monocentric shell_q.(cd).Shell_pair.monocentric
in in
*) *)
(* Compute the integral class from the primitive shell quartet *) (* Compute the integral class from the primitive shell quartet *)
class_indices class_indices
|> Array.iteri (fun i key -> |> Array.iteri (fun i key ->
let a = Zkey.to_int_array Zkey.Kind_12 key in let a = Zkey.to_int_array Zkey.Kind_12 key in
let (angMomA,angMomB,angMomC,angMomD) = let (angMomA,angMomB,angMomC,angMomD) =
( [| a.(0) ; a.(1) ; a.(2) |], ( [| a.(0) ; a.(1) ; a.(2) |],
[| a.(3) ; a.(4) ; a.(5) |], [| a.(3) ; a.(4) ; a.(5) |],
[| a.(6) ; a.(7) ; a.(8) |], [| a.(6) ; a.(7) ; a.(8) |],
[| a.(9) ; a.(10) ; a.(11) |] ) [| a.(9) ; a.(10) ; a.(11) |] )
in in
try try
(* (*
if monocentric then if monocentric then
begin begin
@ -391,7 +391,7 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
raise NullQuartet raise NullQuartet
end; end;
*) *)
(* Schwartz screening *) (* Schwartz screening *)
(* (*
let schwartz_p = let schwartz_p =
let key = let key =
@ -421,23 +421,23 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
if schwartz_p *. schwartz_q < cutoff2 then raise NullQuartet; if schwartz_p *. schwartz_q < cutoff2 then raise NullQuartet;
*) *)
let norm = norm_coef_scale.(i) in let norm = norm_coef_scale.(i) in
let coef_prod = coef_prod *. norm in let coef_prod = coef_prod *. norm in
let integral = let integral =
hvrr_two_e (angMomA, angMomB, angMomC, angMomD) hvrr_two_e (angMomA, angMomB, angMomC, angMomD)
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b, (Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b,
Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d) Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d)
(maxm, zero_m_array) (maxm, zero_m_array)
(Contracted_shell.expo shell_b b, Contracted_shell.expo shell_d d) (Contracted_shell.expo shell_b b, Contracted_shell.expo shell_d d)
(shell_p.(ab).Shell_pair.expo_inv, shell_q.(cd).Shell_pair.expo_inv) (shell_p.(ab).Shell_pair.expo_inv, shell_q.(cd).Shell_pair.expo_inv)
(shell_p.(ab).Shell_pair.center_ab, shell_q.(cd).Shell_pair.center_ab, center_pq) (shell_p.(ab).Shell_pair.center_ab, shell_q.(cd).Shell_pair.center_ab, center_pq)
map_1d map_2d map_1d map_2d
in in
contracted_class.(i) <- contracted_class.(i) +. coef_prod *. integral contracted_class.(i) <- contracted_class.(i) +. coef_prod *. integral
with NullQuartet -> () with NullQuartet -> ()
) )
end end
with NullQuartet -> () with NullQuartet -> ()
done done
done; done;

View File

@ -43,8 +43,8 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
in in
let f = expo_b *. (Coordinate.coord center_ab xyz) in let f = expo_b *. (Coordinate.coord center_ab xyz) in
Array.init ncoef (fun k -> coef_prod.(k) *. expo_inv_p *. Array.init ncoef (fun k -> coef_prod.(k) *. expo_inv_p *.
( (Coordinate.coord center_pq.(k) xyz) *. zero_m_array.(m+1).(k) ( (Coordinate.coord center_pq.(k) xyz) *. zero_m_array.(m+1).(k)
-. f *. zero_m_array.(m).(k) ) ) -. f *. zero_m_array.(m).(k) ) )
| 0 -> Array.map2 ( *. ) zero_m_array.(m) coef_prod | 0 -> Array.map2 ( *. ) zero_m_array.(m) coef_prod
| totAngMom_a -> | totAngMom_a ->
let key = Zkey.of_int_tuple (Zkey.Three angMom_a) let key = Zkey.of_int_tuple (Zkey.Three angMom_a)
@ -52,138 +52,138 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
try Zmap.find map_1d.(m) key with try Zmap.find map_1d.(m) key with
| Not_found -> | Not_found ->
let result = let result =
let am, amm, amxyz, xyz = let am, amm, amxyz, xyz =
match angMom_a with match angMom_a with
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0 | (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1 | (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2 | (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
in in
if amxyz < 0 then empty else if amxyz < 0 then empty else
let v1 = let v1 =
let f = let f =
-. expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz) -. expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)
in in
if (abs_float f < cutoff) then empty else if (abs_float f < cutoff) then empty else
Array.map (fun v1k -> f *. v1k) (vrr0_v m am (totAngMom_a-1) ) Array.map (fun v1k -> f *. v1k) (vrr0_v m am (totAngMom_a-1) )
in in
let p1 = let p1 =
Array.mapi (fun k v2k -> v1.(k) +. expo_inv_p *. (Coordinate.coord center_pq.(k) xyz) *. v2k) (vrr0_v (m+1) am (totAngMom_a-1)) Array.mapi (fun k v2k -> v1.(k) +. expo_inv_p *. (Coordinate.coord center_pq.(k) xyz) *. v2k) (vrr0_v (m+1) am (totAngMom_a-1))
in in
if amxyz < 1 then p1 else if amxyz < 1 then p1 else
let f = (float_of_int amxyz) *. expo_inv_p *. 0.5 let f = (float_of_int amxyz) *. expo_inv_p *. 0.5
in in
if (abs_float f < cutoff) then empty else if (abs_float f < cutoff) then empty else
let v1 = vrr0_v m amm (totAngMom_a-2) let v1 = vrr0_v m amm (totAngMom_a-2)
in in
let v2 = let v2 =
if (abs_float (f *. expo_inv_p)) < cutoff then empty else if (abs_float (f *. expo_inv_p)) < cutoff then empty else
vrr0_v (m+1) amm (totAngMom_a-2) vrr0_v (m+1) amm (totAngMom_a-2)
in in
Array.init ncoef (fun k -> p1.(k) +. Array.init ncoef (fun k -> p1.(k) +.
f *. (v1.(k) +. v2.(k) *. expo_inv_p ) ) f *. (v1.(k) +. v2.(k) *. expo_inv_p ) )
in Zmap.add map_1d.(m) key result; in Zmap.add map_1d.(m) key result;
result result
and vrr_v m angMom_a angMom_c totAngMom_a totAngMom_c = and vrr_v m angMom_a angMom_c totAngMom_a totAngMom_c =
match (totAngMom_a, totAngMom_c) with match (totAngMom_a, totAngMom_c) with
| (i,0) -> if (i>0) then | (i,0) -> if (i>0) then
vrr0_v m angMom_a totAngMom_a vrr0_v m angMom_a totAngMom_a
else else
Array.map2 ( *. ) zero_m_array.(m) coef_prod Array.map2 ( *. ) zero_m_array.(m) coef_prod
| (_,_) -> | (_,_) ->
let key = Zkey.of_int_tuple (Zkey.Six (angMom_a, angMom_c)) let key = Zkey.of_int_tuple (Zkey.Six (angMom_a, angMom_c))
in in
try Zmap.find map_2d.(m) key with try Zmap.find map_2d.(m) key with
| Not_found -> | Not_found ->
let result = let result =
begin begin
let am, cm, cmm, axyz, cxyz, xyz = let am, cm, cmm, axyz, cxyz, xyz =
let (aax, aay, aaz) = angMom_a let (aax, aay, aaz) = angMom_a
and (acx, acy, acz) = angMom_c in and (acx, acy, acz) = angMom_c in
if (acz > 0) then if (acz > 0) then
(aax, aay, aaz-1), (aax, aay, aaz-1),
(acx, acy, acz-1), (acx, acy, acz-1),
(acx, acy, acz-2), (acx, acy, acz-2),
aaz, acz, 2 aaz, acz, 2
else if (acy > 0) then else if (acy > 0) then
(aax, aay-1,aaz), (aax, aay-1,aaz),
(acx, acy-1,acz), (acx, acy-1,acz),
(acx, acy-2,acz), (acx, acy-2,acz),
aay,acy, 1 aay,acy, 1
else else
(aax-1,aay,aaz), (aax-1,aay,aaz),
(acx-1,acy,acz), (acx-1,acy,acz),
(acx-2,acy,acz), (acx-2,acy,acz),
aax,acx, 0 aax,acx, 0
in in
(* (*
if cxyz < 1 then empty else if cxyz < 1 then empty else
*) *)
let f1 = let f1 =
Array.init ncoef (fun k -> Array.init ncoef (fun k ->
expo_d.(k) *. expo_inv_q.(k) *. expo_d.(k) *. expo_inv_q.(k) *.
(Coordinate.coord center_cd.(k) xyz) ) (Coordinate.coord center_cd.(k) xyz) )
in in
let f2 = let f2 =
Array.init ncoef (fun k -> Array.init ncoef (fun k ->
expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz) ) expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz) )
in in
let v1 = let v1 =
if (at_least_one_valid f1) then if (at_least_one_valid f1) then
vrr_v m angMom_a cm totAngMom_a (totAngMom_c-1) vrr_v m angMom_a cm totAngMom_a (totAngMom_c-1)
else empty else empty
and v2 = and v2 =
if (at_least_one_valid f2) then if (at_least_one_valid f2) then
vrr_v (m+1) angMom_a cm totAngMom_a (totAngMom_c-1) vrr_v (m+1) angMom_a cm totAngMom_a (totAngMom_c-1)
else empty else empty
in in
let p1 = let p1 =
Array.init ncoef (fun k -> -. v1.(k) *. f1.(k) -. v2.(k) *. f2.(k)) Array.init ncoef (fun k -> -. v1.(k) *. f1.(k) -. v2.(k) *. f2.(k))
in in
let p2 = let p2 =
if cxyz < 2 then p1 else if cxyz < 2 then p1 else
let fcm = let fcm =
(float_of_int (cxyz-1)) *. 0.5 (float_of_int (cxyz-1)) *. 0.5
in in
let f1 = let f1 =
Array.map (fun e -> fcm *. e) expo_inv_q Array.map (fun e -> fcm *. e) expo_inv_q
in in
let f2 = let f2 =
Array.map2 ( *. ) f1 expo_inv_q Array.map2 ( *. ) f1 expo_inv_q
in in
let v1 = let v1 =
if (at_least_one_valid f1) then if (at_least_one_valid f1) then
vrr_v m angMom_a cmm totAngMom_a (totAngMom_c-2) vrr_v m angMom_a cmm totAngMom_a (totAngMom_c-2)
else empty else empty
in in
let v2 = let v2 =
if (at_least_one_valid f2) then if (at_least_one_valid f2) then
vrr_v (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2) vrr_v (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2)
else empty else empty
in in
Array.init ncoef (fun k -> p1.(k) +. f1.(k) *. v1.(k) +. f2.(k) *. v2.(k)) Array.init ncoef (fun k -> p1.(k) +. f1.(k) *. v1.(k) +. f2.(k) *. v2.(k))
in in
if (axyz < 1) || (cxyz < 1) then p2 else if (axyz < 1) || (cxyz < 1) then p2 else
let fa = let fa =
(float_of_int axyz) *. expo_inv_p *. 0.5 (float_of_int axyz) *. expo_inv_p *. 0.5
in in
let f1 = let f1 =
Array.map (fun e -> fa *. e ) expo_inv_q Array.map (fun e -> fa *. e ) expo_inv_q
in in
if (at_least_one_valid f1) then if (at_least_one_valid f1) then
let v = let v =
vrr_v (m+1) am cm (totAngMom_a-1) (totAngMom_c-1) vrr_v (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
in in
Array.init ncoef (fun k -> p2.(k) -. f1.(k) *. v.(k)) Array.init ncoef (fun k -> p2.(k) -. f1.(k) *. v.(k))
else p2 else p2
end end
in Zmap.add map_2d.(m) key result; in Zmap.add map_2d.(m) key result;
result result
@ -203,14 +203,14 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
| 1 -> | 1 ->
let (aax, aay, aaz) = angMom_a in let (aax, aay, aaz) = angMom_a in
let ap, xyz = let ap, xyz =
match angMom_b with match angMom_b with
| (_,_,1) -> (aax,aay,aaz+1), 2 | (_,_,1) -> (aax,aay,aaz+1), 2
| (_,1,_) -> (aax,aay+1,aaz), 1 | (_,1,_) -> (aax,aay+1,aaz), 1
| (_,_,_) -> (aax+1,aay,aaz), 0 | (_,_,_) -> (aax+1,aay,aaz), 0
in in
let f = Coordinate.coord center_ab xyz in let f = Coordinate.coord center_ab xyz in
let v1 = let v1 =
vrr_v 0 ap angMom_c (totAngMom_a+1) totAngMom_c vrr_v 0 ap angMom_c (totAngMom_a+1) totAngMom_c
in in
if (abs_float f < cutoff) then v1 else if (abs_float f < cutoff) then v1 else
let v2 = let v2 =
@ -221,36 +221,36 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
let (aax, aay, aaz) = angMom_a let (aax, aay, aaz) = angMom_a
and (abx, aby, abz) = angMom_b in and (abx, aby, abz) = angMom_b in
let bxyz, xyz = let bxyz, xyz =
match angMom_b with match angMom_b with
| (0,0,_) -> abz, 2 | (0,0,_) -> abz, 2
| (0,_,_) -> aby, 1 | (0,_,_) -> aby, 1
| _ -> abx, 0 | _ -> abx, 0
in in
if (bxyz < 1) then empty else if (bxyz < 1) then empty else
let ap, bm = let ap, bm =
match xyz with match xyz with
| 0 -> (aax+1,aay,aaz),(abx-1,aby,abz) | 0 -> (aax+1,aay,aaz),(abx-1,aby,abz)
| 1 -> (aax,aay+1,aaz),(abx,aby-1,abz) | 1 -> (aax,aay+1,aaz),(abx,aby-1,abz)
| _ -> (aax,aay,aaz+1),(abx,aby,abz-1) | _ -> (aax,aay,aaz+1),(abx,aby,abz-1)
in in
let h1 = let h1 =
hrr0_v ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c hrr0_v ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
in in
let f = (Coordinate.coord center_ab xyz) in let f = (Coordinate.coord center_ab xyz) in
if (abs_float f < cutoff) then h1 else if (abs_float f < cutoff) then h1 else
let h2 = let h2 =
hrr0_v angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c hrr0_v angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in Array.map2 (fun h1 h2 -> h1 +. h2 *. f) h1 h2 in Array.map2 (fun h1 h2 -> h1 +. h2 *. f) h1 h2
and hrr_v angMom_a angMom_b angMom_c angMom_d and hrr_v angMom_a angMom_b angMom_c angMom_d
totAngMom_a totAngMom_b totAngMom_c totAngMom_d = totAngMom_a totAngMom_b totAngMom_c totAngMom_d =
match (totAngMom_b, totAngMom_d) with match (totAngMom_b, totAngMom_d) with
| (_,0) -> if (totAngMom_b = 0) then | (_,0) -> if (totAngMom_b = 0) then
vrr_v 0 angMom_a angMom_c totAngMom_a totAngMom_c vrr_v 0 angMom_a angMom_c totAngMom_a totAngMom_c
else else
hrr0_v angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c hrr0_v angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
| (_,_) -> | (_,_) ->
let (acx, acy, acz) = angMom_c let (acx, acy, acz) = angMom_c
and (adx, ady, adz) = angMom_d in and (adx, ady, adz) = angMom_d in
@ -314,32 +314,32 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
contracted_class.(0) <- contracted_class.(0) <-
Array.fold_left Array.fold_left
(fun accu shell_ab -> accu +. (fun accu shell_ab -> accu +.
Array.fold_left (fun accu shell_cd -> Array.fold_left (fun accu shell_cd ->
let coef_prod = let coef_prod =
shell_ab.Shell_pair.coef *. shell_cd.Shell_pair.coef shell_ab.Shell_pair.coef *. shell_cd.Shell_pair.coef
in in
(** Screening on the product of coefficients *) (** Screening on the product of coefficients *)
try try
if (abs_float coef_prod) < 1.e-3*.cutoff then if (abs_float coef_prod) < 1.e-3*.cutoff then
raise NullQuartet; raise NullQuartet;
let expo_pq_inv = let expo_pq_inv =
shell_ab.Shell_pair.expo_inv +. shell_cd.Shell_pair.expo_inv shell_ab.Shell_pair.expo_inv +. shell_cd.Shell_pair.expo_inv
in in
let center_pq = let center_pq =
Coordinate.(shell_ab.Shell_pair.center |- shell_cd.Shell_pair.center) Coordinate.(shell_ab.Shell_pair.center |- shell_cd.Shell_pair.center)
in in
let norm_pq_sq = let norm_pq_sq =
Coordinate.dot center_pq center_pq Coordinate.dot center_pq center_pq
in in
let zero_m_array = let zero_m_array =
zero_m ~maxm:0 ~expo_pq_inv ~norm_pq_sq zero_m ~maxm:0 ~expo_pq_inv ~norm_pq_sq
in in
accu +. coef_prod *. zero_m_array.(0) accu +. coef_prod *. zero_m_array.(0)
with NullQuartet -> accu with NullQuartet -> accu
) 0. shell_q ) 0. shell_q
) 0. shell_p ) 0. shell_p
| _ -> | _ ->
@ -368,18 +368,18 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
let d = shell_cd.Shell_pair.j in let d = shell_cd.Shell_pair.j in
(zero_m_array, shell_cd.Shell_pair.expo_inv, (zero_m_array, shell_cd.Shell_pair.expo_inv,
Contracted_shell.expo shell_d d, shell_cd.Shell_pair.center_ab, Contracted_shell.expo shell_d d, shell_cd.Shell_pair.center_ab,
center_pq,coef_prod) center_pq,coef_prod)
) shell_q ) shell_q
|> Array.to_list |> Array.to_list
|> List.filter (fun (zero_m_array, expo_inv, d, center_cd, |> List.filter (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> abs_float coef_prod >= 1.e-4 *. cutoff) center_pq,coef_prod) -> abs_float coef_prod >= 1.e-4 *. cutoff)
|> Array.of_list |> Array.of_list
in in
let zero_m_array = Array.map (fun (zero_m_array, expo_inv, d, center_cd, let zero_m_array = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> zero_m_array) common center_pq,coef_prod) -> zero_m_array) common
and expo_inv = Array.map (fun (zero_m_array, expo_inv, d, center_cd, and expo_inv = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> expo_inv ) common center_pq,coef_prod) -> expo_inv ) common
and d = Array.map (fun (zero_m_array, expo_inv, d, center_cd, and d = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> d) common center_pq,coef_prod) -> d) common
and center_cd = Array.map (fun (zero_m_array, expo_inv, d, center_cd, and center_cd = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
@ -393,48 +393,48 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
*) *)
let zero_m_array = let zero_m_array =
let result = Array.init (maxm+1) (fun _ -> let result = Array.init (maxm+1) (fun _ ->
Array.make (Array.length coef_prod) 0.) Array.make (Array.length coef_prod) 0.)
in in
for m=0 to maxm do for m=0 to maxm do
for k=0 to (Array.length coef_prod-1) do for k=0 to (Array.length coef_prod-1) do
result.(m).(k) <- zero_m_array.(k).(m) result.(m).(k) <- zero_m_array.(k).(m)
done; done;
done; done;
result result
in in
(* Compute the integral class from the primitive shell quartet *) (* Compute the integral class from the primitive shell quartet *)
let map_1d = Array.init maxm (fun _ -> Zmap.create (4*maxm)) in let map_1d = Array.init maxm (fun _ -> Zmap.create (4*maxm)) in
let map_2d = Array.init maxm (fun _ -> Zmap.create (Array.length class_indices)) in let map_2d = Array.init maxm (fun _ -> Zmap.create (Array.length class_indices)) in
let norm = let norm =
let norm_coef_scale_q = shell_q.(0).Shell_pair.norm_coef_scale in let norm_coef_scale_q = shell_q.(0).Shell_pair.norm_coef_scale in
Array.map (fun v1 -> Array.map (fun v1 ->
Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q
) norm_coef_scale_p ) norm_coef_scale_p
|> Array.to_list |> Array.to_list
|> Array.concat |> Array.concat
in in
Array.iteri (fun i key -> Array.iteri (fun i key ->
let a = Zkey.to_int_array Zkey.Kind_12 key in let a = Zkey.to_int_array Zkey.Kind_12 key in
let (angMomA,angMomB,angMomC,angMomD) = let (angMomA,angMomB,angMomC,angMomD) =
( [| a.(0) ; a.(1) ; a.(2) |], ( [| a.(0) ; a.(1) ; a.(2) |],
[| a.(3) ; a.(4) ; a.(5) |], [| a.(3) ; a.(4) ; a.(5) |],
[| a.(6) ; a.(7) ; a.(8) |], [| a.(6) ; a.(7) ; a.(8) |],
[| a.(9) ; a.(10) ; a.(11) |] ) [| a.(9) ; a.(10) ; a.(11) |] )
in in
let integral = let integral =
hvrr_two_e_vector (angMomA, angMomB, angMomC, angMomD) hvrr_two_e_vector (angMomA, angMomB, angMomC, angMomD)
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b, (Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b,
Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d) Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d)
(maxm, zero_m_array) (maxm, zero_m_array)
(Contracted_shell.expo shell_b b, d) (Contracted_shell.expo shell_b b, d)
(shell_ab.Shell_pair.expo_inv, expo_inv) (shell_ab.Shell_pair.expo_inv, expo_inv)
(shell_ab.Shell_pair.center_ab, center_cd, center_pq) (shell_ab.Shell_pair.center_ab, center_cd, center_pq)
coef_prod map_1d map_2d coef_prod map_1d map_2d
in in
let x = Array.fold_left (+.) 0. integral in let x = Array.fold_left (+.) 0. integral in
contracted_class.(i) <- contracted_class.(i) +. x *. norm.(i) contracted_class.(i) <- contracted_class.(i) +. x *. norm.(i)
) class_indices ) class_indices
) shell_p ) shell_p
end; end;

View File

@ -34,24 +34,24 @@ let incomplete_gamma ~alpha x =
let r0 = exp (a *. log x -. x -. loggamma_a) /. a in let r0 = exp (a *. log x -. x -. loggamma_a) /. a in
pg_loop min_float r0 r0 1. pg_loop min_float r0 r0 1.
and q_gamma a x loggamma_a = and q_gamma a x loggamma_a =
if x < 1. +. a then 1. -. p_gamma a x loggamma_a if x < 1. +. a then 1. -. p_gamma a x loggamma_a
else else
let rec qg_loop prev res la lb w k = let rec qg_loop prev res la lb w k =
if k > 1000. then failwith "q_gamma did not converge." if k > 1000. then failwith "q_gamma did not converge."
else if prev = res then res else if prev = res then res
else else
let k_inv = 1. /. k in let k_inv = 1. /. k in
let la, lb = let la, lb =
lb, ((k -. 1. -. a) *. (lb -. la) +. (k +. x) *. lb) *. k_inv lb, ((k -. 1. -. a) *. (lb -. la) +. (k +. x) *. lb) *. k_inv
in in
let w = w *. (k -. 1. -. a) *. k_inv in let w = w *. (k -. 1. -. a) *. k_inv in
let prev, res = res, res +. w /. (la *. lb) in let prev, res = res, res +. w /. (la *. lb) in
qg_loop prev res la lb w (k +. 1.) qg_loop prev res la lb w (k +. 1.)
in in
let w = exp (a *. log x -. x -. loggamma_a) in let w = exp (a *. log x -. x -. loggamma_a) in
let lb = (1. +. x -. a) in let lb = (1. +. x -. a) in
qg_loop min_float (w /. lb) 1. lb w 2.0 qg_loop min_float (w /. lb) 1. lb w 2.0
in in
let gf = gamma_float alpha in let gf = gamma_float alpha in
gf *. p_gamma alpha x (log gf) gf *. p_gamma alpha x (log gf)
@ -62,12 +62,12 @@ let incomplete_gamma ~alpha x =
let fact_memo = let fact_memo =
let rec aux accu_l accu = function let rec aux accu_l accu = function
| 0 -> aux [1.] 1. 1 | 0 -> aux [1.] 1. 1
| i when (i = factmax) -> | i when (i = factmax) ->
let x = (float_of_int factmax) *. accu in let x = (float_of_int factmax) *. accu in
List.rev (x::accu_l) List.rev (x::accu_l)
| i -> let x = (float_of_int i) *. accu in | i -> let x = (float_of_int i) *. accu in
aux (x::accu_l) x (i+1) aux (x::accu_l) x (i+1)
in in
aux [] 0. 0 aux [] 0. 0
|> Array.of_list |> Array.of_list
@ -114,8 +114,8 @@ let boys_function ~maxm t =
| 0 -> | 0 ->
begin begin
if t = 0. then [| 1. |] else if t = 0. then [| 1. |] else
let sq_t = sqrt t in let sq_t = sqrt t in
[| (sq_pi_over_two /. sq_t) *. erf_float sq_t |] [| (sq_pi_over_two /. sq_t) *. erf_float sq_t |]
end end
| _ -> | _ ->
begin begin