2018-02-23 18:44:31 +01:00
|
|
|
open Util
|
|
|
|
open Constants
|
|
|
|
open Coordinate
|
|
|
|
|
|
|
|
type t = {
|
2018-03-06 00:47:33 +01:00
|
|
|
expo : float array;
|
|
|
|
coef : float array;
|
|
|
|
center : Coordinate.t;
|
|
|
|
totAngMom : AngularMomentum.t;
|
|
|
|
size : int;
|
|
|
|
norm_coef : float array;
|
|
|
|
norm_coef_scale : float array;
|
|
|
|
index : int;
|
2018-02-23 18:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module Am = AngularMomentum
|
|
|
|
|
2018-03-13 18:24:00 +01:00
|
|
|
|
2018-02-23 18:44:31 +01:00
|
|
|
let compute_norm_coef expo totAngMom =
|
|
|
|
let atot =
|
|
|
|
Am.to_int totAngMom
|
|
|
|
in
|
|
|
|
let factor int_array =
|
|
|
|
let dfa = Array.map (fun j ->
|
|
|
|
( float_of_int (1 lsl j) *. fact j) /. fact (j+j)
|
|
|
|
) int_array
|
|
|
|
in
|
|
|
|
sqrt (dfa.(0) *.dfa.(1) *. dfa.(2))
|
|
|
|
in
|
|
|
|
let expo =
|
|
|
|
if atot mod 2 = 0 then
|
|
|
|
Array.map (fun alpha ->
|
|
|
|
let alpha_2 = alpha +. alpha in
|
|
|
|
(alpha_2 *. pi_inv)**(0.75) *. (pow (alpha_2 +. alpha_2) (atot/2))
|
|
|
|
) expo
|
|
|
|
else
|
|
|
|
Array.map (fun alpha ->
|
|
|
|
let alpha_2 = alpha +. alpha in
|
|
|
|
(alpha_2 *. pi_inv)**(0.75) *. sqrt (pow (alpha_2 +. alpha_2) atot)
|
|
|
|
) expo
|
|
|
|
in
|
|
|
|
Array.map (fun x -> let f a = x *. (factor a) in f) expo
|
|
|
|
|
|
|
|
|
|
|
|
let make ~index ~expo ~coef ~center ~totAngMom =
|
|
|
|
assert (Array.length expo = Array.length coef);
|
|
|
|
assert (Array.length expo > 0);
|
|
|
|
let norm_coef_func =
|
|
|
|
compute_norm_coef expo totAngMom
|
|
|
|
in
|
|
|
|
let powers =
|
|
|
|
Am.zkey_array (Am.Singlet totAngMom)
|
|
|
|
in
|
|
|
|
let norm_coef =
|
|
|
|
Array.map (fun f -> f [| Am.to_int totAngMom ; 0 ; 0 |]) norm_coef_func
|
|
|
|
in
|
|
|
|
let norm_coef_scale =
|
|
|
|
Array.map (fun a ->
|
2018-02-25 01:40:12 +01:00
|
|
|
(norm_coef_func.(0) (Zkey.to_int_array a)) /. norm_coef.(0)
|
2018-02-23 18:44:31 +01:00
|
|
|
) powers
|
|
|
|
in
|
|
|
|
{ index ; expo ; coef ; center ; totAngMom ; size=Array.length expo ; norm_coef ;
|
2018-03-13 18:24:00 +01:00
|
|
|
norm_coef_scale }
|
2018-02-23 18:44:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
let with_index a i =
|
|
|
|
{ a with index = i }
|
|
|
|
|
|
|
|
|
|
|
|
let to_string s =
|
|
|
|
let coord = s.center in
|
|
|
|
let open Printf in
|
|
|
|
(match s.totAngMom with
|
|
|
|
| Am.S -> sprintf "%3d " (s.index+1)
|
2018-03-13 18:24:00 +01:00
|
|
|
| _ -> sprintf "%3d-%-3d" (s.index+1) (s.index+(Array.length s.norm_coef_scale))
|
2018-02-23 18:44:31 +01:00
|
|
|
) ^
|
|
|
|
( sprintf "%1s %8.3f %8.3f %8.3f " (Am.to_string s.totAngMom)
|
|
|
|
(get X coord) (get Y coord) (get Z coord) ) ^
|
|
|
|
(Array.map2 (fun e c -> sprintf "%16.8e %16.8e" e c) s.expo s.coef
|
|
|
|
|> Array.to_list |> String.concat (sprintf "\n%36s" " ") )
|
|
|
|
|
|
|
|
|
|
|
|
(** Normalization coefficient of contracted function i, which depends on the
|
|
|
|
exponent and the angular momentum. Two conventions can be chosen : a single
|
|
|
|
normalisation factor for all functions of the class, or a coefficient which
|
|
|
|
depends on the powers of x,y and z.
|
|
|
|
Returns, for each contracted function, an array of functions taking as
|
|
|
|
argument the [|x;y;z|] powers.
|
|
|
|
*)
|
|
|
|
let compute_norm_coef expo totAngMom =
|
|
|
|
let atot =
|
|
|
|
Am.to_int totAngMom
|
|
|
|
in
|
|
|
|
let factor int_array =
|
|
|
|
let dfa = Array.map (fun j ->
|
|
|
|
(float_of_int (1 lsl j) *. fact j) /. fact (j+j)
|
|
|
|
) int_array
|
|
|
|
in
|
|
|
|
sqrt (dfa.(0) *.dfa.(1) *. dfa.(2))
|
|
|
|
in
|
|
|
|
let expo =
|
|
|
|
if atot mod 2 = 0 then
|
|
|
|
Array.map (fun alpha ->
|
|
|
|
let alpha_2 = alpha +. alpha in
|
|
|
|
(alpha_2 *. pi_inv)**(0.75) *. (pow (alpha_2 +. alpha_2) (atot/2))
|
|
|
|
) expo
|
|
|
|
else
|
|
|
|
Array.map (fun alpha ->
|
|
|
|
let alpha_2 = alpha +. alpha in
|
|
|
|
(alpha_2 *. pi_inv)**(0.75) *. sqrt (pow (alpha_2 +. alpha_2) atot)
|
|
|
|
) expo
|
|
|
|
in
|
|
|
|
Array.map (fun x -> let f a = x *. factor a in f) expo
|
|
|
|
|
|
|
|
|
|
|
|
|