10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-08 07:03:57 +01:00
quantum_package/src/Bitmask/bitmasks.irp.f

220 lines
5.9 KiB
Fortran
Raw Normal View History

2014-04-03 01:50:22 +02:00
use bitmasks
BEGIN_PROVIDER [ integer, N_int ]
implicit none
BEGIN_DOC
! Number of 64-bit integers needed to represent determinants as binary strings
END_DOC
N_int = (mo_tot_num-1)/bit_kind_size + 1
END_PROVIDER
BEGIN_PROVIDER [ integer(bit_kind), full_ijkl_bitmask, (N_int,4) ]
implicit none
BEGIN_DOC
2014-04-10 22:17:26 +02:00
! Bitmask to include all possible MOs
2014-04-03 01:50:22 +02:00
END_DOC
integer :: i,j,n
n = mod(mo_tot_num-1,bit_kind_size)+1
full_ijkl_bitmask = 0_bit_kind
do j=1,4
do i=1,N_int-1
full_ijkl_bitmask(i,j) = not(0_bit_kind)
enddo
do i=1,n
full_ijkl_bitmask(N_int,j) = ibset(full_ijkl_bitmask(N_int,j),i-1)
enddo
enddo
END_PROVIDER
2014-06-25 14:58:58 +02:00
BEGIN_PROVIDER [ integer(bit_kind), cis_ijkl_bitmask, (N_int,4) ]
implicit none
BEGIN_DOC
! Bitmask to include all possible single excitations from Hartree-Fock
END_DOC
integer :: i,j,n
cis_ijkl_bitmask = full_ijkl_bitmask
cis_ijkl_bitmask(:,1) = HF_bitmask(:,1)
END_PROVIDER
2014-04-03 01:50:22 +02:00
BEGIN_PROVIDER [ integer(bit_kind), HF_bitmask, (N_int,2)]
implicit none
BEGIN_DOC
! Hartree Fock bit mask
END_DOC
integer :: i,j,n
integer :: occ(elec_alpha_num)
HF_bitmask = 0_bit_kind
do i=1,elec_alpha_num
occ(i) = i
enddo
call list_to_bitstring( HF_bitmask(1,1), occ, elec_alpha_num, N_int)
! elec_alpha_num <= elec_beta_num, so occ is already OK.
call list_to_bitstring( HF_bitmask(1,2), occ, elec_beta_num, N_int)
END_PROVIDER
BEGIN_PROVIDER [ integer(bit_kind), ref_bitmask, (N_int,2)]
implicit none
BEGIN_DOC
! Reference bit mask, used in Slater rules, chosen as Hartree-Fock bitmask
END_DOC
ref_bitmask = HF_bitmask
END_PROVIDER
2014-05-24 11:01:28 +02:00
BEGIN_PROVIDER [ integer, N_generators_bitmask ]
implicit none
BEGIN_DOC
! Number of bitmasks for generators
END_DOC
logical :: exists
PROVIDE ezfio_filename
call ezfio_has_bitmasks_N_mask_gen(exists)
if (exists) then
call ezfio_get_bitmasks_N_mask_gen(N_generators_bitmask)
integer :: N_int_check
integer :: bit_kind_check
call ezfio_get_bitmasks_bit_kind(bit_kind_check)
if (bit_kind_check /= bit_kind) then
print *, bit_kind_check, bit_kind
print *, 'Error: bit_kind is not correct in EZFIO file'
endif
call ezfio_get_bitmasks_N_int(N_int_check)
if (N_int_check /= N_int) then
print *, N_int_check, N_int
print *, 'Error: N_int is not correct in EZFIO file'
endif
else
N_generators_bitmask = 1
endif
ASSERT (N_generators_bitmask > 0)
END_PROVIDER
BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask, (N_int,2,6,N_generators_bitmask) ]
2014-05-24 11:01:28 +02:00
implicit none
BEGIN_DOC
2015-03-02 10:32:04 +01:00
! Bitmasks for generator determinants.
! (N_int, alpha/beta, hole/particle, generator).
!
! 3rd index is :
2015-03-02 10:32:04 +01:00
!
! * 1 : hole for single exc
2015-03-02 10:32:04 +01:00
!
! * 2 : particle for single exc
2015-03-02 10:32:04 +01:00
!
! * 3 : hole for 1st exc of double
2015-03-02 10:32:04 +01:00
!
! * 4 : particle for 1st exc of double
2015-03-02 10:32:04 +01:00
!
! * 5 : hole for 2nd exc of double
!
! * 6 : particle for 2nd exc of double
!
2014-05-24 11:01:28 +02:00
END_DOC
logical :: exists
PROVIDE ezfio_filename
call ezfio_has_bitmasks_generators(exists)
if (exists) then
call ezfio_get_bitmasks_generators(generators_bitmask)
else
integer :: k, ispin
do k=1,N_generators_bitmask
do ispin=1,2
generators_bitmask(:,ispin,s_hole ,k) = full_ijkl_bitmask(:,d_hole1)
generators_bitmask(:,ispin,s_part ,k) = full_ijkl_bitmask(:,d_part1)
generators_bitmask(:,ispin,d_hole1,k) = full_ijkl_bitmask(:,d_hole1)
generators_bitmask(:,ispin,d_part1,k) = full_ijkl_bitmask(:,d_part1)
generators_bitmask(:,ispin,d_hole2,k) = full_ijkl_bitmask(:,d_hole2)
generators_bitmask(:,ispin,d_part2,k) = full_ijkl_bitmask(:,d_part2)
enddo
enddo
2014-05-24 11:01:28 +02:00
endif
END_PROVIDER
2014-05-13 13:57:58 +02:00
BEGIN_PROVIDER [ integer, N_cas_bitmask ]
implicit none
BEGIN_DOC
! Number of bitmasks for CAS
END_DOC
logical :: exists
PROVIDE ezfio_filename
call ezfio_has_bitmasks_N_mask_cas(exists)
if (exists) then
call ezfio_get_bitmasks_N_mask_cas(N_cas_bitmask)
integer :: N_int_check
integer :: bit_kind_check
call ezfio_get_bitmasks_bit_kind(bit_kind_check)
if (bit_kind_check /= bit_kind) then
print *, bit_kind_check, bit_kind
print *, 'Error: bit_kind is not correct in EZFIO file'
endif
call ezfio_get_bitmasks_N_int(N_int_check)
if (N_int_check /= N_int) then
print *, N_int_check, N_int
print *, 'Error: N_int is not correct in EZFIO file'
endif
else
N_cas_bitmask = 1
endif
ASSERT (N_cas_bitmask > 0)
END_PROVIDER
BEGIN_PROVIDER [ integer(bit_kind), cas_bitmask, (N_int,2,N_cas_bitmask) ]
implicit none
BEGIN_DOC
! Bitmasks for CAS reference determinants. (N_int, alpha/beta, CAS reference)
END_DOC
logical :: exists
integer :: i
PROVIDE ezfio_filename
call ezfio_has_bitmasks_cas(exists)
if (exists) then
call ezfio_get_bitmasks_cas(cas_bitmask)
else
do i=1,N_cas_bitmask
cas_bitmask(:,:,i) = iand(not(HF_bitmask(:,:)),full_ijkl_bitmask(:,:))
enddo
endif
END_PROVIDER
BEGIN_PROVIDER [ integer(bit_kind), inact_bitmask, (N_int,2) ]
&BEGIN_PROVIDER [ integer(bit_kind), virt_bitmask, (N_int,2) ]
implicit none
BEGIN_DOC
! Bitmasks for the inactive orbitals that are excited in post CAS method
END_DOC
logical :: exists
integer :: j
PROVIDE ezfio_filename
do j = 1, N_int
inact_bitmask(j,1) = xor(generators_bitmask(j,1,1,1),cas_bitmask(j,1,1))
inact_bitmask(j,2) = xor(generators_bitmask(j,2,1,1),cas_bitmask(j,2,1))
virt_bitmask(j,1) = xor(generators_bitmask(j,1,2,1),cas_bitmask(j,1,1))
virt_bitmask(j,2) = xor(generators_bitmask(j,2,2,1),cas_bitmask(j,2,1))
enddo
END_PROVIDER
BEGIN_PROVIDER [ integer, i_bitmask_gen ]
implicit none
BEGIN_DOC
! Current bitmask for the generators
END_DOC
i_bitmask_gen = 1
END_PROVIDER