From d7c3c9f6b739286a7ec5e365652f9f4ed058a254 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 7 Feb 2018 13:33:25 +0100 Subject: [PATCH] Introducing unique shell pairs --- Basis/Contracted_shell.mli | 14 +------------- Basis/ERI.ml | 11 ++++++----- Basis/Shell_pair.ml | 23 ++++++++++++++++++++++- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Basis/Contracted_shell.mli b/Basis/Contracted_shell.mli index e3f6b2b..b0bdd46 100644 --- a/Basis/Contracted_shell.mli +++ b/Basis/Contracted_shell.mli @@ -1,17 +1,5 @@ type t -(* -type t = { - expo : float array; - coef : float array; - center : Coordinate.t; - totAngMom : Angular_momentum.t; - size : int; - norm_coef : float array; - norm_coef_scale : float array; - indice : int; - powers : Zkey.t array; -} -*) + (** Returns the number of contracted Gaussians *) val size : t -> int diff --git a/Basis/ERI.ml b/Basis/ERI.ml index 1f4772c..8468fc5 100644 --- a/Basis/ERI.ml +++ b/Basis/ERI.ml @@ -72,11 +72,7 @@ let to_file ~filename basis = (* Pre-compute all shell pairs *) let shell_pairs = - Array.mapi (fun i shell_a -> Array.map (fun shell_b -> - (* - Shell_pair.create_array shell_a shell_b) (Array.sub basis 0 (i+1)) ) basis - *) - Shell_pair.create_array shell_a shell_b) (basis) ) basis + Shell_pair.shell_pairs basis in Printf.printf "%d shells\n" (Array.length basis); @@ -128,6 +124,11 @@ let to_file ~filename basis = let shell_p = shell_pairs.(i).(j) in + (* + Printf.printf "%d %d : " i j; + Array.iter (fun i -> Printf.printf "%d " (Shell_pair.hash i)) shell_p; + print_newline (); + *) for k=0 to i do for l=0 to k do diff --git a/Basis/Shell_pair.ml b/Basis/Shell_pair.ml index a3ae733..37d7ed2 100644 --- a/Basis/Shell_pair.ml +++ b/Basis/Shell_pair.ml @@ -103,5 +103,26 @@ let create_array ?cutoff p_a p_b = |> List.map (function Some x -> x | None -> assert false) |> Array.of_list -open Util + +let hash a = + Hashtbl.hash (a.expo, a.center_a, a.center_ab, a.coef) + +let cmp a b = + hash a - hash b + + +let shell_pairs basis = + Array.mapi (fun i shell_a -> Array.map (fun shell_b -> + create_array shell_a shell_b) (Array.sub basis 0 (i+1)) ) basis + + +let unique_shell_pairs basis = + let map = + Hashtbl.create 129 + in + Array.iter (fun spa -> + Array.iter (fun value -> + let key = hash value in + Hashtbl.add map key value) spa) basis; + map