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

List of shell pairs

This commit is contained in:
Anthony Scemama 2018-03-20 19:02:58 +01:00
parent d4e56ef443
commit a50ffd83f8
5 changed files with 119 additions and 131 deletions

View File

@ -7,13 +7,7 @@ type t =
{ {
shell_a : ContractedShell.t; shell_a : ContractedShell.t;
shell_b : ContractedShell.t; shell_b : ContractedShell.t;
shell_pairs : PrimitiveShellPair.t list; coefs_and_shell_pairs : (float * PrimitiveShellPair.t) list;
coefficients : float array;
exponents_inv : float array;
center_ab : Coordinate.t; (* A-B *)
norm_sq : float; (* |A-B|^2 *)
norm_scales : float array; (* norm_coef.(i) / norm_coef.(0) *)
totAngMom : AngularMomentum.t; (* Total angular Momentum *)
} }
@ -31,7 +25,7 @@ let make ?(cutoff=1.e-32) s_a s_b =
let make = Psp.create_make_of (Cs.primitives s_a).(0) (Cs.primitives s_b).(0) in let make = Psp.create_make_of (Cs.primitives s_a).(0) (Cs.primitives s_b).(0) in
let shell_pairs = let coefs_and_shell_pairs =
Array.mapi (fun i p_a -> Array.mapi (fun i p_a ->
let c_a = (Cs.coefficients s_a).(i) in let c_a = (Cs.coefficients s_a).(i) in
let make = make p_a in let make = make p_a in
@ -45,38 +39,55 @@ let make ?(cutoff=1.e-32) s_a s_b =
|> Array.concat |> Array.concat
|> Array.to_list |> Array.to_list
|> List.filter (function (_, Some _) -> true | _ -> false) |> List.filter (function (_, Some _) -> true | _ -> false)
|> List.map (function (c, Some x) -> (c,x) | _ -> assert false) |> List.map (function (c, Some x) -> (c *. Psp.normalization x, x) | _ -> assert false)
in in
match coefs_and_shell_pairs with
match shell_pairs with
| [] -> None | [] -> None
| head :: _ -> | coefs_and_shell_pairs -> Some { shell_a = s_a ; shell_b = s_b ; coefs_and_shell_pairs }
let coefficients = List.map (fun (c,y) -> c *. Psp.normalization y) shell_pairs |> Array.of_list
and exponents_inv = List.map (fun (_,y) -> Psp.exponent_inv y) shell_pairs |> Array.of_list
in
let shell_pairs = List.map snd shell_pairs in
let root = snd head in
Some {
shell_a = s_a ; shell_b = s_b ; coefficients ; exponents_inv ; shell_pairs ;
center_ab = Psp.a_minus_b root;
norm_scales = Psp.norm_scales root;
norm_sq=Psp.a_minus_b_sq root;
totAngMom = Psp.totAngMom root;
}
let shell_a x = x.shell_a let shell_a x = x.shell_a
let shell_b x = x.shell_b let shell_b x = x.shell_b
let shell_pairs x = Array.of_list x.shell_pairs let coefs_and_shell_pairs x = x.coefs_and_shell_pairs
let coefficients x = x.coefficients
let exponents_inv x = x.exponents_inv let shell_pairs x =
let center_ab x = x.center_ab List.map snd x.coefs_and_shell_pairs
let norm_sq x = x.norm_sq |> Array.of_list
let totAngMom x = x.totAngMom
let norm_scales x = x.norm_scales let coefficients x =
List.map fst x.coefs_and_shell_pairs
|> Array.of_list
let exponents_inv x =
List.map (fun (_,sp) -> Psp.exponent_inv sp) x.coefs_and_shell_pairs
|> Array.of_list
let center_ab x =
match x.coefs_and_shell_pairs with
| [] -> assert false
| (_,sp)::_ -> Psp.a_minus_b sp
let norm_sq x =
match x.coefs_and_shell_pairs with
| [] -> assert false
| (_,sp)::_ -> Psp.a_minus_b_sq sp
let totAngMom x =
match x.coefs_and_shell_pairs with
| [] -> assert false
| (_,sp)::_ -> Psp.totAngMom sp
let norm_scales x =
match x.coefs_and_shell_pairs with
| [] -> assert false
| (_,sp)::_ -> Psp.norm_scales sp
let monocentric x =
match x.coefs_and_shell_pairs with
| [] -> assert false
| (_,sp)::_ -> Psp.monocentric sp
let monocentric x = Psp.monocentric (List.hd x.shell_pairs)
(** Returns an integer characteristic of a contracted shell pair *) (** Returns an integer characteristic of a contracted shell pair *)
let hash a = let hash a =

View File

@ -45,6 +45,11 @@ val shell_b : t -> ContractedShell.t
build the contracted shell pair. build the contracted shell pair.
*) *)
val coefs_and_shell_pairs : t -> (float * PrimitiveShellPair.t) list
(** Returns an list of coefficients and of {!PrimitiveShellPair.t}, containing all
the pairs of primitive functions used to build the contracted shell pair.
*)
val shell_pairs : t -> PrimitiveShellPair.t array val shell_pairs : t -> PrimitiveShellPair.t array
(** Returns an array of {!PrimitiveShellPair.t}, containing all the pairs of (** Returns an array of {!PrimitiveShellPair.t}, containing all the pairs of
primitive functions used to build the contracted shell pair. primitive functions used to build the contracted shell pair.
@ -54,6 +59,7 @@ val coefficients : t -> float array
val exponents_inv : t -> float array val exponents_inv : t -> float array
val center_ab : t -> Coordinate.t val center_ab : t -> Coordinate.t
(* A-B *) (* A-B *)

View File

@ -117,40 +117,24 @@ let contracted_class_shell_pair ~zero_m shell_p geometry : float Zmap.t =
(* Compute all integrals in the shell for each pair of significant shell pairs *) (* Compute all integrals in the shell for each pair of significant shell pairs *)
let norm_scales_p = Csp.norm_scales shell_p let norm_scales_p = Csp.norm_scales shell_p in
in
let sp = Csp.shell_pairs shell_p in let center_ab = Csp.center_ab shell_p in
for ab=0 to Array.length sp - 1
do List.iter (fun (coef_prod, psp) ->
try try
begin begin
let coef_prod = (Csp.coefficients shell_p).(ab) in
(** Screening on the product of coefficients *) (** Screening on the product of coefficients *)
if abs_float coef_prod < 1.e-3 *. integrals_cutoff then if abs_float coef_prod < 1.e-3 *. integrals_cutoff then
raise NullPair; raise NullPair;
let expo_pq_inv = Psp.exponent_inv psp
let expo_pq_inv = and expo_b = Ps.exponent (Psp.shell_b psp)
(Csp.exponents_inv shell_p).(ab) and center_p = Psp.center psp
and center_pa = Psp.center_minus_a psp
in in
let expo_b = Array.iter (fun (element, nucl_coord) ->
Ps.exponent (Psp.shell_b sp.(ab))
in
let center_ab =
Csp.center_ab shell_p
in
let center_p =
Psp.center sp.(ab)
in
let center_pa =
Psp.center_minus_a sp.(ab)
in
for c=0 to Array.length geometry - 1 do
let element, nucl_coord = geometry.(c) in
let charge = Element.to_charge element |> Charge.to_float in let charge = Element.to_charge element |> Charge.to_float in
let center_pc = let center_pc =
Co.(center_p |- nucl_coord ) Co.(center_p |- nucl_coord )
@ -190,15 +174,16 @@ let contracted_class_shell_pair ~zero_m shell_p geometry : float Zmap.t =
in in
contracted_class.(i) <- contracted_class.(i) -. coef_prod *. integral *. charge contracted_class.(i) <- contracted_class.(i) -. coef_prod *. integral *. charge
) )
done ) geometry
end end
with NullPair -> () with NullPair -> ()
done; ) (Csp.coefs_and_shell_pairs shell_p);
let result =
Zmap.create (Array.length contracted_class) let result =
in Zmap.create (Array.length contracted_class)
Array.iteri (fun i key -> Zmap.add result key contracted_class.(i)) class_indices; in
result Array.iteri (fun i key -> Zmap.add result key contracted_class.(i)) class_indices;
result

View File

@ -36,61 +36,51 @@ let contracted_class shell_a shell_b : float Zmap.t =
Array.make (Array.length class_indices) 0. Array.make (Array.length class_indices) 0.
in in
let sp = let center_ab =
Csp.shell_pairs shell_p Csp.center_ab shell_p
in
let norm_coef_scales =
Csp.norm_scales shell_p
in in
let center_ab = (* Compute all integrals in the shell for each pair of significant shell pairs *)
Csp.center_ab shell_p
in
let norm_coef_scales =
Csp.norm_scales shell_p
in
(* Compute all integrals in the shell for each pair of significant shell pairs *) let xyz_of_int k =
match k with
| 0 -> Co.X
| 1 -> Co.Y
| _ -> Co.Z
in
let xyz_of_int k = List.iter (fun (coef_prod, psp) ->
match k with (** Screening on thr product of coefficients *)
| 0 -> Co.X if (abs_float coef_prod) > 1.e-3*.cutoff then
| 1 -> Co.Y begin
| _ -> Co.Z let expo_inv = Psp.exponent_inv psp
in and center_pa = Psp.center_minus_a psp
for ab=0 to (Array.length sp - 1) in
do
let coef_prod =
(Csp.coefficients shell_p).(ab)
in
(** Screening on thr product of coefficients *)
if (abs_float coef_prod) > 1.e-3*.cutoff then
begin
let expo_inv =
(Csp.exponents_inv shell_p).(ab)
in
let center_pa =
Psp.center_minus_a sp.(ab)
in
Array.iteri (fun i key -> Array.iteri (fun i key ->
let (angMomA,angMomB) = to_powers key in let (angMomA,angMomB) = to_powers key in
let f k = let f k =
let xyz = xyz_of_int k in let xyz = xyz_of_int k in
Overlap_primitives.hvrr (Po.get xyz angMomA, Po.get xyz angMomB) Overlap_primitives.hvrr (Po.get xyz angMomA, Po.get xyz angMomB)
expo_inv expo_inv
(Co.get xyz center_ab, (Co.get xyz center_ab,
Co.get xyz center_pa) Co.get xyz center_pa)
in in
let norm = norm_coef_scales.(i) in let norm = norm_coef_scales.(i) in
let integral = chop norm (fun () -> (f 0)*.(f 1)*.(f 2)) in let integral = chop norm (fun () -> (f 0)*.(f 1)*.(f 2)) in
contracted_class.(i) <- contracted_class.(i) +. coef_prod *. integral contracted_class.(i) <- contracted_class.(i) +. coef_prod *. integral
) class_indices ) class_indices
end end
done; ) (Csp.coefs_and_shell_pairs shell_p);
let result = let result =
Zmap.create (Array.length contracted_class) Zmap.create (Array.length contracted_class)
in in
Array.iteri (fun i key -> Zmap.add result key contracted_class.(i)) class_indices; Array.iteri (fun i key -> Zmap.add result key contracted_class.(i)) class_indices;
result result
end end
| None -> Zmap.create 0 | None -> Zmap.create 0

View File

@ -279,7 +279,6 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
and shell_b = Csp.shell_b shell_p and shell_b = Csp.shell_b shell_p
and shell_c = Csp.shell_a shell_q and shell_c = Csp.shell_a shell_q
and shell_d = Csp.shell_b shell_q and shell_d = Csp.shell_b shell_q
and sp = Csp.shell_pairs shell_p
in in
let maxm = Am.(Csp.totAngMom shell_p + Csp.totAngMom shell_q |> to_int) in let maxm = Am.(Csp.totAngMom shell_p + Csp.totAngMom shell_q |> to_int) in
@ -304,19 +303,16 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
let norm_coef_scale_p_list = Array.to_list (Csp.norm_scales shell_p) in let norm_coef_scale_p_list = Array.to_list (Csp.norm_scales shell_p) in
let norm_coef_scale_q = Csp.norm_scales shell_q in let norm_coef_scale_q = Csp.norm_scales shell_q in
for ab=0 to (Array.length sp - 1) do let center_ab = Csp.center_ab shell_p in
List.iter (fun (c_ab, sp_ab) ->
let sp_ab = (Csp.shell_pairs shell_p).(ab) in let expo_b = Ps.exponent (Psp.shell_b sp_ab)
let c_ab = (Csp.coefficients shell_p).(ab) in and expo_inv_p = Psp.exponent_inv sp_ab
let expo_b = Ps.exponent (Psp.shell_b sp_ab) in and center_pa = Psp.center_minus_a sp_ab
let expo_inv_p = Psp.exponent_inv sp_ab in in
let center_ab = Psp.a_minus_b sp_ab in
let center_pa = Psp.center_minus_a sp_ab in
for cd=0 to (Array.length (Csp.shell_pairs shell_q) - 1) do List.iter (fun (c_cd, sp_cd) ->
let sp_cd = (Csp.shell_pairs shell_q).(cd) in
let c_cd = (Csp.coefficients shell_q).(cd) in
let coef_prod = c_ab *. c_cd in let coef_prod = c_ab *. c_cd in
(** Screening on the product of coefficients *) (** Screening on the product of coefficients *)
@ -415,8 +411,8 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
) )
end end
with NullQuartet -> () with NullQuartet -> ()
done ) (Csp.coefs_and_shell_pairs shell_q)
done; ) (Csp.coefs_and_shell_pairs shell_p);
let result = let result =
Zmap.create (Array.length contracted_class) Zmap.create (Array.length contracted_class)