10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-08-06 20:40:30 +02:00

Bug in psi_det N_det psi_coef

This commit is contained in:
Anthony Scemama 2014-10-28 17:16:51 +01:00
parent 3f8f8da2ae
commit 82a285774c
10 changed files with 123 additions and 38 deletions

View File

@ -142,7 +142,7 @@ end = struct
let to_string b = let to_string b =
let short_basis = to_basis b in let short_basis = to_basis b in
Printf.sprintf "Basis name : %s\n\n%s" b.ao_basis Printf.sprintf "Basis name : %s\n\n%s\n" b.ao_basis
(Basis.to_string short_basis) (Basis.to_string short_basis)
;; ;;

View File

@ -4,7 +4,7 @@ open Core.Std;;
module Cisd_sc2 : sig module Cisd_sc2 : sig
type t = type t =
{ n_det_max_cisd_sc2 : Det_number.t; { n_det_max_cisd_sc2 : Det_number_max.t;
pt2_max : PT2_energy.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} with sexp } with sexp
@ -13,7 +13,7 @@ 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 : Det_number.t; { n_det_max_cisd_sc2 : Det_number_max.t;
pt2_max : PT2_energy.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} with sexp } with sexp
@ -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 ()
|> Det_number.of_int |> Det_number_max.of_int
;; ;;
@ -61,12 +61,11 @@ end = struct
;; ;;
let to_string b = let to_string b =
Printf.sprintf " Printf.sprintf "n_det_max_cisd_sc2 = %s
n_det_max_cisd_sc2 = %s
pt2_max = %s pt2_max = %s
do_pt2_end = %s do_pt2_end = %s
" "
(Det_number.to_string b.n_det_max_cisd_sc2) (Det_number_max.to_string b.n_det_max_cisd_sc2)
(PT2_energy.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

@ -10,7 +10,7 @@ module Determinants : sig
n_det : Det_number.t; n_det : Det_number.t;
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 : Strictly_positive_int.t;
threshold_generators : Threshold.t; threshold_generators : Threshold.t;
threshold_selectors : Threshold.t; threshold_selectors : Threshold.t;
read_wf : bool; read_wf : bool;
@ -30,7 +30,7 @@ end = struct
n_det : Det_number.t; n_det : Det_number.t;
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 : Strictly_positive_int.t;
threshold_generators : Threshold.t; threshold_generators : Threshold.t;
threshold_selectors : Threshold.t; threshold_selectors : Threshold.t;
read_wf : bool; read_wf : bool;
@ -106,7 +106,7 @@ end = struct
|> Ezfio.set_determinants_n_det_max_jacobi |> Ezfio.set_determinants_n_det_max_jacobi
; ;
Ezfio.get_determinants_n_det_max_jacobi () Ezfio.get_determinants_n_det_max_jacobi ()
|> Det_number.of_int |> Strictly_positive_int.of_int
;; ;;
let read_threshold_generators () = let read_threshold_generators () =
@ -234,6 +234,30 @@ end = struct
;; ;;
let to_string b = let to_string b =
Printf.sprintf "read_wf = %s
n_det = %s
n_states = %s
threshold_generators = %s
threshold_selectors = %s
n_det_max_jacobi = %s
n_states_diag = %s
s2_eig = %s
expected_s2 = %s
mo_label = \"%s\"
"
(b.read_wf |> Bool.to_string)
(b.n_det |> Det_number.to_string)
(b.n_states |> States_number.to_string)
(b.threshold_generators |> Threshold.to_string)
(b.threshold_selectors |> Threshold.to_string)
(b.n_det_max_jacobi |> Strictly_positive_int.to_string)
(b.n_states_diag |> States_number.to_string)
(b.s2_eig |> Bool.to_string)
(b.expected_s2 |> Positive_float.to_string)
(b.mo_label |> Non_empty_string.to_string)
;;
let debug b =
Printf.sprintf " Printf.sprintf "
n_int = %s n_int = %s
bit_kind = %s bit_kind = %s
@ -256,7 +280,7 @@ psi_det = %s
(b.n_det |> Det_number.to_string) (b.n_det |> Det_number.to_string)
(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 |> Strictly_positive_int.to_string)
(b.threshold_generators |> Threshold.to_string) (b.threshold_generators |> Threshold.to_string)
(b.threshold_selectors |> Threshold.to_string) (b.threshold_selectors |> Threshold.to_string)
(b.read_wf |> Bool.to_string) (b.read_wf |> Bool.to_string)
@ -269,8 +293,7 @@ psi_det = %s
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:" | ")
; ;;
;;
end end

View File

@ -47,14 +47,22 @@ end = struct
;; ;;
let to_string b = let to_string b =
Printf.sprintf " Printf.sprintf "elec_alpha_num = %s
elec_alpha_num = %s elec_beta_num = %s
"
(Elec_alpha_number.to_string b.elec_alpha_num)
(Elec_beta_number.to_string b.elec_beta_num)
;;
let debug b =
Printf.sprintf "elec_alpha_num = %s
elec_beta_num = %s elec_beta_num = %s
elec_num = %s elec_num = %s
" "
(Elec_alpha_number.to_string b.elec_alpha_num) (Elec_alpha_number.to_string b.elec_alpha_num)
(Elec_beta_number.to_string b.elec_beta_num) (Elec_beta_number.to_string b.elec_beta_num)
(Elec_number.to_string b.elec_num) (Elec_number.to_string b.elec_num)
;;
end end

View File

@ -4,7 +4,7 @@ open Core.Std;;
module Full_ci : sig module Full_ci : sig
type t = type t =
{ n_det_max_fci : Det_number.t; { n_det_max_fci : Det_number_max.t;
pt2_max : PT2_energy.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} with sexp } with sexp
@ -13,7 +13,7 @@ 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 : Det_number.t; { n_det_max_fci : Det_number_max.t;
pt2_max : PT2_energy.t; pt2_max : PT2_energy.t;
do_pt2_end : bool; do_pt2_end : bool;
} with sexp } with sexp
@ -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 ()
|> Det_number.of_int |> Det_number_max.of_int
;; ;;
let read_pt2_max () = let read_pt2_max () =
@ -59,12 +59,11 @@ end = struct
;; ;;
let to_string b = let to_string b =
Printf.sprintf " Printf.sprintf "n_det_max_fci = %s
n_det_max_fci = %s
pt2_max = %s pt2_max = %s
do_pt2_end = %s do_pt2_end = %s
" "
(Det_number.to_string b.n_det_max_fci) (Det_number_max.to_string b.n_det_max_fci)
(PT2_energy.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

@ -46,8 +46,7 @@ end = struct
;; ;;
let to_string b = let to_string b =
Printf.sprintf " Printf.sprintf "n_it_scf_max = %s
n_it_scf_max = %s
thresh_scf = %s thresh_scf = %s
" "
(Strictly_positive_int.to_string b.n_it_scf_max) (Strictly_positive_int.to_string b.n_it_scf_max)

View File

@ -72,6 +72,16 @@ end = struct
let to_string b = let to_string b =
Printf.sprintf " Printf.sprintf "
mo_label = %s mo_label = %s
mo_tot_num = %s
"
(Non_empty_string.to_string b.mo_label)
(MO_number.to_string b.mo_tot_num)
;;
let debug b =
Printf.sprintf "
mo_label = %s
mo_tot_num = \"%s\" mo_tot_num = \"%s\"
mo_occ = %s mo_occ = %s
mo_coef = %s mo_coef = %s
@ -82,6 +92,7 @@ mo_coef = %s
~f:(Positive_float.to_string) |> String.concat ~sep:", " ) ~f:(Positive_float.to_string) |> String.concat ~sep:", " )
(b.mo_coef |> Array.to_list |> List.map (b.mo_coef |> Array.to_list |> List.map
~f:(MO_coef.to_string) |> String.concat ~sep:", " ) ~f:(MO_coef.to_string) |> String.concat ~sep:", " )
;;
end end

View File

@ -15,11 +15,23 @@ let instructions filename = Printf.sprintf
type keyword = type keyword =
| Ao_basis | Ao_basis
| Bielec_integrals | Bielec_integrals
| Cisd_sc2
| Determinants
| Electrons
| Full_ci
| Hartree_fock
| Mo_basis
;; ;;
let keyword_to_string = function let keyword_to_string = function
| Ao_basis -> "AO basis" | Ao_basis -> "AO basis"
| Bielec_integrals -> "Two electron integrals" | Bielec_integrals -> "Two electron integrals"
| Cisd_sc2 -> "CISD (SC)^2"
| Determinants -> "Determinants"
| Electrons -> "Electrons"
| Full_ci -> "Selected Full-CI"
| Hartree_fock -> "Hartree-Fock"
| Mo_basis -> "MO basis"
;; ;;
let make_header kw = let make_header kw =
@ -28,15 +40,37 @@ let make_header kw =
"\n\n# "^s^"\n"^"# "^(String.init l ~f:(fun _ -> '='))^"\n\n" "\n\n# "^s^"\n"^"# "^(String.init l ~f:(fun _ -> '='))^"\n\n"
;; ;;
let get_bielec () = let get s =
(make_header Bielec_integrals)^ let header = (make_header s)
(Input.Bielec_integrals.(to_string (read ()))) in header^(match s with
| Bielec_integrals ->
Input.Bielec_integrals.(to_string (read ()))
| Ao_basis ->
Input.Ao_basis.(to_string (read ()))
| Cisd_sc2 ->
Input.Cisd_sc2.(to_string (read ()))
| Determinants ->
Input.Determinants.(to_string (read ()))
| Electrons ->
Input.Electrons.(to_string (read ()))
| Full_ci ->
Input.Full_ci.(to_string (read ()))
| Hartree_fock ->
Input.Hartree_fock.(to_string (read ()))
| Mo_basis ->
Input.Mo_basis.(to_string (read ()))
)
;; ;;
let get_ao_basis () = (*
(make_header Ao_basis)^ let create_temp_file ezfio_filename fields =
(Input.Ao_basis.(to_string (read ()))) In_channel.with_file filename ~f:(func out_channel ->
(instructions ezfio_filename) :: (List.map ~f:get fields)
|> String.concat output
|> print_string
)
;; ;;
*)
let run ezfio_filename = let run ezfio_filename =
@ -46,11 +80,18 @@ let run ezfio_filename =
Ezfio.set_file ezfio_filename; Ezfio.set_file ezfio_filename;
let output = [ let output = (instructions ezfio_filename) :: (
(instructions ezfio_filename) ; List.map ~f:get [
(get_ao_basis ()) ; Electrons ;
(get_bielec ()) Ao_basis ;
] in Mo_basis ;
Bielec_integrals ;
Cisd_sc2 ;
Determinants ;
Full_ci ;
Hartree_fock ;
])
in
String.concat output String.concat output
|> print_string |> print_string
;; ;;

View File

@ -68,8 +68,13 @@ let input_data = "
assert (x > 0) ; assert (x > 0) ;
if (x > 100000000) then if (x > 100000000) then
warning \"More than 100 million determinants\"; warning \"More than 100 million determinants\";
if (Ezfio.has_determinants_det_num ()) then if (Ezfio.has_determinants_n_det ()) then
assert (x <= (Ezfio.get_determinants_det_num ())); assert (x <= (Ezfio.get_determinants_n_det ()));
* Det_number_max : int
assert (x > 0) ;
if (x > 100000000) then
warning \"More than 100 million determinants\";
* States_number : int * States_number : int
assert (x > 0) ; assert (x > 0) ;

View File

@ -136,7 +136,6 @@ subroutine copy_H_apply_buffer_to_wf
do j=0,nproc-1 do j=0,nproc-1
N_det = N_det + H_apply_buffer(j)%N_det N_det = N_det + H_apply_buffer(j)%N_det
enddo enddo
SOFT_TOUCH N_det
if (psi_det_size < N_det) then if (psi_det_size < N_det) then
psi_det_size = N_det psi_det_size = N_det
@ -180,6 +179,7 @@ subroutine copy_H_apply_buffer_to_wf
H_apply_buffer(j)%N_det = 0 H_apply_buffer(j)%N_det = 0
!$OMP END PARALLEL !$OMP END PARALLEL
call normalize(psi_coef,N_det) call normalize(psi_coef,N_det)
SOFT_TOUCH N_det psi_det psi_coef
end end