9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-04 19:03:28 +01:00
qp2/src/fci/pt2.irp.f

67 lines
1.9 KiB
Fortran
Raw Normal View History

2021-01-12 14:23:33 +01:00
! -*- mode: f90 -*-
2019-01-25 11:39:31 +01:00
program pt2
implicit none
BEGIN_DOC
2019-01-29 23:10:00 +01:00
! Second order perturbative correction to the wave function contained
! in the |EZFIO| directory.
2019-01-25 11:39:31 +01:00
!
2019-01-29 23:10:00 +01:00
! This programs runs the stochastic |PT2| correction on all
! :option:`determinants n_states` wave functions stored in the |EZFIO|
! directory.
2019-01-25 11:39:31 +01:00
!
2019-01-29 23:10:00 +01:00
! The main option for the |PT2| correction is the
! :option:`perturbation pt2_relative_error` which is the relative
! stochastic error on the |PT2| to reach before stopping the
! sampling.
2019-01-25 11:39:31 +01:00
!
END_DOC
if (.not. is_zmq_slave) then
2021-01-12 14:23:33 +01:00
read_wf = .True.
threshold_generators = 1.d0
SOFT_TOUCH read_wf threshold_generators
PROVIDE mo_two_e_integrals_in_map
PROVIDE psi_energy
call run
2019-01-25 11:39:31 +01:00
else
2021-01-12 14:23:33 +01:00
call run_slave_cipsi
2019-01-25 11:39:31 +01:00
endif
2021-01-12 14:23:33 +01:00
end program pt2
2019-01-25 11:39:31 +01:00
subroutine run
implicit none
2020-08-28 00:10:46 +02:00
use selection_types
2019-01-25 11:39:31 +01:00
integer :: i,j,k
logical, external :: detEq
2021-01-12 14:23:33 +01:00
2020-08-31 01:45:36 +02:00
type(pt2_type) :: pt2_data, pt2_data_err
2019-01-25 11:39:31 +01:00
integer :: degree
integer :: n_det_before, to_select
double precision :: threshold_davidson_in
2021-01-12 14:23:33 +01:00
2020-08-31 01:45:36 +02:00
double precision :: relative_error
double precision, allocatable :: E_CI_before(:)
2021-01-12 14:23:33 +01:00
2020-08-31 01:45:36 +02:00
allocate ( E_CI_before(N_states))
2020-08-28 15:39:01 +02:00
call pt2_alloc(pt2_data, N_states)
2020-08-31 01:45:36 +02:00
call pt2_alloc(pt2_data_err, N_states)
2021-01-12 14:23:33 +01:00
2019-01-25 11:39:31 +01:00
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
relative_error=PT2_relative_error
2021-01-12 14:23:33 +01:00
2019-07-09 13:40:06 +02:00
if (do_pt2) then
2021-01-12 14:23:33 +01:00
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2_data, pt2_data_err, relative_error, 0) ! Stochastic PT2
2019-07-09 13:40:06 +02:00
else
2021-01-12 14:23:33 +01:00
call ZMQ_selection(0, pt2_data)
2019-07-09 13:40:06 +02:00
endif
2020-08-28 00:10:46 +02:00
call print_summary(psi_energy_with_nucl_rep(1:N_states), &
2021-01-12 14:23:33 +01:00
pt2_data, pt2_data_err, N_det,N_configuration,N_states,psi_s2)
2020-08-31 01:45:36 +02:00
call save_energy(E_CI_before, pt2_data % pt2)
2020-08-28 15:39:01 +02:00
call pt2_dealloc(pt2_data)
2020-08-31 01:45:36 +02:00
call pt2_dealloc(pt2_data_err)
deallocate(E_CI_before)
2021-01-12 14:23:33 +01:00
end subroutine run
2019-01-25 11:39:31 +01:00