From 6b3ba6a99ed25eb13366512bc118c646a77d42a0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 7 Mar 2016 20:13:43 +0100 Subject: [PATCH] Fixed QMCPACK bugs (Issue #154) --- ocaml/Input_determinants_by_hand.ml | 21 +++++++++++++-------- ocaml/TaskServer.ml | 2 +- ocaml/qp_print_basis.ml | 6 ++---- ocaml/test_message.ml | 4 ++-- plugins/qmcpack/save_for_qmcpack.irp.f | 6 ++++++ scripts/ezfio_interface/qp_edit_template | 2 +- src/AO_Basis/aos.irp.f | 3 --- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ocaml/Input_determinants_by_hand.ml b/ocaml/Input_determinants_by_hand.ml index 6d48c917..c69c8ad9 100644 --- a/ocaml/Input_determinants_by_hand.ml +++ b/ocaml/Input_determinants_by_hand.ml @@ -11,7 +11,8 @@ module Determinants_by_hand : sig psi_coef : Det_coef.t array; psi_det : Determinant.t array; } with sexp - val read : unit -> t option + val read : unit -> t + val read_maybe : unit -> t option val write : t -> unit val to_string : t -> string val to_rst : t -> Rst_string.t @@ -210,13 +211,6 @@ end = struct let read () = if (Ezfio.has_mo_basis_mo_tot_num ()) then - let n_det = - read_n_det () - in - if ( (Det_number.to_int n_det) > n_det_read_max ) then - None - else - Some { n_int = read_n_int () ; bit_kind = read_bit_kind () ; n_det = read_n_det () ; @@ -224,6 +218,17 @@ end = struct psi_coef = read_psi_coef () ; psi_det = read_psi_det () ; } + else + failwith "No molecular orbitals, so no determinants" + ;; + + let read_maybe () = + let n_det = + read_n_det () + in + if ( (Det_number.to_int n_det) < n_det_read_max ) then + try Some (read ()) with + | Failure _ -> None else None ;; diff --git a/ocaml/TaskServer.ml b/ocaml/TaskServer.ml index 28a7d0a7..67d5bb07 100644 --- a/ocaml/TaskServer.ml +++ b/ocaml/TaskServer.ml @@ -36,7 +36,7 @@ let bind_socket ~socket_type ~socket ~address = | 0 -> failwith @@ Printf.sprintf "Unable to bind the %s socket : %s " socket_type address - | -1 -> (); + | -1 -> () | i -> try ZMQ.Socket.bind socket address; diff --git a/ocaml/qp_print_basis.ml b/ocaml/qp_print_basis.ml index 16a2f721..aff52837 100644 --- a/ocaml/qp_print_basis.ml +++ b/ocaml/qp_print_basis.ml @@ -43,9 +43,7 @@ let psi_det () = failwith "Error reading EZFIO file"; Ezfio.set_file ezfio_filename; let psi_det = - match Input.Determinants_by_hand.read () with - | Some psi_det -> psi_det - | _ -> failwith "Error reading the mo set" + Input.Determinants_by_hand.read () in Input.Determinants_by_hand.to_rst psi_det |> Rst_string.to_string @@ -56,5 +54,5 @@ let psi_det () = let () = basis (); mo (); - psi_det (); + psi_det () diff --git a/ocaml/test_message.ml b/ocaml/test_message.ml index 90b73d5e..2f5592ec 100644 --- a/ocaml/test_message.ml +++ b/ocaml/test_message.ml @@ -1,7 +1,7 @@ open Core.Std let () = - Message.of_string "new_job tcp://127.0.0.1 inproc://ao_ints:12345 ao_integrals" + Message.of_string "new_job ao_integrals tcp://127.0.0.1 inproc://ao_ints:12345" |> Message.to_string |> print_endline ; @@ -37,7 +37,7 @@ let () = ; try - Message.of_string "new_job inproc://ao_ints tcp://127.0.0.1:12345 ao_integrals" + Message.of_string "new_job ao_integrals inproc://ao_ints tcp://127.0.0.1:12345" |> Message.to_string |> print_endline ; diff --git a/plugins/qmcpack/save_for_qmcpack.irp.f b/plugins/qmcpack/save_for_qmcpack.irp.f index 95e3320c..186ca616 100644 --- a/plugins/qmcpack/save_for_qmcpack.irp.f +++ b/plugins/qmcpack/save_for_qmcpack.irp.f @@ -14,6 +14,12 @@ program qmcpack enddo enddo call ezfio_set_ao_basis_ao_coef(ao_coef) + do j=1,mo_tot_num + do i=1,ao_num + mo_coef(i,j) *= 1.d0/ao_coef_normalization_factor(i) + enddo + enddo + call save_mos call system('rm '//trim(ezfio_filename)//'/mo_basis/ao_md5') call system('$QP_ROOT/src/qmcpack/qp_convert_qmcpack_to_ezfio.py '//trim(ezfio_filename)) diff --git a/scripts/ezfio_interface/qp_edit_template b/scripts/ezfio_interface/qp_edit_template index 218b21ae..408ca3f7 100644 --- a/scripts/ezfio_interface/qp_edit_template +++ b/scripts/ezfio_interface/qp_edit_template @@ -75,7 +75,7 @@ let get s = | Ao_basis -> f Ao_basis.(read, to_rst) | Determinants_by_hand -> - f Determinants_by_hand.(read, to_rst) + f Determinants_by_hand.(read_maybe, to_rst) {section_to_rst} end with diff --git a/src/AO_Basis/aos.irp.f b/src/AO_Basis/aos.irp.f index 8c2db90e..aa805093 100644 --- a/src/AO_Basis/aos.irp.f +++ b/src/AO_Basis/aos.irp.f @@ -50,9 +50,6 @@ END_PROVIDER enddo enddo ao_coef_normalization_factor(i) = 1.d0/sqrt(norm) - do j=1,ao_prim_num(i) - ao_coef_normalized(i,j) = ao_coef_normalized(i,j) * ao_coef_normalization_factor(i) - enddo enddo END_PROVIDER