10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-07-16 16:10:22 +02:00
QCaml/ao/lib/basis.ml

203 lines
5.6 KiB
OCaml
Raw Normal View History

2021-01-04 23:15:27 +01:00
(* [[file:~/QCaml/ao/basis.org::*Types][Types:2]] *)
2020-10-02 23:35:56 +02:00
type t =
2020-10-19 18:33:02 +02:00
{ ao_basis : Basis_poly.t ;
2020-10-02 23:35:56 +02:00
cartesian : bool
}
2020-10-07 17:54:15 +02:00
2020-10-18 01:58:22 +02:00
type ao = Ao_dim.t
2021-01-04 09:19:35 +01:00
open Linear_algebra
open Common
2021-01-04 23:15:27 +01:00
(* Types:2 ends here *)
2021-01-04 09:19:35 +01:00
2021-01-28 00:34:26 +01:00
(* |--------------------------------+------------------------------------------------------------------------------------------------------------------------|
* | ~of_nuclei_and_basis_filename~ | Creates the data structure for the atomic orbitals basis from a molecule ~Nuclei.t~ and the name of the basis-set file |
* |--------------------------------+------------------------------------------------------------------------------------------------------------------------|
2021-01-04 23:15:27 +01:00
*
* Defaults:
* - ~kind~ : ~`Gaussian~
* - ~operators~ : ~[]~
* - ~cartesian~ : ~false~
*
2021-01-28 00:34:26 +01:00
* Example:
2021-01-04 23:15:27 +01:00
* #+begin_example
* let b = Ao.Basis.of_nuclei_and_basis_filename ~nuclei filename;;
* val b : Ao.Basis.t = Gaussian Basis, spherical, 15 AOs
* #+end_example *)
2023-04-24 19:01:42 +02:00
2021-01-04 09:19:35 +01:00
(* [[file:~/QCaml/ao/basis.org::*Conversions][Conversions:2]] *)
2023-04-24 19:01:42 +02:00
let not_implemented () =
Util.not_implemented "Only Gaussian is implemented"
2020-10-07 17:54:15 +02:00
let of_nuclei_and_basis_filename ?(kind=`Gaussian) ?operators ?(cartesian=false)
~nuclei filename =
match kind with
| `Gaussian ->
let basis =
2020-10-10 10:59:09 +02:00
Gaussian.Basis.of_nuclei_and_basis_filename ~nuclei filename
2020-10-07 17:54:15 +02:00
in
2023-04-24 19:01:42 +02:00
let ao_basis =
2020-10-19 18:33:02 +02:00
Basis_poly.Gaussian (Basis_gaussian.make ~basis ?operators ~cartesian nuclei )
2020-10-07 17:54:15 +02:00
in
{ ao_basis ; cartesian }
2023-04-24 19:01:42 +02:00
| _ -> not_implemented ()
2021-01-04 09:19:35 +01:00
(* Conversions:2 ends here *)
2021-01-28 00:34:26 +01:00
(* |---------------------+--------------------------------------------------|
* | ~size~ | Number of atomic orbitals in the AO basis set |
2021-01-04 09:19:35 +01:00
* | ~ao_basis~ | One-electron basis set |
* | ~overlap~ | Overlap matrix |
* | ~multipole~ | Multipole matrices |
* | ~ortho~ | Orthonormalization matrix of the overlap |
* | ~eN_ints~ | Electron-nucleus potential integrals |
* | ~kin_ints~ | Kinetic energy integrals |
* | ~ee_ints~ | Electron-electron potential integrals |
* | ~ee_lr_ints~ | Electron-electron long-range potential integrals |
* | ~f12_ints~ | Electron-electron potential integrals |
* | ~f12_over_r12_ints~ | Electron-electron potential integrals |
* | ~cartesian~ | If true, use cartesian Gaussians (6d, 10f, ...) |
2021-01-28 00:34:26 +01:00
* | ~values~ | Values of the AOs evaluated at a given point |
* |---------------------+--------------------------------------------------| *)
2020-10-07 17:54:15 +02:00
2021-01-04 09:19:35 +01:00
(* [[file:~/QCaml/ao/basis.org::*Access][Access:2]] *)
2020-10-07 17:54:15 +02:00
let ao_basis t = t.ao_basis
2023-04-24 19:01:42 +02:00
let size t =
2020-10-07 17:54:15 +02:00
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.size b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
let overlap t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.overlap b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Matrix.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let multipole t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b ->
let m = Basis_gaussian.multipole b in
fun s ->
Gaussian_integrals.Multipole.matrix m s
|> Matrix.relabel
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let ortho t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.ortho b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Matrix.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let eN_ints t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.eN_ints b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Matrix.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let kin_ints t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.kin_ints b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Matrix.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let ee_ints t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.ee_ints b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Four_idx_storage.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let ee_lr_ints t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.ee_lr_ints b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Four_idx_storage.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let f12_ints t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.f12_ints b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Four_idx_storage.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let f12_over_r12_ints t =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.f12_over_r12_ints b
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Four_idx_storage.relabel
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let cartesian t = t.cartesian
2023-04-24 19:01:42 +02:00
2020-10-07 17:54:15 +02:00
let values t point =
begin
match t.ao_basis with
2020-10-19 18:33:02 +02:00
| Basis_poly.Gaussian b -> Basis_gaussian.values b point
2020-10-07 17:54:15 +02:00
| _ -> not_implemented ()
end
|> Vector.relabel
2021-01-04 09:19:35 +01:00
(* Access:2 ends here *)
2023-04-24 19:01:42 +02:00
(* [[file:~/QCaml/ao/basis.org::*Read][Read:2]] *)
(*
let of_trexio f =
match Trexio.read_basis_type f with
| "G"
| "Gaussian"
| "gaussian" ->
let basis =
Gaussian.Basis.of_trexio f
in
let ao_basis =
Basis_poly.Gaussian (Basis_gaussian.make ~basis ?operators ~cartesian nuclei )
in
{ ao_basis ; cartesian }
| _ -> not_implemented ()
*)
(* Read:2 ends here *)
(* [[file:~/QCaml/ao/basis.org::*Write][Write:2]] *)
(*
let to_trexio f t =
match t.ao_basis with
| Basis_poly.Gaussian b -> Gaussian.Basis.to_trexio f (Basis_gaussian.basis b))
| _ -> not_implemented ()
*)
(* Write:2 ends here *)
2021-01-04 09:19:35 +01:00
(* [[file:~/QCaml/ao/basis.org::*Printers][Printers:2]] *)
let pp ppf t =
2021-01-04 23:15:27 +01:00
begin
match t.ao_basis with
| Basis_poly.Gaussian b -> Basis_gaussian.pp ppf b
| _ -> not_implemented ()
end
2021-01-04 09:19:35 +01:00
(* Printers:2 ends here *)