open Util open Constants type shell_contracted = { expo : float array; coef : float array; center : Coordinate.t; totAngMom : Angular_momentum.t; size : int; norm_coef : float array; norm_coef_scale : float array; index : int; powers : Zkey.t array; } type t = shell_contracted (** 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 = Angular_momentum.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 = Angular_momentum.zkey_array (Angular_momentum.Singlet totAngMom) in let norm_coef = Array.map (fun f -> f [| Angular_momentum.to_int totAngMom ; 0 ; 0 |]) norm_coef_func in let norm_coef_scale = Array.map (fun a -> (norm_coef_func.(0) (Zkey.to_int_array ~kind:Zkey.Kind_3 a)) /. norm_coef.(0) ) powers in { index ; expo ; coef ; center ; totAngMom ; size=Array.length expo ; norm_coef ; norm_coef_scale ; powers } let with_index a i = { a with index = i }