QCaml/Basis/Basis.ml

66 lines
1.7 KiB
OCaml

type t = Contracted_shell.t array
(** 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 ~indice:0)
) n
|> Array.to_list
|> Array.concat
in
Array.iteri (fun i x ->
if (i > 0) then
result.(i) <- {x with Contracted_shell.indice= (
result.(i-1).Contracted_shell.indice + (Array.length result.(i-1).Contracted_shell.powers)) }
) result ;
result
let to_string b =
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 file : string option ref = ref None
let set_file f =
file := Some f
let general_basis = lazy(
match !file with
| None -> failwith "basis set file not defined"
| Some filename -> Gamess_reader.read ~filename
)
let basis = lazy (
of_nuclei_and_general_basis
(Lazy.force Nuclei.nuclei) (Lazy.force general_basis)
)