9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 11:33:29 +01:00
qp2/plugins/local/bi_ort_ints/three_body_ijmkl.irp.f

246 lines
9.4 KiB
Fortran
Raw Normal View History

2023-02-07 13:27:19 +01:00
! ---
2023-06-02 20:32:31 +02:00
double precision function three_e_5_idx_exch12_bi_ort(m,l,i,k,j) result(integral)
implicit none
integer, intent(in) :: m,l,j,k,i
integral = three_e_5_idx_direct_bi_ort(m,l,j,k,i)
end
2023-02-07 13:27:19 +01:00
2023-06-02 11:08:30 +02:00
BEGIN_PROVIDER [ double precision, three_e_5_idx_direct_bi_ort , (mo_num, mo_num, mo_num, mo_num, mo_num)]
&BEGIN_PROVIDER [ double precision, three_e_5_idx_exch23_bi_ort , (mo_num, mo_num, mo_num, mo_num, mo_num)]
&BEGIN_PROVIDER [ double precision, three_e_5_idx_exch13_bi_ort , (mo_num, mo_num, mo_num, mo_num, mo_num)]
&BEGIN_PROVIDER [ double precision, three_e_5_idx_cycle_1_bi_ort, (mo_num, mo_num, mo_num, mo_num, mo_num)]
&BEGIN_PROVIDER [ double precision, three_e_5_idx_cycle_2_bi_ort, (mo_num, mo_num, mo_num, mo_num, mo_num)]
2023-02-07 13:27:19 +01:00
BEGIN_DOC
!
! matrix element of the -L three-body operator FOR THE DIRECT TERMS OF DOUBLE EXCITATIONS AND BI ORTHO MOs
!
2023-06-04 16:45:38 +02:00
! three_e_5_idx_direct_bi_ort(m,l,j,k,i) = <mlk|-L|mji> :: : notice that i is the RIGHT MO and k is the LEFT MO
2023-02-07 13:27:19 +01:00
!
! notice the -1 sign: in this way three_e_3_idx_direct_bi_ort can be directly used to compute Slater rules with a + sign
2023-06-02 20:32:31 +02:00
!
2023-02-07 13:27:19 +01:00
END_DOC
implicit none
2023-06-03 22:12:30 +02:00
2023-06-04 16:45:38 +02:00
integer :: i, j, k, m, l
double precision :: wall1, wall0
integer :: ipoint
double precision, allocatable :: grad_mli(:,:), orb_mat(:,:,:)
double precision, allocatable :: lk_grad_mi(:,:,:,:), rk_grad_im(:,:,:)
double precision, allocatable :: lm_grad_ik(:,:,:,:), rm_grad_ik(:,:,:)
double precision, allocatable :: tmp_mat(:,:,:)
2023-06-02 09:11:32 +02:00
provide mos_r_in_r_array_transp mos_l_in_r_array_transp
PROVIDE mo_l_coef mo_r_coef int2_grad1_u12_bimo_t
2023-02-07 13:27:19 +01:00
2023-06-04 16:45:38 +02:00
call print_memory_usage
2023-06-02 11:08:30 +02:00
print *, ' Providing the three_e_5_idx_bi_ort ...'
2023-02-07 13:27:19 +01:00
call wall_time(wall0)
2023-06-04 16:45:38 +02:00
three_e_5_idx_direct_bi_ort (:,:,:,:,:) = 0.d0
three_e_5_idx_cycle_1_bi_ort(:,:,:,:,:) = 0.d0
three_e_5_idx_cycle_2_bi_ort(:,:,:,:,:) = 0.d0
three_e_5_idx_exch23_bi_ort (:,:,:,:,:) = 0.d0
three_e_5_idx_exch13_bi_ort (:,:,:,:,:) = 0.d0
2023-02-07 13:27:19 +01:00
2023-06-04 16:45:38 +02:00
call print_memory_usage
allocate(tmp_mat(mo_num,mo_num,mo_num))
2023-06-02 11:40:21 +02:00
allocate(orb_mat(n_points_final_grid,mo_num,mo_num))
2023-06-04 16:45:38 +02:00
!$OMP PARALLEL DO PRIVATE (i,l,ipoint)
2023-06-02 09:11:32 +02:00
do i=1,mo_num
do l=1,mo_num
2023-06-04 16:45:38 +02:00
do ipoint=1, n_points_final_grid
2023-06-02 09:11:32 +02:00
2023-06-04 16:45:38 +02:00
orb_mat(ipoint,l,i) = final_weight_at_r_vector(ipoint) &
* mos_l_in_r_array_transp(ipoint,l) &
* mos_r_in_r_array_transp(ipoint,i)
2023-06-03 22:12:30 +02:00
enddo
enddo
2023-02-07 13:27:19 +01:00
enddo
2023-06-02 09:11:32 +02:00
!$OMP END PARALLEL DO
2023-06-04 16:45:38 +02:00
tmp_mat = 0.d0
call print_memory_usage
2023-02-07 13:27:19 +01:00
2023-06-04 16:45:38 +02:00
do m = 1, mo_num
2023-06-02 11:40:21 +02:00
2023-06-04 16:45:38 +02:00
allocate(grad_mli(n_points_final_grid,mo_num))
2023-06-03 22:12:30 +02:00
2023-06-04 16:45:38 +02:00
do i=1,mo_num
!$OMP PARALLEL DO PRIVATE (l,ipoint)
do l=1,mo_num
do ipoint=1, n_points_final_grid
2023-06-03 22:12:30 +02:00
2023-06-04 16:45:38 +02:00
grad_mli(ipoint,l) = &
int2_grad1_u12_bimo_t(ipoint,1,m,m) * int2_grad1_u12_bimo_t(ipoint,1,l,i) +&
int2_grad1_u12_bimo_t(ipoint,2,m,m) * int2_grad1_u12_bimo_t(ipoint,2,l,i) +&
int2_grad1_u12_bimo_t(ipoint,3,m,m) * int2_grad1_u12_bimo_t(ipoint,3,l,i)
2023-06-02 11:40:21 +02:00
2023-06-02 09:11:32 +02:00
enddo
enddo
2023-06-04 16:45:38 +02:00
!$OMP END PARALLEL DO
call dgemm('T','N', mo_num*mo_num, mo_num, n_points_final_grid, 1.d0,&
orb_mat, n_points_final_grid, &
grad_mli, n_points_final_grid, 0.d0, &
tmp_mat, mo_num*mo_num)
!$OMP PARALLEL PRIVATE(j,k,l)
!$OMP DO
2023-06-03 22:12:30 +02:00
do k = 1, mo_num
do j = 1, mo_num
do l = 1, mo_num
2023-06-04 16:45:38 +02:00
three_e_5_idx_direct_bi_ort(m,l,j,k,i) = three_e_5_idx_direct_bi_ort(m,l,j,k,i) - tmp_mat(l,j,k)
enddo
enddo
enddo
!$OMP END DO
!$OMP DO
2023-02-07 13:27:19 +01:00
do j = 1, mo_num
2023-06-02 10:34:05 +02:00
do l = 1, mo_num
2023-06-04 16:45:38 +02:00
do k = 1, mo_num
three_e_5_idx_direct_bi_ort(m,k,i,l,j) = three_e_5_idx_direct_bi_ort(m,k,i,l,j) - tmp_mat(l,j,k)
2023-06-03 22:12:30 +02:00
enddo
2023-02-07 13:27:19 +01:00
enddo
enddo
2023-06-04 16:45:38 +02:00
!$OMP END DO
!$OMP END PARALLEL
2023-02-07 13:27:19 +01:00
enddo
2023-06-03 22:12:30 +02:00
2023-06-04 16:45:38 +02:00
deallocate(grad_mli)
2023-06-03 22:12:30 +02:00
allocate(lm_grad_ik(n_points_final_grid,3,mo_num,mo_num))
2023-06-04 16:45:38 +02:00
allocate(lk_grad_mi(n_points_final_grid,3,mo_num,mo_num))
2023-06-02 11:40:21 +02:00
2023-06-04 16:45:38 +02:00
!$OMP PARALLEL DO PRIVATE (i,l,ipoint)
2023-06-03 22:12:30 +02:00
do i=1,mo_num
do l=1,mo_num
do ipoint=1, n_points_final_grid
lm_grad_ik(ipoint,1,l,i) = mos_l_in_r_array_transp(ipoint,m) * int2_grad1_u12_bimo_t(ipoint,1,l,i) * final_weight_at_r_vector(ipoint)
lm_grad_ik(ipoint,2,l,i) = mos_l_in_r_array_transp(ipoint,m) * int2_grad1_u12_bimo_t(ipoint,2,l,i) * final_weight_at_r_vector(ipoint)
lm_grad_ik(ipoint,3,l,i) = mos_l_in_r_array_transp(ipoint,m) * int2_grad1_u12_bimo_t(ipoint,3,l,i) * final_weight_at_r_vector(ipoint)
2023-06-04 16:45:38 +02:00
lk_grad_mi(ipoint,1,l,i) = mos_l_in_r_array_transp(ipoint,l) * int2_grad1_u12_bimo_t(ipoint,1,m,i) * final_weight_at_r_vector(ipoint)
lk_grad_mi(ipoint,2,l,i) = mos_l_in_r_array_transp(ipoint,l) * int2_grad1_u12_bimo_t(ipoint,2,m,i) * final_weight_at_r_vector(ipoint)
lk_grad_mi(ipoint,3,l,i) = mos_l_in_r_array_transp(ipoint,l) * int2_grad1_u12_bimo_t(ipoint,3,m,i) * final_weight_at_r_vector(ipoint)
2023-06-03 22:12:30 +02:00
enddo
enddo
2023-06-02 11:40:21 +02:00
enddo
2023-06-04 16:45:38 +02:00
!$OMP END PARALLEL DO
2023-06-02 00:33:37 +02:00
2023-06-04 16:45:38 +02:00
allocate(rm_grad_ik(n_points_final_grid,3,mo_num))
allocate(rk_grad_im(n_points_final_grid,3,mo_num))
do i=1,mo_num
!$OMP PARALLEL DO PRIVATE (l,ipoint)
do l=1,mo_num
do ipoint=1, n_points_final_grid
rm_grad_ik(ipoint,1,l) = mos_r_in_r_array_transp(ipoint,m) * int2_grad1_u12_bimo_t(ipoint,1,l,i)
rm_grad_ik(ipoint,2,l) = mos_r_in_r_array_transp(ipoint,m) * int2_grad1_u12_bimo_t(ipoint,2,l,i)
rm_grad_ik(ipoint,3,l) = mos_r_in_r_array_transp(ipoint,m) * int2_grad1_u12_bimo_t(ipoint,3,l,i)
rk_grad_im(ipoint,1,l) = mos_r_in_r_array_transp(ipoint,l) * int2_grad1_u12_bimo_t(ipoint,1,i,m)
rk_grad_im(ipoint,2,l) = mos_r_in_r_array_transp(ipoint,l) * int2_grad1_u12_bimo_t(ipoint,2,i,m)
rk_grad_im(ipoint,3,l) = mos_r_in_r_array_transp(ipoint,l) * int2_grad1_u12_bimo_t(ipoint,3,i,m)
enddo
enddo
!$OMP END PARALLEL DO
call dgemm('T','N', mo_num*mo_num, mo_num, 3*n_points_final_grid, 1.d0,&
lm_grad_ik, 3*n_points_final_grid, &
rm_grad_ik, 3*n_points_final_grid, 0.d0, &
tmp_mat, mo_num*mo_num)
!$OMP PARALLEL DO PRIVATE(j,k,l)
2023-06-03 22:12:30 +02:00
do k = 1, mo_num
do j = 1, mo_num
do l = 1, mo_num
2023-06-04 16:45:38 +02:00
three_e_5_idx_direct_bi_ort(m,l,j,k,i) = three_e_5_idx_direct_bi_ort(m,l,j,k,i) - tmp_mat(l,j,k)
2023-06-03 22:12:30 +02:00
enddo
2023-06-02 09:11:32 +02:00
enddo
enddo
2023-06-04 16:45:38 +02:00
!$OMP END PARALLEL DO
call dgemm('T','N', mo_num*mo_num, mo_num, 3*n_points_final_grid, 1.d0,&
lm_grad_ik, 3*n_points_final_grid, &
rk_grad_im, 3*n_points_final_grid, 0.d0, &
tmp_mat, mo_num*mo_num)
!$OMP PARALLEL DO PRIVATE(j,k,l)
2023-06-03 22:12:30 +02:00
do k = 1, mo_num
do j = 1, mo_num
do l = 1, mo_num
2023-06-04 16:45:38 +02:00
three_e_5_idx_cycle_1_bi_ort(m,l,j,i,k) = three_e_5_idx_cycle_1_bi_ort(m,l,j,i,k) - tmp_mat(l,k,j)
three_e_5_idx_cycle_2_bi_ort(m,i,j,k,l) = three_e_5_idx_cycle_2_bi_ort(m,i,j,k,l) - tmp_mat(k,j,l)
three_e_5_idx_exch23_bi_ort (m,i,j,k,l) = three_e_5_idx_exch23_bi_ort (m,i,j,k,l) - tmp_mat(k,l,j)
three_e_5_idx_exch13_bi_ort (m,l,j,i,k) = three_e_5_idx_exch13_bi_ort (m,l,j,i,k) - tmp_mat(l,j,k)
2023-06-03 22:12:30 +02:00
enddo
2023-02-07 13:27:19 +01:00
enddo
enddo
2023-06-04 16:45:38 +02:00
!$OMP END PARALLEL DO
call dgemm('T','N', mo_num*mo_num, mo_num, 3*n_points_final_grid, 1.d0,&
lk_grad_mi, 3*n_points_final_grid, &
rm_grad_ik, 3*n_points_final_grid, 0.d0, &
tmp_mat, mo_num*mo_num)
!$OMP PARALLEL DO PRIVATE(j,k,l)
2023-06-03 22:12:30 +02:00
do k = 1, mo_num
do j = 1, mo_num
do l = 1, mo_num
2023-06-04 16:45:38 +02:00
three_e_5_idx_cycle_1_bi_ort(m,l,j,k,i) = three_e_5_idx_cycle_1_bi_ort(m,l,j,k,i) - tmp_mat(k,j,l)
three_e_5_idx_cycle_2_bi_ort(m,l,i,k,j) = three_e_5_idx_cycle_2_bi_ort(m,l,i,k,j) - tmp_mat(l,j,k)
three_e_5_idx_exch23_bi_ort (m,l,j,k,i) = three_e_5_idx_exch23_bi_ort (m,l,j,k,i) - tmp_mat(l,j,k)
three_e_5_idx_exch13_bi_ort (m,l,i,k,j) = three_e_5_idx_exch13_bi_ort (m,l,i,k,j) - tmp_mat(k,j,l)
2023-06-03 22:12:30 +02:00
enddo
2023-02-07 13:27:19 +01:00
enddo
enddo
2023-06-04 16:45:38 +02:00
!$OMP END PARALLEL DO
call dgemm('T','N', mo_num*mo_num, mo_num, 3*n_points_final_grid, 1.d0,&
lk_grad_mi, 3*n_points_final_grid, &
rk_grad_im, 3*n_points_final_grid, 0.d0, &
tmp_mat, mo_num*mo_num)
!$OMP PARALLEL DO PRIVATE(j,k,l)
2023-06-03 22:12:30 +02:00
do k = 1, mo_num
do j = 1, mo_num
do l = 1, mo_num
2023-06-04 16:45:38 +02:00
three_e_5_idx_cycle_1_bi_ort(m,l,j,i,k) = three_e_5_idx_cycle_1_bi_ort(m,l,j,i,k) - tmp_mat(l,j,k)
three_e_5_idx_cycle_2_bi_ort(m,i,j,k,l) = three_e_5_idx_cycle_2_bi_ort(m,i,j,k,l) - tmp_mat(k,l,j)
three_e_5_idx_exch23_bi_ort (m,i,j,k,l) = three_e_5_idx_exch23_bi_ort (m,i,j,k,l) - tmp_mat(k,j,l)
three_e_5_idx_exch13_bi_ort (m,l,j,i,k) = three_e_5_idx_exch13_bi_ort (m,l,j,i,k) - tmp_mat(l,k,j)
2023-06-03 22:12:30 +02:00
enddo
2023-06-02 00:33:37 +02:00
enddo
enddo
2023-06-04 16:45:38 +02:00
!$OMP END PARALLEL DO
2023-06-02 00:33:37 +02:00
enddo
2023-06-03 22:12:30 +02:00
deallocate(rm_grad_ik)
deallocate(rk_grad_im)
2023-06-04 16:45:38 +02:00
deallocate(lk_grad_mi)
deallocate(lm_grad_ik)
2023-06-02 11:08:30 +02:00
2023-06-02 10:34:05 +02:00
enddo
2023-06-02 00:33:37 +02:00
2023-06-03 22:12:30 +02:00
deallocate(tmp_mat)
2023-02-07 13:27:19 +01:00
2023-06-04 16:45:38 +02:00
deallocate(orb_mat)
2023-02-07 13:27:19 +01:00
call wall_time(wall1)
2023-06-02 11:08:30 +02:00
print *, ' wall time for three_e_5_idx_bi_ort', wall1 - wall0
2023-06-02 20:16:39 +02:00
call print_memory_usage()
2023-02-07 13:27:19 +01:00
2023-06-02 00:33:37 +02:00
END_PROVIDER
2023-02-07 13:27:19 +01:00