10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-07-03 01:45:59 +02:00

Added -state option to qp_edit

This commit is contained in:
Anthony Scemama 2017-04-12 14:46:12 +02:00
parent 51cff0d890
commit 06efe7ca16
3 changed files with 54 additions and 12 deletions

View File

@ -20,6 +20,7 @@ module Determinants_by_hand : sig
val of_rst : Rst_string.t -> t option val of_rst : Rst_string.t -> t option
val read_n_int : unit -> N_int_number.t val read_n_int : unit -> N_int_number.t
val update_ndet : Det_number.t -> unit val update_ndet : Det_number.t -> unit
val extract_state : States_number.t -> unit
end = struct end = struct
type t = type t =
{ n_int : N_int_number.t; { n_int : N_int_number.t;
@ -132,12 +133,12 @@ end = struct
|> Array.map ~f:Det_coef.of_float |> Array.map ~f:Det_coef.of_float
;; ;;
let write_psi_coef ~n_det c = let write_psi_coef ~n_det ~n_states c =
let n_det = Det_number.to_int n_det let n_det = Det_number.to_int n_det
and c = Array.to_list c and c = Array.to_list c
|> List.map ~f:Det_coef.to_float |> List.map ~f:Det_coef.to_float
and n_states = and n_states =
read_n_states () |> States_number.to_int States_number.to_int n_states
in in
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|> Ezfio.set_determinants_psi_coef |> Ezfio.set_determinants_psi_coef
@ -233,7 +234,7 @@ end = struct
write_n_det n_det; write_n_det n_det;
write_n_states n_states; write_n_states n_states;
write_expected_s2 expected_s2; write_expected_s2 expected_s2;
write_psi_coef ~n_det:n_det psi_coef ; write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ;
write_psi_det ~n_int:n_int ~n_det:n_det psi_det; write_psi_det ~n_int:n_int ~n_det:n_det psi_det;
;; ;;
@ -455,6 +456,7 @@ psi_det = %s
;; ;;
let update_ndet n_det_new = let update_ndet n_det_new =
Printf.printf "Reducing n_det to %d\n" (Det_number.to_int n_det_new);
let n_det_new = let n_det_new =
Det_number.to_int n_det_new Det_number.to_int n_det_new
in in
@ -487,6 +489,36 @@ psi_det = %s
write new_det write new_det
;; ;;
let extract_state istate =
Printf.printf "Extracting state %d\n" (States_number.to_int istate);
let det =
read ()
in
let n_det, n_states =
Det_number.to_int det.n_det,
States_number.to_int det.n_states
in
if (States_number.to_int istate) > n_states then
failwith "State to extract should not be greater than n_states"
;
let j =
(States_number.to_int istate) - 1
in
begin
if (j>0) then
let ishift =
j*n_det
in
for i=0 to (n_det-1) do
det.psi_coef.(i) <- det.psi_coef.(i+ishift)
done
end;
let new_det =
{ det with n_states = (States_number.of_int 1) }
in
write new_det
;;
end end

View File

@ -32,7 +32,7 @@ subroutine ZMQ_pt2(pt2,relative_error)
sum2above = 0d0 sum2above = 0d0
Nabove = 0d0 Nabove = 0d0
provide nproc fragment_first fragment_count mo_bielec_integrals_in_map mo_mono_elec_integral provide nproc fragment_first fragment_count mo_bielec_integrals_in_map mo_mono_elec_integral pt2_weight
!call random_seed() !call random_seed()
@ -515,8 +515,10 @@ end subroutine
pt2_cweight(i) = pt2_cweight(i-1) + psi_coef_generators(i,1)**2 pt2_cweight(i) = pt2_cweight(i-1) + psi_coef_generators(i,1)**2
end do end do
pt2_weight = pt2_weight / pt2_cweight(N_det_generators) do i=1,N_det_generators
pt2_cweight = pt2_cweight / pt2_cweight(N_det_generators) pt2_weight(i) = pt2_weight(i) / pt2_cweight(N_det_generators)
pt2_cweight(i) = pt2_cweight(i) / pt2_cweight(N_det_generators)
enddo
norm_left = 1d0 norm_left = 1d0

View File

@ -144,13 +144,13 @@ let create_temp_file ezfio_filename fields =
let run check_only ?ndet ezfio_filename = let run check_only ?ndet ?state ezfio_filename =
(* Set check_only if the arguments are not empty *) (* Set check_only if the arguments are not empty *)
let check_only = let check_only =
match ndet with match ndet, state with
| None -> check_only | None, None -> check_only
| Some _ -> true | _ -> true
in in
(* Open EZFIO *) (* Open EZFIO *)
@ -165,6 +165,12 @@ let run check_only ?ndet ezfio_filename =
| Some n -> Input.Determinants_by_hand.update_ndet (Det_number.of_int n) | Some n -> Input.Determinants_by_hand.update_ndet (Det_number.of_int n)
end; end;
begin
match state with
| None -> ()
| Some n -> Input.Determinants_by_hand.extract_state (States_number.of_int n)
end;
(* (*
let output = (file_header ezfio_filename) :: ( let output = (file_header ezfio_filename) :: (
@ -244,6 +250,8 @@ let spec =
~doc:"Checks the input data" ~doc:"Checks the input data"
+> flag "ndet" (optional int) +> flag "ndet" (optional int)
~doc:"int Truncate the wavefunction to the target number of determinants" ~doc:"int Truncate the wavefunction to the target number of determinants"
+> flag "state" (optional int)
~doc:"int Pick the state as a new wavefunction."
+> anon ("ezfio_file" %: string) +> anon ("ezfio_file" %: string)
@ -262,9 +270,9 @@ Edit input data
with with
| _ msg -> print_string ("\n\nError\n\n"^msg^"\n\n") | _ msg -> print_string ("\n\nError\n\n"^msg^"\n\n")
*) *)
(fun c ndet ezfio_file () -> (fun c ndet state ezfio_file () ->
try try
run c ?ndet ezfio_file ; run c ?ndet ?state ezfio_file ;
(* create_backup ezfio_file; *) (* create_backup ezfio_file; *)
with with
| Failure exc | Failure exc