2016-09-05 17:16:09 +02:00
|
|
|
use bitmasks
|
|
|
|
|
|
|
|
BEGIN_PROVIDER [ double precision, integral8, (mo_tot_num, mo_tot_num, mo_tot_num, mo_tot_num) ]
|
|
|
|
use bitmasks
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer :: h1, h2
|
|
|
|
|
|
|
|
integral8 = 0d0
|
|
|
|
do h1=1, mo_tot_num
|
|
|
|
do h2=1, mo_tot_num
|
|
|
|
call get_mo_bielec_integrals_ij(h1, h2 ,mo_tot_num,integral8(1,1,h1,h2),mo_integrals_map)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
END_PROVIDER
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROVIDER [ integer(bit_kind), psi_phasemask, (N_int, 2, N_det)]
|
|
|
|
use bitmasks
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer :: i
|
|
|
|
do i=1, N_det
|
|
|
|
call get_mask_phase(psi_det_sorted(1,1,i), psi_phasemask(1,1,i))
|
|
|
|
end do
|
|
|
|
END_PROVIDER
|
|
|
|
|
|
|
|
|
|
|
|
subroutine assert(cond, msg)
|
|
|
|
character(*), intent(in) :: msg
|
|
|
|
logical, intent(in) :: cond
|
|
|
|
|
|
|
|
if(.not. cond) then
|
|
|
|
print *, "assert fail: "//msg
|
|
|
|
stop
|
|
|
|
end if
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
subroutine get_mask_phase(det, phasemask)
|
|
|
|
use bitmasks
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(bit_kind), intent(in) :: det(N_int, 2)
|
|
|
|
integer(bit_kind), intent(out) :: phasemask(N_int, 2)
|
|
|
|
integer :: s, ni, i
|
|
|
|
logical :: change
|
|
|
|
|
2016-09-08 10:12:28 +02:00
|
|
|
phasemask = 0_8
|
2016-09-05 17:16:09 +02:00
|
|
|
do s=1,2
|
|
|
|
change = .false.
|
|
|
|
do ni=1,N_int
|
|
|
|
do i=0,bit_kind_size-1
|
|
|
|
if(BTEST(det(ni, s), i)) change = .not. change
|
|
|
|
if(change) phasemask(ni, s) = ibset(phasemask(ni, s), i)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
subroutine select_connected(i_generator,E0,pt2,b)
|
|
|
|
use bitmasks
|
|
|
|
use selection_types
|
|
|
|
implicit none
|
|
|
|
integer, intent(in) :: i_generator
|
|
|
|
type(selection_buffer), intent(inout) :: b
|
|
|
|
double precision, intent(inout) :: pt2(N_states)
|
|
|
|
integer :: k,l
|
|
|
|
double precision, intent(in) :: E0(N_states)
|
|
|
|
|
|
|
|
integer(bit_kind) :: hole_mask(N_int,2), particle_mask(N_int,2)
|
|
|
|
double precision :: fock_diag_tmp(2,mo_tot_num+1)
|
|
|
|
|
|
|
|
call build_fock_tmp(fock_diag_tmp,psi_det_generators(1,1,i_generator),N_int)
|
|
|
|
|
|
|
|
do l=1,N_generators_bitmask
|
|
|
|
do k=1,N_int
|
|
|
|
hole_mask(k,1) = iand(generators_bitmask(k,1,s_hole,l), psi_det_generators(k,1,i_generator))
|
|
|
|
hole_mask(k,2) = iand(generators_bitmask(k,2,s_hole,l), psi_det_generators(k,2,i_generator))
|
|
|
|
particle_mask(k,1) = iand(generators_bitmask(k,1,s_part,l), not(psi_det_generators(k,1,i_generator)) )
|
|
|
|
particle_mask(k,2) = iand(generators_bitmask(k,2,s_part,l), not(psi_det_generators(k,2,i_generator)) )
|
|
|
|
|
|
|
|
hole_mask(k,1) = ior(generators_bitmask(k,1,s_hole,l), generators_bitmask(k,1,s_part,l))
|
|
|
|
hole_mask(k,2) = ior(generators_bitmask(k,2,s_hole,l), generators_bitmask(k,2,s_part,l))
|
|
|
|
particle_mask(k,:) = hole_mask(k,:)
|
|
|
|
enddo
|
2016-09-05 17:18:01 +02:00
|
|
|
call select_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,b)
|
2016-09-05 17:16:09 +02:00
|
|
|
call select_singles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,b)
|
|
|
|
enddo
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
subroutine spot_occupied(mask, bannedOrb)
|
|
|
|
use bitmasks
|
|
|
|
implicit none
|
|
|
|
|
2016-09-08 10:12:28 +02:00
|
|
|
integer(bit_kind),intent(in) :: mask(N_int)
|
|
|
|
logical, intent(inout) :: bannedOrb(mo_tot_num)
|
|
|
|
integer :: i, ne, list(mo_tot_num)
|
2016-09-05 17:16:09 +02:00
|
|
|
|
2016-09-08 10:12:28 +02:00
|
|
|
call bitstring_to_list(mask, list, ne, N_int)
|
|
|
|
do i=1, ne
|
|
|
|
bannedOrb(list(i)) = .true.
|
2016-09-05 17:16:09 +02:00
|
|
|
end do
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
double precision function get_phase_bi(phasemask, s1, s2, h1, p1, h2, p2)
|
|
|
|
use bitmasks
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(bit_kind), intent(in) :: phasemask(N_int, 2)
|
|
|
|
integer, intent(in) :: s1, s2, h1, h2, p1, p2
|
|
|
|
logical :: change
|
2016-09-08 10:12:28 +02:00
|
|
|
integer :: np
|
|
|
|
double precision, parameter :: res(0:1) = (/1d0, -1d0/)
|
|
|
|
|
|
|
|
call assert(s1 /= s2 .or. (h1 <= h2 .and. p1 <= p2), irp_here)
|
|
|
|
np = 0
|
|
|
|
change = btest(phasemask(1+ishft(h1, -6), s1), iand(h1-1, 63))
|
|
|
|
change = xor(change, btest(phasemask(1+ishft(p1, -6), s1), iand(p1-1, 63)))
|
|
|
|
if(xor(change, p1 < h1)) np = 1
|
|
|
|
|
|
|
|
change = btest(phasemask(1+ishft(h2, -6), s2), iand(h2-1, 63))
|
|
|
|
change = xor(change, btest(phasemask(1+ishft(p2, -6), s2), iand(p2-1, 63)))
|
|
|
|
if(xor(change, p2 < h2)) np = np + 1
|
|
|
|
|
|
|
|
if(s1 == s2 .and. max(h1, p1) > min(h2, p2)) np = np + 1
|
|
|
|
get_phase_bi = res(iand(np,1))
|
2016-09-05 17:16:09 +02:00
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
double precision function get_phase_mono(phasemask, s1, h1, p1)
|
|
|
|
use bitmasks
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(bit_kind), intent(in) :: phasemask(N_int, 2)
|
|
|
|
integer, intent(in) :: s1, h1, p1
|
|
|
|
logical :: change
|
2016-09-08 10:12:28 +02:00
|
|
|
stop "phase moni BUGGED"
|
2016-09-05 17:16:09 +02:00
|
|
|
|
|
|
|
change = btest(phasemask(ishft(h1, bit_kind_shift), s1), iand(h1, 63_8))
|
|
|
|
change = xor(change, btest(phasemask(ishft(p1, bit_kind_shift), s1), iand(p1, 63_8)))
|
|
|
|
|
|
|
|
get_phase_mono = 1d0
|
|
|
|
if(change) get_phase_mono = -1d0
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
|