mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-07-25 12:17:25 +02:00
Optimization
This commit is contained in:
parent
fb8fff6ee1
commit
49c503fa55
@ -1,4 +1,5 @@
|
|||||||
open Util
|
open Util
|
||||||
|
open Constants
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
expo : float array;
|
expo : float array;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
(** Electron-electron repulsion integrals *)
|
(** Electron-electron repulsion integrals *)
|
||||||
|
|
||||||
open Util
|
open Util
|
||||||
|
open Constants
|
||||||
|
|
||||||
(** (00|00)^m : Fundamental electron repulsion integral
|
(** (00|00)^m : Fundamental electron repulsion integral
|
||||||
$ \int \int \phi_p(r1) 1/r_{12} \phi_q(r2) dr_1 dr_2 $
|
$ \int \int \phi_p(r1) 1/r_{12} \phi_q(r2) dr_1 dr_2 $
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
open Util
|
open Util
|
||||||
|
open Constants
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
expo : float;
|
expo : float;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
open Util
|
open Util
|
||||||
|
open Constants
|
||||||
|
|
||||||
let cutoff2 = cutoff *. cutoff
|
let cutoff2 = cutoff *. cutoff
|
||||||
let debug = false
|
let debug = false
|
||||||
@ -12,10 +13,10 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
(expo_b, expo_d)
|
(expo_b, expo_d)
|
||||||
(expo_inv_p, expo_inv_q)
|
(expo_inv_p, expo_inv_q)
|
||||||
(center_ab, center_cd, center_pq)
|
(center_ab, center_cd, center_pq)
|
||||||
map
|
map_1d map_2d
|
||||||
=
|
=
|
||||||
|
|
||||||
let totAngMom_a = Angular_momentum.to_int totAngMom_a
|
(* 2_011_273 *) let totAngMom_a = Angular_momentum.to_int totAngMom_a
|
||||||
and totAngMom_b = Angular_momentum.to_int totAngMom_b
|
and totAngMom_b = Angular_momentum.to_int totAngMom_b
|
||||||
and totAngMom_c = Angular_momentum.to_int totAngMom_c
|
and totAngMom_c = Angular_momentum.to_int totAngMom_c
|
||||||
and totAngMom_d = Angular_momentum.to_int totAngMom_d
|
and totAngMom_d = Angular_momentum.to_int totAngMom_d
|
||||||
@ -38,30 +39,27 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
|
|
||||||
(** Vertical recurrence relations *)
|
(** Vertical recurrence relations *)
|
||||||
let rec vrr0 angMom_a totAngMom_a =
|
let rec vrr0 angMom_a totAngMom_a =
|
||||||
if debug then
|
(* 1_137_164 *) if debug then
|
||||||
Printf.printf "vrr0: %d : %d %d %d\n" totAngMom_a angMom_a.(0) angMom_a.(1) angMom_a.(2);
|
Printf.printf "vrr0: %d : %d %d %d\n" totAngMom_a angMom_a.(0) angMom_a.(1) angMom_a.(2);
|
||||||
match totAngMom_a with
|
match totAngMom_a with
|
||||||
| 0 -> zero_m_array
|
| 0 -> (* 66_288 *) zero_m_array
|
||||||
| _ ->
|
| _ ->
|
||||||
let maxsze = maxm+1 in
|
(* 1_070_876 *) let maxsze = maxm+1 in
|
||||||
let key = Zkey.of_int_tuple (Zkey.Three
|
let key = Zkey.of_int_tuple (Zkey.Three
|
||||||
(angMom_a.(0)+1, angMom_a.(1)+1, angMom_a.(2)+1) )
|
(angMom_a.(0)+1, angMom_a.(1)+1, angMom_a.(2)+1) )
|
||||||
in
|
in
|
||||||
|
|
||||||
try Zmap.find map key with
|
try Zmap.find map_1d key with
|
||||||
| Not_found ->
|
| Not_found ->
|
||||||
let result =
|
let result =
|
||||||
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in
|
||||||
and amm = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
|
||||||
in
|
|
||||||
let xyz =
|
let xyz =
|
||||||
match angMom_a with
|
match angMom_a with
|
||||||
| [|_;0;0|] -> 0
|
| [|_;0;0|] -> (* 28_336 *) 0
|
||||||
| [|_;_;0|] -> 1
|
| [|_;_;0|] -> (* 52_221 *) 1
|
||||||
| _ -> 2
|
| _ -> (* 87_215 *) 2
|
||||||
in
|
in
|
||||||
am.(xyz) <- am.(xyz) - 1;
|
am.(xyz) <- am.(xyz) - 1;
|
||||||
amm.(xyz) <- amm.(xyz) - 2;
|
|
||||||
if am.(xyz) < 0 then empty else
|
if am.(xyz) < 0 then empty else
|
||||||
let v1 =
|
let v1 =
|
||||||
vrr0 am (totAngMom_a-1)
|
vrr0 am (totAngMom_a-1)
|
||||||
@ -69,54 +67,53 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
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 amm.(xyz) < 0 then
|
if am.(xyz) < 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) )
|
(* 544_860 *) if m = maxm then 0. else (f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
|
||||||
else
|
else
|
||||||
let f3 = (float_of_int am.(xyz)) *. expo_inv_p *. 0.5 in
|
let f3 = (float_of_int am.(xyz)) *. expo_inv_p *. 0.5 in
|
||||||
|
let amm = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in
|
||||||
|
let () = amm.(xyz) <- amm.(xyz) - 2 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 (f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
|
(* 484_257 *) (if m = maxm then 0. else
|
||||||
+. f3 *. (v3.(m) +. if m = maxm then 0. else
|
(f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
|
||||||
|
+. 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 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
|
(* 11_580_843 *) if debug then
|
||||||
Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2);
|
Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2);
|
||||||
|
|
||||||
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) -> (* 959_629 *) if (i>0) then vrr0 angMom_a totAngMom_a else zero_m_array
|
||||||
| (_,_) ->
|
| (_,_) ->
|
||||||
|
|
||||||
let maxsze = maxm+1 in
|
(* 10_621_214 *) let maxsze = maxm+1 in
|
||||||
let key = Zkey.of_int_tuple (Zkey.Six
|
let key = Zkey.of_int_tuple (Zkey.Six
|
||||||
((angMom_a.(0)+1, angMom_a.(1)+1, angMom_a.(2)+1),
|
((angMom_a.(0)+1, angMom_a.(1)+1, angMom_a.(2)+1),
|
||||||
(angMom_c.(0)+1, angMom_c.(1)+1, angMom_c.(2)+1)) )
|
(angMom_c.(0)+1, angMom_c.(1)+1, angMom_c.(2)+1)) )
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
try Zmap.find map key with
|
try Zmap.find map_2d key with
|
||||||
| Not_found ->
|
| Not_found ->
|
||||||
let result =
|
let result =
|
||||||
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
let cm = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |] in
|
||||||
and cm = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
let xyz =
|
||||||
and cmm = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
|
||||||
and xyz =
|
|
||||||
match angMom_c with
|
match angMom_c with
|
||||||
| [|_;0;0|] -> 0
|
| [|_;0;0|] -> (* 321_984 *) 0
|
||||||
| [|_;_;0|] -> 1
|
| [|_;_;0|] -> (* 612_002 *) 1
|
||||||
| _ -> 2
|
| _ -> (* 1_067_324 *) 2
|
||||||
in
|
in
|
||||||
am.(xyz) <- am.(xyz) - 1;
|
|
||||||
cm.(xyz) <- cm.(xyz) - 1;
|
cm.(xyz) <- cm.(xyz) - 1;
|
||||||
cmm.(xyz) <- cmm.(xyz) - 2;
|
|
||||||
if cm.(xyz) < 0 then empty else
|
if cm.(xyz) < 0 then empty else
|
||||||
let f1 =
|
let f1 =
|
||||||
-. expo_d *. expo_inv_q *. (Coordinate.coord center_cd xyz)
|
-. expo_d *. expo_inv_q *. (Coordinate.coord center_cd xyz)
|
||||||
@ -129,22 +126,28 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
let v1 =
|
let v1 =
|
||||||
vrr angMom_a cm totAngMom_a (totAngMom_c-1)
|
vrr angMom_a cm totAngMom_a (totAngMom_c-1)
|
||||||
in
|
in
|
||||||
Array.init (maxsze) (fun m ->
|
Array.init maxsze (fun m ->
|
||||||
f1 *. v1.(m) -. (if m = maxm then 0. else f2 *. v1.(m+1)) )
|
(* 9_232_029 *) f1 *. v1.(m) -. (if m = maxm then 0. else f2 *. v1.(m+1)) )
|
||||||
in
|
in
|
||||||
let result =
|
let result =
|
||||||
if cmm.(xyz) < 0 then result else
|
if cm.(xyz) < 1 then result else
|
||||||
let f3 =
|
let f3 =
|
||||||
(float_of_int cm.(xyz)) *. expo_inv_q *. 0.5
|
(float_of_int cm.(xyz)) *. expo_inv_q *. 0.5
|
||||||
in
|
in
|
||||||
if (abs_float f3 < cutoff) && (abs_float (f3 *. expo_inv_q) < cutoff) then result else
|
if (abs_float f3 < cutoff) && (abs_float (f3 *. expo_inv_q) < cutoff) then result else
|
||||||
|
(
|
||||||
|
let cmm = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |] in
|
||||||
|
cmm.(xyz) <- cmm.(xyz) - 2;
|
||||||
let v3 =
|
let v3 =
|
||||||
vrr angMom_a cmm totAngMom_a (totAngMom_c-2)
|
vrr angMom_a cmm totAngMom_a (totAngMom_c-2)
|
||||||
in
|
in
|
||||||
Array.init (maxsze) (fun m -> result.(m) +.
|
Array.init maxsze (fun m -> (* 7_322_025 *) result.(m) +.
|
||||||
f3 *. (v3.(m) +. (if m=maxm then 0. else expo_inv_q *. v3.(m+1)) ))
|
f3 *. (v3.(m) +. (if m=maxm then 0. else expo_inv_q *. v3.(m+1)) ))
|
||||||
|
)
|
||||||
in
|
in
|
||||||
let result =
|
let result =
|
||||||
|
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in
|
||||||
|
am.(xyz) <- am.(xyz) - 1;
|
||||||
if am.(xyz) lor cm.(xyz) < 0 then result else
|
if am.(xyz) lor cm.(xyz) < 0 then result else
|
||||||
let f5 =
|
let f5 =
|
||||||
(float_of_int angMom_a.(xyz)) *. expo_inv_p *. expo_inv_q *. 0.5
|
(float_of_int angMom_a.(xyz)) *. expo_inv_p *. expo_inv_q *. 0.5
|
||||||
@ -154,10 +157,10 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
vrr am cm (totAngMom_a-1) (totAngMom_c-1)
|
vrr am cm (totAngMom_a-1) (totAngMom_c-1)
|
||||||
in
|
in
|
||||||
Array.init (maxsze) (fun m ->
|
Array.init (maxsze) (fun m ->
|
||||||
result.(m) -. (if m = maxm then 0. else f5 *. v5.(m+1)))
|
(* 7_963_213 *) result.(m) -. (if m = maxm then 0. else f5 *. v5.(m+1)))
|
||||||
in
|
in
|
||||||
result
|
result
|
||||||
in Zmap.add map key result;
|
in Zmap.add map_2d key result;
|
||||||
result
|
result
|
||||||
|
|
||||||
|
|
||||||
@ -168,13 +171,13 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
and hrr0 angMom_a angMom_b angMom_c
|
and hrr0 angMom_a angMom_b angMom_c
|
||||||
totAngMom_a totAngMom_b totAngMom_c =
|
totAngMom_a totAngMom_b totAngMom_c =
|
||||||
|
|
||||||
if debug then
|
(* 8_448_486 *) if debug then
|
||||||
Printf.printf "hrr0: %d %d %d : %d %d %d %d %d %d %d %d %d\n" totAngMom_a totAngMom_b totAngMom_c angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_b.(0) angMom_b.(1) angMom_b.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2);
|
Printf.printf "hrr0: %d %d %d : %d %d %d %d %d %d %d %d %d\n" totAngMom_a totAngMom_b totAngMom_c angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_b.(0) angMom_b.(1) angMom_b.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2);
|
||||||
|
|
||||||
match totAngMom_b with
|
match totAngMom_b with
|
||||||
| 0 -> (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
|
| 0 -> (* 0 *) (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
|
||||||
| 1 ->
|
| 1 ->
|
||||||
let xyz = if angMom_b.(0) = 1 then 0 else if angMom_b.(1) = 1 then 1 else 2 in
|
(* 5_045_008 *) let xyz = if angMom_b.(0) = 1 then 0 else if angMom_b.(1) = 1 then 1 else 2 in
|
||||||
let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in
|
let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in
|
||||||
ap.(xyz) <- ap.(xyz) + 1;
|
ap.(xyz) <- ap.(xyz) + 1;
|
||||||
let v1 =
|
let v1 =
|
||||||
@ -189,13 +192,13 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
in
|
in
|
||||||
v1.(0) +. f2 *. v2.(0)
|
v1.(0) +. f2 *. v2.(0)
|
||||||
| _ ->
|
| _ ->
|
||||||
let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
(* 3_403_478 *) let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
||||||
and bm = [| angMom_b.(0) ; angMom_b.(1) ; angMom_b.(2) |]
|
and bm = [| angMom_b.(0) ; angMom_b.(1) ; angMom_b.(2) |]
|
||||||
and xyz =
|
and xyz =
|
||||||
match angMom_b with
|
match angMom_b with
|
||||||
| [|_;0;0|] -> 0
|
| [|_;0;0|] -> (* 677_315 *) 0
|
||||||
| [|_;_;0|] -> 1
|
| [|_;_;0|] -> (* 1_136_646 *) 1
|
||||||
| _ -> 2
|
| _ -> (* 1_589_517 *) 2
|
||||||
in
|
in
|
||||||
ap.(xyz) <- ap.(xyz) + 1;
|
ap.(xyz) <- ap.(xyz) + 1;
|
||||||
bm.(xyz) <- bm.(xyz) - 1;
|
bm.(xyz) <- bm.(xyz) - 1;
|
||||||
@ -215,20 +218,22 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
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
|
(* 7_738_602 *) if debug then
|
||||||
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 angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_b.(0) angMom_b.(1) angMom_b.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2) angMom_d.(0) angMom_d.(1) angMom_d.(2);
|
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 angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_b.(0) angMom_b.(1) angMom_b.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2) angMom_d.(0) angMom_d.(1) angMom_d.(2);
|
||||||
|
|
||||||
match (totAngMom_b, totAngMom_d) with
|
match (totAngMom_b, totAngMom_d) with
|
||||||
| (0,0) -> (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
|
| (_,0) -> (* 3_608_781 *) if (totAngMom_b = 0) then
|
||||||
| (_,0) -> hrr0 angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
|
(vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
|
||||||
|
else
|
||||||
|
hrr0 angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
|
||||||
| (_,_) ->
|
| (_,_) ->
|
||||||
let cp = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
(* 4_130_325 *) let cp = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
||||||
and dm = [| angMom_d.(0) ; angMom_d.(1) ; angMom_d.(2) |]
|
and dm = [| angMom_d.(0) ; angMom_d.(1) ; angMom_d.(2) |]
|
||||||
and xyz =
|
and xyz =
|
||||||
match angMom_d with
|
match angMom_d with
|
||||||
| [|_;0;0|] -> 0
|
| [|_;0;0|] -> (* 1_524_451 *) 0
|
||||||
| [|_;_;0|] -> 1
|
| [|_;_;0|] -> (* 1_302_937 *) 1
|
||||||
| _ -> 2
|
| _ -> (* 1_302_937 *) 2
|
||||||
in
|
in
|
||||||
cp.(xyz) <- cp.(xyz) + 1;
|
cp.(xyz) <- cp.(xyz) + 1;
|
||||||
dm.(xyz) <- dm.(xyz) - 1;
|
dm.(xyz) <- dm.(xyz) - 1;
|
||||||
@ -250,7 +255,7 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
|
|
||||||
let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q : float Zmap.t =
|
let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q : float Zmap.t =
|
||||||
|
|
||||||
let shell_a = shell_p.(0).Shell_pair.shell_a
|
(* 12850 *) let shell_a = shell_p.(0).Shell_pair.shell_a
|
||||||
and shell_b = shell_p.(0).Shell_pair.shell_b
|
and shell_b = shell_p.(0).Shell_pair.shell_b
|
||||||
and shell_c = shell_q.(0).Shell_pair.shell_a
|
and shell_c = shell_q.(0).Shell_pair.shell_a
|
||||||
and shell_d = shell_q.(0).Shell_pair.shell_b
|
and shell_d = shell_q.(0).Shell_pair.shell_b
|
||||||
@ -305,17 +310,18 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
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 =
|
(* 14_700 *) 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
|
(* 15_577 *) let d = shell_q.(cd).Shell_pair.j in
|
||||||
let map = Zmap.create (Array.length class_indices) in
|
let map_1d = Zmap.create (4*maxm) 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
|
(* 165_245 *) Array.map (fun v2 -> (* 2_011_273 *) v1 *. v2) norm_coef_scale_q
|
||||||
) norm_coef_scale_p
|
) norm_coef_scale_p
|
||||||
|> Array.to_list
|
|> Array.to_list
|
||||||
|> Array.concat
|
|> Array.concat
|
||||||
@ -323,7 +329,7 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
(* 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
|
(* 2_011_273 *) 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) |],
|
||||||
@ -363,15 +369,16 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
|
|
||||||
|
|
||||||
let norm = norm_coef_scale.(i) in
|
let norm = norm_coef_scale.(i) in
|
||||||
let integral = chop norm (fun () ->
|
let coef_prod = coef_prod *. norm in
|
||||||
hvrr_two_e (angMomA, angMomB, angMomC, angMomD)
|
let integral =
|
||||||
|
(* 2_011_273 *) 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 )
|
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 -> ()
|
||||||
@ -384,7 +391,7 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
let result =
|
let result =
|
||||||
Zmap.create (Array.length contracted_class)
|
Zmap.create (Array.length contracted_class)
|
||||||
in
|
in
|
||||||
Array.iteri (fun i key -> Zmap.add result key contracted_class.(i)) class_indices;
|
Array.iteri (fun i key -> (* 1_929_480 *) Zmap.add result key contracted_class.(i)) class_indices;
|
||||||
result
|
result
|
||||||
|
|
||||||
|
|
||||||
@ -392,7 +399,7 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
(** Computes all the two-electron integrals of the contracted shell quartet *)
|
(** Computes all the two-electron integrals of the contracted shell quartet *)
|
||||||
let contracted_class ~zero_m shell_a shell_b shell_c shell_d : float Zmap.t =
|
let contracted_class ~zero_m shell_a shell_b shell_c shell_d : float Zmap.t =
|
||||||
|
|
||||||
let shell_p = Shell_pair.create_array ~cutoff shell_a shell_b
|
(* 0 *) let shell_p = Shell_pair.create_array ~cutoff shell_a shell_b
|
||||||
and shell_q = Shell_pair.create_array ~cutoff shell_c shell_d
|
and shell_q = Shell_pair.create_array ~cutoff shell_c shell_d
|
||||||
in
|
in
|
||||||
contracted_class_shell_pairs ~zero_m shell_p shell_q
|
contracted_class_shell_pairs ~zero_m shell_p shell_q
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
open Util
|
open Util
|
||||||
|
|
||||||
|
let cutoff = Constants.cutoff
|
||||||
let cutoff2 = cutoff *. cutoff
|
let cutoff2 = cutoff *. cutoff
|
||||||
|
|
||||||
exception NullQuartet
|
exception NullQuartet
|
||||||
@ -17,7 +18,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
(expo_b, expo_d)
|
(expo_b, expo_d)
|
||||||
(expo_inv_p, expo_inv_q)
|
(expo_inv_p, expo_inv_q)
|
||||||
(center_ab, center_cd, center_pq)
|
(center_ab, center_cd, center_pq)
|
||||||
coef_prod map
|
coef_prod map_1d map_2d
|
||||||
=
|
=
|
||||||
|
|
||||||
let ncoef = (Array.length coef_prod) in
|
let ncoef = (Array.length coef_prod) in
|
||||||
@ -47,7 +48,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
in
|
in
|
||||||
|
|
||||||
let (found, result) =
|
let (found, result) =
|
||||||
try (true, Zmap.find map.(m) key) with
|
try (true, Zmap.find map_1d.(m) key) with
|
||||||
| Not_found -> (false,
|
| Not_found -> (false,
|
||||||
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
||||||
and amm = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
and amm = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
||||||
@ -86,7 +87,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
)
|
)
|
||||||
in
|
in
|
||||||
if not found then
|
if not found then
|
||||||
Zmap.add map.(m) key result;
|
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 =
|
||||||
@ -105,7 +106,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
in
|
in
|
||||||
|
|
||||||
let (found, result) =
|
let (found, result) =
|
||||||
try (true, Zmap.find map.(m) key) with
|
try (true, Zmap.find map_2d.(m) key) with
|
||||||
| Not_found -> (false,
|
| Not_found -> (false,
|
||||||
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
let am = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
||||||
and cm = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
and cm = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
||||||
@ -182,7 +183,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
)
|
)
|
||||||
in
|
in
|
||||||
if not found then
|
if not found then
|
||||||
Zmap.add map.(m) key result;
|
Zmap.add map_2d.(m) key result;
|
||||||
result
|
result
|
||||||
|
|
||||||
|
|
||||||
@ -376,7 +377,8 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
center_pq,coef_prod) -> coef_prod) common
|
center_pq,coef_prod) -> coef_prod) common
|
||||||
in
|
in
|
||||||
(* Compute the integral class from the primitive shell quartet *)
|
(* Compute the integral class from the primitive shell quartet *)
|
||||||
let map = Array.init maxm (fun _ -> Zmap.create (Array.length class_indices)) 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 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 ->
|
||||||
@ -401,11 +403,10 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
|
|||||||
(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
|
coef_prod map_1d map_2d
|
||||||
|> Array.map (fun x -> x *. norm.(i) )
|
|
||||||
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
|
contracted_class.(i) <- contracted_class.(i) +. x *. norm.(i)
|
||||||
) class_indices
|
) class_indices
|
||||||
) shell_p
|
) shell_p
|
||||||
|
|
||||||
|
5
Makefile
5
Makefile
@ -43,6 +43,11 @@ doc: qpackage.odocl
|
|||||||
$(OCAMLBUILD) $*.p.native -use-ocamlfind $(PKGS)
|
$(OCAMLBUILD) $*.p.native -use-ocamlfind $(PKGS)
|
||||||
ln -s $*.p.native $*
|
ln -s $*.p.native $*
|
||||||
|
|
||||||
|
%.p.byte: $(MLFILES) $(MLIFILES) $(MLLFILES) $(MLYFILES)
|
||||||
|
rm -f -- $*
|
||||||
|
$(OCAMLBUILD) -ocamlc ocamlcp $*.byte -use-ocamlfind $(PKGS)
|
||||||
|
ln -s $*.byte $*
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf _build $(ALL_EXE) $(ALL_TESTS) *.native *.byte
|
rm -rf _build $(ALL_EXE) $(ALL_TESTS) *.native *.byte
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
open Util
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
| Bohr of (float * float * float)
|
| Bohr of (float * float * float)
|
||||||
| Angstrom of (float * float * float)
|
| Angstrom of (float * float * float)
|
||||||
|
|
||||||
let a0 = Constants.a0
|
|
||||||
|
|
||||||
let zero = Bohr (0., 0., 0.)
|
let zero = Bohr (0., 0., 0.)
|
||||||
|
|
||||||
let of_float_triplet (x,y,z) = function
|
let of_float_triplet (x,y,z) = function
|
||||||
@ -35,10 +35,10 @@ let (|.) s a =
|
|||||||
|
|
||||||
let to_Angstrom = function
|
let to_Angstrom = function
|
||||||
| Angstrom a -> Angstrom a
|
| Angstrom a -> Angstrom a
|
||||||
| Bohr a -> Angstrom (a0 |. Bohr a |> extract_float_tuple)
|
| Bohr a -> Angstrom (Constants.a0 |. Bohr a |> extract_float_tuple)
|
||||||
|
|
||||||
let to_Bohr = function
|
let to_Bohr = function
|
||||||
| Angstrom a -> Bohr (1./.a0 |. Angstrom a |> extract_float_tuple)
|
| Angstrom a -> Bohr (1./.Constants.a0 |. Angstrom a |> extract_float_tuple)
|
||||||
| Bohr a -> Bohr a
|
| Bohr a -> Bohr a
|
||||||
|
|
||||||
let (|-), (|+) =
|
let (|-), (|+) =
|
||||||
|
@ -3,7 +3,7 @@ external erf_float : float -> float = "erf_float_bytecode" "erf_float" [@@unboxe
|
|||||||
external erfc_float : float -> float = "erfc_float_bytecode" "erfc_float" [@@unboxed] [@@noalloc]
|
external erfc_float : float -> float = "erfc_float_bytecode" "erfc_float" [@@unboxed] [@@noalloc]
|
||||||
external gamma_float : float -> float = "gamma_float_bytecode" "gamma_float" [@@unboxed] [@@noalloc]
|
external gamma_float : float -> float = "gamma_float_bytecode" "gamma_float" [@@unboxed] [@@noalloc]
|
||||||
|
|
||||||
include Constants
|
open Constants
|
||||||
|
|
||||||
let factmax = 150
|
let factmax = 150
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user