10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-07-31 09:34:05 +02:00
QuantumPackage/src/mo_two_e_ints/cholesky.irp.f

99 lines
2.8 KiB
Fortran
Raw Normal View History

2024-06-07 16:09:53 +02:00
BEGIN_PROVIDER [ logical, do_mo_cholesky ]
2023-07-12 12:34:48 +02:00
implicit none
BEGIN_DOC
2024-06-07 16:09:53 +02:00
! If True, use Cholesky vectors for MO integrals
2023-07-12 12:34:48 +02:00
END_DOC
2024-06-07 16:09:53 +02:00
do_mo_cholesky = do_ao_cholesky
2023-07-12 12:34:48 +02:00
END_PROVIDER
2024-06-07 16:09:53 +02:00
BEGIN_PROVIDER [ integer, cholesky_mo_num ]
2023-05-04 15:50:40 +02:00
implicit none
BEGIN_DOC
2024-06-07 16:09:53 +02:00
! Number of Cholesky vectors in MO basis
2023-05-04 15:50:40 +02:00
END_DOC
2024-06-07 16:09:53 +02:00
integer, external :: getUnitAndOpen
integer :: iunit
if (read_mo_cholesky) then
iunit = getUnitAndOpen(trim(ezfio_work_dir)//'cholesky_mo_transp', 'R')
read(iunit) cholesky_mo_num
close(iunit)
else
cholesky_mo_num = cholesky_ao_num
endif
2023-05-17 16:55:29 +02:00
END_PROVIDER
2024-06-07 16:09:53 +02:00
!BEGIN_PROVIDER [ double precision, cholesky_mo, (mo_num, mo_num, cholesky_mo_num) ]
! implicit none
! BEGIN_DOC
! ! Cholesky vectors in MO basis
! END_DOC
!
! integer :: k, i, j
!
! call set_multiple_levels_omp(.False.)
! !$OMP PARALLEL DO PRIVATE(k)
! do k=1,cholesky_mo_num
! do j=1,mo_num
! do i=1,mo_num
! cholesky_mo(i,j,k) = cholesky_mo_transp(k,i,j)
! enddo
! enddo
! enddo
! !$OMP END PARALLEL DO
!
!END_PROVIDER
!
2023-07-12 12:34:48 +02:00
BEGIN_PROVIDER [ double precision, cholesky_mo_transp, (cholesky_mo_num, mo_num, mo_num) ]
2023-05-17 16:55:29 +02:00
implicit none
BEGIN_DOC
2024-06-07 16:09:53 +02:00
! Cholesky vectors in MO basis. Warning: it is transposed wrt cholesky_ao:
!
! - cholesky_ao is (ao_num^2 x cholesky_ao_num)
!
! - cholesky_mo_transp is (cholesky_mo_num x mo_num^2)
2023-05-17 16:55:29 +02:00
END_DOC
double precision, allocatable :: X(:,:,:)
double precision :: wall0, wall1
2024-06-07 16:09:53 +02:00
integer, external :: getUnitAndOpen
integer :: iunit, ierr, rank
2023-06-12 14:05:36 +02:00
2024-06-07 16:09:53 +02:00
if (read_mo_cholesky) then
print *, 'Reading Cholesky MO vectors from disk...'
iunit = getUnitAndOpen(trim(ezfio_work_dir)//'cholesky_mo_transp', 'R')
read(iunit) rank
if (cholesky_mo_num /= rank) then
stop 'inconsistent rank'
endif
read(iunit) cholesky_mo_transp
close(iunit)
else
print *, 'AO->MO Transformation of Cholesky vectors'
call wall_time(wall0)
allocate(X(mo_num,cholesky_mo_num,ao_num), stat=ierr)
if (ierr /= 0) then
print *, irp_here, ': Allocation failed'
endif
call dgemm('T','N', ao_num*cholesky_mo_num, mo_num, ao_num, 1.d0, &
cholesky_ao, ao_num, mo_coef, ao_num, 0.d0, X, ao_num*cholesky_mo_num)
call dgemm('T','N', cholesky_mo_num*mo_num, mo_num, ao_num, 1.d0, &
X, ao_num, mo_coef, ao_num, 0.d0, cholesky_mo_transp, cholesky_mo_num*mo_num)
deallocate(X)
call wall_time(wall1)
print*,'Time to provide MO cholesky vectors = ',(wall1-wall0)/60.d0, ' min'
if (write_mo_cholesky) then
print *, 'Writing Cholesky MO vectors to disk...'
iunit = getUnitAndOpen(trim(ezfio_work_dir)//'cholesky_mo_transp', 'W')
write(iunit) rank
write(iunit) cholesky_mo_transp
close(iunit)
call ezfio_set_mo_two_e_ints_io_mo_cholesky('Read')
endif
endif
2023-05-04 15:50:40 +02:00
END_PROVIDER