9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 19:43:32 +01:00

Merge branch 'dev-stable' of https://github.com/QuantumPackage/qp2 into dev-stable

This commit is contained in:
Anthony Scemama 2024-07-03 16:13:17 +02:00
commit d686972988
6 changed files with 170 additions and 74 deletions

View File

@ -25,7 +25,10 @@ END_PROVIDER
! Last dimension of cholesky_ao is cholesky_ao_num ! Last dimension of cholesky_ao is cholesky_ao_num
! !
! https://mogp-emulator.readthedocs.io/en/latest/methods/proc/ProcPivotedCholesky.html ! https://mogp-emulator.readthedocs.io/en/latest/methods/proc/ProcPivotedCholesky.html
!
! https://doi.org/10.1016/j.apnum.2011.10.001 : Page 4, Algorithm 1 ! https://doi.org/10.1016/j.apnum.2011.10.001 : Page 4, Algorithm 1
!
! https://www.diva-portal.org/smash/get/diva2:396223/FULLTEXT01.pdf
END_DOC END_DOC
integer*8 :: ndim8 integer*8 :: ndim8
@ -155,9 +158,9 @@ END_PROVIDER
Lset(np8) = p8 Lset(np8) = p8
endif endif
enddo enddo
np = np8 if (np8 > ndim8) stop 'np>ndim8'
np = int(np8,4)
if (np <= 0) stop 'np<=0' if (np <= 0) stop 'np<=0'
if (np > ndim8) stop 'np>ndim8'
rank_max = min(np,20*elec_num*elec_num) rank_max = min(np,20*elec_num*elec_num)
call mmap(trim(ezfio_work_dir)//'cholesky_ao_tmp', (/ ndim8, rank_max /), 8, fd(1), .False., .True., c_pointer(1)) call mmap(trim(ezfio_work_dir)//'cholesky_ao_tmp', (/ ndim8, rank_max /), 8, fd(1), .False., .True., c_pointer(1))
@ -428,7 +431,7 @@ END_PROVIDER
Lset(np8) = p8 Lset(np8) = p8
endif endif
enddo enddo
np = np8 np = int(np8,4)
enddo enddo

View File

@ -40,7 +40,7 @@ end
! Min and max values of the MOs for which the integrals are in the cache ! Min and max values of the MOs for which the integrals are in the cache
END_DOC END_DOC
mo_integrals_cache_size = 2_8**mo_integrals_cache_shift mo_integrals_cache_size = 2**mo_integrals_cache_shift
mo_integrals_cache_min = max(1,elec_alpha_num - (mo_integrals_cache_size/2 - 1) ) mo_integrals_cache_min = max(1,elec_alpha_num - (mo_integrals_cache_size/2 - 1) )
mo_integrals_cache_max = min(mo_num, mo_integrals_cache_min + mo_integrals_cache_size - 1) mo_integrals_cache_max = min(mo_num, mo_integrals_cache_min + mo_integrals_cache_size - 1)

View File

@ -12,6 +12,9 @@ program four_idx_transform
! !
END_DOC END_DOC
if (do_mo_cholesky) then
stop 'Not implemented with Cholesky integrals'
endif
io_mo_two_e_integrals = 'Write' io_mo_two_e_integrals = 'Write'
SOFT_TOUCH io_mo_two_e_integrals SOFT_TOUCH io_mo_two_e_integrals
if (.true.) then if (.true.) then

View File

@ -557,7 +557,7 @@ subroutine export_trexio(update,full_path)
do k=1,cholesky_ao_num do k=1,cholesky_ao_num
do j=1,mo_num do j=1,mo_num
do i=1,mo_num do i=1,mo_num
integral = cholesky_mo(i,j,k) integral = cholesky_mo_transp(k,i,j)
if (integral == 0.d0) cycle if (integral == 0.d0) cycle
icount += 1_8 icount += 1_8
chol_buffer(icount) = integral chol_buffer(icount) = integral

View File

@ -28,7 +28,7 @@ subroutine run(f)
integer(trexio_t), intent(in) :: f ! TREXIO file handle integer(trexio_t), intent(in) :: f ! TREXIO file handle
integer(trexio_exit_code) :: rc integer(trexio_exit_code) :: rc
integer ::i,j,k,l integer :: i,j,k,l, iunit
integer(8) :: m, n_integrals integer(8) :: m, n_integrals
double precision :: integral double precision :: integral
@ -41,10 +41,12 @@ subroutine run(f)
integer , allocatable :: Vi(:,:) integer , allocatable :: Vi(:,:)
double precision :: s double precision :: s
! TODO: integer*4 :: BUFSIZE
! - If Cholesky AO in trexio file, read cholesky ao vectors integer :: rank
! - If Cholesky MO in trexio file, read cholesky mo vectors double precision, allocatable :: tmp(:,:,:)
! - If Cholesky MO not in trexio file, force do_cholesky_mo to False integer*8 :: offset, icount
integer, external :: getUnitAndOpen
if (trexio_has_nucleus_repulsion(f) == TREXIO_SUCCESS) then if (trexio_has_nucleus_repulsion(f) == TREXIO_SUCCESS) then
rc = trexio_read_nucleus_repulsion(f, s) rc = trexio_read_nucleus_repulsion(f, s)
@ -119,16 +121,58 @@ subroutine run(f)
rc = trexio_has_ao_2e_int(f) rc = trexio_has_ao_2e_int(f)
PROVIDE ao_num PROVIDE ao_num
if (rc /= TREXIO_HAS_NOT) then
rc = trexio_has_ao_2e_int_eri_cholesky(f)
if (rc /= TREXIO_HAS_NOT) then
rc = trexio_read_ao_2e_int_eri_cholesky_num(f, rank)
call trexio_assert(rc, TREXIO_SUCCESS)
allocate(tmp(ao_num,ao_num,rank))
tmp(:,:,:) = 0.d0
BUFSIZE=ao_num**2
allocate(Vi(3,BUFSIZE), V(BUFSIZE))
offset = 0_8
icount = BUFSIZE
rc = TREXIO_SUCCESS
do while (icount == size(V))
rc = trexio_read_ao_2e_int_eri_cholesky(f, offset, icount, Vi, V)
do m=1,icount
i = Vi(1,m)
j = Vi(2,m)
k = Vi(3,m)
integral = V(m)
tmp(i,j,k) = integral
enddo
offset = offset + icount
if (rc /= TREXIO_SUCCESS) then
exit
endif
end do
print *, 'Writing Cholesky AO vectors to disk...'
iunit = getUnitAndOpen(trim(ezfio_work_dir)//'cholesky_ao', 'W')
write(iunit) rank
write(iunit) tmp(:,:,:)
close(iunit)
call ezfio_set_ao_two_e_ints_io_ao_cholesky('Read')
deallocate(Vi, V, tmp)
print *, 'Cholesky AO integrals read from TREXIO file'
endif
rc = trexio_has_ao_2e_int_eri(f)
if (rc /= TREXIO_HAS_NOT) then if (rc /= TREXIO_HAS_NOT) then
PROVIDE ao_integrals_map PROVIDE ao_integrals_map
integer*4 :: BUFSIZE
BUFSIZE=ao_num**2 BUFSIZE=ao_num**2
allocate(buffer_i(BUFSIZE), buffer_values(BUFSIZE)) allocate(buffer_i(BUFSIZE), buffer_values(BUFSIZE))
allocate(Vi(4,BUFSIZE), V(BUFSIZE)) allocate(Vi(4,BUFSIZE), V(BUFSIZE))
integer*8 :: offset, icount
offset = 0_8 offset = 0_8
icount = BUFSIZE icount = BUFSIZE
rc = TREXIO_SUCCESS rc = TREXIO_SUCCESS
@ -159,6 +203,7 @@ subroutine run(f)
deallocate(buffer_i, buffer_values, Vi, V) deallocate(buffer_i, buffer_values, Vi, V)
print *, 'AO integrals read from TREXIO file' print *, 'AO integrals read from TREXIO file'
endif
else else
print *, 'AO integrals not found in TREXIO file' print *, 'AO integrals not found in TREXIO file'
endif endif
@ -186,6 +231,49 @@ subroutine run(f)
rc = trexio_has_mo_2e_int(f) rc = trexio_has_mo_2e_int(f)
if (rc /= TREXIO_HAS_NOT) then if (rc /= TREXIO_HAS_NOT) then
rc = trexio_has_mo_2e_int_eri_cholesky(f)
if (rc /= TREXIO_HAS_NOT) then
rc = trexio_read_mo_2e_int_eri_cholesky_num(f, rank)
call trexio_assert(rc, TREXIO_SUCCESS)
allocate(tmp(rank,mo_num,mo_num))
tmp(:,:,:) = 0.d0
BUFSIZE=mo_num**2
allocate(Vi(3,BUFSIZE), V(BUFSIZE))
offset = 0_8
icount = BUFSIZE
rc = TREXIO_SUCCESS
do while (icount == size(V))
rc = trexio_read_mo_2e_int_eri_cholesky(f, offset, icount, Vi, V)
do m=1,icount
i = Vi(1,m)
j = Vi(2,m)
k = Vi(3,m)
integral = V(m)
tmp(k,i,j) = integral
enddo
offset = offset + icount
if (rc /= TREXIO_SUCCESS) then
exit
endif
end do
print *, 'Writing Cholesky MO vectors to disk...'
iunit = getUnitAndOpen(trim(ezfio_work_dir)//'cholesky_mo_transp', 'W')
write(iunit) rank
write(iunit) tmp(:,:,:)
close(iunit)
call ezfio_set_mo_two_e_ints_io_mo_cholesky('Read')
deallocate(Vi, V, tmp)
print *, 'Cholesky MO integrals read from TREXIO file'
endif
rc = trexio_has_mo_2e_int_eri(f)
if (rc /= TREXIO_HAS_NOT) then
BUFSIZE=mo_num**2 BUFSIZE=mo_num**2
allocate(buffer_i(BUFSIZE), buffer_values(BUFSIZE)) allocate(buffer_i(BUFSIZE), buffer_values(BUFSIZE))
allocate(Vi(4,BUFSIZE), V(BUFSIZE)) allocate(Vi(4,BUFSIZE), V(BUFSIZE))
@ -220,6 +308,8 @@ subroutine run(f)
call ezfio_set_mo_two_e_ints_io_mo_two_e_integrals('Read') call ezfio_set_mo_two_e_ints_io_mo_two_e_integrals('Read')
deallocate(buffer_i, buffer_values, Vi, V) deallocate(buffer_i, buffer_values, Vi, V)
print *, 'MO integrals read from TREXIO file' print *, 'MO integrals read from TREXIO file'
endif
else else
print *, 'MO integrals not found in TREXIO file' print *, 'MO integrals not found in TREXIO file'
endif endif

View File

@ -1856,7 +1856,7 @@ subroutine pivoted_cholesky( A, rank, tol, ndim, U)
! !
! matrix A is destroyed inside this subroutine ! matrix A is destroyed inside this subroutine
! Cholesky vectors are stored in U ! Cholesky vectors are stored in U
! dimension of U: U(1:rank, 1:n) ! dimension of U: U(1:n, 1:rank)
! U is allocated inside this subroutine ! U is allocated inside this subroutine
! rank is the number of Cholesky vectors depending on tol ! rank is the number of Cholesky vectors depending on tol
! !