mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-23 04:43:50 +01:00
Input_nuclei is written by qp_edit
This commit is contained in:
parent
1ffc72cc79
commit
f9fe342c58
@ -67,13 +67,6 @@ let read_one in_channel =
|
||||
|
||||
|
||||
(** Transform the gto to a string *)
|
||||
let to_string { sym = sym ; lc = lc } =
|
||||
let f (p,c) = Printf.sprintf "( %s, %f )" (Primitive.to_string p) (AO_coef.to_float c)
|
||||
in
|
||||
Printf.sprintf "( %s, %s )" (Symmetry.to_string sym)
|
||||
(String.concat (List.map ~f:f lc) ~sep:", ")
|
||||
;;
|
||||
|
||||
let to_string { sym = sym ; lc = lc } =
|
||||
let result =
|
||||
Printf.sprintf "%s %3d" (Symmetry.to_string sym) (List.length lc)
|
||||
|
@ -145,16 +145,12 @@ end = struct
|
||||
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
|
||||
let rec do_work = 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
|
||||
(Printf.sprintf " %5d %6d %-8s\n" i (Nucl_number.to_int n) (Symmetry.Xyz.to_string x))::
|
||||
(do_work tail)
|
||||
in do_work l
|
||||
|> String.concat
|
||||
in
|
||||
|
||||
@ -168,9 +164,12 @@ Basis set ::
|
||||
|
||||
%s
|
||||
|
||||
Symmetries ::
|
||||
|
||||
======= ========= ===========
|
||||
Basis Nucleus Symmetries
|
||||
======= ========= ===========
|
||||
%s
|
||||
======= ========= ===========
|
||||
|
||||
" b.ao_basis
|
||||
(Basis.to_string short_basis
|
||||
@ -181,6 +180,22 @@ Symmetries ::
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
let read_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
in
|
||||
let rec extract_basis = function
|
||||
| [] -> failwith "Error in basis set"
|
||||
| line :: tail ->
|
||||
let line = String.strip line in
|
||||
if line = "Basis set ::" then
|
||||
String.concat tail ~sep:"\n"
|
||||
else
|
||||
extract_basis tail
|
||||
in
|
||||
extract_basis s
|
||||
;;
|
||||
|
||||
let to_md5 b =
|
||||
let short_basis = to_basis b in
|
||||
Basis.to_md5 short_basis
|
||||
|
@ -11,6 +11,7 @@ module Nuclei : sig
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
@ -30,18 +31,52 @@ end = struct
|
||||
Nucl_number.of_int ~max:nmax nmax
|
||||
;;
|
||||
|
||||
let write_nucl_num n =
|
||||
Nucl_number.to_int n
|
||||
|> Ezfio.set_nuclei_nucl_num
|
||||
;;
|
||||
|
||||
|
||||
let read_nucl_label () =
|
||||
Ezfio.get_nuclei_nucl_label ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:Element.of_string
|
||||
;;
|
||||
|
||||
let write_nucl_label ~nucl_num labels =
|
||||
let nucl_num =
|
||||
Nucl_number.to_int nucl_num
|
||||
in
|
||||
let labels =
|
||||
Array.to_list labels
|
||||
|> List.map ~f:Element.to_string
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:1
|
||||
~dim:[| nucl_num |] ~data:labels
|
||||
|> Ezfio.set_nuclei_nucl_label
|
||||
;;
|
||||
|
||||
|
||||
let read_nucl_charge () =
|
||||
Ezfio.get_nuclei_nucl_charge ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:Charge.of_float
|
||||
;;
|
||||
|
||||
let write_nucl_charge ~nucl_num charges =
|
||||
let nucl_num =
|
||||
Nucl_number.to_int nucl_num
|
||||
in
|
||||
let charges =
|
||||
Array.to_list charges
|
||||
|> List.map ~f:Charge.to_float
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:1
|
||||
~dim:[| nucl_num |] ~data:charges
|
||||
|> Ezfio.set_nuclei_nucl_charge
|
||||
;;
|
||||
|
||||
|
||||
let read_nucl_coord () =
|
||||
let nucl_num = Nucl_number.to_int (read_nucl_num ()) in
|
||||
let raw_data =
|
||||
@ -59,6 +94,81 @@ end = struct
|
||||
result
|
||||
;;
|
||||
|
||||
let write_nucl_coord ~nucl_num coord =
|
||||
let nucl_num =
|
||||
Nucl_number.to_int nucl_num
|
||||
in
|
||||
let coord = Array.to_list coord in
|
||||
let coord =
|
||||
(List.map ~f:(fun x-> x.Point3d.x) coord) @
|
||||
(List.map ~f:(fun x-> x.Point3d.y) coord) @
|
||||
(List.map ~f:(fun x-> x.Point3d.z) coord)
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:2
|
||||
~dim:[| nucl_num ; 3 |] ~data:coord
|
||||
|> Ezfio.set_nuclei_nucl_coord
|
||||
;;
|
||||
|
||||
|
||||
let read () =
|
||||
{ nucl_num = read_nucl_num ();
|
||||
nucl_label = read_nucl_label () ;
|
||||
nucl_charge = read_nucl_charge ();
|
||||
nucl_coord = read_nucl_coord ();
|
||||
}
|
||||
;;
|
||||
|
||||
let write { nucl_num ;
|
||||
nucl_label ;
|
||||
nucl_charge ;
|
||||
nucl_coord ;
|
||||
} =
|
||||
write_nucl_num nucl_num ;
|
||||
write_nucl_label ~nucl_num:nucl_num nucl_label;
|
||||
write_nucl_charge ~nucl_num:nucl_num nucl_charge;
|
||||
write_nucl_coord ~nucl_num:nucl_num nucl_coord;
|
||||
;;
|
||||
|
||||
|
||||
let to_string b =
|
||||
Printf.sprintf "
|
||||
nucl_num = %s
|
||||
nucl_label = %s
|
||||
nucl_charge = %s
|
||||
nucl_coord = %s
|
||||
"
|
||||
(Nucl_number.to_string b.nucl_num)
|
||||
(b.nucl_label |> Array.to_list |> List.map
|
||||
~f:(Element.to_string) |> String.concat ~sep:", " )
|
||||
(b.nucl_charge |> Array.to_list |> List.map
|
||||
~f:(Charge.to_string) |> String.concat ~sep:", " )
|
||||
(b.nucl_coord |> Array.to_list |> List.map
|
||||
~f:(Point3d.to_string Units.Bohr) |> String.concat ~sep:"\n" )
|
||||
;;
|
||||
|
||||
|
||||
let to_rst b =
|
||||
let nucl_num = Nucl_number.to_int b.nucl_num in
|
||||
let text =
|
||||
( Printf.sprintf " %d\n "
|
||||
nucl_num
|
||||
) :: (
|
||||
List.init nucl_num ~f:(fun i->
|
||||
Printf.sprintf " %-3s %d %s"
|
||||
(b.nucl_label.(i) |> Element.to_string)
|
||||
(b.nucl_charge.(i) |> Charge.to_int )
|
||||
(b.nucl_coord.(i) |> Point3d.to_string Units.Angstrom) )
|
||||
) |> String.concat ~sep:"\n"
|
||||
in
|
||||
Printf.sprintf "
|
||||
Nuclear coordinates in xyz format (Angstroms) ::
|
||||
|
||||
%s
|
||||
|
||||
" text
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let l = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
@ -104,52 +214,6 @@ end = struct
|
||||
}
|
||||
;;
|
||||
|
||||
let read () =
|
||||
{ nucl_num = read_nucl_num ();
|
||||
nucl_label = read_nucl_label () ;
|
||||
nucl_charge = read_nucl_charge ();
|
||||
nucl_coord = read_nucl_coord ();
|
||||
}
|
||||
;;
|
||||
|
||||
let to_string b =
|
||||
Printf.sprintf "
|
||||
nucl_num = %s
|
||||
nucl_label = %s
|
||||
nucl_charge = %s
|
||||
nucl_coord = %s
|
||||
"
|
||||
(Nucl_number.to_string b.nucl_num)
|
||||
(b.nucl_label |> Array.to_list |> List.map
|
||||
~f:(Element.to_string) |> String.concat ~sep:", " )
|
||||
(b.nucl_charge |> Array.to_list |> List.map
|
||||
~f:(Charge.to_string) |> String.concat ~sep:", " )
|
||||
(b.nucl_coord |> Array.to_list |> List.map
|
||||
~f:(Point3d.to_string Units.Bohr) |> String.concat ~sep:"\n" )
|
||||
;;
|
||||
|
||||
let to_rst b =
|
||||
let nucl_num = Nucl_number.to_int b.nucl_num in
|
||||
let text =
|
||||
( Printf.sprintf " %d\n "
|
||||
nucl_num
|
||||
) :: (
|
||||
List.init nucl_num ~f:(fun i->
|
||||
Printf.sprintf " %-3s %d %s"
|
||||
(b.nucl_label.(i) |> Element.to_string)
|
||||
(b.nucl_charge.(i) |> Charge.to_int )
|
||||
(b.nucl_coord.(i) |> Point3d.to_string Units.Angstrom) )
|
||||
) |> String.concat ~sep:"\n"
|
||||
in
|
||||
Printf.sprintf "
|
||||
Nuclear coordinates in xyz format (Angstroms) ::
|
||||
|
||||
%s
|
||||
|
||||
" text
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -91,8 +91,8 @@ let set str s =
|
||||
| Cisd_sc2 ->
|
||||
*)
|
||||
| Nuclei ->
|
||||
let b = Input.Nuclei.of_rst str in
|
||||
print_string (Input.Nuclei.to_string b);
|
||||
Input.Nuclei.of_rst str
|
||||
|> Input.Nuclei.write;
|
||||
| Bielec_integrals ->
|
||||
let b = Input.Bielec_integrals.of_rst str in
|
||||
print_string (Input.Bielec_integrals.to_string b);
|
||||
|
Loading…
Reference in New Issue
Block a user