mirror of
https://gitlab.com/scemama/qp_plugins_scemama.git
synced 2024-10-06 16:25:58 +02:00
Compare commits
No commits in common. "2906771a3de570b4d4691dfea41f3cf04ed579aa" and "6dfb4d3d00a8f5cc6c14f0eec7a211b5a20234ca" have entirely different histories.
2906771a3d
...
6dfb4d3d00
59
devel/variance/.gitignore
vendored
Normal file
59
devel/variance/.gitignore
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
IRPF90_temp/
|
||||||
|
IRPF90_man/
|
||||||
|
build.ninja
|
||||||
|
irpf90.make
|
||||||
|
ezfio_interface.irp.f
|
||||||
|
irpf90_entities
|
||||||
|
tags
|
||||||
|
Makefile
|
||||||
|
ao_basis
|
||||||
|
ao_one_e_ints
|
||||||
|
ao_two_e_erf_ints
|
||||||
|
ao_two_e_ints
|
||||||
|
aux_quantities
|
||||||
|
becke_numerical_grid
|
||||||
|
bitmask
|
||||||
|
cis
|
||||||
|
cisd
|
||||||
|
cipsi
|
||||||
|
davidson
|
||||||
|
davidson_dressed
|
||||||
|
davidson_undressed
|
||||||
|
density_for_dft
|
||||||
|
determinants
|
||||||
|
dft_keywords
|
||||||
|
dft_utils_in_r
|
||||||
|
dft_utils_one_e
|
||||||
|
dft_utils_two_body
|
||||||
|
dressing
|
||||||
|
dummy
|
||||||
|
electrons
|
||||||
|
ezfio_files
|
||||||
|
fci
|
||||||
|
generators_cas
|
||||||
|
generators_full
|
||||||
|
hartree_fock
|
||||||
|
iterations
|
||||||
|
kohn_sham
|
||||||
|
kohn_sham_rs
|
||||||
|
mo_basis
|
||||||
|
mo_guess
|
||||||
|
mo_one_e_ints
|
||||||
|
mo_two_e_erf_ints
|
||||||
|
mo_two_e_ints
|
||||||
|
mpi
|
||||||
|
mrpt_utils
|
||||||
|
nuclei
|
||||||
|
perturbation
|
||||||
|
pseudo
|
||||||
|
psiref_cas
|
||||||
|
psiref_utils
|
||||||
|
scf_utils
|
||||||
|
selectors_cassd
|
||||||
|
selectors_full
|
||||||
|
selectors_utils
|
||||||
|
single_ref_method
|
||||||
|
slave
|
||||||
|
tools
|
||||||
|
utils
|
||||||
|
zmq
|
6
devel/variance/EZFIO.cfg
Normal file
6
devel/variance/EZFIO.cfg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[expected_variance]
|
||||||
|
type: double precision
|
||||||
|
doc: Expected variance where the calculation should stop
|
||||||
|
interface: ezfio, provider, ocaml
|
||||||
|
default: 0.1
|
||||||
|
|
1
devel/variance/NEED
Normal file
1
devel/variance/NEED
Normal file
@ -0,0 +1 @@
|
|||||||
|
fci
|
4
devel/variance/README.rst
Normal file
4
devel/variance/README.rst
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
========
|
||||||
|
variance
|
||||||
|
========
|
||||||
|
|
BIN
devel/variance/variance
Executable file
BIN
devel/variance/variance
Executable file
Binary file not shown.
118
devel/variance/variance.irp.f
Normal file
118
devel/variance/variance.irp.f
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
program variance
|
||||||
|
implicit none
|
||||||
|
BEGIN_DOC
|
||||||
|
! Selected Full Configuration Interaction with Stochastic selection and PT2.
|
||||||
|
END_DOC
|
||||||
|
integer :: i,j,k
|
||||||
|
double precision, allocatable :: pt2(:), var(:), norm(:), rpt2(:)
|
||||||
|
integer :: to_select
|
||||||
|
logical, external :: qp_stop
|
||||||
|
|
||||||
|
double precision :: rss
|
||||||
|
double precision, external :: memory_of_double
|
||||||
|
PROVIDE H_apply_buffer_allocated N_generators_bitmask
|
||||||
|
|
||||||
|
threshold_generators = 1.d0
|
||||||
|
SOFT_TOUCH threshold_generators
|
||||||
|
|
||||||
|
rss = memory_of_double(N_states)*4.d0
|
||||||
|
call check_mem(rss,irp_here)
|
||||||
|
|
||||||
|
allocate (pt2(N_states), rpt2(N_states), norm(N_states), var(N_states))
|
||||||
|
|
||||||
|
double precision :: hf_energy_ref
|
||||||
|
logical :: has
|
||||||
|
double precision :: relative_error
|
||||||
|
|
||||||
|
relative_error=PT2_relative_error
|
||||||
|
|
||||||
|
pt2 = -huge(1.e0)
|
||||||
|
rpt2 = -huge(1.e0)
|
||||||
|
norm = 0.d0
|
||||||
|
var = huge(1.e0)
|
||||||
|
|
||||||
|
if (s2_eig) then
|
||||||
|
call make_s2_eigenfunction
|
||||||
|
endif
|
||||||
|
call diagonalize_CI
|
||||||
|
call save_wavefunction
|
||||||
|
|
||||||
|
call ezfio_has_hartree_fock_energy(has)
|
||||||
|
if (has) then
|
||||||
|
call ezfio_get_hartree_fock_energy(hf_energy_ref)
|
||||||
|
else
|
||||||
|
hf_energy_ref = ref_bitmask_energy
|
||||||
|
endif
|
||||||
|
|
||||||
|
if (N_det > N_det_max) then
|
||||||
|
psi_det = psi_det_sorted
|
||||||
|
psi_coef = psi_coef_sorted
|
||||||
|
N_det = N_det_max
|
||||||
|
soft_touch N_det psi_det psi_coef
|
||||||
|
if (s2_eig) then
|
||||||
|
call make_s2_eigenfunction
|
||||||
|
endif
|
||||||
|
call diagonalize_CI
|
||||||
|
call save_wavefunction
|
||||||
|
endif
|
||||||
|
|
||||||
|
double precision :: correlation_energy_ratio
|
||||||
|
double precision :: error(N_states)
|
||||||
|
|
||||||
|
correlation_energy_ratio = 0.d0
|
||||||
|
|
||||||
|
do while ( &
|
||||||
|
(N_det < N_det_max) .and. &
|
||||||
|
(maxval(abs(pt2(1:N_states))) > pt2_max) .and. &
|
||||||
|
(maxval(abs(var(1:N_states))) > variance_max) .and. &
|
||||||
|
(correlation_energy_ratio <= correlation_energy_ratio_max) &
|
||||||
|
)
|
||||||
|
write(*,'(A)') '--------------------------------------------------------------------------------'
|
||||||
|
|
||||||
|
|
||||||
|
to_select = N_det/20
|
||||||
|
to_select = max(N_states_diag, to_select)
|
||||||
|
|
||||||
|
pt2 = 0.d0
|
||||||
|
var = 0.d0
|
||||||
|
norm = 0.d0
|
||||||
|
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, var, &
|
||||||
|
norm, to_select) ! Stochastic PT2 and selection
|
||||||
|
|
||||||
|
correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / &
|
||||||
|
(psi_energy_with_nucl_rep(1) + pt2(1) - hf_energy_ref)
|
||||||
|
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
|
||||||
|
|
||||||
|
call save_energy(psi_energy_with_nucl_rep, pt2)
|
||||||
|
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
|
||||||
|
call print_summary(psi_energy_with_nucl_rep,pt2,error,var,norm,N_det,N_occ_pattern,N_states,psi_s2)
|
||||||
|
|
||||||
|
do k=1,N_states
|
||||||
|
rpt2(:) = pt2(:)/(1.d0 + norm(k))
|
||||||
|
enddo
|
||||||
|
|
||||||
|
call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det)
|
||||||
|
call print_extrapolated_energy()
|
||||||
|
N_iter += 1
|
||||||
|
|
||||||
|
if ( (maxval(abs(pt2(1:N_states))) <= pt2_max) .or. &
|
||||||
|
(maxval(abs(var(1:N_states))) <= variance_max) .or. &
|
||||||
|
qp_stop() ) then
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
! Add selected determinants
|
||||||
|
call copy_H_apply_buffer_to_wf()
|
||||||
|
call save_wavefunction
|
||||||
|
|
||||||
|
PROVIDE psi_coef
|
||||||
|
PROVIDE psi_det
|
||||||
|
PROVIDE psi_det_sorted
|
||||||
|
|
||||||
|
call diagonalize_CI
|
||||||
|
call save_wavefunction
|
||||||
|
rpt2(:) = 0.d0
|
||||||
|
call save_energy(psi_energy_with_nucl_rep, rpt2)
|
||||||
|
if (qp_stop()) exit
|
||||||
|
enddo
|
||||||
|
|
||||||
|
end
|
@ -4,8 +4,7 @@ program qmcpack
|
|||||||
! Generates a file for CHAMP
|
! Generates a file for CHAMP
|
||||||
END_DOC
|
END_DOC
|
||||||
|
|
||||||
integer :: i,j,k,l, istate
|
integer :: i,j
|
||||||
|
|
||||||
read_wf = .True.
|
read_wf = .True.
|
||||||
TOUCH read_wf
|
TOUCH read_wf
|
||||||
do j=1,ao_prim_num_max
|
do j=1,ao_prim_num_max
|
||||||
@ -23,71 +22,4 @@ program qmcpack
|
|||||||
call system('rm '//trim(ezfio_filename)//'/mo_basis/ao_md5')
|
call system('rm '//trim(ezfio_filename)//'/mo_basis/ao_md5')
|
||||||
call system('$QP_ROOT/src/champ/qp_convert.py '//trim(ezfio_filename))
|
call system('$QP_ROOT/src/champ/qp_convert.py '//trim(ezfio_filename))
|
||||||
|
|
||||||
integer :: iunit
|
|
||||||
integer, external :: getUnitAndOpen
|
|
||||||
iunit = getUnitAndOpen(trim(ezfio_filename)//'.H','w')
|
|
||||||
|
|
||||||
double precision, external :: diag_h_mat_elem
|
|
||||||
write(iunit,*) N_states
|
|
||||||
do istate=1,N_states
|
|
||||||
write(iunit,*) istate, psi_energy_with_nucl_rep(istate)
|
|
||||||
enddo
|
|
||||||
write(iunit,*) N_det
|
|
||||||
do k=1,N_det
|
|
||||||
write(iunit,'(I10,X,F22.15)') k, diag_h_mat_elem(psi_det(1,1,k),N_int) + nuclear_repulsion
|
|
||||||
enddo
|
|
||||||
|
|
||||||
|
|
||||||
double precision :: F(N_states)
|
|
||||||
integer(bit_kind), allocatable :: det(:,:,:)
|
|
||||||
double precision , allocatable :: coef(:,:)
|
|
||||||
integer :: ispin
|
|
||||||
double precision :: norm(N_states), hij
|
|
||||||
allocate(det(N_int,2,N_det), coef(N_det,N_states))
|
|
||||||
do j=1,mo_num
|
|
||||||
do i=1,j-1
|
|
||||||
do ispin=1,2
|
|
||||||
call build_singly_excited_wavefunction(j,i,1,det,coef)
|
|
||||||
F = 0.d0
|
|
||||||
do istate=1,N_states
|
|
||||||
norm(istate) = 0.d0
|
|
||||||
do k=1,N_det
|
|
||||||
norm(istate) = norm(istate) + coef(k,istate) * coef(k,istate)
|
|
||||||
enddo
|
|
||||||
if (norm(istate) > 0.d0) then
|
|
||||||
norm(istate) = (1.d0/dsqrt(norm(istate)))
|
|
||||||
endif
|
|
||||||
enddo
|
|
||||||
if (sum(norm(:)) > 0.d0) then
|
|
||||||
|
|
||||||
do istate = 1,N_states
|
|
||||||
coef(:,istate) = coef(:,istate) * norm(istate)
|
|
||||||
enddo
|
|
||||||
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,j,istate,hij) REDUCTION(+:F)
|
|
||||||
do k=1,N_det
|
|
||||||
call i_H_j(det(1,1,k), det(1,1,k), N_int, hij)
|
|
||||||
do istate=1,N_states
|
|
||||||
F(istate) = F(istate) + hij*coef(k,istate)*coef(k,istate)
|
|
||||||
enddo
|
|
||||||
do l=1,k-1
|
|
||||||
call i_H_j(det(1,1,k), det(1,1,l), N_int, hij)
|
|
||||||
do istate=1,N_states
|
|
||||||
F(istate) = F(istate) + 2.d0*hij*coef(k,istate)*coef(l,istate)
|
|
||||||
enddo
|
|
||||||
enddo
|
|
||||||
enddo
|
|
||||||
!$OMP END PARALLEL DO
|
|
||||||
F(:) = F(:) - psi_energy(:)
|
|
||||||
endif
|
|
||||||
do istate=1,N_states
|
|
||||||
write(iunit,'(I4,X,I4,X,I1,X,I3,X,F22.15)') i, j, ispin, istate, F(istate)
|
|
||||||
enddo
|
|
||||||
enddo
|
|
||||||
enddo
|
|
||||||
enddo
|
|
||||||
|
|
||||||
deallocate(det,coef)
|
|
||||||
|
|
||||||
close(iunit)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user