mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-10-04 23:36:08 +02:00
Cleaning in ERI
This commit is contained in:
parent
ab7abda328
commit
f186b6ef1b
82
Basis/ERI.ml
82
Basis/ERI.ml
@ -2,20 +2,9 @@
|
||||
|
||||
open Util
|
||||
open Constants
|
||||
open Bigarray
|
||||
|
||||
let max_ao = 1 lsl 14
|
||||
|
||||
type index_pair = { first : int ; second : int }
|
||||
|
||||
type t = FourIdxStorage.t
|
||||
|
||||
let get_chem = FourIdxStorage.get_chem
|
||||
let get_phys = FourIdxStorage.get_phys
|
||||
|
||||
let set_chem = FourIdxStorage.set_chem
|
||||
let set_phys = FourIdxStorage.set_phys
|
||||
|
||||
|
||||
module Am = AngularMomentum
|
||||
module As = AtomicShell
|
||||
@ -23,6 +12,17 @@ module Asp = AtomicShellPair
|
||||
module Bs = Basis
|
||||
module Cs = ContractedShell
|
||||
module Csp = ContractedShellPair
|
||||
module Fis = FourIdxStorage
|
||||
|
||||
|
||||
let get_chem = Fis.get_chem
|
||||
let get_phys = Fis.get_phys
|
||||
|
||||
let set_chem = Fis.set_chem
|
||||
let set_phys = Fis.set_phys
|
||||
|
||||
let to_file = Fis.to_file
|
||||
|
||||
|
||||
|
||||
(** (00|00)^m : Fundamental electron repulsion integral
|
||||
@ -67,9 +67,6 @@ let class_of_contracted_shell_pairs shell_p shell_q =
|
||||
|
||||
|
||||
let filter_contracted_shell_pairs ?(cutoff=integrals_cutoff) shell_pairs =
|
||||
let t0 = Unix.gettimeofday () in
|
||||
|
||||
let schwartz =
|
||||
List.map (fun pair ->
|
||||
let cls =
|
||||
class_of_contracted_shell_pairs pair pair
|
||||
@ -78,11 +75,9 @@ let filter_contracted_shell_pairs ?(cutoff=integrals_cutoff) shell_pairs =
|
||||
) shell_pairs
|
||||
|> List.filter (fun (_, schwartz_p_max) -> schwartz_p_max >= cutoff)
|
||||
|> List.map fst
|
||||
in
|
||||
|
||||
Printf.printf "%d shell pairs computed in %f seconds\n"
|
||||
(List.length schwartz) (Unix.gettimeofday () -. t0);
|
||||
schwartz
|
||||
|
||||
|
||||
|
||||
let store_class ?(cutoff=integrals_cutoff) data cls shell_p shell_q =
|
||||
let to_powers x =
|
||||
@ -91,6 +86,7 @@ let store_class ?(cutoff=integrals_cutoff) data cls shell_p shell_q =
|
||||
| Three x -> x
|
||||
| _ -> assert false
|
||||
in
|
||||
|
||||
Array.iteri (fun i_c powers_i ->
|
||||
let i_c = Cs.index (Csp.shell_a shell_p) + i_c + 1 in
|
||||
let xi = to_powers powers_i in
|
||||
@ -120,36 +116,29 @@ let of_basis basis =
|
||||
|
||||
let n = Bs.size basis
|
||||
and shell = Bs.contracted_shells basis
|
||||
(*TODO
|
||||
and atomic_shells = Bs.atomic_shells basis
|
||||
*)
|
||||
in
|
||||
|
||||
|
||||
(* Pre-compute all shell pairs *)
|
||||
let shell_pairs =
|
||||
Csp.of_contracted_shell_array shell
|
||||
in
|
||||
|
||||
(* Pre-compute diagonal integrals for Schwartz *)
|
||||
let schwartz =
|
||||
filter_contracted_shell_pairs shell_pairs
|
||||
in
|
||||
|
||||
(* 4D data initialization *)
|
||||
let eri_array =
|
||||
FourIdxStorage.create ~size:n `Dense
|
||||
Fis.create ~size:n `Dense
|
||||
(*
|
||||
FourIdxStorage.create ~size:n `Sparse
|
||||
Fis.create ~size:n `Sparse
|
||||
*)
|
||||
in
|
||||
|
||||
(* Compute ERIs *)
|
||||
|
||||
let t0 = Unix.gettimeofday () in
|
||||
let inn = ref 0 and out = ref 0 in
|
||||
|
||||
let shell_pairs =
|
||||
Csp.of_contracted_shell_array shell
|
||||
|> filter_contracted_shell_pairs ~cutoff:integrals_cutoff
|
||||
in
|
||||
|
||||
Printf.printf "%d significant shell pairs computed in %f seconds\n"
|
||||
(List.length shell_pairs) (Unix.gettimeofday () -. t0);
|
||||
|
||||
|
||||
let t0 = Unix.gettimeofday () in
|
||||
let ishell = ref 0 in
|
||||
|
||||
List.iter (fun shell_p ->
|
||||
let () =
|
||||
if (Cs.index (Csp.shell_a shell_p) > !ishell) then
|
||||
@ -171,29 +160,20 @@ let of_basis basis =
|
||||
Csp.shell_pairs shell_q
|
||||
in
|
||||
|
||||
let swap =
|
||||
Array.length sp > Array.length sq
|
||||
in
|
||||
|
||||
(* Compute all the integrals of the class *)
|
||||
let f p q =
|
||||
let cls = class_of_contracted_shell_pairs p q in
|
||||
store_class ~cutoff:integrals_cutoff eri_array cls p q
|
||||
in
|
||||
if swap then
|
||||
|
||||
if Array.length sp > Array.length sq then
|
||||
f shell_q shell_p
|
||||
else
|
||||
f shell_p shell_q
|
||||
) schwartz
|
||||
) shell_pairs
|
||||
with Exit -> ()
|
||||
) schwartz;
|
||||
Printf.printf "In: %d Out:%d\n" !inn !out ;
|
||||
) shell_pairs ;
|
||||
Printf.printf "Computed ERIs in %f seconds\n%!" (Unix.gettimeofday () -. t0);
|
||||
eri_array
|
||||
|
||||
|
||||
(** Write all integrals to a file with the <ij|kl> convention *)
|
||||
let to_file = FourIdxStorage.to_file
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user