Removing org-mode

This commit is contained in:
Anthony Scemama 2024-01-17 14:24:28 +01:00
parent e59d016ae7
commit 744f2a0552
9 changed files with 196 additions and 646 deletions

View File

@ -1,175 +0,0 @@
#+begin_src elisp tangle: no :results none :exports none
(setq pwd (file-name-directory buffer-file-name))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq lib (concat pwd "lib/"))
(setq testdir (concat pwd "test/"))
(setq mli (concat lib name ".mli"))
(setq ml (concat lib name ".ml"))
(setq test-ml (concat testdir name ".ml"))
(org-babel-tangle)
#+end_src
* Atomic shell
:PROPERTIES:
:header-args: :noweb yes :comments both
:END:
Set of contracted Gaussians differing only by the powers of $x$, $y$ and $z$, with a
constant ~Angular_momentum.t~, all centered on the same point.
In other words, it is the set of all contracted shells sharing the same center.
\begin{align*}
\chi_{n_x,n_y,n_z}(r) & = f(n_x,n_y,n_z) \sum_{j=1}^{n} \sum_{i=1}^{m} \mathcal{N}_{ij}\, d_{ij}\, g_{ij\,n_x,n_y,n_z}(r) \\
& = (x-X_A)^{n_x} (y-Y_A)^{n_y} (z-Z_A)^{n_z} f(n_x,n_y,n_z) \sum_{j=1}^{n} \sum_{i=1}^{m} \mathcal{N}_{ij}\, d_{ij}\, \exp \left( -\alpha_{ij} |r-R_A|^2 \right)
\end{align*}
where:
- $g_{ij\,n_x,n_y,n_z}(r)$ is the $i$-th ~PrimitiveShell.t~ of the $j$-th ~Contracted_shell.t~
- $n_x + n_y + n_z = l$, the total angular momentum
- $\alpha_{ij}$ are the exponents (tabulated) of the $j$-th ~Contracted_shell.t~
- $d_{ij}$ are the contraction coefficients of the $j$-th ~Contracted_shell.t~
- $\mathcal{N}_{ij}$ is the normalization coefficient of the $i$-th primitive shell
(~PrimitiveShell.norm_coef~) of the $j$-th ~Contracted_shell.t~
- $f(n_x,n_y,n_z)$ is a scaling factor adjusting the normalization coefficient for the
particular powers of $x,y,z$ (~PrimitiveShell.norm_coef_scale~)
** Type
#+begin_src ocaml :tangle (eval mli)
type t
open Common
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
open Common
type t = {
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;
}
module Am = Angular_momentum
module Co = Coordinate
module Cs = Contracted_shell
#+end_src
** Access
#+begin_src ocaml :tangle (eval mli)
val ang_mom : t -> Angular_momentum.t
val center : t -> Coordinate.t
val coefficients : t -> float array array
val contracted_shells : t -> Contracted_shell.t array
val exponents : t -> float array array
val index : t -> int
val normalizations : t -> float array array
val norm_scales : t -> float array
val size_of_shell : t -> int
val size : t -> int
#+end_src
| ~ang_mom~ | Total angular momentum : $l = n_x + n_y + n_z$. |
| ~center~ | Coordinate of the center $\mathbf{A} = (X_A,Y_A,Z_A)$. |
| ~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. |
| ~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. |
| ~index~ | Index in the basis set, represented as an array of contracted shells. |
| ~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~. |
| ~size~ | Number of contracted functions, $n$ in the definition. |
| ~size_of_shell~ | Number of contracted functions in the shell: length of ~norm_coef_scale~. |
#+begin_example
#+end_example
#+begin_src ocaml :tangle (eval ml) :exports none
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
#+end_src
** Creation
#+begin_src ocaml :tangle (eval mli)
val make : ?index:int -> Contracted_shell.t array -> t
val with_index : t -> int -> t
#+end_src
| ~make~ | Creates a contracted shell from a list of coefficients and primitives. |
| ~with_index~ | Returns a copy of the contracted shell with a modified index. |
#+begin_src ocaml :tangle (eval ml) :exports none
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
| 0 -> true
| i -> if Cs.center contr.(i) = center then (unique_center [@tailcall]) (i-1) else false
in
if not (unique_center (Array.length contr - 1)) then
invalid_arg "ContractedAtomicShell.make Coordinate.t differ";
let ang_mom = Cs.ang_mom contr.(0) in
let rec unique_angmom = function
| 0 -> true
| i -> if Cs.ang_mom contr.(i) = ang_mom then (unique_angmom [@tailcall]) (i-1) else false
in
if not (unique_angmom (Array.length contr - 1)) then
invalid_arg "Contracted_shell.make: Angular_momentum.t differ";
let norm_coef =
Array.map Cs.normalizations contr
in
let norm_coef_scale = Cs.norm_scales contr.(0)
in
{ index ; expo ; coef ; center ; ang_mom ; norm_coef ;
norm_coef_scale ; contr }
let with_index a i =
{ a with index = i }
#+end_src
** Printers
#+begin_src ocaml :tangle (eval mli)
val pp : Format.formatter -> t -> unit
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
let pp ppf s =
let open Format in
fprintf ppf "@[%3d-%-3d@]" (s.index+1) (s.index+ (size_of_shell s)*(size s));
fprintf ppf "@[%a@ %a@] @[" Am.pp_string s.ang_mom Co.pp s.center;
Array.iter2 (fun e_arr c_arr -> fprintf ppf "@[<v>";
Array.iter2 (fun e c -> fprintf ppf "@[%16.8e %16.8e@]@;" e c)
e_arr c_arr;
fprintf ppf "@;@]") s.expo s.coef;
fprintf ppf "@]"
#+end_src

View File

@ -1,161 +0,0 @@
#+begin_src elisp tangle: no :results none :exports none
(setq pwd (file-name-directory buffer-file-name))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq lib (concat pwd "lib/"))
(setq testdir (concat pwd "test/"))
(setq mli (concat lib name ".mli"))
(setq ml (concat lib name ".ml"))
(setq test-ml (concat testdir name ".ml"))
(org-babel-tangle)
#+end_src
* Atomic shell pair
:PROPERTIES:
:header-args: :noweb yes :comments both
:END:
Data structure to represent pairs of atomic shells. The products of
functions in the shell pair are one-electron functions.
An atomic shell pair is an array of pairs of contracted shells.
** Type
#+begin_src ocaml :tangle (eval mli)
type t
open Common
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
open Common
type t =
{
contracted_shell_pairs : Contracted_shell_pair.t list;
atomic_shell_a : Atomic_shell.t;
atomic_shell_b : Atomic_shell.t;
}
module Am = Angular_momentum
module As = Atomic_shell
module Co = Coordinate
module Cs = Contracted_shell
module Csp = Contracted_shell_pair
#+end_src
** Access
#+begin_src ocaml :tangle (eval mli)
val atomic_shell_a : t -> Atomic_shell.t
val atomic_shell_b : t -> Atomic_shell.t
val contracted_shell_pairs : t -> Contracted_shell_pair.t list
val ang_mom : t -> Angular_momentum.t
val monocentric : t -> bool
val norm_scales : t -> float array
val a_minus_b : t -> Coordinate.t
val a_minus_b_sq : t -> float
#+end_src
| ~atomic_shell_a~ | Returns the first ~Atomic_shell.t~ which was used to build the atomic shell pair. |
| ~atomic_shell_b~ | Returns the second ~Atomic_shell.t~ which was used to build the atomic shell pair. |
| ~contracted_shell_pairs~ | Returns an array of ~ContractedShellPair.t~, containing all the pairs of contracted functions used to build the atomic shell pair. |
| ~norm_scales~ | norm_coef.(i) / norm_coef.(0) |
| ~ang_mom~ | Total angular Momentum |
| ~monocentric~ | If true, the two atomic shells have the same center. |
| ~a_minus_b~ | Returns $A-B$ |
| ~a_minus_b_sq~ | Returns $\vert A-B \vert^2$ |
#+begin_src ocaml :tangle (eval ml) :exports none
let atomic_shell_a x = x.atomic_shell_a
let atomic_shell_b x = x.atomic_shell_b
let contracted_shell_pairs x = x.contracted_shell_pairs
let monocentric x =
Csp.monocentric @@ List.hd x.contracted_shell_pairs
let a_minus_b x =
Csp.a_minus_b @@ List.hd x.contracted_shell_pairs
let a_minus_b_sq x =
Csp.a_minus_b_sq @@ List.hd x.contracted_shell_pairs
let ang_mom x =
Csp.ang_mom @@ List.hd x.contracted_shell_pairs
let norm_scales x =
Csp.norm_scales @@ List.hd x.contracted_shell_pairs
#+end_src
** Creation
#+begin_src ocaml :tangle (eval mli)
val make : ?cutoff:float -> Atomic_shell.t -> Atomic_shell.t -> t option
#+end_src
Creates an atomic shell pair from two atomic shells.
The contracted shell pairs contains the only pairs of primitives for which
the norm is greater than ~cutoff~.
If all the contracted shell pairs are not significant, the function returns
~None~.
#+begin_src ocaml :tangle (eval mli)
val of_atomic_shell_array : ?cutoff:float -> Atomic_shell.t array -> t option array array
#+end_src
Creates all possible atomic shell pairs from an array of atomic shells.
If an atomic shell pair is not significant, sets the value to ~None~.
#+begin_src ocaml :tangle (eval ml) :exports none
let make ?(cutoff=Constants.epsilon) atomic_shell_a atomic_shell_b =
let l_a = Array.to_list (As.contracted_shells atomic_shell_a)
and l_b = Array.to_list (As.contracted_shells atomic_shell_b)
in
let contracted_shell_pairs =
List.concat_map (fun s_a ->
List.map (fun s_b ->
if Cs.index s_b <= Cs.index s_a then
Csp.make ~cutoff s_a s_b
else
None
) l_b
) l_a
|> Util.list_some
in
match contracted_shell_pairs with
| [] -> None
| _ -> Some { atomic_shell_a ; atomic_shell_b ; contracted_shell_pairs }
let of_atomic_shell_array ?(cutoff=Constants.epsilon) basis =
Array.mapi (fun i shell_a ->
Array.map (fun shell_b ->
make ~cutoff shell_a shell_b)
(Array.sub basis 0 (i+1))
) basis
#+end_src
** Printers
#+begin_src ocaml :tangle (eval mli)
val pp : Format.formatter -> t -> unit
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
let pp ppf s =
let open Format in
fprintf ppf "@[%a@ %a@]"
Atomic_shell.pp s.atomic_shell_a
Atomic_shell.pp s.atomic_shell_b
#+end_src

View File

@ -1,168 +0,0 @@
#+begin_src elisp tangle: no :results none :exports none
(setq pwd (file-name-directory buffer-file-name))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq lib (concat pwd "lib/"))
(setq testdir (concat pwd "test/"))
(setq mli (concat lib name ".mli"))
(setq ml (concat lib name ".ml"))
(setq test-ml (concat testdir name ".ml"))
(org-babel-tangle)
#+end_src
* Atomic shell pair couple
:PROPERTIES:
:header-args: :noweb yes :comments both
:END:
An atomic shell pair couple is the cartesian product between two sets of functions, one
set over electron one and one set over electron two. Both sets are atomic shell
pairs.
These are usually called /shell quartets/ in the literature, but we prefer to use
/pair/ for two functions with the same electron, and /couple/ for two functions
acting on different electrons, since they will be coupled by a two-electron operator.
** Type
#+begin_src ocaml :tangle (eval mli)
type t
open Common
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
open Common
type t =
{
contracted_shell_pair_couples : Contracted_shell_pair_couple.t list ;
atomic_shell_pair_p: Atomic_shell_pair.t ;
atomic_shell_pair_q: Atomic_shell_pair.t ;
atomic_shell_a : Atomic_shell.t ;
atomic_shell_b : Atomic_shell.t ;
atomic_shell_c : Atomic_shell.t ;
atomic_shell_d : Atomic_shell.t ;
ang_mom : Angular_momentum.t ;
}
module Am = Angular_momentum
module Co = Coordinate
module As = Atomic_shell
module Asp = Atomic_shell_pair
module Cspc = Contracted_shell_pair_couple
#+end_src
** Access
#+begin_src ocaml :tangle (eval mli)
val ang_mom : t -> Angular_momentum.t
val atomic_shell_a : t -> Atomic_shell.t
val atomic_shell_b : t -> Atomic_shell.t
val atomic_shell_c : t -> Atomic_shell.t
val atomic_shell_d : t -> Atomic_shell.t
val atomic_shell_pair_p : t -> Atomic_shell_pair.t
val atomic_shell_pair_q : t -> Atomic_shell_pair.t
val contracted_shell_pair_couples : t -> Contracted_shell_pair_couple.t list
val monocentric : t -> bool
val norm_scales : t -> float array
val zkey_array : t -> Zkey.t array
#+end_src
| ~ang_mom~ | Total angular momentum of the shell pair couple: sum of the angular momenta of all the shells. |
| ~atomic_shell_a~ | Returns the first atomic shell of the first shell pair. |
| ~atomic_shell_b~ | Returns the second atomic shell of the first shell pair. |
| ~atomic_shell_c~ | Returns the first atomic shell of the second shell pair. |
| ~atomic_shell_d~ | Returns the second atomic shell of the second shell pair. |
| ~atomic_shell_pair_p~ | Returns the first atomic shell pair that was used to build the shell pair. |
| ~atomic_shell_pair_q~ | Returns the second atomic shell pair that was used to build the shell pair. |
| ~contracted_shell_pair_couples~ | Returns the list of significant contracted shell pair couples. |
| ~monocentric~ | True if all four atomic shells have the same center. |
| ~norm_scales~ | Scaling factors of normalization coefficients inside the shell. The ordering is the same as ~zkey_array~. |
| ~zkey_array~ | Returns the array of ~Zkey.t~ relative to the four shells of the shell pair couple. |
#+begin_src ocaml :tangle (eval ml) :exports none
let contracted_shell_pair_couples t = t.contracted_shell_pair_couples
let monocentric t =
Asp.monocentric t.atomic_shell_pair_p && Asp.monocentric t.atomic_shell_pair_q &&
As.center (Asp.atomic_shell_a t.atomic_shell_pair_p) = As.center (Asp.atomic_shell_a t.atomic_shell_pair_q)
let ang_mom t = t.ang_mom
let atomic_shell_pair_p t = t.atomic_shell_pair_p
let atomic_shell_pair_q t = t.atomic_shell_pair_q
let atomic_shell_a t = t.atomic_shell_a
let atomic_shell_b t = t.atomic_shell_b
let atomic_shell_c t = t.atomic_shell_c
let atomic_shell_d t = t.atomic_shell_d
let zkey_array t =
match t.contracted_shell_pair_couples with
| f::_ -> Cspc.zkey_array f
| _ -> invalid_arg "AtomicShellPairCouple.zkey_array"
let norm_scales t =
match t.contracted_shell_pair_couples with
| f::_ -> Cspc.norm_scales f
| _ -> invalid_arg "AtomicShellPairCouple.norm_scales"
#+end_src
** Creation
#+begin_src ocaml :tangle (eval mli)
val make : ?cutoff:float -> Atomic_shell_pair.t -> Atomic_shell_pair.t -> t option
#+end_src
Default cutoff is $\epsilon$.
| ~make~ | Creates an atomic shell pair couple using two atomic shell pairs. |
#+begin_example
#+end_example
#+begin_src ocaml :tangle (eval ml) :exports none
let make ?(cutoff=Constants.epsilon) atomic_shell_pair_p atomic_shell_pair_q =
let ang_mom =
Am.(Asp.ang_mom atomic_shell_pair_p + Asp.ang_mom atomic_shell_pair_q)
in
let atomic_shell_a = Asp.atomic_shell_a atomic_shell_pair_p
and atomic_shell_b = Asp.atomic_shell_b atomic_shell_pair_p
and atomic_shell_c = Asp.atomic_shell_a atomic_shell_pair_q
and atomic_shell_d = Asp.atomic_shell_b atomic_shell_pair_q
in
let contracted_shell_pair_couples =
List.concat_map (fun ap_ab ->
List.map (fun ap_cd ->
Cspc.make ~cutoff ap_ab ap_cd
) (Asp.contracted_shell_pairs atomic_shell_pair_q)
) (Asp.contracted_shell_pairs atomic_shell_pair_p)
|> Util.list_some
in
match contracted_shell_pair_couples with
| [] -> None
| _ -> Some { atomic_shell_pair_p ; atomic_shell_pair_q ; ang_mom ;
atomic_shell_a ; atomic_shell_b ; atomic_shell_c ; atomic_shell_d ;
contracted_shell_pair_couples ;
}
#+end_src
** Printers
#+begin_src ocaml :tangle (eval mli)
val pp : Format.formatter -> t -> unit
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
let pp ppf t =
Format.fprintf ppf "[(%d,%d),(%d,%d)]"
(Atomic_shell.index t.atomic_shell_a)
(Atomic_shell.index t.atomic_shell_b)
(Atomic_shell.index t.atomic_shell_c)
(Atomic_shell.index t.atomic_shell_d)
#+end_src

View File

@ -1,4 +1,5 @@
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Type][Type:2]] *)
(** Types and modules *)
open Common
type t = {
@ -15,27 +16,11 @@ type t = {
module Am = Angular_momentum
module Co = Coordinate
module Cs = Contracted_shell
(* Type:2 ends here *)
(* | ~ang_mom~ | Total angular momentum : $l = n_x + n_y + n_z$. |
* | ~center~ | Coordinate of the center $\mathbf{A} = (X_A,Y_A,Z_A)$. |
* | ~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. |
* | ~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. |
* | ~index~ | Index in the basis set, represented as an array of contracted shells. |
* | ~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~. |
* | ~size~ | Number of contracted functions, $n$ in the definition. |
* | ~size_of_shell~ | Number of contracted functions in the shell: length of ~norm_coef_scale~. |
*
* #+begin_example
*
* #+end_example *)
(** Access *)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Access][Access:2]] *)
let ang_mom t = t.ang_mom
let center t = t.center
let coefficients t = t.coef
@ -46,16 +31,9 @@ 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
(* Access:2 ends here *)
(* | ~make~ | Creates a contracted shell from a list of coefficients and primitives. |
* | ~with_index~ | Returns a copy of the contracted shell with a modified index. | *)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Creation][Creation:2]] *)
let make ?(index=0) contr =
let make ?(index=0) contr =
assert (Array.length contr > 0);
let coef = Array.map Cs.coefficients contr
@ -69,7 +47,7 @@ let make ?(index=0) contr =
in
if not (unique_center (Array.length contr - 1)) then
invalid_arg "ContractedAtomicShell.make Coordinate.t differ";
let ang_mom = Cs.ang_mom contr.(0) in
let rec unique_angmom = function
| 0 -> true
@ -77,9 +55,9 @@ let make ?(index=0) contr =
in
if not (unique_angmom (Array.length contr - 1)) then
invalid_arg "Contracted_shell.make: Angular_momentum.t differ";
let norm_coef =
Array.map Cs.normalizations contr
Array.map Cs.normalizations contr
in
let norm_coef_scale = Cs.norm_scales contr.(0)
in
@ -89,9 +67,10 @@ let make ?(index=0) contr =
let with_index a i =
{ a with index = i }
(* Creation:2 ends here *)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Printers][Printers:2]] *)
(** Printers *)
let pp ppf s =
let open Format in
fprintf ppf "@[%3d-%-3d@]" (s.index+1) (s.index+ (size_of_shell s)*(size s));
@ -101,4 +80,3 @@ let pp ppf s =
e_arr c_arr;
fprintf ppf "@;@]") s.expo s.coef;
fprintf ppf "@]"
(* Printers:2 ends here *)

View File

@ -1,40 +1,97 @@
(* Type *)
(** Atomic Shell *)
(**
* Set of contracted Gaussians differing only by the powers of $x$, $y$
* and $z$, with a constant ~Angular_momentum.t~, all centered on the same
* point.
*
* In other words, it is the set of all contracted shells sharing the same
* center.
*
* \begin{align*}
* \chi_{n_x,n_y,n_z}(r) & = f(n_x,n_y,n_z) \sum_{j=1}^{n} \sum_{i=1}^{m} \mathcal{N}_{ij}\, d_{ij}\, g_{ij\,n_x,n_y,n_z}(r) \\
* & = (x-X_A)^{n_x} (y-Y_A)^{n_y} (z-Z_A)^{n_z} f(n_x,n_y,n_z) \sum_{j=1}^{n} \sum_{i=1}^{m} \mathcal{N}_{ij}\, d_{ij}\, \exp \left( -\alpha_{ij} |r-R_A|^2 \right)
* \end{align*}
*
* where:
*
* - $g_{ij\,n_x,n_y,n_z}(r)$ is the $i$-th ~PrimitiveShell.t~ of the
* $j$-th ~Contracted_shell.t~
* - $n_x + n_y + n_z = l$, the total angular momentum
* - $\alpha_{ij}$ are the exponents (tabulated) of the $j$-th
* ~Contracted_shell.t~
* - $d_{ij}$ are the contraction coefficients of the $j$-th
* ~Contracted_shell.t~
* - $\mathcal{N}_{ij}$ is the normalization coefficient of the $i$-th
* primitive shell
* (~PrimitiveShell.norm_coef~) of the $j$-th ~Contracted_shell.t~
* - $f(n_x,n_y,n_z)$ is a scaling factor adjusting the normalization
* coefficient for the particular powers of $x,y,z$
* (~PrimitiveShell.norm_coef_scale~)
*)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Type][Type:1]] *)
(** Types and modules *)
type t
open Common
(* Type:1 ends here *)
(* Access *)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Access][Access:1]] *)
(** Access *)
val ang_mom : t -> Angular_momentum.t
(** Total angular momentum : $l = n_x + n_y + n_z$. *)
val center : t -> Coordinate.t
(** Coordinate of the center $\mathbf{A} = (X_A,Y_A,Z_A)$. *)
val coefficients : t -> float array array
(** 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.
*)
val contracted_shells : t -> Contracted_shell.t array
(** Array of contracted gaussians *)
val exponents : t -> float array array
(** 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.
*)
val index : t -> int
(** Index in the basis set, represented as an array of contracted shells. *)
val normalizations : t -> float array array
(** 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.
*)
val norm_scales : t -> float array
(** Scaling factors $f(n_x,n_y,n_z)$, given in the same order as
* ~Angular_momentum.zkey_array ang_mom~.
*)
val size_of_shell : t -> int
(** Number of contracted functions in the shell: length of
* ~norm_coef_scale~.
*)
val size : t -> int
(* Access:1 ends here *)
(* Creation *)
(** Number of contracted functions, $n$ in the definition. *)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Creation][Creation:1]] *)
val make : ?index:int -> Contracted_shell.t array -> t
(** Creation *)
val make : ?index:int -> Contracted_shell.t array -> t
(** Creates a contracted shell from a list of coefficients and primitives. *)
val with_index : t -> int -> t
(* Creation:1 ends here *)
(* Printers *)
(** Returns a copy of the contracted shell with a modified index. *)
(* [[file:~/QCaml/gaussian/atomic_shell.org::*Printers][Printers:1]] *)
(** Printers *)
val pp : Format.formatter -> t -> unit
(* Printers:1 ends here *)

View File

@ -1,4 +1,4 @@
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Type][Type:2]] *)
(** Type *)
open Common
type t =
@ -14,21 +14,10 @@ module As = Atomic_shell
module Co = Coordinate
module Cs = Contracted_shell
module Csp = Contracted_shell_pair
(* Type:2 ends here *)
(** Access *)
(* | ~atomic_shell_a~ | Returns the first ~Atomic_shell.t~ which was used to build the atomic shell pair. |
* | ~atomic_shell_b~ | Returns the second ~Atomic_shell.t~ which was used to build the atomic shell pair. |
* | ~contracted_shell_pairs~ | Returns an array of ~ContractedShellPair.t~, containing all the pairs of contracted functions used to build the atomic shell pair. |
* | ~norm_scales~ | norm_coef.(i) / norm_coef.(0) |
* | ~ang_mom~ | Total angular Momentum |
* | ~monocentric~ | If true, the two atomic shells have the same center. |
* | ~a_minus_b~ | Returns $A-B$ |
* | ~a_minus_b_sq~ | Returns $\vert A-B \vert^2$ | *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Access][Access:2]] *)
let atomic_shell_a x = x.atomic_shell_a
let atomic_shell_b x = x.atomic_shell_b
let contracted_shell_pairs x = x.contracted_shell_pairs
@ -47,15 +36,10 @@ let ang_mom x =
let norm_scales x =
Csp.norm_scales @@ List.hd x.contracted_shell_pairs
(* Access:2 ends here *)
(** Creation *)
(* Creates all possible atomic shell pairs from an array of atomic shells.
* If an atomic shell pair is not significant, sets the value to ~None~. *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Creation][Creation:3]] *)
let make ?(cutoff=Constants.epsilon) atomic_shell_a atomic_shell_b =
let l_a = Array.to_list (As.contracted_shells atomic_shell_a)
@ -85,12 +69,13 @@ let of_atomic_shell_array ?(cutoff=Constants.epsilon) basis =
make ~cutoff shell_a shell_b)
(Array.sub basis 0 (i+1))
) basis
(* Creation:3 ends here *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Printers][Printers:2]] *)
(** Printers *)
let pp ppf s =
let open Format in
fprintf ppf "@[%a@ %a@]"
Atomic_shell.pp s.atomic_shell_a
Atomic_shell.pp s.atomic_shell_b
(* Printers:2 ends here *)

View File

@ -1,35 +1,52 @@
(* Type *)
(** Atomic shell pair *)
(** Data structure to represent pairs of atomic shells. The products of
* functions in the shell pair are one-electron functions.
*
* An atomic shell pair is an array of pairs of contracted shells.
*)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Type][Type:1]] *)
(** Type *)
type t
open Common
(* Type:1 ends here *)
(* Access *)
(** Access *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Access][Access:1]] *)
val atomic_shell_a : t -> Atomic_shell.t
(** Returns the first ~Atomic_shell.t~ which was used to build the atomic
* shell pair. *)
val atomic_shell_b : t -> Atomic_shell.t
(** Returns the second ~Atomic_shell.t~ which was used to build the atomic
* shell pair. *)
val contracted_shell_pairs : t -> Contracted_shell_pair.t list
(** Returns an array of ~ContractedShellPair.t~, containing all the pairs of
* contracted functions used to build the atomic shell pair.
*)
val ang_mom : t -> Angular_momentum.t
(** Total angular Momentum *)
val monocentric : t -> bool
(** If true, the two atomic shells have the same center. *)
val norm_scales : t -> float array
(** norm_coef.(i) / norm_coef.(0) *)
val a_minus_b : t -> Coordinate.t
(** Returns $A-B$ *)
val a_minus_b_sq : t -> float
(* Access:1 ends here *)
(* Creation *)
(** Returns $\vert A-B \vert^2$ *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Creation][Creation:1]] *)
(** Creation *)
val make : ?cutoff:float -> Atomic_shell.t -> Atomic_shell.t -> t option
(* Creation:1 ends here *)
(* Creates an atomic shell pair from two atomic shells.
*
* The contracted shell pairs contains the only pairs of primitives for which
@ -38,14 +55,14 @@ val make : ?cutoff:float -> Atomic_shell.t -> Atomic_shell.t -> t option
* If all the contracted shell pairs are not significant, the function returns
* ~None~. *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Creation][Creation:2]] *)
val of_atomic_shell_array : ?cutoff:float -> Atomic_shell.t array -> t option array array
(* Creation:2 ends here *)
(* Printers *)
(** Creates all possible atomic shell pairs from an array of atomic shells.
* If an atomic shell pair is not significant, sets the value to ~None~.
*)
(* [[file:~/QCaml/gaussian/atomic_shell_pair.org::*Printers][Printers:1]] *)
(** Printers *)
val pp : Format.formatter -> t -> unit
(* Printers:1 ends here *)

View File

@ -1,7 +1,10 @@
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Type][Type:2]] *)
(** Atomic shell pair couple *)
open Common
type t =
(** Type *)
type t =
{
contracted_shell_pair_couples : Contracted_shell_pair_couple.t list ;
atomic_shell_pair_p: Atomic_shell_pair.t ;
@ -18,24 +21,10 @@ module Co = Coordinate
module As = Atomic_shell
module Asp = Atomic_shell_pair
module Cspc = Contracted_shell_pair_couple
(* Type:2 ends here *)
(** Access *)
(* | ~ang_mom~ | Total angular momentum of the shell pair couple: sum of the angular momenta of all the shells. |
* | ~atomic_shell_a~ | Returns the first atomic shell of the first shell pair. |
* | ~atomic_shell_b~ | Returns the second atomic shell of the first shell pair. |
* | ~atomic_shell_c~ | Returns the first atomic shell of the second shell pair. |
* | ~atomic_shell_d~ | Returns the second atomic shell of the second shell pair. |
* | ~atomic_shell_pair_p~ | Returns the first atomic shell pair that was used to build the shell pair. |
* | ~atomic_shell_pair_q~ | Returns the second atomic shell pair that was used to build the shell pair. |
* | ~contracted_shell_pair_couples~ | Returns the list of significant contracted shell pair couples. |
* | ~monocentric~ | True if all four atomic shells have the same center. |
* | ~norm_scales~ | Scaling factors of normalization coefficients inside the shell. The ordering is the same as ~zkey_array~. |
* | ~zkey_array~ | Returns the array of ~Zkey.t~ relative to the four shells of the shell pair couple. | *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Access][Access:2]] *)
let contracted_shell_pair_couples t = t.contracted_shell_pair_couples
let monocentric t =
@ -59,24 +48,15 @@ let zkey_array t =
| f::_ -> Cspc.zkey_array f
| _ -> invalid_arg "AtomicShellPairCouple.zkey_array"
let norm_scales t =
let norm_scales t =
match t.contracted_shell_pair_couples with
| f::_ -> Cspc.norm_scales f
| _ -> invalid_arg "AtomicShellPairCouple.norm_scales"
(* Access:2 ends here *)
(* Default cutoff is $\epsilon$.
*
* | ~make~ | Creates an atomic shell pair couple using two atomic shell pairs. |
*
* #+begin_example
*
* #+end_example *)
(** Creation *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Creation][Creation:2]] *)
let make ?(cutoff=Constants.epsilon) atomic_shell_pair_p atomic_shell_pair_q =
let make ?(cutoff=Constants.epsilon) atomic_shell_pair_p atomic_shell_pair_q =
let ang_mom =
Am.(Asp.ang_mom atomic_shell_pair_p + Asp.ang_mom atomic_shell_pair_q)
in
@ -86,26 +66,24 @@ let make ?(cutoff=Constants.epsilon) atomic_shell_pair_p atomic_shell_pair_q =
and atomic_shell_d = Asp.atomic_shell_b atomic_shell_pair_q
in
let contracted_shell_pair_couples =
List.concat_map (fun ap_ab ->
List.map (fun ap_cd ->
List.concat_map (fun ap_ab ->
List.map (fun ap_cd ->
Cspc.make ~cutoff ap_ab ap_cd
) (Asp.contracted_shell_pairs atomic_shell_pair_q)
) (Asp.contracted_shell_pairs atomic_shell_pair_p)
|> Util.list_some
in
match contracted_shell_pair_couples with
| [] -> None
| [] -> None
| _ -> Some { atomic_shell_pair_p ; atomic_shell_pair_q ; ang_mom ;
atomic_shell_a ; atomic_shell_b ; atomic_shell_c ; atomic_shell_d ;
contracted_shell_pair_couples ;
}
(* Creation:2 ends here *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Printers][Printers:2]] *)
(** Printers *)
let pp ppf t =
Format.fprintf ppf "[(%d,%d),(%d,%d)]"
(Atomic_shell.index t.atomic_shell_a)
(Atomic_shell.index t.atomic_shell_b)
(Atomic_shell.index t.atomic_shell_c)
(Atomic_shell.index t.atomic_shell_d)
(* Printers:2 ends here *)

View File

@ -1,39 +1,78 @@
(* Type *)
(** Atomic shell pair couple *)
(** An atomic shell pair couple is the cartesian product between two sets of
* functions, one set over electron one and one set over electron two. Both
* sets are atomic shell pairs.
*)
(** These are usually called /shell quartets/ in the literature, but we
* prefer to use /pair/ for two functions with the same electron, and
* /couple/ for two functions acting on different electrons, since they will
* be coupled by a two-electron operator.
*)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Type][Type:1]] *)
(** Type *)
type t
open Common
(* Type:1 ends here *)
(* Access *)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Access][Access:1]] *)
(** Access *)
val ang_mom : t -> Angular_momentum.t
(** Total angular momentum of the shell pair couple: sum of the angular
* momenta of all the shells.
*)
val atomic_shell_a : t -> Atomic_shell.t
(** Returns the first atomic shell of the first shell pair. *)
val atomic_shell_b : t -> Atomic_shell.t
(** Returns the second atomic shell of the first shell pair. *)
val atomic_shell_c : t -> Atomic_shell.t
(** Returns the first atomic shell of the second shell pair. *)
val atomic_shell_d : t -> Atomic_shell.t
(** Returns the second atomic shell of the second shell pair. *)
val atomic_shell_pair_p : t -> Atomic_shell_pair.t
(** Returns the first atomic shell pair that was used to build the shell
* pair.
*)
val atomic_shell_pair_q : t -> Atomic_shell_pair.t
(** Returns the second atomic shell pair that was used to build the shell
* pair.
*)
val contracted_shell_pair_couples : t -> Contracted_shell_pair_couple.t list
(** Returns the list of significant contracted shell pair couples. *)
val monocentric : t -> bool
(** True if all four atomic shells have the same center. *)
val norm_scales : t -> float array
(** Scaling factors of normalization coefficients inside the shell. The
* ordering is the same as ~zkey_array~.
*)
val zkey_array : t -> Zkey.t array
(* Access:1 ends here *)
(* Creation *)
(** Returns the array of ~Zkey.t~ relative to the four shells of the shell
* pair couple.
*)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Creation][Creation:1]] *)
(** Creation *)
val make : ?cutoff:float -> Atomic_shell_pair.t -> Atomic_shell_pair.t -> t option
(* Creation:1 ends here *)
(* Printers *)
(** Creates an atomic shell pair couple using two atomic shell pairs.
* Default cutoff is $\epsilon$.
*)
(* [[file:~/QCaml/gaussian/atomic_shell_pair_couple.org::*Printers][Printers:1]] *)
(** Printers *)
val pp : Format.formatter -> t -> unit
(* Printers:1 ends here *)