10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-10-02 14:30:59 +02:00

Added Input_hartree_fock.ml

This commit is contained in:
Anthony Scemama 2014-10-22 00:12:23 +02:00
parent ede29e4284
commit abb8967d63
12 changed files with 167 additions and 69 deletions

View File

@ -11,5 +11,6 @@ include Input_cisd_sc2;;
include Input_determinants;; include Input_determinants;;
include Input_electrons;; include Input_electrons;;
include Input_full_ci;; include Input_full_ci;;
include Input_hartree_fock;;

View File

@ -6,12 +6,12 @@ module Ao_basis : sig
type t = type t =
{ ao_basis : string ; { ao_basis : string ;
ao_num : AO_number.t ; ao_num : AO_number.t ;
ao_prim_num : Strictly_positive_int.t array; ao_prim_num : AO_prim_number.t array;
ao_prim_num_max : Strictly_positive_int.t; ao_prim_num_max : AO_prim_number.t;
ao_nucl : Nucl_number.t array; ao_nucl : Nucl_number.t array;
ao_power : Symmetry.Xyz.t array; ao_power : Symmetry.Xyz.t array;
ao_coef : float array; ao_coef : AO_coef.t array;
ao_expo : Positive_float.t array; ao_expo : AO_expo.t array;
} }
;; ;;
val read : unit -> t val read : unit -> t
@ -20,12 +20,12 @@ end = struct
type t = type t =
{ ao_basis : string ; { ao_basis : string ;
ao_num : AO_number.t ; ao_num : AO_number.t ;
ao_prim_num : Strictly_positive_int.t array; ao_prim_num : AO_prim_number.t array;
ao_prim_num_max : Strictly_positive_int.t; ao_prim_num_max : AO_prim_number.t;
ao_nucl : Nucl_number.t array; ao_nucl : Nucl_number.t array;
ao_power : Symmetry.Xyz.t array; ao_power : Symmetry.Xyz.t array;
ao_coef : float array; ao_coef : AO_coef.t array;
ao_expo : Positive_float.t array; ao_expo : AO_expo.t array;
} }
;; ;;
@ -46,14 +46,14 @@ end = struct
let read_ao_prim_num () = let read_ao_prim_num () =
(Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data (Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data
|> Ezfio.flattened_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 () = let read_ao_prim_num_max () =
(Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data (Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data
|> Ezfio.flattened_ezfio_data |> Ezfio.flattened_ezfio_data
|> Array.fold ~f:(fun x y -> if x>y then x else y) ~init:0 |> 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 () = let read_ao_nucl () =
@ -82,12 +82,13 @@ end = struct
let read_ao_coef () = let read_ao_coef () =
(Ezfio.get_ao_basis_ao_coef () ).Ezfio.data (Ezfio.get_ao_basis_ao_coef () ).Ezfio.data
|> Ezfio.flattened_ezfio_data |> Ezfio.flattened_ezfio_data
|> Array.map ~f:AO_coef.of_float
;; ;;
let read_ao_expo () = let read_ao_expo () =
(Ezfio.get_ao_basis_ao_expo () ).Ezfio.data (Ezfio.get_ao_basis_ao_expo () ).Ezfio.data
|> Ezfio.flattened_ezfio_data |> Ezfio.flattened_ezfio_data
|> Array.map ~f:Positive_float.of_float |> Array.map ~f:AO_expo.of_float
;; ;;
let read () = let read () =
@ -116,15 +117,15 @@ ao_expo = %s
b.ao_basis b.ao_basis
(AO_number.to_string b.ao_num) (AO_number.to_string b.ao_num)
(b.ao_prim_num |> Array.to_list |> List.map (b.ao_prim_num |> Array.to_list |> List.map
~f:(Strictly_positive_int.to_string) |> String.concat ~sep:", " ) ~f:(AO_prim_number.to_string) |> String.concat ~sep:", " )
(Strictly_positive_int.to_string b.ao_prim_num_max) (AO_prim_number.to_string b.ao_prim_num_max)
(b.ao_nucl |> Array.to_list |> List.map ~f:Nucl_number.to_string |> (b.ao_nucl |> Array.to_list |> List.map ~f:Nucl_number.to_string |>
String.concat ~sep:", ") String.concat ~sep:", ")
(b.ao_power |> Array.to_list |> List.map ~f:(fun x-> (b.ao_power |> Array.to_list |> List.map ~f:(fun x->
"("^(Symmetry.Xyz.to_string x)^")" )|> String.concat ~sep:", ") "("^(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:", ") |> 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:", ") |> String.concat ~sep:", ")
end end

View File

@ -8,8 +8,8 @@ module Bielec_integrals : sig
read_mo_integrals : bool; read_mo_integrals : bool;
write_ao_integrals : bool; write_ao_integrals : bool;
write_mo_integrals : bool; write_mo_integrals : bool;
threshold_ao : Positive_float.t; threshold_ao : Threshold.t;
threshold_mo : Positive_float.t; threshold_mo : Threshold.t;
direct : bool; direct : bool;
} }
;; ;;
@ -21,8 +21,8 @@ end = struct
read_mo_integrals : bool; read_mo_integrals : bool;
write_ao_integrals : bool; write_ao_integrals : bool;
write_mo_integrals : bool; write_mo_integrals : bool;
threshold_ao : Positive_float.t; threshold_ao : Threshold.t;
threshold_mo : Positive_float.t; threshold_mo : Threshold.t;
direct : bool; direct : bool;
} }
;; ;;
@ -81,7 +81,7 @@ end = struct
|> Ezfio.set_bielec_integrals_threshold_ao |> Ezfio.set_bielec_integrals_threshold_ao
; ;
Ezfio.get_bielec_integrals_threshold_ao () Ezfio.get_bielec_integrals_threshold_ao ()
|> Positive_float.of_float |> Threshold.of_float
;; ;;
let read_threshold_mo () = let read_threshold_mo () =
@ -91,7 +91,7 @@ end = struct
|> Ezfio.set_bielec_integrals_threshold_mo |> Ezfio.set_bielec_integrals_threshold_mo
; ;
Ezfio.get_bielec_integrals_threshold_mo () Ezfio.get_bielec_integrals_threshold_mo ()
|> Positive_float.of_float |> Threshold.of_float
;; ;;
let read ()= let read ()=
@ -127,8 +127,8 @@ direct = %s
(Bool.to_string b.read_mo_integrals) (Bool.to_string b.read_mo_integrals)
(Bool.to_string b.write_ao_integrals) (Bool.to_string b.write_ao_integrals)
(Bool.to_string b.write_mo_integrals) (Bool.to_string b.write_mo_integrals)
(Positive_float.to_string b.threshold_ao) (Threshold.to_string b.threshold_ao)
(Positive_float.to_string b.threshold_mo) (Threshold.to_string b.threshold_mo)
(Bool.to_string b.direct) (Bool.to_string b.direct)
end end

View File

@ -6,7 +6,7 @@ module Bitmasks : sig
type t = type t =
{ n_int : N_int_number.t; { n_int : N_int_number.t;
bit_kind : Bit_kind.t; bit_kind : Bit_kind.t;
n_mask_gen : Strictly_positive_int.t; n_mask_gen : Bitmask_number.t;
generators : int64 array; generators : int64 array;
} }
;; ;;
@ -16,7 +16,7 @@ end = struct
type t = type t =
{ n_int : N_int_number.t; { n_int : N_int_number.t;
bit_kind : Bit_kind.t; bit_kind : Bit_kind.t;
n_mask_gen : Strictly_positive_int.t; n_mask_gen : Bitmask_number.t;
generators : int64 array; generators : int64 array;
} }
;; ;;
@ -49,7 +49,7 @@ end = struct
Ezfio.set_bitmasks_n_mask_gen 1 Ezfio.set_bitmasks_n_mask_gen 1
; ;
Ezfio.get_bitmasks_n_mask_gen () 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) (N_int_number.to_string b.n_int)
(Bit_kind.to_string b.bit_kind) (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 (Array.to_list b.generators
|> List.map ~f:(fun x-> Int64.to_string x) |> List.map ~f:(fun x-> Int64.to_string x)
|> String.concat ~sep:", ") |> String.concat ~sep:", ")

View File

@ -4,7 +4,7 @@ open Core.Std;;
module Cis_dressed : sig module Cis_dressed : sig
type t = type t =
{ n_state_cis : Strictly_positive_int.t; { n_state_cis : States_number.t;
n_core_cis : Positive_int.t; n_core_cis : Positive_int.t;
n_act_cis : Positive_int.t; n_act_cis : Positive_int.t;
mp2_dressing : bool; mp2_dressing : bool;
@ -16,7 +16,7 @@ module Cis_dressed : sig
val to_string : t -> string val to_string : t -> string
end = struct end = struct
type t = type t =
{ n_state_cis : Strictly_positive_int.t; { n_state_cis : States_number.t;
n_core_cis : Positive_int.t; n_core_cis : Positive_int.t;
n_act_cis : Positive_int.t; n_act_cis : Positive_int.t;
mp2_dressing : bool; mp2_dressing : bool;
@ -34,7 +34,7 @@ end = struct
|> Ezfio.set_cis_dressed_n_state_cis |> Ezfio.set_cis_dressed_n_state_cis
; ;
Ezfio.get_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 () = let read_n_core_cis () =
@ -102,7 +102,7 @@ mp2_dressing = %s
standard_doubles = %s standard_doubles = %s
en_2_2 = %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_core_cis)
(Positive_int.to_string b.n_act_cis) (Positive_int.to_string b.n_act_cis)
(Bool.to_string b.mp2_dressing) (Bool.to_string b.mp2_dressing)

View File

@ -4,8 +4,8 @@ open Core.Std;;
module Cisd_sc2 : sig module Cisd_sc2 : sig
type t = type t =
{ n_det_max_cisd_sc2 : Strictly_positive_int.t; { n_det_max_cisd_sc2 : Det_number.t;
pt2_max : Positive_float.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} }
;; ;;
@ -13,8 +13,8 @@ module Cisd_sc2 : sig
val to_string : t -> string val to_string : t -> string
end = struct end = struct
type t = type t =
{ n_det_max_cisd_sc2 : Strictly_positive_int.t; { n_det_max_cisd_sc2 : Det_number.t;
pt2_max : Positive_float.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} }
;; ;;
@ -28,7 +28,7 @@ end = struct
|> Ezfio.set_cisd_sc2_selected_n_det_max_cisd_sc2 |> Ezfio.set_cisd_sc2_selected_n_det_max_cisd_sc2
; ;
Ezfio.get_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.set_cisd_sc2_selected_pt2_max
; ;
Ezfio.get_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 pt2_max = %s
do_pt2_end = %s do_pt2_end = %s
" "
(Strictly_positive_int.to_string b.n_det_max_cisd_sc2) (Det_number.to_string b.n_det_max_cisd_sc2)
(Positive_float.to_string b.pt2_max) (PT2_energy.to_string b.pt2_max)
(Bool.to_string b.do_pt2_end) (Bool.to_string b.do_pt2_end)
end end

View File

@ -11,8 +11,8 @@ module Determinants : sig
n_states : States_number.t; n_states : States_number.t;
n_states_diag : States_number.t; n_states_diag : States_number.t;
n_det_max_jacobi : Det_number.t; n_det_max_jacobi : Det_number.t;
threshold_generators : Positive_float.t; threshold_generators : Threshold.t;
threshold_selectors : Positive_float.t; threshold_selectors : Threshold.t;
read_wf : bool; read_wf : bool;
expected_s2 : Positive_float.t; expected_s2 : Positive_float.t;
s2_eig : bool; s2_eig : bool;
@ -31,8 +31,8 @@ end = struct
n_states : States_number.t; n_states : States_number.t;
n_states_diag : States_number.t; n_states_diag : States_number.t;
n_det_max_jacobi : Det_number.t; n_det_max_jacobi : Det_number.t;
threshold_generators : Positive_float.t; threshold_generators : Threshold.t;
threshold_selectors : Positive_float.t; threshold_selectors : Threshold.t;
read_wf : bool; read_wf : bool;
expected_s2 : Positive_float.t; expected_s2 : Positive_float.t;
s2_eig : bool; s2_eig : bool;
@ -116,7 +116,7 @@ end = struct
|> Ezfio.set_determinants_threshold_generators |> Ezfio.set_determinants_threshold_generators
; ;
Ezfio.get_determinants_threshold_generators () Ezfio.get_determinants_threshold_generators ()
|> Positive_float.of_float |> Threshold.of_float
;; ;;
let read_threshold_selectors () = let read_threshold_selectors () =
@ -126,7 +126,7 @@ end = struct
|> Ezfio.set_determinants_threshold_selectors |> Ezfio.set_determinants_threshold_selectors
; ;
Ezfio.get_determinants_threshold_selectors () Ezfio.get_determinants_threshold_selectors ()
|> Positive_float.of_float |> Threshold.of_float
;; ;;
let read_read_wf () = let read_read_wf () =
@ -257,8 +257,8 @@ psi_det = %s
(b.n_states |> States_number.to_string) (b.n_states |> States_number.to_string)
(b.n_states_diag |> States_number.to_string) (b.n_states_diag |> States_number.to_string)
(b.n_det_max_jacobi |> Det_number.to_string) (b.n_det_max_jacobi |> Det_number.to_string)
(b.threshold_generators |> Positive_float.to_string) (b.threshold_generators |> Threshold.to_string)
(b.threshold_selectors |> Positive_float.to_string) (b.threshold_selectors |> Threshold.to_string)
(b.read_wf |> Bool.to_string) (b.read_wf |> Bool.to_string)
(b.expected_s2 |> Positive_float.to_string) (b.expected_s2 |> Positive_float.to_string)
(b.s2_eig |> Bool.to_string) (b.s2_eig |> Bool.to_string)
@ -266,7 +266,6 @@ psi_det = %s
|> String.concat ~sep:", ") |> String.concat ~sep:", ")
(b.psi_det |> Array.map ~f:(fun x -> Determinant.to_int64_array x (b.psi_det |> Array.map ~f:(fun x -> Determinant.to_int64_array x
|> Array.map ~f:(fun x-> |> Array.map ~f:(fun x->
print_endline (Int64.to_string x) ;
Int64.to_string x )|> Array.to_list |> Int64.to_string x )|> Array.to_list |>
String.concat ~sep:", ") |> Array.to_list String.concat ~sep:", ") |> Array.to_list
|> String.concat ~sep:" | ") |> String.concat ~sep:" | ")

View File

@ -4,18 +4,18 @@ open Core.Std;;
module Electrons : sig module Electrons : sig
type t = type t =
{ elec_alpha_num : Strictly_positive_int.t; { elec_alpha_num : Elec_alpha_number.t;
elec_beta_num : Positive_int.t; elec_beta_num : Elec_beta_number.t;
elec_num : Strictly_positive_int.t; elec_num : Elec_number.t;
} }
;; ;;
val read : unit -> t val read : unit -> t
val to_string : t -> string val to_string : t -> string
end = struct end = struct
type t = type t =
{ elec_alpha_num : Strictly_positive_int.t; { elec_alpha_num : Elec_alpha_number.t;
elec_beta_num : Positive_int.t; elec_beta_num : Elec_beta_number.t;
elec_num : Strictly_positive_int.t; elec_num : Elec_number.t;
} }
;; ;;
@ -23,19 +23,19 @@ end = struct
let read_elec_alpha_num() = let read_elec_alpha_num() =
Ezfio.get_electrons_elec_alpha_num () Ezfio.get_electrons_elec_alpha_num ()
|> Strictly_positive_int.of_int |> Elec_alpha_number.of_int
;; ;;
let read_elec_beta_num() = let read_elec_beta_num() =
Ezfio.get_electrons_elec_beta_num () Ezfio.get_electrons_elec_beta_num ()
|> Positive_int.of_int |> Elec_beta_number.of_int
;; ;;
let read_elec_num () = let read_elec_num () =
let na = Ezfio.get_electrons_elec_alpha_num () let na = Ezfio.get_electrons_elec_alpha_num ()
and nb = Ezfio.get_electrons_elec_beta_num () and nb = Ezfio.get_electrons_elec_beta_num ()
in assert (na >= nb); 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_beta_num = %s
elec_num = %s elec_num = %s
" "
(Strictly_positive_int.to_string b.elec_alpha_num) (Elec_alpha_number.to_string b.elec_alpha_num)
(Positive_int.to_string b.elec_beta_num) (Elec_beta_number.to_string b.elec_beta_num)
(Strictly_positive_int.to_string b.elec_num) (Elec_number.to_string b.elec_num)
end end

View File

@ -4,8 +4,8 @@ open Core.Std;;
module Full_ci : sig module Full_ci : sig
type t = type t =
{ n_det_max_fci : Strictly_positive_int.t; { n_det_max_fci : Det_number.t;
pt2_max : Positive_float.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} }
;; ;;
@ -13,8 +13,8 @@ module Full_ci : sig
val to_string : t -> string val to_string : t -> string
end = struct end = struct
type t = type t =
{ n_det_max_fci : Strictly_positive_int.t; { n_det_max_fci : Det_number.t;
pt2_max : Positive_float.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} }
;; ;;
@ -28,7 +28,7 @@ end = struct
|> Ezfio.set_full_ci_n_det_max_fci |> Ezfio.set_full_ci_n_det_max_fci
; ;
Ezfio.get_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 () = let read_pt2_max () =
@ -38,7 +38,7 @@ end = struct
|> Ezfio.set_full_ci_pt2_max |> Ezfio.set_full_ci_pt2_max
; ;
Ezfio.get_full_ci_pt2_max () Ezfio.get_full_ci_pt2_max ()
|> Positive_float.of_float |> PT2_energy.of_float
;; ;;
let read_do_pt2_end () = let read_do_pt2_end () =
@ -64,8 +64,8 @@ n_det_max_fci = %s
pt2_max = %s pt2_max = %s
do_pt2_end = %s do_pt2_end = %s
" "
(Strictly_positive_int.to_string b.n_det_max_fci) (Det_number.to_string b.n_det_max_fci)
(Positive_float.to_string b.pt2_max) (PT2_energy.to_string b.pt2_max)
(Bool.to_string b.do_pt2_end) (Bool.to_string b.do_pt2_end)
end end

View File

@ -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

View File

@ -99,10 +99,35 @@ let input_data = "
| _ -> raise (Failure \"Bit_kind should be (1|2|4|8).\") | _ -> raise (Failure \"Bit_kind should be (1|2|4|8).\")
end; end;
* Bitmask_number : int
assert (x > 0) ;
* MO_coef : float * MO_coef : float
* AO_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) ;
" "
;; ;;

View File

@ -54,4 +54,19 @@ let test_fci () =
print_endline (Input.Full_ci.to_string b); 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 ();