diff --git a/ocaml/Input.ml b/ocaml/Input.ml index a861e3ec..9d5f6b7f 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -11,5 +11,6 @@ include Input_cisd_sc2;; include Input_determinants;; include Input_electrons;; include Input_full_ci;; +include Input_hartree_fock;; diff --git a/ocaml/Input_ao_basis.ml b/ocaml/Input_ao_basis.ml index 8bf2a303..276e4b8d 100644 --- a/ocaml/Input_ao_basis.ml +++ b/ocaml/Input_ao_basis.ml @@ -6,12 +6,12 @@ module Ao_basis : sig type t = { ao_basis : string ; ao_num : AO_number.t ; - ao_prim_num : Strictly_positive_int.t array; - ao_prim_num_max : Strictly_positive_int.t; + ao_prim_num : AO_prim_number.t array; + ao_prim_num_max : AO_prim_number.t; ao_nucl : Nucl_number.t array; ao_power : Symmetry.Xyz.t array; - ao_coef : float array; - ao_expo : Positive_float.t array; + ao_coef : AO_coef.t array; + ao_expo : AO_expo.t array; } ;; val read : unit -> t @@ -20,12 +20,12 @@ end = struct type t = { ao_basis : string ; ao_num : AO_number.t ; - ao_prim_num : Strictly_positive_int.t array; - ao_prim_num_max : Strictly_positive_int.t; + ao_prim_num : AO_prim_number.t array; + ao_prim_num_max : AO_prim_number.t; ao_nucl : Nucl_number.t array; ao_power : Symmetry.Xyz.t array; - ao_coef : float array; - ao_expo : Positive_float.t array; + ao_coef : AO_coef.t array; + ao_expo : AO_expo.t array; } ;; @@ -46,14 +46,14 @@ end = struct let read_ao_prim_num () = (Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data |> Ezfio.flattened_ezfio_data - |> Array.map ~f:Strictly_positive_int.of_int + |> Array.map ~f:AO_prim_number.of_int ;; let read_ao_prim_num_max () = (Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data |> Ezfio.flattened_ezfio_data |> Array.fold ~f:(fun x y -> if x>y then x else y) ~init:0 - |> Strictly_positive_int.of_int + |> AO_prim_number.of_int ;; let read_ao_nucl () = @@ -82,12 +82,13 @@ end = struct let read_ao_coef () = (Ezfio.get_ao_basis_ao_coef () ).Ezfio.data |> Ezfio.flattened_ezfio_data + |> Array.map ~f:AO_coef.of_float ;; let read_ao_expo () = (Ezfio.get_ao_basis_ao_expo () ).Ezfio.data |> Ezfio.flattened_ezfio_data - |> Array.map ~f:Positive_float.of_float + |> Array.map ~f:AO_expo.of_float ;; let read () = @@ -116,15 +117,15 @@ ao_expo = %s b.ao_basis (AO_number.to_string b.ao_num) (b.ao_prim_num |> Array.to_list |> List.map - ~f:(Strictly_positive_int.to_string) |> String.concat ~sep:", " ) - (Strictly_positive_int.to_string b.ao_prim_num_max) + ~f:(AO_prim_number.to_string) |> String.concat ~sep:", " ) + (AO_prim_number.to_string b.ao_prim_num_max) (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:", ") - (b.ao_coef |> Array.to_list |> List.map ~f:Float.to_string + (b.ao_coef |> Array.to_list |> List.map ~f:AO_coef.to_string |> String.concat ~sep:", ") - (b.ao_expo |> Array.to_list |> List.map ~f:Positive_float.to_string + (b.ao_expo |> Array.to_list |> List.map ~f:AO_expo.to_string |> String.concat ~sep:", ") end diff --git a/ocaml/Input_bi_integrals.ml b/ocaml/Input_bi_integrals.ml index e040ce5f..3322f4c2 100644 --- a/ocaml/Input_bi_integrals.ml +++ b/ocaml/Input_bi_integrals.ml @@ -8,8 +8,8 @@ module Bielec_integrals : sig read_mo_integrals : bool; write_ao_integrals : bool; write_mo_integrals : bool; - threshold_ao : Positive_float.t; - threshold_mo : Positive_float.t; + threshold_ao : Threshold.t; + threshold_mo : Threshold.t; direct : bool; } ;; @@ -21,8 +21,8 @@ end = struct read_mo_integrals : bool; write_ao_integrals : bool; write_mo_integrals : bool; - threshold_ao : Positive_float.t; - threshold_mo : Positive_float.t; + threshold_ao : Threshold.t; + threshold_mo : Threshold.t; direct : bool; } ;; @@ -81,7 +81,7 @@ end = struct |> Ezfio.set_bielec_integrals_threshold_ao ; Ezfio.get_bielec_integrals_threshold_ao () - |> Positive_float.of_float + |> Threshold.of_float ;; let read_threshold_mo () = @@ -91,7 +91,7 @@ end = struct |> Ezfio.set_bielec_integrals_threshold_mo ; Ezfio.get_bielec_integrals_threshold_mo () - |> Positive_float.of_float + |> Threshold.of_float ;; let read ()= @@ -127,8 +127,8 @@ direct = %s (Bool.to_string b.read_mo_integrals) (Bool.to_string b.write_ao_integrals) (Bool.to_string b.write_mo_integrals) - (Positive_float.to_string b.threshold_ao) - (Positive_float.to_string b.threshold_mo) + (Threshold.to_string b.threshold_ao) + (Threshold.to_string b.threshold_mo) (Bool.to_string b.direct) end diff --git a/ocaml/Input_bitmasks.ml b/ocaml/Input_bitmasks.ml index 9e60b67e..be82f603 100644 --- a/ocaml/Input_bitmasks.ml +++ b/ocaml/Input_bitmasks.ml @@ -6,7 +6,7 @@ module Bitmasks : sig type t = { n_int : N_int_number.t; bit_kind : Bit_kind.t; - n_mask_gen : Strictly_positive_int.t; + n_mask_gen : Bitmask_number.t; generators : int64 array; } ;; @@ -16,7 +16,7 @@ end = struct type t = { n_int : N_int_number.t; bit_kind : Bit_kind.t; - n_mask_gen : Strictly_positive_int.t; + n_mask_gen : Bitmask_number.t; generators : int64 array; } ;; @@ -49,7 +49,7 @@ end = struct Ezfio.set_bitmasks_n_mask_gen 1 ; Ezfio.get_bitmasks_n_mask_gen () - |> Strictly_positive_int.of_int + |> Bitmask_number.of_int ;; @@ -93,7 +93,7 @@ generators = %s " (N_int_number.to_string b.n_int) (Bit_kind.to_string b.bit_kind) - (Strictly_positive_int.to_string b.n_mask_gen) + (Bitmask_number.to_string b.n_mask_gen) (Array.to_list b.generators |> List.map ~f:(fun x-> Int64.to_string x) |> String.concat ~sep:", ") diff --git a/ocaml/Input_cis.ml b/ocaml/Input_cis.ml index 3ee0e93b..6b521872 100644 --- a/ocaml/Input_cis.ml +++ b/ocaml/Input_cis.ml @@ -4,7 +4,7 @@ open Core.Std;; module Cis_dressed : sig type t = - { n_state_cis : Strictly_positive_int.t; + { n_state_cis : States_number.t; n_core_cis : Positive_int.t; n_act_cis : Positive_int.t; mp2_dressing : bool; @@ -16,7 +16,7 @@ module Cis_dressed : sig val to_string : t -> string end = struct type t = - { n_state_cis : Strictly_positive_int.t; + { n_state_cis : States_number.t; n_core_cis : Positive_int.t; n_act_cis : Positive_int.t; mp2_dressing : bool; @@ -34,7 +34,7 @@ end = struct |> Ezfio.set_cis_dressed_n_state_cis ; Ezfio.get_cis_dressed_n_state_cis () - |> Strictly_positive_int.of_int + |> States_number.of_int ;; let read_n_core_cis () = @@ -102,7 +102,7 @@ mp2_dressing = %s standard_doubles = %s en_2_2 = %s " - (Strictly_positive_int.to_string b.n_state_cis) + (States_number.to_string b.n_state_cis) (Positive_int.to_string b.n_core_cis) (Positive_int.to_string b.n_act_cis) (Bool.to_string b.mp2_dressing) diff --git a/ocaml/Input_cisd_sc2.ml b/ocaml/Input_cisd_sc2.ml index a976e683..4a5461f4 100644 --- a/ocaml/Input_cisd_sc2.ml +++ b/ocaml/Input_cisd_sc2.ml @@ -4,8 +4,8 @@ open Core.Std;; module Cisd_sc2 : sig type t = - { n_det_max_cisd_sc2 : Strictly_positive_int.t; - pt2_max : Positive_float.t; + { n_det_max_cisd_sc2 : Det_number.t; + pt2_max : PT2_energy.t; do_pt2_end : bool; } ;; @@ -13,8 +13,8 @@ module Cisd_sc2 : sig val to_string : t -> string end = struct type t = - { n_det_max_cisd_sc2 : Strictly_positive_int.t; - pt2_max : Positive_float.t; + { n_det_max_cisd_sc2 : Det_number.t; + pt2_max : PT2_energy.t; do_pt2_end : bool; } ;; @@ -28,7 +28,7 @@ end = struct |> Ezfio.set_cisd_sc2_selected_n_det_max_cisd_sc2 ; Ezfio.get_cisd_sc2_selected_n_det_max_cisd_sc2 () - |> Strictly_positive_int.of_int + |> Det_number.of_int ;; @@ -39,7 +39,7 @@ end = struct |> Ezfio.set_cisd_sc2_selected_pt2_max ; Ezfio.get_cisd_sc2_selected_pt2_max () - |> Positive_float.of_float + |> PT2_energy.of_float ;; @@ -66,8 +66,8 @@ n_det_max_cisd_sc2 = %s pt2_max = %s do_pt2_end = %s " - (Strictly_positive_int.to_string b.n_det_max_cisd_sc2) - (Positive_float.to_string b.pt2_max) + (Det_number.to_string b.n_det_max_cisd_sc2) + (PT2_energy.to_string b.pt2_max) (Bool.to_string b.do_pt2_end) end diff --git a/ocaml/Input_determinants.ml b/ocaml/Input_determinants.ml index 7a2e1ddf..fb2f599f 100644 --- a/ocaml/Input_determinants.ml +++ b/ocaml/Input_determinants.ml @@ -11,8 +11,8 @@ module Determinants : sig n_states : States_number.t; n_states_diag : States_number.t; n_det_max_jacobi : Det_number.t; - threshold_generators : Positive_float.t; - threshold_selectors : Positive_float.t; + threshold_generators : Threshold.t; + threshold_selectors : Threshold.t; read_wf : bool; expected_s2 : Positive_float.t; s2_eig : bool; @@ -31,8 +31,8 @@ end = struct n_states : States_number.t; n_states_diag : States_number.t; n_det_max_jacobi : Det_number.t; - threshold_generators : Positive_float.t; - threshold_selectors : Positive_float.t; + threshold_generators : Threshold.t; + threshold_selectors : Threshold.t; read_wf : bool; expected_s2 : Positive_float.t; s2_eig : bool; @@ -116,7 +116,7 @@ end = struct |> Ezfio.set_determinants_threshold_generators ; Ezfio.get_determinants_threshold_generators () - |> Positive_float.of_float + |> Threshold.of_float ;; let read_threshold_selectors () = @@ -126,7 +126,7 @@ end = struct |> Ezfio.set_determinants_threshold_selectors ; Ezfio.get_determinants_threshold_selectors () - |> Positive_float.of_float + |> Threshold.of_float ;; let read_read_wf () = @@ -257,8 +257,8 @@ psi_det = %s (b.n_states |> States_number.to_string) (b.n_states_diag |> States_number.to_string) (b.n_det_max_jacobi |> Det_number.to_string) - (b.threshold_generators |> Positive_float.to_string) - (b.threshold_selectors |> Positive_float.to_string) + (b.threshold_generators |> Threshold.to_string) + (b.threshold_selectors |> Threshold.to_string) (b.read_wf |> Bool.to_string) (b.expected_s2 |> Positive_float.to_string) (b.s2_eig |> Bool.to_string) @@ -266,7 +266,6 @@ psi_det = %s |> String.concat ~sep:", ") (b.psi_det |> Array.map ~f:(fun x -> Determinant.to_int64_array x |> Array.map ~f:(fun x-> - print_endline (Int64.to_string x) ; Int64.to_string x )|> Array.to_list |> String.concat ~sep:", ") |> Array.to_list |> String.concat ~sep:" | ") diff --git a/ocaml/Input_electrons.ml b/ocaml/Input_electrons.ml index af016d08..75785aea 100644 --- a/ocaml/Input_electrons.ml +++ b/ocaml/Input_electrons.ml @@ -4,18 +4,18 @@ open Core.Std;; module Electrons : sig type t = - { elec_alpha_num : Strictly_positive_int.t; - elec_beta_num : Positive_int.t; - elec_num : Strictly_positive_int.t; + { elec_alpha_num : Elec_alpha_number.t; + elec_beta_num : Elec_beta_number.t; + elec_num : Elec_number.t; } ;; val read : unit -> t val to_string : t -> string end = struct type t = - { elec_alpha_num : Strictly_positive_int.t; - elec_beta_num : Positive_int.t; - elec_num : Strictly_positive_int.t; + { elec_alpha_num : Elec_alpha_number.t; + elec_beta_num : Elec_beta_number.t; + elec_num : Elec_number.t; } ;; @@ -23,19 +23,19 @@ end = struct let read_elec_alpha_num() = Ezfio.get_electrons_elec_alpha_num () - |> Strictly_positive_int.of_int + |> Elec_alpha_number.of_int ;; let read_elec_beta_num() = Ezfio.get_electrons_elec_beta_num () - |> Positive_int.of_int + |> Elec_beta_number.of_int ;; let read_elec_num () = let na = Ezfio.get_electrons_elec_alpha_num () and nb = Ezfio.get_electrons_elec_beta_num () in assert (na >= nb); - Strictly_positive_int.of_int (na + nb) + Elec_number.of_int (na + nb) ;; @@ -52,9 +52,9 @@ elec_alpha_num = %s elec_beta_num = %s elec_num = %s " - (Strictly_positive_int.to_string b.elec_alpha_num) - (Positive_int.to_string b.elec_beta_num) - (Strictly_positive_int.to_string b.elec_num) + (Elec_alpha_number.to_string b.elec_alpha_num) + (Elec_beta_number.to_string b.elec_beta_num) + (Elec_number.to_string b.elec_num) end diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml index 64de6498..bcff6681 100644 --- a/ocaml/Input_full_ci.ml +++ b/ocaml/Input_full_ci.ml @@ -4,8 +4,8 @@ open Core.Std;; module Full_ci : sig type t = - { n_det_max_fci : Strictly_positive_int.t; - pt2_max : Positive_float.t; + { n_det_max_fci : Det_number.t; + pt2_max : PT2_energy.t; do_pt2_end : bool; } ;; @@ -13,8 +13,8 @@ module Full_ci : sig val to_string : t -> string end = struct type t = - { n_det_max_fci : Strictly_positive_int.t; - pt2_max : Positive_float.t; + { n_det_max_fci : Det_number.t; + pt2_max : PT2_energy.t; do_pt2_end : bool; } ;; @@ -28,7 +28,7 @@ end = struct |> Ezfio.set_full_ci_n_det_max_fci ; Ezfio.get_full_ci_n_det_max_fci () - |> Strictly_positive_int.of_int + |> Det_number.of_int ;; let read_pt2_max () = @@ -38,7 +38,7 @@ end = struct |> Ezfio.set_full_ci_pt2_max ; Ezfio.get_full_ci_pt2_max () - |> Positive_float.of_float + |> PT2_energy.of_float ;; let read_do_pt2_end () = @@ -64,8 +64,8 @@ n_det_max_fci = %s pt2_max = %s do_pt2_end = %s " - (Strictly_positive_int.to_string b.n_det_max_fci) - (Positive_float.to_string b.pt2_max) + (Det_number.to_string b.n_det_max_fci) + (PT2_energy.to_string b.pt2_max) (Bool.to_string b.do_pt2_end) end diff --git a/ocaml/Input_hartree_fock.ml b/ocaml/Input_hartree_fock.ml new file mode 100644 index 00000000..a612ae74 --- /dev/null +++ b/ocaml/Input_hartree_fock.ml @@ -0,0 +1,57 @@ +open Qptypes;; +open Qputils;; +open Core.Std;; + +module Hartree_fock : sig + type t = + { n_it_scf_max : Strictly_positive_int.t; + thresh_scf : Threshold.t; + } + ;; + val read : unit -> t + val to_string : t -> string +end = struct + type t = + { n_it_scf_max : Strictly_positive_int.t; + thresh_scf : Threshold.t; + } + ;; + + let get_default = Qpackage.get_ezfio_default "hartree_fock";; + + let read_n_it_scf_max () = + if not (Ezfio.has_hartree_fock_n_it_scf_max ()) then + get_default "n_it_scf_max" + |> Int.of_string + |> Ezfio.set_hartree_fock_n_it_scf_max + ; + Ezfio.get_hartree_fock_n_it_scf_max () + |> Strictly_positive_int.of_int + ;; + + let read_thresh_scf() = + if not (Ezfio.has_hartree_fock_thresh_scf()) then + get_default "thresh_scf" + |> Float.of_string + |> Ezfio.set_hartree_fock_thresh_scf + ; + Ezfio.get_hartree_fock_thresh_scf () + |> Threshold.of_float ;; + + + let read () = + { n_it_scf_max = read_n_it_scf_max (); + thresh_scf = read_thresh_scf (); + } + ;; + + let to_string b = + Printf.sprintf " +n_it_scf_max = %s +thresh_scf = %s +" + (Strictly_positive_int.to_string b.n_it_scf_max) + (Threshold.to_string b.thresh_scf) +end + + diff --git a/ocaml/qptypes_generator.ml b/ocaml/qptypes_generator.ml index 24b08b25..8ab5b5cf 100644 --- a/ocaml/qptypes_generator.ml +++ b/ocaml/qptypes_generator.ml @@ -99,10 +99,35 @@ let input_data = " | _ -> raise (Failure \"Bit_kind should be (1|2|4|8).\") end; +* Bitmask_number : int + assert (x > 0) ; + * MO_coef : float * AO_coef : float +* AO_expo : float + assert (x >= 0.) ; + +* AO_prim_number : int + assert (x > 0) ; + +* Threshold : float + assert (x >= 0.) ; + assert (x <= 1.) ; + +* PT2_energy : float + assert (x >=0.) ; + +* Elec_alpha_number : int + assert (x > 0) ; + +* Elec_beta_number : int + assert (x >= 0) ; + +* Elec_number : int + assert (x > 0) ; + " ;; diff --git a/ocaml/test_input.ml b/ocaml/test_input.ml index 4b7d135e..b88cd37c 100644 --- a/ocaml/test_input.ml +++ b/ocaml/test_input.ml @@ -54,4 +54,19 @@ let test_fci () = print_endline (Input.Full_ci.to_string b); ;; -test_fci();; +let test_hf () = + Ezfio.set_file "F2.ezfio" ; + let b = Input.Hartree_fock.read () + in + print_endline (Input.Hartree_fock.to_string b); +;; + +(* +test_hf ();; +test_ao ();; +test_bielec_intergals ();; +test_bitmasks (); +test_cis (); +test_dets (); +*) +test_cisd_sc2 ();