mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-22 04:13:55 +01:00
commit
01331ff512
@ -17,12 +17,15 @@ program bi_ort_ints
|
||||
! call test_3e
|
||||
! call test_5idx
|
||||
! call test_5idx2
|
||||
call test_4idx()
|
||||
! call test_4idx()
|
||||
!call test_4idx_n4()
|
||||
!call test_4idx2()
|
||||
!call test_5idx2
|
||||
!call test_5idx
|
||||
|
||||
call test_mos_in_r()
|
||||
call test_int2_grad1_u12_bimo_t()
|
||||
|
||||
end
|
||||
|
||||
subroutine test_5idx2
|
||||
@ -472,4 +475,94 @@ subroutine test_4idx()
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine test_mos_in_r()
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i, j
|
||||
double precision :: err_tot, nrm_tot, err_loc, acc_thr
|
||||
|
||||
PROVIDE mos_l_in_r_array_transp_old mos_r_in_r_array_transp_old
|
||||
PROVIDE mos_l_in_r_array_transp mos_r_in_r_array_transp
|
||||
|
||||
acc_thr = 1d-13
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do i = 1, mo_num
|
||||
do j = 1, n_points_final_grid
|
||||
err_loc = dabs(mos_l_in_r_array_transp_old(j,i) - mos_l_in_r_array_transp(j,i))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", j, i
|
||||
print*, " old res", mos_l_in_r_array_transp_old(j,i)
|
||||
print*, " new res", mos_l_in_r_array_transp (j,i)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(mos_l_in_r_array_transp_old(j,i))
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on mos_l_in_r_array_transp (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do i = 1, mo_num
|
||||
do j = 1, n_points_final_grid
|
||||
err_loc = dabs(mos_r_in_r_array_transp_old(j,i) - mos_r_in_r_array_transp(j,i))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", j, i
|
||||
print*, " old res", mos_r_in_r_array_transp_old(j,i)
|
||||
print*, " new res", mos_r_in_r_array_transp (j,i)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(mos_r_in_r_array_transp_old(j,i))
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on mos_r_in_r_array_transp (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine test_int2_grad1_u12_bimo_t()
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint, m
|
||||
double precision :: err_tot, nrm_tot, err_loc, acc_thr
|
||||
|
||||
PROVIDE int2_grad1_u12_bimo_t_old
|
||||
PROVIDE int2_grad1_u12_bimo_t
|
||||
|
||||
acc_thr = 1d-13
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
err_loc = dabs(int2_grad1_u12_bimo_t_old(ipoint,m,j,i) - int2_grad1_u12_bimo_t(ipoint,m,j,i))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", ipoint, m, j, i
|
||||
print*, " old res", int2_grad1_u12_bimo_t_old(ipoint,m,j,i)
|
||||
print*, " new res", int2_grad1_u12_bimo_t (ipoint,m,j,i)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(int2_grad1_u12_bimo_t_old(ipoint,m,j,i))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on int2_grad1_u12_bimo_t (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
||||
|
@ -710,6 +710,8 @@ BEGIN_PROVIDER [double precision, noL_0e]
|
||||
|
||||
endif
|
||||
|
||||
print*, " noL_0e =", noL_0e
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
@ -1,360 +1,54 @@
|
||||
|
||||
! ---
|
||||
|
||||
! TODO :: optimization : transform into a DGEMM
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_v_ki_bi_ortho_erf_rk_cst_mu, (mo_num, mo_num, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! mo_v_ki_bi_ortho_erf_rk_cst_mu(k,i,ip) = int dr chi_k(r) phi_i(r) (erf(mu |r - R_ip|) - 1 )/(2|r - R_ip|) on the BI-ORTHO MO basis
|
||||
!
|
||||
! where phi_k(r) is a LEFT MOs and phi_i(r) is a RIGHT MO
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: ipoint
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid,v_ij_erf_rk_cst_mu,mo_v_ki_bi_ortho_erf_rk_cst_mu)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho( v_ij_erf_rk_cst_mu (1,1,ipoint), size(v_ij_erf_rk_cst_mu, 1) &
|
||||
, mo_v_ki_bi_ortho_erf_rk_cst_mu(1,1,ipoint), size(mo_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
mo_v_ki_bi_ortho_erf_rk_cst_mu = mo_v_ki_bi_ortho_erf_rk_cst_mu * 0.5d0
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_v_ki_bi_ortho_erf_rk_cst_mu_transp, (n_points_final_grid, mo_num, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! int dr phi_i(r) phi_j(r) (erf(mu(R) |r - R|) - 1)/(2|r - R|) on the BI-ORTHO MO basis
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j
|
||||
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
mo_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,j,i) = mo_v_ki_bi_ortho_erf_rk_cst_mu(j,i,ipoint)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!FREE mo_v_ki_bi_ortho_erf_rk_cst_mu
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
! TODO :: optimization : transform into a DGEMM
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_x_v_ki_bi_ortho_erf_rk_cst_mu, (mo_num, mo_num, 3, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! mo_x_v_ki_bi_ortho_erf_rk_cst_mu(k,i,m,ip) = int dr x(m) * chi_k(r) phi_i(r) (erf(mu |r - R_ip|) - 1)/2|r - R_ip| on the BI-ORTHO MO basis
|
||||
!
|
||||
! where chi_k(r)/phi_i(r) are left/right MOs, m=1 => x(m) = x, m=2 => x(m) = y, m=3 => x(m) = z,
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: ipoint
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid,x_v_ij_erf_rk_cst_mu_transp,mo_x_v_ki_bi_ortho_erf_rk_cst_mu)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
call ao_to_mo_bi_ortho( x_v_ij_erf_rk_cst_mu_transp (1,1,1,ipoint), size(x_v_ij_erf_rk_cst_mu_transp, 1) &
|
||||
, mo_x_v_ki_bi_ortho_erf_rk_cst_mu(1,1,1,ipoint), size(mo_x_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
call ao_to_mo_bi_ortho( x_v_ij_erf_rk_cst_mu_transp (1,1,2,ipoint), size(x_v_ij_erf_rk_cst_mu_transp, 1) &
|
||||
, mo_x_v_ki_bi_ortho_erf_rk_cst_mu(1,1,2,ipoint), size(mo_x_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
call ao_to_mo_bi_ortho( x_v_ij_erf_rk_cst_mu_transp (1,1,3,ipoint), size(x_v_ij_erf_rk_cst_mu_transp, 1) &
|
||||
, mo_x_v_ki_bi_ortho_erf_rk_cst_mu(1,1,3,ipoint), size(mo_x_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu = 0.5d0 * mo_x_v_ki_bi_ortho_erf_rk_cst_mu
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_transp, (ao_num, ao_num, 3, n_points_final_grid)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!print *, ' providing int2_grad1_u12_ao_transp ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
if(test_cycle_tc) then
|
||||
|
||||
PROVIDE int2_grad1_u12_ao_test
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
int2_grad1_u12_ao_transp(j,i,1,ipoint) = int2_grad1_u12_ao_test(j,i,ipoint,1)
|
||||
int2_grad1_u12_ao_transp(j,i,2,ipoint) = int2_grad1_u12_ao_test(j,i,ipoint,2)
|
||||
int2_grad1_u12_ao_transp(j,i,3,ipoint) = int2_grad1_u12_ao_test(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
FREE int2_grad1_u12_ao_test
|
||||
|
||||
else
|
||||
|
||||
PROVIDE int2_grad1_u12_ao
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
int2_grad1_u12_ao_transp(j,i,1,ipoint) = int2_grad1_u12_ao(j,i,ipoint,1)
|
||||
int2_grad1_u12_ao_transp(j,i,2,ipoint) = int2_grad1_u12_ao(j,i,ipoint,2)
|
||||
int2_grad1_u12_ao_transp(j,i,3,ipoint) = int2_grad1_u12_ao(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
endif
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_ao_transp (min) = ', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [double precision, int2_grad1_u12_bimo_transp, (mo_num, mo_num, 3, n_points_final_grid)]
|
||||
|
||||
implicit none
|
||||
integer :: ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE int2_grad1_u12_ao_transp
|
||||
|
||||
!print *, ' providing int2_grad1_u12_bimo_transp ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid,int2_grad1_u12_ao_transp,int2_grad1_u12_bimo_transp)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho( int2_grad1_u12_ao_transp (1,1,1,ipoint), size(int2_grad1_u12_ao_transp , 1) &
|
||||
, int2_grad1_u12_bimo_transp(1,1,1,ipoint), size(int2_grad1_u12_bimo_transp, 1) )
|
||||
call ao_to_mo_bi_ortho( int2_grad1_u12_ao_transp (1,1,2,ipoint), size(int2_grad1_u12_ao_transp , 1) &
|
||||
, int2_grad1_u12_bimo_transp(1,1,2,ipoint), size(int2_grad1_u12_bimo_transp, 1) )
|
||||
call ao_to_mo_bi_ortho( int2_grad1_u12_ao_transp (1,1,3,ipoint), size(int2_grad1_u12_ao_transp , 1) &
|
||||
, int2_grad1_u12_bimo_transp(1,1,3,ipoint), size(int2_grad1_u12_bimo_transp, 1) )
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
!FREE int2_grad1_u12_ao_transp
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_bimo_transp (min) =', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [double precision, int2_grad1_u12_bimo_t, (n_points_final_grid, 3, mo_num, mo_num)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!call wall_time(wall0)
|
||||
!print *, ' providing int2_grad1_u12_bimo_t ...'
|
||||
integer :: i, j, ipoint
|
||||
double precision :: tt1, tt2
|
||||
double precision, allocatable :: tmp(:,:,:,:)
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE int2_grad1_u12_bimo_transp
|
||||
PROVIDE int2_grad1_u12_ao
|
||||
|
||||
call wall_time(tt1)
|
||||
|
||||
allocate(tmp(mo_num,mo_num,n_points_final_grid,3))
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (ao_num, mo_num, n_points_final_grid, int2_grad1_u12_ao, tmp)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,1), ao_num, tmp(1,1,ipoint,1), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,2), ao_num, tmp(1,1,ipoint,2), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,3), ao_num, tmp(1,1,ipoint,3), mo_num)
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, ipoint) &
|
||||
!$OMP SHARED (mo_num, n_points_final_grid, tmp, int2_grad1_u12_bimo_t)
|
||||
!$OMP DO COLLAPSE(2) SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
int2_grad1_u12_bimo_t(ipoint,1,j,i) = int2_grad1_u12_bimo_transp(j,i,1,ipoint)
|
||||
int2_grad1_u12_bimo_t(ipoint,2,j,i) = int2_grad1_u12_bimo_transp(j,i,2,ipoint)
|
||||
int2_grad1_u12_bimo_t(ipoint,3,j,i) = int2_grad1_u12_bimo_transp(j,i,3,ipoint)
|
||||
int2_grad1_u12_bimo_t(ipoint,1,j,i) = tmp(j,i,ipoint,1)
|
||||
int2_grad1_u12_bimo_t(ipoint,2,j,i) = tmp(j,i,ipoint,2)
|
||||
int2_grad1_u12_bimo_t(ipoint,3,j,i) = tmp(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
FREE int2_grad1_u12_bimo_transp
|
||||
deallocate(tmp)
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_bimo_t (min) =', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [double precision, int2_grad1_u12_ao_t, (n_points_final_grid, 3, ao_num, ao_num)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!call wall_time(wall0)
|
||||
!print *, ' providing int2_grad1_u12_ao_t ...'
|
||||
|
||||
PROVIDE int2_grad1_u12_ao
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
int2_grad1_u12_ao_t(ipoint,1,j,i) = int2_grad1_u12_ao(j,i,ipoint,1)
|
||||
int2_grad1_u12_ao_t(ipoint,2,j,i) = int2_grad1_u12_ao(j,i,ipoint,2)
|
||||
int2_grad1_u12_ao_t(ipoint,3,j,i) = int2_grad1_u12_ao(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_ao_t (min) =', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp, (n_points_final_grid, 3, mo_num, mo_num)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,1,j,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu(j,i,1,ipoint)
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,2,j,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu(j,i,2,ipoint)
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,3,j,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu(j,i,3,ipoint)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, x_W_ki_bi_ortho_erf_rk, (n_points_final_grid, 3, mo_num, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! x_W_ki_bi_ortho_erf_rk(ip,m,k,i) = \int dr chi_k(r) \frac{(1 - erf(mu |r-R_ip|))}{2|r-R_ip|} (x(m)-R_ip(m)) phi_i(r) ON THE BI-ORTHO MO BASIS
|
||||
!
|
||||
! where chi_k(r)/phi_i(r) are left/right MOs, m=1 => X(m) = x, m=2 => X(m) = y, m=3 => X(m) = z,
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
include 'constants.include.F'
|
||||
|
||||
integer :: ipoint, m, i, k
|
||||
double precision :: xyz
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!print*, ' providing x_W_ki_bi_ortho_erf_rk ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint,m,i,k,xyz) &
|
||||
!$OMP SHARED (x_W_ki_bi_ortho_erf_rk,n_points_final_grid,mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_num,final_grid_points)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
xyz = final_grid_points(m,ipoint)
|
||||
x_W_ki_bi_ortho_erf_rk(ipoint,m,k,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,m,k,i) - xyz * mo_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,k,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
! FREE mo_v_ki_bi_ortho_erf_rk_cst_mu_transp
|
||||
! FREE mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' time to provide x_W_ki_bi_ortho_erf_rk = ', wall1 - wall0
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, x_W_ki_bi_ortho_erf_rk_diag, (n_points_final_grid, 3, mo_num)]
|
||||
BEGIN_DOC
|
||||
! x_W_ki_bi_ortho_erf_rk_diag(ip,m,i) = \int dr chi_i(r) (1 - erf(mu |r-R_ip|)) (x(m)-X(m)_ip) phi_i(r) ON THE BI-ORTHO MO BASIS
|
||||
!
|
||||
! where chi_k(r)/phi_i(r) are left/right MOs, m=1 => X(m) = x, m=2 => X(m) = y, m=3 => X(m) = z,
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
include 'constants.include.F'
|
||||
|
||||
integer :: ipoint, m, i
|
||||
double precision :: xyz
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!print*,'providing x_W_ki_bi_ortho_erf_rk_diag ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint,m,i,xyz) &
|
||||
!$OMP SHARED (x_W_ki_bi_ortho_erf_rk_diag,n_points_final_grid,mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_num,final_grid_points)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do i = 1, mo_num
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
xyz = final_grid_points(m,ipoint)
|
||||
x_W_ki_bi_ortho_erf_rk_diag(ipoint,m,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,m,i,i) - xyz * mo_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,i,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print*,'time to provide x_W_ki_bi_ortho_erf_rk_diag = ',wall1 - wall0
|
||||
call wall_time(tt2)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for int2_grad1_u12_bimo_t (sec) = ', (tt2 - tt1)
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
362
plugins/local/bi_ort_ints/semi_num_ints_mo_old.irp.f
Normal file
362
plugins/local/bi_ort_ints/semi_num_ints_mo_old.irp.f
Normal file
@ -0,0 +1,362 @@
|
||||
|
||||
! ---
|
||||
|
||||
! TODO :: optimization : transform into a DGEMM
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_v_ki_bi_ortho_erf_rk_cst_mu, (mo_num, mo_num, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! mo_v_ki_bi_ortho_erf_rk_cst_mu(k,i,ip) = int dr chi_k(r) phi_i(r) (erf(mu |r - R_ip|) - 1 )/(2|r - R_ip|) on the BI-ORTHO MO basis
|
||||
!
|
||||
! where phi_k(r) is a LEFT MOs and phi_i(r) is a RIGHT MO
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: ipoint
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid,v_ij_erf_rk_cst_mu,mo_v_ki_bi_ortho_erf_rk_cst_mu)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho( v_ij_erf_rk_cst_mu (1,1,ipoint), size(v_ij_erf_rk_cst_mu, 1) &
|
||||
, mo_v_ki_bi_ortho_erf_rk_cst_mu(1,1,ipoint), size(mo_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
mo_v_ki_bi_ortho_erf_rk_cst_mu = mo_v_ki_bi_ortho_erf_rk_cst_mu * 0.5d0
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_v_ki_bi_ortho_erf_rk_cst_mu_transp, (n_points_final_grid, mo_num, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! int dr phi_i(r) phi_j(r) (erf(mu(R) |r - R|) - 1)/(2|r - R|) on the BI-ORTHO MO basis
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j
|
||||
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
mo_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,j,i) = mo_v_ki_bi_ortho_erf_rk_cst_mu(j,i,ipoint)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!FREE mo_v_ki_bi_ortho_erf_rk_cst_mu
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
! TODO :: optimization : transform into a DGEMM
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_x_v_ki_bi_ortho_erf_rk_cst_mu, (mo_num, mo_num, 3, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! mo_x_v_ki_bi_ortho_erf_rk_cst_mu(k,i,m,ip) = int dr x(m) * chi_k(r) phi_i(r) (erf(mu |r - R_ip|) - 1)/2|r - R_ip| on the BI-ORTHO MO basis
|
||||
!
|
||||
! where chi_k(r)/phi_i(r) are left/right MOs, m=1 => x(m) = x, m=2 => x(m) = y, m=3 => x(m) = z,
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: ipoint
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid,x_v_ij_erf_rk_cst_mu_transp,mo_x_v_ki_bi_ortho_erf_rk_cst_mu)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
call ao_to_mo_bi_ortho( x_v_ij_erf_rk_cst_mu_transp (1,1,1,ipoint), size(x_v_ij_erf_rk_cst_mu_transp, 1) &
|
||||
, mo_x_v_ki_bi_ortho_erf_rk_cst_mu(1,1,1,ipoint), size(mo_x_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
call ao_to_mo_bi_ortho( x_v_ij_erf_rk_cst_mu_transp (1,1,2,ipoint), size(x_v_ij_erf_rk_cst_mu_transp, 1) &
|
||||
, mo_x_v_ki_bi_ortho_erf_rk_cst_mu(1,1,2,ipoint), size(mo_x_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
call ao_to_mo_bi_ortho( x_v_ij_erf_rk_cst_mu_transp (1,1,3,ipoint), size(x_v_ij_erf_rk_cst_mu_transp, 1) &
|
||||
, mo_x_v_ki_bi_ortho_erf_rk_cst_mu(1,1,3,ipoint), size(mo_x_v_ki_bi_ortho_erf_rk_cst_mu, 1) )
|
||||
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu = 0.5d0 * mo_x_v_ki_bi_ortho_erf_rk_cst_mu
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_transp, (ao_num, ao_num, 3, n_points_final_grid)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!print *, ' providing int2_grad1_u12_ao_transp ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
if(test_cycle_tc) then
|
||||
|
||||
PROVIDE int2_grad1_u12_ao_test
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
int2_grad1_u12_ao_transp(j,i,1,ipoint) = int2_grad1_u12_ao_test(j,i,ipoint,1)
|
||||
int2_grad1_u12_ao_transp(j,i,2,ipoint) = int2_grad1_u12_ao_test(j,i,ipoint,2)
|
||||
int2_grad1_u12_ao_transp(j,i,3,ipoint) = int2_grad1_u12_ao_test(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
FREE int2_grad1_u12_ao_test
|
||||
|
||||
else
|
||||
|
||||
PROVIDE int2_grad1_u12_ao
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
int2_grad1_u12_ao_transp(j,i,1,ipoint) = int2_grad1_u12_ao(j,i,ipoint,1)
|
||||
int2_grad1_u12_ao_transp(j,i,2,ipoint) = int2_grad1_u12_ao(j,i,ipoint,2)
|
||||
int2_grad1_u12_ao_transp(j,i,3,ipoint) = int2_grad1_u12_ao(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
endif
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_ao_transp (min) = ', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [double precision, int2_grad1_u12_bimo_transp, (mo_num, mo_num, 3, n_points_final_grid)]
|
||||
|
||||
implicit none
|
||||
integer :: ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE int2_grad1_u12_ao_transp
|
||||
|
||||
!print *, ' providing int2_grad1_u12_bimo_transp ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid,int2_grad1_u12_ao_transp,int2_grad1_u12_bimo_transp)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho( int2_grad1_u12_ao_transp (1,1,1,ipoint), size(int2_grad1_u12_ao_transp , 1) &
|
||||
, int2_grad1_u12_bimo_transp(1,1,1,ipoint), size(int2_grad1_u12_bimo_transp, 1) )
|
||||
call ao_to_mo_bi_ortho( int2_grad1_u12_ao_transp (1,1,2,ipoint), size(int2_grad1_u12_ao_transp , 1) &
|
||||
, int2_grad1_u12_bimo_transp(1,1,2,ipoint), size(int2_grad1_u12_bimo_transp, 1) )
|
||||
call ao_to_mo_bi_ortho( int2_grad1_u12_ao_transp (1,1,3,ipoint), size(int2_grad1_u12_ao_transp , 1) &
|
||||
, int2_grad1_u12_bimo_transp(1,1,3,ipoint), size(int2_grad1_u12_bimo_transp, 1) )
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
!FREE int2_grad1_u12_ao_transp
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_bimo_transp (min) =', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [double precision, int2_grad1_u12_bimo_t_old, (n_points_final_grid, 3, mo_num, mo_num)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!call wall_time(wall0)
|
||||
!print *, ' providing int2_grad1_u12_bimo_t_old ...'
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE int2_grad1_u12_bimo_transp
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
int2_grad1_u12_bimo_t_old(ipoint,1,j,i) = int2_grad1_u12_bimo_transp(j,i,1,ipoint)
|
||||
int2_grad1_u12_bimo_t_old(ipoint,2,j,i) = int2_grad1_u12_bimo_transp(j,i,2,ipoint)
|
||||
int2_grad1_u12_bimo_t_old(ipoint,3,j,i) = int2_grad1_u12_bimo_transp(j,i,3,ipoint)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
FREE int2_grad1_u12_bimo_transp
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_bimo_t_old (min) =', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [double precision, int2_grad1_u12_ao_t, (n_points_final_grid, 3, ao_num, ao_num)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!call wall_time(wall0)
|
||||
!print *, ' providing int2_grad1_u12_ao_t ...'
|
||||
|
||||
PROVIDE int2_grad1_u12_ao
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
int2_grad1_u12_ao_t(ipoint,1,j,i) = int2_grad1_u12_ao(j,i,ipoint,1)
|
||||
int2_grad1_u12_ao_t(ipoint,2,j,i) = int2_grad1_u12_ao(j,i,ipoint,2)
|
||||
int2_grad1_u12_ao_t(ipoint,3,j,i) = int2_grad1_u12_ao(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' wall time for int2_grad1_u12_ao_t (min) =', (wall1 - wall0) / 60.d0
|
||||
!call print_memory_usage()
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp, (n_points_final_grid, 3, mo_num, mo_num)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, ipoint
|
||||
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,1,j,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu(j,i,1,ipoint)
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,2,j,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu(j,i,2,ipoint)
|
||||
mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,3,j,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu(j,i,3,ipoint)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, x_W_ki_bi_ortho_erf_rk, (n_points_final_grid, 3, mo_num, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! x_W_ki_bi_ortho_erf_rk(ip,m,k,i) = \int dr chi_k(r) \frac{(1 - erf(mu |r-R_ip|))}{2|r-R_ip|} (x(m)-R_ip(m)) phi_i(r) ON THE BI-ORTHO MO BASIS
|
||||
!
|
||||
! where chi_k(r)/phi_i(r) are left/right MOs, m=1 => X(m) = x, m=2 => X(m) = y, m=3 => X(m) = z,
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
include 'constants.include.F'
|
||||
|
||||
integer :: ipoint, m, i, k
|
||||
double precision :: xyz
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!print*, ' providing x_W_ki_bi_ortho_erf_rk ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint,m,i,k,xyz) &
|
||||
!$OMP SHARED (x_W_ki_bi_ortho_erf_rk,n_points_final_grid,mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_num,final_grid_points)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
xyz = final_grid_points(m,ipoint)
|
||||
x_W_ki_bi_ortho_erf_rk(ipoint,m,k,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,m,k,i) - xyz * mo_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,k,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
! FREE mo_v_ki_bi_ortho_erf_rk_cst_mu_transp
|
||||
! FREE mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print *, ' time to provide x_W_ki_bi_ortho_erf_rk = ', wall1 - wall0
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, x_W_ki_bi_ortho_erf_rk_diag, (n_points_final_grid, 3, mo_num)]
|
||||
BEGIN_DOC
|
||||
! x_W_ki_bi_ortho_erf_rk_diag(ip,m,i) = \int dr chi_i(r) (1 - erf(mu |r-R_ip|)) (x(m)-X(m)_ip) phi_i(r) ON THE BI-ORTHO MO BASIS
|
||||
!
|
||||
! where chi_k(r)/phi_i(r) are left/right MOs, m=1 => X(m) = x, m=2 => X(m) = y, m=3 => X(m) = z,
|
||||
!
|
||||
! R_ip = the "ip"-th point of the DFT Grid
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
include 'constants.include.F'
|
||||
|
||||
integer :: ipoint, m, i
|
||||
double precision :: xyz
|
||||
double precision :: wall0, wall1
|
||||
|
||||
!print*,'providing x_W_ki_bi_ortho_erf_rk_diag ...'
|
||||
!call wall_time(wall0)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint,m,i,xyz) &
|
||||
!$OMP SHARED (x_W_ki_bi_ortho_erf_rk_diag,n_points_final_grid,mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_v_ki_bi_ortho_erf_rk_cst_mu_transp,mo_num,final_grid_points)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do i = 1, mo_num
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
xyz = final_grid_points(m,ipoint)
|
||||
x_W_ki_bi_ortho_erf_rk_diag(ipoint,m,i) = mo_x_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,m,i,i) - xyz * mo_v_ki_bi_ortho_erf_rk_cst_mu_transp(ipoint,i,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
!call wall_time(wall1)
|
||||
!print*,'time to provide x_W_ki_bi_ortho_erf_rk_diag = ',wall1 - wall0
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
@ -1,135 +1,70 @@
|
||||
|
||||
! TODO: left & right MO without duplicate AO calculation
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_r_in_r_array, (mo_num, n_points_final_grid)]
|
||||
BEGIN_PROVIDER[double precision, mos_l_in_r_array_transp, (n_points_final_grid, mo_num)]
|
||||
&BEGIN_PROVIDER[double precision, mos_r_in_r_array_transp, (n_points_final_grid, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_in_r_array(i,j) = value of the ith RIGHT mo on the jth grid point
|
||||
!
|
||||
! mos_l_in_r_array_transp(i,j) = value of the jth left-mo on the ith grid point
|
||||
! mos_r_in_r_array_transp(i,j) = value of the jth right-mo on the ith grid point
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
double precision :: mos_array(mo_num), r(3)
|
||||
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, r, mos_array) &
|
||||
!$OMP SHARED (mos_r_in_r_array, n_points_final_grid, mo_num, final_grid_points)
|
||||
integer :: i
|
||||
double precision :: tt0, tt1, tt2, tt3
|
||||
double precision :: r(3)
|
||||
double precision, allocatable :: aos_r(:,:)
|
||||
|
||||
call wall_time(tt0)
|
||||
|
||||
allocate(aos_r(ao_num,n_points_final_grid))
|
||||
|
||||
! provide everything required before OpenMP
|
||||
r(1) = final_grid_points(1,1)
|
||||
r(2) = final_grid_points(2,1)
|
||||
r(3) = final_grid_points(3,1)
|
||||
call give_all_aos_at_r(r, aos_r(1,1))
|
||||
|
||||
|
||||
call wall_time(tt2)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, r) &
|
||||
!$OMP SHARED(n_points_final_grid, final_grid_points, aos_r)
|
||||
!$OMP DO
|
||||
do i = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,i)
|
||||
r(2) = final_grid_points(2,i)
|
||||
r(3) = final_grid_points(3,i)
|
||||
call give_all_mos_r_at_r(r, mos_array)
|
||||
do j = 1, mo_num
|
||||
mos_r_in_r_array(j,i) = mos_array(j)
|
||||
enddo
|
||||
call give_all_aos_at_r(r, aos_r(1,i))
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
END_PROVIDER
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
! ---
|
||||
call wall_time(tt3)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for AOs on r (sec) = ', (tt3 - tt2)
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_r_in_r_array_transp, (n_points_final_grid, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_r_in_r_array_transp(i,j) = value of the jth mo on the ith grid point
|
||||
END_DOC
|
||||
call dgemm("T", "N", n_points_final_grid, mo_num, ao_num, &
|
||||
1.d0, &
|
||||
aos_r(1,1), ao_num, &
|
||||
mo_l_coef(1,1), ao_num, &
|
||||
0.d0, &
|
||||
mos_l_in_r_array_transp(1,1), n_points_final_grid)
|
||||
|
||||
implicit none
|
||||
integer :: i,j
|
||||
call dgemm("T", "N", n_points_final_grid, mo_num, ao_num, &
|
||||
1.d0, &
|
||||
aos_r(1,1), ao_num, &
|
||||
mo_r_coef(1,1), ao_num, &
|
||||
0.d0, &
|
||||
mos_r_in_r_array_transp(1,1), n_points_final_grid)
|
||||
|
||||
do i = 1, n_points_final_grid
|
||||
do j = 1, mo_num
|
||||
mos_r_in_r_array_transp(i,j) = mos_r_in_r_array(j,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
subroutine give_all_mos_r_at_r(r, mos_r_array)
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_r_array(i) = ith RIGHT MO function evaluated at "r"
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
double precision, intent(in) :: r(3)
|
||||
double precision, intent(out) :: mos_r_array(mo_num)
|
||||
double precision :: aos_array(ao_num)
|
||||
|
||||
call give_all_aos_at_r(r, aos_array)
|
||||
call dgemv('N', mo_num, ao_num, 1.d0, mo_r_coef_transp, mo_num, aos_array, 1, 0.d0, mos_r_array, 1)
|
||||
|
||||
end subroutine give_all_mos_r_at_r
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_l_in_r_array, (mo_num, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_in_r_array(i,j) = value of the ith LEFT mo on the jth grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
double precision :: mos_array(mo_num), r(3)
|
||||
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,r,mos_array,j) &
|
||||
!$OMP SHARED(mos_l_in_r_array,n_points_final_grid,mo_num,final_grid_points)
|
||||
do i = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,i)
|
||||
r(2) = final_grid_points(2,i)
|
||||
r(3) = final_grid_points(3,i)
|
||||
call give_all_mos_l_at_r(r, mos_array)
|
||||
do j = 1, mo_num
|
||||
mos_l_in_r_array(j,i) = mos_array(j)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
subroutine give_all_mos_l_at_r(r, mos_l_array)
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_l_array(i) = ith LEFT MO function evaluated at "r"
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
double precision, intent(in) :: r(3)
|
||||
double precision, intent(out) :: mos_l_array(mo_num)
|
||||
double precision :: aos_array(ao_num)
|
||||
|
||||
call give_all_aos_at_r(r, aos_array)
|
||||
call dgemv('N', mo_num, ao_num, 1.d0, mo_l_coef_transp, mo_num, aos_array, 1, 0.d0, mos_l_array, 1)
|
||||
|
||||
end subroutine give_all_mos_l_at_r
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_l_in_r_array_transp, (n_points_final_grid,mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_l_in_r_array_transp(i,j) = value of the jth mo on the ith grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
|
||||
do i = 1, n_points_final_grid
|
||||
do j = 1, mo_num
|
||||
mos_l_in_r_array_transp(i,j) = mos_l_in_r_array(j,i)
|
||||
enddo
|
||||
enddo
|
||||
deallocate(aos_r)
|
||||
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for mos_l_in_r_array_transp & mos_r_in_r_array_transp (sec) = ', (tt1 - tt0)
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
137
plugins/local/bi_ortho_mos/bi_ort_mos_in_r_old.irp.f
Normal file
137
plugins/local/bi_ortho_mos/bi_ort_mos_in_r_old.irp.f
Normal file
@ -0,0 +1,137 @@
|
||||
|
||||
! TODO: left & right MO without duplicate AO calculation
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_r_in_r_array, (mo_num, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_in_r_array(i,j) = value of the ith RIGHT mo on the jth grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
double precision :: mos_array(mo_num), r(3)
|
||||
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, r, mos_array) &
|
||||
!$OMP SHARED (mos_r_in_r_array, n_points_final_grid, mo_num, final_grid_points)
|
||||
do i = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,i)
|
||||
r(2) = final_grid_points(2,i)
|
||||
r(3) = final_grid_points(3,i)
|
||||
call give_all_mos_r_at_r(r, mos_array)
|
||||
do j = 1, mo_num
|
||||
mos_r_in_r_array(j,i) = mos_array(j)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_r_in_r_array_transp_old, (n_points_final_grid, mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_r_in_r_array_transp_old(i,j) = value of the jth mo on the ith grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i,j
|
||||
|
||||
do i = 1, n_points_final_grid
|
||||
do j = 1, mo_num
|
||||
mos_r_in_r_array_transp_old(i,j) = mos_r_in_r_array(j,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
subroutine give_all_mos_r_at_r(r, mos_r_array)
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_r_array(i) = ith RIGHT MO function evaluated at "r"
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
double precision, intent(in) :: r(3)
|
||||
double precision, intent(out) :: mos_r_array(mo_num)
|
||||
double precision :: aos_array(ao_num)
|
||||
|
||||
call give_all_aos_at_r(r, aos_array)
|
||||
call dgemv('N', mo_num, ao_num, 1.d0, mo_r_coef_transp, mo_num, aos_array, 1, 0.d0, mos_r_array, 1)
|
||||
|
||||
end subroutine give_all_mos_r_at_r
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_l_in_r_array, (mo_num, n_points_final_grid)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_in_r_array(i,j) = value of the ith LEFT mo on the jth grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
double precision :: mos_array(mo_num), r(3)
|
||||
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,r,mos_array,j) &
|
||||
!$OMP SHARED(mos_l_in_r_array,n_points_final_grid,mo_num,final_grid_points)
|
||||
do i = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,i)
|
||||
r(2) = final_grid_points(2,i)
|
||||
r(3) = final_grid_points(3,i)
|
||||
call give_all_mos_l_at_r(r, mos_array)
|
||||
do j = 1, mo_num
|
||||
mos_l_in_r_array(j,i) = mos_array(j)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
subroutine give_all_mos_l_at_r(r, mos_l_array)
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_l_array(i) = ith LEFT MO function evaluated at "r"
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
double precision, intent(in) :: r(3)
|
||||
double precision, intent(out) :: mos_l_array(mo_num)
|
||||
double precision :: aos_array(ao_num)
|
||||
|
||||
call give_all_aos_at_r(r, aos_array)
|
||||
call dgemv('N', mo_num, ao_num, 1.d0, mo_l_coef_transp, mo_num, aos_array, 1, 0.d0, mos_l_array, 1)
|
||||
|
||||
end subroutine give_all_mos_l_at_r
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, mos_l_in_r_array_transp_old, (n_points_final_grid,mo_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
! mos_l_in_r_array_transp_old(i,j) = value of the jth mo on the ith grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
|
||||
do i = 1, n_points_final_grid
|
||||
do j = 1, mo_num
|
||||
mos_l_in_r_array_transp_old(i,j) = mos_l_in_r_array(j,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
@ -232,6 +232,14 @@
|
||||
|
||||
! ---
|
||||
|
||||
do i_nucl = 1, nucl_num
|
||||
do p = 1, jBH_size
|
||||
if(jBH_m(p,i_nucl) .eq. jBH_n(p,i_nucl)) then
|
||||
jBH_c(p,i_nucl) = 0.5d0 * jBH_c(p,i_nucl)
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
|
||||
print *, ' parameters for Boys-Handy Jastrow'
|
||||
print *, ' nb of terms per nucleus = ', jBH_size
|
||||
|
||||
|
@ -335,9 +335,6 @@ subroutine grad1_j12_r1_seq(r1, n_grid2, gradx, grady, gradz)
|
||||
npA = jBH_n(p,i_nucl)
|
||||
opA = jBH_o(p,i_nucl)
|
||||
tmp = jBH_c(p,i_nucl)
|
||||
if(mpA .eq. npA) then
|
||||
tmp = tmp * 0.5d0
|
||||
endif
|
||||
|
||||
tmp1 = double_p(mpA) * f1A_power(mpA-1) * f2A_power(npA) + double_p(npA) * f1A_power(npA-1) * f2A_power(mpA)
|
||||
tmp1 = tmp1 * g12_power(opA) * tmp
|
||||
|
@ -204,7 +204,7 @@ BEGIN_PROVIDER [double precision, int2_grad1_u12_ao, (ao_num, ao_num, n_points_f
|
||||
print*, ' Writing int2_grad1_u12_ao in ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
|
@ -118,7 +118,7 @@ BEGIN_PROVIDER [double precision, ao_two_e_tc_tot, (ao_num, ao_num, ao_num, ao_n
|
||||
!$OMP END PARALLEL
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, int2_grad1_u12_square_ao(1,1,1), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 0.d0, ao_two_e_tc_tot, ao_num*ao_num)
|
||||
, 0.d0, ao_two_e_tc_tot(1,1,1,1), ao_num*ao_num)
|
||||
deallocate(c_mat)
|
||||
endif
|
||||
|
||||
|
@ -129,9 +129,9 @@ subroutine htilde_mu_mat_opt_bi_ortho(key_j, key_i, Nint, hmono, htwoe, hthree,
|
||||
|
||||
endif
|
||||
|
||||
if(degree==0) then
|
||||
htot += nuclear_repulsion
|
||||
endif
|
||||
! if(degree==0) then
|
||||
! htot += nuclear_repulsion
|
||||
! endif
|
||||
|
||||
end
|
||||
|
||||
|
@ -8,9 +8,13 @@ subroutine write_tc_energy()
|
||||
double precision :: E_1e, E_2e, E_3e
|
||||
double precision, allocatable :: E_TC_tmp(:), E_1e_tmp(:), E_2e_tmp(:), E_3e_tmp(:)
|
||||
|
||||
call htilde_mu_mat_opt_bi_ortho(psi_det(1,1,1), psi_det(1,1,1), N_int, hmono, htwoe, hthree, htot)
|
||||
|
||||
! GS
|
||||
! ---
|
||||
|
||||
call htilde_mu_mat_opt_bi_ortho(psi_det(1,1,1), psi_det(1,1,1), N_int, hmono, htwoe, hthree, htot)
|
||||
|
||||
allocate(E_TC_tmp(N_det), E_1e_tmp(N_det), E_2e_tmp(N_det), E_3e_tmp(N_det))
|
||||
|
||||
!$OMP PARALLEL &
|
||||
|
36
plugins/local/tc_int/EZFIO.cfg
Normal file
36
plugins/local/tc_int/EZFIO.cfg
Normal file
@ -0,0 +1,36 @@
|
||||
[nxBlocks]
|
||||
type: integer
|
||||
doc: nb of x blocks in the Grid
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 10
|
||||
|
||||
[nyBlocks]
|
||||
type: integer
|
||||
doc: nb of y blocks in the Grid
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1
|
||||
|
||||
[nzBlocks]
|
||||
type: integer
|
||||
doc: nb of z blocks in the Grid
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1
|
||||
|
||||
[blockxSize]
|
||||
type: integer
|
||||
doc: size of x blocks
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 32
|
||||
|
||||
[blockySize]
|
||||
type: integer
|
||||
doc: size of y blocks
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1
|
||||
|
||||
[blockzSize]
|
||||
type: integer
|
||||
doc: size of z blocks
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1
|
||||
|
1
plugins/local/tc_int/LIB
Normal file
1
plugins/local/tc_int/LIB
Normal file
@ -0,0 +1 @@
|
||||
-lcutcint
|
@ -4,3 +4,4 @@ jastrow
|
||||
qmckl
|
||||
becke_numerical_grid
|
||||
dft_utils_in_r
|
||||
bi_ortho_mos
|
||||
|
233
plugins/local/tc_int/compute_int_2e_ao_cpu.irp.f
Normal file
233
plugins/local/tc_int/compute_int_2e_ao_cpu.irp.f
Normal file
@ -0,0 +1,233 @@
|
||||
|
||||
! ---
|
||||
|
||||
program compute_int_2e_ao_cpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: m
|
||||
integer :: i, j, k, l
|
||||
integer :: ipoint, jpoint
|
||||
|
||||
double precision :: weight1, ao_i_r, ao_k_r
|
||||
|
||||
double precision :: time0, time1
|
||||
double precision :: wall_time0, wall_time1
|
||||
double precision :: wall_ttime0, wall_ttime1
|
||||
double precision :: tt1, tt2
|
||||
|
||||
double precision, allocatable :: rn(:,:), aos_data1(:,:,:), aos_data2(:,:,:)
|
||||
double precision, allocatable :: grad1_u12(:,:,:), int_fct_long_range(:,:,:), c_mat(:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: int_2e_ao(:,:,:,:)
|
||||
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start compute_int_2e_ao_cpu'
|
||||
|
||||
|
||||
! ---
|
||||
|
||||
allocate(rn(3,nucl_num))
|
||||
allocate(aos_data1(n_points_final_grid,ao_num,4))
|
||||
allocate(aos_data2(n_points_extra_final_grid,ao_num,4))
|
||||
|
||||
do k = 1, nucl_num
|
||||
rn(1,k) = nucl_coord(k,1)
|
||||
rn(2,k) = nucl_coord(k,2)
|
||||
rn(3,k) = nucl_coord(k,3)
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
aos_data1(ipoint,k,1) = aos_in_r_array(k,ipoint)
|
||||
aos_data1(ipoint,k,2) = aos_grad_in_r_array(k,ipoint,1)
|
||||
aos_data1(ipoint,k,3) = aos_grad_in_r_array(k,ipoint,2)
|
||||
aos_data1(ipoint,k,4) = aos_grad_in_r_array(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_extra_final_grid
|
||||
aos_data2(ipoint,k,1) = aos_in_r_array_extra(k,ipoint)
|
||||
aos_data2(ipoint,k,2) = aos_grad_in_r_array_extra(k,ipoint,1)
|
||||
aos_data2(ipoint,k,3) = aos_grad_in_r_array_extra(k,ipoint,2)
|
||||
aos_data2(ipoint,k,4) = aos_grad_in_r_array_extra(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
||||
allocate(int_fct_long_range(n_points_extra_final_grid,ao_num,ao_num))
|
||||
allocate(grad1_u12(n_points_extra_final_grid,n_points_final_grid,4))
|
||||
allocate(c_mat(n_points_final_grid,ao_num,ao_num))
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,4))
|
||||
allocate(int_2e_ao(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
call wall_time(wall_time0)
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, i, jpoint) &
|
||||
!$OMP SHARED (int_fct_long_range, ao_num, n_points_extra_final_grid, final_weight_at_r_vector_extra, aos_in_r_array_extra_transp)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do jpoint = 1, n_points_extra_final_grid
|
||||
int_fct_long_range(jpoint,i,j) = final_weight_at_r_vector_extra(jpoint) * aos_in_r_array_extra_transp(jpoint,i) * aos_in_r_array_extra_transp(jpoint,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for int_long_range (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid, n_points_extra_final_grid, grad1_u12)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, grad1_u12(1,ipoint,1) &
|
||||
, grad1_u12(1,ipoint,2) &
|
||||
, grad1_u12(1,ipoint,3) &
|
||||
, grad1_u12(1,ipoint,4) )
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for tc_int_bh (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
do m = 1, 4
|
||||
call dgemm("T", "N", ao_num*ao_num, n_points_final_grid, n_points_extra_final_grid, 1.d0 &
|
||||
, int_fct_long_range(1,1,1), n_points_extra_final_grid, grad1_u12(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao(1,1,1,m), ao_num*ao_num)
|
||||
enddo
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for DGEMM of integ over r2 (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, c_mat, ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
c_mat(ipoint,k,i) = final_weight_at_r_vector(ipoint) * aos_in_r_array_transp(ipoint,i) * aos_in_r_array_transp(ipoint,k)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time of Hermitian part (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, int2_grad1_u12_ao(1,1,1,4), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 0.d0, int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for DGEMM of Hermitian part (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
tt1 = 0.d0
|
||||
tt2 = 0.d0
|
||||
do m = 1, 3
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint, weight1, ao_i_r, ao_k_r) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, aos_grad_in_r_array_transp_bis, c_mat, &
|
||||
!$OMP ao_num, n_points_final_grid, final_weight_at_r_vector, m)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
weight1 = final_weight_at_r_vector(ipoint)
|
||||
ao_i_r = aos_in_r_array_transp(ipoint,i)
|
||||
ao_k_r = aos_in_r_array_transp(ipoint,k)
|
||||
|
||||
c_mat(ipoint,k,i) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,m) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,m))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
tt1 += wall_ttime1 - wall_ttime0
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, -0.5d0 &
|
||||
, int2_grad1_u12_ao(1,1,1,m), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 1.d0, int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
call wall_time(wall_ttime1)
|
||||
tt2 += wall_ttime1 - wall_ttime0
|
||||
enddo
|
||||
write(*,"(A,2X,F15.7)") ' wall time of non-Hermitian part (sec) = ', tt1
|
||||
write(*,"(A,2X,F15.7)") ' wall time for DGEMM of non Hermitian part (sec) = ', tt2
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
call sum_A_At(int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time of A + A.T (sec) = ', wall_ttime1 - wall_ttime0
|
||||
|
||||
|
||||
call wall_time(wall_time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time on cpu (sec) = ', (wall_time1 - wall_time0)
|
||||
|
||||
|
||||
deallocate(int_fct_long_range, grad1_u12, c_mat)
|
||||
deallocate(int_2e_ao, int2_grad1_u12_ao)
|
||||
deallocate(rn, aos_data1, aos_data2)
|
||||
|
||||
call wall_time(time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for compute_int_2e_ao_cpu (sec) = ', (time1 - time0)
|
||||
|
||||
return
|
||||
end
|
117
plugins/local/tc_int/compute_int_2e_ao_gpu.irp.f
Normal file
117
plugins/local/tc_int/compute_int_2e_ao_gpu.irp.f
Normal file
@ -0,0 +1,117 @@
|
||||
|
||||
! ---
|
||||
|
||||
program compute_int_2e_ao_gpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k, l
|
||||
integer :: ipoint
|
||||
|
||||
double precision :: time0, time1
|
||||
|
||||
double precision, allocatable :: rn(:,:), aos_data1(:,:,:), aos_data2(:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_ao_gpu(:,:,:,:)
|
||||
double precision, allocatable :: int_2e_ao_gpu(:,:,:,:)
|
||||
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start compute_int_2e_ao_gpu'
|
||||
|
||||
|
||||
! ---
|
||||
|
||||
allocate(rn(3,nucl_num))
|
||||
allocate(aos_data1(n_points_final_grid,ao_num,4))
|
||||
allocate(aos_data2(n_points_extra_final_grid,ao_num,4))
|
||||
|
||||
do k = 1, nucl_num
|
||||
rn(1,k) = nucl_coord(k,1)
|
||||
rn(2,k) = nucl_coord(k,2)
|
||||
rn(3,k) = nucl_coord(k,3)
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
aos_data1(ipoint,k,1) = aos_in_r_array(k,ipoint)
|
||||
aos_data1(ipoint,k,2) = aos_grad_in_r_array(k,ipoint,1)
|
||||
aos_data1(ipoint,k,3) = aos_grad_in_r_array(k,ipoint,2)
|
||||
aos_data1(ipoint,k,4) = aos_grad_in_r_array(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_extra_final_grid
|
||||
aos_data2(ipoint,k,1) = aos_in_r_array_extra(k,ipoint)
|
||||
aos_data2(ipoint,k,2) = aos_grad_in_r_array_extra(k,ipoint,1)
|
||||
aos_data2(ipoint,k,3) = aos_grad_in_r_array_extra(k,ipoint,2)
|
||||
aos_data2(ipoint,k,4) = aos_grad_in_r_array_extra(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! ---
|
||||
|
||||
integer :: nB
|
||||
integer :: sB
|
||||
|
||||
PROVIDE nxBlocks nyBlocks nzBlocks
|
||||
PROVIDE blockxSize blockySize blockzSize
|
||||
|
||||
sB = 32
|
||||
nB = (n_points_final_grid + sB - 1) / sB
|
||||
|
||||
call ezfio_set_tc_int_blockxSize(sB)
|
||||
call ezfio_set_tc_int_nxBlocks(nB)
|
||||
|
||||
allocate(int2_grad1_u12_ao_gpu(ao_num,ao_num,n_points_final_grid,3))
|
||||
allocate(int_2e_ao_gpu(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
call cutc_int(nxBlocks, nyBlocks, nzBlocks, blockxSize, blockySize, blockzSize, &
|
||||
n_points_final_grid, n_points_extra_final_grid, ao_num, nucl_num, jBH_size, &
|
||||
final_grid_points, final_weight_at_r_vector, &
|
||||
final_grid_points_extra, final_weight_at_r_vector_extra, &
|
||||
rn, aos_data1, aos_data2, jBH_c, jBH_m, jBH_n, jBH_o, &
|
||||
int2_grad1_u12_ao_gpu, int_2e_ao_gpu)
|
||||
|
||||
deallocate(int_2e_ao_gpu, int2_grad1_u12_ao_gpu)
|
||||
deallocate(rn, aos_data1, aos_data2)
|
||||
|
||||
call wall_time(time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for compute_int_2e_ao_gpu (sec) = ', (time1 - time0)
|
||||
|
||||
return
|
||||
end
|
143
plugins/local/tc_int/compute_no_cpu.irp.f
Normal file
143
plugins/local/tc_int/compute_no_cpu.irp.f
Normal file
@ -0,0 +1,143 @@
|
||||
|
||||
! ---
|
||||
|
||||
program compute_no_cpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k, l, ipoint
|
||||
double precision :: time0, time1
|
||||
double precision :: tt0, tt1
|
||||
double precision :: acc_thr, err_tot, nrm_tot, err_loc
|
||||
double precision :: noL_0e
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: tmp(:,:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_bimo_t(:,:,:,:)
|
||||
double precision, allocatable :: noL_1e (:,:)
|
||||
double precision, allocatable :: noL_2e (:,:,:,:)
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE mos_l_in_r_array_transp mos_r_in_r_array_transp
|
||||
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start compute_no_cpu'
|
||||
|
||||
|
||||
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,3))
|
||||
print*, ' Reading int2_grad1_u12_ao from ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
call wall_time(tt0)
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="read")
|
||||
read(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for reading (sec) = ', (tt1 - tt0)
|
||||
|
||||
allocate(tmp(mo_num,mo_num,n_points_final_grid,3))
|
||||
allocate(int2_grad1_u12_bimo_t(n_points_final_grid,3,mo_num,mo_num))
|
||||
|
||||
call wall_time(tt0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (ao_num, mo_num, n_points_final_grid, int2_grad1_u12_ao, tmp)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,1), ao_num, tmp(1,1,ipoint,1), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,2), ao_num, tmp(1,1,ipoint,2), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,3), ao_num, tmp(1,1,ipoint,3), mo_num)
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(int2_grad1_u12_ao)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, ipoint) &
|
||||
!$OMP SHARED (mo_num, n_points_final_grid, tmp, int2_grad1_u12_bimo_t)
|
||||
!$OMP DO COLLAPSE(2) SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
int2_grad1_u12_bimo_t(ipoint,1,j,i) = tmp(j,i,ipoint,1)
|
||||
int2_grad1_u12_bimo_t(ipoint,2,j,i) = tmp(j,i,ipoint,2)
|
||||
int2_grad1_u12_bimo_t(ipoint,3,j,i) = tmp(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for 3e-tensor (sec) = ', (tt1 - tt0)
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
allocate(noL_2e(mo_num,mo_num,mo_num,mo_num))
|
||||
allocate(noL_1e(mo_num,mo_num))
|
||||
|
||||
call provide_no_2e(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_2e(1,1,1,1))
|
||||
|
||||
call provide_no_1e(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_1e(1,1))
|
||||
|
||||
call provide_no_0e(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_0e)
|
||||
|
||||
deallocate(int2_grad1_u12_bimo_t)
|
||||
deallocate(noL_2e)
|
||||
deallocate(noL_1e)
|
||||
|
||||
|
||||
call wall_time(time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for compute_no_cpu (sec) = ', (time1 - time0)
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
132
plugins/local/tc_int/compute_no_gpu.irp.f
Normal file
132
plugins/local/tc_int/compute_no_gpu.irp.f
Normal file
@ -0,0 +1,132 @@
|
||||
|
||||
! ---
|
||||
|
||||
program compute_no_gpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k, l, ipoint
|
||||
double precision :: time0, time1
|
||||
double precision :: tt0, tt1
|
||||
double precision :: acc_thr, err_tot, nrm_tot, err_loc
|
||||
double precision :: noL_0e_gpu(1)
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: tmp(:,:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_bimo_t(:,:,:,:)
|
||||
double precision, allocatable :: noL_1e_gpu(:,:)
|
||||
double precision, allocatable :: noL_2e_gpu(:,:,:,:)
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE mos_l_in_r_array_transp mos_r_in_r_array_transp
|
||||
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start compute_no_gpu'
|
||||
|
||||
|
||||
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,3))
|
||||
print*, ' Reading int2_grad1_u12_ao from ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
call wall_time(tt0)
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="read")
|
||||
read(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for reading (sec) = ', (tt1 - tt0)
|
||||
|
||||
allocate(tmp(mo_num,mo_num,n_points_final_grid,3))
|
||||
allocate(int2_grad1_u12_bimo_t(n_points_final_grid,3,mo_num,mo_num))
|
||||
|
||||
call wall_time(tt0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (ao_num, mo_num, n_points_final_grid, int2_grad1_u12_ao, tmp)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,1), ao_num, tmp(1,1,ipoint,1), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,2), ao_num, tmp(1,1,ipoint,2), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,3), ao_num, tmp(1,1,ipoint,3), mo_num)
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(int2_grad1_u12_ao)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, ipoint) &
|
||||
!$OMP SHARED (mo_num, n_points_final_grid, tmp, int2_grad1_u12_bimo_t)
|
||||
!$OMP DO COLLAPSE(2) SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
int2_grad1_u12_bimo_t(ipoint,1,j,i) = tmp(j,i,ipoint,1)
|
||||
int2_grad1_u12_bimo_t(ipoint,2,j,i) = tmp(j,i,ipoint,2)
|
||||
int2_grad1_u12_bimo_t(ipoint,3,j,i) = tmp(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for 3e-tensor (sec) = ', (tt1 - tt0)
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
allocate(noL_2e_gpu(mo_num,mo_num,mo_num,mo_num))
|
||||
allocate(noL_1e_gpu(mo_num,mo_num))
|
||||
|
||||
call cutc_no(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_2e_gpu(1,1,1,1), noL_1e_gpu(1,1), noL_0e_gpu(1))
|
||||
|
||||
deallocate(int2_grad1_u12_bimo_t)
|
||||
deallocate(noL_2e_gpu)
|
||||
deallocate(noL_1e_gpu)
|
||||
|
||||
call wall_time(time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for compute_no_gpu (sec) = ', (time1 - time0)
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
! ---
|
||||
|
||||
subroutine provide_int2_grad1_u12_ao()
|
||||
use gpu
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! int2_grad1_u12_ao(i,j,ipoint,1) = \int dr2 [\grad1 u(r1,r2)]_x1 \chi_i(r2) \chi_j(r2)
|
||||
@ -35,8 +35,8 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
double precision :: weight1, ao_k_r, ao_i_r
|
||||
double precision :: der_envsq_x, der_envsq_y, der_envsq_z, lap_envsq
|
||||
double precision :: time0, time1, time2, tc1, tc2, tc
|
||||
type(gpu_double4) :: int2_grad1_u12_ao
|
||||
type(gpu_double3) :: tmp_grad1_u12, tmp_grad1_u12p, tmp
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: tmp_grad1_u12(:,:,:), tmp(:,:,:)
|
||||
double precision, allocatable :: c_mat(:,:,:), tc_int_2e_ao(:,:,:,:)
|
||||
|
||||
double precision, external :: get_ao_two_e_integral
|
||||
@ -52,7 +52,6 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
|
||||
call total_memory(mem)
|
||||
mem = max(1.d0, qp_max_mem - mem)
|
||||
mem = 6
|
||||
n_double = mem * 1.d8
|
||||
n_blocks = int(min(n_double / (n_points_extra_final_grid * 4.d0), 1.d0*n_points_final_grid))
|
||||
n_rest = int(mod(n_points_final_grid, n_blocks))
|
||||
@ -66,9 +65,9 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
! ---
|
||||
! ---
|
||||
|
||||
call gpu_allocate(int2_grad1_u12_ao, ao_num,ao_num,n_points_final_grid,4)
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,4))
|
||||
|
||||
call gpu_allocate(tmp,n_points_extra_final_grid,ao_num,ao_num)
|
||||
allocate(tmp(n_points_extra_final_grid,ao_num,ao_num))
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, i, jpoint) &
|
||||
@ -77,23 +76,17 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do jpoint = 1, n_points_extra_final_grid
|
||||
tmp%f(jpoint,i,j) = final_weight_at_r_vector_extra(jpoint) * aos_in_r_array_extra_transp(jpoint,i) * aos_in_r_array_extra_transp(jpoint,j)
|
||||
tmp(jpoint,i,j) = final_weight_at_r_vector_extra(jpoint) * aos_in_r_array_extra_transp(jpoint,i) * aos_in_r_array_extra_transp(jpoint,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
call gpu_allocate(tmp_grad1_u12,n_points_extra_final_grid,n_blocks,4)
|
||||
call gpu_allocate(tmp_grad1_u12p,n_points_extra_final_grid,n_blocks,4)
|
||||
allocate(tmp_grad1_u12(n_points_extra_final_grid,n_blocks,4))
|
||||
|
||||
tc = 0.d0
|
||||
|
||||
type(gpu_stream) :: stream(4)
|
||||
do i=1,4
|
||||
call gpu_stream_create(stream(i))
|
||||
enddo
|
||||
|
||||
do i_pass = 1, n_pass
|
||||
ii = (i_pass-1)*n_blocks + 1
|
||||
|
||||
@ -102,25 +95,22 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i_blocks, ipoint) &
|
||||
!$OMP SHARED (n_blocks, n_points_extra_final_grid, ii, final_grid_points, tmp_grad1_u12)
|
||||
!$OMP SHARED (n_blocks, n_points_extra_final_grid, ii, tmp_grad1_u12)
|
||||
!$OMP DO
|
||||
do i_blocks = 1, n_blocks
|
||||
ipoint = ii - 1 + i_blocks ! r1
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, tmp_grad1_u12%f(1,i_blocks,1), tmp_grad1_u12%f(1,i_blocks,2), &
|
||||
tmp_grad1_u12%f(1,i_blocks,3), tmp_grad1_u12%f(1,i_blocks,4))
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, tmp_grad1_u12(1,i_blocks,1), tmp_grad1_u12(1,i_blocks,2), &
|
||||
tmp_grad1_u12(1,i_blocks,3), tmp_grad1_u12(1,i_blocks,4))
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(tc2)
|
||||
tc = tc + tc2 - tc1
|
||||
|
||||
call gpu_synchronize()
|
||||
call gpu_copy(tmp_grad1_u12,tmp_grad1_u12p)
|
||||
do m = 1, 4
|
||||
call gpu_set_stream(blas_handle, stream(m))
|
||||
call gpu_dgemm(blas_handle, "T", "N", ao_num*ao_num, n_blocks, n_points_extra_final_grid, 1.d0 &
|
||||
, tmp%f(1,1,1), n_points_extra_final_grid, tmp_grad1_u12p%f(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao%f(1,1,ii,m), ao_num*ao_num)
|
||||
call dgemm("T", "N", ao_num*ao_num, n_blocks, n_points_extra_final_grid, 1.d0 &
|
||||
, tmp(1,1,1), n_points_extra_final_grid, tmp_grad1_u12(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao(1,1,ii,m), ao_num*ao_num)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
@ -132,12 +122,12 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i_rest, ipoint) &
|
||||
!$OMP SHARED (n_rest, n_points_extra_final_grid, ii, final_grid_points, tmp_grad1_u12)
|
||||
!$OMP SHARED (n_rest, n_points_extra_final_grid, ii, tmp_grad1_u12)
|
||||
!$OMP DO
|
||||
do i_rest = 1, n_rest
|
||||
ipoint = ii - 1 + i_rest ! r1
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, tmp_grad1_u12%f(1,i_rest,1), tmp_grad1_u12%f(1,i_rest,2), &
|
||||
tmp_grad1_u12%f(1,i_rest,3), tmp_grad1_u12%f(1,i_rest,4))
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, tmp_grad1_u12(1,i_rest,1), tmp_grad1_u12(1,i_rest,2), &
|
||||
tmp_grad1_u12(1,i_rest,3), tmp_grad1_u12(1,i_rest,4))
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
@ -145,42 +135,33 @@ subroutine provide_int2_grad1_u12_ao()
|
||||
tc = tc + tc2 - tc1
|
||||
|
||||
do m = 1, 4
|
||||
call gpu_set_stream(blas_handle, stream(m))
|
||||
call gpu_dgemm(blas_handle, "T", "N", ao_num*ao_num, n_rest, n_points_extra_final_grid, 1.d0 &
|
||||
, tmp%f(1,1,1), n_points_extra_final_grid, tmp_grad1_u12%f(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao%f(1,1,ii,m), ao_num*ao_num)
|
||||
call dgemm("T", "N", ao_num*ao_num, n_rest, n_points_extra_final_grid, 1.d0 &
|
||||
, tmp(1,1,1), n_points_extra_final_grid, tmp_grad1_u12(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao(1,1,ii,m), ao_num*ao_num)
|
||||
enddo
|
||||
|
||||
endif
|
||||
call gpu_synchronize()
|
||||
call gpu_deallocate(tmp_grad1_u12)
|
||||
call gpu_deallocate(tmp_grad1_u12p)
|
||||
deallocate(tmp_grad1_u12)
|
||||
|
||||
do i=1,4
|
||||
call gpu_stream_destroy(stream(i))
|
||||
enddo
|
||||
|
||||
|
||||
call gpu_deallocate(tmp)
|
||||
deallocate(tmp)
|
||||
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' wall time for int2_grad1_u12_ao (min) = ', (time1-time0) / 60.d0
|
||||
print*, ' wall time Jastrow derivatives (min) = ', tc / 60.d0
|
||||
|
||||
call print_memory_usage()
|
||||
|
||||
!TODO
|
||||
stop
|
||||
! ---
|
||||
! ---
|
||||
! ---
|
||||
|
||||
|
||||
allocate(c_mat(n_points_final_grid,ao_num,ao_num))
|
||||
allocate(tc_int_2e_ao(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
allocate(c_mat(n_points_final_grid,ao_num,ao_num))
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
@ -196,19 +177,18 @@ stop
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, int2_grad1_u12_ao%f(1,1,1,4), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, int2_grad1_u12_ao(1,1,1,4), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 0.d0, tc_int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
deallocate(c_mat)
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' wall time of Hermitian part of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
allocate(c_mat(n_points_final_grid,ao_num,ao_num))
|
||||
do m = 1, 3
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
@ -220,7 +200,7 @@ stop
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
weight1 = 0.5d0 * final_weight_at_r_vector(ipoint)
|
||||
weight1 = final_weight_at_r_vector(ipoint)
|
||||
ao_i_r = aos_in_r_array_transp(ipoint,i)
|
||||
ao_k_r = aos_in_r_array_transp(ipoint,k)
|
||||
|
||||
@ -231,14 +211,16 @@ stop
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, -1.d0 &
|
||||
, int2_grad1_u12_ao%f(1,1,1,m), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, -0.5d0 &
|
||||
, int2_grad1_u12_ao(1,1,1,m), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 1.d0, tc_int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
enddo
|
||||
deallocate(c_mat)
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' wall time of non-Hermitian part of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
|
||||
deallocate(c_mat)
|
||||
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
@ -249,13 +231,18 @@ stop
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' lower- and upper-triangle of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
|
||||
double precision :: tmp_omp
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
PROVIDE ao_integrals_map
|
||||
tmp_omp = get_ao_two_e_integral(1, 1, 1, 1, ao_integrals_map)
|
||||
|
||||
!$OMP PARALLEL DEFAULT(NONE) &
|
||||
!$OMP SHARED(ao_num, tc_int_2e_ao, ao_integrals_map) &
|
||||
!$OMP PRIVATE(i, j, k, l)
|
||||
@ -281,9 +268,10 @@ stop
|
||||
|
||||
print*, ' Writing int2_grad1_u12_ao in ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao%f(:,:,:,1:3)
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao(:,:,:,1:3)
|
||||
close(11)
|
||||
deallocate(int2_grad1_u12_ao)
|
||||
|
||||
print*, ' Saving tc_int_2e_ao in ', trim(ezfio_filename) // '/work/ao_two_e_tc_tot'
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/ao_two_e_tc_tot', action="write")
|
||||
@ -295,7 +283,6 @@ stop
|
||||
|
||||
! ----
|
||||
|
||||
call gpu_deallocate(int2_grad1_u12_ao)
|
||||
deallocate(tc_int_2e_ao)
|
||||
|
||||
call wall_time(time2)
|
||||
|
315
plugins/local/tc_int/compute_tc_int_gpu.irp.f
Normal file
315
plugins/local/tc_int/compute_tc_int_gpu.irp.f
Normal file
@ -0,0 +1,315 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine provide_int2_grad1_u12_ao_gpu()
|
||||
|
||||
use gpu
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! int2_grad1_u12_ao(i,j,ipoint,1) = \int dr2 [\grad1 u(r1,r2)]_x1 \chi_i(r2) \chi_j(r2)
|
||||
! int2_grad1_u12_ao(i,j,ipoint,2) = \int dr2 [\grad1 u(r1,r2)]_y1 \chi_i(r2) \chi_j(r2)
|
||||
! int2_grad1_u12_ao(i,j,ipoint,3) = \int dr2 [\grad1 u(r1,r2)]_z1 \chi_i(r2) \chi_j(r2)
|
||||
! int2_grad1_u12_ao(i,j,ipoint,4) = \int dr2 [-(1/2) [\grad1 u(r1,r2)]^2] \chi_i(r2) \chi_j(r2)
|
||||
!
|
||||
!
|
||||
! tc_int_2e_ao(k,i,l,j) = (ki|V^TC(r_12)|lj)
|
||||
! = <lk| V^TC(r_12) |ji> where V^TC(r_12) is the total TC operator
|
||||
! = tc_grad_and_lapl_ao(k,i,l,j) + tc_grad_square_ao(k,i,l,j) + ao_two_e_coul(k,i,l,j)
|
||||
! where:
|
||||
!
|
||||
! tc_grad_and_lapl_ao(k,i,l,j) = < k l | -1/2 \Delta_1 u(r1,r2) - \grad_1 u(r1,r2) . \grad_1 | ij >
|
||||
! = -1/2 \int dr1 (phi_k(r1) \grad_r1 phi_i(r1) - phi_i(r1) \grad_r1 phi_k(r1)) . \int dr2 \grad_r1 u(r1,r2) \phi_l(r2) \phi_j(r2)
|
||||
! = 1/2 \int dr1 (phi_k(r1) \grad_r1 phi_i(r1) - phi_i(r1) \grad_r1 phi_k(r1)) . \int dr2 (-1) \grad_r1 u(r1,r2) \phi_l(r2) \phi_j(r2)
|
||||
!
|
||||
! tc_grad_square_ao(k,i,l,j) = -1/2 <kl | |\grad_1 u(r1,r2)|^2 + |\grad_2 u(r1,r2)|^2 | ij>
|
||||
!
|
||||
! ao_two_e_coul(k,i,l,j) = < l k | 1/r12 | j i > = ( k i | 1/r12 | l j )
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k, l, m, ipoint, jpoint
|
||||
integer :: n_blocks, n_rest, n_pass
|
||||
integer :: i_blocks, i_rest, i_pass, ii
|
||||
double precision :: mem, n_double
|
||||
double precision :: weight1, ao_k_r, ao_i_r
|
||||
double precision :: der_envsq_x, der_envsq_y, der_envsq_z, lap_envsq
|
||||
double precision :: time0, time1, time2, tc1, tc2, tc
|
||||
type(gpu_double4) :: int2_grad1_u12_ao
|
||||
type(gpu_double3) :: tmp_grad1_u12, tmp_grad1_u12p, tmp
|
||||
double precision, allocatable :: c_mat(:,:,:), tc_int_2e_ao(:,:,:,:)
|
||||
|
||||
double precision, external :: get_ao_two_e_integral
|
||||
|
||||
|
||||
PROVIDE final_weight_at_r_vector_extra aos_in_r_array_extra
|
||||
PROVIDE final_weight_at_r_vector aos_grad_in_r_array_transp_bis final_weight_at_r_vector aos_in_r_array_transp
|
||||
|
||||
|
||||
|
||||
print*, ' start provide_int2_grad1_u12_ao ...'
|
||||
call wall_time(time0)
|
||||
|
||||
call total_memory(mem)
|
||||
mem = max(1.d0, qp_max_mem - mem)
|
||||
mem = 6
|
||||
n_double = mem * 1.d8
|
||||
n_blocks = int(min(n_double / (n_points_extra_final_grid * 4.d0), 1.d0*n_points_final_grid))
|
||||
n_rest = int(mod(n_points_final_grid, n_blocks))
|
||||
n_pass = int((n_points_final_grid - n_rest) / n_blocks)
|
||||
|
||||
call write_int(6, n_pass, 'Number of passes')
|
||||
call write_int(6, n_blocks, 'Size of the blocks')
|
||||
call write_int(6, n_rest, 'Size of the last block')
|
||||
|
||||
! ---
|
||||
! ---
|
||||
! ---
|
||||
|
||||
call gpu_allocate(int2_grad1_u12_ao, ao_num,ao_num,n_points_final_grid,4)
|
||||
|
||||
call gpu_allocate(tmp,n_points_extra_final_grid,ao_num,ao_num)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, i, jpoint) &
|
||||
!$OMP SHARED (tmp, ao_num, n_points_extra_final_grid, final_weight_at_r_vector_extra, aos_in_r_array_extra_transp)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do jpoint = 1, n_points_extra_final_grid
|
||||
tmp%f(jpoint,i,j) = final_weight_at_r_vector_extra(jpoint) * aos_in_r_array_extra_transp(jpoint,i) * aos_in_r_array_extra_transp(jpoint,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
call gpu_allocate(tmp_grad1_u12,n_points_extra_final_grid,n_blocks,4)
|
||||
call gpu_allocate(tmp_grad1_u12p,n_points_extra_final_grid,n_blocks,4)
|
||||
|
||||
tc = 0.d0
|
||||
|
||||
type(gpu_stream) :: stream(4)
|
||||
do i=1,4
|
||||
call gpu_stream_create(stream(i))
|
||||
enddo
|
||||
|
||||
do i_pass = 1, n_pass
|
||||
ii = (i_pass-1)*n_blocks + 1
|
||||
|
||||
call wall_time(tc1)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i_blocks, ipoint) &
|
||||
!$OMP SHARED (n_blocks, n_points_extra_final_grid, ii, final_grid_points, tmp_grad1_u12)
|
||||
!$OMP DO
|
||||
do i_blocks = 1, n_blocks
|
||||
ipoint = ii - 1 + i_blocks ! r1
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, tmp_grad1_u12%f(1,i_blocks,1), tmp_grad1_u12%f(1,i_blocks,2), &
|
||||
tmp_grad1_u12%f(1,i_blocks,3), tmp_grad1_u12%f(1,i_blocks,4))
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(tc2)
|
||||
tc = tc + tc2 - tc1
|
||||
|
||||
call gpu_synchronize()
|
||||
call gpu_copy(tmp_grad1_u12,tmp_grad1_u12p)
|
||||
do m = 1, 4
|
||||
call gpu_set_stream(blas_handle, stream(m))
|
||||
call gpu_dgemm(blas_handle, "T", "N", ao_num*ao_num, n_blocks, n_points_extra_final_grid, 1.d0 &
|
||||
, tmp%f(1,1,1), n_points_extra_final_grid, tmp_grad1_u12p%f(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao%f(1,1,ii,m), ao_num*ao_num)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
if(n_rest .gt. 0) then
|
||||
|
||||
ii = n_pass*n_blocks + 1
|
||||
|
||||
call wall_time(tc1)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i_rest, ipoint) &
|
||||
!$OMP SHARED (n_rest, n_points_extra_final_grid, ii, final_grid_points, tmp_grad1_u12)
|
||||
!$OMP DO
|
||||
do i_rest = 1, n_rest
|
||||
ipoint = ii - 1 + i_rest ! r1
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, tmp_grad1_u12%f(1,i_rest,1), tmp_grad1_u12%f(1,i_rest,2), &
|
||||
tmp_grad1_u12%f(1,i_rest,3), tmp_grad1_u12%f(1,i_rest,4))
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(tc2)
|
||||
tc = tc + tc2 - tc1
|
||||
|
||||
do m = 1, 4
|
||||
call gpu_set_stream(blas_handle, stream(m))
|
||||
call gpu_dgemm(blas_handle, "T", "N", ao_num*ao_num, n_rest, n_points_extra_final_grid, 1.d0 &
|
||||
, tmp%f(1,1,1), n_points_extra_final_grid, tmp_grad1_u12%f(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao%f(1,1,ii,m), ao_num*ao_num)
|
||||
enddo
|
||||
|
||||
endif
|
||||
call gpu_synchronize()
|
||||
call gpu_deallocate(tmp_grad1_u12)
|
||||
call gpu_deallocate(tmp_grad1_u12p)
|
||||
|
||||
do i=1,4
|
||||
call gpu_stream_destroy(stream(i))
|
||||
enddo
|
||||
|
||||
|
||||
call gpu_deallocate(tmp)
|
||||
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' wall time for int2_grad1_u12_ao (min) = ', (time1-time0) / 60.d0
|
||||
print*, ' wall time Jastrow derivatives (min) = ', tc / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
!TODO
|
||||
stop
|
||||
! ---
|
||||
! ---
|
||||
! ---
|
||||
|
||||
|
||||
allocate(c_mat(n_points_final_grid,ao_num,ao_num))
|
||||
allocate(tc_int_2e_ao(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, c_mat, ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
c_mat(ipoint,k,i) = final_weight_at_r_vector(ipoint) * aos_in_r_array_transp(ipoint,i) * aos_in_r_array_transp(ipoint,k)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, int2_grad1_u12_ao%f(1,1,1,4), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 0.d0, tc_int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' wall time of Hermitian part of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
do m = 1, 3
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint, weight1, ao_i_r, ao_k_r) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, aos_grad_in_r_array_transp_bis, c_mat, &
|
||||
!$OMP ao_num, n_points_final_grid, final_weight_at_r_vector, m)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
weight1 = 0.5d0 * final_weight_at_r_vector(ipoint)
|
||||
ao_i_r = aos_in_r_array_transp(ipoint,i)
|
||||
ao_k_r = aos_in_r_array_transp(ipoint,k)
|
||||
|
||||
c_mat(ipoint,k,i) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,m) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,m))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, -1.d0 &
|
||||
, int2_grad1_u12_ao%f(1,1,1,m), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 1.d0, tc_int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
enddo
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' wall time of non-Hermitian part of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
deallocate(c_mat)
|
||||
|
||||
! ---
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
call sum_A_At(tc_int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' lower- and upper-triangle of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
|
||||
call wall_time(time1)
|
||||
|
||||
PROVIDE ao_integrals_map
|
||||
!$OMP PARALLEL DEFAULT(NONE) &
|
||||
!$OMP SHARED(ao_num, tc_int_2e_ao, ao_integrals_map) &
|
||||
!$OMP PRIVATE(i, j, k, l)
|
||||
!$OMP DO COLLAPSE(3)
|
||||
do j = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
! < 1:i, 2:j | 1:k, 2:l >
|
||||
tc_int_2e_ao(k,i,l,j) = tc_int_2e_ao(k,i,l,j) + get_ao_two_e_integral(i, j, k, l, ao_integrals_map)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' wall time of Coulomb part of tc_int_2e_ao (min) ', (time2 - time1) / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
|
||||
print*, ' Writing int2_grad1_u12_ao in ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao%f(:,:,:,1:3)
|
||||
close(11)
|
||||
|
||||
print*, ' Saving tc_int_2e_ao in ', trim(ezfio_filename) // '/work/ao_two_e_tc_tot'
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/ao_two_e_tc_tot', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
do i = 1, ao_num
|
||||
write(11) tc_int_2e_ao(:,:,:,i)
|
||||
enddo
|
||||
close(11)
|
||||
|
||||
! ----
|
||||
|
||||
call gpu_deallocate(int2_grad1_u12_ao)
|
||||
deallocate(tc_int_2e_ao)
|
||||
|
||||
call wall_time(time2)
|
||||
print*, ' wall time for tc_int_2e_ao (min) = ', (time2-time1) / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
! ---
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' wall time for TC-integrals (min) = ', (time1-time0) / 60.d0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
70
plugins/local/tc_int/cutc_module.F90
Normal file
70
plugins/local/tc_int/cutc_module.F90
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
module cutc_module
|
||||
|
||||
use, intrinsic :: iso_c_binding
|
||||
|
||||
implicit none
|
||||
|
||||
interface
|
||||
|
||||
! ---
|
||||
|
||||
subroutine cutc_int(nxBlocks, nyBlocks, nzBlocks, &
|
||||
blockxSize, blockySize, blockzSize, &
|
||||
n_grid1, n_grid2, n_ao, n_nuc, size_bh, &
|
||||
r1, wr1, r2, wr2, rn, &
|
||||
aos_data1, aos_data2, &
|
||||
c_bh, m_bh, n_bh, o_bh, &
|
||||
int2_grad1_u12_ao, int_2e_ao) bind(C, name = "cutc_int")
|
||||
|
||||
import c_int, c_double, c_ptr
|
||||
integer(c_int), intent(in), value :: nxBlocks, blockxSize
|
||||
integer(c_int), intent(in), value :: nyBlocks, blockySize
|
||||
integer(c_int), intent(in), value :: nzBlocks, blockzSize
|
||||
integer(c_int), intent(in), value :: n_grid1, n_grid2
|
||||
integer(c_int), intent(in), value :: n_ao
|
||||
integer(c_int), intent(in), value :: n_nuc
|
||||
integer(c_int), intent(in), value :: size_bh
|
||||
real(c_double), intent(in) :: r1(3,n_grid1), wr1(n_grid1)
|
||||
real(c_double), intent(in) :: r2(3,n_grid2), wr2(n_grid2)
|
||||
real(c_double), intent(in) :: rn(3,n_nuc)
|
||||
real(c_double), intent(in) :: aos_data1(n_grid1,n_ao,4)
|
||||
real(c_double), intent(in) :: aos_data2(n_grid2,n_ao,4)
|
||||
real(c_double), intent(in) :: c_bh(size_bh,n_nuc)
|
||||
integer(c_int), intent(in) :: m_bh(size_bh,n_nuc)
|
||||
integer(c_int), intent(in) :: n_bh(size_bh,n_nuc)
|
||||
integer(c_int), intent(in) :: o_bh(size_bh,n_nuc)
|
||||
real(c_double), intent(out) :: int2_grad1_u12_ao(n_ao,n_ao,n_grid1,3)
|
||||
real(c_double), intent(out) :: int_2e_ao(n_ao,n_ao,n_ao,n_ao)
|
||||
|
||||
end subroutine cutc_int
|
||||
|
||||
! ---
|
||||
|
||||
subroutine cutc_no(n_grid1, n_mo, ne_a, ne_b, &
|
||||
wr1, mos_l_in_r, mos_r_in_r, int2_grad1_u12, &
|
||||
no_2e, no_1e, no_0e) bind(C, name = "cutc_no")
|
||||
|
||||
import c_int, c_double, c_ptr
|
||||
|
||||
integer(c_int), intent(in), value :: n_grid1
|
||||
integer(c_int), intent(in), value :: n_mo
|
||||
integer(c_int), intent(in), value :: ne_a
|
||||
integer(c_int), intent(in), value :: ne_b
|
||||
real(c_double), intent(in) :: wr1(n_grid1)
|
||||
real(c_double), intent(in) :: mos_l_in_r(n_grid1,n_mo)
|
||||
real(c_double), intent(in) :: mos_r_in_r(n_grid1,n_mo)
|
||||
real(c_double), intent(in) :: int2_grad1_u12(n_grid1,3,n_mo,n_mo)
|
||||
real(c_double), intent(out) :: no_2e(n_mo,n_mo,n_mo,n_mo)
|
||||
real(c_double), intent(out) :: no_1e(n_mo,n_mo)
|
||||
real(c_double), intent(out) :: no_0e(1)
|
||||
|
||||
end subroutine cutc_no
|
||||
|
||||
! ---
|
||||
|
||||
end interface
|
||||
|
||||
end module cutc_module
|
||||
|
||||
|
311
plugins/local/tc_int/deb_int_2e_ao_gpu.irp.f
Normal file
311
plugins/local/tc_int/deb_int_2e_ao_gpu.irp.f
Normal file
@ -0,0 +1,311 @@
|
||||
|
||||
! ---
|
||||
|
||||
program deb_int_2e_ao_gpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: m
|
||||
integer :: i, j, k, l
|
||||
integer :: ipoint, jpoint
|
||||
|
||||
double precision :: weight1, ao_i_r, ao_k_r
|
||||
|
||||
double precision :: acc_thr, err_tot, nrm_tot, err_loc
|
||||
|
||||
double precision :: time0, time1
|
||||
double precision :: wall_time0, wall_time1
|
||||
double precision :: wall_ttime0, wall_ttime1
|
||||
double precision :: tt1, tt2
|
||||
|
||||
double precision, allocatable :: rn(:,:), aos_data1(:,:,:), aos_data2(:,:,:)
|
||||
double precision, allocatable :: grad1_u12(:,:,:), int_fct_long_range(:,:,:), c_mat(:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_ao_gpu(:,:,:,:)
|
||||
double precision, allocatable :: int_2e_ao(:,:,:,:)
|
||||
double precision, allocatable :: int_2e_ao_gpu(:,:,:,:)
|
||||
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start deb_int_2e_ao_gpu'
|
||||
|
||||
|
||||
! ---
|
||||
|
||||
allocate(rn(3,nucl_num))
|
||||
allocate(aos_data1(n_points_final_grid,ao_num,4))
|
||||
allocate(aos_data2(n_points_extra_final_grid,ao_num,4))
|
||||
|
||||
do k = 1, nucl_num
|
||||
rn(1,k) = nucl_coord(k,1)
|
||||
rn(2,k) = nucl_coord(k,2)
|
||||
rn(3,k) = nucl_coord(k,3)
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
aos_data1(ipoint,k,1) = aos_in_r_array(k,ipoint)
|
||||
aos_data1(ipoint,k,2) = aos_grad_in_r_array(k,ipoint,1)
|
||||
aos_data1(ipoint,k,3) = aos_grad_in_r_array(k,ipoint,2)
|
||||
aos_data1(ipoint,k,4) = aos_grad_in_r_array(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_extra_final_grid
|
||||
aos_data2(ipoint,k,1) = aos_in_r_array_extra(k,ipoint)
|
||||
aos_data2(ipoint,k,2) = aos_grad_in_r_array_extra(k,ipoint,1)
|
||||
aos_data2(ipoint,k,3) = aos_grad_in_r_array_extra(k,ipoint,2)
|
||||
aos_data2(ipoint,k,4) = aos_grad_in_r_array_extra(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! ---
|
||||
|
||||
integer :: nB
|
||||
integer :: sB
|
||||
|
||||
PROVIDE nxBlocks nyBlocks nzBlocks
|
||||
PROVIDE blockxSize blockySize blockzSize
|
||||
|
||||
sB = 32
|
||||
nB = (n_points_final_grid + sB - 1) / sB
|
||||
|
||||
call ezfio_set_tc_int_blockxSize(sB)
|
||||
call ezfio_set_tc_int_nxBlocks(nB)
|
||||
|
||||
allocate(int2_grad1_u12_ao_gpu(ao_num,ao_num,n_points_final_grid,3))
|
||||
allocate(int_2e_ao_gpu(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
call cutc_int(nxBlocks, nyBlocks, nzBlocks, blockxSize, blockySize, blockzSize, &
|
||||
n_points_final_grid, n_points_extra_final_grid, ao_num, nucl_num, jBH_size, &
|
||||
final_grid_points, final_weight_at_r_vector, &
|
||||
final_grid_points_extra, final_weight_at_r_vector_extra, &
|
||||
rn, aos_data1, aos_data2, jBH_c, jBH_m, jBH_n, jBH_o, &
|
||||
int2_grad1_u12_ao_gpu, int_2e_ao_gpu)
|
||||
|
||||
! ---
|
||||
|
||||
allocate(int_fct_long_range(n_points_extra_final_grid,ao_num,ao_num))
|
||||
allocate(grad1_u12(n_points_extra_final_grid,n_points_final_grid,4))
|
||||
allocate(c_mat(n_points_final_grid,ao_num,ao_num))
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,4))
|
||||
allocate(int_2e_ao(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
call wall_time(wall_time0)
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, i, jpoint) &
|
||||
!$OMP SHARED (int_fct_long_range, ao_num, n_points_extra_final_grid, final_weight_at_r_vector_extra, aos_in_r_array_extra_transp)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do jpoint = 1, n_points_extra_final_grid
|
||||
int_fct_long_range(jpoint,i,j) = final_weight_at_r_vector_extra(jpoint) * aos_in_r_array_extra_transp(jpoint,i) * aos_in_r_array_extra_transp(jpoint,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for int_long_range (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (n_points_final_grid, n_points_extra_final_grid, grad1_u12)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call get_grad1_u12_for_tc(ipoint, n_points_extra_final_grid, grad1_u12(1,ipoint,1) &
|
||||
, grad1_u12(1,ipoint,2) &
|
||||
, grad1_u12(1,ipoint,3) &
|
||||
, grad1_u12(1,ipoint,4) )
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for tc_int_bh (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
do m = 1, 4
|
||||
call dgemm("T", "N", ao_num*ao_num, n_points_final_grid, n_points_extra_final_grid, 1.d0 &
|
||||
, int_fct_long_range(1,1,1), n_points_extra_final_grid, grad1_u12(1,1,m), n_points_extra_final_grid &
|
||||
, 0.d0, int2_grad1_u12_ao(1,1,1,m), ao_num*ao_num)
|
||||
enddo
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for DGEMM of integ over r2 (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, c_mat, ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
c_mat(ipoint,k,i) = final_weight_at_r_vector(ipoint) * aos_in_r_array_transp(ipoint,i) * aos_in_r_array_transp(ipoint,k)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time of Hermitian part (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, int2_grad1_u12_ao(1,1,1,4), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 0.d0, int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for DGEMM of Hermitian part (sec) = ', (wall_ttime1 - wall_ttime0)
|
||||
|
||||
|
||||
tt1 = 0.d0
|
||||
tt2 = 0.d0
|
||||
do m = 1, 3
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint, weight1, ao_i_r, ao_k_r) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, aos_grad_in_r_array_transp_bis, c_mat, &
|
||||
!$OMP ao_num, n_points_final_grid, final_weight_at_r_vector, m)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
weight1 = final_weight_at_r_vector(ipoint)
|
||||
ao_i_r = aos_in_r_array_transp(ipoint,i)
|
||||
ao_k_r = aos_in_r_array_transp(ipoint,k)
|
||||
|
||||
c_mat(ipoint,k,i) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,m) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,m))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(wall_ttime1)
|
||||
tt1 += wall_ttime1 - wall_ttime0
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, -0.5d0 &
|
||||
, int2_grad1_u12_ao(1,1,1,m), ao_num*ao_num, c_mat(1,1,1), n_points_final_grid &
|
||||
, 1.d0, int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
call wall_time(wall_ttime1)
|
||||
tt2 += wall_ttime1 - wall_ttime0
|
||||
enddo
|
||||
write(*,"(A,2X,F15.7)") ' wall time of non-Hermitian part (sec) = ', tt1
|
||||
write(*,"(A,2X,F15.7)") ' wall time for DGEMM of non Hermitian part (sec) = ', tt2
|
||||
|
||||
|
||||
call wall_time(wall_ttime0)
|
||||
call sum_A_At(int_2e_ao(1,1,1,1), ao_num*ao_num)
|
||||
call wall_time(wall_ttime1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time of A + A.T (sec) = ', wall_ttime1 - wall_ttime0
|
||||
|
||||
|
||||
call wall_time(wall_time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time on cpu (sec) = ', (wall_time1 - wall_time0)
|
||||
|
||||
! ---
|
||||
|
||||
acc_thr = 1d-12
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
err_loc = dabs(int2_grad1_u12_ao(i,j,ipoint,m) - int2_grad1_u12_ao_gpu(i,j,ipoint,m))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", i, j, ipoint, m
|
||||
print*, " CPU res", int2_grad1_u12_ao (i,j,ipoint,m)
|
||||
print*, " GPU res", int2_grad1_u12_ao_gpu(i,j,ipoint,m)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(int2_grad1_u12_ao(i,j,ipoint,m))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on int2_grad1_u12_ao (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
err_loc = dabs(int_2e_ao(l,k,j,i) - int_2e_ao_gpu(l,k,j,i))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", l, k, j, i
|
||||
print*, " CPU res", int_2e_ao (l,k,j,i)
|
||||
print*, " GPU res", int_2e_ao_gpu(l,k,j,i)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(int_2e_ao(l,k,j,i))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on int_2e_ao (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
! ---
|
||||
|
||||
deallocate(int_fct_long_range, grad1_u12, c_mat)
|
||||
deallocate(int_2e_ao, int2_grad1_u12_ao)
|
||||
deallocate(int_2e_ao_gpu, int2_grad1_u12_ao_gpu)
|
||||
deallocate(rn, aos_data1, aos_data2)
|
||||
|
||||
call wall_time(time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for deb_int_2e_ao_gpu (sec) = ', (time1 - time0)
|
||||
|
||||
return
|
||||
end
|
218
plugins/local/tc_int/deb_no_gpu.irp.f
Normal file
218
plugins/local/tc_int/deb_no_gpu.irp.f
Normal file
@ -0,0 +1,218 @@
|
||||
|
||||
! ---
|
||||
|
||||
program deb_no_gpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k, l, ipoint
|
||||
double precision :: time0, time1
|
||||
double precision :: tt0, tt1
|
||||
double precision :: acc_thr, err_tot, nrm_tot, err_loc
|
||||
double precision :: noL_0e
|
||||
double precision :: noL_0e_gpu(1)
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: tmp(:,:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_bimo_t(:,:,:,:)
|
||||
double precision, allocatable :: noL_1e (:,:)
|
||||
double precision, allocatable :: noL_1e_gpu(:,:)
|
||||
double precision, allocatable :: noL_2e (:,:,:,:)
|
||||
double precision, allocatable :: noL_2e_gpu(:,:,:,:)
|
||||
|
||||
|
||||
PROVIDE mo_l_coef mo_r_coef
|
||||
PROVIDE mos_l_in_r_array_transp mos_r_in_r_array_transp
|
||||
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start deb_no_gpu'
|
||||
|
||||
|
||||
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,3))
|
||||
print*, ' Reading int2_grad1_u12_ao from ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
call wall_time(tt0)
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="read")
|
||||
read(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for reading (sec) = ', (tt1 - tt0)
|
||||
|
||||
allocate(tmp(mo_num,mo_num,n_points_final_grid,3))
|
||||
allocate(int2_grad1_u12_bimo_t(n_points_final_grid,3,mo_num,mo_num))
|
||||
|
||||
call wall_time(tt0)
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (ipoint) &
|
||||
!$OMP SHARED (ao_num, mo_num, n_points_final_grid, int2_grad1_u12_ao, tmp)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,1), ao_num, tmp(1,1,ipoint,1), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,2), ao_num, tmp(1,1,ipoint,2), mo_num)
|
||||
call ao_to_mo_bi_ortho(int2_grad1_u12_ao(1,1,ipoint,3), ao_num, tmp(1,1,ipoint,3), mo_num)
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(int2_grad1_u12_ao)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, ipoint) &
|
||||
!$OMP SHARED (mo_num, n_points_final_grid, tmp, int2_grad1_u12_bimo_t)
|
||||
!$OMP DO COLLAPSE(2) SCHEDULE (dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
int2_grad1_u12_bimo_t(ipoint,1,j,i) = tmp(j,i,ipoint,1)
|
||||
int2_grad1_u12_bimo_t(ipoint,2,j,i) = tmp(j,i,ipoint,2)
|
||||
int2_grad1_u12_bimo_t(ipoint,3,j,i) = tmp(j,i,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
call wall_time(tt1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for 3e-tensor (sec) = ', (tt1 - tt0)
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
! ---
|
||||
|
||||
allocate(noL_2e_gpu(mo_num,mo_num,mo_num,mo_num))
|
||||
allocate(noL_1e_gpu(mo_num,mo_num))
|
||||
|
||||
call cutc_no(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_2e_gpu(1,1,1,1), noL_1e_gpu(1,1), noL_0e_gpu(1))
|
||||
|
||||
! ---
|
||||
|
||||
allocate(noL_2e(mo_num,mo_num,mo_num,mo_num))
|
||||
allocate(noL_1e(mo_num,mo_num))
|
||||
|
||||
call provide_no_2e(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_2e(1,1,1,1))
|
||||
|
||||
call provide_no_1e(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_1e(1,1))
|
||||
|
||||
call provide_no_0e(n_points_final_grid, mo_num, elec_alpha_num, elec_beta_num, &
|
||||
final_weight_at_r_vector(1), &
|
||||
mos_l_in_r_array_transp(1,1), mos_r_in_r_array_transp(1,1), &
|
||||
int2_grad1_u12_bimo_t(1,1,1,1), noL_0e)
|
||||
|
||||
! ---
|
||||
|
||||
deallocate(int2_grad1_u12_bimo_t)
|
||||
|
||||
acc_thr = 1d-12
|
||||
|
||||
! ---
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do l = 1, mo_num
|
||||
err_loc = dabs(noL_2e(l,k,j,i) - noL_2e_gpu(l,k,j,i))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", l, k, j, i
|
||||
print*, " CPU res", noL_2e (l,k,j,i)
|
||||
print*, " GPU res", noL_2e_gpu(l,k,j,i)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(noL_2e(l,k,j,i))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on noL_2e (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
deallocate(noL_2e)
|
||||
deallocate(noL_2e_gpu)
|
||||
|
||||
! ---
|
||||
|
||||
err_tot = 0.d0
|
||||
nrm_tot = 0.d0
|
||||
do k = 1, mo_num
|
||||
do l = 1, mo_num
|
||||
err_loc = dabs(noL_1e(l,k) - noL_1e_gpu(l,k))
|
||||
if(err_loc > acc_thr) then
|
||||
print*, " error on", l, k
|
||||
print*, " CPU res", noL_1e (l,k)
|
||||
print*, " GPU res", noL_1e_gpu(l,k)
|
||||
stop
|
||||
endif
|
||||
err_tot = err_tot + err_loc
|
||||
nrm_tot = nrm_tot + dabs(noL_1e(l,k))
|
||||
enddo
|
||||
enddo
|
||||
print *, ' absolute accuracy on noL_1e (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
deallocate(noL_1e)
|
||||
deallocate(noL_1e_gpu)
|
||||
|
||||
! ---
|
||||
|
||||
print *, 'noL_0e CPU = ', noL_0e
|
||||
print *, 'noL_0e GPU = ', noL_0e_gpu(1)
|
||||
|
||||
err_tot = dabs(noL_0e - noL_0e_gpu(1))
|
||||
nrm_tot = dabs(noL_0e)
|
||||
print *, ' absolute accuracy on noL_0e (%) =', 100.d0 * err_tot / nrm_tot
|
||||
|
||||
|
||||
call wall_time(time1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for deb_no_gpu (sec) = ', (time1 - time0)
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
18
plugins/local/tc_int/install
Executable file
18
plugins/local/tc_int/install
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if the QP_ROOT environment variable is set.
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
print "The QP_ROOT environment variable is not set."
|
||||
print "Please reload the quantum_package.rc file."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
git clone https://github.com/AbdAmmar/CuTC
|
||||
cd CuTC
|
||||
source config/env.rc
|
||||
make
|
||||
cd ..
|
||||
|
||||
ln -s ${PWD}/CuTC/build/libcutcint.so ${QP_ROOT}/lib
|
||||
|
@ -58,7 +58,7 @@ subroutine grad1_j12_r1_seq(r1, n_grid2, gradx, grady, gradz)
|
||||
integer :: jpoint, i_nucl, p, mpA, npA, opA
|
||||
double precision :: r2(3)
|
||||
double precision :: dx, dy, dz, r12, tmp
|
||||
double precision :: rn(3), f1A, grad1_f1A(3), f2A, grad2_f2A(3), g12, grad1_g12(3)
|
||||
double precision :: rn(3), f1A, grad1_f1A(3), f2A, g12, grad1_g12(3)
|
||||
double precision :: tmp1, tmp2, dist
|
||||
integer :: powmax1, powmax, powmax2
|
||||
double precision, allocatable :: f1A_power(:), f2A_power(:), double_p(:), g12_power(:)
|
||||
@ -91,35 +91,29 @@ subroutine grad1_j12_r1_seq(r1, n_grid2, gradx, grady, gradz)
|
||||
grady(jpoint) = 0.d0
|
||||
gradz(jpoint) = 0.d0
|
||||
|
||||
call jBH_elem_fct_grad_alpha1(r1, r2, g12, grad1_g12)
|
||||
|
||||
! dist = (r1(1) - r2(1)) * (r1(1) - r2(1)) &
|
||||
! + (r1(2) - r2(2)) * (r1(2) - r2(2)) &
|
||||
! + (r1(3) - r2(3)) * (r1(3) - r2(3))
|
||||
!
|
||||
! if(dist .ge. 1d-15) then
|
||||
! dist = dsqrt( dist )
|
||||
!
|
||||
! tmp1 = 1.d0 / (1.d0 + dist)
|
||||
!
|
||||
! g12 = dist * tmp1
|
||||
! tmp2 = tmp1 * tmp1 / dist
|
||||
! grad1_g12(1) = tmp2 * (r1(1) - r2(1))
|
||||
! grad1_g12(2) = tmp2 * (r1(2) - r2(2))
|
||||
! grad1_g12(3) = tmp2 * (r1(3) - r2(3))
|
||||
!
|
||||
! else
|
||||
!
|
||||
! grad1_g12(1) = 0.d0
|
||||
! grad1_g12(2) = 0.d0
|
||||
! grad1_g12(3) = 0.d0
|
||||
! g12 = 0.d0
|
||||
!
|
||||
! endif
|
||||
!
|
||||
do p = 1, powmax2
|
||||
g12_power(p) = g12_power(p-1) * g12
|
||||
enddo
|
||||
dist = (r1(1) - r2(1)) * (r1(1) - r2(1)) &
|
||||
+ (r1(2) - r2(2)) * (r1(2) - r2(2)) &
|
||||
+ (r1(3) - r2(3)) * (r1(3) - r2(3))
|
||||
if(dist .ge. 1d-15) then
|
||||
dist = dsqrt(dist)
|
||||
tmp1 = 1.d0 / (1.d0 + dist)
|
||||
g12 = dist * tmp1
|
||||
tmp2 = tmp1 * tmp1 / dist
|
||||
grad1_g12(1) = tmp2 * (r1(1) - r2(1))
|
||||
grad1_g12(2) = tmp2 * (r1(2) - r2(2))
|
||||
grad1_g12(3) = tmp2 * (r1(3) - r2(3))
|
||||
do p = 1, powmax2
|
||||
g12_power(p) = g12_power(p-1) * g12
|
||||
enddo
|
||||
else
|
||||
grad1_g12(1) = 0.d0
|
||||
grad1_g12(2) = 0.d0
|
||||
grad1_g12(3) = 0.d0
|
||||
g12 = 0.d0
|
||||
do p = 1, powmax2
|
||||
g12_power(p) = 0.d0
|
||||
enddo
|
||||
endif
|
||||
|
||||
do i_nucl = 1, nucl_num
|
||||
|
||||
@ -127,71 +121,54 @@ subroutine grad1_j12_r1_seq(r1, n_grid2, gradx, grady, gradz)
|
||||
rn(2) = nucl_coord(i_nucl,2)
|
||||
rn(3) = nucl_coord(i_nucl,3)
|
||||
|
||||
call jBH_elem_fct_grad_alpha1(r1, rn, f1A, grad1_f1A)
|
||||
! dist = (r1(1) - rn(1)) * (r1(1) - rn(1)) &
|
||||
! + (r1(2) - rn(2)) * (r1(2) - rn(2)) &
|
||||
! + (r1(3) - rn(3)) * (r1(3) - rn(3))
|
||||
! if (dist > 1.d-15) then
|
||||
! dist = dsqrt( dist )
|
||||
!
|
||||
! tmp1 = 1.d0 / (1.d0 + dist)
|
||||
!
|
||||
! f1A = dist * tmp1
|
||||
! tmp2 = tmp1 * tmp1 / dist
|
||||
! grad1_f1A(1) = tmp2 * (r1(1) - rn(1))
|
||||
! grad1_f1A(2) = tmp2 * (r1(2) - rn(2))
|
||||
! grad1_f1A(3) = tmp2 * (r1(3) - rn(3))
|
||||
!
|
||||
! else
|
||||
!
|
||||
! grad1_f1A(1) = 0.d0
|
||||
! grad1_f1A(2) = 0.d0
|
||||
! grad1_f1A(3) = 0.d0
|
||||
! f1A = 0.d0
|
||||
!
|
||||
! endif
|
||||
dist = (r1(1) - rn(1)) * (r1(1) - rn(1)) &
|
||||
+ (r1(2) - rn(2)) * (r1(2) - rn(2)) &
|
||||
+ (r1(3) - rn(3)) * (r1(3) - rn(3))
|
||||
if (dist > 1.d-15) then
|
||||
dist = dsqrt(dist)
|
||||
tmp1 = 1.d0 / (1.d0 + dist)
|
||||
f1A = dist * tmp1
|
||||
tmp2 = tmp1 * tmp1 / dist
|
||||
grad1_f1A(1) = tmp2 * (r1(1) - rn(1))
|
||||
grad1_f1A(2) = tmp2 * (r1(2) - rn(2))
|
||||
grad1_f1A(3) = tmp2 * (r1(3) - rn(3))
|
||||
do p = 1, powmax1
|
||||
f1A_power(p) = f1A_power(p-1) * f1A
|
||||
enddo
|
||||
else
|
||||
grad1_f1A(1) = 0.d0
|
||||
grad1_f1A(2) = 0.d0
|
||||
grad1_f1A(3) = 0.d0
|
||||
f1A = 0.d0
|
||||
do p = 1, powmax1
|
||||
f1A_power(p) = 0.d0
|
||||
enddo
|
||||
endif
|
||||
|
||||
call jBH_elem_fct_grad_alpha1(r2, rn, f2A, grad2_f2A)
|
||||
! dist = (r2(1) - rn(1)) * (r2(1) - rn(1)) &
|
||||
! + (r2(2) - rn(2)) * (r2(2) - rn(2)) &
|
||||
! + (r2(3) - rn(3)) * (r2(3) - rn(3))
|
||||
!
|
||||
! if (dist > 1.d-15) then
|
||||
! dist = dsqrt( dist )
|
||||
!
|
||||
! tmp1 = 1.d0 / (1.d0 + dist)
|
||||
!
|
||||
! f2A = dist * tmp1
|
||||
! tmp2 = tmp1 * tmp1 / dist
|
||||
! grad2_f2A(1) = tmp2 * (r2(1) - rn(1))
|
||||
! grad2_f2A(2) = tmp2 * (r2(2) - rn(2))
|
||||
! grad2_f2A(3) = tmp2 * (r2(3) - rn(3))
|
||||
!
|
||||
! else
|
||||
!
|
||||
! grad2_f2A(1) = 0.d0
|
||||
! grad2_f2A(2) = 0.d0
|
||||
! grad2_f2A(3) = 0.d0
|
||||
! f2A = 0.d0
|
||||
!
|
||||
! endif
|
||||
|
||||
! Compute powers of f1A and f2A
|
||||
do p = 1, powmax1
|
||||
f1A_power(p) = f1A_power(p-1) * f1A
|
||||
f2A_power(p) = f2A_power(p-1) * f2A
|
||||
enddo
|
||||
dist = (r2(1) - rn(1)) * (r2(1) - rn(1)) &
|
||||
+ (r2(2) - rn(2)) * (r2(2) - rn(2)) &
|
||||
+ (r2(3) - rn(3)) * (r2(3) - rn(3))
|
||||
if (dist > 1.d-15) then
|
||||
dist = dsqrt(dist)
|
||||
f2A = dist / (1.d0 + dist)
|
||||
do p = 1, powmax1
|
||||
f2A_power(p) = f2A_power(p-1) * f2A
|
||||
enddo
|
||||
else
|
||||
f2A = 0.d0
|
||||
do p = 1, powmax1
|
||||
f2A_power(p) = 0.d0
|
||||
enddo
|
||||
endif
|
||||
|
||||
do p = 1, jBH_size
|
||||
|
||||
tmp = jBH_c(p,i_nucl)
|
||||
if (dabs(tmp) <= 1.d-10) cycle
|
||||
|
||||
mpA = jBH_m(p,i_nucl)
|
||||
npA = jBH_n(p,i_nucl)
|
||||
opA = jBH_o(p,i_nucl)
|
||||
tmp = jBH_c(p,i_nucl)
|
||||
! if (dabs(tmp) <= 1.d-10) cycle
|
||||
!
|
||||
if(mpA .eq. npA) then
|
||||
tmp = tmp * 0.5d0
|
||||
endif
|
||||
|
||||
tmp1 = double_p(mpA) * f1A_power(mpA-1) * f2A_power(npA) + double_p(npA) * f1A_power(npA-1) * f2A_power(mpA)
|
||||
tmp1 = tmp1 * g12_power(opA) * tmp
|
||||
@ -207,39 +184,5 @@ subroutine grad1_j12_r1_seq(r1, n_grid2, gradx, grady, gradz)
|
||||
return
|
||||
end
|
||||
|
||||
subroutine jBH_elem_fct_grad_alpha1(r1, r2, fct, grad1_fct)
|
||||
|
||||
implicit none
|
||||
double precision, intent(in) :: r1(3), r2(3)
|
||||
double precision, intent(out) :: fct, grad1_fct(3)
|
||||
double precision :: dist, tmp1, tmp2
|
||||
|
||||
dist = (r1(1) - r2(1)) * (r1(1) - r2(1)) &
|
||||
+ (r1(2) - r2(2)) * (r1(2) - r2(2)) &
|
||||
+ (r1(3) - r2(3)) * (r1(3) - r2(3))
|
||||
|
||||
|
||||
if(dist .ge. 1d-15) then
|
||||
dist = dsqrt( dist )
|
||||
|
||||
tmp1 = 1.d0 / (1.d0 + dist)
|
||||
|
||||
fct = dist * tmp1
|
||||
tmp2 = tmp1 * tmp1 / dist
|
||||
grad1_fct(1) = tmp2 * (r1(1) - r2(1))
|
||||
grad1_fct(2) = tmp2 * (r1(2) - r2(2))
|
||||
grad1_fct(3) = tmp2 * (r1(3) - r2(3))
|
||||
|
||||
else
|
||||
|
||||
grad1_fct(1) = 0.d0
|
||||
grad1_fct(2) = 0.d0
|
||||
grad1_fct(3) = 0.d0
|
||||
fct = 0.d0
|
||||
|
||||
endif
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
|
||||
! ---
|
||||
|
||||
|
||||
|
||||
subroutine jBH_elem_fct_grad(alpha, r1, r2, fct, grad1_fct)
|
||||
|
||||
implicit none
|
||||
double precision, intent(in) :: alpha, r1(3), r2(3)
|
||||
double precision, intent(out) :: fct, grad1_fct(3)
|
||||
double precision :: dist, tmp1, tmp2, dist_inv
|
||||
|
||||
dist = (r1(1) - r2(1)) * (r1(1) - r2(1)) &
|
||||
+ (r1(2) - r2(2)) * (r1(2) - r2(2)) &
|
||||
+ (r1(3) - r2(3)) * (r1(3) - r2(3))
|
||||
|
||||
|
||||
if(dist .ge. 1d-15) then
|
||||
dist_inv = 1.d0/dsqrt( dist )
|
||||
dist = dist_inv * dist
|
||||
|
||||
tmp1 = 1.d0 / (1.d0 + alpha * dist)
|
||||
|
||||
fct = alpha * dist * tmp1
|
||||
tmp2 = alpha * tmp1 * tmp1 * dist_inv
|
||||
grad1_fct(1) = tmp2 * (r1(1) - r2(1))
|
||||
grad1_fct(2) = tmp2 * (r1(2) - r2(2))
|
||||
grad1_fct(3) = tmp2 * (r1(3) - r2(3))
|
||||
|
||||
else
|
||||
|
||||
grad1_fct(1) = 0.d0
|
||||
grad1_fct(2) = 0.d0
|
||||
grad1_fct(3) = 0.d0
|
||||
fct = 0.d0
|
||||
|
||||
endif
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
407
plugins/local/tc_int/no_0e.irp.f
Normal file
407
plugins/local/tc_int/no_0e.irp.f
Normal file
@ -0,0 +1,407 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine provide_no_0e(n_grid, n_mo, ne_a, ne_b, wr1, mos_l_in_r, mos_r_in_r, int2_grad1_u12, noL_0e)
|
||||
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: n_grid, n_mo
|
||||
integer, intent(in) :: ne_a, ne_b
|
||||
double precision, intent(in) :: wr1(n_grid)
|
||||
double precision, intent(in) :: mos_l_in_r(n_grid,n_mo)
|
||||
double precision, intent(in) :: mos_r_in_r(n_grid,n_mo)
|
||||
double precision, intent(in) :: int2_grad1_u12(n_grid,3,n_mo,n_mo)
|
||||
double precision, intent(out) :: noL_0e
|
||||
|
||||
integer :: i, j, k, ipoint
|
||||
double precision :: t0, t1
|
||||
double precision, allocatable :: tmp(:)
|
||||
double precision, allocatable :: tmpL(:,:), tmpR(:,:)
|
||||
double precision, allocatable :: tmpM(:,:), tmpS(:), tmpO(:), tmpJ(:,:)
|
||||
double precision, allocatable :: tmpM_priv(:,:), tmpS_priv(:), tmpO_priv(:), tmpJ_priv(:,:)
|
||||
|
||||
|
||||
call wall_time(t0)
|
||||
|
||||
|
||||
if(ne_a .eq. ne_b) then
|
||||
|
||||
allocate(tmp(ne_b))
|
||||
allocate(tmpL(n_grid,3), tmpR(n_grid,3))
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(j, i, ipoint, tmpL, tmpR) &
|
||||
!$OMP SHARED(ne_b, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, wr1, &
|
||||
!$OMP int2_grad1_u12, tmp)
|
||||
|
||||
!$OMP DO
|
||||
do j = 1, ne_b
|
||||
|
||||
tmpL = 0.d0
|
||||
tmpR = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpL(ipoint,1) = tmpL(ipoint,1) + int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,2) = tmpL(ipoint,2) + int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,3) = tmpL(ipoint,3) + int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i)
|
||||
|
||||
tmpR(ipoint,1) = tmpR(ipoint,1) + int2_grad1_u12(ipoint,1,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,2) = tmpR(ipoint,2) + int2_grad1_u12(ipoint,2,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,3) = tmpR(ipoint,3) + int2_grad1_u12(ipoint,3,i,j) * mos_r_in_r(ipoint,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
tmp(j) = 0.d0
|
||||
do ipoint = 1, n_grid
|
||||
tmp(j) = tmp(j) + wr1(ipoint) * (tmpL(ipoint,1)*tmpR(ipoint,1) + tmpL(ipoint,2)*tmpR(ipoint,2) + tmpL(ipoint,3)*tmpR(ipoint,3))
|
||||
enddo
|
||||
enddo ! j
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
noL_0e = -2.d0 * sum(tmp)
|
||||
|
||||
deallocate(tmp)
|
||||
deallocate(tmpL, tmpR)
|
||||
|
||||
! ---
|
||||
|
||||
allocate(tmpO(n_grid), tmpJ(n_grid,3))
|
||||
tmpO = 0.d0
|
||||
tmpJ = 0.d0
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(i, ipoint, tmpO_priv, tmpJ_priv) &
|
||||
!$OMP SHARED(ne_b, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, tmpO, tmpJ)
|
||||
|
||||
allocate(tmpO_priv(n_grid), tmpJ_priv(n_grid,3))
|
||||
tmpO_priv = 0.d0
|
||||
tmpJ_priv = 0.d0
|
||||
|
||||
!$OMP DO
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpO_priv(ipoint) = tmpO_priv(ipoint) + mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ_priv(ipoint,1) = tmpJ_priv(ipoint,1) + int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ_priv(ipoint,2) = tmpJ_priv(ipoint,2) + int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ_priv(ipoint,3) = tmpJ_priv(ipoint,3) + int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP CRITICAL
|
||||
tmpO = tmpO + tmpO_priv
|
||||
tmpJ = tmpJ + tmpJ_priv
|
||||
!$OMP END CRITICAL
|
||||
|
||||
deallocate(tmpO_priv, tmpJ_priv)
|
||||
!$OMP END PARALLEL
|
||||
|
||||
allocate(tmpM(n_grid,3), tmpS(n_grid))
|
||||
tmpM = 0.d0
|
||||
tmpS = 0.d0
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(i, j, ipoint, tmpM_priv, tmpS_priv) &
|
||||
!$OMP SHARED(ne_b, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, tmpM, tmpS)
|
||||
|
||||
allocate(tmpM_priv(n_grid,3), tmpS_priv(n_grid))
|
||||
tmpM_priv = 0.d0
|
||||
tmpS_priv = 0.d0
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do i = 1, ne_b
|
||||
do j = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpM_priv(ipoint,1) = tmpM_priv(ipoint,1) + int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,2) = tmpM_priv(ipoint,2) + int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,3) = tmpM_priv(ipoint,3) + int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
|
||||
tmpS_priv(ipoint) = tmpS_priv(ipoint) + int2_grad1_u12(ipoint,1,i,j) * int2_grad1_u12(ipoint,1,j,i) &
|
||||
+ int2_grad1_u12(ipoint,2,i,j) * int2_grad1_u12(ipoint,2,j,i) &
|
||||
+ int2_grad1_u12(ipoint,3,i,j) * int2_grad1_u12(ipoint,3,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP CRITICAL
|
||||
tmpM = tmpM + tmpM_priv
|
||||
tmpS = tmpS + tmpS_priv
|
||||
!$OMP END CRITICAL
|
||||
|
||||
deallocate(tmpM_priv, tmpS_priv)
|
||||
!$OMP END PARALLEL
|
||||
|
||||
allocate(tmp(n_grid))
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpS(ipoint) = 2.d0 * (tmpJ(ipoint,1)*tmpJ(ipoint,1) + tmpJ(ipoint,2)*tmpJ(ipoint,2) + tmpJ(ipoint,3)*tmpJ(ipoint,3)) - tmpS(ipoint)
|
||||
|
||||
tmp(ipoint) = wr1(ipoint) * ( tmpO(ipoint) * tmpS(ipoint) - 2.d0 * ( tmpJ(ipoint,1) * tmpM(ipoint,1) &
|
||||
+ tmpJ(ipoint,2) * tmpM(ipoint,2) &
|
||||
+ tmpJ(ipoint,3) * tmpM(ipoint,3) ) )
|
||||
enddo
|
||||
|
||||
noL_0e = noL_0e - 2.d0 * (sum(tmp))
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
else
|
||||
|
||||
allocate(tmp(ne_a))
|
||||
allocate(tmpL(n_grid,3), tmpR(n_grid,3))
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(j, i, ipoint, tmpL, tmpR) &
|
||||
!$OMP SHARED(ne_b, ne_a, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, tmp, wr1)
|
||||
|
||||
!$OMP DO
|
||||
do j = 1, ne_b
|
||||
|
||||
tmpL = 0.d0
|
||||
tmpR = 0.d0
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpL(ipoint,1) = tmpL(ipoint,1) + 0.5d0 * int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,2) = tmpL(ipoint,2) + 0.5d0 * int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,3) = tmpL(ipoint,3) + 0.5d0 * int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i)
|
||||
|
||||
tmpR(ipoint,1) = tmpR(ipoint,1) + 0.5d0 * int2_grad1_u12(ipoint,1,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,2) = tmpR(ipoint,2) + 0.5d0 * int2_grad1_u12(ipoint,2,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,3) = tmpR(ipoint,3) + 0.5d0 * int2_grad1_u12(ipoint,3,i,j) * mos_r_in_r(ipoint,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
tmp(j) = 0.d0
|
||||
do ipoint = 1, n_grid
|
||||
tmp(j) = tmp(j) + wr1(ipoint) * (tmpL(ipoint,1)*tmpR(ipoint,1) + tmpL(ipoint,2)*tmpR(ipoint,2) + tmpL(ipoint,3)*tmpR(ipoint,3))
|
||||
enddo
|
||||
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpL(ipoint,1) = tmpL(ipoint,1) + int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,2) = tmpL(ipoint,2) + int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,3) = tmpL(ipoint,3) + int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i)
|
||||
|
||||
tmpR(ipoint,1) = tmpR(ipoint,1) + int2_grad1_u12(ipoint,1,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,2) = tmpR(ipoint,2) + int2_grad1_u12(ipoint,2,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,3) = tmpR(ipoint,3) + int2_grad1_u12(ipoint,3,i,j) * mos_r_in_r(ipoint,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
tmp(j) = tmp(j) + wr1(ipoint) * (tmpL(ipoint,1)*tmpR(ipoint,1) + tmpL(ipoint,2)*tmpR(ipoint,2) + tmpL(ipoint,3)*tmpR(ipoint,3))
|
||||
enddo
|
||||
enddo ! j
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
! ---
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(j, i, ipoint, tmpL, tmpR) &
|
||||
!$OMP SHARED(ne_b, ne_a, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, tmp, wr1)
|
||||
|
||||
!$OMP DO
|
||||
do j = ne_b+1, ne_a
|
||||
|
||||
tmpL = 0.d0
|
||||
tmpR = 0.d0
|
||||
do i = 1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpL(ipoint,1) = tmpL(ipoint,1) + int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,2) = tmpL(ipoint,2) + int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i)
|
||||
tmpL(ipoint,3) = tmpL(ipoint,3) + int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i)
|
||||
|
||||
tmpR(ipoint,1) = tmpR(ipoint,1) + int2_grad1_u12(ipoint,1,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,2) = tmpR(ipoint,2) + int2_grad1_u12(ipoint,2,i,j) * mos_r_in_r(ipoint,i)
|
||||
tmpR(ipoint,3) = tmpR(ipoint,3) + int2_grad1_u12(ipoint,3,i,j) * mos_r_in_r(ipoint,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
tmp(j) = 0.d0
|
||||
do ipoint = 1, n_grid
|
||||
tmp(j) = tmp(j) + 0.5d0 * wr1(ipoint) * (tmpL(ipoint,1)*tmpR(ipoint,1) + tmpL(ipoint,2)*tmpR(ipoint,2) + tmpL(ipoint,3)*tmpR(ipoint,3))
|
||||
enddo
|
||||
enddo ! j
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
noL_0e = -2.d0 * sum(tmp)
|
||||
|
||||
deallocate(tmp)
|
||||
deallocate(tmpL, tmpR)
|
||||
|
||||
! ---
|
||||
|
||||
allocate(tmpO(n_grid), tmpJ(n_grid,3))
|
||||
tmpO = 0.d0
|
||||
tmpJ = 0.d0
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(i, ipoint, tmpO_priv, tmpJ_priv) &
|
||||
!$OMP SHARED(ne_b, ne_a, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, tmpO, tmpJ)
|
||||
|
||||
allocate(tmpO_priv(n_grid), tmpJ_priv(n_grid,3))
|
||||
tmpO_priv = 0.d0
|
||||
tmpJ_priv = 0.d0
|
||||
|
||||
!$OMP DO
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpO_priv(ipoint) = tmpO_priv(ipoint) + mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ_priv(ipoint,1) = tmpJ_priv(ipoint,1) + int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ_priv(ipoint,2) = tmpJ_priv(ipoint,2) + int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ_priv(ipoint,3) = tmpJ_priv(ipoint,3) + int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP DO
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpO_priv(ipoint) = tmpO_priv(ipoint) + 0.5d0 * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ_priv(ipoint,1) = tmpJ_priv(ipoint,1) + 0.5d0 * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ_priv(ipoint,2) = tmpJ_priv(ipoint,2) + 0.5d0 * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ_priv(ipoint,3) = tmpJ_priv(ipoint,3) + 0.5d0 * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP CRITICAL
|
||||
tmpO = tmpO + tmpO_priv
|
||||
tmpJ = tmpJ + tmpJ_priv
|
||||
!$OMP END CRITICAL
|
||||
|
||||
deallocate(tmpO_priv, tmpJ_priv)
|
||||
!$OMP END PARALLEL
|
||||
|
||||
! ---
|
||||
|
||||
allocate(tmpM(n_grid,3), tmpS(n_grid))
|
||||
tmpM = 0.d0
|
||||
tmpS = 0.d0
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(i, j, ipoint, tmpM_priv, tmpS_priv) &
|
||||
!$OMP SHARED(ne_b, ne_a, n_grid, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, tmpM, tmpS)
|
||||
|
||||
allocate(tmpM_priv(n_grid,3), tmpS_priv(n_grid))
|
||||
tmpM_priv = 0.d0
|
||||
tmpS_priv = 0.d0
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do i = 1, ne_b
|
||||
do j = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpM_priv(ipoint,1) = tmpM_priv(ipoint,1) + int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,2) = tmpM_priv(ipoint,2) + int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,3) = tmpM_priv(ipoint,3) + int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
|
||||
tmpS_priv(ipoint) = tmpS_priv(ipoint) + int2_grad1_u12(ipoint,1,i,j) * int2_grad1_u12(ipoint,1,j,i) &
|
||||
+ int2_grad1_u12(ipoint,2,i,j) * int2_grad1_u12(ipoint,2,j,i) &
|
||||
+ int2_grad1_u12(ipoint,3,i,j) * int2_grad1_u12(ipoint,3,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do i = ne_b+1, ne_a
|
||||
do j = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpM_priv(ipoint,1) = tmpM_priv(ipoint,1) + 0.5d0 * int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,2) = tmpM_priv(ipoint,2) + 0.5d0 * int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,3) = tmpM_priv(ipoint,3) + 0.5d0 * int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
|
||||
tmpM_priv(ipoint,1) = tmpM_priv(ipoint,1) + 0.5d0 * int2_grad1_u12(ipoint,1,i,j) * mos_l_in_r(ipoint,j) * mos_r_in_r(ipoint,i)
|
||||
tmpM_priv(ipoint,2) = tmpM_priv(ipoint,2) + 0.5d0 * int2_grad1_u12(ipoint,2,i,j) * mos_l_in_r(ipoint,j) * mos_r_in_r(ipoint,i)
|
||||
tmpM_priv(ipoint,3) = tmpM_priv(ipoint,3) + 0.5d0 * int2_grad1_u12(ipoint,3,i,j) * mos_l_in_r(ipoint,j) * mos_r_in_r(ipoint,i)
|
||||
|
||||
tmpS_priv(ipoint) = tmpS_priv(ipoint) + int2_grad1_u12(ipoint,1,i,j) * int2_grad1_u12(ipoint,1,j,i) &
|
||||
+ int2_grad1_u12(ipoint,2,i,j) * int2_grad1_u12(ipoint,2,j,i) &
|
||||
+ int2_grad1_u12(ipoint,3,i,j) * int2_grad1_u12(ipoint,3,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do i = ne_b+1, ne_a
|
||||
do j = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpM_priv(ipoint,1) = tmpM_priv(ipoint,1) + 0.5d0 * int2_grad1_u12(ipoint,1,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,2) = tmpM_priv(ipoint,2) + 0.5d0 * int2_grad1_u12(ipoint,2,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
tmpM_priv(ipoint,3) = tmpM_priv(ipoint,3) + 0.5d0 * int2_grad1_u12(ipoint,3,j,i) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,j)
|
||||
|
||||
tmpS_priv(ipoint) = tmpS_priv(ipoint) + 0.5d0 * int2_grad1_u12(ipoint,1,i,j) * int2_grad1_u12(ipoint,1,j,i) &
|
||||
+ 0.5d0 * int2_grad1_u12(ipoint,2,i,j) * int2_grad1_u12(ipoint,2,j,i) &
|
||||
+ 0.5d0 * int2_grad1_u12(ipoint,3,i,j) * int2_grad1_u12(ipoint,3,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP CRITICAL
|
||||
tmpM = tmpM + tmpM_priv
|
||||
tmpS = tmpS + tmpS_priv
|
||||
!$OMP END CRITICAL
|
||||
|
||||
deallocate(tmpM_priv, tmpS_priv)
|
||||
!$OMP END PARALLEL
|
||||
|
||||
allocate(tmp(n_grid))
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpS(ipoint) = 2.d0 * (tmpJ(ipoint,1)*tmpJ(ipoint,1) + tmpJ(ipoint,2)*tmpJ(ipoint,2) + tmpJ(ipoint,3)*tmpJ(ipoint,3)) - tmpS(ipoint)
|
||||
|
||||
tmp(ipoint) = wr1(ipoint) * ( tmpO(ipoint) * tmpS(ipoint) - 2.d0 * ( tmpJ(ipoint,1) * tmpM(ipoint,1) &
|
||||
+ tmpJ(ipoint,2) * tmpM(ipoint,2) &
|
||||
+ tmpJ(ipoint,3) * tmpM(ipoint,3) ) )
|
||||
enddo
|
||||
|
||||
noL_0e = noL_0e - 2.d0 * (sum(tmp))
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
call wall_time(t1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for noL_0e (sec) = ', (t1 - t0)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
1179
plugins/local/tc_int/no_1e.irp.f
Normal file
1179
plugins/local/tc_int/no_1e.irp.f
Normal file
File diff suppressed because it is too large
Load Diff
605
plugins/local/tc_int/no_2e.irp.f
Normal file
605
plugins/local/tc_int/no_2e.irp.f
Normal file
@ -0,0 +1,605 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine provide_no_2e(n_grid, n_mo, ne_a, ne_b, wr1, mos_l_in_r, mos_r_in_r, int2_grad1_u12, noL_2e)
|
||||
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: n_grid, n_mo
|
||||
integer, intent(in) :: ne_a, ne_b
|
||||
double precision, intent(in) :: wr1(n_grid)
|
||||
double precision, intent(in) :: mos_l_in_r(n_grid,n_mo)
|
||||
double precision, intent(in) :: mos_r_in_r(n_grid,n_mo)
|
||||
double precision, intent(in) :: int2_grad1_u12(n_grid,3,n_mo,n_mo)
|
||||
double precision, intent(out) :: noL_2e(n_mo,n_mo,n_mo,n_mo)
|
||||
|
||||
integer :: p, q, s, t, i, ipoint
|
||||
double precision :: t0, t1
|
||||
double precision, allocatable :: tmpO(:), tmpJ(:,:)
|
||||
double precision, allocatable :: tmpA(:,:,:), tmpB(:,:,:)
|
||||
double precision, allocatable :: tmpC(:,:,:,:), tmpD(:,:,:,:)
|
||||
double precision, allocatable :: tmpE(:,:,:,:)
|
||||
|
||||
|
||||
call wall_time(t0)
|
||||
|
||||
if(ne_a .eq. ne_b) then
|
||||
|
||||
allocate(tmpO(n_grid), tmpJ(n_grid,3))
|
||||
allocate(tmpA(n_grid,3,n_mo), tmpB(n_grid,3,n_mo))
|
||||
allocate(tmpC(n_grid,4,n_mo,n_mo), tmpD(n_grid,4,n_mo,n_mo))
|
||||
allocate(tmpE(n_mo,n_mo,n_mo,n_mo))
|
||||
|
||||
tmpO = 0.d0
|
||||
tmpJ = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpO(ipoint) = tmpO(ipoint) + wr1(ipoint) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ(ipoint,1) = tmpJ(ipoint,1) + wr1(ipoint) * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ(ipoint,2) = tmpJ(ipoint,2) + wr1(ipoint) * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ(ipoint,3) = tmpJ(ipoint,3) + wr1(ipoint) * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB)
|
||||
|
||||
!$OMP DO
|
||||
do p = 1, n_mo
|
||||
|
||||
tmpA(:,:,p) = 0.d0
|
||||
tmpB(:,:,p) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpA(ipoint,1,p) = tmpA(ipoint,1,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,p,i)
|
||||
tmpA(ipoint,2,p) = tmpA(ipoint,2,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,p,i)
|
||||
tmpA(ipoint,3,p) = tmpA(ipoint,3,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,p,i)
|
||||
tmpB(ipoint,1,p) = tmpB(ipoint,1,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,i,p)
|
||||
tmpB(ipoint,2,p) = tmpB(ipoint,2,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,i,p)
|
||||
tmpB(ipoint,3,p) = tmpB(ipoint,3,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,i,p)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, s, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB, tmpO, tmpJ, tmpC, tmpD)
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do s = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpC(ipoint,1,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,1,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,1,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,1,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,1)
|
||||
tmpC(ipoint,2,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,2,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,2,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,2,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,2)
|
||||
tmpC(ipoint,3,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,3,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,3,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,3,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,3)
|
||||
|
||||
tmpD(ipoint,1,p,s) = int2_grad1_u12(ipoint,1,p,s)
|
||||
tmpD(ipoint,2,p,s) = int2_grad1_u12(ipoint,2,p,s)
|
||||
tmpD(ipoint,3,p,s) = int2_grad1_u12(ipoint,3,p,s)
|
||||
tmpD(ipoint,4,p,s) = wr1(ipoint) * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s)
|
||||
|
||||
enddo ! ipoint
|
||||
|
||||
tmpC(:,4,p,s) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpC(ipoint,4,p,s) += int2_grad1_u12(ipoint,1,p,i) * int2_grad1_u12(ipoint,1,i,s) &
|
||||
+ int2_grad1_u12(ipoint,2,p,i) * int2_grad1_u12(ipoint,2,i,s) &
|
||||
+ int2_grad1_u12(ipoint,3,p,i) * int2_grad1_u12(ipoint,3,i,s)
|
||||
enddo ! ipoint
|
||||
enddo ! i
|
||||
|
||||
enddo ! p
|
||||
enddo ! s
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(tmpO, tmpJ, tmpA, tmpB)
|
||||
|
||||
|
||||
call dgemm( 'T', 'N', n_mo*n_mo, n_mo*n_mo, 4*n_grid, 0.5d0 &
|
||||
, tmpC(1,1,1,1), 4*n_grid, tmpD(1,1,1,1), 4*n_grid &
|
||||
, 0.d0, tmpE(1,1,1,1), n_mo*n_mo)
|
||||
|
||||
deallocate(tmpC, tmpD)
|
||||
|
||||
call sum_a_at(tmpE, n_mo*n_mo)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(t, s, q, p) &
|
||||
!$OMP SHARED(n_mo, tmpE, noL_2e)
|
||||
|
||||
!$OMP DO COLLAPSE(3)
|
||||
do t = 1, n_mo
|
||||
do s = 1, n_mo
|
||||
do q = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
noL_2e(p,q,s,t) = tmpE(p,s,q,t)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(tmpE)
|
||||
|
||||
else
|
||||
|
||||
allocate(tmpO(n_grid), tmpJ(n_grid,3))
|
||||
allocate(tmpA(n_grid,3,n_mo), tmpB(n_grid,3,n_mo))
|
||||
allocate(tmpC(n_grid,4,n_mo,n_mo), tmpD(n_grid,4,n_mo,n_mo))
|
||||
allocate(tmpE(n_mo,n_mo,n_mo,n_mo))
|
||||
|
||||
tmpO = 0.d0
|
||||
tmpJ = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpO(ipoint) = tmpO(ipoint) + wr1(ipoint) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ(ipoint,1) = tmpJ(ipoint,1) + wr1(ipoint) * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ(ipoint,2) = tmpJ(ipoint,2) + wr1(ipoint) * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ(ipoint,3) = tmpJ(ipoint,3) + wr1(ipoint) * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpO(ipoint) = tmpO(ipoint) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ(ipoint,1) = tmpJ(ipoint,1) + 0.5d0 * wr1(ipoint) * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ(ipoint,2) = tmpJ(ipoint,2) + 0.5d0 * wr1(ipoint) * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ(ipoint,3) = tmpJ(ipoint,3) + 0.5d0 * wr1(ipoint) * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_a, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB)
|
||||
|
||||
!$OMP DO
|
||||
do p = 1, n_mo
|
||||
|
||||
tmpA(:,:,p) = 0.d0
|
||||
tmpB(:,:,p) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpA(ipoint,1,p) = tmpA(ipoint,1,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,p,i)
|
||||
tmpA(ipoint,2,p) = tmpA(ipoint,2,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,p,i)
|
||||
tmpA(ipoint,3,p) = tmpA(ipoint,3,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,p,i)
|
||||
tmpB(ipoint,1,p) = tmpB(ipoint,1,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,i,p)
|
||||
tmpB(ipoint,2,p) = tmpB(ipoint,2,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,i,p)
|
||||
tmpB(ipoint,3,p) = tmpB(ipoint,3,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,i,p)
|
||||
enddo
|
||||
enddo
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpA(ipoint,1,p) = tmpA(ipoint,1,p) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,p,i)
|
||||
tmpA(ipoint,2,p) = tmpA(ipoint,2,p) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,p,i)
|
||||
tmpA(ipoint,3,p) = tmpA(ipoint,3,p) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,p,i)
|
||||
tmpB(ipoint,1,p) = tmpB(ipoint,1,p) + 0.5d0 * wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,i,p)
|
||||
tmpB(ipoint,2,p) = tmpB(ipoint,2,p) + 0.5d0 * wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,i,p)
|
||||
tmpB(ipoint,3,p) = tmpB(ipoint,3,p) + 0.5d0 * wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,i,p)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, s, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_a, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB, tmpO, tmpJ, tmpC, tmpD)
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do s = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpC(ipoint,1,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,1,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,1,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,1,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,1)
|
||||
tmpC(ipoint,2,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,2,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,2,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,2,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,2)
|
||||
tmpC(ipoint,3,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,3,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,3,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,3,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,3)
|
||||
|
||||
tmpD(ipoint,1,p,s) = int2_grad1_u12(ipoint,1,p,s)
|
||||
tmpD(ipoint,2,p,s) = int2_grad1_u12(ipoint,2,p,s)
|
||||
tmpD(ipoint,3,p,s) = int2_grad1_u12(ipoint,3,p,s)
|
||||
tmpD(ipoint,4,p,s) = wr1(ipoint) * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s)
|
||||
|
||||
enddo ! ipoint
|
||||
|
||||
tmpC(:,4,p,s) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpC(ipoint,4,p,s) += int2_grad1_u12(ipoint,1,p,i) * int2_grad1_u12(ipoint,1,i,s) &
|
||||
+ int2_grad1_u12(ipoint,2,p,i) * int2_grad1_u12(ipoint,2,i,s) &
|
||||
+ int2_grad1_u12(ipoint,3,p,i) * int2_grad1_u12(ipoint,3,i,s)
|
||||
enddo ! ipoint
|
||||
enddo ! i
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpC(ipoint,4,p,s) += 0.5d0 * int2_grad1_u12(ipoint,1,p,i) * int2_grad1_u12(ipoint,1,i,s) &
|
||||
+ 0.5d0 * int2_grad1_u12(ipoint,2,p,i) * int2_grad1_u12(ipoint,2,i,s) &
|
||||
+ 0.5d0 * int2_grad1_u12(ipoint,3,p,i) * int2_grad1_u12(ipoint,3,i,s)
|
||||
enddo ! ipoint
|
||||
enddo ! i
|
||||
|
||||
enddo ! p
|
||||
enddo ! s
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(tmpO, tmpJ, tmpA, tmpB)
|
||||
|
||||
|
||||
call dgemm( 'T', 'N', n_mo*n_mo, n_mo*n_mo, 4*n_grid, 0.5d0 &
|
||||
, tmpC(1,1,1,1), 4*n_grid, tmpD(1,1,1,1), 4*n_grid &
|
||||
, 0.d0, tmpE(1,1,1,1), n_mo*n_mo)
|
||||
|
||||
deallocate(tmpC, tmpD)
|
||||
|
||||
call sum_a_at(tmpE, n_mo*n_mo)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(t, s, q, p) &
|
||||
!$OMP SHARED(n_mo, tmpE, noL_2e)
|
||||
|
||||
!$OMP DO COLLAPSE(3)
|
||||
do t = 1, n_mo
|
||||
do s = 1, n_mo
|
||||
do q = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
noL_2e(p,q,s,t) = tmpE(p,s,q,t)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
deallocate(tmpE)
|
||||
|
||||
endif
|
||||
|
||||
call wall_time(t1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for noL_2e (sec) = ', (t1 - t0)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine provide_no_2e_tmp(n_grid, n_mo, ne_a, ne_b, wr1, mos_l_in_r, mos_r_in_r, int2_grad1_u12, &
|
||||
tmpO, tmpJ, tmpA, tmpB, tmpC, tmpD, tmpE, noL_2e)
|
||||
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: n_grid, n_mo
|
||||
integer, intent(in) :: ne_a, ne_b
|
||||
double precision, intent(in) :: wr1(n_grid)
|
||||
double precision, intent(in) :: mos_l_in_r(n_grid,n_mo)
|
||||
double precision, intent(in) :: mos_r_in_r(n_grid,n_mo)
|
||||
double precision, intent(in) :: int2_grad1_u12(n_grid,3,n_mo,n_mo)
|
||||
double precision, intent(out) :: tmpO(n_grid), tmpJ(n_grid,3)
|
||||
double precision, intent(out) :: tmpA(n_grid,3,n_mo), tmpB(n_grid,3,n_mo)
|
||||
double precision, intent(out) :: tmpC(n_grid,4,n_mo,n_mo), tmpD(n_grid,4,n_mo,n_mo)
|
||||
double precision, intent(out) :: tmpE(n_mo,n_mo,n_mo,n_mo)
|
||||
double precision, intent(out) :: noL_2e(n_mo,n_mo,n_mo,n_mo)
|
||||
|
||||
integer :: p, q, s, t, i, ipoint
|
||||
double precision :: t0, t1
|
||||
|
||||
|
||||
call wall_time(t0)
|
||||
|
||||
if(ne_a .eq. ne_b) then
|
||||
|
||||
tmpO = 0.d0
|
||||
tmpJ = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpO(ipoint) = tmpO(ipoint) + wr1(ipoint) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ(ipoint,1) = tmpJ(ipoint,1) + wr1(ipoint) * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ(ipoint,2) = tmpJ(ipoint,2) + wr1(ipoint) * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ(ipoint,3) = tmpJ(ipoint,3) + wr1(ipoint) * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB)
|
||||
|
||||
!$OMP DO
|
||||
do p = 1, n_mo
|
||||
|
||||
tmpA(:,:,p) = 0.d0
|
||||
tmpB(:,:,p) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpA(ipoint,1,p) = tmpA(ipoint,1,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,p,i)
|
||||
tmpA(ipoint,2,p) = tmpA(ipoint,2,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,p,i)
|
||||
tmpA(ipoint,3,p) = tmpA(ipoint,3,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,p,i)
|
||||
tmpB(ipoint,1,p) = tmpB(ipoint,1,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,i,p)
|
||||
tmpB(ipoint,2,p) = tmpB(ipoint,2,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,i,p)
|
||||
tmpB(ipoint,3,p) = tmpB(ipoint,3,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,i,p)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, s, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB, tmpO, tmpJ, tmpC, tmpD)
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do s = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpC(ipoint,1,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,1,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,1,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,1,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,1)
|
||||
tmpC(ipoint,2,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,2,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,2,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,2,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,2)
|
||||
tmpC(ipoint,3,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,3,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,3,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,3,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,3)
|
||||
|
||||
tmpD(ipoint,1,p,s) = int2_grad1_u12(ipoint,1,p,s)
|
||||
tmpD(ipoint,2,p,s) = int2_grad1_u12(ipoint,2,p,s)
|
||||
tmpD(ipoint,3,p,s) = int2_grad1_u12(ipoint,3,p,s)
|
||||
tmpD(ipoint,4,p,s) = wr1(ipoint) * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s)
|
||||
|
||||
enddo ! ipoint
|
||||
|
||||
tmpC(:,4,p,s) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpC(ipoint,4,p,s) += int2_grad1_u12(ipoint,1,p,i) * int2_grad1_u12(ipoint,1,i,s) &
|
||||
+ int2_grad1_u12(ipoint,2,p,i) * int2_grad1_u12(ipoint,2,i,s) &
|
||||
+ int2_grad1_u12(ipoint,3,p,i) * int2_grad1_u12(ipoint,3,i,s)
|
||||
enddo ! ipoint
|
||||
enddo ! i
|
||||
|
||||
enddo ! p
|
||||
enddo ! s
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
call dgemm( 'T', 'N', n_mo*n_mo, n_mo*n_mo, 4*n_grid, 0.5d0 &
|
||||
, tmpC(1,1,1,1), 4*n_grid, tmpD(1,1,1,1), 4*n_grid &
|
||||
, 0.d0, tmpE(1,1,1,1), n_mo*n_mo)
|
||||
|
||||
call sum_a_at(tmpE, n_mo*n_mo)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(t, s, q, p) &
|
||||
!$OMP SHARED(n_mo, tmpE, noL_2e)
|
||||
|
||||
!$OMP DO COLLAPSE(3)
|
||||
do t = 1, n_mo
|
||||
do s = 1, n_mo
|
||||
do q = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
noL_2e(p,q,s,t) = tmpE(p,s,q,t)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
else
|
||||
|
||||
tmpO = 0.d0
|
||||
tmpJ = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpO(ipoint) = tmpO(ipoint) + wr1(ipoint) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ(ipoint,1) = tmpJ(ipoint,1) + wr1(ipoint) * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ(ipoint,2) = tmpJ(ipoint,2) + wr1(ipoint) * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ(ipoint,3) = tmpJ(ipoint,3) + wr1(ipoint) * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpO(ipoint) = tmpO(ipoint) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * mos_r_in_r(ipoint,i)
|
||||
tmpJ(ipoint,1) = tmpJ(ipoint,1) + 0.5d0 * wr1(ipoint) * int2_grad1_u12(ipoint,1,i,i)
|
||||
tmpJ(ipoint,2) = tmpJ(ipoint,2) + 0.5d0 * wr1(ipoint) * int2_grad1_u12(ipoint,2,i,i)
|
||||
tmpJ(ipoint,3) = tmpJ(ipoint,3) + 0.5d0 * wr1(ipoint) * int2_grad1_u12(ipoint,3,i,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_a, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB)
|
||||
|
||||
!$OMP DO
|
||||
do p = 1, n_mo
|
||||
|
||||
tmpA(:,:,p) = 0.d0
|
||||
tmpB(:,:,p) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpA(ipoint,1,p) = tmpA(ipoint,1,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,p,i)
|
||||
tmpA(ipoint,2,p) = tmpA(ipoint,2,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,p,i)
|
||||
tmpA(ipoint,3,p) = tmpA(ipoint,3,p) + wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,p,i)
|
||||
tmpB(ipoint,1,p) = tmpB(ipoint,1,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,i,p)
|
||||
tmpB(ipoint,2,p) = tmpB(ipoint,2,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,i,p)
|
||||
tmpB(ipoint,3,p) = tmpB(ipoint,3,p) + wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,i,p)
|
||||
enddo
|
||||
enddo
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpA(ipoint,1,p) = tmpA(ipoint,1,p) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,p,i)
|
||||
tmpA(ipoint,2,p) = tmpA(ipoint,2,p) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,p,i)
|
||||
tmpA(ipoint,3,p) = tmpA(ipoint,3,p) + 0.5d0 * wr1(ipoint) * mos_l_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,p,i)
|
||||
tmpB(ipoint,1,p) = tmpB(ipoint,1,p) + 0.5d0 * wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,1,i,p)
|
||||
tmpB(ipoint,2,p) = tmpB(ipoint,2,p) + 0.5d0 * wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,2,i,p)
|
||||
tmpB(ipoint,3,p) = tmpB(ipoint,3,p) + 0.5d0 * wr1(ipoint) * mos_r_in_r(ipoint,i) * int2_grad1_u12(ipoint,3,i,p)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(p, s, i, ipoint) &
|
||||
!$OMP SHARED(n_mo, ne_a, ne_b, n_grid, &
|
||||
!$OMP wr1, &
|
||||
!$OMP mos_l_in_r, mos_r_in_r, &
|
||||
!$OMP int2_grad1_u12, &
|
||||
!$OMP tmpA, tmpB, tmpO, tmpJ, tmpC, tmpD)
|
||||
|
||||
!$OMP DO COLLAPSE(2)
|
||||
do s = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
|
||||
do ipoint = 1, n_grid
|
||||
|
||||
tmpC(ipoint,1,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,1,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,1,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,1,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,1)
|
||||
tmpC(ipoint,2,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,2,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,2,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,2,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,2)
|
||||
tmpC(ipoint,3,p,s) = mos_r_in_r(ipoint,s) * tmpA(ipoint,3,p) &
|
||||
+ mos_l_in_r(ipoint,p) * tmpB(ipoint,3,s) &
|
||||
- tmpO(ipoint) * int2_grad1_u12(ipoint,3,p,s) &
|
||||
- 2.d0 * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s) * tmpJ(ipoint,3)
|
||||
|
||||
tmpD(ipoint,1,p,s) = int2_grad1_u12(ipoint,1,p,s)
|
||||
tmpD(ipoint,2,p,s) = int2_grad1_u12(ipoint,2,p,s)
|
||||
tmpD(ipoint,3,p,s) = int2_grad1_u12(ipoint,3,p,s)
|
||||
tmpD(ipoint,4,p,s) = wr1(ipoint) * mos_l_in_r(ipoint,p) * mos_r_in_r(ipoint,s)
|
||||
|
||||
enddo ! ipoint
|
||||
|
||||
tmpC(:,4,p,s) = 0.d0
|
||||
do i = 1, ne_b
|
||||
do ipoint = 1, n_grid
|
||||
tmpC(ipoint,4,p,s) += int2_grad1_u12(ipoint,1,p,i) * int2_grad1_u12(ipoint,1,i,s) &
|
||||
+ int2_grad1_u12(ipoint,2,p,i) * int2_grad1_u12(ipoint,2,i,s) &
|
||||
+ int2_grad1_u12(ipoint,3,p,i) * int2_grad1_u12(ipoint,3,i,s)
|
||||
enddo ! ipoint
|
||||
enddo ! i
|
||||
do i = ne_b+1, ne_a
|
||||
do ipoint = 1, n_grid
|
||||
tmpC(ipoint,4,p,s) += 0.5d0 * int2_grad1_u12(ipoint,1,p,i) * int2_grad1_u12(ipoint,1,i,s) &
|
||||
+ 0.5d0 * int2_grad1_u12(ipoint,2,p,i) * int2_grad1_u12(ipoint,2,i,s) &
|
||||
+ 0.5d0 * int2_grad1_u12(ipoint,3,p,i) * int2_grad1_u12(ipoint,3,i,s)
|
||||
enddo ! ipoint
|
||||
enddo ! i
|
||||
|
||||
enddo ! p
|
||||
enddo ! s
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
call dgemm( 'T', 'N', n_mo*n_mo, n_mo*n_mo, 4*n_grid, 0.5d0 &
|
||||
, tmpC(1,1,1,1), 4*n_grid, tmpD(1,1,1,1), 4*n_grid &
|
||||
, 0.d0, tmpE(1,1,1,1), n_mo*n_mo)
|
||||
|
||||
call sum_a_at(tmpE, n_mo*n_mo)
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT(NONE) &
|
||||
!$OMP PRIVATE(t, s, q, p) &
|
||||
!$OMP SHARED(n_mo, tmpE, noL_2e)
|
||||
|
||||
!$OMP DO COLLAPSE(3)
|
||||
do t = 1, n_mo
|
||||
do s = 1, n_mo
|
||||
do q = 1, n_mo
|
||||
do p = 1, n_mo
|
||||
noL_2e(p,q,s,t) = tmpE(p,s,q,t)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
endif
|
||||
|
||||
call wall_time(t1)
|
||||
write(*,"(A,2X,F15.7)") ' wall time for noL_2e & tmp tensors (sec) = ', (t1 - t0)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
13
plugins/local/tc_int/uninstall
Executable file
13
plugins/local/tc_int/uninstall
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if the QP_ROOT environment variable is set.
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
print "The QP_ROOT environment variable is not set."
|
||||
print "Please reload the quantum_package.rc file."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
rm -rf ${PWD}/CuTC
|
||||
rm ${QP_ROOT}/lib/libcutcint.so
|
||||
|
194
plugins/local/tc_int/write_tc_int_cuda.irp.f
Normal file
194
plugins/local/tc_int/write_tc_int_cuda.irp.f
Normal file
@ -0,0 +1,194 @@
|
||||
! ---
|
||||
|
||||
program write_tc_int_cuda
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
implicit none
|
||||
|
||||
PROVIDE io_tc_integ
|
||||
|
||||
print*, 'io_tc_integ = ', io_tc_integ
|
||||
|
||||
if(io_tc_integ .ne. "Write") then
|
||||
print*, 'io_tc_integ != Write'
|
||||
print*, io_tc_integ
|
||||
stop
|
||||
endif
|
||||
|
||||
call do_work_on_gpu()
|
||||
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine do_work_on_gpu()
|
||||
|
||||
use cutc_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: k, ipoint
|
||||
|
||||
double precision, allocatable :: rn(:,:), aos_data1(:,:,:), aos_data2(:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
double precision, allocatable :: int_2e_ao(:,:,:,:)
|
||||
|
||||
double precision :: time0, time1
|
||||
double precision :: cuda_time0, cuda_time1
|
||||
|
||||
call wall_time(time0)
|
||||
print*, ' start calculation of TC-integrals'
|
||||
|
||||
allocate(rn(3,nucl_num))
|
||||
allocate(aos_data1(n_points_final_grid,ao_num,4))
|
||||
allocate(aos_data2(n_points_extra_final_grid,ao_num,4))
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,3))
|
||||
allocate(int_2e_ao(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
|
||||
do k = 1, nucl_num
|
||||
rn(1,k) = nucl_coord(k,1)
|
||||
rn(2,k) = nucl_coord(k,2)
|
||||
rn(3,k) = nucl_coord(k,3)
|
||||
enddo
|
||||
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
aos_data1(ipoint,k,1) = aos_in_r_array(k,ipoint)
|
||||
aos_data1(ipoint,k,2) = aos_grad_in_r_array(k,ipoint,1)
|
||||
aos_data1(ipoint,k,3) = aos_grad_in_r_array(k,ipoint,2)
|
||||
aos_data1(ipoint,k,4) = aos_grad_in_r_array(k,ipoint,3)
|
||||
enddo
|
||||
|
||||
do ipoint = 1, n_points_extra_final_grid
|
||||
aos_data2(ipoint,k,1) = aos_in_r_array_extra(k,ipoint)
|
||||
aos_data2(ipoint,k,2) = aos_grad_in_r_array_extra(k,ipoint,1)
|
||||
aos_data2(ipoint,k,3) = aos_grad_in_r_array_extra(k,ipoint,2)
|
||||
aos_data2(ipoint,k,4) = aos_grad_in_r_array_extra(k,ipoint,3)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! ---
|
||||
|
||||
integer :: nB
|
||||
integer :: sB
|
||||
|
||||
PROVIDE nxBlocks nyBlocks nzBlocks
|
||||
PROVIDE blockxSize blockySize blockzSize
|
||||
|
||||
sB = 32
|
||||
nB = (n_points_final_grid + sB - 1) / sB
|
||||
|
||||
call ezfio_set_tc_int_blockxSize(sB)
|
||||
call ezfio_set_tc_int_nxBlocks(nB)
|
||||
|
||||
|
||||
|
||||
call wall_time(cuda_time0)
|
||||
print*, ' start CUDA kernel'
|
||||
|
||||
call cutc_int(nxBlocks, nyBlocks, nzBlocks, blockxSize, blockySize, blockzSize, &
|
||||
n_points_final_grid, n_points_extra_final_grid, ao_num, nucl_num, jBH_size, &
|
||||
final_grid_points, final_weight_at_r_vector, &
|
||||
final_grid_points_extra, final_weight_at_r_vector_extra, &
|
||||
rn, aos_data1, aos_data2, jBH_c, jBH_m, jBH_n, jBH_o, &
|
||||
int2_grad1_u12_ao, int_2e_ao)
|
||||
|
||||
call wall_time(cuda_time1)
|
||||
print*, ' wall time for CUDA kernel (min) = ', (cuda_time1-cuda_time0) / 60.d0
|
||||
|
||||
deallocate(aos_data1, aos_data2)
|
||||
|
||||
! ---
|
||||
|
||||
integer :: i, j, l
|
||||
double precision :: t1, t2
|
||||
double precision :: tmp
|
||||
double precision, external :: get_ao_two_e_integral
|
||||
|
||||
call wall_time(t1)
|
||||
|
||||
PROVIDE ao_integrals_map
|
||||
tmp = get_ao_two_e_integral(1, 1, 1, 1, ao_integrals_map)
|
||||
|
||||
!$OMP PARALLEL DEFAULT(NONE) &
|
||||
!$OMP SHARED(ao_num, int_2e_ao, ao_integrals_map) &
|
||||
!$OMP PRIVATE(i, j, k, l)
|
||||
!$OMP DO COLLAPSE(3)
|
||||
do j = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
! < 1:i, 2:j | 1:k, 2:l >
|
||||
int_2e_ao(k,i,l,j) = int_2e_ao(k,i,l,j) + get_ao_two_e_integral(i, j, k, l, ao_integrals_map)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
call wall_time(t2)
|
||||
print*, ' wall time of Coulomb part of tc_int_2e_ao (min) ', (t2 - t1) / 60.d0
|
||||
|
||||
! ---
|
||||
|
||||
print*, ' Writing int2_grad1_u12_ao in ', trim(ezfio_filename) // '/work/int2_grad1_u12_ao'
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
deallocate(int2_grad1_u12_ao)
|
||||
|
||||
print*, ' Saving tc_int_2e_ao in ', trim(ezfio_filename) // '/work/ao_two_e_tc_tot'
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/ao_two_e_tc_tot', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
do k = 1, ao_num
|
||||
write(11) int_2e_ao(:,:,:,k)
|
||||
enddo
|
||||
close(11)
|
||||
deallocate(int_2e_ao)
|
||||
|
||||
! ----
|
||||
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' wall time for TC-integrals (min) = ', (time1-time0) / 60.d0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
56
plugins/local/tc_int/write_tc_int_gpu.irp.f
Normal file
56
plugins/local/tc_int/write_tc_int_gpu.irp.f
Normal file
@ -0,0 +1,56 @@
|
||||
! ---
|
||||
|
||||
program write_tc_int_gpu
|
||||
|
||||
implicit none
|
||||
|
||||
print *, ' j2e_type = ', j2e_type
|
||||
print *, ' j1e_type = ', j1e_type
|
||||
print *, ' env_type = ', env_type
|
||||
|
||||
my_grid_becke = .True.
|
||||
PROVIDE tc_grid1_a tc_grid1_r
|
||||
my_n_pt_r_grid = tc_grid1_r
|
||||
my_n_pt_a_grid = tc_grid1_a
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
my_extra_grid_becke = .True.
|
||||
PROVIDE tc_grid2_a tc_grid2_r
|
||||
my_n_pt_r_extra_grid = tc_grid2_r
|
||||
my_n_pt_a_extra_grid = tc_grid2_a
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
call write_int(6, my_n_pt_r_grid, 'radial external grid over')
|
||||
call write_int(6, my_n_pt_a_grid, 'angular external grid over')
|
||||
|
||||
call write_int(6, my_n_pt_r_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine main()
|
||||
|
||||
implicit none
|
||||
|
||||
PROVIDE io_tc_integ
|
||||
|
||||
print*, 'io_tc_integ = ', io_tc_integ
|
||||
|
||||
if(io_tc_integ .ne. "Write") then
|
||||
print*, 'io_tc_integ != Write'
|
||||
print*, io_tc_integ
|
||||
stop
|
||||
endif
|
||||
|
||||
call provide_int2_grad1_u12_ao_gpu()
|
||||
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
@ -28,7 +28,7 @@
|
||||
enddo
|
||||
enddo
|
||||
|
||||
if((three_body_h_tc .eq. .False.) .and. (.not. noL_standard)) then
|
||||
if((three_body_h_tc .eqv. .False.) .and. (.not. noL_standard)) then
|
||||
TC_HF_three_e_energy = 0.d0
|
||||
else
|
||||
TC_HF_three_e_energy = noL_0e
|
||||
|
@ -52,35 +52,39 @@ END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER[double precision, aos_grad_in_r_array, (ao_num,n_points_final_grid,3)]
|
||||
|
||||
BEGIN_DOC
|
||||
! aos_grad_in_r_array(i,j,k) = value of the kth component of the gradient of ith ao on the jth grid point
|
||||
!
|
||||
! k = 1 : x, k= 2, y, k 3, z
|
||||
END_DOC
|
||||
BEGIN_DOC
|
||||
!
|
||||
! aos_grad_in_r_array(i,j,k) = value of the kth component of the gradient of ith ao on the jth grid point
|
||||
!
|
||||
! k = 1 : x, k= 2, y, k 3, z
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i,j,m
|
||||
double precision :: aos_array(ao_num), r(3)
|
||||
double precision :: aos_grad_array(3,ao_num)
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,r,aos_array,aos_grad_array,j,m) &
|
||||
!$OMP SHARED(aos_grad_in_r_array,n_points_final_grid,ao_num,final_grid_points)
|
||||
do i = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,i)
|
||||
r(2) = final_grid_points(2,i)
|
||||
r(3) = final_grid_points(3,i)
|
||||
call give_all_aos_and_grad_at_r(r,aos_array,aos_grad_array)
|
||||
do m = 1, 3
|
||||
do j = 1, ao_num
|
||||
aos_grad_in_r_array(j,i,m) = aos_grad_array(m,j)
|
||||
enddo
|
||||
implicit none
|
||||
integer :: i, j, m
|
||||
double precision :: aos_array(ao_num), r(3)
|
||||
double precision :: aos_grad_array(3,ao_num)
|
||||
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,m,r,aos_array,aos_grad_array) &
|
||||
!$OMP SHARED(aos_grad_in_r_array,n_points_final_grid,ao_num,final_grid_points)
|
||||
do i = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,i)
|
||||
r(2) = final_grid_points(2,i)
|
||||
r(3) = final_grid_points(3,i)
|
||||
call give_all_aos_and_grad_at_r(r,aos_array,aos_grad_array)
|
||||
do m = 1, 3
|
||||
do j = 1, ao_num
|
||||
aos_grad_in_r_array(j,i,m) = aos_grad_array(m,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
END_PROVIDER
|
||||
! ---
|
||||
|
||||
|
||||
BEGIN_PROVIDER[double precision, aos_grad_in_r_array_transp, (3,ao_num,n_points_final_grid)]
|
||||
@ -205,18 +209,53 @@ BEGIN_PROVIDER[double precision, aos_grad_in_r_array, (ao_num,n_points_final_gri
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
BEGIN_PROVIDER[double precision, aos_in_r_array_extra_transp, (n_points_extra_final_grid,ao_num)]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! aos_in_r_array_extra_transp(i,j) = value of the jth ao on the ith grid point
|
||||
END_DOC
|
||||
integer :: i,j
|
||||
double precision :: aos_array(ao_num), r(3)
|
||||
do i = 1, n_points_extra_final_grid
|
||||
do j = 1, ao_num
|
||||
aos_in_r_array_extra_transp(i,j) = aos_in_r_array_extra(j,i)
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, aos_in_r_array_extra_transp, (n_points_extra_final_grid,ao_num)]
|
||||
|
||||
BEGIN_DOC
|
||||
! aos_in_r_array_extra_transp(i,j) = value of the jth ao on the ith grid point
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
double precision :: aos_array(ao_num), r(3)
|
||||
|
||||
do i = 1, n_points_extra_final_grid
|
||||
do j = 1, ao_num
|
||||
aos_in_r_array_extra_transp(i,j) = aos_in_r_array_extra(j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER[double precision, aos_grad_in_r_array_extra, (ao_num,n_points_extra_final_grid,3)]
|
||||
|
||||
implicit none
|
||||
integer :: i, j, m
|
||||
double precision :: aos_array(ao_num), r(3)
|
||||
double precision :: aos_grad_array(3,ao_num)
|
||||
|
||||
!$OMP PARALLEL DO &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,m,r,aos_array,aos_grad_array) &
|
||||
!$OMP SHARED(aos_grad_in_r_array_extra,n_points_extra_final_grid,ao_num,final_grid_points_extra)
|
||||
do i = 1, n_points_extra_final_grid
|
||||
r(1) = final_grid_points_extra(1,i)
|
||||
r(2) = final_grid_points_extra(2,i)
|
||||
r(3) = final_grid_points_extra(3,i)
|
||||
call give_all_aos_and_grad_at_r(r, aos_array, aos_grad_array)
|
||||
do m = 1, 3
|
||||
do j = 1, ao_num
|
||||
aos_grad_in_r_array_extra(j,i,m) = aos_grad_array(m,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user