10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 14:43:41 +01:00
QCaml/Basis/Basis.ml

75 lines
1.7 KiB
OCaml
Raw Normal View History

2018-02-09 00:37:25 +01:00
type t =
{
size : int;
2018-02-23 18:41:30 +01:00
contracted_shells : ContractedShell.t array;
2018-02-09 00:37:25 +01:00
}
2018-02-23 18:41:30 +01:00
module Cs = ContractedShell
module Gb = GeneralBasis
2018-03-14 16:22:08 +01:00
module Ps = PrimitiveShell
2018-02-23 18:41:30 +01:00
2018-01-18 00:21:05 +01:00
2018-01-18 17:39:10 +01:00
(** Returns an array of the basis set per atom *)
2018-01-18 00:21:05 +01:00
let of_nuclei_and_general_basis n b =
2018-01-19 17:42:12 +01:00
let result =
Array.map (fun (e, center) ->
2018-02-06 18:12:19 +01:00
List.assoc e b
|> Array.map (fun (totAngMom, shell) ->
2018-03-14 16:22:08 +01:00
let lc =
Array.map (fun Gb.{exponent ; coefficient} ->
coefficient, Ps.make totAngMom center exponent) shell
2018-02-06 18:12:19 +01:00
in
2018-03-14 16:22:08 +01:00
Cs.make lc)
2018-02-06 18:12:19 +01:00
) n
2018-01-19 17:42:12 +01:00
|> Array.to_list
|> Array.concat
in
Array.iteri (fun i x ->
2018-02-06 18:12:19 +01:00
if (i > 0) then
2018-02-23 15:49:27 +01:00
result.(i) <- Cs.with_index x (
2018-03-13 18:56:28 +01:00
Cs.index result.(i-1) +
Cs.size_of_shell result.(i-1) )
2018-01-19 17:42:12 +01:00
) result ;
2018-02-09 00:37:25 +01:00
let size =
let n = ref 0 in
for i=0 to (Array.length result) - 1 do
2018-03-13 18:56:28 +01:00
n := !n + Cs.size_of_shell result.(i)
2018-02-09 00:37:25 +01:00
done; !n
in
{ contracted_shells = result ; size }
2018-01-18 00:21:05 +01:00
let to_string b =
2018-02-09 00:37:25 +01:00
let b = b.contracted_shells in
2018-01-18 17:39:10 +01:00
let line ="
-----------------------------------------------------------------------
" in
"
Atomic Basis set
----------------
-----------------------------------------------------------------------
2018-01-19 17:42:12 +01:00
# Angular Coordinates (Bohr) Exponents Coefficients
Momentum X Y Z
2018-01-18 17:39:10 +01:00
-----------------------------------------------------------------------
"
2018-01-19 03:14:06 +01:00
^
2018-02-06 18:12:19 +01:00
( Array.map (fun i ->
2018-02-23 15:49:27 +01:00
Cs.to_string i) b
2018-02-06 18:12:19 +01:00
|> Array.to_list
|> String.concat line
)
^ line
2017-12-30 19:06:07 +01:00
2018-02-23 18:41:30 +01:00
2018-03-08 23:29:08 +01:00
let of_nuclei_and_basis_filename ~nuclei filename =
2018-02-09 00:37:25 +01:00
let general_basis =
2018-03-08 23:29:08 +01:00
GeneralBasis.read filename
2018-02-09 00:37:25 +01:00
in
of_nuclei_and_general_basis nuclei general_basis
2018-01-22 23:19:24 +01:00
2018-01-18 23:42:48 +01:00