Multi-state PT2

This commit is contained in:
Anthony Scemama 2017-11-21 14:53:32 +01:00
parent a290736145
commit cd3c13077a
4 changed files with 47 additions and 21 deletions

View File

@ -29,10 +29,10 @@ size: (full_ci_zmq.n_iter)
interface: ezfio
doc: The energy without a pt2 correction for n_det
type: double precision
size: (full_ci_zmq.n_iter)
size: (full_ci_zmq.n_iter,determinants.n_states)
[pt2_iter]
interface: ezfio
doc: The pt2 correction for n_det
type: double precision
size: (full_ci_zmq.n_iter)
size: (full_ci_zmq.n_iter,determinants.n_states)

View File

@ -6,15 +6,17 @@ subroutine dump_fci_iterations_value(n_determinants,energy,pt2)
! BEGIN_DOC
!! Output the number of determinants, energy, and pt2 correction at each iteration
! END_DOC
integer :: n_determinants
double precision :: energy, pt2
integer, intent(in) :: n_determinants
double precision, intent(in) :: energy(N_states), pt2(N_states)
integer :: N_iterations
integer, allocatable :: n_determinants_list(:)
double precision, allocatable :: energy_list(:)
double precision, allocatable :: pt2_list(:)
double precision, allocatable :: energy_list(:,:)
double precision, allocatable :: pt2_list(:,:)
integer :: saveMethod
logical :: hasIter
logical,save :: firstAccess=.TRUE. !! every update of firstAccess will be saved
double precision, allocatable :: extrapolated_energy(:,:)
integer :: i,k
!!! Check to ensure that we should save iterations (default is Append)
! saveMethod: 1==Append, 2==Overwrite, 3==NoSave
@ -42,16 +44,17 @@ subroutine dump_fci_iterations_value(n_determinants,energy,pt2)
endif
!! Now allocate the array for entire size needed
allocate(extrapolated_energy(N_iterations+1,N_states))
allocate(n_determinants_list(N_iterations+1))
allocate(energy_list(N_iterations+1))
allocate(pt2_list(N_iterations+1))
allocate(energy_list(N_states,N_iterations+1))
allocate(pt2_list(N_states,N_iterations+1))
!!! Pull previously written data
!!! Unless it is at the beginning of a new/restarted calculation
if((hasIter).AND.(N_iterations>0)) then
call ezfio_get_full_ci_zmq_n_det_iter(n_determinants_list(1:N_iterations))
call ezfio_get_full_ci_zmq_energy_iter(energy_list(1:N_iterations))
call ezfio_get_full_ci_zmq_pt2_iter(pt2_list(1:N_iterations))
call ezfio_get_full_ci_zmq_n_det_iter(n_determinants_list)
call ezfio_get_full_ci_zmq_energy_iter(energy_list)
call ezfio_get_full_ci_zmq_pt2_iter(pt2_list)
endif
!! Now increment to the current iteration
@ -59,8 +62,29 @@ subroutine dump_fci_iterations_value(n_determinants,energy,pt2)
!! Add the data from latest iteration
n_determinants_list(N_iterations) = n_determinants
energy_list(N_iterations) = energy
pt2_list(N_iterations) = pt2
energy_list(:,N_iterations) = energy(:)
pt2_list(:,N_iterations) = pt2(:)
print *, 'Extrapolation'
print *, '============='
do i=1,N_states
call extrapolate_data(N_iterations, energy_list(i,1:N_iterations), pt2_list(i,1:N_iterations), extrapolated_energy(1:N_iterations,i))
enddo
do i=1,N_states
print *, 'State ', i
print *, '------------------'
print *, ''
write(*,*) '=========== ', '==================='
write(*,*) 'minimum PT2 ', 'Extrapolated energy'
write(*,*) '=========== ', '==================='
do k=2,min(N_iterations,8)
write(*,'(F11.4,2X,F18.8)') pt2_list(i,N_iterations+1-k), extrapolated_energy(k,i)
enddo
write(*,*) '=========== ', '==================='
enddo
! Reset the iteration number
call ezfio_set_full_ci_zmq_n_iter(N_iterations)
@ -74,10 +98,11 @@ subroutine dump_fci_iterations_value(n_determinants,energy,pt2)
deallocate(n_determinants_list)
deallocate(energy_list)
deallocate(pt2_list)
endif
!!! set first access to false
!!! it will be saved
firstAccess=.FALSE.
end subroutine

View File

@ -45,7 +45,7 @@ program fci_zmq
print *, 'E+PT2 = ', CI_energy(k) + pt2(k)
print *, '-----'
enddo
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
call dump_fci_iterations_value(N_det,CI_energy,pt2) ! This call automatically appends data
endif
@ -89,6 +89,7 @@ program fci_zmq
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
print *, 'N_det = ', N_det
print *, 'N_states = ', N_states
print*, 'correlation_ratio = ', correlation_energy_ratio
@ -115,6 +116,8 @@ program fci_zmq
(CI_energy(i)+ pt2(i) - (CI_energy(1) + pt2(1))) * 27.2107362681d0
enddo
endif
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
call dump_fci_iterations_value(N_det,CI_energy,pt2)
n_det_before = N_det
to_select = N_det
@ -132,8 +135,6 @@ program fci_zmq
call diagonalize_CI
call save_wavefunction
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
enddo
endif
@ -142,8 +143,7 @@ program fci_zmq
call diagonalize_CI
call save_wavefunction
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
endif
if (do_pt2) then
@ -157,7 +157,6 @@ program fci_zmq
SOFT_TOUCH threshold_selectors threshold_generators
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
endif
print *, 'N_det = ', N_det
print *, 'N_states = ', N_states
@ -171,6 +170,8 @@ program fci_zmq
enddo
print *, '-----'
call dump_fci_iterations_value(N_det,CI_energy,pt2)
end

View File

@ -102,7 +102,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, absolute_error, error)
!$OMP PRIVATE(i)
i = omp_get_thread_num()
if (i==0) then
call pt2_collector(E(pt2_stoch_istate), b, tbc, comb, Ncomb, computed, pt2_detail, sumabove, sum2above, Nabove, relative_error, absolute_error,w,error)
call pt2_collector(E(pt2_stoch_istate), b, tbc, comb, Ncomb, computed, pt2_detail, sumabove, sum2above, Nabove, relative_error, absolute_error, w, error)
pt2(pt2_stoch_istate) = w(pt2_stoch_istate)
else
call pt2_slave_inproc(i)