10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-07-31 17:44:12 +02:00
QCaml/gaussian/lib/atomic_shell.ml

105 lines
4.7 KiB
OCaml
Raw Normal View History

2021-01-06 09:03:26 +01:00
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Type][Type:2]] *)
2020-10-09 09:47:57 +02:00
open Common
2018-03-20 14:11:31 +01:00
type t = {
2021-01-07 09:21:06 +01:00
expo : float array array;
coef : float array array;
norm_coef : float array array;
norm_coef_scale : float array;
contr : Contracted_shell.t array;
index : int;
center : Coordinate.t;
ang_mom : Angular_momentum.t;
}
2018-03-20 14:11:31 +01:00
2020-09-26 12:02:53 +02:00
module Am = Angular_momentum
2018-03-20 14:11:31 +01:00
module Co = Coordinate
2020-09-26 12:02:53 +02:00
module Cs = Contracted_shell
2021-01-06 09:03:26 +01:00
(* Type:2 ends here *)
2018-03-20 14:11:31 +01:00
2021-01-06 09:03:26 +01:00
2021-01-07 09:21:06 +01:00
(* | ~ang_mom~ | Total angular momentum : $l = n_x + n_y + n_z$. |
2021-01-06 09:03:26 +01:00
* | ~center~ | Coordinate of the center $\mathbf{A} = (X_A,Y_A,Z_A)$. |
2021-01-07 09:21:06 +01:00
* | ~coefficients~ | Array of contraction coefficients $d_{ij}$. The first index is the index of the contracted function, and the second index is the index of the primitive. |
2021-01-06 09:03:26 +01:00
* | ~contracted_shells:~ | Array of contracted gaussians |
* | ~exponents~ | Array of exponents $\alpha_{ij}$. The first index is the index of the contracted function, and the second index is the index of the primitive. |
2021-01-07 09:21:06 +01:00
* | ~index~ | Index in the basis set, represented as an array of contracted shells. |
2021-01-06 09:03:26 +01:00
* | ~normalizations~ | Normalization coefficients $\mathcal{N}_{ij}$. The first index is the index of the contracted function, and the second index is the index of the primitive. |
* | ~norm_scales~ | Scaling factors $f(n_x,n_y,n_z)$, given in the same order as ~Angular_momentum.zkey_array ang_mom~. |
2021-01-07 09:21:06 +01:00
* | ~size~ | Number of contracted functions, $n$ in the definition. |
2021-01-06 09:03:26 +01:00
* | ~size_of_shell~ | Number of contracted functions in the shell: length of ~norm_coef_scale~. |
*
2021-01-07 09:21:06 +01:00
* #+begin_example
2021-01-06 09:03:26 +01:00
*
2021-01-07 09:21:06 +01:00
* #+end_example *)
2021-01-06 09:03:26 +01:00
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Access][Access:2]] *)
2021-01-07 09:21:06 +01:00
let ang_mom t = t.ang_mom
let center t = t.center
let coefficients t = t.coef
let contracted_shells t = t.contr
let exponents t = t.expo
let index t = t.index
let normalizations t = t.norm_coef
let norm_scales t = t.norm_coef_scale
let size_of_shell t = Array.length t.norm_coef_scale
let size t = Array.length t.contr
2021-01-06 09:03:26 +01:00
(* Access:2 ends here *)
(* | ~make~ | Creates a contracted shell from a list of coefficients and primitives. |
2021-01-07 09:21:06 +01:00
* | ~with_index~ | Returns a copy of the contracted shell with a modified index. | *)
2021-01-06 09:03:26 +01:00
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Creation][Creation:2]] *)
2018-03-20 14:11:31 +01:00
let make ?(index=0) contr =
assert (Array.length contr > 0);
let coef = Array.map Cs.coefficients contr
and expo = Array.map Cs.exponents contr
in
let center = Cs.center contr.(0) in
let rec unique_center = function
2021-01-07 09:21:06 +01:00
| 0 -> true
| i -> if Cs.center contr.(i) = center then (unique_center [@tailcall]) (i-1) else false
2018-03-20 14:11:31 +01:00
in
if not (unique_center (Array.length contr - 1)) then
invalid_arg "ContractedAtomicShell.make Coordinate.t differ";
2021-01-07 09:21:06 +01:00
2018-03-21 15:01:39 +01:00
let ang_mom = Cs.ang_mom contr.(0) in
2018-03-20 14:11:31 +01:00
let rec unique_angmom = function
2021-01-07 09:21:06 +01:00
| 0 -> true
| i -> if Cs.ang_mom contr.(i) = ang_mom then (unique_angmom [@tailcall]) (i-1) else false
2018-03-20 14:11:31 +01:00
in
if not (unique_angmom (Array.length contr - 1)) then
2020-09-26 12:02:53 +02:00
invalid_arg "Contracted_shell.make: Angular_momentum.t differ";
2021-01-07 09:21:06 +01:00
2018-03-20 14:11:31 +01:00
let norm_coef =
Array.map Cs.normalizations contr
in
let norm_coef_scale = Cs.norm_scales contr.(0)
in
2018-03-21 15:01:39 +01:00
{ index ; expo ; coef ; center ; ang_mom ; norm_coef ;
2018-03-20 14:11:31 +01:00
norm_coef_scale ; contr }
let with_index a i =
{ a with index = i }
2021-01-06 09:03:26 +01:00
(* Creation:2 ends here *)
2018-03-20 14:11:31 +01:00
2021-01-06 09:03:26 +01:00
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Printers][Printers:2]] *)
2018-03-20 14:11:31 +01:00
let pp ppf s =
2021-01-06 09:03:26 +01:00
let open Format in
2018-03-20 15:16:24 +01:00
fprintf ppf "@[%3d-%-3d@]" (s.index+1) (s.index+ (size_of_shell s)*(size s));
2018-03-21 15:01:39 +01:00
fprintf ppf "@[%a@ %a@] @[" Am.pp_string s.ang_mom Co.pp s.center;
2018-03-20 15:16:24 +01:00
Array.iter2 (fun e_arr c_arr -> fprintf ppf "@[<v>";
2021-01-07 09:21:06 +01:00
Array.iter2 (fun e c -> fprintf ppf "@[%16.8e %16.8e@]@;" e c)
e_arr c_arr;
fprintf ppf "@;@]") s.expo s.coef;
2018-03-20 14:11:31 +01:00
fprintf ppf "@]"
2021-01-06 09:03:26 +01:00
(* Printers:2 ends here *)