From 94e06e2a5b593d9ecbbe30a3966daa14adf802dc Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 18:24:40 +0100 Subject: [PATCH] Ocaml default on multiple files --- data/ezfio_defaults | 60 -------------------------------------- data/ezfio_defaults/.empty | 0 ocaml/Input_full_ci.ml | 2 +- ocaml/Input_mo_basis.ml | 26 +++++++---------- ocaml/Qpackage.ml | 30 ++++++++++++++++--- 5 files changed, 37 insertions(+), 81 deletions(-) delete mode 100644 data/ezfio_defaults create mode 100644 data/ezfio_defaults/.empty diff --git a/data/ezfio_defaults b/data/ezfio_defaults deleted file mode 100644 index 5da4d813..00000000 --- a/data/ezfio_defaults +++ /dev/null @@ -1,60 +0,0 @@ -bielec_integrals - read_ao_integrals False - read_mo_integrals False - write_ao_integrals False - write_mo_integrals False - threshold_ao 1.e-15 - threshold_mo 1.e-15 - direct False - -cis_dressed - n_state_cis 10 - n_core_cis 0 - n_act_cis mo_basis_mo_tot_num - mp2_dressing False - standard_doubles True - en_2_2 False - -determinants - n_states 1 - n_states_diag determinants_n_states - n_det_max_jacobi 1000 - threshold_generators 0.99 - threshold_selectors 0.999 - read_wf False - s2_eig False - only_single_double_dm False - -full_ci - n_det_max_fci 10000 - n_det_max_fci_property 50000 - pt2_max 1.e-4 - do_pt2_end True - var_pt2_ratio 0.75 - -all_singles - n_det_max_fci 50000 - pt2_max 1.e-8 - do_pt2_end False - -cassd - n_det_max_cassd 10000 - pt2_max 1.e-4 - do_pt2_end True - -hartree_fock - n_it_scf_max 200 - thresh_scf 1.e-10 - guess "Huckel" - -cisd_selected - n_det_max_cisd 10000 - pt2_max 1.e-4 - -cisd_sc2_selected - n_det_max_cisd_sc2 10000 - pt2_max 1.e-4 - do_pt2_end True - -properties - z_one_point 3.9 diff --git a/data/ezfio_defaults/.empty b/data/ezfio_defaults/.empty new file mode 100644 index 00000000..e69de29b diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml index 01548e88..f963ee7e 100644 --- a/ocaml/Input_full_ci.ml +++ b/ocaml/Input_full_ci.ml @@ -3,7 +3,7 @@ open Qputils;; open Core.Std;; module Full_ci : sig - type t = + type t = { n_det_max_fci : Det_number_max.t; pt2_max : PT2_energy.t; do_pt2_end : bool; diff --git a/ocaml/Input_mo_basis.ml b/ocaml/Input_mo_basis.ml index f02dbfa9..ab75b869 100644 --- a/ocaml/Input_mo_basis.ml +++ b/ocaml/Input_mo_basis.ml @@ -2,27 +2,21 @@ open Qptypes;; open Qputils;; open Core.Std;; +type t_mo = + { mo_tot_num : MO_number.t ; + mo_label : MO_label.t; + mo_occ : MO_occ.t array; + mo_coef : (MO_coef.t array) array; + ao_md5 : MD5.t; + } with sexp + module Mo_basis : sig - type t = - { mo_tot_num : MO_number.t ; - mo_label : MO_label.t; - mo_occ : MO_occ.t array; - mo_coef : (MO_coef.t array) array; - ao_md5 : MD5.t; - } with sexp - ;; + type t = t_mo val read : unit -> t option val to_string : t -> string val to_rst : t -> Rst_string.t end = struct - type t = - { mo_tot_num : MO_number.t ; - mo_label : MO_label.t; - mo_occ : MO_occ.t array; - mo_coef : (MO_coef.t array) array; - ao_md5 : MD5.t; - } with sexp - ;; + type t = t_mo let get_default = Qpackage.get_ezfio_default "mo_basis";; diff --git a/ocaml/Qpackage.ml b/ocaml/Qpackage.ml index 143cff28..4d08192a 100644 --- a/ocaml/Qpackage.ml +++ b/ocaml/Qpackage.ml @@ -71,8 +71,8 @@ let executables = lazy ( ) -let get_ezfio_default directory data = - let filename = root^"/data/ezfio_defaults" in + +let get_ezfio_default_in_file ~directory ~data ~filename = let lines = In_channel.with_file filename ~f:(fun in_channel -> In_channel.input_lines in_channel) in let rec find_dir = function @@ -93,8 +93,10 @@ let get_ezfio_default directory data = begin match (String.lsplit2 ~on:' ' (String.strip line)) with | Some (l,r) -> - if (l = data) then (String.lowercase (String.strip r)) - else find_data rest + if (l = data) then + String.lowercase (String.strip r) + else + find_data rest | None -> raise Not_found end | [] -> raise Not_found @@ -102,3 +104,23 @@ let get_ezfio_default directory data = find_dir lines |> find_data ; ;; + +let get_ezfio_default directory data = + let dirname = root^"/data/ezfio_defaults/" in + + let rec aux = function + | [] -> raise Not_found + | filename :: tail -> + let filename = + dirname^filename + in + try + get_ezfio_default_in_file ~directory ~data ~filename + with + | Not_found -> aux tail + in + Sys.readdir dirname + |> Array.to_list + |> aux +;; +