10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-06 22:23:42 +01:00
QCaml/Basis/Contracted_shell.ml

73 lines
2.1 KiB
OCaml
Raw Normal View History

2018-01-17 18:19:38 +01:00
open Util
type t = {
expo : float array;
coef : float array;
center : Coordinate.t;
totAngMom : Angular_momentum.t;
size : int;
norm_coef : (int array -> float) array;
2018-01-19 17:42:12 +01:00
indice : int;
powers : Zkey.t array;
2018-01-17 18:19:38 +01:00
}
2018-01-17 19:09:57 +01:00
let size a = a.size
let expo a i = a.expo.(i)
let coef a i = a.coef.(i)
let center a = a.center
let totAngMom a = a.totAngMom
let norm_coef a i = a.norm_coef.(i)
2018-01-19 17:42:12 +01:00
let indice a = a.indice
let powers a = a.powers
2018-01-17 18:19:38 +01:00
2018-01-18 00:21:05 +01:00
let to_string s =
2018-01-18 17:39:10 +01:00
let coord =
Coordinate.to_Bohr s.center
in
2018-01-18 00:21:05 +01:00
let open Printf in
2018-01-19 17:42:12 +01:00
(match s.totAngMom with
| Angular_momentum.S -> sprintf "%3d " (s.indice+1)
| _ -> sprintf "%3d-%-3d" (s.indice+1) (s.indice+(Array.length s.powers))
) ^
( sprintf "%1s %8.3f %8.3f %8.3f " (Angular_momentum.to_string s.totAngMom)
2018-01-18 17:39:10 +01:00
(Coordinate.x coord) (Coordinate.y coord) (Coordinate.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" " ") )
2018-01-18 00:21:05 +01:00
2018-01-17 18:19:38 +01:00
(** 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.
*)
let compute_norm_coef s =
let atot =
Angular_momentum.to_int s.totAngMom
in
Array.mapi (fun i alpha ->
2018-01-30 14:51:37 +01:00
let alpha_2 =
alpha +. alpha
in
2018-01-17 18:19:38 +01:00
let c =
2018-01-30 14:51:37 +01:00
(alpha_2 *. pi_inv)**(1.5) *. (pow (alpha_2 +. alpha_2) atot)
2018-01-17 18:19:38 +01:00
in
let result a =
let dfa = Array.map (fun j ->
2018-01-30 14:51:37 +01:00
( float_of_int (1 lsl j) *. fact j) /. fact (j+j)
2018-01-17 18:19:38 +01:00
) a
2018-01-30 14:51:37 +01:00
in sqrt (c *. dfa.(0) *.dfa.(1) *. dfa.(2))
2018-01-17 18:19:38 +01:00
in
result
) s.expo
2018-01-19 17:42:12 +01:00
let create ~indice ~expo ~coef ~center ~totAngMom =
2018-01-17 18:19:38 +01:00
assert (Array.length expo = Array.length coef);
assert (Array.length expo > 0);
let tmp =
2018-01-19 17:42:12 +01:00
{ indice ; expo ; coef ; center ; totAngMom ; size=Array.length expo ; norm_coef = [||];
2018-01-19 18:18:11 +01:00
powers = Angular_momentum.zkey_array (Angular_momentum.Singlet totAngMom) }
2018-01-17 18:19:38 +01:00
in
{ tmp with norm_coef = compute_norm_coef tmp }
2018-01-19 17:42:12 +01:00