10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-19 19:52:06 +02:00

zerom_cache

This commit is contained in:
Anthony Scemama 2018-02-02 21:14:13 +01:00
parent 9a8f440f7a
commit 94ab6f0174
3 changed files with 51 additions and 5 deletions

View File

@ -13,6 +13,7 @@ open Bigarray
norm_pq_sq : square of the distance between the centers of $\phi_p$
and $\phi_q$
*)
let zero_m ~maxm ~expo_pq_inv ~norm_pq_sq =
let exp_pq = 1. /. expo_pq_inv in
let t = norm_pq_sq *. exp_pq in

View File

@ -325,6 +325,9 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
(* Compute all integrals in the shell for each pair of significant shell pairs *)
let zero_m_cache =
Hashtbl.create 129
in
for ab=0 to (Array.length shell_p - 1) do
let cab = shell_p.(ab).Shell_pair.coef in
let b = shell_p.(ab).Shell_pair.j in
@ -349,8 +352,21 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
in
let zero_m_array =
let key = String.concat " "
[ string_of_int maxm ; string_of_float expo_pq_inv ; string_of_float norm_pq_sq ]
in
try
let result =
Hashtbl.find zero_m_cache key
in
result
with
| Not_found ->
let result =
zero_m ~maxm ~expo_pq_inv ~norm_pq_sq
in
(Hashtbl.add zero_m_cache key result ; result)
in
begin
match Contracted_shell.(totAngMom shell_a, totAngMom shell_b,
totAngMom shell_c, totAngMom shell_d) with

View File

@ -306,6 +306,9 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
Array.make (Array.length class_indices) 0.;
in
let zero_m_cache =
Hashtbl.create 129
in
(* Compute all integrals in the shell for each pair of significant shell pairs *)
begin
@ -335,8 +338,21 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
in
let zero_m_array =
let key = String.concat " "
[ string_of_int 0 ; string_of_float expo_pq_inv ; string_of_float norm_pq_sq ]
in
try
let result =
Hashtbl.find zero_m_cache key
in
result
with
| Not_found ->
let result =
zero_m ~maxm:0 ~expo_pq_inv ~norm_pq_sq
in
(Hashtbl.add zero_m_cache key result ; result)
in
accu +. coef_prod *. zero_m_array.(0)
with NullQuartet -> accu
@ -363,8 +379,21 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
in
let zero_m_array =
let key = String.concat " "
[ string_of_int maxm ; string_of_float expo_pq_inv ; string_of_float norm_pq_sq ]
in
try
let result =
Hashtbl.find zero_m_cache key
in
result
with
| Not_found ->
let result =
zero_m ~maxm ~expo_pq_inv ~norm_pq_sq
in
(Hashtbl.add zero_m_cache key result ; result)
in
let d = shell_cd.Shell_pair.j in