2018-02-03 23:26:20 +01:00
|
|
|
(** Electron-nucleus repulsion integrals *)
|
|
|
|
|
|
|
|
open Util
|
|
|
|
open Constants
|
2018-02-09 00:37:25 +01:00
|
|
|
open Lacaml.D
|
|
|
|
|
|
|
|
type t = Mat.t
|
2018-02-03 23:26:20 +01:00
|
|
|
|
|
|
|
(** (0|0)^m : Fundamental electron-nucleus repulsion integral
|
|
|
|
$ \int \phi_p(r1) 1/r_{C} dr_1 $
|
|
|
|
|
|
|
|
maxm : Maximum total angular momentum
|
|
|
|
expo_pq_inv : $1./p + 1./q$ where $p$ and $q$ are the exponents of
|
|
|
|
$\phi_p$ and $\phi_q$
|
|
|
|
norm_pq_sq : square of the distance between the centers of $\phi_p$
|
|
|
|
and $\phi_q$
|
|
|
|
*)
|
|
|
|
|
|
|
|
let zero_m ~maxm ~expo_pq_inv ~norm_pq_sq =
|
|
|
|
let exp_pq = 1. /. expo_pq_inv in
|
|
|
|
let t = norm_pq_sq *. exp_pq in
|
|
|
|
boys_function ~maxm t
|
|
|
|
|> Array.mapi (fun m fm ->
|
2018-02-04 23:46:06 +01:00
|
|
|
two_over_sq_pi *. fm *.
|
2018-02-03 23:26:20 +01:00
|
|
|
(pow exp_pq m) *. (sqrt exp_pq)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(** Compute all the integrals of a contracted class *)
|
2018-02-05 23:31:46 +01:00
|
|
|
let contracted_class_shell_pair shell_p geometry: float Zmap.t =
|
|
|
|
OneElectronRR.contracted_class_shell_pair ~zero_m shell_p geometry
|
2018-02-03 23:26:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
let cutoff2 = cutoff *. cutoff
|
|
|
|
exception NullIntegral
|
|
|
|
|
2018-02-09 00:37:25 +01:00
|
|
|
|
|
|
|
let of_basis_nuclei basis nuclei =
|
2018-02-03 23:26:20 +01:00
|
|
|
let to_int_tuple x =
|
|
|
|
let open Zkey in
|
|
|
|
match to_int_tuple Kind_3 x with
|
|
|
|
| Three x -> x
|
|
|
|
| _ -> assert false
|
|
|
|
in
|
|
|
|
|
2018-02-09 00:37:25 +01:00
|
|
|
let n =
|
|
|
|
Basis.size basis
|
|
|
|
and shell =
|
|
|
|
Basis.contracted_shells basis
|
|
|
|
in
|
|
|
|
|
|
|
|
let eni_array = Mat.create n n in
|
2018-02-03 23:26:20 +01:00
|
|
|
|
|
|
|
(* Pre-compute all shell pairs *)
|
|
|
|
let shell_pairs =
|
|
|
|
Array.mapi (fun i shell_a -> Array.map (fun shell_b ->
|
2018-02-09 00:37:25 +01:00
|
|
|
ContractedShellPair.create shell_a shell_b) (Array.sub shell 0 (i+1)) ) shell
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
(* Compute Integrals *)
|
2018-02-09 00:37:25 +01:00
|
|
|
for i=0 to (Array.length shell) - 1 do
|
2018-02-03 23:26:20 +01:00
|
|
|
for j=0 to i do
|
|
|
|
let
|
|
|
|
shell_p = shell_pairs.(i).(j)
|
|
|
|
in
|
|
|
|
|
|
|
|
(* Compute all the integrals of the class *)
|
|
|
|
let cls =
|
2018-02-09 00:37:25 +01:00
|
|
|
contracted_class_shell_pair shell_p nuclei
|
2018-02-03 23:26:20 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
(* Write the data in the output file *)
|
|
|
|
Array.iteri (fun i_c powers_i ->
|
2018-02-09 00:37:25 +01:00
|
|
|
let i_c = (Contracted_shell.index shell.(i)) + i_c + 1 in
|
2018-02-03 23:26:20 +01:00
|
|
|
let xi = to_int_tuple powers_i in
|
|
|
|
Array.iteri (fun j_c powers_j ->
|
2018-02-09 00:37:25 +01:00
|
|
|
let j_c = (Contracted_shell.index shell.(j)) + j_c + 1 in
|
2018-02-03 23:26:20 +01:00
|
|
|
let xj = to_int_tuple powers_j in
|
|
|
|
let key =
|
|
|
|
Zkey.of_int_tuple (Zkey.Six (xi,xj))
|
|
|
|
in
|
|
|
|
let value =
|
|
|
|
Zmap.find cls key
|
|
|
|
in
|
2018-02-09 00:37:25 +01:00
|
|
|
eni_array.{j_c,i_c} <- value;
|
|
|
|
) (Contracted_shell.powers shell.(j))
|
|
|
|
) (Contracted_shell.powers shell.(i));
|
2018-02-03 23:26:20 +01:00
|
|
|
done;
|
|
|
|
done;
|
2018-02-09 00:37:25 +01:00
|
|
|
Mat.detri eni_array;
|
|
|
|
eni_array
|
|
|
|
|
2018-02-03 23:26:20 +01:00
|
|
|
|
2018-02-09 00:37:25 +01:00
|
|
|
let to_file ~filename eni_array =
|
|
|
|
let n = Mat.dim1 eni_array in
|
|
|
|
let oc = open_out filename in
|
2018-02-03 23:26:20 +01:00
|
|
|
|
2018-02-09 00:37:25 +01:00
|
|
|
for j=1 to n do
|
|
|
|
for i=1 to j do
|
|
|
|
let value = eni_array.{i,j} in
|
2018-02-03 23:26:20 +01:00
|
|
|
if (value <> 0.) then
|
2018-02-09 00:37:25 +01:00
|
|
|
Printf.fprintf oc " %5d %5d %20.15f\n" i j value;
|
2018-02-03 23:26:20 +01:00
|
|
|
done;
|
|
|
|
done;
|
|
|
|
close_out oc
|
|
|
|
|