10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-14 17:25:19 +02:00
QCaml/Basis/Basis.ml

67 lines
1.7 KiB
OCaml
Raw Normal View History

2018-01-19 03:14:06 +01:00
type t = Contracted_shell.t array
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) ->
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
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
result.(i) <- Contracted_shell.with_index x (
(Contracted_shell.index result.(i-1)) +
(Array.length (Contracted_shell.powers result.(i-1))))
2018-01-19 17:42:12 +01:00
) result ;
result
2018-01-18 00:21:05 +01:00
let to_string b =
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 ->
Contracted_shell.to_string i) b
|> Array.to_list
|> String.concat line
)
^ line
2017-12-30 19:06:07 +01:00
2018-01-22 23:19:24 +01:00
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)
)
2018-01-18 23:42:48 +01:00