2018-01-22 15:27:41 +01:00
|
|
|
open Util
|
2018-02-03 23:26:20 +01:00
|
|
|
open Constants
|
|
|
|
|
|
|
|
exception NullPair
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
(** In chop f g, evaluate g only if f is non zero, and return f *. (g ()) *)
|
|
|
|
let chop f g =
|
|
|
|
if (abs_float f) < cutoff then 0.
|
|
|
|
else f *. (g ())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** Horizontal and Vertical Recurrence Relations (HVRR) *)
|
|
|
|
let hvrr_one_e
|
2018-02-03 23:26:20 +01:00
|
|
|
(angMom_a, angMom_b) (totAngMom_a, totAngMom_b)
|
2018-02-06 12:02:00 +01:00
|
|
|
(maxm, zero_m_array) (expo_b) (expo_inv_p) (center_ab, center_pa, center_pc)
|
2018-01-22 15:27:41 +01:00
|
|
|
map
|
|
|
|
=
|
|
|
|
|
|
|
|
let totAngMom_a = Angular_momentum.to_int totAngMom_a
|
|
|
|
and totAngMom_b = Angular_momentum.to_int totAngMom_b
|
|
|
|
in
|
2018-02-03 23:26:20 +01:00
|
|
|
let maxm = totAngMom_a+totAngMom_b in
|
|
|
|
let maxsze = maxm+1 in
|
|
|
|
let empty = Array.make maxsze 0. in
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
(** Vertical recurrence relations *)
|
2018-02-03 23:26:20 +01:00
|
|
|
let rec vrr angMom_a totAngMom_a =
|
|
|
|
let ax,ay,az = angMom_a in
|
|
|
|
if (ax < 0) || (ay < 0) || (az < 0) then
|
|
|
|
empty
|
2018-01-22 15:27:41 +01:00
|
|
|
else
|
|
|
|
match totAngMom_a with
|
2018-02-03 23:26:20 +01:00
|
|
|
| 0 -> zero_m_array
|
2018-01-22 15:27:41 +01:00
|
|
|
| _ ->
|
2018-02-03 23:26:20 +01:00
|
|
|
let key = Zkey.of_int_tuple (Zkey.Three angMom_a) in
|
|
|
|
|
|
|
|
try Zmap.find map key with
|
|
|
|
| Not_found ->
|
|
|
|
let result =
|
|
|
|
let am, amm, amxyz, xyz =
|
|
|
|
match angMom_a with
|
|
|
|
| (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,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
|
|
|
|
in
|
|
|
|
if amxyz < 0 then empty else
|
2018-02-06 12:02:00 +01:00
|
|
|
let f1 = Coordinate.coord center_pa xyz
|
2018-02-03 23:26:20 +01:00
|
|
|
and f2 = expo_inv_p *. (Coordinate.coord center_pc xyz)
|
|
|
|
in
|
|
|
|
if amxyz < 1 then
|
|
|
|
let v1 =
|
|
|
|
vrr am (totAngMom_a-1)
|
|
|
|
in
|
|
|
|
Array.init maxsze (fun m ->
|
2018-02-06 12:02:00 +01:00
|
|
|
if m = maxm then (f1 *. v1.(m) ) else
|
|
|
|
(f1 *. v1.(m) ) -. f2 *. v1.(m+1) )
|
2018-02-03 23:26:20 +01:00
|
|
|
else
|
|
|
|
let v3 =
|
|
|
|
vrr amm (totAngMom_a-2)
|
|
|
|
in
|
|
|
|
let v1 =
|
|
|
|
vrr am (totAngMom_a-1)
|
|
|
|
in
|
|
|
|
let f3 = (float_of_int amxyz) *. expo_inv_p *. 0.5 in
|
2018-02-06 12:02:00 +01:00
|
|
|
Array.init maxsze (fun m -> f1 *. v1.(m) -.
|
2018-02-03 23:26:20 +01:00
|
|
|
(if m = maxm then 0. else
|
2018-02-06 12:02:00 +01:00
|
|
|
f2 *. v1.(m+1) )
|
|
|
|
+. f3 *. (v3.(m) -. if m = maxm then 0. else
|
2018-02-03 23:26:20 +01:00
|
|
|
expo_inv_p *. v3.(m+1))
|
|
|
|
)
|
|
|
|
in Zmap.add map key result;
|
|
|
|
result
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
(** Horizontal recurrence relations *)
|
|
|
|
and hrr angMom_a angMom_b totAngMom_a totAngMom_b =
|
|
|
|
|
2018-02-03 23:26:20 +01:00
|
|
|
let bx,by,bz = angMom_b in
|
|
|
|
if (bx < 0) || (by < 0) || (bz < 0) then 0.
|
2018-01-22 15:27:41 +01:00
|
|
|
else
|
|
|
|
match totAngMom_b with
|
2018-02-03 23:26:20 +01:00
|
|
|
| 0 -> (vrr angMom_a totAngMom_a).(0)
|
2018-01-22 15:27:41 +01:00
|
|
|
| _ ->
|
2018-02-03 23:26:20 +01:00
|
|
|
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
|
2018-01-22 15:27:41 +01:00
|
|
|
in
|
2018-02-03 23:26:20 +01:00
|
|
|
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 =
|
|
|
|
hrr ap bm (totAngMom_a+1) (totAngMom_b-1)
|
|
|
|
in
|
|
|
|
let f2 =
|
|
|
|
(Coordinate.coord center_ab xyz)
|
|
|
|
in
|
|
|
|
if (abs_float f2 < cutoff) then h1 else
|
|
|
|
let h2 =
|
|
|
|
hrr angMom_a bm totAngMom_a (totAngMom_b-1)
|
|
|
|
in
|
|
|
|
h1 +. f2 *. h2
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
in
|
2018-02-06 17:13:25 +01:00
|
|
|
hrr angMom_a angMom_b totAngMom_a totAngMom_b
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** Computes all the one-electron integrals of the contracted shell pair *)
|
2018-02-05 23:31:46 +01:00
|
|
|
let contracted_class_shell_pair ~zero_m shell_p geometry : float Zmap.t =
|
2018-01-22 15:27:41 +01:00
|
|
|
|
2018-02-07 17:07:05 +01:00
|
|
|
let shell_a = shell_p.(0).ShellPair.shell_a
|
|
|
|
and shell_b = shell_p.(0).ShellPair.shell_b
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
let maxm =
|
2018-01-22 15:27:41 +01:00
|
|
|
let open Angular_momentum in
|
|
|
|
(to_int @@ Contracted_shell.totAngMom shell_a) + (to_int @@ Contracted_shell.totAngMom shell_b)
|
|
|
|
in
|
|
|
|
|
|
|
|
(* Pre-computation of integral class indices *)
|
|
|
|
let class_indices =
|
|
|
|
Angular_momentum.zkey_array
|
|
|
|
(Angular_momentum.Doublet
|
|
|
|
Contracted_shell.(totAngMom shell_a, totAngMom shell_b))
|
|
|
|
in
|
|
|
|
|
|
|
|
let contracted_class =
|
|
|
|
Array.make (Array.length class_indices) 0.;
|
|
|
|
in
|
|
|
|
|
|
|
|
(* Compute all integrals in the shell for each pair of significant shell pairs *)
|
|
|
|
|
|
|
|
for ab=0 to (Array.length shell_p - 1)
|
|
|
|
do
|
2018-02-07 17:07:05 +01:00
|
|
|
let b = shell_p.(ab).ShellPair.j in
|
2018-02-03 23:26:20 +01:00
|
|
|
try
|
|
|
|
begin
|
2018-02-07 17:07:05 +01:00
|
|
|
let coef_prod = shell_p.(ab).ShellPair.coef in
|
|
|
|
let norm_coef_scale_p = shell_p.(ab).ShellPair.norm_coef_scale in
|
2018-01-22 15:27:41 +01:00
|
|
|
|
2018-02-03 23:26:20 +01:00
|
|
|
(** Screening on the product of coefficients *)
|
|
|
|
if (abs_float coef_prod) < 1.e-4*.cutoff then
|
|
|
|
raise NullPair;
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
|
2018-02-03 23:26:20 +01:00
|
|
|
let expo_pq_inv =
|
2018-02-07 17:07:05 +01:00
|
|
|
shell_p.(ab).ShellPair.expo_inv
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
let center_ab =
|
2018-02-07 17:07:05 +01:00
|
|
|
shell_p.(ab).ShellPair.center_ab
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
2018-02-06 12:02:00 +01:00
|
|
|
let center_p =
|
2018-02-07 17:07:05 +01:00
|
|
|
shell_p.(ab).ShellPair.center
|
2018-02-06 12:02:00 +01:00
|
|
|
in
|
2018-02-03 23:26:20 +01:00
|
|
|
let center_pa =
|
2018-02-06 18:12:19 +01:00
|
|
|
Coordinate.(center_p |- Contracted_shell.center shell_a)
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
|
2018-02-05 23:31:46 +01:00
|
|
|
for c=0 to Array.length geometry - 1 do
|
|
|
|
let element, nucl_coord = geometry.(c) in
|
|
|
|
let charge = Element.to_charge element |> Charge.to_float in
|
2018-02-03 23:26:20 +01:00
|
|
|
let center_pc =
|
2018-02-06 12:02:00 +01:00
|
|
|
Coordinate.(center_p |- nucl_coord )
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
let norm_pq_sq =
|
|
|
|
Coordinate.dot center_pc center_pc
|
|
|
|
in
|
|
|
|
|
|
|
|
let zero_m_array =
|
|
|
|
zero_m ~maxm ~expo_pq_inv ~norm_pq_sq
|
|
|
|
in
|
|
|
|
match Contracted_shell.(totAngMom shell_a, totAngMom shell_b) with
|
|
|
|
| Angular_momentum.(S,S) ->
|
|
|
|
let integral =
|
|
|
|
zero_m_array.(0)
|
|
|
|
in
|
2018-02-05 23:31:46 +01:00
|
|
|
contracted_class.(0) <- contracted_class.(0) -. coef_prod *. integral *. charge
|
2018-02-03 23:26:20 +01:00
|
|
|
| _ ->
|
|
|
|
let map = Zmap.create (2*maxm) in
|
|
|
|
let norm_coef_scale = norm_coef_scale_p in
|
|
|
|
(* Compute the integral class from the primitive shell quartet *)
|
|
|
|
class_indices
|
|
|
|
|> Array.iteri (fun i key ->
|
|
|
|
let (angMomA,angMomB) =
|
2018-02-06 17:13:25 +01:00
|
|
|
match Zkey.to_int_tuple ~kind:Zkey.Kind_6 key with
|
|
|
|
| Zkey.Six x -> x
|
|
|
|
| _ -> assert false
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
let norm = norm_coef_scale.(i) in
|
|
|
|
let coef_prod = coef_prod *. norm in
|
|
|
|
let integral =
|
|
|
|
hvrr_one_e (angMomA, angMomB)
|
|
|
|
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b)
|
2018-02-06 12:02:00 +01:00
|
|
|
(maxm, zero_m_array)
|
|
|
|
(Contracted_shell.expo shell_b b)
|
2018-02-07 17:07:05 +01:00
|
|
|
(shell_p.(ab).ShellPair.expo_inv)
|
2018-02-03 23:26:20 +01:00
|
|
|
(center_ab, center_pa, center_pc)
|
|
|
|
map
|
|
|
|
in
|
2018-02-05 23:31:46 +01:00
|
|
|
contracted_class.(i) <- contracted_class.(i) -. coef_prod *. integral *. charge
|
2018-02-03 23:26:20 +01:00
|
|
|
)
|
|
|
|
done
|
|
|
|
end
|
|
|
|
with NullPair -> ()
|
|
|
|
done;
|
|
|
|
let result =
|
|
|
|
Zmap.create (Array.length contracted_class)
|
|
|
|
in
|
|
|
|
Array.iteri (fun i key -> Zmap.add result key contracted_class.(i)) class_indices;
|
|
|
|
result
|
|
|
|
|
2018-01-22 15:27:41 +01:00
|
|
|
|
|
|
|
|