10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-19 04:22:21 +01:00
QCaml/Basis/Basis.ml

72 lines
1.9 KiB
OCaml

type t =
{
size : int;
contracted_shells : Contracted_shell.t array;
}
let size b = b.size
let contracted_shells b = b.contracted_shells
(** Returns an array of the basis set per atom *)
let of_nuclei_and_general_basis n b =
let result =
Array.map (fun (e, center) ->
List.assoc e b
|> Array.map (fun (totAngMom, shell) ->
let expo = Array.map (fun General_basis.{exponent ; coefficient} ->
exponent) shell
and coef = Array.map (fun General_basis.{exponent ; coefficient} ->
coefficient) shell
in
Contracted_shell.create ~expo ~coef ~totAngMom ~center ~index:0)
) n
|> Array.to_list
|> Array.concat
in
Array.iteri (fun i x ->
if (i > 0) then
result.(i) <- Contracted_shell.with_index x (
(Contracted_shell.index result.(i-1)) +
(Array.length (Contracted_shell.powers result.(i-1))))
) result ;
let size =
let n = ref 0 in
for i=0 to (Array.length result) - 1 do
n := !n + (Array.length (Contracted_shell.powers (result.(i))))
done; !n
in
{ contracted_shells = result ; size }
let to_string b =
let b = b.contracted_shells in
let line ="
-----------------------------------------------------------------------
" in
"
Atomic Basis set
----------------
-----------------------------------------------------------------------
# Angular Coordinates (Bohr) Exponents Coefficients
Momentum X Y Z
-----------------------------------------------------------------------
"
^
( Array.map (fun i ->
Contracted_shell.to_string i) b
|> Array.to_list
|> String.concat line
)
^ line
let of_nuclei_and_basis_filename ~nuclei ~filename =
let general_basis =
Gamess_reader.read ~filename
in
of_nuclei_and_general_basis nuclei general_basis