10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-23 04:43:50 +01:00

Removed spin contaminants of Davidson

This commit is contained in:
Anthony Scemama 2016-11-18 15:06:33 +01:00
parent 278c961c0f
commit 5e3201cea9
2 changed files with 59 additions and 24 deletions

View File

@ -784,8 +784,12 @@ subroutine davidson_diag_hjj_sjj_mrcc(dets_in,u_in,H_jj,S2_jj,energies,dim_in,sz
if (s2_eig) then if (s2_eig) then
logical :: state_ok(N_st_diag*davidson_sze_max) logical :: state_ok(N_st_diag*davidson_sze_max)
do k=1,shift2 do k=1,shift2
state_ok(k) = (dabs(s2(k)-expected_s2) < 1.d0) state_ok(k) = (dabs(s2(k)-expected_s2) < 0.5d0)
enddo enddo
else
state_ok(k) = .True.
endif
do k=1,shift2 do k=1,shift2
if (.not. state_ok(k)) then if (.not. state_ok(k)) then
do l=k+1,shift2 do l=k+1,shift2
@ -799,9 +803,18 @@ subroutine davidson_diag_hjj_sjj_mrcc(dets_in,u_in,H_jj,S2_jj,energies,dim_in,sz
endif endif
enddo enddo
endif endif
! Randomize components with bad <S2>
if (.not. state_ok(k)) then
do i=1,shift2
call random_number(r1)
call random_number(r2)
r1 = dsqrt(-2.d0*dlog(r1))
r2 = dtwo_pi*r2
y(i,k) = r1*dcos(r2)
lambda(k) = 1.d0
enddo enddo
endif endif
enddo
! ! Compute overlap with U_in ! ! Compute overlap with U_in
! ! ------------------------- ! ! -------------------------
@ -857,6 +870,17 @@ subroutine davidson_diag_hjj_sjj_mrcc(dets_in,u_in,H_jj,S2_jj,energies,dim_in,sz
* (1.d0 + s2(k) * U(i,shift2+k) - S(i,shift2+k) - S_z2_Sz & * (1.d0 + s2(k) * U(i,shift2+k) - S(i,shift2+k) - S_z2_Sz &
)/max(H_jj(i) - lambda (k),1.d-2) )/max(H_jj(i) - lambda (k),1.d-2)
enddo enddo
! else
! ! Randomize components with bad <S2>
! do i=1,sze
! call random_number(r1)
! call random_number(r2)
! r1 = dsqrt(-2.d0*dlog(r1))
! r2 = dtwo_pi*r2
! U(i,shift2+k) = r1*dcos(r2)
! enddo
! endif
if (k <= N_st) then if (k <= N_st) then
residual_norm(k) = u_dot_u(U(1,shift2+k),sze) residual_norm(k) = u_dot_u(U(1,shift2+k),sze)
to_print(1,k) = lambda(k) + nuclear_repulsion to_print(1,k) = lambda(k) + nuclear_repulsion

View File

@ -587,6 +587,17 @@ subroutine davidson_diag_hjj_sjj_mmap(dets_in,u_in,H_jj,S2_jj,energies,dim_in,sz
enddo enddo
endif endif
enddo enddo
! Randomize components with bad <S2>
if (.not. state_ok(k)) then
do i=1,shift2
call random_number(r1)
call random_number(r2)
r1 = dsqrt(-2.d0*dlog(r1))
r2 = dtwo_pi*r2
y(i,k) = r1*dcos(r2)
lambda(k) = 1.d0
enddo
endif
endif endif