10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-22 12:23:30 +01:00

Better prepare_walkers

This commit is contained in:
Anthony Scemama 2016-03-29 15:16:16 +02:00
parent 22cadde5a1
commit 6f3ac7fa29
2 changed files with 29 additions and 21 deletions

View File

@ -30,6 +30,19 @@ let run ?(daemon=true) ezfio_filename =
Qputils.set_ezfio_filename ezfio_filename; Qputils.set_ezfio_filename ezfio_filename;
(** Check if walkers need to be created. *)
let () =
if ( not(Ezfio.has_electrons_elec_coord_pool ()) ) then
begin
Printf.printf "Generating initial walkers...\n%!";
Unix.fork_exec ~prog:(Lazy.force Qmcchem_config.qmc_create_walkers)
~args:["qmc_create_walkers" ; ezfio_filename] ()
|> Unix.waitpid_exn ;
Printf.printf "Initial walkers ready\n%!"
end ;
in
(** Measures the time difference between [t0] and [Time.now ()] *) (** Measures the time difference between [t0] and [Time.now ()] *)
let delta_t t0 = let delta_t t0 =
let t1 = let t1 =
@ -38,7 +51,6 @@ let run ?(daemon=true) ezfio_filename =
Time.abs_diff t1 t0 Time.abs_diff t1 t0
in in
(** {2 ZeroMQ initialization} *) (** {2 ZeroMQ initialization} *)
let zmq_context = let zmq_context =
@ -174,15 +186,6 @@ let run ?(daemon=true) ezfio_filename =
3*elec_num + 3 3*elec_num + 3
in in
let result = let result =
if ( not(Ezfio.has_electrons_elec_coord_pool ()) ) then
begin
Printf.printf "Generating initial walkers...\n%!";
Unix.fork_exec ~prog:(Lazy.force Qmcchem_config.qmc_create_walkers)
~args:["qmc_create_walkers" ; ezfio_filename] ()
|> Unix.waitpid_exn ;
Printf.printf "Initial walkers ready\n%!"
end ;
let size = let size =
Ezfio.get_electrons_elec_coord_pool_size () Ezfio.get_electrons_elec_coord_pool_size ()
and ez = and ez =

View File

@ -61,10 +61,14 @@ subroutine draw_init_points
call rinfo( irp_here, 'time step =', time_step ) call rinfo( irp_here, 'time step =', time_step )
do iwalk=1,walk_num do iwalk=1,walk_num
call iinfo( irp_here, 'Generate initial positions for walker', iwalk ) print *, 'Generating initial positions for walker', iwalk
acc_num = 0 acc_num = 0
do_elec = .True. do_elec = .True.
do while (acc_num < elec_num) integer :: iter
do iter = 1,10000
if (acc_num >= elec_num) then
exit
endif
double precision :: gauss double precision :: gauss
real :: re_compute real :: re_compute
re_compute = 0. re_compute = 0.
@ -72,7 +76,7 @@ subroutine draw_init_points
do i=1,elec_num do i=1,elec_num
if (do_elec(i)) then if (do_elec(i)) then
do l=1,3 do l=1,3
elec_coord(i,l) = xmin(l,i) + 2.*(0.5-qmc_ranf()) elec_coord(i,l) = xmin(l,i) + 1.5*(0.5-qmc_ranf())
enddo enddo
endif endif
enddo enddo
@ -98,7 +102,6 @@ subroutine draw_init_points
endif endif
enddo enddo
enddo enddo
do l=1,3 do l=1,3
@ -159,17 +162,17 @@ subroutine run_prepare_walkers
enddo enddo
enddo enddo
TOUCH mo_coef_transp TOUCH mo_coef_transp
call iinfo (irp_here, 'Starting walker ', iwalk ) print *, 'Starting walker ', iwalk
do istep=1,1000 do istep=1,1000
if (single_det_value == 0.d0) then if (psidet_value == 0.d0) then
exit exit
endif endif
prepare_walkers_t = float(istep)/1000. prepare_walkers_t = float(istep)/1000.
TOUCH prepare_walkers_t TOUCH prepare_walkers_t
rcond = log(abs(dble(single_det_value))) rcond = log(abs(dble(psidet_value)))
real :: factor real :: factor
rcond = log(abs(dble(single_det_value))) rcond = log(abs(dble(psidet_value)))
integer :: icount integer :: icount
icount = 0 icount = 0
do while ( (rcond > 10.d0) .or. (rcond < -10.d0) ) do while ( (rcond > 10.d0) .or. (rcond < -10.d0) )
@ -190,18 +193,21 @@ subroutine run_prepare_walkers
enddo enddo
TOUCH mo_coef_transp TOUCH mo_coef_transp
rcond = log(abs(dble(single_det_value))) rcond = log(abs(dble(psidet_value)))
enddo enddo
double precision :: p,q double precision :: p,q
logical :: accepted logical :: accepted
real :: delta_x real :: delta_x
accepted = .False. accepted = .False.
do while (.not.accepted) do icount=1,100
if (vmc_algo == t_Brownian) then if (vmc_algo == t_Brownian) then
call brownian_step(p,q,accepted,delta_x) call brownian_step(p,q,accepted,delta_x)
else if (vmc_algo == t_Langevin) then else if (vmc_algo == t_Langevin) then
call langevin_step(p,q,accepted,delta_x) call langevin_step(p,q,accepted,delta_x)
endif endif
if (accepted) then
exit
endif
enddo enddo
enddo enddo
do l=1,3 do l=1,3
@ -209,7 +215,6 @@ subroutine run_prepare_walkers
elec_coord_full(i,l,iwalk) = elec_coord(i,l) elec_coord_full(i,l,iwalk) = elec_coord(i,l)
enddo enddo
enddo enddo
call iinfo(irp_here, 'Walker done', iwalk)
TOUCH elec_coord_full TOUCH elec_coord_full
enddo enddo