9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 03:23:29 +01:00

Removed Core from qp_create_ezfio.ml

This commit is contained in:
Anthony Scemama 2019-03-13 11:35:21 +01:00
parent 83d3cafbb2
commit da3ba4ef4b
6 changed files with 131 additions and 148 deletions

View File

@ -1,4 +1,4 @@
open Core open Sexplib.Std
open Qptypes open Qptypes
exception ElementError of string exception ElementError of string
@ -14,7 +14,7 @@ type t =
[@@deriving sexp] [@@deriving sexp]
let of_string x = let of_string x =
match (String.capitalize (String.lowercase x)) with match (String.capitalize_ascii (String.lowercase_ascii x)) with
| "X" | "Dummy" -> X | "X" | "Dummy" -> X
| "H" | "Hydrogen" -> H | "H" | "Hydrogen" -> H
| "He" | "Helium" -> He | "He" | "Helium" -> He

View File

@ -1,5 +1,6 @@
(** CONTRL *) (** CONTRL *)
type scftyp_t = RHF | ROHF | MCSCF | NONE type scftyp_t = RHF | ROHF | MCSCF | NONE
let string_of_scftyp = function let string_of_scftyp = function
| RHF -> "RHF" | RHF -> "RHF"
| ROHF -> "ROHF" | ROHF -> "ROHF"
@ -116,7 +117,7 @@ type guess_t =
| Natural of (int*string) | Natural of (int*string)
let guess_of_string s = let guess_of_string s =
match String.lowercase s with match String.lowercase_ascii s with
| "huckel" -> Huckel | "huckel" -> Huckel
| "hcore" -> Hcore | "hcore" -> Hcore
| _ -> raise (Invalid_argument "Bad MO guess") | _ -> raise (Invalid_argument "Bad MO guess")

View File

@ -33,7 +33,7 @@ let to_string x =
let of_string s = let of_string s =
match (String.lowercase s) with match (String.lowercase_ascii s) with
| "core" -> Core [] | "core" -> Core []
| "inactive" -> Inactive [] | "inactive" -> Inactive []
| "active" -> Active [] | "active" -> Active []

View File

@ -1,4 +1,4 @@
open Core;; open Sexplib.Std
type t = type t =
| Guess | Guess
@ -8,7 +8,7 @@ type t =
| Orthonormalized | Orthonormalized
| None | None
[@@deriving sexp] [@@deriving sexp]
;;
let to_string = function let to_string = function
| Guess -> "Guess" | Guess -> "Guess"
@ -20,7 +20,7 @@ let to_string = function
;; ;;
let of_string s = let of_string s =
match String.lowercase (String.strip s) with match String.lowercase_ascii (String.trim s) with
| "guess" -> Guess | "guess" -> Guess
| "canonical" -> Canonical | "canonical" -> Canonical
| "natural" -> Natural | "natural" -> Natural

View File

@ -1,5 +1,5 @@
open Core;; open Qptypes
open Qptypes;; open Sexplib.Std
type t = { type t = {
x : float ; x : float ;
@ -21,9 +21,9 @@ let of_string ~units s =
| Units.Angstrom -> Units.angstrom_to_bohr | Units.Angstrom -> Units.angstrom_to_bohr
in in
let l = s let l = s
|> String.split ~on:' ' |> String_ext.split ~on:' '
|> List.filter ~f:(fun x -> x <> "") |> List.filter (fun x -> x <> "")
|> List.map ~f:Float.of_string |> List.map float_of_string
|> Array.of_list |> Array.of_list
in in
{ x = l.(0) *. f ; { x = l.(0) *. f ;

View File

@ -1,6 +1,6 @@
open Qputils open Qputils
open Qptypes open Qptypes
open Core open Sexplib.Std
type element = type element =
| Element of Element.t | Element of Element.t
@ -38,7 +38,7 @@ let dummy_centers ~threshold ~molecule ~nuclei =
| _ -> assert false | _ -> assert false
in in
aux [] (n-1,n-1) aux [] (n-1,n-1)
|> List.map ~f:(fun (i,x,j,y,r) -> |> List.map (fun (i,x,j,y,r) ->
let f = let f =
x /. (x +. y) x /. (x +. y)
in in
@ -58,22 +58,22 @@ let dummy_centers ~threshold ~molecule ~nuclei =
(** Returns the list of available basis sets *) (** Returns the list of available basis sets *)
let list_basis () = let list_basis () =
let basis_list = let basis_list =
let ic = Pervasives.open_in (Qpackage.root ^ "/data/basis/00_README.rst") in let ic = open_in (Qpackage.root ^ "/data/basis/00_README.rst") in
let n = Pervasives.in_channel_length ic in let n = in_channel_length ic in
let s = Bytes.create n in let s = Bytes.create n in
Pervasives.really_input ic s 0 n; really_input ic s 0 n;
Pervasives.close_in ic; close_in ic;
Bytes.to_string s Bytes.to_string s
|> String.split ~on:'\n' |> String_ext.split ~on:'\n'
|> List.filter ~f:(fun line -> String.length line > 1 && line.[0] <> '#') |> List.filter (fun line -> String.length line > 1 && line.[0] <> '#')
|> List.map ~f:(fun line -> |> List.map (fun line ->
match String.split ~on:'\'' line with match String_ext.split ~on:'\'' line with
| file :: name :: descr :: _ -> | file :: name :: descr :: _ ->
Printf.sprintf "%s\n %s\n %s\n\n" file name (String.strip descr) Printf.sprintf "%s\n %s\n %s\n\n" file name (String.trim descr)
| _ -> assert false | _ -> assert false
) )
in in
List.sort basis_list ~compare:String.ascending List.sort compare basis_list
(** Run the program *) (** Run the program *)
@ -101,7 +101,7 @@ let run ?o b au c d m p cart xyz_file =
**********) **********)
let basis_table = let basis_table =
Hashtbl.Poly.create () Hashtbl.create 63
in in
(* Open basis set channels *) (* Open basis set channels *)
@ -111,10 +111,7 @@ let run ?o b au c d m p cart xyz_file =
| Element e -> Element.to_string e | Element e -> Element.to_string e
| Int_elem (i,e) -> Printf.sprintf "%d,%s" (Nucl_number.to_int i) (Element.to_string e) | Int_elem (i,e) -> Printf.sprintf "%d,%s" (Nucl_number.to_int i) (Element.to_string e)
in in
match Hashtbl.find basis_table key with Hashtbl.find basis_table key
| Some in_channel ->
in_channel
| None -> raise Caml.Not_found
in in
let temp_filename = let temp_filename =
@ -129,11 +126,11 @@ let run ?o b au c d m p cart xyz_file =
Qpackage.root ^ "/data/basis/" ^ basis Qpackage.root ^ "/data/basis/" ^ basis
in in
match match
Sys.is_file basis, Sys.file_exists basis,
Sys.is_file long_basis Sys.file_exists long_basis
with with
| `Yes, _ -> In_channel.create basis | true , _ -> open_in basis
| `No , `Yes -> In_channel.create long_basis | false, true -> open_in long_basis
| _ -> failwith ("Basis "^basis^" not found") | _ -> failwith ("Basis "^basis^" not found")
in in
@ -141,7 +138,7 @@ let run ?o b au c d m p cart xyz_file =
| [] -> () | [] -> ()
| elem_and_basis_name :: rest -> | elem_and_basis_name :: rest ->
begin begin
match (String.lsplit2 ~on:':' elem_and_basis_name) with match (String_ext.lsplit2 ~on:':' elem_and_basis_name) with
| None -> (* Principal basis *) | None -> (* Principal basis *)
begin begin
let basis = let basis =
@ -150,14 +147,12 @@ let run ?o b au c d m p cart xyz_file =
let new_channel = let new_channel =
fetch_channel basis fetch_channel basis
in in
List.iter nuclei ~f:(fun elem-> List.iter (fun elem->
let key = let key =
Element.to_string elem.Atom.element Element.to_string elem.Atom.element
in in
match Hashtbl.add basis_table ~key:key ~data:new_channel with Hashtbl.add basis_table key new_channel
| `Ok -> () ) nuclei
| `Duplicate -> ()
)
end end
| Some (key, basis) -> (*Aux basis *) | Some (key, basis) -> (*Aux basis *)
begin begin
@ -166,12 +161,12 @@ let run ?o b au c d m p cart xyz_file =
Element (Element.of_string key) Element (Element.of_string key)
with Element.ElementError _ -> with Element.ElementError _ ->
let result = let result =
match (String.split ~on:',' key) with match (String_ext.split ~on:',' key) with
| i :: k :: [] -> (Nucl_number.of_int @@ int_of_string i, Element.of_string k) | i :: k :: [] -> (Nucl_number.of_int @@ int_of_string i, Element.of_string k)
| _ -> failwith "Expected format is int,Element:basis" | _ -> failwith "Expected format is int,Element:basis"
in Int_elem result in Int_elem result
and basis = and basis =
String.lowercase basis String.lowercase_ascii basis
in in
let key = let key =
match elem with match elem with
@ -181,23 +176,13 @@ let run ?o b au c d m p cart xyz_file =
let new_channel = let new_channel =
fetch_channel basis fetch_channel basis
in in
begin Hashtbl.add basis_table key new_channel
match Hashtbl.add basis_table ~key:key ~data:new_channel with
| `Ok -> ()
| `Duplicate ->
let e =
match elem with
| Element e -> e
| Int_elem (_,e) -> e
in
failwith ("Duplicate definition of basis for "^(Element.to_long_string e))
end
end end
end; end;
build_basis rest build_basis rest
in in
String.split ~on:'|' b String_ext.split ~on:'|' b
|> List.rev_map ~f:String.strip |> List.rev_map String.trim
|> build_basis; |> build_basis;
@ -207,7 +192,7 @@ let run ?o b au c d m p cart xyz_file =
***************) ***************)
let pseudo_table = let pseudo_table =
Hashtbl.Poly.create () Hashtbl.create 63
in in
(* Open pseudo channels *) (* Open pseudo channels *)
@ -215,7 +200,7 @@ let run ?o b au c d m p cart xyz_file =
let key = let key =
Element.to_string element Element.to_string element
in in
Hashtbl.find pseudo_table key Hashtbl.find_opt pseudo_table key
in in
let temp_filename = let temp_filename =
Filename.temp_file "qp_create_" ".pseudo" Filename.temp_file "qp_create_" ".pseudo"
@ -229,11 +214,11 @@ let run ?o b au c d m p cart xyz_file =
Qpackage.root ^ "/data/pseudo/" ^ pseudo Qpackage.root ^ "/data/pseudo/" ^ pseudo
in in
match match
Sys.is_file pseudo, Sys.file_exists pseudo,
Sys.is_file long_pseudo Sys.file_exists long_pseudo
with with
| `Yes, _ -> In_channel.create pseudo | true , _ -> open_in pseudo
| `No , `Yes -> In_channel.create long_pseudo | false, true-> open_in long_pseudo
| _ -> failwith ("Pseudo file "^pseudo^" not found.") | _ -> failwith ("Pseudo file "^pseudo^" not found.")
in in
@ -241,7 +226,7 @@ let run ?o b au c d m p cart xyz_file =
| [] -> () | [] -> ()
| elem_and_pseudo_name :: rest -> | elem_and_pseudo_name :: rest ->
begin begin
match (String.lsplit2 ~on:':' elem_and_pseudo_name) with match (String_ext.lsplit2 ~on:':' elem_and_pseudo_name) with
| None -> (* Principal pseudo *) | None -> (* Principal pseudo *)
begin begin
let pseudo = let pseudo =
@ -250,21 +235,19 @@ let run ?o b au c d m p cart xyz_file =
let new_channel = let new_channel =
fetch_channel pseudo fetch_channel pseudo
in in
List.iter nuclei ~f:(fun elem-> List.iter (fun elem->
let key = let key =
Element.to_string elem.Atom.element Element.to_string elem.Atom.element
in in
match Hashtbl.add pseudo_table ~key:key ~data:new_channel with Hashtbl.add pseudo_table key new_channel
| `Ok -> () ) nuclei
| `Duplicate -> ()
)
end end
| Some (key, pseudo) -> (*Aux pseudo *) | Some (key, pseudo) -> (*Aux pseudo *)
begin begin
let elem = let elem =
Element.of_string key Element.of_string key
and pseudo = and pseudo =
String.lowercase pseudo String.lowercase_ascii pseudo
in in
let key = let key =
Element.to_string elem Element.to_string elem
@ -272,11 +255,7 @@ let run ?o b au c d m p cart xyz_file =
let new_channel = let new_channel =
fetch_channel pseudo fetch_channel pseudo
in in
begin Hashtbl.add pseudo_table key new_channel
match Hashtbl.add pseudo_table ~key:key ~data:new_channel with
| `Ok -> ()
| `Duplicate -> failwith ("Duplicate definition of pseudo for "^(Element.to_long_string elem))
end
end end
end; end;
build_pseudo rest build_pseudo rest
@ -285,8 +264,8 @@ let run ?o b au c d m p cart xyz_file =
match p with match p with
| None -> () | None -> ()
| Some p -> | Some p ->
String.split ~on:'|' p String_ext.split ~on:'|' p
|> List.rev_map ~f:String.strip |> List.rev_map String.trim
|> build_pseudo |> build_pseudo
in in
@ -296,13 +275,13 @@ let run ?o b au c d m p cart xyz_file =
| Some x -> x | Some x -> x
| None -> | None ->
begin begin
match String.rsplit2 ~on:'.' xyz_file with match String_ext.rsplit2 ~on:'.' xyz_file with
| Some (x,"xyz") | Some (x,"xyz")
| Some (x,"zmt") -> x^".ezfio" | Some (x,"zmt") -> x^".ezfio"
| _ -> xyz_file^".ezfio" | _ -> xyz_file^".ezfio"
end end
in in
if Sys.file_exists_exn ezfio_file then if Sys.file_exists ezfio_file then
failwith (ezfio_file^" already exists"); failwith (ezfio_file^" already exists");
let write_file () = let write_file () =
@ -311,17 +290,17 @@ let run ?o b au c d m p cart xyz_file =
(* Write Pseudo *) (* Write Pseudo *)
let pseudo = let pseudo =
List.map nuclei ~f:(fun x -> List.map (fun x ->
match pseudo_channel x.Atom.element with match pseudo_channel x.Atom.element with
| Some channel -> Pseudo.read_element channel x.Atom.element | Some channel -> Pseudo.read_element channel x.Atom.element
| None -> Pseudo.empty x.Atom.element | None -> Pseudo.empty x.Atom.element
) ) nuclei
in in
let molecule = let molecule =
let n_elec_to_remove = let n_elec_to_remove =
List.fold pseudo ~init:0 ~f:(fun accu x -> List.fold_left (fun accu x ->
accu + (Positive_int.to_int x.Pseudo.n_elec)) accu + (Positive_int.to_int x.Pseudo.n_elec)) 0 pseudo
in in
{ Molecule.elec_alpha = { Molecule.elec_alpha =
(Elec_alpha_number.to_int molecule.Molecule.elec_alpha) (Elec_alpha_number.to_int molecule.Molecule.elec_alpha)
@ -333,14 +312,14 @@ let run ?o b au c d m p cart xyz_file =
|> Elec_beta_number.of_int; |> Elec_beta_number.of_int;
Molecule.nuclei = Molecule.nuclei =
let charges = let charges =
List.map pseudo ~f:(fun x -> Positive_int.to_int x.Pseudo.n_elec List.map (fun x -> Positive_int.to_int x.Pseudo.n_elec
|> Float.of_int) |> Float.of_int) pseudo
|> Array.of_list |> Array.of_list
in in
List.mapi molecule.Molecule.nuclei ~f:(fun i x -> List.mapi (fun i x ->
{ x with Atom.charge = (Charge.to_float x.Atom.charge) -. charges.(i) { x with Atom.charge = (Charge.to_float x.Atom.charge) -. charges.(i)
|> Charge.of_float } |> Charge.of_float }
) ) molecule.Molecule.nuclei
} }
in in
let nuclei = let nuclei =
@ -356,13 +335,13 @@ let run ?o b au c d m p cart xyz_file =
(* Write Nuclei *) (* Write Nuclei *)
let labels = let labels =
List.map ~f:(fun x->Element.to_string x.Atom.element) nuclei List.map (fun x->Element.to_string x.Atom.element) nuclei
and charges = and charges =
List.map ~f:(fun x-> Atom.(Charge.to_float x.charge)) nuclei List.map (fun x-> Atom.(Charge.to_float x.charge)) nuclei
and coords = and coords =
(List.map ~f:(fun x-> x.Atom.coord.Point3d.x) nuclei) @ (List.map (fun x-> x.Atom.coord.Point3d.x) nuclei) @
(List.map ~f:(fun x-> x.Atom.coord.Point3d.y) nuclei) @ (List.map (fun x-> x.Atom.coord.Point3d.y) nuclei) @
(List.map ~f:(fun x-> x.Atom.coord.Point3d.z) nuclei) in (List.map (fun x-> x.Atom.coord.Point3d.z) nuclei) in
let nucl_num = (List.length labels) in let nucl_num = (List.length labels) in
Ezfio.set_nuclei_nucl_num nucl_num ; Ezfio.set_nuclei_nucl_num nucl_num ;
Ezfio.set_nuclei_nucl_label (Ezfio.ezfio_array_of_list Ezfio.set_nuclei_nucl_label (Ezfio.ezfio_array_of_list
@ -381,40 +360,41 @@ let run ?o b au c d m p cart xyz_file =
in in
let klocmax = let klocmax =
List.fold pseudo ~init:0 ~f:(fun accu x -> List.fold_left (fun accu x ->
let x = let x =
List.length x.Pseudo.local List.length x.Pseudo.local
in in
if (x > accu) then x if (x > accu) then x
else accu else accu
) ) 0 pseudo
and lmax = and lmax =
List.fold pseudo ~init:0 ~f:(fun accu x -> List.fold_left (fun accu x ->
let x = let x =
List.fold x.Pseudo.non_local ~init:0 ~f:(fun accu (x,_) -> List.fold_left (fun accu (x,_) ->
let x = let x =
Positive_int.to_int x.Pseudo.GaussianPrimitive_non_local.proj Positive_int.to_int x.Pseudo.GaussianPrimitive_non_local.proj
in in
if (x > accu) then x if (x > accu) then x
else accu else accu
) ) 0 x.Pseudo.non_local
in in
if (x > accu) then x if (x > accu) then x
else accu else accu
) ) 0 pseudo
in in
let kmax = let kmax =
Array.init (lmax+1) ~f:(fun i-> Array.init (lmax+1) (fun i->
List.map pseudo ~f:(fun x -> List.map (fun x ->
List.filter x.Pseudo.non_local ~f:(fun (y,_) -> List.filter (fun (y,_) ->
(Positive_int.to_int y.Pseudo.GaussianPrimitive_non_local.proj) = i) (Positive_int.to_int y.Pseudo.GaussianPrimitive_non_local.proj) = i)
|> List.length ) x.Pseudo.non_local
|> List.fold ~init:0 ~f:(fun accu x -> |> List.length ) pseudo
if accu > x then accu else x) |> List.fold_left (fun accu x ->
if accu > x then accu else x) 0
) )
|> Array.fold ~init:0 ~f:(fun accu i -> |> Array.fold_left (fun accu i ->
if i > accu then i else accu) if i > accu then i else accu) 0
in in
@ -423,12 +403,12 @@ let run ?o b au c d m p cart xyz_file =
Ezfio.set_pseudo_pseudo_kmax kmax; Ezfio.set_pseudo_pseudo_kmax kmax;
Ezfio.set_pseudo_pseudo_lmax lmax; Ezfio.set_pseudo_pseudo_lmax lmax;
let tmp_array_v_k, tmp_array_dz_k, tmp_array_n_k = let tmp_array_v_k, tmp_array_dz_k, tmp_array_n_k =
Array.make_matrix ~dimx:klocmax ~dimy:nucl_num 0. , Array.make_matrix klocmax nucl_num 0. ,
Array.make_matrix ~dimx:klocmax ~dimy:nucl_num 0. , Array.make_matrix klocmax nucl_num 0. ,
Array.make_matrix ~dimx:klocmax ~dimy:nucl_num 0 Array.make_matrix klocmax nucl_num 0
in in
List.iteri pseudo ~f:(fun j x -> List.iteri (fun j x ->
List.iteri x.Pseudo.local ~f:(fun i (y,c) -> List.iteri (fun i (y,c) ->
tmp_array_v_k.(i).(j) <- AO_coef.to_float c; tmp_array_v_k.(i).(j) <- AO_coef.to_float c;
let y, z = let y, z =
AO_expo.to_float y.Pseudo.GaussianPrimitive_local.expo, AO_expo.to_float y.Pseudo.GaussianPrimitive_local.expo,
@ -436,11 +416,11 @@ let run ?o b au c d m p cart xyz_file =
in in
tmp_array_dz_k.(i).(j) <- y; tmp_array_dz_k.(i).(j) <- y;
tmp_array_n_k.(i).(j) <- z; tmp_array_n_k.(i).(j) <- z;
) ) x.Pseudo.local
); ) pseudo ;
let concat_2d tmp_array = let concat_2d tmp_array =
let data = let data =
Array.map tmp_array ~f:Array.to_list Array.map Array.to_list tmp_array
|> Array.to_list |> Array.to_list
|> List.concat |> List.concat
in in
@ -454,18 +434,18 @@ let run ?o b au c d m p cart xyz_file =
|> Ezfio.set_pseudo_pseudo_n_k; |> Ezfio.set_pseudo_pseudo_n_k;
let tmp_array_v_kl, tmp_array_dz_kl, tmp_array_n_kl = let tmp_array_v_kl, tmp_array_dz_kl, tmp_array_n_kl =
Array.init (lmax+1) ~f:(fun _ -> Array.init (lmax+1) (fun _ ->
(Array.make_matrix ~dimx:kmax ~dimy:nucl_num 0. )), (Array.make_matrix kmax nucl_num 0. )),
Array.init (lmax+1) ~f:(fun _ -> Array.init (lmax+1) (fun _ ->
(Array.make_matrix ~dimx:kmax ~dimy:nucl_num 0. )), (Array.make_matrix kmax nucl_num 0. )),
Array.init (lmax+1) ~f:(fun _ -> Array.init (lmax+1) (fun _ ->
(Array.make_matrix ~dimx:kmax ~dimy:nucl_num 0 )) (Array.make_matrix kmax nucl_num 0 ))
in in
List.iteri pseudo ~f:(fun j x -> List.iteri (fun j x ->
let last_idx = let last_idx =
Array.create ~len:(lmax+1) 0 Array.make (lmax+1) 0
in in
List.iter x.Pseudo.non_local ~f:(fun (y,c) -> List.iter (fun (y,c) ->
let k, y, z = let k, y, z =
Positive_int.to_int y.Pseudo.GaussianPrimitive_non_local.proj, Positive_int.to_int y.Pseudo.GaussianPrimitive_non_local.proj,
AO_expo.to_float y.Pseudo.GaussianPrimitive_non_local.expo, AO_expo.to_float y.Pseudo.GaussianPrimitive_non_local.expo,
@ -478,14 +458,14 @@ let run ?o b au c d m p cart xyz_file =
tmp_array_dz_kl.(k).(i).(j) <- y; tmp_array_dz_kl.(k).(i).(j) <- y;
tmp_array_n_kl.(k).(i).(j) <- z; tmp_array_n_kl.(k).(i).(j) <- z;
last_idx.(k) <- i+1; last_idx.(k) <- i+1;
) ) x.Pseudo.non_local
); ) pseudo ;
let concat_3d tmp_array = let concat_3d tmp_array =
let data = let data =
Array.map tmp_array ~f:(fun x -> Array.map (fun x ->
Array.map x ~f:Array.to_list Array.map Array.to_list x
|> Array.to_list |> Array.to_list
|> List.concat) |> List.concat) tmp_array
|> Array.to_list |> Array.to_list
|> List.concat |> List.concat
in in
@ -518,7 +498,7 @@ let run ?o b au c d m p cart xyz_file =
in in
let result = do_work [] 1 nuclei let result = do_work [] 1 nuclei
|> List.rev |> List.rev
|> List.map ~f:(fun (x,i) -> |> List.map (fun (x,i) ->
try try
let e = let e =
match x.Atom.element with match x.Atom.element with
@ -552,37 +532,38 @@ let run ?o b au c d m p cart xyz_file =
let ao_num = List.length long_basis in let ao_num = List.length long_basis in
Ezfio.set_ao_basis_ao_num ao_num; Ezfio.set_ao_basis_ao_num ao_num;
Ezfio.set_ao_basis_ao_basis b; Ezfio.set_ao_basis_ao_basis b;
let ao_prim_num = List.map long_basis ~f:(fun (_,g,_) -> List.length g.Gto.lc) let ao_prim_num = List.map (fun (_,g,_) -> List.length g.Gto.lc) long_basis
and ao_nucl = List.map long_basis ~f:(fun (_,_,n) -> Nucl_number.to_int n) and ao_nucl = List.map (fun (_,_,n) -> Nucl_number.to_int n) long_basis
and ao_power= and ao_power=
let l = List.map long_basis ~f:(fun (x,_,_) -> x) in let l = List.map (fun (x,_,_) -> x) long_basis in
(List.map l ~f:(fun t -> Positive_int.to_int Symmetry.Xyz.(t.x)) )@ (List.map (fun t -> Positive_int.to_int Symmetry.Xyz.(t.x)) l)@
(List.map l ~f:(fun t -> Positive_int.to_int Symmetry.Xyz.(t.y)) )@ (List.map (fun t -> Positive_int.to_int Symmetry.Xyz.(t.y)) l)@
(List.map l ~f:(fun t -> Positive_int.to_int Symmetry.Xyz.(t.z)) ) (List.map (fun t -> Positive_int.to_int Symmetry.Xyz.(t.z)) l)
in in
let ao_prim_num_max = List.fold ~init:0 ~f:(fun s x -> let ao_prim_num_max = List.fold_left (fun s x ->
if x > s then x if x > s then x
else s) ao_prim_num else s) 0 ao_prim_num
in in
let gtos = let gtos =
List.map long_basis ~f:(fun (_,x,_) -> x) List.map (fun (_,x,_) -> x) long_basis
in in
let create_expo_coef ec = let create_expo_coef ec =
let coefs = let coefs =
begin match ec with begin match ec with
| `Coefs -> List.map gtos ~f:(fun x-> | `Coefs -> List.map (fun x->
List.map x.Gto.lc ~f:(fun (_,coef) -> AO_coef.to_float coef) ) List.map (fun (_,coef) ->
| `Expos -> List.map gtos ~f:(fun x-> AO_coef.to_float coef) x.Gto.lc) gtos
List.map x.Gto.lc ~f:(fun (prim,_) -> AO_expo.to_float | `Expos -> List.map (fun x->
prim.GaussianPrimitive.expo) ) List.map (fun (prim,_) -> AO_expo.to_float
prim.GaussianPrimitive.expo) x.Gto.lc) gtos
end end
in in
let rec get_n n accu = function let rec get_n n accu = function
| [] -> List.rev accu | [] -> List.rev accu
| h::tail -> | h::tail ->
let y = let y =
begin match List.nth h n with begin match List.nth_opt h n with
| Some x -> x | Some x -> x
| None -> 0. | None -> 0.
end end
@ -621,9 +602,10 @@ let run ?o b au c d m p cart xyz_file =
| ex -> | ex ->
begin begin
begin begin
match Sys.is_directory ezfio_file with try
| `Yes -> rmdir ezfio_file if Sys.is_directory ezfio_file then
| _ -> () rmdir ezfio_file
with _ -> ()
end; end;
raise ex; raise ex;
end end
@ -730,7 +712,7 @@ If a file with the same name as the basis set exists, this file will be read. O
if basis = "show" then if basis = "show" then
begin begin
list_basis () list_basis ()
|> List.iter ~f:print_endline; |> List.iter print_endline;
exit 0 exit 0
end; end;