mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 04:13:33 +01:00
Hash table for zkey_array
This commit is contained in:
parent
e3d8582caa
commit
e54a5e034a
@ -28,13 +28,13 @@ let of_nuclei_and_general_basis n b =
|
||||
if (i > 0) then
|
||||
result.(i) <- Cs.with_index x (
|
||||
result.(i-1).index +
|
||||
(Array.length result.(i-1).powers ))
|
||||
(Array.length result.(i-1).norm_coef_scale ))
|
||||
) result ;
|
||||
|
||||
let size =
|
||||
let n = ref 0 in
|
||||
for i=0 to (Array.length result) - 1 do
|
||||
n := !n + (Array.length (result.(i).powers ))
|
||||
n := !n + (Array.length (result.(i).norm_coef_scale))
|
||||
done; !n
|
||||
in
|
||||
{ contracted_shells = result ; size }
|
||||
|
@ -10,19 +10,12 @@ type t = {
|
||||
size : int;
|
||||
norm_coef : float array;
|
||||
norm_coef_scale : float array;
|
||||
powers : Zkey.t array;
|
||||
index : int;
|
||||
}
|
||||
|
||||
module Am = AngularMomentum
|
||||
|
||||
(** 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 =
|
||||
Am.to_int totAngMom
|
||||
@ -67,7 +60,7 @@ let make ~index ~expo ~coef ~center ~totAngMom =
|
||||
) powers
|
||||
in
|
||||
{ index ; expo ; coef ; center ; totAngMom ; size=Array.length expo ; norm_coef ;
|
||||
norm_coef_scale ; powers }
|
||||
norm_coef_scale }
|
||||
|
||||
|
||||
let with_index a i =
|
||||
@ -79,7 +72,7 @@ let to_string s =
|
||||
let open Printf in
|
||||
(match s.totAngMom with
|
||||
| Am.S -> sprintf "%3d " (s.index+1)
|
||||
| _ -> sprintf "%3d-%-3d" (s.index+1) (s.index+(Array.length s.powers))
|
||||
| _ -> sprintf "%3d-%-3d" (s.index+1) (s.index+(Array.length s.norm_coef_scale))
|
||||
) ^
|
||||
( sprintf "%1s %8.3f %8.3f %8.3f " (Am.to_string s.totAngMom)
|
||||
(get X coord) (get Y coord) (get Z coord) ) ^
|
||||
|
@ -35,8 +35,7 @@ type t = private {
|
||||
totAngMom : AngularMomentum.t; (** Total angular momentum : {% $l = n_x + n_y + n_z$ %} *)
|
||||
size : int; (** Number of contracted functions, {% $m$ %} in the formula *)
|
||||
norm_coef : float array; (** Normalization coefficients of primitive functions {% $\mathcal{N}_i$ %} *)
|
||||
norm_coef_scale : float array; (** Scaling factors {% $f_i$ %}, given in the same order as [powers]. *)
|
||||
powers : Zkey.t array; (** Triplets {% $(n_x,n_y,n_z)$ %} encoded in a {!Zkey.t}. *)
|
||||
norm_coef_scale : float array; (** Scaling factors {% $f_i$ %}, given in the same order as [AngularMomentum.zkey_array totAngMom]. *)
|
||||
index : int; (** Index in the basis set, represented as an array of contracted shells. *)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ open Bigarray
|
||||
|
||||
type t = (float, float32_elt, fortran_layout) Bigarray.Genarray.t
|
||||
|
||||
module Am = AngularMomentum
|
||||
module Bs = Basis
|
||||
module Cs = ContractedShell
|
||||
module Csp = ContractedShellPair
|
||||
@ -212,10 +213,10 @@ let of_basis basis =
|
||||
)
|
||||
else
|
||||
out := !out + 1;
|
||||
) shell.(l).powers
|
||||
) shell.(k).powers
|
||||
) shell.(j).powers
|
||||
) shell.(i).powers
|
||||
) Am.(zkey_array (Singlet shell.(l).Cs.totAngMom))
|
||||
) Am.(zkey_array (Singlet shell.(k).Cs.totAngMom))
|
||||
) Am.(zkey_array (Singlet shell.(j).Cs.totAngMom))
|
||||
) Am.(zkey_array (Singlet shell.(i).Cs.totAngMom))
|
||||
with NullIntegral -> ()
|
||||
done;
|
||||
done;
|
||||
|
@ -1,3 +1,4 @@
|
||||
(** Reads a basis set in GAMESS format *)
|
||||
let read_basis filename =
|
||||
let lexbuf =
|
||||
let ic = open_in filename in
|
||||
|
@ -155,8 +155,8 @@ let of_basis basis =
|
||||
in
|
||||
result.{i_c,j_c} <- value;
|
||||
result.{j_c,i_c} <- value;
|
||||
) shell.(i).powers
|
||||
) shell.(j).powers
|
||||
) Am.(zkey_array (Singlet shell.(i).Cs.totAngMom))
|
||||
) Am.(zkey_array (Singlet shell.(j).Cs.totAngMom))
|
||||
done;
|
||||
done;
|
||||
Mat.detri result;
|
||||
|
@ -6,7 +6,9 @@ open Lacaml.D
|
||||
|
||||
type t = Mat.t
|
||||
|
||||
module Am = AngularMomentum
|
||||
module Bs = Basis
|
||||
module Cs = ContractedShell
|
||||
|
||||
(** (0|0)^m : Fundamental electron-nucleus repulsion integral
|
||||
$ \int \phi_p(r1) 1/r_{C} dr_1 $
|
||||
@ -86,8 +88,8 @@ let of_basis_nuclei basis nuclei =
|
||||
in
|
||||
eni_array.{j_c,i_c} <- value;
|
||||
eni_array.{i_c,j_c} <- value;
|
||||
) shell.(j).powers
|
||||
) shell.(i).powers
|
||||
) Am.(zkey_array (Singlet shell.(j).Cs.totAngMom))
|
||||
) Am.(zkey_array (Singlet shell.(i).Cs.totAngMom))
|
||||
done;
|
||||
done;
|
||||
Mat.detri eni_array;
|
||||
|
@ -127,8 +127,8 @@ let of_basis basis =
|
||||
in
|
||||
result.{i_c,j_c} <- value;
|
||||
result.{j_c,i_c} <- value;
|
||||
) shell.(i).powers
|
||||
) shell.(j).powers
|
||||
) Am.(zkey_array (Singlet shell.(i).Cs.totAngMom))
|
||||
) Am.(zkey_array (Singlet shell.(j).Cs.totAngMom))
|
||||
done;
|
||||
done;
|
||||
Mat.detri result;
|
||||
|
@ -8,22 +8,23 @@ let hvrr (angMom_a, angMom_b) (expo_inv_p) (center_ab, center_pa)
|
||||
(** Vertical recurrence relations *)
|
||||
let rec vrr angMom_a =
|
||||
|
||||
if angMom_a < 0 then 0.
|
||||
else if angMom_a = 0 then 1.
|
||||
else
|
||||
(chop center_pa (fun () -> vrr (angMom_a-1)))
|
||||
+. chop (0.5 *. (float_of_int (angMom_a-1)) *. expo_inv_p)
|
||||
if angMom_a > 0 then
|
||||
chop center_pa (fun () -> vrr (angMom_a-1))
|
||||
+. chop (0.5 *. float_of_int (angMom_a-1) *. expo_inv_p)
|
||||
(fun () -> vrr (angMom_a-2))
|
||||
else if angMom_a = 0 then 1.
|
||||
else 0.
|
||||
|
||||
|
||||
(** Horizontal recurrence relations *)
|
||||
and hrr angMom_a angMom_b =
|
||||
|
||||
if angMom_b < 0 then 0.
|
||||
else if angMom_b = 0 then vrr angMom_a
|
||||
else
|
||||
if angMom_b > 0 then
|
||||
hrr (angMom_a+1) (angMom_b-1) +. chop center_ab
|
||||
(fun () -> hrr angMom_a (angMom_b-1) )
|
||||
else if angMom_b = 0 then
|
||||
vrr angMom_a
|
||||
else 0.
|
||||
|
||||
in
|
||||
hrr angMom_a angMom_b
|
||||
|
@ -1,5 +1,6 @@
|
||||
open Lacaml.D
|
||||
open Simulation
|
||||
open Constants
|
||||
|
||||
type t = Mat.t
|
||||
|
||||
@ -17,6 +18,7 @@ let make ~density simulation =
|
||||
for nu = 1 to nBas do
|
||||
for lambda = 1 to nBas do
|
||||
let p = m_P.{lambda,sigma} in
|
||||
if abs_float p > epsilon then
|
||||
for mu = 1 to nu do
|
||||
m_F.{mu,nu} <- m_F.{mu,nu} +. p *.
|
||||
(m_G.{mu,lambda,nu,sigma} -. 0.5 *. m_G.{mu,lambda,sigma,nu})
|
||||
|
@ -68,8 +68,12 @@ let n_functions a =
|
||||
(a*a + 3*a + 2)/2
|
||||
|
||||
|
||||
let zkey_array_memo : (kind, Zkey.t array) Hashtbl.t =
|
||||
Hashtbl.create 13
|
||||
|
||||
(** Returns an array of Zkeys corresponding to all possible angular momenta *)
|
||||
let zkey_array a =
|
||||
|
||||
let keys_1d l =
|
||||
let create_z { x ; y ; _ } =
|
||||
Powers.of_int_tuple (x,y,l-(x+y))
|
||||
@ -93,6 +97,12 @@ let zkey_array a =
|
||||
|> List.rev
|
||||
in
|
||||
|
||||
try
|
||||
Hashtbl.find zkey_array_memo a
|
||||
|
||||
with Not_found ->
|
||||
|
||||
let result =
|
||||
begin
|
||||
match a with
|
||||
| Singlet l1 ->
|
||||
@ -130,4 +140,7 @@ let zkey_array a =
|
||||
|> List.concat
|
||||
end
|
||||
|> Array.of_list
|
||||
in
|
||||
Hashtbl.add zkey_array_memo a result;
|
||||
result
|
||||
|
||||
|
@ -67,3 +67,4 @@ val equal : t -> t -> bool
|
||||
val compare : t -> t -> int
|
||||
(** Comparison function, used for sorting. *)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user