2014-10-17 22:25:45 +02:00
|
|
|
open Qptypes;;
|
|
|
|
open Qputils;;
|
|
|
|
open Core.Std;;
|
|
|
|
|
|
|
|
module Ao_basis : sig
|
2014-10-21 23:32:47 +02:00
|
|
|
type t =
|
|
|
|
{ ao_basis : string ;
|
|
|
|
ao_num : AO_number.t ;
|
2014-10-22 00:12:23 +02:00
|
|
|
ao_prim_num : AO_prim_number.t array;
|
|
|
|
ao_prim_num_max : AO_prim_number.t;
|
2014-10-21 23:32:47 +02:00
|
|
|
ao_nucl : Nucl_number.t array;
|
|
|
|
ao_power : Symmetry.Xyz.t array;
|
2014-10-22 00:12:23 +02:00
|
|
|
ao_coef : AO_coef.t array;
|
|
|
|
ao_expo : AO_expo.t array;
|
2014-10-25 21:24:21 +02:00
|
|
|
} with sexp
|
2014-10-21 23:32:47 +02:00
|
|
|
;;
|
2014-10-17 22:25:45 +02:00
|
|
|
val read : unit -> t
|
|
|
|
val to_string : t -> string
|
2014-10-26 17:29:11 +01:00
|
|
|
val to_md5 : t -> MD5.t
|
2014-10-29 22:13:03 +01:00
|
|
|
val to_rst : t -> Rst_string.t
|
2014-10-17 22:25:45 +02:00
|
|
|
end = struct
|
|
|
|
type t =
|
|
|
|
{ ao_basis : string ;
|
|
|
|
ao_num : AO_number.t ;
|
2014-10-22 00:12:23 +02:00
|
|
|
ao_prim_num : AO_prim_number.t array;
|
|
|
|
ao_prim_num_max : AO_prim_number.t;
|
2014-10-17 22:25:45 +02:00
|
|
|
ao_nucl : Nucl_number.t array;
|
|
|
|
ao_power : Symmetry.Xyz.t array;
|
2014-10-22 00:12:23 +02:00
|
|
|
ao_coef : AO_coef.t array;
|
|
|
|
ao_expo : AO_expo.t array;
|
2014-10-25 21:24:21 +02:00
|
|
|
} with sexp
|
2014-10-17 22:25:45 +02:00
|
|
|
;;
|
|
|
|
|
2014-10-18 00:10:25 +02:00
|
|
|
let get_default = Qpackage.get_ezfio_default "ao_basis";;
|
|
|
|
|
2014-10-17 22:25:45 +02:00
|
|
|
let read_ao_basis () =
|
|
|
|
if not (Ezfio.has_ao_basis_ao_basis ()) then
|
|
|
|
Ezfio.set_ao_basis_ao_basis ""
|
|
|
|
;
|
|
|
|
Ezfio.get_ao_basis_ao_basis ()
|
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_num () =
|
|
|
|
Ezfio.get_ao_basis_ao_num ()
|
|
|
|
|> AO_number.of_int
|
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_prim_num () =
|
2014-11-03 17:37:16 +01:00
|
|
|
Ezfio.get_ao_basis_ao_prim_num ()
|
|
|
|
|> Ezfio.flattened_ezfio
|
2014-10-22 00:12:23 +02:00
|
|
|
|> Array.map ~f:AO_prim_number.of_int
|
2014-10-17 22:25:45 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_prim_num_max () =
|
2014-11-03 17:37:16 +01:00
|
|
|
Ezfio.get_ao_basis_ao_prim_num ()
|
|
|
|
|> Ezfio.flattened_ezfio
|
2014-10-17 22:25:45 +02:00
|
|
|
|> Array.fold ~f:(fun x y -> if x>y then x else y) ~init:0
|
2014-10-22 00:12:23 +02:00
|
|
|
|> AO_prim_number.of_int
|
2014-10-17 22:25:45 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_nucl () =
|
2014-10-30 16:26:31 +01:00
|
|
|
let nmax = Nucl_number.get_max () in
|
2014-11-03 17:37:16 +01:00
|
|
|
Ezfio.get_ao_basis_ao_nucl ()
|
|
|
|
|> Ezfio.flattened_ezfio
|
2014-10-30 16:26:31 +01:00
|
|
|
|> Array.map ~f:(fun x-> Nucl_number.of_int ~max:nmax x)
|
2014-10-17 22:25:45 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_power () =
|
|
|
|
let x = Ezfio.get_ao_basis_ao_power () in
|
|
|
|
let dim = x.Ezfio.dim.(0) in
|
2014-11-03 17:37:16 +01:00
|
|
|
let data = Ezfio.flattened_ezfio x in
|
2014-10-17 22:25:45 +02:00
|
|
|
let result = Array.init dim ~f:(fun x -> "") in
|
|
|
|
for i=1 to dim
|
|
|
|
do
|
|
|
|
if (data.(i-1) > 0) then
|
|
|
|
result.(i-1) <- result.(i-1)^"x"^(Int.to_string data.(i-1));
|
|
|
|
if (data.(dim+i-1) > 0) then
|
|
|
|
result.(i-1) <- result.(i-1)^"y"^(Int.to_string data.(dim+i-1));
|
|
|
|
if (data.(2*dim+i-1) > 0) then
|
|
|
|
result.(i-1) <- result.(i-1)^"z"^(Int.to_string data.(2*dim+i-1));
|
|
|
|
done;
|
|
|
|
Array.map ~f:Symmetry.Xyz.of_string result
|
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_coef () =
|
2014-11-03 17:37:16 +01:00
|
|
|
Ezfio.get_ao_basis_ao_coef ()
|
|
|
|
|> Ezfio.flattened_ezfio
|
2014-10-22 00:12:23 +02:00
|
|
|
|> Array.map ~f:AO_coef.of_float
|
2014-10-17 22:25:45 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
let read_ao_expo () =
|
2014-11-03 17:37:16 +01:00
|
|
|
Ezfio.get_ao_basis_ao_expo ()
|
|
|
|
|> Ezfio.flattened_ezfio
|
2014-10-22 00:12:23 +02:00
|
|
|
|> Array.map ~f:AO_expo.of_float
|
2014-10-17 22:25:45 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
let read () =
|
|
|
|
{ ao_basis = read_ao_basis ();
|
|
|
|
ao_num = read_ao_num () ;
|
|
|
|
ao_prim_num = read_ao_prim_num ();
|
|
|
|
ao_prim_num_max = read_ao_prim_num_max ();
|
|
|
|
ao_nucl = read_ao_nucl ();
|
|
|
|
ao_power = read_ao_power ();
|
|
|
|
ao_coef = read_ao_coef () ;
|
|
|
|
ao_expo = read_ao_expo () ;
|
|
|
|
}
|
|
|
|
;;
|
2014-10-26 17:29:11 +01:00
|
|
|
|
|
|
|
let to_long_basis b =
|
2014-10-25 21:24:21 +02:00
|
|
|
let ao_num = AO_number.to_int b.ao_num in
|
|
|
|
let gto_array = Array.init (AO_number.to_int b.ao_num)
|
|
|
|
~f:(fun i ->
|
|
|
|
let s = Symmetry.Xyz.to_symmetry b.ao_power.(i) in
|
|
|
|
let ao_prim_num = AO_prim_number.to_int b.ao_prim_num.(i) in
|
|
|
|
let prims = List.init ao_prim_num ~f:(fun j ->
|
|
|
|
let prim = { Primitive.sym = s ;
|
|
|
|
Primitive.expo = b.ao_expo.(ao_num*j+i)
|
|
|
|
}
|
|
|
|
in
|
|
|
|
let coef = b.ao_coef.(ao_num*j+i) in
|
|
|
|
(prim,coef)
|
|
|
|
) in
|
|
|
|
Gto.of_prim_coef_list prims
|
|
|
|
)
|
|
|
|
in
|
2014-10-26 17:29:11 +01:00
|
|
|
let rec do_work accu sym gto nucl =
|
|
|
|
match (sym, gto, nucl) with
|
|
|
|
| (s::srest, g::grest, n::nrest) ->
|
|
|
|
do_work ((s,g,n)::accu) srest grest nrest
|
|
|
|
| ([],[],[]) -> List.rev accu
|
|
|
|
| _ -> assert false
|
2014-10-26 12:46:17 +01:00
|
|
|
in
|
2014-10-26 17:29:11 +01:00
|
|
|
do_work []
|
|
|
|
(Array.to_list b.ao_power)
|
|
|
|
(Array.to_list gto_array)
|
|
|
|
(Array.to_list b.ao_nucl)
|
|
|
|
;;
|
|
|
|
|
|
|
|
let to_basis b =
|
|
|
|
to_long_basis b
|
|
|
|
|> Long_basis.to_basis
|
|
|
|
;;
|
|
|
|
|
2014-10-29 22:13:03 +01:00
|
|
|
let to_rst b =
|
2014-10-31 23:05:41 +01:00
|
|
|
let print_sym =
|
|
|
|
let l = List.init (Array.length b.ao_power) ~f:(
|
|
|
|
fun i -> ( (i+1),b.ao_nucl.(i),b.ao_power.(i) ) ) in
|
|
|
|
let rec do_work count = function
|
|
|
|
| [] -> []
|
|
|
|
| (i,n,x)::tail ->
|
|
|
|
if (count < 2) then
|
|
|
|
(Printf.sprintf " (%4d) %d:%-8s" i (Nucl_number.to_int n) (Symmetry.Xyz.to_string x))::
|
|
|
|
(do_work (count+1) tail)
|
|
|
|
else
|
|
|
|
(Printf.sprintf " (%4d) %d:%-8s\n" i (Nucl_number.to_int n) (Symmetry.Xyz.to_string x))::
|
|
|
|
(do_work 0 tail)
|
|
|
|
in do_work 0 l
|
|
|
|
|> String.concat
|
|
|
|
in
|
|
|
|
|
2014-10-26 17:29:11 +01:00
|
|
|
let short_basis = to_basis b in
|
2014-10-29 00:12:45 +01:00
|
|
|
Printf.sprintf "
|
|
|
|
Name of the AO basis ::
|
|
|
|
|
|
|
|
ao_basis = %s
|
|
|
|
|
|
|
|
Basis set ::
|
|
|
|
|
|
|
|
%s
|
|
|
|
|
2014-10-31 23:05:41 +01:00
|
|
|
Symmetries ::
|
|
|
|
|
|
|
|
%s
|
|
|
|
|
2014-10-29 00:12:45 +01:00
|
|
|
" b.ao_basis
|
|
|
|
(Basis.to_string short_basis
|
|
|
|
|> String.split ~on:'\n'
|
|
|
|
|> List.map ~f:(fun x-> " "^x)
|
|
|
|
|> String.concat ~sep:"\n"
|
2014-10-31 23:05:41 +01:00
|
|
|
) print_sym
|
2014-10-29 22:13:03 +01:00
|
|
|
|> Rst_string.of_string
|
2014-10-25 21:24:21 +02:00
|
|
|
;;
|
2014-10-26 17:29:11 +01:00
|
|
|
|
|
|
|
let to_md5 b =
|
|
|
|
let short_basis = to_basis b in
|
|
|
|
Basis.to_md5 short_basis
|
|
|
|
;;
|
2014-10-25 21:24:21 +02:00
|
|
|
|
2014-10-29 22:13:03 +01:00
|
|
|
let to_string b =
|
2014-10-17 22:25:45 +02:00
|
|
|
Printf.sprintf "
|
2014-10-26 12:46:17 +01:00
|
|
|
ao_basis = %s
|
|
|
|
ao_num = %s
|
|
|
|
ao_prim_num = %s
|
|
|
|
ao_prim_num_max = %s
|
|
|
|
ao_nucl = %s
|
|
|
|
ao_power = %s
|
|
|
|
ao_coef = %s
|
|
|
|
ao_expo = %s
|
2014-10-26 17:29:11 +01:00
|
|
|
md5 = %s
|
2014-10-26 12:46:17 +01:00
|
|
|
"
|
2014-10-17 22:25:45 +02:00
|
|
|
b.ao_basis
|
|
|
|
(AO_number.to_string b.ao_num)
|
|
|
|
(b.ao_prim_num |> Array.to_list |> List.map
|
2014-10-22 00:12:23 +02:00
|
|
|
~f:(AO_prim_number.to_string) |> String.concat ~sep:", " )
|
|
|
|
(AO_prim_number.to_string b.ao_prim_num_max)
|
2014-10-17 22:25:45 +02:00
|
|
|
(b.ao_nucl |> Array.to_list |> List.map ~f:Nucl_number.to_string |>
|
|
|
|
String.concat ~sep:", ")
|
|
|
|
(b.ao_power |> Array.to_list |> List.map ~f:(fun x->
|
|
|
|
"("^(Symmetry.Xyz.to_string x)^")" )|> String.concat ~sep:", ")
|
2014-10-22 00:12:23 +02:00
|
|
|
(b.ao_coef |> Array.to_list |> List.map ~f:AO_coef.to_string
|
2014-10-17 22:25:45 +02:00
|
|
|
|> String.concat ~sep:", ")
|
2014-10-22 00:12:23 +02:00
|
|
|
(b.ao_expo |> Array.to_list |> List.map ~f:AO_expo.to_string
|
2014-10-17 22:25:45 +02:00
|
|
|
|> String.concat ~sep:", ")
|
2014-10-26 17:29:11 +01:00
|
|
|
(to_md5 b |> MD5.to_string )
|
2014-10-17 22:25:45 +02:00
|
|
|
|
2014-10-25 21:24:21 +02:00
|
|
|
;;
|
2014-10-17 22:25:45 +02:00
|
|
|
end
|
|
|
|
|