10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-23 04:43:32 +01:00
QCaml/gaussian_integrals/lib/electron_nucleus.ml

100 lines
2.7 KiB
OCaml
Raw Normal View History

2018-02-03 23:26:20 +01:00
(** Electron-nucleus repulsion integrals *)
2020-10-09 09:47:57 +02:00
include Common
include Particles
include Linear_algebra
2020-10-10 10:59:09 +02:00
include Gaussian
2018-02-03 23:26:20 +01:00
open Util
open Constants
2018-02-09 00:37:25 +01:00
2020-09-26 12:02:53 +02:00
module Am = Angular_momentum
2018-02-23 15:49:27 +01:00
module Bs = Basis
2020-09-26 12:02:53 +02:00
module Cs = Contracted_shell
2018-02-23 15:49:27 +01:00
2020-10-02 18:55:19 +02:00
type t = (Bs.t, Bs.t) Matrix.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 =
2020-09-26 12:02:53 +02:00
One_electron_rr.contracted_class_shell_pair ~zero_m shell_p geometry
2018-02-03 23:26:20 +01:00
2018-02-09 00:37:25 +01:00
2018-06-13 17:49:58 +02:00
let of_basis_nuclei ~basis nuclei =
2018-02-19 16:01:13 +01:00
let to_powers x =
2018-02-03 23:26:20 +01:00
let open Zkey in
2018-02-25 01:40:12 +01:00
match to_powers x with
2018-02-03 23:26:20 +01:00
| Three x -> x
| _ -> assert false
in
2018-03-20 14:11:31 +01:00
let n = Bs.size basis
and shell = Bs.contracted_shells basis
2018-02-09 00:37:25 +01:00
in
2020-09-26 12:02:53 +02:00
let eni_array = Matrix.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 ->
2020-09-26 12:02:53 +02:00
Contracted_shell_pair.make 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
2018-03-15 19:35:10 +01:00
match shell_pairs.(i).(j) with
| None -> ()
| Some shell_p ->
(* Compute all the integrals of the class *)
let cls =
contracted_class_shell_pair shell_p nuclei
in
(* Write the data in the output file *)
Array.iteri (fun i_c powers_i ->
let i_c = Cs.index shell.(i) + i_c + 1 in
let xi = to_powers powers_i in
Array.iteri (fun j_c powers_j ->
let j_c = Cs.index shell.(j) + j_c + 1 in
let xj = to_powers powers_j in
let key =
Zkey.of_powers_six xi xj
in
let value =
Zmap.find cls key
in
Matrix.set eni_array j_c i_c value;
Matrix.set eni_array i_c j_c value;
2018-03-21 15:01:39 +01:00
) (Am.zkey_array (Singlet (Cs.ang_mom shell.(j))))
) (Am.zkey_array (Singlet (Cs.ang_mom shell.(i))))
2018-02-03 23:26:20 +01:00
done;
done;
2020-09-26 12:02:53 +02:00
Matrix.detri_inplace eni_array;
2018-02-09 00:37:25 +01:00
eni_array
2020-09-26 12:02:53 +02:00
let of_basis _basis =
2018-06-13 19:03:42 +02:00
invalid_arg "of_basis_nuclei should be called for NucInt"
2020-09-26 12:02:53 +02:00
let of_basis_pair _basis =
failwith "Not implemented"