mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 12:23:31 +01:00
Vectorized
This commit is contained in:
parent
bdccd66b1a
commit
2d759e736e
@ -14,9 +14,6 @@ let hvrr_two_e m (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
coef_prod map
|
coef_prod map
|
||||||
=
|
=
|
||||||
|
|
||||||
let k = 0 in
|
|
||||||
let getk a = a.(k) in
|
|
||||||
|
|
||||||
let totAngMom_a = Angular_momentum.to_int totAngMom_a
|
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
|
||||||
@ -105,27 +102,38 @@ let hvrr_two_e m (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
am.(xyz) <- am.(xyz) - 1;
|
am.(xyz) <- am.(xyz) - 1;
|
||||||
cm.(xyz) <- cm.(xyz) - 1;
|
cm.(xyz) <- cm.(xyz) - 1;
|
||||||
cmm.(xyz) <- cmm.(xyz) - 2;
|
cmm.(xyz) <- cmm.(xyz) - 2;
|
||||||
Array.mapi (fun k _ ->
|
if cm.(xyz) < 0 then
|
||||||
if cm.(xyz) < 0 then 0. else
|
Array.map (fun _ -> 0.) coef_prod
|
||||||
|
else
|
||||||
let v1 =
|
let v1 =
|
||||||
vrr m angMom_a cm totAngMom_a (totAngMom_c-1)
|
vrr m angMom_a cm totAngMom_a (totAngMom_c-1)
|
||||||
and v2 =
|
and v2 =
|
||||||
vrr (m+1) angMom_a cm totAngMom_a (totAngMom_c-1)
|
vrr (m+1) angMom_a cm totAngMom_a (totAngMom_c-1)
|
||||||
in
|
in
|
||||||
|
let p1 =
|
||||||
|
Array.mapi (fun k _ ->
|
||||||
-. v1.(k) *. expo_d.(k) *. expo_inv_q.(k) *. (Coordinate.coord center_cd.(k) xyz)
|
-. v1.(k) *. expo_d.(k) *. expo_inv_q.(k) *. (Coordinate.coord center_cd.(k) xyz)
|
||||||
-. v2.(k) *. (expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz))
|
-. v2.(k) *. (expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz))
|
||||||
+. (if cmm.(xyz) < 0 then 0. else
|
) coef_prod
|
||||||
|
in
|
||||||
|
let p2 =
|
||||||
|
if cmm.(xyz) < 0 then p1 else
|
||||||
let v1 =
|
let v1 =
|
||||||
vrr m angMom_a cmm totAngMom_a (totAngMom_c-2)
|
vrr m angMom_a cmm totAngMom_a (totAngMom_c-2)
|
||||||
and v2 =
|
and v2 =
|
||||||
vrr (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2)
|
vrr (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2)
|
||||||
in
|
in
|
||||||
((float_of_int cm.(xyz)) *. expo_inv_q.(k) *. 0.5 ) *.(v1.(k) +. expo_inv_q.(k) *. v2.(k) ) )
|
Array.mapi (fun k _ -> p1.(k) +.
|
||||||
-. (if am.(xyz) lor cm.(xyz) < 0 then 0. else
|
((float_of_int cm.(xyz)) *. expo_inv_q.(k) *. 0.5 )
|
||||||
|
*. (v1.(k) +. expo_inv_q.(k) *. v2.(k))
|
||||||
|
) coef_prod
|
||||||
|
in
|
||||||
|
if (am.(xyz) < 0) || (cm.(xyz) < 0) then p2 else
|
||||||
let v =
|
let v =
|
||||||
vrr (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
|
vrr (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
|
||||||
in
|
in
|
||||||
(float_of_int angMom_a.(xyz)) *. expo_inv_p *. expo_inv_q.(k) *. 0.5 *.v.(k) )
|
Array.mapi (fun k _ ->
|
||||||
|
p2.(k) -. (float_of_int angMom_a.(xyz)) *. expo_inv_p *. expo_inv_q.(k) *. 0.5 *.v.(k)
|
||||||
) coef_prod
|
) coef_prod
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
@ -142,17 +150,14 @@ if cm.(xyz) < 0 then 0. else
|
|||||||
|
|
||||||
match totAngMom_b with
|
match totAngMom_b with
|
||||||
| 0 -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|
| 0 -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|
||||||
|> getk
|
|
||||||
| 1 -> let xyz = if angMom_b.(0) = 1 then 0 else if angMom_b.(1) = 1 then 1 else 2 in
|
| 1 -> 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 =
|
||||||
vrr m ap angMom_c (totAngMom_a+1) totAngMom_c
|
vrr m ap angMom_c (totAngMom_a+1) totAngMom_c
|
||||||
|> getk
|
|
||||||
and v2 =
|
and v2 =
|
||||||
vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|
vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|
||||||
|> getk
|
in Array.map2 (fun v1 v2 -> v1 +. v2 *. (Coordinate.coord center_ab xyz) ) v1 v2
|
||||||
in v1 +. v2 *. (Coordinate.coord center_ab xyz)
|
|
||||||
| _ ->
|
| _ ->
|
||||||
let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
|
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) |]
|
||||||
@ -164,19 +169,18 @@ if cm.(xyz) < 0 then 0. else
|
|||||||
in
|
in
|
||||||
ap.(xyz) <- ap.(xyz) + 1;
|
ap.(xyz) <- ap.(xyz) + 1;
|
||||||
bm.(xyz) <- bm.(xyz) - 1;
|
bm.(xyz) <- bm.(xyz) - 1;
|
||||||
if (bm.(xyz) < 0) then 0. else
|
if (bm.(xyz) < 0) then Array.map (fun _ -> 0.) coef_prod else
|
||||||
let h1 =
|
let h1 =
|
||||||
hrr0 m ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
|
hrr0 m ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
|
||||||
and h2 =
|
and h2 =
|
||||||
hrr0 m angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
|
hrr0 m angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
|
||||||
in h1 +. h2 *. (Coordinate.coord center_ab xyz)
|
in Array.map2 (fun h1 h2 -> h1 +. h2 *. (Coordinate.coord center_ab xyz)) h1 h2
|
||||||
|
|
||||||
and hrr m angMom_a angMom_b angMom_c angMom_d
|
and hrr m 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,0) -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|
| (0,0) -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|
||||||
|> getk
|
|
||||||
| (_,0) -> hrr0 m angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
|
| (_,0) -> hrr0 m angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
|
||||||
| (_,_) ->
|
| (_,_) ->
|
||||||
let cp = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
let cp = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]
|
||||||
@ -193,8 +197,7 @@ if cm.(xyz) < 0 then 0. else
|
|||||||
hrr m angMom_a angMom_b cp dm totAngMom_a totAngMom_b (totAngMom_c+1) (totAngMom_d-1) ,
|
hrr m angMom_a angMom_b cp dm totAngMom_a totAngMom_b (totAngMom_c+1) (totAngMom_d-1) ,
|
||||||
hrr m angMom_a angMom_b angMom_c dm totAngMom_a totAngMom_b totAngMom_c (totAngMom_d-1)
|
hrr m angMom_a angMom_b angMom_c dm totAngMom_a totAngMom_b totAngMom_c (totAngMom_d-1)
|
||||||
in
|
in
|
||||||
Array.map (fun center_cd -> h1 +. h2 *. (Coordinate.coord center_cd xyz)) center_cd
|
Array.mapi (fun k center_cd -> h1.(k) +. h2.(k) *. (Coordinate.coord center_cd xyz)) center_cd
|
||||||
|> getk
|
|
||||||
in
|
in
|
||||||
hrr m angMom_a angMom_b angMom_c angMom_d totAngMom_a totAngMom_b
|
hrr m angMom_a angMom_b angMom_c angMom_d totAngMom_a totAngMom_b
|
||||||
totAngMom_c totAngMom_d
|
totAngMom_c totAngMom_d
|
||||||
@ -302,17 +305,18 @@ Array.iter (fun shell_ab ->
|
|||||||
center_pq,coef_prod)
|
center_pq,coef_prod)
|
||||||
) shell_q
|
) shell_q
|
||||||
in
|
in
|
||||||
Array.iteri (fun cd shell_cd ->
|
let zero_m_array = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
|
||||||
try
|
center_pq,coef_prod) -> zero_m_array) common
|
||||||
let (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) = common.(cd)
|
center_pq,coef_prod) -> expo_inv ) common
|
||||||
in
|
and d = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
|
||||||
let zero_m_array = [| zero_m_array |]
|
center_pq,coef_prod) -> d) common
|
||||||
and expo_inv = [| expo_inv |]
|
and center_cd = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
|
||||||
and d = [| d |]
|
center_pq,coef_prod) -> center_cd) common
|
||||||
and center_cd = [| center_cd |]
|
and center_pq = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
|
||||||
and center_pq = [| center_pq |]
|
center_pq,coef_prod) -> center_pq) common
|
||||||
and coef_prod = [| coef_prod |]
|
and coef_prod = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
|
||||||
|
center_pq,coef_prod) -> coef_prod) common
|
||||||
in
|
in
|
||||||
let map = Array.init maxm (fun _ -> Zmap.create (Array.length class_indices)) in
|
let map = Array.init maxm (fun _ -> Zmap.create (Array.length class_indices)) in
|
||||||
(* Compute the integral class from the primitive shell quartet *)
|
(* Compute the integral class from the primitive shell quartet *)
|
||||||
@ -324,12 +328,12 @@ Array.iter (fun shell_ab ->
|
|||||||
[| 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
|
|
||||||
|
|
||||||
let norm =
|
let norm =
|
||||||
|
Array.map (fun shell_cd ->
|
||||||
shell_ab.Shell_pair.norm_fun angMomA angMomB *. shell_cd.Shell_pair.norm_fun angMomC angMomD
|
shell_ab.Shell_pair.norm_fun angMomA angMomB *. shell_cd.Shell_pair.norm_fun angMomC angMomD
|
||||||
|
) shell_q
|
||||||
in
|
in
|
||||||
let integral = chop norm (fun () ->
|
let integral =
|
||||||
hvrr_two_e 0 (angMomA, angMomB, angMomC, angMomD)
|
hvrr_two_e 0 (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)
|
||||||
@ -337,13 +341,12 @@ Array.iter (fun shell_ab ->
|
|||||||
(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
|
||||||
|
|> Array.map2 (fun x y -> x *. y ) norm
|
||||||
in
|
in
|
||||||
contracted_class.(i) <- contracted_class.(i) +. integral
|
let x = Array.fold_left (+.) 0. integral in
|
||||||
with NullQuartet -> ()
|
contracted_class.(i) <- contracted_class.(i) +. x
|
||||||
) class_indices
|
) class_indices
|
||||||
with NullQuartet -> ()
|
|
||||||
) shell_q
|
|
||||||
) shell_p
|
) shell_p
|
||||||
|
|
||||||
end;
|
end;
|
||||||
@ -364,4 +367,3 @@ let contracted_class ~zero_m shell_a shell_b shell_c shell_d : float Zmap.t =
|
|||||||
in
|
in
|
||||||
contracted_class_shell_pairs ~zero_m shell_p shell_q
|
contracted_class_shell_pairs ~zero_m shell_p shell_q
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user