mirror of
https://github.com/LCPQ/quantum_package
synced 2024-11-04 21:24:02 +01:00
Merge branch 'alpha_factory' of https://github.com/garniron/quantum_package into garniron-alpha_factory
This commit is contained in:
commit
9d84d403c9
@ -32,7 +32,7 @@ OPENMP : 1 ; Append OpenMP flags
|
|||||||
#
|
#
|
||||||
[OPT]
|
[OPT]
|
||||||
FC : -traceback
|
FC : -traceback
|
||||||
FCFLAGS : -xAVX -O2 -ip -ftz -g
|
FCFLAGS : -xSSE4.2 -O2 -ip -ftz -g
|
||||||
|
|
||||||
# Profiling flags
|
# Profiling flags
|
||||||
#################
|
#################
|
||||||
|
@ -27,6 +27,7 @@ subroutine run
|
|||||||
threshold_generators = 1d0
|
threshold_generators = 1d0
|
||||||
relative_error = 1.d-9
|
relative_error = 1.d-9
|
||||||
absolute_error = 1.d-9
|
absolute_error = 1.d-9
|
||||||
|
|
||||||
call ZMQ_pt2(E_CI_before, pt2, relative_error, absolute_error, eqt)
|
call ZMQ_pt2(E_CI_before, pt2, relative_error, absolute_error, eqt)
|
||||||
print *, 'Final step'
|
print *, 'Final step'
|
||||||
print *, 'N_det = ', N_det
|
print *, 'N_det = ', N_det
|
||||||
|
@ -269,7 +269,6 @@ subroutine pt2_collector(zmq_socket_pull, E, b, tbc, comb, Ncomb, computed, pt2_
|
|||||||
parts_to_get(index(i)) -= 1
|
parts_to_get(index(i)) -= 1
|
||||||
if(parts_to_get(index(i)) < 0) then
|
if(parts_to_get(index(i)) < 0) then
|
||||||
print *, i, index(i), parts_to_get(index(i))
|
print *, i, index(i), parts_to_get(index(i))
|
||||||
print *, "PARTS ??"
|
|
||||||
print *, parts_to_get
|
print *, parts_to_get
|
||||||
stop "PARTS ??"
|
stop "PARTS ??"
|
||||||
end if
|
end if
|
||||||
@ -295,6 +294,11 @@ subroutine pt2_collector(zmq_socket_pull, E, b, tbc, comb, Ncomb, computed, pt2_
|
|||||||
end do
|
end do
|
||||||
|
|
||||||
integer, external :: zmq_abort
|
integer, external :: zmq_abort
|
||||||
|
double precision :: E0, avg, prop
|
||||||
|
|
||||||
|
call do_carlo(tbc, Ncomb+1-firstTBDcomb, comb(firstTBDcomb), pt2_detail, actually_computed, sumabove, sum2above, Nabove)
|
||||||
|
firstTBDcomb = int(Nabove(1)) - orgTBDcomb + 1
|
||||||
|
call get_first_tooth(actually_computed, tooth)
|
||||||
|
|
||||||
if (firstTBDcomb > Ncomb) then
|
if (firstTBDcomb > Ncomb) then
|
||||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||||
@ -306,11 +310,7 @@ subroutine pt2_collector(zmq_socket_pull, E, b, tbc, comb, Ncomb, computed, pt2_
|
|||||||
exit pullLoop
|
exit pullLoop
|
||||||
endif
|
endif
|
||||||
|
|
||||||
double precision :: E0, avg, prop
|
!if(Nabove(1) < 5d0) cycle
|
||||||
call do_carlo(tbc, Ncomb+1-firstTBDcomb, comb(firstTBDcomb), pt2_detail, actually_computed, sumabove, sum2above, Nabove)
|
|
||||||
firstTBDcomb = int(Nabove(1)) - orgTBDcomb + 1
|
|
||||||
if(Nabove(1) < 5d0) cycle
|
|
||||||
call get_first_tooth(actually_computed, tooth)
|
|
||||||
|
|
||||||
E0 = sum(pt2_detail(pt2_stoch_istate,:first_det_of_teeth(tooth)-1))
|
E0 = sum(pt2_detail(pt2_stoch_istate,:first_det_of_teeth(tooth)-1))
|
||||||
if (tooth <= comb_teeth) then
|
if (tooth <= comb_teeth) then
|
||||||
@ -323,7 +323,7 @@ subroutine pt2_collector(zmq_socket_pull, E, b, tbc, comb, Ncomb, computed, pt2_
|
|||||||
eqt = 0.d0
|
eqt = 0.d0
|
||||||
endif
|
endif
|
||||||
call wall_time(time)
|
call wall_time(time)
|
||||||
if ( (dabs(eqt/avg) < relative_error) .or. (dabs(eqt) < absolute_error) ) then
|
if ( (dabs(eqt/avg) < relative_error) .or. (dabs(eqt) < absolute_error) .and. Nabove(tooth) >= 30) then
|
||||||
! Termination
|
! Termination
|
||||||
pt2(pt2_stoch_istate) = avg
|
pt2(pt2_stoch_istate) = avg
|
||||||
error(pt2_stoch_istate) = eqt
|
error(pt2_stoch_istate) = eqt
|
||||||
@ -336,19 +336,36 @@ subroutine pt2_collector(zmq_socket_pull, E, b, tbc, comb, Ncomb, computed, pt2_
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if (Nabove(tooth) > Nabove_old) then
|
if (Nabove(tooth) > Nabove_old) then
|
||||||
|
print *, loop
|
||||||
print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', Nabove(tooth), avg+E, eqt, time-time0, ''
|
print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', Nabove(tooth), avg+E, eqt, time-time0, ''
|
||||||
Nabove_old = Nabove(tooth)
|
Nabove_old = Nabove(tooth)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
end if
|
end if
|
||||||
end do pullLoop
|
end do pullLoop
|
||||||
|
!<<<<<<< HEAD
|
||||||
|
|
||||||
|
if(tooth == comb_teeth+1) then
|
||||||
|
pt2(pt2_stoch_istate) = sum(pt2_detail(pt2_stoch_istate,:))
|
||||||
|
error(pt2_stoch_istate) = 0d0
|
||||||
|
else
|
||||||
E0 = sum(pt2_detail(pt2_stoch_istate,:first_det_of_teeth(tooth)-1))
|
E0 = sum(pt2_detail(pt2_stoch_istate,:first_det_of_teeth(tooth)-1))
|
||||||
prop = ((1d0 - dfloat(comb_teeth - tooth + 1) * comb_step) - pt2_cweight(first_det_of_teeth(tooth)-1))
|
prop = ((1d0 - dfloat(comb_teeth - tooth + 1) * comb_step) - pt2_cweight(first_det_of_teeth(tooth)-1))
|
||||||
prop = prop * pt2_weight_inv(first_det_of_teeth(tooth))
|
prop = prop * pt2_weight_inv(first_det_of_teeth(tooth))
|
||||||
E0 += pt2_detail(pt2_stoch_istate,first_det_of_teeth(tooth)) * prop
|
E0 += pt2_detail(pt2_stoch_istate,first_det_of_teeth(tooth)) * prop
|
||||||
pt2(pt2_stoch_istate) = E0 + (sumabove(tooth) / Nabove(tooth))
|
pt2(pt2_stoch_istate) = E0 + (sumabove(tooth) / Nabove(tooth))
|
||||||
|
error(pt2_stoch_istate) = sqrt(1d0 / (Nabove(tooth)-1) * abs(sum2above(tooth) / Nabove(tooth) - (sumabove(tooth)/Nabove(tooth))**2))
|
||||||
|
end if
|
||||||
|
|
||||||
|
!=======
|
||||||
|
!
|
||||||
|
! E0 = sum(pt2_detail(pt2_stoch_istate,:first_det_of_teeth(tooth)-1))
|
||||||
|
! prop = ((1d0 - dfloat(comb_teeth - tooth + 1) * comb_step) - pt2_cweight(first_det_of_teeth(tooth)-1))
|
||||||
|
! prop = prop * pt2_weight_inv(first_det_of_teeth(tooth))
|
||||||
|
! E0 += pt2_detail(pt2_stoch_istate,first_det_of_teeth(tooth)) * prop
|
||||||
|
! pt2(pt2_stoch_istate) = E0 + (sumabove(tooth) / Nabove(tooth))
|
||||||
|
!
|
||||||
|
!>>>>>>> master
|
||||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||||
call sort_selection_buffer(b)
|
call sort_selection_buffer(b)
|
||||||
end subroutine
|
end subroutine
|
||||||
@ -393,7 +410,7 @@ subroutine get_first_tooth(computed, first_teeth)
|
|||||||
integer, intent(out) :: first_teeth
|
integer, intent(out) :: first_teeth
|
||||||
integer :: i, first_det
|
integer :: i, first_det
|
||||||
|
|
||||||
first_det = 1
|
first_det = N_det_generators+1+1
|
||||||
first_teeth = 1
|
first_teeth = 1
|
||||||
do i=first_det_of_comb, N_det_generators
|
do i=first_det_of_comb, N_det_generators
|
||||||
if(.not.(computed(i))) then
|
if(.not.(computed(i))) then
|
||||||
@ -402,7 +419,7 @@ subroutine get_first_tooth(computed, first_teeth)
|
|||||||
end if
|
end if
|
||||||
end do
|
end do
|
||||||
|
|
||||||
do i=comb_teeth, 1, -1
|
do i=comb_teeth+1, 1, -1
|
||||||
if(first_det_of_teeth(i) < first_det) then
|
if(first_det_of_teeth(i) < first_det) then
|
||||||
first_teeth = i
|
first_teeth = i
|
||||||
exit
|
exit
|
||||||
|
@ -1 +1 @@
|
|||||||
Selectors_full Generators_full ZMQ
|
ZMQ
|
||||||
|
@ -85,7 +85,6 @@ subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, bitmask_index
|
|||||||
!hole (k,2) = iand(psi_det_generators(k,2,i_generator), full_ijkl_bitmask(k))
|
!hole (k,2) = iand(psi_det_generators(k,2,i_generator), full_ijkl_bitmask(k))
|
||||||
!particle(k,1) = iand(not(psi_det_generators(k,1,i_generator)), full_ijkl_bitmask(k))
|
!particle(k,1) = iand(not(psi_det_generators(k,1,i_generator)), full_ijkl_bitmask(k))
|
||||||
!particle(k,2) = iand(not(psi_det_generators(k,2,i_generator)), full_ijkl_bitmask(k))
|
!particle(k,2) = iand(not(psi_det_generators(k,2,i_generator)), full_ijkl_bitmask(k))
|
||||||
|
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
integer :: N_holes(2), N_particles(2)
|
integer :: N_holes(2), N_particles(2)
|
||||||
@ -100,10 +99,10 @@ subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, bitmask_index
|
|||||||
allocate (indices(N_det), &
|
allocate (indices(N_det), &
|
||||||
exc_degree(max(N_det_alpha_unique,N_det_beta_unique)))
|
exc_degree(max(N_det_alpha_unique,N_det_beta_unique)))
|
||||||
|
|
||||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
!PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
!PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
!PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||||
PROVIDE psi_bilinear_matrix_transp_order
|
!PROVIDE psi_bilinear_matrix_transp_order
|
||||||
|
|
||||||
k=1
|
k=1
|
||||||
do i=1,N_det_alpha_unique
|
do i=1,N_det_alpha_unique
|
||||||
|
@ -10,11 +10,10 @@ subroutine run_dressing(N_st,energy)
|
|||||||
integer :: iteration
|
integer :: iteration
|
||||||
|
|
||||||
integer :: n_it_dress_max
|
integer :: n_it_dress_max
|
||||||
double precision :: thresh_dress
|
double precision :: thresh_dress, dummy
|
||||||
|
|
||||||
thresh_dress = thresh_dressed_ci
|
thresh_dress = thresh_dressed_ci
|
||||||
n_it_dress_max = n_it_max_dressed_ci
|
n_it_dress_max = n_it_max_dressed_ci
|
||||||
|
|
||||||
if(n_it_dress_max == 1) then
|
if(n_it_dress_max == 1) then
|
||||||
do j=1,N_states
|
do j=1,N_states
|
||||||
do i=1,N_det
|
do i=1,N_det
|
||||||
@ -30,13 +29,23 @@ subroutine run_dressing(N_st,energy)
|
|||||||
delta_E = 1.d0
|
delta_E = 1.d0
|
||||||
iteration = 0
|
iteration = 0
|
||||||
do iteration=1,n_it_dress_max
|
do iteration=1,n_it_dress_max
|
||||||
|
N_det_delta_ij = N_det
|
||||||
|
touch N_det_delta_ij
|
||||||
print *, '==============================================='
|
print *, '==============================================='
|
||||||
print *, 'Iteration', iteration, '/', n_it_dress_max
|
print *, 'Iteration', iteration, '/', n_it_dress_max
|
||||||
print *, '==============================================='
|
print *, '==============================================='
|
||||||
print *, ''
|
print *, ''
|
||||||
E_old = sum(psi_energy(:))
|
E_old = sum(psi_energy(:))
|
||||||
|
print *, 'Variational energy <Psi|H|Psi>'
|
||||||
do i=1,N_st
|
do i=1,N_st
|
||||||
call write_double(6,ci_energy_dressed(i),"Energy")
|
print *, i, psi_energy(i)
|
||||||
|
enddo
|
||||||
|
!print *, "DELTA IJ", delta_ij(1,1,1)
|
||||||
|
if(.true.) dummy = delta_ij_tmp(1,1,1)
|
||||||
|
if(.true.) call delta_ij_done()
|
||||||
|
print *, 'Dressed energy <Psi|H+Delta|Psi>'
|
||||||
|
do i=1,N_st
|
||||||
|
print *, i, ci_energy_dressed(i)
|
||||||
enddo
|
enddo
|
||||||
call diagonalize_ci_dressed
|
call diagonalize_ci_dressed
|
||||||
E_new = sum(psi_energy(:))
|
E_new = sum(psi_energy(:))
|
||||||
@ -52,8 +61,16 @@ subroutine run_dressing(N_st,energy)
|
|||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
call write_double(6,ci_energy_dressed(1),"Final energy")
|
print *, 'Variational energy <Psi|H|Psi>'
|
||||||
|
do i=1,N_st
|
||||||
|
print *, i, psi_energy(i)
|
||||||
|
enddo
|
||||||
|
print *, 'Dressed energy <Psi|H+Delta|Psi>'
|
||||||
|
do i=1,N_st
|
||||||
|
print *, i, ci_energy_dressed(i)
|
||||||
|
enddo
|
||||||
endif
|
endif
|
||||||
energy(1:N_st) = ci_energy_dressed(1:N_st)
|
|
||||||
|
if(.true.) energy(1:N_st) = 0d0 ! ci_energy_dressed(1:N_st)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@ subroutine dress_slave
|
|||||||
read_wf = .False.
|
read_wf = .False.
|
||||||
distributed_davidson = .False.
|
distributed_davidson = .False.
|
||||||
SOFT_TOUCH read_wf distributed_davidson
|
SOFT_TOUCH read_wf distributed_davidson
|
||||||
|
|
||||||
|
threshold_selectors = 1.d0
|
||||||
|
threshold_generators = 1d0
|
||||||
|
|
||||||
call provide_everything
|
call provide_everything
|
||||||
call switch_qp_run_to_master
|
call switch_qp_run_to_master
|
||||||
call run_wf
|
call run_wf
|
||||||
@ -24,6 +28,11 @@ subroutine run_wf
|
|||||||
double precision :: energy(N_states_diag)
|
double precision :: energy(N_states_diag)
|
||||||
character*(64) :: states(1)
|
character*(64) :: states(1)
|
||||||
integer :: rc, i
|
integer :: rc, i
|
||||||
|
integer, external :: zmq_get_dvector, zmq_get_N_det_generators
|
||||||
|
integer, external :: zmq_get_psi, zmq_get_N_det_selectors
|
||||||
|
integer, external :: zmq_get_N_states_diag
|
||||||
|
double precision :: tmp
|
||||||
|
|
||||||
|
|
||||||
call provide_everything
|
call provide_everything
|
||||||
|
|
||||||
@ -33,34 +42,38 @@ subroutine run_wf
|
|||||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
call wait_for_states(states,zmq_state,1)
|
call wait_for_states(states,zmq_state,1)
|
||||||
|
if(zmq_state(:7) == 'Stopped') then
|
||||||
if(trim(zmq_state) == 'Stopped') then
|
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
||||||
else if (trim(zmq_state) == 'dress') then
|
else if (zmq_state(:5) == 'dress') then
|
||||||
|
! Dress
|
||||||
! Selection
|
|
||||||
! ---------
|
! ---------
|
||||||
|
!call zmq_get_psi(zmq_to_qp_run_socket,1,energy,N_states)
|
||||||
|
if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle
|
||||||
|
!TOUCH psi_det
|
||||||
|
if (zmq_get_N_det_generators (zmq_to_qp_run_socket, 1) == -1) cycle
|
||||||
|
if (zmq_get_N_det_selectors(zmq_to_qp_run_socket, 1) == -1) cycle
|
||||||
|
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) cycle
|
||||||
|
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states) == -1) cycle
|
||||||
|
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'dress_stoch_istate',tmp,1) == -1) cycle
|
||||||
|
dress_stoch_istate = int(tmp)
|
||||||
|
|
||||||
print *, 'dress'
|
|
||||||
call zmq_get_psi(zmq_to_qp_run_socket,1,energy,N_states)
|
TOUCH dress_stoch_istate
|
||||||
|
TOUCH state_average_weight
|
||||||
|
|
||||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||||
PROVIDE psi_bilinear_matrix_transp_order
|
PROVIDE psi_bilinear_matrix_transp_order
|
||||||
|
!!$OMP PARALLEL PRIVATE(i)
|
||||||
!$OMP PARALLEL PRIVATE(i)
|
!i = omp_get_thread_num()
|
||||||
i = omp_get_thread_num()
|
! call dress_slave_tcp(i+1, energy)
|
||||||
call dress_slave_tcp(i, energy)
|
call dress_slave_tcp(0, energy)
|
||||||
!$OMP END PARALLEL
|
!!$OMP END PARALLEL
|
||||||
print *, 'dress done'
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
end do
|
end do
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -70,6 +83,6 @@ subroutine dress_slave_tcp(i,energy)
|
|||||||
integer, intent(in) :: i
|
integer, intent(in) :: i
|
||||||
logical :: lstop
|
logical :: lstop
|
||||||
lstop = .False.
|
lstop = .False.
|
||||||
call run_dress_slave(0,i,energy,lstop)
|
call run_dress_slave(0,i,energy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,13 +4,14 @@ BEGIN_PROVIDER [ integer, fragment_first ]
|
|||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error, lndet)
|
||||||
use f77_zmq
|
use f77_zmq
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
|
integer, intent(in) :: lndet
|
||||||
character(len=64000) :: task
|
character(len=64000) :: task
|
||||||
|
character(len=3200) :: temp
|
||||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull
|
integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull
|
||||||
integer, external :: omp_get_thread_num
|
integer, external :: omp_get_thread_num
|
||||||
double precision, intent(in) :: E(N_states), relative_error
|
double precision, intent(in) :: E(N_states), relative_error
|
||||||
@ -27,9 +28,9 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
|||||||
double precision :: time
|
double precision :: time
|
||||||
integer, external :: add_task_to_taskserver
|
integer, external :: add_task_to_taskserver
|
||||||
double precision :: state_average_weight_save(N_states)
|
double precision :: state_average_weight_save(N_states)
|
||||||
|
task(:) = CHAR(0)
|
||||||
|
temp(:) = CHAR(0)
|
||||||
allocate(delta(N_states,N_det), delta_s2(N_det,N_states))
|
allocate(delta(N_states,N_det), delta_s2(N_states, N_det))
|
||||||
state_average_weight_save(:) = state_average_weight(:)
|
state_average_weight_save(:) = state_average_weight(:)
|
||||||
do dress_stoch_istate=1,N_states
|
do dress_stoch_istate=1,N_states
|
||||||
SOFT_TOUCH dress_stoch_istate
|
SOFT_TOUCH dress_stoch_istate
|
||||||
@ -37,14 +38,14 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
|||||||
state_average_weight(dress_stoch_istate) = 1.d0
|
state_average_weight(dress_stoch_istate) = 1.d0
|
||||||
TOUCH state_average_weight
|
TOUCH state_average_weight
|
||||||
|
|
||||||
|
!provide psi_coef_generators
|
||||||
provide nproc fragment_first fragment_count mo_bielec_integrals_in_map mo_mono_elec_integral dress_weight psi_selectors
|
provide nproc fragment_first fragment_count mo_bielec_integrals_in_map mo_mono_elec_integral dress_weight psi_selectors
|
||||||
|
!print *, dress_e0_denominator
|
||||||
|
|
||||||
print *, '========== ================= ================= ================='
|
print *, '========== ================= ================= ================='
|
||||||
print *, ' Samples Energy Stat. Error Seconds '
|
print *, ' Samples Energy Stat. Error Seconds '
|
||||||
print *, '========== ================= ================= ================='
|
print *, '========== ================= ================= ================='
|
||||||
|
|
||||||
|
|
||||||
call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull, 'dress')
|
call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull, 'dress')
|
||||||
|
|
||||||
integer, external :: zmq_put_psi
|
integer, external :: zmq_put_psi
|
||||||
@ -52,6 +53,7 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
|||||||
integer, external :: zmq_put_N_det_selectors
|
integer, external :: zmq_put_N_det_selectors
|
||||||
integer, external :: zmq_put_dvector
|
integer, external :: zmq_put_dvector
|
||||||
integer, external :: zmq_set_running
|
integer, external :: zmq_set_running
|
||||||
|
|
||||||
if (zmq_put_psi(zmq_to_qp_run_socket,1) == -1) then
|
if (zmq_put_psi(zmq_to_qp_run_socket,1) == -1) then
|
||||||
stop 'Unable to put psi on ZMQ server'
|
stop 'Unable to put psi on ZMQ server'
|
||||||
endif
|
endif
|
||||||
@ -64,15 +66,38 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
|||||||
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'energy',dress_e0_denominator,size(dress_e0_denominator)) == -1) then
|
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'energy',dress_e0_denominator,size(dress_e0_denominator)) == -1) then
|
||||||
stop 'Unable to put energy on ZMQ server'
|
stop 'Unable to put energy on ZMQ server'
|
||||||
endif
|
endif
|
||||||
|
if (zmq_put_dvector(zmq_to_qp_run_socket,1,"state_average_weight",state_average_weight,N_states) == -1) then
|
||||||
|
stop 'Unable to put state_average_weight on ZMQ server'
|
||||||
|
endif
|
||||||
|
if (zmq_put_dvector(zmq_to_qp_run_socket,1,"dress_stoch_istate",real(dress_stoch_istate,8),1) == -1) then
|
||||||
|
stop 'Unable to put dress_stoch_istate on ZMQ server'
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
|
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
|
||||||
integer :: ipos
|
integer :: ipos, sz
|
||||||
|
integer :: block(1), block_i, cur_tooth_reduce, ntas
|
||||||
|
logical :: flushme
|
||||||
|
block = 0
|
||||||
|
block_i = 0
|
||||||
|
cur_tooth_reduce = 0
|
||||||
ipos=1
|
ipos=1
|
||||||
do i=1,N_dress_jobs
|
ntas = 0
|
||||||
if(dress_jobs(i) > fragment_first) then
|
do i=1,N_dress_jobs+1
|
||||||
write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') 0, dress_jobs(i)
|
flushme = (i==N_dress_jobs+1 .or. block_i == size(block) .or. block_i >=cur_tooth_reduce )
|
||||||
ipos += 20
|
if(.not. flushme) flushme = (tooth_reduce(dress_jobs(i)) == 0 .or. tooth_reduce(dress_jobs(i)) /= cur_tooth_reduce)
|
||||||
if (ipos > 63980) then
|
|
||||||
|
if(flushme .and. block_i > 0) then
|
||||||
|
if(block(1) > fragment_first) then
|
||||||
|
ntas += 1
|
||||||
|
write(temp, '(I9,1X,60(I9,1X))') 0, block(:block_i)
|
||||||
|
sz = len(trim(temp))+1
|
||||||
|
temp(sz:sz) = '|'
|
||||||
|
!write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') 0, dress_jobs(i)
|
||||||
|
write(task(ipos:ipos+sz), *) temp(:sz)
|
||||||
|
!ipos += 20
|
||||||
|
ipos += sz+1
|
||||||
|
if (ipos > 63000 .or. i==N_dress_jobs+1) then
|
||||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||||
stop 'Unable to add task to task server'
|
stop 'Unable to add task to task server'
|
||||||
endif
|
endif
|
||||||
@ -80,10 +105,13 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
|||||||
ipos=1
|
ipos=1
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
|
if(block_i /= 1) stop "reduced fragmented dets"
|
||||||
do j=1,fragment_count
|
do j=1,fragment_count
|
||||||
write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') j, dress_jobs(i)
|
ntas += 1
|
||||||
|
write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') j, block(1)
|
||||||
ipos += 20
|
ipos += 20
|
||||||
if (ipos > 63980) then
|
if (ipos > 63000 .or. i==N_dress_jobs+1) then
|
||||||
|
ntas += 1
|
||||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||||
stop 'Unable to add task to task server'
|
stop 'Unable to add task to task server'
|
||||||
endif
|
endif
|
||||||
@ -91,28 +119,32 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
|||||||
endif
|
endif
|
||||||
end do
|
end do
|
||||||
end if
|
end if
|
||||||
|
block_i = 0
|
||||||
|
block = 0
|
||||||
|
end if
|
||||||
|
|
||||||
|
if(i /= N_dress_jobs+1) then
|
||||||
|
cur_tooth_reduce = tooth_reduce(dress_jobs(i))
|
||||||
|
block_i += 1
|
||||||
|
block(block_i) = dress_jobs(i)
|
||||||
|
end if
|
||||||
end do
|
end do
|
||||||
if (ipos > 1) then
|
|
||||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
|
||||||
stop 'Unable to add task to task server'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if (zmq_set_running(zmq_to_qp_run_socket) == -1) then
|
if (zmq_set_running(zmq_to_qp_run_socket) == -1) then
|
||||||
print *, irp_here, ': Failed in zmq_set_running'
|
print *, irp_here, ': Failed in zmq_set_running'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
!$OMP PARALLEL DEFAULT(shared) NUM_THREADS(nproc+1) &
|
!!$OMP PARALLEL DEFAULT(shared) NUM_THREADS(nproc) &
|
||||||
!$OMP PRIVATE(i)
|
! !$OMP PRIVATE(i)
|
||||||
i = omp_get_thread_num()
|
!i = omp_get_thread_num()
|
||||||
if (i==0) then
|
!if (i==0) then
|
||||||
call dress_collector(zmq_socket_pull,E, relative_error, delta, delta_s2, dress,&
|
call dress_collector(zmq_socket_pull,E, relative_error, delta, delta_s2, dress,&
|
||||||
dress_stoch_istate)
|
dress_stoch_istate)
|
||||||
else
|
!else
|
||||||
call dress_slave_inproc(i)
|
! call dress_slave_inproc(i)
|
||||||
endif
|
!endif
|
||||||
!$OMP END PARALLEL
|
!!$OMP END PARALLEL
|
||||||
delta_out(dress_stoch_istate,1:N_det) = delta(dress_stoch_istate,1:N_det)
|
delta_out(dress_stoch_istate,1:N_det) = delta(dress_stoch_istate,1:N_det)
|
||||||
delta_s2_out(dress_stoch_istate,1:N_det) = delta_s2_out(dress_stoch_istate,1:N_det)
|
delta_s2_out(dress_stoch_istate,1:N_det) = delta_s2(dress_stoch_istate,1:N_det)
|
||||||
call end_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'dress')
|
call end_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'dress')
|
||||||
|
|
||||||
print *, '========== ================= ================= ================='
|
print *, '========== ================= ================= ================='
|
||||||
@ -140,7 +172,6 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
|||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
|
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
|
||||||
integer, intent(in) :: istate
|
integer, intent(in) :: istate
|
||||||
|
|
||||||
@ -150,7 +181,7 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
|||||||
|
|
||||||
double precision, intent(out) :: delta(N_states, N_det)
|
double precision, intent(out) :: delta(N_states, N_det)
|
||||||
double precision, intent(out) :: delta_s2(N_states, N_det)
|
double precision, intent(out) :: delta_s2(N_states, N_det)
|
||||||
double precision, allocatable :: delta_loc(:,:,:), delta_det(:,:,:,:)
|
double precision, allocatable :: delta_loc(:,:,:)
|
||||||
double precision, allocatable :: dress_detail(:,:)
|
double precision, allocatable :: dress_detail(:,:)
|
||||||
double precision :: dress_mwen(N_states)
|
double precision :: dress_mwen(N_states)
|
||||||
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
||||||
@ -162,127 +193,95 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
|||||||
integer :: i, j, k, i_state, N
|
integer :: i, j, k, i_state, N
|
||||||
integer :: task_id, ind
|
integer :: task_id, ind
|
||||||
double precision, save :: time0 = -1.d0
|
double precision, save :: time0 = -1.d0
|
||||||
double precision :: time, timeLast, old_tooth
|
double precision :: time
|
||||||
double precision, external :: omp_get_wtime
|
double precision, external :: omp_get_wtime
|
||||||
integer :: cur_cp, old_cur_cp
|
integer :: cur_cp, last_cp
|
||||||
integer, allocatable :: parts_to_get(:)
|
integer :: delta_loc_cur, is, N_buf(3)
|
||||||
logical, allocatable :: actually_computed(:)
|
integer, allocatable :: int_buf(:), agreg_for_cp(:)
|
||||||
integer :: total_computed
|
double precision, allocatable :: double_buf(:)
|
||||||
|
integer(bit_kind), allocatable :: det_buf(:,:,:)
|
||||||
|
integer, external :: zmq_delete_tasks
|
||||||
|
last_cp = 10000000
|
||||||
|
allocate(agreg_for_cp(N_cp))
|
||||||
|
agreg_for_cp = 0
|
||||||
|
allocate(int_buf(N_dress_int_buffer), double_buf(N_dress_double_buffer), det_buf(N_int,2,N_dress_det_buffer))
|
||||||
|
delta_loc_cur = 1
|
||||||
|
|
||||||
delta = 0d0
|
delta = 0d0
|
||||||
delta_s2 = 0d0
|
delta_s2 = 0d0
|
||||||
allocate(delta_det(N_states, N_det, 0:comb_teeth+1, 2))
|
|
||||||
allocate(cp(N_states, N_det, N_cp, 2), dress_detail(N_states, N_det))
|
allocate(cp(N_states, N_det, N_cp, 2), dress_detail(N_states, N_det))
|
||||||
allocate(delta_loc(N_states, N_det, 2))
|
allocate(delta_loc(N_states, N_det, 2))
|
||||||
dress_detail = 0d0
|
dress_detail = -1000d0
|
||||||
delta_det = 0d0
|
|
||||||
cp = 0d0
|
cp = 0d0
|
||||||
total_computed = 0
|
|
||||||
character*(512) :: task
|
character*(512) :: task
|
||||||
|
|
||||||
allocate(actually_computed(N_det_generators), parts_to_get(N_det_generators))
|
|
||||||
|
|
||||||
dress_mwen =0.d0
|
|
||||||
|
|
||||||
parts_to_get(:) = 1
|
|
||||||
if(fragment_first > 0) then
|
|
||||||
do i=1,fragment_first
|
|
||||||
parts_to_get(i) = fragment_count
|
|
||||||
enddo
|
|
||||||
endif
|
|
||||||
|
|
||||||
actually_computed = .false.
|
|
||||||
|
|
||||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||||
more = 1
|
more = 1
|
||||||
if (time0 < 0.d0) then
|
if (time0 < 0.d0) then
|
||||||
call wall_time(time0)
|
call wall_time(time0)
|
||||||
endif
|
endif
|
||||||
timeLast = time0
|
logical :: loop, floop
|
||||||
cur_cp = 0
|
|
||||||
old_cur_cp = 0
|
floop = .true.
|
||||||
logical :: loop
|
|
||||||
loop = .true.
|
loop = .true.
|
||||||
|
|
||||||
pullLoop : do while (loop)
|
pullLoop : do while (loop)
|
||||||
call pull_dress_results(zmq_socket_pull, ind, delta_loc, task_id)
|
call pull_dress_results(zmq_socket_pull, ind, cur_cp, delta_loc, int_buf, double_buf, det_buf, N_buf, task_id, dress_mwen)
|
||||||
dress_mwen(:) = 0d0
|
if(floop) then
|
||||||
|
call wall_time(time)
|
||||||
!!!!! A VERIFIER !!!!!
|
print *, "first_pull", time-time0
|
||||||
do i_state=1,N_states
|
time0 = time
|
||||||
do i=1, N_det
|
floop = .false.
|
||||||
dress_mwen(i_state) += delta_loc(i_state, i, 1) * psi_coef(i, i_state)
|
|
||||||
end do
|
|
||||||
end do
|
|
||||||
|
|
||||||
dress_detail(:, ind) += dress_mwen(:)
|
|
||||||
do j=1,N_cp !! optimizable
|
|
||||||
if(cps(ind, j) > 0d0) then
|
|
||||||
if(tooth_of_det(ind) < cp_first_tooth(j)) stop "coef on supposedely deterministic det"
|
|
||||||
double precision :: fac
|
|
||||||
integer :: toothMwen
|
|
||||||
logical :: fracted
|
|
||||||
fac = cps(ind, j) / cps_N(j) * dress_weight_inv(ind) * comb_step
|
|
||||||
cp(1:N_states,1:N_det,j,1) += delta_loc(1:N_states,1:N_det,1) * fac
|
|
||||||
cp(1:N_states,1:N_det,j,2) += delta_loc(1:N_states,1:N_det,2) * fac
|
|
||||||
end if
|
end if
|
||||||
end do
|
if(cur_cp == -1 .and. ind == N_det_generators) then
|
||||||
toothMwen = tooth_of_det(ind)
|
call wall_time(time)
|
||||||
fracted = (toothMwen /= 0)
|
|
||||||
if(fracted) fracted = (ind == first_det_of_teeth(toothMwen))
|
|
||||||
|
|
||||||
if(fracted) then
|
|
||||||
delta_det(1:N_states,1:N_det,toothMwen-1, 1) = delta_det(1:N_states,1:N_det,toothMwen-1, 1) + delta_loc(1:N_states,1:N_det,1) * (1d0-fractage(toothMwen))
|
|
||||||
delta_det(1:N_states,1:N_det,toothMwen-1, 2) = delta_det(1:N_states,1:N_det,toothMwen-1, 2) + delta_loc(1:N_states,1:N_det,2) * (1d0-fractage(toothMwen))
|
|
||||||
delta_det(1:N_states,1:N_det,toothMwen , 1) = delta_det(1:N_states,1:N_det,toothMwen , 1) + delta_loc(1:N_states,1:N_det,1) * (fractage(toothMwen))
|
|
||||||
delta_det(1:N_states,1:N_det,toothMwen , 2) = delta_det(1:N_states,1:N_det,toothMwen , 2) + delta_loc(1:N_states,1:N_det,2) * (fractage(toothMwen))
|
|
||||||
else
|
|
||||||
delta_det(1:N_states,1:N_det,toothMwen , 1) = delta_det(1:N_states,1:N_det,toothMwen , 1) + delta_loc(1:N_states,1:N_det,1)
|
|
||||||
delta_det(1:N_states,1:N_det,toothMwen , 2) = delta_det(1:N_states,1:N_det,toothMwen , 2) + delta_loc(1:N_states,1:N_det,2)
|
|
||||||
end if
|
|
||||||
|
|
||||||
parts_to_get(ind) -= 1
|
|
||||||
if(parts_to_get(ind) == 0) then
|
|
||||||
actually_computed(ind) = .true.
|
|
||||||
total_computed += 1
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|
||||||
integer, external :: zmq_delete_tasks
|
if(cur_cp == -1) then
|
||||||
|
call dress_pulled(ind, int_buf, double_buf, det_buf, N_buf)
|
||||||
if (zmq_delete_tasks(zmq_to_qp_run_socket,zmq_socket_pull,task_id,1,more) == -1) then
|
if (zmq_delete_tasks(zmq_to_qp_run_socket,zmq_socket_pull,task_id,1,more) == -1) then
|
||||||
stop 'Unable to delete tasks'
|
stop 'Unable to delete tasks'
|
||||||
endif
|
endif
|
||||||
if(more == 0) loop = .false.
|
if(more == 0) loop = .false. !stop 'loop = .false.' !!!!!!!!!!!!!!!!
|
||||||
|
dress_detail(:, ind) = dress_mwen(:)
|
||||||
time = omp_get_wtime()
|
!print *, "DETAIL", ind, dress_mwen
|
||||||
|
else if(cur_cp > 0) then
|
||||||
if((time - timeLast > 2d0) .or. (.not. loop)) then
|
if(ind == 0) cycle
|
||||||
timeLast = time
|
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i)
|
||||||
cur_cp = N_cp
|
do i=1,N_det
|
||||||
|
cp(:,i,cur_cp,1) += delta_loc(:,i,1)
|
||||||
do i=1,N_det_generators
|
|
||||||
if(.not. actually_computed(dress_jobs(i))) then
|
|
||||||
if(i /= 1) then
|
|
||||||
cur_cp = done_cp_at(i-1)
|
|
||||||
else
|
|
||||||
cur_cp = 0
|
|
||||||
end if
|
|
||||||
exit
|
|
||||||
end if
|
|
||||||
end do
|
end do
|
||||||
if(cur_cp == 0) cycle pullLoop
|
|
||||||
|
|
||||||
|
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i)
|
||||||
|
do i=1,N_det
|
||||||
|
cp(:,i,cur_cp,2) += delta_loc(:,i,2)
|
||||||
|
end do
|
||||||
|
!$OMP END PARALLEL DO
|
||||||
|
agreg_for_cp(cur_cp) += ind
|
||||||
|
!print *, agreg_for_cp(cur_cp), ind, needed_by_cp(cur_cp), cur_cp
|
||||||
|
if(agreg_for_cp(cur_cp) > needed_by_cp(cur_cp)) then
|
||||||
|
stop "too much results..."
|
||||||
|
end if
|
||||||
|
if(agreg_for_cp(cur_cp) /= needed_by_cp(cur_cp)) cycle
|
||||||
|
|
||||||
|
call wall_time(time)
|
||||||
|
|
||||||
|
last_cp = cur_cp
|
||||||
double precision :: su, su2, eqt, avg, E0, val
|
double precision :: su, su2, eqt, avg, E0, val
|
||||||
integer, external :: zmq_abort
|
integer, external :: zmq_abort
|
||||||
|
|
||||||
su = 0d0
|
su = 0d0
|
||||||
su2 = 0d0
|
su2 = 0d0
|
||||||
|
!$OMP PARALLEL DO DEFAULT(NONE) PRIVATE(i, val) SHARED(comb, dress_detail, &
|
||||||
|
!$OMP cur_cp,istate,cps_N) REDUCTION(+:su) REDUCTION(+:su2)
|
||||||
do i=1, int(cps_N(cur_cp))
|
do i=1, int(cps_N(cur_cp))
|
||||||
call get_comb_val(comb(i), dress_detail, cur_cp, val, istate)
|
call get_comb_val(comb(i), dress_detail, cur_cp, val, istate)
|
||||||
su += val
|
su += val
|
||||||
su2 += val*val
|
su2 += val*val
|
||||||
end do
|
end do
|
||||||
|
!$OMP END PARALLEL DO
|
||||||
|
|
||||||
avg = su / cps_N(cur_cp)
|
avg = su / cps_N(cur_cp)
|
||||||
eqt = dsqrt( ((su2 / cps_N(cur_cp)) - avg*avg) / cps_N(cur_cp) )
|
eqt = dsqrt( ((su2 / cps_N(cur_cp)) - avg*avg) / cps_N(cur_cp) )
|
||||||
E0 = sum(dress_detail(istate, :first_det_of_teeth(cp_first_tooth(cur_cp))-1))
|
E0 = sum(dress_detail(istate, :first_det_of_teeth(cp_first_tooth(cur_cp))-1))
|
||||||
@ -290,44 +289,25 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
|||||||
E0 = E0 + dress_detail(istate, first_det_of_teeth(cp_first_tooth(cur_cp))) * (1d0-fractage(cp_first_tooth(cur_cp)))
|
E0 = E0 + dress_detail(istate, first_det_of_teeth(cp_first_tooth(cur_cp))) * (1d0-fractage(cp_first_tooth(cur_cp)))
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
!print '(I2X, F16.7, 2X, G16.3, 2X, F16.4, A20)', avg+E(istate)+E0, eqt, time-time0, ''
|
||||||
call wall_time(time)
|
print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', cps_N(cur_cp), avg+E0+E(istate), eqt, time-time0, ''
|
||||||
if ((dabs(eqt) < relative_error .and. cps_N(cur_cp) >= 30) .or. total_computed == N_det_generators) then
|
if ((dabs(eqt) < relative_error .and. cps_N(cur_cp) >= 30)) then
|
||||||
! Termination
|
! Termination
|
||||||
print '(2X, F16.7, 2X, G16.3, 2X, F16.4, A20)', avg+E(istate)+E0, eqt, time-time0, ''
|
print *, "TERMINATE"
|
||||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||||
call sleep(1)
|
call sleep(1)
|
||||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||||
print *, irp_here, ': Error in sending abort signal (2)'
|
print *, irp_here, ': Error in sending abort signal (2)'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
|
||||||
if (cur_cp > old_cur_cp) then
|
|
||||||
old_cur_cp = cur_cp
|
|
||||||
print '(2X, F16.7, 2X, G16.3, 2X, F16.4, A20)', avg+E(istate)+E0, eqt, time-time0, ''
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
end if
|
end if
|
||||||
end do pullLoop
|
end do pullLoop
|
||||||
|
|
||||||
if(total_computed == N_det_generators) then
|
delta(:,:) = cp(:,:,last_cp,1)
|
||||||
delta (1:N_states,1:N_det) = 0d0
|
delta_s2(:,:) = cp(:,:,last_cp,2)
|
||||||
delta_s2(1:N_states,1:N_det) = 0d0
|
|
||||||
do i=comb_teeth+1,0,-1
|
|
||||||
delta (1:N_states,1:N_det) = delta (1:N_states,1:N_det) + delta_det(1:N_states,1:N_det,i,1)
|
|
||||||
delta_s2(1:N_states,1:N_det) = delta_s2(1:N_states,1:N_det) + delta_det(1:N_states,1:N_det,i,2)
|
|
||||||
end do
|
|
||||||
else
|
|
||||||
|
|
||||||
delta (1:N_states,1:N_det) = cp(1:N_states,1:N_det,cur_cp,1)
|
dress(istate) = E(istate)+E0+avg
|
||||||
delta_s2(1:N_states,1:N_det) = cp(1:N_states,1:N_det,cur_cp,2)
|
|
||||||
do i=cp_first_tooth(cur_cp)-1,0,-1
|
|
||||||
delta (1:N_states,1:N_det) = delta (1:N_states,1:N_det) + delta_det(1:N_states,1:N_det,i,1)
|
|
||||||
delta_s2(1:N_states,1:N_det) = delta_s2(1:N_states,1:N_det) + delta_det(1:N_states,1:N_det,i,2)
|
|
||||||
end do
|
|
||||||
|
|
||||||
end if
|
|
||||||
dress(istate) = E(istate)+E0
|
|
||||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
@ -369,7 +349,7 @@ end function
|
|||||||
! gen_per_cp : number of generators per checkpoint
|
! gen_per_cp : number of generators per checkpoint
|
||||||
END_DOC
|
END_DOC
|
||||||
comb_teeth = 64
|
comb_teeth = 64
|
||||||
N_cps_max = 256
|
N_cps_max = 16
|
||||||
gen_per_cp = (N_det_generators / N_cps_max) + 1
|
gen_per_cp = (N_det_generators / N_cps_max) + 1
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
@ -378,24 +358,50 @@ END_PROVIDER
|
|||||||
&BEGIN_PROVIDER [ double precision, cps_N, (N_cps_max) ]
|
&BEGIN_PROVIDER [ double precision, cps_N, (N_cps_max) ]
|
||||||
&BEGIN_PROVIDER [ integer, cp_first_tooth, (N_cps_max) ]
|
&BEGIN_PROVIDER [ integer, cp_first_tooth, (N_cps_max) ]
|
||||||
&BEGIN_PROVIDER [ integer, done_cp_at, (N_det_generators) ]
|
&BEGIN_PROVIDER [ integer, done_cp_at, (N_det_generators) ]
|
||||||
|
&BEGIN_PROVIDER [ integer, done_cp_at_det, (N_det_generators) ]
|
||||||
|
&BEGIN_PROVIDER [ integer, needed_by_cp, (0:N_cps_max) ]
|
||||||
&BEGIN_PROVIDER [ double precision, cps, (N_det_generators, N_cps_max) ]
|
&BEGIN_PROVIDER [ double precision, cps, (N_det_generators, N_cps_max) ]
|
||||||
&BEGIN_PROVIDER [ integer, N_dress_jobs ]
|
&BEGIN_PROVIDER [ integer, N_dress_jobs ]
|
||||||
&BEGIN_PROVIDER [ integer, dress_jobs, (N_det_generators) ]
|
&BEGIN_PROVIDER [ integer, dress_jobs, (N_det_generators) ]
|
||||||
&BEGIN_PROVIDER [ double precision, comb, (N_det_generators) ]
|
&BEGIN_PROVIDER [ double precision, comb, (N_det_generators) ]
|
||||||
|
&BEGIN_PROVIDER [ integer, tooth_reduce, (N_det_generators) ]
|
||||||
implicit none
|
implicit none
|
||||||
logical, allocatable :: computed(:)
|
logical, allocatable :: computed(:), comp_filler(:)
|
||||||
integer :: i, j, last_full, dets(comb_teeth)
|
integer :: i, j, last_full, dets(comb_teeth)
|
||||||
integer :: k, l, cur_cp, under_det(comb_teeth+1)
|
|
||||||
integer, allocatable :: iorder(:), first_cp(:)
|
|
||||||
|
|
||||||
|
integer :: k, l, cur_cp, under_det(comb_teeth+1)
|
||||||
|
integer :: cp_limit(N_cps_max)
|
||||||
|
integer, allocatable :: iorder(:), first_cp(:)
|
||||||
|
integer, allocatable :: filler(:)
|
||||||
|
integer :: nfiller, lfiller, cfiller
|
||||||
|
logical :: fracted
|
||||||
|
|
||||||
|
integer :: first_suspect
|
||||||
|
provide psi_coef_generators
|
||||||
|
first_suspect = 1
|
||||||
|
|
||||||
|
allocate(filler(n_det_generators))
|
||||||
allocate(iorder(N_det_generators), first_cp(N_cps_max+1))
|
allocate(iorder(N_det_generators), first_cp(N_cps_max+1))
|
||||||
allocate(computed(N_det_generators))
|
allocate(computed(N_det_generators))
|
||||||
|
allocate(comp_filler(N_det_generators))
|
||||||
first_cp = 1
|
first_cp = 1
|
||||||
cps = 0d0
|
cps = 0d0
|
||||||
cur_cp = 1
|
cur_cp = 1
|
||||||
done_cp_at = 0
|
done_cp_at = 0
|
||||||
|
done_cp_at_det = 0
|
||||||
|
needed_by_cp = 0
|
||||||
|
comp_filler = .false.
|
||||||
computed = .false.
|
computed = .false.
|
||||||
|
cps_N = 1d0
|
||||||
|
tooth_reduce = 0
|
||||||
|
|
||||||
|
integer :: fragsize
|
||||||
|
fragsize = N_det_generators / ((N_cps_max-1+1)*(N_cps_max-1+2)/2)
|
||||||
|
|
||||||
|
do i=1,N_cps_max
|
||||||
|
cp_limit(i) = fragsize * i * (i+1) / 2
|
||||||
|
end do
|
||||||
|
cp_limit(N_cps_max) = N_det*2
|
||||||
|
|
||||||
N_dress_jobs = first_det_of_comb - 1
|
N_dress_jobs = first_det_of_comb - 1
|
||||||
do i=1, N_dress_jobs
|
do i=1, N_dress_jobs
|
||||||
@ -404,13 +410,18 @@ END_PROVIDER
|
|||||||
end do
|
end do
|
||||||
|
|
||||||
l=first_det_of_comb
|
l=first_det_of_comb
|
||||||
|
call random_seed(put=(/321,654,65,321,65,321,654,65,321,6321,654,65,321,621,654,65,321,65,654,65,321,65/))
|
||||||
call RANDOM_NUMBER(comb)
|
call RANDOM_NUMBER(comb)
|
||||||
|
lfiller = 1
|
||||||
|
nfiller = 1
|
||||||
do i=1,N_det_generators
|
do i=1,N_det_generators
|
||||||
|
!print *, i, N_dress_jobs
|
||||||
comb(i) = comb(i) * comb_step
|
comb(i) = comb(i) * comb_step
|
||||||
!DIR$ FORCEINLINE
|
!DIR$ FORCEINLINE
|
||||||
call add_comb(comb(i), computed, cps(1, cur_cp), N_dress_jobs, dress_jobs)
|
call add_comb(comb(i), computed, cps(1, cur_cp), N_dress_jobs, dress_jobs)
|
||||||
|
|
||||||
if(N_dress_jobs / gen_per_cp > (cur_cp-1) .or. N_dress_jobs == N_det_generators) then
|
!if(N_dress_jobs / gen_per_cp > (cur_cp-1) .or. N_dress_jobs == N_det_generators) then
|
||||||
|
if(N_dress_jobs > cp_limit(cur_cp) .or. N_dress_jobs == N_det_generators) then
|
||||||
first_cp(cur_cp+1) = N_dress_jobs
|
first_cp(cur_cp+1) = N_dress_jobs
|
||||||
done_cp_at(N_dress_jobs) = cur_cp
|
done_cp_at(N_dress_jobs) = cur_cp
|
||||||
cps_N(cur_cp) = dfloat(i)
|
cps_N(cur_cp) = dfloat(i)
|
||||||
@ -419,17 +430,69 @@ END_PROVIDER
|
|||||||
cur_cp += 1
|
cur_cp += 1
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if (N_dress_jobs == N_det_generators) exit
|
if (N_dress_jobs == N_det_generators) then
|
||||||
|
exit
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
if(.FALSE.) then
|
||||||
|
do l=first_suspect,N_det_generators
|
||||||
|
if((.not. computed(l))) then
|
||||||
|
N_dress_jobs+=1
|
||||||
|
dress_jobs(N_dress_jobs) = l
|
||||||
|
computed(l) = .true.
|
||||||
|
first_suspect = l
|
||||||
|
exit
|
||||||
end if
|
end if
|
||||||
do while (computed(l))
|
|
||||||
l=l+1
|
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
if (N_dress_jobs == N_det_generators) exit
|
||||||
|
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
ELSE
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
do l=first_suspect,N_det_generators
|
||||||
|
if((.not. computed(l)) .and. (.not. comp_filler(l))) exit
|
||||||
|
end do
|
||||||
|
first_suspect = l
|
||||||
|
if(l > N_det_generators) cycle
|
||||||
|
|
||||||
|
cfiller = tooth_of_det(l)-1
|
||||||
|
if(cfiller > lfiller) then
|
||||||
|
do j=1,nfiller-1
|
||||||
|
if(.not. computed(filler(j))) then
|
||||||
k=N_dress_jobs+1
|
k=N_dress_jobs+1
|
||||||
dress_jobs(k) = l
|
dress_jobs(k) = filler(j)
|
||||||
computed(l) = .True.
|
|
||||||
N_dress_jobs = k
|
N_dress_jobs = k
|
||||||
|
end if
|
||||||
|
computed(filler(j)) = .true.
|
||||||
end do
|
end do
|
||||||
|
nfiller = 2
|
||||||
|
filler(1) = l
|
||||||
|
lfiller = cfiller
|
||||||
|
else
|
||||||
|
filler(nfiller) = l
|
||||||
|
nfiller += 1
|
||||||
|
end if
|
||||||
|
comp_filler(l) = .True.
|
||||||
|
end if
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
enddo
|
||||||
|
|
||||||
|
|
||||||
|
do j=1,nfiller-1
|
||||||
|
if(.not. computed(filler(j)))then
|
||||||
|
k=N_dress_jobs+1
|
||||||
|
dress_jobs(k) = filler(j)
|
||||||
|
N_dress_jobs = k
|
||||||
|
end if
|
||||||
|
computed(filler(j)) = .true.
|
||||||
|
end do
|
||||||
|
|
||||||
|
|
||||||
N_cp = cur_cp
|
N_cp = cur_cp
|
||||||
|
|
||||||
if(N_dress_jobs /= N_det_generators .or. N_cp > N_cps_max) then
|
if(N_dress_jobs /= N_det_generators .or. N_cp > N_cps_max) then
|
||||||
print *, N_dress_jobs, N_det_generators, N_cp, N_cps_max
|
print *, N_dress_jobs, N_det_generators, N_cp, N_cps_max
|
||||||
stop "error in jobs creation"
|
stop "error in jobs creation"
|
||||||
@ -439,6 +502,8 @@ END_PROVIDER
|
|||||||
do i=1,N_dress_jobs
|
do i=1,N_dress_jobs
|
||||||
if(done_cp_at(i) /= 0) cur_cp = done_cp_at(i)
|
if(done_cp_at(i) /= 0) cur_cp = done_cp_at(i)
|
||||||
done_cp_at(i) = cur_cp
|
done_cp_at(i) = cur_cp
|
||||||
|
done_cp_at_det(dress_jobs(i)) = cur_cp
|
||||||
|
needed_by_cp(cur_cp) += 1
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
|
||||||
@ -461,12 +526,40 @@ END_PROVIDER
|
|||||||
end if
|
end if
|
||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
cps(:, N_cp) = 0d0
|
|
||||||
cp_first_tooth(N_cp) = comb_teeth+1
|
cp_first_tooth(N_cp) = comb_teeth+1
|
||||||
|
|
||||||
|
do i=1,N_det_generators
|
||||||
|
do j=N_cp,2,-1
|
||||||
|
cps(i,j) -= cps(i,j-1)
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
|
||||||
iorder = -1
|
iorder = -1
|
||||||
|
|
||||||
|
cps(:, N_cp) = 0d0
|
||||||
|
|
||||||
|
iloop : do i=fragment_first+1,N_det_generators
|
||||||
|
k = tooth_of_det(i)
|
||||||
|
if(k == 0) cycle
|
||||||
|
if (i == first_det_of_teeth(k)) cycle
|
||||||
|
|
||||||
|
do j=1,N_cp
|
||||||
|
if(cps(i, j) /= 0d0) cycle iloop
|
||||||
|
end do
|
||||||
|
|
||||||
|
tooth_reduce(i) = k
|
||||||
|
end do iloop
|
||||||
|
|
||||||
|
do i=1,N_det_generators
|
||||||
|
if(tooth_reduce(dress_jobs(i)) == 0) dress_jobs(i) = dress_jobs(i)+N_det*2
|
||||||
|
end do
|
||||||
|
|
||||||
do i=1,N_cp-1
|
do i=1,N_cp-1
|
||||||
call isort(dress_jobs(first_cp(i)+1:first_cp(i+1)),iorder,first_cp(i+1)-first_cp(i))
|
call isort(dress_jobs(first_cp(i)+1),iorder,first_cp(i+1)-first_cp(i)-1)
|
||||||
|
end do
|
||||||
|
|
||||||
|
do i=1,N_det_generators
|
||||||
|
if(dress_jobs(i) > N_det) dress_jobs(i) = dress_jobs(i) - N_det*2
|
||||||
end do
|
end do
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ subroutine dress_zmq()
|
|||||||
implicit none
|
implicit none
|
||||||
double precision, allocatable :: energy(:)
|
double precision, allocatable :: energy(:)
|
||||||
allocate (energy(N_states))
|
allocate (energy(N_states))
|
||||||
|
threshold_selectors = 1.d0
|
||||||
|
threshold_generators = 1d0
|
||||||
|
|
||||||
read_wf = .True.
|
read_wf = .True.
|
||||||
SOFT_TOUCH read_wf
|
SOFT_TOUCH read_wf
|
||||||
|
@ -63,8 +63,18 @@ BEGIN_PROVIDER [ double precision, dress_norm_acc, (0:N_det, N_states) ]
|
|||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_PROVIDER [ integer , N_det_delta_ij ]
|
||||||
|
implicit none
|
||||||
|
!N_det_delta_ij = 0!N_det
|
||||||
|
END_PROVIDER
|
||||||
|
|
||||||
BEGIN_PROVIDER [ double precision, delta_ij, (N_states, N_det, 2) ]
|
BEGIN_PROVIDER [ double precision, delta_ij, (N_states, N_det, 2) ]
|
||||||
|
implicit none
|
||||||
|
if(.true.) delta_ij(:,:N_det_delta_ij, :) = delta_ij_tmp(:,:,:)
|
||||||
|
delta_ij(:,N_det_delta_ij+1:,:) = 0d0
|
||||||
|
END_PROVIDER
|
||||||
|
|
||||||
|
BEGIN_PROVIDER [ double precision, delta_ij_tmp, (N_states,N_det_delta_ij,2) ]
|
||||||
use bitmasks
|
use bitmasks
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
@ -72,29 +82,34 @@ BEGIN_PROVIDER [ double precision, delta_ij, (N_states,N_det,2) ]
|
|||||||
|
|
||||||
double precision, allocatable :: dress(:), del(:,:), del_s2(:,:)
|
double precision, allocatable :: dress(:), del(:,:), del_s2(:,:)
|
||||||
double precision :: E_CI_before(N_states), relative_error
|
double precision :: E_CI_before(N_states), relative_error
|
||||||
! double precision, save :: errr = 0d0
|
|
||||||
|
|
||||||
allocate(dress(N_states), del(N_states, N_det), del_s2(N_states, N_det))
|
! prevents re-providing if delta_ij_tmp is
|
||||||
|
! just being copied
|
||||||
|
if(N_det_delta_ij == N_det) then
|
||||||
|
|
||||||
delta_ij = 0d0
|
allocate(dress(N_states), del(N_states, N_det_delta_ij), del_s2(N_states, N_det_delta_ij))
|
||||||
|
|
||||||
|
delta_ij_tmp = 0d0
|
||||||
|
|
||||||
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
|
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
|
||||||
threshold_selectors = 1.d0
|
threshold_selectors = 1.d0
|
||||||
threshold_generators = 1d0
|
threshold_generators = 1.d0
|
||||||
! if(errr /= 0d0) then
|
! if(errr /= 0d0) then
|
||||||
! errr = errr / 2d0
|
! errr = errr / 2d0
|
||||||
! else
|
! else
|
||||||
! errr = 1d-4
|
! errr = 1d-4
|
||||||
! end if
|
! end if
|
||||||
relative_error = 1.d-4
|
relative_error = 5.d-5
|
||||||
|
|
||||||
call write_double(6,relative_error,"Convergence of the stochastic algorithm")
|
call write_double(6,relative_error,"Convergence of the stochastic algorithm")
|
||||||
|
|
||||||
call ZMQ_dress(E_CI_before, dress, del, del_s2, abs(relative_error))
|
call ZMQ_dress(E_CI_before, dress, del, del_s2, abs(relative_error), N_det_delta_ij)
|
||||||
delta_ij(:,:,1) = del(:,:)
|
delta_ij_tmp(:,:,1) = del(:,:)
|
||||||
delta_ij(:,:,2) = del_s2(:,:)
|
delta_ij_tmp(:,:,2) = del_s2(:,:)
|
||||||
|
|
||||||
|
|
||||||
deallocate(dress, del, del_s2)
|
deallocate(dress, del, del_s2)
|
||||||
|
end if
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
integer :: i,ii,k,j, l
|
integer :: i,ii,k,j, l
|
||||||
double precision :: f, tmp
|
double precision :: f, tmp
|
||||||
double precision, external :: u_dot_v
|
double precision, external :: u_dot_v
|
||||||
|
logical, external :: detEq
|
||||||
|
|
||||||
dressing_column_h(:,:) = 0.d0
|
dressing_column_h(:,:) = 0.d0
|
||||||
dressing_column_s(:,:) = 0.d0
|
dressing_column_s(:,:) = 0.d0
|
||||||
@ -17,8 +18,8 @@
|
|||||||
do j = 1, n_det
|
do j = 1, n_det
|
||||||
dressing_column_h(j,k) = delta_ij(k,j,1)
|
dressing_column_h(j,k) = delta_ij(k,j,1)
|
||||||
dressing_column_s(j,k) = delta_ij(k,j,2)
|
dressing_column_s(j,k) = delta_ij(k,j,2)
|
||||||
|
! print *, j, delta_ij(k,j,:)
|
||||||
enddo
|
enddo
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use bitmasks
|
||||||
|
|
||||||
BEGIN_PROVIDER [ integer, fragment_count ]
|
BEGIN_PROVIDER [ integer, fragment_count ]
|
||||||
implicit none
|
implicit none
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
@ -7,16 +9,17 @@ BEGIN_PROVIDER [ integer, fragment_count ]
|
|||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
subroutine run_dress_slave(thread,iproc,energy)
|
subroutine run_dress_slave(thread,iproce,energy)
|
||||||
use f77_zmq
|
use f77_zmq
|
||||||
|
use omp_lib
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
double precision, intent(in) :: energy(N_states_diag)
|
double precision, intent(in) :: energy(N_states_diag)
|
||||||
integer, intent(in) :: thread, iproc
|
integer, intent(in) :: thread, iproce
|
||||||
integer :: rc, i, subset, i_generator
|
integer :: rc, i, subset, i_generator
|
||||||
|
|
||||||
integer :: worker_id, task_id, ctask, ltask
|
integer :: worker_id, task_id, ctask, ltask
|
||||||
character*(512) :: task
|
character*(5120) :: task
|
||||||
|
|
||||||
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
||||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
||||||
@ -30,63 +33,257 @@ subroutine run_dress_slave(thread,iproc,energy)
|
|||||||
integer :: ind
|
integer :: ind
|
||||||
|
|
||||||
double precision,allocatable :: delta_ij_loc(:,:,:)
|
double precision,allocatable :: delta_ij_loc(:,:,:)
|
||||||
double precision :: div(N_states)
|
|
||||||
integer :: h,p,n,i_state
|
integer :: h,p,n,i_state
|
||||||
logical :: ok
|
logical :: ok
|
||||||
|
|
||||||
allocate(delta_ij_loc(N_states,N_det,2))
|
integer, allocatable :: int_buf(:)
|
||||||
|
double precision, allocatable :: double_buf(:)
|
||||||
|
integer(bit_kind), allocatable :: det_buf(:,:,:)
|
||||||
|
integer :: N_buf(3)
|
||||||
|
logical :: last
|
||||||
|
!integer, external :: omp_get_thread_num
|
||||||
|
double precision, allocatable :: delta_det(:,:,:,:), cp(:,:,:,:)
|
||||||
|
integer :: toothMwen
|
||||||
|
logical :: fracted
|
||||||
|
double precision :: fac
|
||||||
|
|
||||||
|
|
||||||
|
if(iproce /= 0) stop "RUN DRESS SLAVE is OMP"
|
||||||
|
|
||||||
|
allocate(delta_det(N_states, N_det, 0:comb_teeth+1, 2))
|
||||||
|
allocate(cp(N_states, N_det, N_cp, 2))
|
||||||
|
delta_det = 0d9
|
||||||
|
cp = 0d0
|
||||||
|
|
||||||
|
|
||||||
|
task(:) = CHAR(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
integer :: iproc, cur_cp, done_for(0:N_cp)
|
||||||
|
integer, allocatable :: tasks(:)
|
||||||
|
integer :: lastCp(Nproc)
|
||||||
|
integer :: lastSent, lastSendable
|
||||||
|
logical :: send
|
||||||
|
integer(kind=OMP_LOCK_KIND) :: lck_det(0:comb_teeth+1)
|
||||||
|
integer(kind=OMP_LOCK_KIND) :: lck_sto(0:N_cp+1)
|
||||||
|
|
||||||
|
do i=0,N_cp+1
|
||||||
|
call omp_init_lock(lck_sto(i))
|
||||||
|
end do
|
||||||
|
do i=0,comb_teeth+1
|
||||||
|
call omp_init_lock(lck_det(i))
|
||||||
|
end do
|
||||||
|
|
||||||
|
lastCp = 0
|
||||||
|
lastSent = 0
|
||||||
|
send = .false.
|
||||||
|
done_for = 0
|
||||||
|
|
||||||
|
double precision :: hij, sij
|
||||||
|
!call i_h_j_s2(psi_det(1,1,1),psi_det(1,1,2),N_int,hij, sij)
|
||||||
|
|
||||||
|
hij = dress_E0_denominator(1) !PROVIDE BEFORE OMP PARALLEL
|
||||||
|
|
||||||
|
!$OMP PARALLEL DEFAULT(SHARED) &
|
||||||
|
!$OMP PRIVATE(int_buf, double_buf, det_buf, delta_ij_loc, task, task_id) &
|
||||||
|
!$OMP PRIVATE(lastSendable, toothMwen, fracted, fac) &
|
||||||
|
!$OMP PRIVATE(i, cur_cp, send, i_generator, subset, iproc, N_buf) &
|
||||||
|
!$OMP PRIVATE(zmq_to_qp_run_socket, zmq_socket_push, worker_id)
|
||||||
|
|
||||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||||
zmq_socket_push = new_zmq_push_socket(thread)
|
zmq_socket_push = new_zmq_push_socket(thread)
|
||||||
call connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread)
|
call connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread)
|
||||||
if(worker_id == -1) then
|
if(worker_id == -1) then
|
||||||
print *, "WORKER -1"
|
|
||||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||||
call end_zmq_push_socket(zmq_socket_push,thread)
|
call end_zmq_push_socket(zmq_socket_push,thread)
|
||||||
return
|
stop "WORKER -1"
|
||||||
end if
|
end if
|
||||||
do i=1,N_states
|
|
||||||
div(i) = psi_coef(dressed_column_idx(i), i)
|
|
||||||
end do
|
iproc = omp_get_thread_num()+1
|
||||||
|
allocate(int_buf(N_dress_int_buffer))
|
||||||
|
allocate(double_buf(N_dress_double_buffer))
|
||||||
|
allocate(det_buf(N_int, 2, N_dress_det_buffer))
|
||||||
|
allocate(delta_ij_loc(N_states,N_det,2))
|
||||||
do
|
do
|
||||||
call get_task_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task)
|
call get_task_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task)
|
||||||
|
task = task//" 0"
|
||||||
|
if(task_id == 0) exit
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
if(task_id /= 0) then
|
if(task_id /= 0) then
|
||||||
read (task,*) subset, i_generator
|
read (task,*) subset, i_generator
|
||||||
delta_ij_loc = 0d0
|
|
||||||
call alpha_callback(delta_ij_loc, i_generator, subset, iproc)
|
|
||||||
|
|
||||||
call task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id)
|
!$OMP ATOMIC
|
||||||
call push_dress_results(zmq_socket_push, i_generator, delta_ij_loc, task_id)
|
done_for(done_cp_at_det(i_generator)) += 1
|
||||||
else
|
! print *, "IGEN", i_generator, done_cp_at_det(i_generator)
|
||||||
exit
|
delta_ij_loc(:,:,:) = 0d0
|
||||||
end if
|
call generator_start(i_generator, iproc)
|
||||||
|
call alpha_callback(delta_ij_loc, i_generator, subset, iproc)
|
||||||
|
call generator_done(i_generator, int_buf, double_buf, det_buf, N_buf, iproc)
|
||||||
|
|
||||||
|
do i=1,N_cp
|
||||||
|
fac = cps(i_generator, i) * dress_weight_inv(i_generator) * comb_step
|
||||||
|
if(fac == 0d0) cycle
|
||||||
|
call omp_set_lock(lck_sto(i))
|
||||||
|
cp(:,:,i,1) += (delta_ij_loc(:,:,1) * fac)
|
||||||
|
cp(:,:,i,2) += (delta_ij_loc(:,:,2) * fac)
|
||||||
|
call omp_unset_lock(lck_sto(i))
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
|
||||||
|
toothMwen = tooth_of_det(i_generator)
|
||||||
|
fracted = (toothMwen /= 0)
|
||||||
|
if(fracted) fracted = (i_generator == first_det_of_teeth(toothMwen))
|
||||||
|
if(fracted) then
|
||||||
|
call omp_set_lock(lck_det(toothMwen))
|
||||||
|
call omp_set_lock(lck_det(toothMwen-1))
|
||||||
|
delta_det(:,:,toothMwen-1, 1) += delta_ij_loc(:,:,1) * (1d0-fractage(toothMwen))
|
||||||
|
delta_det(:,:,toothMwen-1, 2) += delta_ij_loc(:,:,2) * (1d0-fractage(toothMwen))
|
||||||
|
delta_det(:,:,toothMwen , 1) += delta_ij_loc(:,:,1) * (fractage(toothMwen))
|
||||||
|
delta_det(:,:,toothMwen , 2) += delta_ij_loc(:,:,2) * (fractage(toothMwen))
|
||||||
|
call omp_unset_lock(lck_det(toothMwen))
|
||||||
|
call omp_unset_lock(lck_det(toothMwen-1))
|
||||||
|
else
|
||||||
|
call omp_set_lock(lck_det(toothMwen))
|
||||||
|
delta_det(:,:,toothMwen , 1) += delta_ij_loc(:,:,1)
|
||||||
|
delta_det(:,:,toothMwen , 2) += delta_ij_loc(:,:,2)
|
||||||
|
call omp_unset_lock(lck_det(toothMwen))
|
||||||
|
end if
|
||||||
|
call push_dress_results(zmq_socket_push, i_generator, -1, delta_ij_loc, int_buf, double_buf, det_buf, N_buf, task_id)
|
||||||
|
call task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id)
|
||||||
|
lastCp(iproc) = done_cp_at_det(i_generator)
|
||||||
|
end if
|
||||||
|
|
||||||
|
!$OMP CRITICAL
|
||||||
|
send = .false.
|
||||||
|
lastSendable = N_cp*2
|
||||||
|
do i=1,Nproc
|
||||||
|
lastSendable = min(lastCp(i), lastSendable)
|
||||||
|
end do
|
||||||
|
lastSendable -= 1
|
||||||
|
if(lastSendable > lastSent .or. (lastSendable == N_cp-1 .and. lastSent /= N_cp-1)) then
|
||||||
|
lastSent = lastSendable
|
||||||
|
cur_cp = lastSent
|
||||||
|
send = .true.
|
||||||
|
end if
|
||||||
|
!$OMP END CRITICAL
|
||||||
|
|
||||||
|
if(send) then
|
||||||
|
N_buf = (/0,1,0/)
|
||||||
|
|
||||||
|
delta_ij_loc = 0d0
|
||||||
|
if(cur_cp < 1) stop "cur_cp < 1"
|
||||||
|
do i=1,cur_cp
|
||||||
|
delta_ij_loc(:,:,1) += cp(:,:,i,1)
|
||||||
|
delta_ij_loc(:,:,2) += cp(:,:,i,2)
|
||||||
|
end do
|
||||||
|
|
||||||
|
delta_ij_loc(:,:,:) = delta_ij_loc(:,:,:) / cps_N(cur_cp)
|
||||||
|
do i=cp_first_tooth(cur_cp)-1,0,-1
|
||||||
|
delta_ij_loc(:,:,1) = delta_ij_loc(:,:,1) +delta_det(:,:,i,1)
|
||||||
|
delta_ij_loc(:,:,2) = delta_ij_loc(:,:,2) +delta_det(:,:,i,2)
|
||||||
|
end do
|
||||||
|
call push_dress_results(zmq_socket_push, done_for(cur_cp), cur_cp, delta_ij_loc, int_buf, double_buf, det_buf, N_buf, -1)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if(task_id == 0) exit
|
||||||
|
end do
|
||||||
|
|
||||||
call disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id)
|
call disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id)
|
||||||
call end_zmq_push_socket(zmq_socket_push,thread)
|
|
||||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||||
|
call end_zmq_push_socket(zmq_socket_push,thread)
|
||||||
|
!$OMP END PARALLEL
|
||||||
|
|
||||||
|
do i=0,N_cp+1
|
||||||
|
call omp_destroy_lock(lck_sto(i))
|
||||||
|
end do
|
||||||
|
do i=0,comb_teeth+1
|
||||||
|
call omp_destroy_lock(lck_det(i))
|
||||||
|
end do
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
subroutine push_dress_results(zmq_socket_push, ind, delta_loc, task_id)
|
|
||||||
|
|
||||||
|
subroutine push_dress_results(zmq_socket_push, ind, cur_cp, delta_loc, int_buf, double_buf, det_buf, N_bufi, task_id)
|
||||||
use f77_zmq
|
use f77_zmq
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
|
integer, parameter :: sendt = 4
|
||||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_push
|
integer(ZMQ_PTR), intent(in) :: zmq_socket_push
|
||||||
double precision, intent(in) :: delta_loc(N_states, N_det, 2)
|
double precision, intent(inout) :: delta_loc(N_states, N_det, 2)
|
||||||
integer, intent(in) :: ind, task_id
|
real(kind=4), allocatable :: delta_loc4(:,:,:)
|
||||||
integer :: rc, i
|
double precision, intent(in) :: double_buf(*)
|
||||||
|
integer, intent(in) :: int_buf(*)
|
||||||
|
integer(bit_kind), intent(in) :: det_buf(N_int, 2, *)
|
||||||
|
integer, intent(in) :: N_bufi(3)
|
||||||
|
integer :: N_buf(3)
|
||||||
|
integer, intent(in) :: ind, cur_cp, task_id
|
||||||
|
integer :: rc, i, j, k, l
|
||||||
|
double precision :: contrib(N_states)
|
||||||
|
real(sendt), allocatable :: r4buf(:,:,:)
|
||||||
|
|
||||||
rc = f77_zmq_send( zmq_socket_push, ind, 4, ZMQ_SNDMORE)
|
rc = f77_zmq_send( zmq_socket_push, ind, 4, ZMQ_SNDMORE)
|
||||||
if(rc /= 4) stop "push"
|
if(rc /= 4) stop "push"
|
||||||
|
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, cur_cp, 4, ZMQ_SNDMORE)
|
||||||
|
if(rc /= 4) stop "push"
|
||||||
|
|
||||||
rc = f77_zmq_send( zmq_socket_push, delta_loc, 8*N_states*N_det*2, ZMQ_SNDMORE)
|
|
||||||
if(rc /= 8*N_states*N_det*2) stop "push"
|
if(cur_cp /= -1) then
|
||||||
|
allocate(r4buf(N_states, N_det, 2))
|
||||||
|
do i=1,2
|
||||||
|
do j=1,N_det
|
||||||
|
do k=1,N_states
|
||||||
|
r4buf(k,j,i) = real(delta_loc(k,j,i), sendt)
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, r4buf(1,1,1), sendt*N_states*N_det, ZMQ_SNDMORE)
|
||||||
|
if(rc /= sendt*N_states*N_det) stop "push"
|
||||||
|
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, r4buf(1,1,2), sendt*N_states*N_det, ZMQ_SNDMORE)
|
||||||
|
if(rc /= sendt*N_states*N_det) stop "push"
|
||||||
|
else
|
||||||
|
contrib = 0d0
|
||||||
|
do i=1,N_det
|
||||||
|
contrib(:) += delta_loc(:,i, 1) * psi_coef(i, :)
|
||||||
|
end do
|
||||||
|
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, contrib, 8*N_states, ZMQ_SNDMORE)
|
||||||
|
if(rc /= 8*N_states) stop "push"
|
||||||
|
|
||||||
|
N_buf = N_bufi
|
||||||
|
!N_buf = (/0,1,0/)
|
||||||
|
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, N_buf, 4*3, ZMQ_SNDMORE)
|
||||||
|
if(rc /= 4*3) stop "push5"
|
||||||
|
|
||||||
|
if(N_buf(1) > N_dress_int_buffer) stop "run_dress_slave N_buf bad size?"
|
||||||
|
if(N_buf(2) > N_dress_double_buffer) stop "run_dress_slave N_buf bad size?"
|
||||||
|
if(N_buf(3) > N_dress_det_buffer) stop "run_dress_slave N_buf bad size?"
|
||||||
|
|
||||||
|
|
||||||
|
if(N_buf(1) > 0) then
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, int_buf, 4*N_buf(1), ZMQ_SNDMORE)
|
||||||
|
if(rc /= 4*N_buf(1)) stop "push6"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if(N_buf(2) > 0) then
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, double_buf, 8*N_buf(2), ZMQ_SNDMORE)
|
||||||
|
if(rc /= 8*N_buf(2)) stop "push8"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if(N_buf(3) > 0) then
|
||||||
|
rc = f77_zmq_send( zmq_socket_push, det_buf, 2*N_int*bit_kind*N_buf(3), ZMQ_SNDMORE)
|
||||||
|
if(rc /= 2*N_int*bit_kind*N_buf(3)) stop "push10"
|
||||||
|
end if
|
||||||
|
|
||||||
rc = f77_zmq_send( zmq_socket_push, task_id, 4, 0)
|
rc = f77_zmq_send( zmq_socket_push, task_id, 4, 0)
|
||||||
if(rc /= 4) stop "push"
|
if(rc /= 4) stop "push11"
|
||||||
|
end if
|
||||||
|
|
||||||
! Activate is zmq_socket_push is a REQ
|
! Activate is zmq_socket_push is a REQ
|
||||||
IRP_IF ZMQ_PUSH
|
IRP_IF ZMQ_PUSH
|
||||||
@ -98,25 +295,80 @@ IRP_ENDIF
|
|||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
subroutine pull_dress_results(zmq_socket_pull, ind, delta_loc, task_id)
|
BEGIN_PROVIDER [ real(4), real4buf, (N_states, N_det, 2) ]
|
||||||
|
|
||||||
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
|
subroutine pull_dress_results(zmq_socket_pull, ind, cur_cp, delta_loc, int_buf, double_buf, det_buf, N_buf, task_id, contrib)
|
||||||
use f77_zmq
|
use f77_zmq
|
||||||
implicit none
|
implicit none
|
||||||
|
integer, parameter :: sendt = 4
|
||||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
|
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
|
||||||
|
integer, intent(out) :: cur_cp
|
||||||
double precision, intent(inout) :: delta_loc(N_states, N_det, 2)
|
double precision, intent(inout) :: delta_loc(N_states, N_det, 2)
|
||||||
|
double precision, intent(out) :: double_buf(*), contrib(N_states)
|
||||||
|
integer, intent(out) :: int_buf(*)
|
||||||
|
integer(bit_kind), intent(out) :: det_buf(N_int, 2, *)
|
||||||
integer, intent(out) :: ind
|
integer, intent(out) :: ind
|
||||||
integer, intent(out) :: task_id
|
integer, intent(out) :: task_id
|
||||||
integer :: rc, i
|
integer :: rc, i, j, k
|
||||||
|
integer, intent(out) :: N_buf(3)
|
||||||
|
|
||||||
rc = f77_zmq_recv( zmq_socket_pull, ind, 4, 0)
|
rc = f77_zmq_recv( zmq_socket_pull, ind, 4, 0)
|
||||||
if(rc /= 4) stop "pull"
|
if(rc /= 4) stop "pulla"
|
||||||
|
|
||||||
rc = f77_zmq_recv( zmq_socket_pull, delta_loc, N_states*8*N_det*2, 0)
|
rc = f77_zmq_recv( zmq_socket_pull, cur_cp, 4, 0)
|
||||||
if(rc /= 8*N_states*N_det*2) stop "pull"
|
if(rc /= 4) stop "pulla"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(cur_cp /= -1) then
|
||||||
|
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, real4buf(1,1,1), N_states*sendt*N_det, 0)
|
||||||
|
if(rc /= sendt*N_states*N_det) stop "pullc"
|
||||||
|
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, real4buf(1,1,2), N_states*sendt*N_det, 0)
|
||||||
|
if(rc /= sendt*N_states*N_det) stop "pulld"
|
||||||
|
|
||||||
|
do i=1,2
|
||||||
|
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(j,k)
|
||||||
|
do j=1,N_det
|
||||||
|
do k=1,N_states
|
||||||
|
delta_loc(k,j,i) = real(real4buf(k,j,i), 8)
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
else
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, contrib, 8*N_states, 0)
|
||||||
|
if(rc /= 8*N_states) stop "pullc"
|
||||||
|
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, N_buf, 4*3, 0)
|
||||||
|
if(rc /= 4*3) stop "pull"
|
||||||
|
if(N_buf(1) > N_dress_int_buffer) stop "run_dress_slave N_buf bad size?"
|
||||||
|
if(N_buf(2) > N_dress_double_buffer) stop "run_dress_slave N_buf bad size?"
|
||||||
|
if(N_buf(3) > N_dress_det_buffer) stop "run_dress_slave N_buf bad size?"
|
||||||
|
|
||||||
|
|
||||||
|
if(N_buf(1) > 0) then
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, int_buf, 4*N_buf(1), 0)
|
||||||
|
if(rc /= 4*N_buf(1)) stop "pull1"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if(N_buf(2) > 0) then
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, double_buf, 8*N_buf(2), 0)
|
||||||
|
if(rc /= 8*N_buf(2)) stop "pull2"
|
||||||
|
end if
|
||||||
|
|
||||||
|
if(N_buf(3) > 0) then
|
||||||
|
rc = f77_zmq_recv( zmq_socket_pull, det_buf, 2*N_int*bit_kind*N_buf(3), 0)
|
||||||
|
if(rc /= 2*N_int*bit_kind*N_buf(3)) stop "pull3"
|
||||||
|
end if
|
||||||
|
|
||||||
rc = f77_zmq_recv( zmq_socket_pull, task_id, 4, 0)
|
rc = f77_zmq_recv( zmq_socket_pull, task_id, 4, 0)
|
||||||
if(rc /= 4) stop "pull"
|
if(rc /= 4) stop "pull4"
|
||||||
|
end if
|
||||||
! Activate is zmq_socket_pull is a REP
|
! Activate is zmq_socket_pull is a REP
|
||||||
IRP_IF ZMQ_PUSH
|
IRP_IF ZMQ_PUSH
|
||||||
IRP_ELSE
|
IRP_ELSE
|
||||||
|
@ -1,20 +1,3 @@
|
|||||||
[energy]
|
|
||||||
type: double precision
|
|
||||||
doc: Calculated energy
|
|
||||||
interface: ezfio
|
|
||||||
|
|
||||||
[thresh_dressed_ci]
|
|
||||||
type: Threshold
|
|
||||||
doc: Threshold on the convergence of the dressed CI energy
|
|
||||||
interface: ezfio,provider,ocaml
|
|
||||||
default: 1.e-5
|
|
||||||
|
|
||||||
[n_it_max_dressed_ci]
|
|
||||||
type: Strictly_positive_int
|
|
||||||
doc: Maximum number of dressed CI iterations
|
|
||||||
interface: ezfio,provider,ocaml
|
|
||||||
default: 10
|
|
||||||
|
|
||||||
[h0_type]
|
[h0_type]
|
||||||
type: Perturbation
|
type: Perturbation
|
||||||
doc: Type of zeroth-order Hamiltonian [ EN | Barycentric ]
|
doc: Type of zeroth-order Hamiltonian [ EN | Barycentric ]
|
||||||
|
@ -1 +1 @@
|
|||||||
dress_zmq DavidsonDressed
|
dress_zmq DavidsonDressed Selectors_full Generators_full
|
||||||
|
139
plugins/shiftedbk/selection_buffer.irp.f
Normal file
139
plugins/shiftedbk/selection_buffer.irp.f
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
|
||||||
|
subroutine create_selection_buffer(N, siz_, res)
|
||||||
|
use selection_types
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer, intent(in) :: N, siz_
|
||||||
|
type(selection_buffer), intent(out) :: res
|
||||||
|
|
||||||
|
integer :: siz
|
||||||
|
siz = max(siz_,1)
|
||||||
|
allocate(res%det(N_int, 2, siz), res%val(siz))
|
||||||
|
|
||||||
|
res%val(:) = 0d0
|
||||||
|
res%det(:,:,:) = 0_8
|
||||||
|
res%N = N
|
||||||
|
res%mini = 0d0
|
||||||
|
res%cur = 0
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
subroutine delete_selection_buffer(b)
|
||||||
|
use selection_types
|
||||||
|
implicit none
|
||||||
|
type(selection_buffer), intent(inout) :: b
|
||||||
|
if (associated(b%det)) then
|
||||||
|
deallocate(b%det)
|
||||||
|
endif
|
||||||
|
if (associated(b%val)) then
|
||||||
|
deallocate(b%val)
|
||||||
|
endif
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
subroutine add_to_selection_buffer(b, det, val)
|
||||||
|
use selection_types
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
type(selection_buffer), intent(inout) :: b
|
||||||
|
integer(bit_kind), intent(in) :: det(N_int, 2)
|
||||||
|
double precision, intent(in) :: val
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
if(b%N > 0 .and. val <= b%mini) then
|
||||||
|
b%cur += 1
|
||||||
|
b%det(1:N_int,1:2,b%cur) = det(1:N_int,1:2)
|
||||||
|
b%val(b%cur) = val
|
||||||
|
if(b%cur == size(b%val)) then
|
||||||
|
call sort_selection_buffer(b)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
subroutine merge_selection_buffers(b1, b2)
|
||||||
|
use selection_types
|
||||||
|
implicit none
|
||||||
|
BEGIN_DOC
|
||||||
|
! Merges the selection buffers b1 and b2 into b2
|
||||||
|
END_DOC
|
||||||
|
type(selection_buffer), intent(inout) :: b1
|
||||||
|
type(selection_buffer), intent(inout) :: b2
|
||||||
|
integer(bit_kind), pointer :: detmp(:,:,:)
|
||||||
|
double precision, pointer :: val(:)
|
||||||
|
integer :: i, i1, i2, k, nmwen
|
||||||
|
if (b1%cur == 0) return
|
||||||
|
do while (b1%val(b1%cur) > b2%mini)
|
||||||
|
b1%cur = b1%cur-1
|
||||||
|
if (b1%cur == 0) then
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
nmwen = min(b1%N, b1%cur+b2%cur)
|
||||||
|
allocate( val(size(b1%val)), detmp(N_int, 2, size(b1%det,3)) )
|
||||||
|
i1=1
|
||||||
|
i2=1
|
||||||
|
do i=1,nmwen
|
||||||
|
if ( (i1 > b1%cur).and.(i2 > b2%cur) ) then
|
||||||
|
exit
|
||||||
|
else if (i1 > b1%cur) then
|
||||||
|
val(i) = b2%val(i2)
|
||||||
|
detmp(1:N_int,1,i) = b2%det(1:N_int,1,i2)
|
||||||
|
detmp(1:N_int,2,i) = b2%det(1:N_int,2,i2)
|
||||||
|
i2=i2+1
|
||||||
|
else if (i2 > b2%cur) then
|
||||||
|
val(i) = b1%val(i1)
|
||||||
|
detmp(1:N_int,1,i) = b1%det(1:N_int,1,i1)
|
||||||
|
detmp(1:N_int,2,i) = b1%det(1:N_int,2,i1)
|
||||||
|
i1=i1+1
|
||||||
|
else
|
||||||
|
if (b1%val(i1) <= b2%val(i2)) then
|
||||||
|
val(i) = b1%val(i1)
|
||||||
|
detmp(1:N_int,1,i) = b1%det(1:N_int,1,i1)
|
||||||
|
detmp(1:N_int,2,i) = b1%det(1:N_int,2,i1)
|
||||||
|
i1=i1+1
|
||||||
|
else
|
||||||
|
val(i) = b2%val(i2)
|
||||||
|
detmp(1:N_int,1,i) = b2%det(1:N_int,1,i2)
|
||||||
|
detmp(1:N_int,2,i) = b2%det(1:N_int,2,i2)
|
||||||
|
i2=i2+1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
deallocate(b2%det, b2%val)
|
||||||
|
do i=nmwen+1,b2%N
|
||||||
|
val(i) = 0.d0
|
||||||
|
detmp(1:N_int,1:2,i) = 0_bit_kind
|
||||||
|
enddo
|
||||||
|
b2%det => detmp
|
||||||
|
b2%val => val
|
||||||
|
b2%mini = min(b2%mini,b2%val(b2%N))
|
||||||
|
b2%cur = nmwen
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
subroutine sort_selection_buffer(b)
|
||||||
|
use selection_types
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
type(selection_buffer), intent(inout) :: b
|
||||||
|
integer, allocatable :: iorder(:)
|
||||||
|
integer(bit_kind), pointer :: detmp(:,:,:)
|
||||||
|
integer :: i, nmwen
|
||||||
|
logical, external :: detEq
|
||||||
|
if (b%N == 0 .or. b%cur == 0) return
|
||||||
|
nmwen = min(b%N, b%cur)
|
||||||
|
|
||||||
|
allocate(iorder(b%cur), detmp(N_int, 2, size(b%det,3)))
|
||||||
|
do i=1,b%cur
|
||||||
|
iorder(i) = i
|
||||||
|
end do
|
||||||
|
call dsort(b%val, iorder, b%cur)
|
||||||
|
do i=1, nmwen
|
||||||
|
detmp(1:N_int,1,i) = b%det(1:N_int,1,iorder(i))
|
||||||
|
detmp(1:N_int,2,i) = b%det(1:N_int,2,iorder(i))
|
||||||
|
end do
|
||||||
|
deallocate(b%det,iorder)
|
||||||
|
b%det => detmp
|
||||||
|
b%mini = min(b%mini,b%val(b%N))
|
||||||
|
b%cur = nmwen
|
||||||
|
end subroutine
|
||||||
|
|
9
plugins/shiftedbk/selection_types.f90
Normal file
9
plugins/shiftedbk/selection_types.f90
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module selection_types
|
||||||
|
type selection_buffer
|
||||||
|
integer :: N, cur
|
||||||
|
integer(8) , pointer :: det(:,:,:)
|
||||||
|
double precision, pointer :: val(:)
|
||||||
|
double precision :: mini
|
||||||
|
endtype
|
||||||
|
end module
|
||||||
|
|
@ -4,6 +4,13 @@ program shifted_bk
|
|||||||
! TODO
|
! TODO
|
||||||
END_DOC
|
END_DOC
|
||||||
|
|
||||||
call diagonalize_CI()
|
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||||
|
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||||
|
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||||
|
PROVIDE psi_bilinear_matrix_transp_order
|
||||||
|
|
||||||
|
|
||||||
|
!call diagonalize_CI()
|
||||||
call dress_zmq()
|
call dress_zmq()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,15 +1,274 @@
|
|||||||
|
use selection_types
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_PROVIDER [ double precision, global_sum_alpha2, (N_states) ]
|
||||||
|
&BEGIN_PROVIDER [ double precision, slave_sum_alpha2, (N_states, Nproc) ]
|
||||||
|
global_sum_alpha2 = 0d0
|
||||||
|
slave_sum_alpha2 = 0d0
|
||||||
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
BEGIN_PROVIDER [ double precision, fock_diag_tmp_, (2,mo_tot_num+1,Nproc) ]
|
BEGIN_PROVIDER [ double precision, fock_diag_tmp_, (2,mo_tot_num+1,Nproc) ]
|
||||||
&BEGIN_PROVIDER [ integer, current_generator_, (Nproc) ]
|
&BEGIN_PROVIDER [ integer, n_det_add ]
|
||||||
&BEGIN_PROVIDER [ double precision, a_h_i, (N_det, Nproc) ]
|
&BEGIN_PROVIDER [ double precision, a_h_i, (N_det, Nproc) ]
|
||||||
&BEGIN_PROVIDER [ double precision, a_s2_i, (N_det, Nproc) ]
|
&BEGIN_PROVIDER [ double precision, a_s2_i, (N_det, Nproc) ]
|
||||||
|
&BEGIN_PROVIDER [ type(selection_buffer), sb, (Nproc) ]
|
||||||
|
&BEGIN_PROVIDER [ type(selection_buffer), global_sb ]
|
||||||
|
&BEGIN_PROVIDER [ type(selection_buffer), mini_sb ]
|
||||||
|
&BEGIN_PROVIDER [ double precision, N_det_increase_factor ]
|
||||||
implicit none
|
implicit none
|
||||||
current_generator_(:) = 0
|
|
||||||
fock_diag_tmp_(:,:,:) = 0.d0
|
fock_diag_tmp_(:,:,:) = 0.d0
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
N_det_increase_factor = 1d0
|
||||||
|
|
||||||
|
|
||||||
|
n_det_add = max(1, int(float(N_det) * N_det_increase_factor))
|
||||||
|
call create_selection_buffer(n_det_add, n_det_add*2, global_sb)
|
||||||
|
call create_selection_buffer(n_det_add, n_det_add*2, mini_sb)
|
||||||
|
do i=1,Nproc
|
||||||
|
call create_selection_buffer(n_det_add, n_det_add*2, sb(i))
|
||||||
|
end do
|
||||||
a_h_i = 0d0
|
a_h_i = 0d0
|
||||||
a_s2_i = 0d0
|
a_s2_i = 0d0
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_PROVIDER [ integer, N_dress_int_buffer ]
|
||||||
|
&BEGIN_PROVIDER [ integer, N_dress_double_buffer ]
|
||||||
|
&BEGIN_PROVIDER [ integer, N_dress_det_buffer ]
|
||||||
|
implicit none
|
||||||
|
N_dress_int_buffer = 1
|
||||||
|
N_dress_double_buffer = n_det_add+N_states
|
||||||
|
N_dress_det_buffer = n_det_add
|
||||||
|
END_PROVIDER
|
||||||
|
|
||||||
|
|
||||||
|
subroutine generator_done(i_gen, int_buf, double_buf, det_buf, N_buf, iproc)
|
||||||
|
implicit none
|
||||||
|
integer, intent(in) :: i_gen, iproc
|
||||||
|
integer, intent(out) :: int_buf(N_dress_int_buffer), N_buf(3)
|
||||||
|
double precision, intent(out) :: double_buf(N_dress_double_buffer)
|
||||||
|
integer(bit_kind), intent(out) :: det_buf(N_int, 2, N_dress_det_buffer)
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
call sort_selection_buffer(sb(iproc))
|
||||||
|
det_buf(:,:,:sb(iproc)%cur) = sb(iproc)%det(:,:,:sb(iproc)%cur)
|
||||||
|
double_buf(:sb(iproc)%cur) = sb(iproc)%val(:sb(iproc)%cur)
|
||||||
|
double_buf(sb(iproc)%cur+1:sb(iproc)%cur+N_states) = slave_sum_alpha2(:,iproc)
|
||||||
|
N_buf(1) = 1
|
||||||
|
N_buf(2) = sb(iproc)%cur+N_states
|
||||||
|
N_buf(3) = sb(iproc)%cur
|
||||||
|
|
||||||
|
if(sb(iproc)%cur > 0) then
|
||||||
|
!$OMP CRITICAL
|
||||||
|
call merge_selection_buffers(sb(iproc), mini_sb)
|
||||||
|
!call sort_selection_buffer(mini_sb)
|
||||||
|
do i=1,Nproc
|
||||||
|
sb(i)%mini = min(sb(i)%mini, mini_sb%mini)
|
||||||
|
end do
|
||||||
|
!$OMP END CRITICAL
|
||||||
|
end if
|
||||||
|
|
||||||
|
sb(iproc)%cur = 0
|
||||||
|
slave_sum_alpha2(:,iproc) = 0d0
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
|
subroutine generator_start(i_gen, iproc)
|
||||||
|
implicit none
|
||||||
|
integer, intent(in) :: i_gen, iproc
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
call build_fock_tmp(fock_diag_tmp_(1,1,iproc),psi_det_generators(1,1,i_gen),N_int)
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
|
subroutine dress_pulled(ind, int_buf, double_buf, det_buf, N_buf)
|
||||||
|
use bitmasks
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer, intent(in) :: ind, N_buf(3)
|
||||||
|
integer, intent(in) :: int_buf(*)
|
||||||
|
double precision, intent(in) :: double_buf(*)
|
||||||
|
integer(bit_kind), intent(in) :: det_buf(N_int,2,*)
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
do i=1,N_buf(3)
|
||||||
|
call add_to_selection_buffer(global_sb, det_buf(1,1,i), double_buf(i))
|
||||||
|
end do
|
||||||
|
if(N_buf(3) + N_states /= N_buf(2)) stop "buf size"
|
||||||
|
!$OMP CRITICAL
|
||||||
|
global_sum_alpha2(:) += double_buf(N_buf(3)+1:N_buf(2))
|
||||||
|
!$OMP END CRITICAL
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
|
subroutine delta_ij_done()
|
||||||
|
use bitmasks
|
||||||
|
implicit none
|
||||||
|
integer :: i, old_det_gen
|
||||||
|
integer(bit_kind), allocatable :: old_generators(:,:,:)
|
||||||
|
|
||||||
|
allocate(old_generators(N_int, 2, N_det_generators))
|
||||||
|
old_generators(:,:,:) = psi_det_generators(:,:,:N_det_generators)
|
||||||
|
old_det_gen = N_det_generators
|
||||||
|
|
||||||
|
|
||||||
|
call sort_selection_buffer(global_sb)
|
||||||
|
call fill_H_apply_buffer_no_selection(global_sb%cur,global_sb%det,N_int,0)
|
||||||
|
call copy_H_apply_buffer_to_wf()
|
||||||
|
|
||||||
|
if (s2_eig.or.(N_states > 1) ) then
|
||||||
|
call make_s2_eigenfunction
|
||||||
|
endif
|
||||||
|
call undress_with_alpha(old_generators, old_det_gen, psi_det(1,1,N_det_delta_ij+1), N_det-N_det_delta_ij)
|
||||||
|
call save_wavefunction
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
|
subroutine undress_with_alpha(old_generators, old_det_gen, alpha, n_alpha)
|
||||||
|
use bitmasks
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer(bit_kind), intent(in) :: alpha(N_int,2,n_alpha)
|
||||||
|
integer, intent(in) :: n_alpha
|
||||||
|
integer, allocatable :: minilist(:)
|
||||||
|
integer(bit_kind), allocatable :: det_minilist(:,:,:)
|
||||||
|
double precision, allocatable :: delta_ij_loc(:,:,:,:)
|
||||||
|
integer :: exc(0:2,2,2), h1, h2, p1, p2, s1, s2
|
||||||
|
integer :: i, j, k, ex, n_minilist, iproc, degree
|
||||||
|
double precision :: haa, contrib, phase, c_alpha(N_states,Nproc), s_c_alpha(N_states)
|
||||||
|
logical :: ok
|
||||||
|
integer, external :: omp_get_thread_num
|
||||||
|
|
||||||
|
integer,intent(in) :: old_det_gen
|
||||||
|
integer(bit_kind), intent(in) :: old_generators(N_int, 2, old_det_gen)
|
||||||
|
|
||||||
|
allocate(minilist(N_det_delta_ij), det_minilist(N_int, 2, N_det_delta_ij), delta_ij_loc(N_states, N_det_delta_ij, 2, Nproc))
|
||||||
|
|
||||||
|
c_alpha = 0d0
|
||||||
|
delta_ij_loc = 0d0
|
||||||
|
|
||||||
|
!$OMP PARALLEL DO DEFAULT(SHARED) SCHEDULE(STATIC) PRIVATE(i, j, iproc, n_minilist, ex) &
|
||||||
|
!$OMP PRIVATE(det_minilist, minilist, haa, contrib, s_c_alpha) &
|
||||||
|
!$OMP PRIVATE(exc, h1, h2, p1, p2, s1, s2, phase, degree, ok)
|
||||||
|
do i=n_alpha,1,-1
|
||||||
|
iproc = omp_get_thread_num()+1
|
||||||
|
if(mod(i,10000) == 0) print *, "UNDRESSING", i, "/", n_alpha, iproc
|
||||||
|
n_minilist = 0
|
||||||
|
ok = .false.
|
||||||
|
|
||||||
|
do j=1, old_det_gen
|
||||||
|
call get_excitation_degree(alpha(1,1,i), old_generators(1,1,j), ex, N_int)
|
||||||
|
if(ex <= 2) then
|
||||||
|
call get_excitation(old_generators(1,1,j), alpha(1,1,i), exc,degree,phase,N_int)
|
||||||
|
call decode_exc(exc,degree,h1,p1,h2,p2,s1,s2)
|
||||||
|
ok = (mo_class(h1)(1:1) == 'A' .or. mo_class(h1)(1:1) == 'I') .and. &
|
||||||
|
(mo_class(p1)(1:1) == 'A' .or. mo_class(p1)(1:1) == 'V')
|
||||||
|
if(ok .and. degree == 2) then
|
||||||
|
ok = (mo_class(h2)(1:1) == 'A' .or. mo_class(h2)(1:1) == 'I') .and. &
|
||||||
|
(mo_class(p2)(1:1) == 'A' .or. mo_class(p2)(1:1) == 'V')
|
||||||
|
end if
|
||||||
|
if(ok) exit
|
||||||
|
end if
|
||||||
|
end do
|
||||||
|
|
||||||
|
if(.not. ok) cycle
|
||||||
|
|
||||||
|
do j=1, N_det_delta_ij
|
||||||
|
call get_excitation_degree(alpha(1,1,i), psi_det(1,1,j), ex, N_int)
|
||||||
|
if(ex <= 2) then
|
||||||
|
n_minilist += 1
|
||||||
|
det_minilist(:,:,n_minilist) = psi_det(:,:,j)
|
||||||
|
minilist(n_minilist) = j
|
||||||
|
end if
|
||||||
|
end do
|
||||||
|
call i_h_j(alpha(1,1,i), alpha(1,1,i), N_int, haa)
|
||||||
|
call dress_with_alpha_(N_states, N_det_delta_ij, N_int, delta_ij_loc(1,1,1,iproc), &
|
||||||
|
minilist, det_minilist, n_minilist, alpha(1,1,i), haa, contrib, s_c_alpha, iproc)
|
||||||
|
|
||||||
|
c_alpha(:,iproc) += s_c_alpha(:)**2
|
||||||
|
end do
|
||||||
|
!$OMP END PARALLEL DO
|
||||||
|
|
||||||
|
do i=2,Nproc
|
||||||
|
delta_ij_loc(:,:,:,1) += delta_ij_loc(:,:,:,i)
|
||||||
|
c_alpha(:,1) += c_alpha(:,i)
|
||||||
|
end do
|
||||||
|
|
||||||
|
|
||||||
|
delta_ij_tmp(:,:,1) -= delta_ij_loc(:,:,1,1)
|
||||||
|
delta_ij_tmp(:,:,2) -= delta_ij_loc(:,:,2,1)
|
||||||
|
|
||||||
|
!print *, "SUM ALPHA2 PRE", global_sum_alpha2
|
||||||
|
!global_sum_alpha2(:) -= c_alpha(:,1)
|
||||||
|
print *, "SUM C_ALPHA^2 =", global_sum_alpha2(:)
|
||||||
|
!print *, "*** DRESSINS DIVIDED BY 1+SUM C_ALPHA^2 ***"
|
||||||
|
!do i=1,N_states
|
||||||
|
! delta_ij_tmp(i,:,:) = delta_ij_tmp(i,:,:) / (1d0 + global_sum_alpha2(i))
|
||||||
|
!end do
|
||||||
|
global_sum_alpha2 = 0d0
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
|
subroutine dress_with_alpha_(Nstates,Ndet,Nint,delta_ij_loc,minilist, det_minilist, n_minilist, alpha, haa, contrib, c_alpha, iproc)
|
||||||
|
use bitmasks
|
||||||
|
implicit none
|
||||||
|
BEGIN_DOC
|
||||||
|
!delta_ij_loc(:,:,1) : dressing column for H
|
||||||
|
!delta_ij_loc(:,:,2) : dressing column for S2
|
||||||
|
!minilist : indices of determinants connected to alpha ( in psi_det_sorted )
|
||||||
|
!n_minilist : size of minilist
|
||||||
|
!alpha : alpha determinant
|
||||||
|
END_DOC
|
||||||
|
integer, intent(in) :: Nint, Ndet, Nstates, n_minilist, iproc
|
||||||
|
integer(bit_kind), intent(in) :: alpha(Nint,2), det_minilist(Nint, 2, n_minilist)
|
||||||
|
integer,intent(in) :: minilist(n_minilist)
|
||||||
|
double precision, intent(inout) :: delta_ij_loc(Nstates,N_det,2)
|
||||||
|
double precision, intent(out) :: contrib, c_alpha(N_states)
|
||||||
|
double precision,intent(in) :: haa
|
||||||
|
double precision :: hij, sij
|
||||||
|
double precision, external :: diag_H_mat_elem_fock
|
||||||
|
integer :: i,j,k,l,m, l_sd
|
||||||
|
double precision :: hdress, sdress
|
||||||
|
double precision :: de, a_h_psi(Nstates)
|
||||||
|
|
||||||
|
|
||||||
|
a_h_psi = 0d0
|
||||||
|
|
||||||
|
|
||||||
|
do l_sd=1,n_minilist
|
||||||
|
call i_h_j_s2(alpha,det_minilist(1,1,l_sd),N_int,hij, sij)
|
||||||
|
a_h_i(l_sd, iproc) = hij
|
||||||
|
a_s2_i(l_sd, iproc) = sij
|
||||||
|
do i=1,Nstates
|
||||||
|
a_h_psi(i) += hij * psi_coef(minilist(l_sd), i)
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
|
||||||
|
contrib = 0d0
|
||||||
|
|
||||||
|
do i=1,Nstates
|
||||||
|
de = dress_E0_denominator(i) - haa
|
||||||
|
if(DABS(de) < 1D-5) cycle
|
||||||
|
|
||||||
|
c_alpha(i) = a_h_psi(i) / de
|
||||||
|
contrib = min(contrib, c_alpha(i) * a_h_psi(i))
|
||||||
|
|
||||||
|
do l_sd=1,n_minilist
|
||||||
|
hdress = c_alpha(i) * a_h_i(l_sd, iproc)
|
||||||
|
sdress = c_alpha(i) * a_s2_i(l_sd, iproc)
|
||||||
|
!if(c_alpha(i) * a_s2_i(l_sd, iproc) > 1d-1) then
|
||||||
|
! call debug_det(det_minilist(1,1,l_sd), N_int)
|
||||||
|
! call debug_det(alpha,N_int)
|
||||||
|
!end if
|
||||||
|
delta_ij_loc(i, minilist(l_sd), 1) += hdress
|
||||||
|
delta_ij_loc(i, minilist(l_sd), 2) += sdress
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
subroutine dress_with_alpha_buffer(Nstates,Ndet,Nint,delta_ij_loc, i_gen, minilist, det_minilist, n_minilist, alpha, iproc)
|
subroutine dress_with_alpha_buffer(Nstates,Ndet,Nint,delta_ij_loc, i_gen, minilist, det_minilist, n_minilist, alpha, iproc)
|
||||||
use bitmasks
|
use bitmasks
|
||||||
@ -26,45 +285,19 @@ subroutine dress_with_alpha_buffer(Nstates,Ndet,Nint,delta_ij_loc, i_gen, minili
|
|||||||
integer(bit_kind), intent(in) :: alpha(Nint,2), det_minilist(Nint, 2, n_minilist)
|
integer(bit_kind), intent(in) :: alpha(Nint,2), det_minilist(Nint, 2, n_minilist)
|
||||||
integer,intent(in) :: minilist(n_minilist)
|
integer,intent(in) :: minilist(n_minilist)
|
||||||
double precision, intent(inout) :: delta_ij_loc(Nstates,N_det,2)
|
double precision, intent(inout) :: delta_ij_loc(Nstates,N_det,2)
|
||||||
double precision :: haa, hij, sij
|
|
||||||
double precision, external :: diag_H_mat_elem_fock
|
double precision, external :: diag_H_mat_elem_fock
|
||||||
integer :: i,j,k,l,m, l_sd
|
double precision :: haa, contrib, c_alpha(N_states)
|
||||||
double precision :: hdress, sdress
|
|
||||||
double precision :: de, a_h_psi(Nstates), c_alpha
|
|
||||||
|
|
||||||
|
|
||||||
a_h_psi = 0d0
|
|
||||||
|
|
||||||
if(current_generator_(iproc) /= i_gen) then
|
|
||||||
current_generator_(iproc) = i_gen
|
|
||||||
call build_fock_tmp(fock_diag_tmp_(1,1,iproc),psi_det_generators(1,1,i_gen),N_int)
|
|
||||||
end if
|
|
||||||
|
|
||||||
haa = diag_H_mat_elem_fock(psi_det_generators(1,1,i_gen),alpha,fock_diag_tmp_(1,1,iproc),N_int)
|
haa = diag_H_mat_elem_fock(psi_det_generators(1,1,i_gen),alpha,fock_diag_tmp_(1,1,iproc),N_int)
|
||||||
|
|
||||||
do l_sd=1,n_minilist
|
call dress_with_alpha_(Nstates, Ndet, Nint, delta_ij_loc, minilist, det_minilist, n_minilist, alpha, haa, contrib, c_alpha, iproc)
|
||||||
call i_h_j_s2(alpha,det_minilist(1,1,l_sd),N_int,hij, sij)
|
|
||||||
a_h_i(l_sd, iproc) = hij
|
|
||||||
a_s2_i(l_sd, iproc) = sij
|
|
||||||
do i=1,Nstates
|
|
||||||
a_h_psi(i) += hij * psi_coef(minilist(l_sd), i)
|
|
||||||
end do
|
|
||||||
end do
|
|
||||||
|
|
||||||
|
slave_sum_alpha2(:,iproc) += c_alpha(:)**2
|
||||||
do i=1,Nstates
|
if(contrib < sb(iproc)%mini) then
|
||||||
de = dress_E0_denominator(i) - haa
|
call add_to_selection_buffer(sb(iproc), alpha, contrib)
|
||||||
if(DABS(de) < 1D-5) cycle
|
end if
|
||||||
|
|
||||||
c_alpha = a_h_psi(i) / de
|
|
||||||
|
|
||||||
do l_sd=1,n_minilist
|
|
||||||
hdress = c_alpha * a_h_i(l_sd, iproc)
|
|
||||||
sdress = c_alpha * a_s2_i(l_sd, iproc)
|
|
||||||
delta_ij_loc(i, minilist(l_sd), 1) += hdress
|
|
||||||
delta_ij_loc(i, minilist(l_sd), 2) += sdress
|
|
||||||
end do
|
|
||||||
end do
|
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
program bk_slave
|
program shifted_bk
|
||||||
implicit none
|
implicit none
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Helper subroutine to compute the dress in distributed mode.
|
! Helper subroutine to compute the dress in distributed mode.
|
||||||
END_DOC
|
END_DOC
|
||||||
call dress_slave
|
|
||||||
|
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||||
|
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||||
|
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||||
|
PROVIDE psi_bilinear_matrix_transp_order
|
||||||
|
|
||||||
|
!call diagonalize_CI()
|
||||||
|
call dress_slave()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user