diff --git a/ezfio_config/qmc.config b/ezfio_config/qmc.config index 05a7e4b..f67170b 100644 --- a/ezfio_config/qmc.config +++ b/ezfio_config/qmc.config @@ -31,9 +31,9 @@ electrons nuclei nucl_num integer nucl_label character*(32) (nuclei_nucl_num) - nucl_charge real (nuclei_nucl_num) - nucl_coord real (nuclei_nucl_num,3) - nucl_fitcusp_radius real (nuclei_nucl_num) + nucl_charge real (nuclei_nucl_num) + nucl_coord real (nuclei_nucl_num,3) + nucl_fitcusp_radius real (nuclei_nucl_num) spindeterminants n_det_alpha integer @@ -50,23 +50,22 @@ spindeterminants simulation - do_run integer - stop_time integer - equilibration logical - title character*(128) - http_server character*(128) - do_jast logical - do_nucl_fitcusp logical - method character*(32) - block_time integer - sampling character*(32) - save_data logical - time_step real - print_level integer - ci_threshold double precision - md5_key character*(32) - orig_time double precision - E_ref double precision + do_run integer + stop_time integer + equilibration logical + http_server character*(128) + do_jast logical + do_nucl_fitcusp logical + method character*(32) + block_time integer + sampling character*(32) + save_data logical + time_step real + print_level integer + ci_threshold double precision + md5_key character*(32) + E_ref double precision + dmc_projection_time real jastrow jast_type character*(32) diff --git a/ocaml/Default.ml b/ocaml/Default.ml index 7046276..15743ca 100644 --- a/ocaml/Default.ml +++ b/ocaml/Default.ml @@ -1,26 +1,23 @@ open Core.Std;; -let simulation_do_nucl_fitcusp = - if (not (Ezfio.has_simulation_do_nucl_fitcusp ())) then - begin - if (not (Ezfio.has_pseudo_do_pseudo ())) then - true - else - not (Ezfio.get_pseudo_do_pseudo ()) - end + +let simulation_do_nucl_fitcusp = lazy( + if (not (Ezfio.has_pseudo_do_pseudo ())) then + not (Ezfio.get_pseudo_do_pseudo ()) else - Ezfio.get_simulation_do_nucl_fitcusp () + true +) - -let electrons_elec_walk_num = 30 -let electrons_elec_walk_num_tot = 10000 -let jastrow_jast_type = "None" -let simulation_block_time = 30 -let simulation_ci_threshold = 1.e-8 -let simulation_method = "VMC" -let simulation_sampling = "Langevin" -let simulation_stop_time = 3600 -let simulation_time_step = 0.15 +let electrons_elec_walk_num = lazy ( 30 ) +let electrons_elec_walk_num_tot = lazy ( 10000 ) +let jastrow_jast_type = lazy ( "None" ) +let simulation_block_time = lazy ( 30 ) +let simulation_ci_threshold = lazy ( 1.e-8 ) +let simulation_method = lazy ( "VMC" ) +let simulation_sampling = lazy ( "Langevin" ) +let simulation_stop_time = lazy ( 3600 ) +let simulation_time_step = lazy ( 0.15 ) +let simulation_dmc_projection_time = lazy ( 1. ) let reset_defaults () = List.iter ~f:(fun x -> Sys.remove ( (Lazy.force Qputils.ezfio_filename) ^ x)) diff --git a/ocaml/Input.ml b/ocaml/Input.ml index 2c2fe33..652659d 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -20,7 +20,7 @@ end = struct type t = bool - let doc = "Correct wave function to verify electron-nucleus cusp condition" + let doc = "Compute pseudo-potentials" let of_bool x = x @@ -94,7 +94,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_do_nucl_fitcusp ())) then - Ezfio.set_simulation_do_nucl_fitcusp Default.simulation_do_nucl_fitcusp; + Lazy.force Default.simulation_do_nucl_fitcusp + |> Ezfio.set_simulation_do_nucl_fitcusp ; Ezfio.get_simulation_do_nucl_fitcusp () |> of_bool @@ -159,7 +160,7 @@ end = struct type t = int - let doc = "Length (seconds) of a block" + let doc = "Time (seconds) of a block" let of_int x = if (x < 1) then @@ -176,7 +177,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_block_time ())) then - Ezfio.set_simulation_block_time Default.simulation_block_time; + Lazy.force Default.simulation_block_time + |> Ezfio.set_simulation_block_time ; Ezfio.get_simulation_block_time () |> of_int @@ -242,7 +244,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_electrons_elec_walk_num () )) then - Ezfio.set_electrons_elec_walk_num Default.electrons_elec_walk_num; + Lazy.force Default.electrons_elec_walk_num + |> Ezfio.set_electrons_elec_walk_num ; Ezfio.get_electrons_elec_walk_num () |> of_int @@ -298,7 +301,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_electrons_elec_walk_num_tot () )) then - Ezfio.set_electrons_elec_walk_num_tot Default.electrons_elec_walk_num_tot; + Lazy.force Default.electrons_elec_walk_num_tot + |> Ezfio.set_electrons_elec_walk_num_tot ; Ezfio.get_electrons_elec_walk_num_tot () |> of_int @@ -356,7 +360,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_stop_time ())) then - Ezfio.set_simulation_stop_time Default.simulation_stop_time; + Lazy.force Default.simulation_stop_time + |> Ezfio.set_simulation_stop_time ; Ezfio.get_simulation_stop_time () |> of_int @@ -423,7 +428,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_method ())) then - Ezfio.set_simulation_method Default.simulation_method; + Lazy.force Default.simulation_method + |> Ezfio.set_simulation_method ; Ezfio.get_simulation_method () |> of_string @@ -472,7 +478,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_sampling ())) then - Ezfio.set_simulation_sampling Default.simulation_sampling; + Lazy.force Default.simulation_sampling + |> Ezfio.set_simulation_sampling ; Ezfio.get_simulation_sampling () |> of_string @@ -503,7 +510,7 @@ module Ref_energy : sig end = struct type t = float - let doc = "Fixed reference energy to normalize DMC weights" + let doc = "Fixed reference energy to normalize DMC weights (au)" let of_float x = if (x > 0.) then @@ -562,7 +569,7 @@ end = struct type t = float let doc = "Truncation t of the wave function : Remove determinants with a -contribution to the norm less than t" +contribution to the norm less than t (au)" let of_float x = if (x >= 1.) then @@ -579,7 +586,8 @@ contribution to the norm less than t" Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_ci_threshold ())) then - Ezfio.set_simulation_ci_threshold Default.simulation_ci_threshold ; + Lazy.force Default.simulation_ci_threshold + |> Ezfio.set_simulation_ci_threshold ; Ezfio.get_simulation_ci_threshold () |> of_float @@ -603,6 +611,62 @@ contribution to the norm less than t" end +module DMC_projection_time : 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 = "DMC projection time (au)" + + let of_float x = + if (x >= 100.) then + failwith "DMC Projection time should be < 100."; + if (x <= 0.) then + failwith "DMC Projection time should be positive."; + x + + + let to_float x = x + + let read () = + let _ = + Lazy.force Qputils.ezfio_filename + in + if (not (Ezfio.has_simulation_dmc_projection_time())) then + Lazy.force Default.simulation_dmc_projection_time + |> Ezfio.set_simulation_dmc_projection_time ; + Ezfio.get_simulation_dmc_projection_time () + |> of_float + + + let write t = + let _ = + Lazy.force Qputils.ezfio_filename + in + to_float t + |> Ezfio.set_simulation_dmc_projection_time + + + let of_string x = + Float.of_string x + |> of_float + + + let to_string x = + to_float x + |> Float.to_string + +end + module Time_step : sig type t = float @@ -617,7 +681,7 @@ module Time_step : sig end = struct type t = float - let doc = "Simulation time step" + let doc = "Simulation time step (au)" let of_float x = if (x >= 10.) then @@ -634,7 +698,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_simulation_time_step ())) then - Ezfio.set_simulation_time_step Default.simulation_time_step; + Lazy.force Default.simulation_time_step + |> Ezfio.set_simulation_time_step ; Ezfio.get_simulation_time_step () |> of_float @@ -691,7 +756,8 @@ end = struct Lazy.force Qputils.ezfio_filename in if (not (Ezfio.has_jastrow_jast_type ())) then - Ezfio.set_jastrow_jast_type Default.jastrow_jast_type; + Lazy.force Default.jastrow_jast_type + |> Ezfio.set_jastrow_jast_type ; Ezfio.get_jastrow_jast_type (); |> of_string @@ -704,7 +770,7 @@ end = struct match (Pseudo.read () |> Pseudo.to_bool, t) with | (false, _) | (true , None) -> () - | _ -> failwith "Jastrow and Pseudopotentials are incompatible" + | _ -> failwith "Jastrow and Pseudopotentials are incompatible for now" in to_string t diff --git a/ocaml/Md5.ml b/ocaml/Md5.ml index 54afbca..0cfe106 100644 --- a/ocaml/Md5.ml +++ b/ocaml/Md5.ml @@ -31,6 +31,7 @@ let files_to_track = [ "ao_basis/ao_prim_num.gz" ; "electrons/elec_alpha_num" ; "electrons/elec_beta_num" ; + "electrons/elec_walk_num" ; "jastrow/jast_type" ; "mo_basis/mo_coef.gz" ; "mo_basis/mo_tot_num" ; @@ -54,6 +55,7 @@ let files_to_track = [ "simulation/jast_pen.gz" ; "simulation/method" ; "simulation/time_step" ; + "simulation/dmc_projection_time" ; "spindeterminants/bit_kind" ; "spindeterminants/n_det" ; "spindeterminants/n_det_alpha" ; diff --git a/ocaml/Qmcchem_edit.ml b/ocaml/Qmcchem_edit.ml index 02c618b..cc2b558 100644 --- a/ocaml/Qmcchem_edit.ml +++ b/ocaml/Qmcchem_edit.ml @@ -26,6 +26,7 @@ type field = | Ref_energy | CI_threshold | Time_step + | DMC_projection_time | Jastrow_type | Properties @@ -65,6 +66,8 @@ let get field = option_to_string CI_threshold.read CI_threshold.to_string CI_threshold.doc | Time_step -> option_to_string Time_step.read Time_step.to_string Time_step.doc + | DMC_projection_time -> + option_to_string DMC_projection_time.read DMC_projection_time.to_string DMC_projection_time.doc | Jastrow_type -> option_to_string Jastrow_type.read Jastrow_type.to_string Jastrow_type.doc | Properties -> @@ -102,7 +105,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 ?input ezfio_filename = +let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename = let interactive = ref ( if c then @@ -141,22 +144,24 @@ let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?input ezfio_filename = 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.DMC_projection_time.(of_float , write) p; let fields = [ - Stop_time ; - Block_time ; - Method ; - Ref_energy ; - Sampling ; - Time_step ; - Walk_num ; - Walk_num_tot ; - Fitcusp ; - CI_threshold ; - Jastrow_type ; - Properties ; + Stop_time ; + Block_time ; + Method ; + Sampling ; + Time_step ; + DMC_projection_time ; + Ref_energy ; + Walk_num ; + Walk_num_tot ; + Fitcusp ; + CI_threshold ; + Jastrow_type ; + Properties ; ] in @@ -211,18 +216,19 @@ let run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?input ezfio_filename = try begin match f with - | Stop_time -> Stop_time.(of_string s |> write) - | Fitcusp -> Fitcusp.(of_string s |> write) - | Block_time -> Block_time.(of_string s |> write) - | Method -> Method.(of_string s |> write) - | Ref_energy -> Ref_energy.(of_string s |> write) - | Sampling -> Sampling.(of_string s |> write) - | Time_step -> Time_step.(of_string s |> write) - | Walk_num -> Walk_num.(of_string s |> write) - | 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) - | Properties -> Properties.(of_string s |> write) + | Stop_time -> Stop_time.(of_string s |> write) + | Fitcusp -> Fitcusp.(of_string s |> write) + | Block_time -> Block_time.(of_string s |> write) + | Method -> Method.(of_string s |> write) + | Ref_energy -> Ref_energy.(of_string s |> write) + | Sampling -> Sampling.(of_string s |> write) + | Time_step -> Time_step.(of_string s |> write) + | DMC_projection_time -> DMC_projection_time.(of_string s |> write) + | Walk_num -> Walk_num.(of_string s |> write) + | 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) + | Properties -> Properties.(of_string s |> write) end with | Failure msg -> Printf.eprintf "%s\n" msg @@ -290,6 +296,8 @@ let spec = ~doc:("norm "^Input.CI_threshold.doc) +> flag "j" (optional string) ~doc:("jastrow_type "^Input.Jastrow_type.doc) + +> flag "p" (optional float) + ~doc:("projection_time "^Input.DMC_projection_time.doc) +> anon ("ezfio_file" %: string) +> anon (maybe ("input" %: string)) ;; @@ -302,8 +310,8 @@ let command = Edit input data ") spec - (fun c f t l m e s ts w wt n j ezfio_file input () -> - run ~c ?f ?t ?l ?m ?e ?s ?ts ?w ?wt ?n ?j ?input ezfio_file ) + (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 ) diff --git a/src/PROPERTIES/properties_general.irp.f b/src/PROPERTIES/properties_general.irp.f index b6c0ae9..9b4a32b 100644 --- a/src/PROPERTIES/properties_general.irp.f +++ b/src/PROPERTIES/properties_general.irp.f @@ -47,6 +47,18 @@ BEGIN_PROVIDER [ double precision, wf_extension ] SOFT_TOUCH wf_extension_min wf_extension_max END_PROVIDER +BEGIN_PROVIDER [ double precision, dmc_pop_weight ] + implicit none + BEGIN_DOC + ! Weight of the DMC population + END_DOC + dmc_pop_weight = pop_weight_mult + dmc_pop_weight_min = min(dmc_pop_weight,dmc_pop_weight_min) + dmc_pop_weight_max = max(dmc_pop_weight,dmc_pop_weight_max) + SOFT_TOUCH dmc_pop_weight_min dmc_pop_weight_max + +END_PROVIDER + BEGIN_PROVIDER [ double precision, drift_mod, (size_drift_mod) ] implicit none diff --git a/src/SAMPLING/dmc_step.irp.f b/src/SAMPLING/dmc_step.irp.f index 5800468..706e3e0 100644 --- a/src/SAMPLING/dmc_step.irp.f +++ b/src/SAMPLING/dmc_step.irp.f @@ -110,6 +110,7 @@ END_SHELL ! Update the running population weight pop_weight_mult *= pop_weight(dmc_projection_step) + SOFT_TOUCH pop_weight_mult BEGIN_SHELL [ /usr/bin/python ] from properties import * @@ -264,7 +265,10 @@ END_PROVIDER BEGIN_DOC ! Number of projection steps for SRMC END_DOC - dmc_projection = int( 10.d0/time_step) + real :: dmc_projection_time + dmc_projection_time = 1. + call get_simulation_dmc_projection_time(dmc_projection_time) + dmc_projection = int( dmc_projection_time/time_step) dmc_projection_step = 0 END_PROVIDER diff --git a/src/ezfio_interface.irp.f b/src/ezfio_interface.irp.f index c225411..b644880 100644 --- a/src/ezfio_interface.irp.f +++ b/src/ezfio_interface.irp.f @@ -36,6 +36,7 @@ data = [ \ ("simulation_equilibration" , "logical" , "" ), ("simulation_block_time" , "integer" , "" ), ("simulation_time_step" , "real" , "" ), +("simulation_dmc_projection_time" , "real" , "" ), ("simulation_method" , "character*(32)", "" ), ("simulation_save_data" , "logical" , "" ), ("simulation_print_level" , "integer" , "" ),