From b6b9a85cb2c7ab2a8f5951ee8b00a0125cec08bd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 3 May 2016 09:01:05 +0200 Subject: [PATCH] Added E_trial --- ezfio_config/qmc.config | 1 + ocaml/Input.ml | 57 ++++++++++++++++++++++++++ ocaml/Qmcchem_edit.ml | 38 ++++++++++------- src/PROPERTIES/properties_energy.irp.f | 2 +- src/SAMPLING/pdmc_step.irp.f | 2 +- src/ezfio_interface.irp.f | 1 + src/simulation.irp.f | 8 ++++ 7 files changed, 92 insertions(+), 17 deletions(-) diff --git a/ezfio_config/qmc.config b/ezfio_config/qmc.config index 29aaac9..3789a8b 100644 --- a/ezfio_config/qmc.config +++ b/ezfio_config/qmc.config @@ -64,6 +64,7 @@ simulation ci_threshold double precision md5_key character*(32) E_ref double precision + E_trial double precision srmc_projection_time real jastrow diff --git a/ocaml/Input.ml b/ocaml/Input.ml index 894754b..6a1ff43 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -490,6 +490,63 @@ end +module Trial_wf_energy : sig + + type t = float + val doc : string + val read : unit -> t + val write : t -> unit + val to_float : t -> float + val of_float : float -> t + val to_string : t -> string + val of_string : string -> t + +end = struct + + type t = float + let doc = "Energy of the trial wave function (au)" + + let of_float x = + if (x > 0.) then + failwith "Reference energy should not be positive."; + if (x <= -1_000_000.) then + failwith "Reference energy is too low."; + x + + + let to_float x = x + + let read () = + let _ = + Lazy.force Qputils.ezfio_filename + in + if (not (Ezfio.has_simulation_e_trial ())) then + to_float 0. + |> Ezfio.set_simulation_e_trial; + Ezfio.get_simulation_e_trial () + |> of_float + + + let write t = + let _ = + Lazy.force Qputils.ezfio_filename + in + to_float t + |> Ezfio.set_simulation_e_trial + + + let of_string x = + Float.of_string x + |> of_float + + + let to_string x = + to_float x + |> Float.to_string + + +end + module Ref_energy : sig type t = float diff --git a/ocaml/Qmcchem_edit.ml b/ocaml/Qmcchem_edit.ml index 2f6a6e7..bcad9c7 100644 --- a/ocaml/Qmcchem_edit.ml +++ b/ocaml/Qmcchem_edit.ml @@ -24,6 +24,7 @@ type field = | Method | Sampling | Ref_energy + | Trial_wf_energy | CI_threshold | Time_step | SRMC_projection_time @@ -62,6 +63,8 @@ let get field = option_to_string Sampling.read Sampling.to_string Sampling.doc | Ref_energy -> option_to_string Ref_energy.read Ref_energy.to_string Ref_energy.doc + | Trial_wf_energy -> + option_to_string Trial_wf_energy.read Trial_wf_energy.to_string Trial_wf_energy.doc | CI_threshold -> option_to_string CI_threshold.read CI_threshold.to_string CI_threshold.doc | Time_step -> @@ -105,7 +108,7 @@ let write_input_in_ezfio ezfio_filename fields = (** Run the edit command *) -let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename = +let run ~c ?f ?t ?l ?m ?e ?et ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename = let interactive = ref ( if c then @@ -130,18 +133,19 @@ let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename = in (); in - handle_option Input.Ref_energy.(of_float , write) e; - handle_option Input.Jastrow_type.(of_string, write) j; - handle_option Input.Block_time.(of_int , write) l; - handle_option Input.Method.(of_string, write) m; - handle_option Input.Stop_time.(of_int , write) t; - handle_option Input.Sampling.(of_string, write) s; - handle_option Input.Fitcusp_factor.(of_float , write) f; - handle_option Input.Time_step.(of_float , write) ts; - handle_option Input.Walk_num.(of_int , write) w; - handle_option Input.Walk_num_tot.(of_int , write) wt; - handle_option Input.CI_threshold.(of_float , write) n; - handle_option Input.SRMC_projection_time.(of_float , write) p; + handle_option Input.Ref_energy.(of_float , write) e; + handle_option Input.Trial_wf_energy.(of_float , write) et; + handle_option Input.Jastrow_type.(of_string, write) j; + handle_option Input.Block_time.(of_int , write) l; + handle_option Input.Method.(of_string, write) m; + handle_option Input.Stop_time.(of_int , write) t; + handle_option Input.Sampling.(of_string, write) s; + handle_option Input.Fitcusp_factor.(of_float , write) f; + handle_option Input.Time_step.(of_float , write) ts; + handle_option Input.Walk_num.(of_int , write) w; + handle_option Input.Walk_num_tot.(of_int , write) wt; + handle_option Input.CI_threshold.(of_float , write) n; + handle_option Input.SRMC_projection_time.(of_float , write) p; let fields = @@ -153,6 +157,7 @@ let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename = Time_step ; SRMC_projection_time ; Ref_energy ; + Trial_wf_energy ; Walk_num ; Walk_num_tot ; Fitcusp_factor ; @@ -225,6 +230,7 @@ let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename = | Walk_num_tot -> Walk_num_tot.(of_string s |> write) | CI_threshold -> CI_threshold.(of_string s |> write) | Jastrow_type -> Jastrow_type.(of_string s |> write) + | Trial_wf_energy -> Trial_wf_energy.(of_string s |> write) | Properties -> Properties.(of_string s |> write) end with @@ -281,6 +287,8 @@ let spec = ~doc:("method "^Input.Method.doc) +> flag "e" (optional float) ~doc:("energy "^Input.Ref_energy.doc) + +> flag "et" (optional float) + ~doc:("energy "^Input.Trial_wf_energy.doc) +> flag "s" (optional string) ~doc:("sampling "^Input.Sampling.doc) +> flag "ts" (optional float) @@ -307,8 +315,8 @@ let command = Edit input data ") spec - (fun c f t l m e s ts w wt n j p ezfio_file input () -> - run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_file ) + (fun c f t l m e et s ts w wt n j p ezfio_file input () -> + run ~c ?f ?t ?l ?m ?e ?et ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_file ) diff --git a/src/PROPERTIES/properties_energy.irp.f b/src/PROPERTIES/properties_energy.irp.f index 1924d49..4dd387f 100644 --- a/src/PROPERTIES/properties_energy.irp.f +++ b/src/PROPERTIES/properties_energy.irp.f @@ -253,7 +253,7 @@ BEGIN_PROVIDER [ double precision, E_loc_zv ] BEGIN_DOC ! Zero-variance parameter on E_loc END_DOC - E_loc_zv = E_loc + E_loc_zv = E_trial END_PROVIDER diff --git a/src/SAMPLING/pdmc_step.irp.f b/src/SAMPLING/pdmc_step.irp.f index 9b3758b..592c1a9 100644 --- a/src/SAMPLING/pdmc_step.irp.f +++ b/src/SAMPLING/pdmc_step.irp.f @@ -174,7 +174,7 @@ END_SHELL if (calc_E_loc_zv) then if (dabs(pdmc_weight(i_walk)*pop_weight_mult) > 1.d-6) then - E_loc_zv = E_loc + (E_ref-E_loc)/(pdmc_weight(i_walk)*pop_weight_mult) + E_loc_zv = E_loc + (E_trial-E_loc)/(pdmc_weight(i_walk)*pop_weight_mult) else E_loc_zv = 0.d0 endif diff --git a/src/ezfio_interface.irp.f b/src/ezfio_interface.irp.f index 08c9cfe..0bb76be 100644 --- a/src/ezfio_interface.irp.f +++ b/src/ezfio_interface.irp.f @@ -45,6 +45,7 @@ data = [ \ ("simulation_http_server" , "character*(128)", "" ), ("simulation_md5_key" , "character*(32)" , "" ), ("simulation_e_ref" , "double precision" , "" ), +("simulation_e_trial" , "double precision" , "" ), ("simulation_do_run" , "logical " , "" ), ("pseudo_do_pseudo" , "logical " , "" ), diff --git a/src/simulation.irp.f b/src/simulation.irp.f index ceb66d9..d3ba571 100644 --- a/src/simulation.irp.f +++ b/src/simulation.irp.f @@ -365,3 +365,11 @@ BEGIN_PROVIDER [ character*(32), md5_key ] endif END_PROVIDER +BEGIN_PROVIDER [ double precision, E_trial ] + implicit none + BEGIN_DOC + ! Energy of the trial wave function + END_DOC + call get_simulation_e_trial(E_trial) +END_PROVIDER +