9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-07 05:53:37 +01:00

Improving weights

This commit is contained in:
Anthony Scemama 2021-02-11 01:03:24 +01:00
parent 3d6a75ca42
commit fb07e986c9
3 changed files with 41 additions and 23 deletions

View File

@ -352,9 +352,9 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in)
state_average_weight(:) = state_average_weight_save(:) state_average_weight(:) = state_average_weight_save(:)
TOUCH state_average_weight TOUCH state_average_weight
call update_pt2_and_variance_weights(pt2_data, N_states)
endif endif
call update_pt2_and_variance_weights(pt2_data, N_states)
end subroutine end subroutine

View File

@ -648,7 +648,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
do_cycle = .True. do_cycle = .True.
do k=1,N_dominant_dets_of_cfgs do k=1,N_dominant_dets_of_cfgs
call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int)
do_cycle = do_cycle .and. (degree > excitation_alpha_max) do_cycle = do_cycle .and. (degree > excitation_alpha_max)
enddo enddo
if (do_cycle) cycle if (do_cycle) cycle
endif endif
@ -658,7 +658,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
do_cycle = .True. do_cycle = .True.
do k=1,N_dominant_dets_of_cfgs do k=1,N_dominant_dets_of_cfgs
call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int)
do_cycle = do_cycle .and. (degree > excitation_beta_max) do_cycle = do_cycle .and. (degree > excitation_beta_max)
enddo enddo
if (do_cycle) cycle if (do_cycle) cycle
endif endif

View File

@ -33,43 +33,59 @@ subroutine update_pt2_and_variance_weights(pt2_data, N_st)
double precision :: avg, element, dt, x double precision :: avg, element, dt, x
integer :: k integer :: k
integer, save :: i_iter=0 ! integer, save :: i_iter=0
integer, parameter :: i_itermax = 1 ! integer, parameter :: i_itermax = 1
double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:) ! double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:)
pt2(:) = pt2_data % pt2(:) pt2(:) = pt2_data % pt2(:)
variance(:) = pt2_data % variance(:) variance(:) = pt2_data % variance(:)
if (i_iter == 0) then ! if (i_iter == 0) then
allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax)) ! allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax))
memo_pt2(:,:) = 1.d0 ! memo_pt2(:,:) = 1.d0
memo_variance(:,:) = 1.d0 ! memo_variance(:,:) = 1.d0
endif ! endif
!
! i_iter = i_iter+1
! if (i_iter > i_itermax) then
! i_iter = 1
! endif
!
! dt = 2.0d0
i_iter = i_iter+1 avg = sum(pt2(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero
if (i_iter > i_itermax) then ! do k=1,N_st
i_iter = 1 ! element = exp(dt*(pt2(k)/avg -1.d0))
endif ! element = min(2.0d0 , element)
! element = max(0.5d0 , element)
! memo_pt2(k,i_iter) = element
! pt2_match_weight(k) *= product(memo_pt2(k,:))
!enddo
dt = 2.0d0 dt = 1.0d0 * selection_factor
avg = sum(pt2(1:N_st)) / dble(N_st) - 1.d-32 ! Avoid future division by zero
do k=1,N_st do k=1,N_st
element = exp(dt*(pt2(k)/avg -1.d0)) element = exp(dt*(pt2(k)/avg - 1.d0))
element = min(2.0d0 , element) element = min(2.0d0 , element)
element = max(0.5d0 , element) element = max(0.5d0 , element)
memo_pt2(k,i_iter) = element print *, k, element
pt2_match_weight(k) *= product(memo_pt2(k,:)) pt2_match_weight(k) *= element
enddo enddo
avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero
! do k=1,N_st
! element = exp(dt*(variance(k)/avg -1.d0))
! element = min(2.0d0 , element)
! element = max(0.5d0 , element)
! memo_variance(k,i_iter) = element
! variance_match_weight(k) *= product(memo_variance(k,:))
! enddo
do k=1,N_st do k=1,N_st
element = exp(dt*(variance(k)/avg -1.d0)) element = exp(dt*(variance(k)/avg -1.d0))
element = min(2.0d0 , element) element = min(2.0d0 , element)
element = max(0.5d0 , element) element = max(0.5d0 , element)
memo_variance(k,i_iter) = element variance_match_weight(k) *= element
variance_match_weight(k) *= product(memo_variance(k,:))
enddo enddo
if (N_det < 100) then if (N_det < 100) then
@ -78,6 +94,8 @@ subroutine update_pt2_and_variance_weights(pt2_data, N_st)
variance_match_weight(:) = 1.d0 variance_match_weight(:) = 1.d0
endif endif
print *, 'XXX', n_det, pt2_match_weight(1), pt2_match_weight(2)
threshold_davidson_pt2 = min(1.d-6, & threshold_davidson_pt2 = min(1.d-6, &
max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) ) max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) )