10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-09 07:33:49 +01:00
QuantumPackage/src/non_h_ints_mu/new_grad_tc_manu.irp.f

200 lines
7.1 KiB
Fortran
Raw Normal View History

2023-02-06 19:00:35 +01:00
BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_test, (ao_num, ao_num, n_points_final_grid, 3)]
BEGIN_DOC
!
2023-03-17 19:23:07 +01:00
! int2_grad1_u12_ao_test(i,j,ipoint,:) = \int dr2 [-1 * \grad_r1 J(r1,r2)] \phi_i(r2) \phi_j(r2)
2023-02-06 19:00:35 +01:00
!
! where r1 = r(ipoint)
!
! if J(r1,r2) = u12:
!
! int2_grad1_u12_ao_test(i,j,ipoint,:) = 0.5 x \int dr2 [(r1 - r2) (erf(mu * r12)-1)r_12] \phi_i(r2) \phi_j(r2)
! = 0.5 * [ v_ij_erf_rk_cst_mu(i,j,ipoint) * r(:) - x_v_ij_erf_rk_cst_mu(i,j,ipoint,:) ]
!
! if J(r1,r2) = u12 x v1 x v2
!
! int2_grad1_u12_ao_test(i,j,ipoint,:) = v1 x [ 0.5 x \int dr2 [(r1 - r2) (erf(mu * r12)-1)r_12] v2 \phi_i(r2) \phi_j(r2) ]
2023-03-17 19:23:07 +01:00
! - \grad_1 v1 x [ \int dr2 u12 v2 \phi_i(r2) \phi_j(r2) ]
! = 0.5 v_1b(ipoint) * v_ij_erf_rk_cst_mu_j1b(i,j,ipoint) * r(:)
! - 0.5 v_1b(ipoint) * x_v_ij_erf_rk_cst_mu_j1b(i,j,ipoint,:)
2023-02-06 19:00:35 +01:00
! - v_1b_grad[:,ipoint] * v_ij_u_cst_mu_j1b(i,j,ipoint)
!
!
END_DOC
implicit none
2023-03-04 02:19:15 +01:00
integer :: ipoint, i, j, m
2023-02-06 19:00:35 +01:00
double precision :: time0, time1
double precision :: x, y, z, tmp_x, tmp_y, tmp_z, tmp0, tmp1, tmp2
print*, ' providing int2_grad1_u12_ao_test ...'
call wall_time(time0)
PROVIDE j1b_type
2023-03-04 02:19:15 +01:00
if(read_tc_integ) then
2023-02-06 19:00:35 +01:00
2023-03-17 19:23:07 +01:00
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao_test', action="read")
read(11) int2_grad1_u12_ao_test
2023-03-04 02:19:15 +01:00
close(11)
2023-02-06 19:00:35 +01:00
else
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
if(j1b_type .eq. 3) then
do ipoint = 1, n_points_final_grid
x = final_grid_points(1,ipoint)
y = final_grid_points(2,ipoint)
2023-03-17 19:23:07 +01:00
z = final_grid_points(3,ipoint)
2023-03-04 02:19:15 +01:00
tmp0 = 0.5d0 * v_1b(ipoint)
tmp_x = v_1b_grad(1,ipoint)
tmp_y = v_1b_grad(2,ipoint)
tmp_z = v_1b_grad(3,ipoint)
do j = 1, ao_num
do i = 1, ao_num
tmp1 = tmp0 * v_ij_erf_rk_cst_mu_j1b_test(i,j,ipoint)
tmp2 = v_ij_u_cst_mu_j1b_test(i,j,ipoint)
int2_grad1_u12_ao_test(i,j,ipoint,1) = tmp1 * x - tmp0 * x_v_ij_erf_rk_cst_mu_j1b_test(i,j,ipoint,1) - tmp2 * tmp_x
int2_grad1_u12_ao_test(i,j,ipoint,2) = tmp1 * y - tmp0 * x_v_ij_erf_rk_cst_mu_j1b_test(i,j,ipoint,2) - tmp2 * tmp_y
int2_grad1_u12_ao_test(i,j,ipoint,3) = tmp1 * z - tmp0 * x_v_ij_erf_rk_cst_mu_j1b_test(i,j,ipoint,3) - tmp2 * tmp_z
enddo
2023-02-06 19:00:35 +01:00
enddo
enddo
2023-03-04 02:19:15 +01:00
else
do ipoint = 1, n_points_final_grid
x = final_grid_points(1,ipoint)
y = final_grid_points(2,ipoint)
z = final_grid_points(3,ipoint)
do j = 1, ao_num
do i = 1, ao_num
tmp1 = v_ij_erf_rk_cst_mu(i,j,ipoint)
int2_grad1_u12_ao_test(i,j,ipoint,1) = tmp1 * x - x_v_ij_erf_rk_cst_mu_tmp(i,j,ipoint,1)
int2_grad1_u12_ao_test(i,j,ipoint,2) = tmp1 * y - x_v_ij_erf_rk_cst_mu_tmp(i,j,ipoint,2)
int2_grad1_u12_ao_test(i,j,ipoint,3) = tmp1 * z - x_v_ij_erf_rk_cst_mu_tmp(i,j,ipoint,3)
enddo
enddo
enddo
int2_grad1_u12_ao_test *= 0.5d0
endif
2023-02-06 19:00:35 +01:00
2023-03-04 02:19:15 +01:00
endif
2023-02-06 19:00:35 +01:00
2023-03-17 19:23:07 +01:00
if(write_tc_integ.and.mpi_master) then
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao_test', action="write")
call ezfio_set_work_empty(.False.)
write(11) int2_grad1_u12_ao_test
2023-03-04 02:19:15 +01:00
close(11)
2023-03-17 19:23:07 +01:00
call ezfio_set_tc_keywords_io_tc_integ('Read')
2023-02-06 19:00:35 +01:00
endif
call wall_time(time1)
print*, ' Wall time for int2_grad1_u12_ao_test = ', time1 - time0
2023-03-17 19:23:07 +01:00
END_PROVIDER
2023-02-06 19:00:35 +01:00
! ---
BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao_test, (ao_num, ao_num, ao_num, ao_num)]
BEGIN_DOC
!
! tc_grad_and_lapl_ao_test(k,i,l,j) = < k l | -1/2 \Delta_1 u(r1,r2) - \grad_1 u(r1,r2) | ij >
!
2023-03-17 19:23:07 +01:00
! = 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)
2023-02-06 19:00:35 +01:00
!
2023-03-17 19:23:07 +01:00
! This is obtained by integration by parts.
2023-02-06 19:00:35 +01:00
!
END_DOC
implicit none
integer :: ipoint, i, j, k, l, m
double precision :: weight1, contrib_x, contrib_y, contrib_z, tmp_x, tmp_y, tmp_z
double precision :: ao_k_r, ao_i_r, ao_i_dx, ao_i_dy, ao_i_dz
double precision :: time0, time1
double precision, allocatable :: ac_mat(:,:,:,:), b_mat(:,:,:,:)
print*, ' providing tc_grad_and_lapl_ao_test ...'
call wall_time(time0)
2023-03-04 02:19:15 +01:00
if(read_tc_integ) then
2023-03-17 19:23:07 +01:00
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_and_lapl_ao_test', action="read")
read(11) tc_grad_and_lapl_ao_test
2023-03-04 02:19:15 +01:00
close(11)
2023-02-06 19:00:35 +01:00
2023-03-04 02:19:15 +01:00
else
2023-02-06 19:00:35 +01:00
2023-03-17 19:23:07 +01:00
provide int2_grad1_u12_ao_test
2023-03-04 02:19:15 +01:00
allocate(b_mat(n_points_final_grid,ao_num,ao_num,3), ac_mat(ao_num,ao_num,ao_num,ao_num))
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
b_mat = 0.d0
!$OMP PARALLEL &
!$OMP DEFAULT (NONE) &
2023-03-17 19:23:07 +01:00
!$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, b_mat, &
2023-03-04 02:19:15 +01:00
!$OMP 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
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
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)
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
b_mat(ipoint,k,i,1) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,1) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,1))
b_mat(ipoint,k,i,2) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,2) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,2))
b_mat(ipoint,k,i,3) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,3) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,3))
enddo
2023-02-06 19:00:35 +01:00
enddo
enddo
2023-03-04 02:19:15 +01:00
!$OMP END DO
!$OMP END PARALLEL
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
ac_mat = 0.d0
do m = 1, 3
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
, int2_grad1_u12_ao_test(1,1,1,m), ao_num*ao_num, b_mat(1,1,1,m), n_points_final_grid &
, 1.d0, ac_mat, ao_num*ao_num)
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
enddo
deallocate(b_mat)
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
!$OMP PARALLEL &
!$OMP DEFAULT (NONE) &
2023-03-17 19:23:07 +01:00
!$OMP PRIVATE (i, j, k, l) &
2023-03-04 02:19:15 +01:00
!$OMP SHARED (ac_mat, tc_grad_and_lapl_ao_test, ao_num)
!$OMP DO SCHEDULE (static)
do j = 1, ao_num
do l = 1, ao_num
do i = 1, ao_num
do k = 1, ao_num
tc_grad_and_lapl_ao_test(k,i,l,j) = ac_mat(k,i,l,j) + ac_mat(l,j,k,i)
enddo
2023-02-06 19:00:35 +01:00
enddo
enddo
enddo
2023-03-04 02:19:15 +01:00
!$OMP END DO
!$OMP END PARALLEL
2023-03-17 19:23:07 +01:00
2023-03-04 02:19:15 +01:00
deallocate(ac_mat)
endif
2023-02-06 19:00:35 +01:00
2023-03-17 19:23:07 +01:00
if(write_tc_integ.and.mpi_master) then
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_and_lapl_ao_test', action="write")
call ezfio_set_work_empty(.False.)
write(11) tc_grad_and_lapl_ao_test
2023-03-04 02:19:15 +01:00
close(11)
2023-03-17 19:23:07 +01:00
call ezfio_set_tc_keywords_io_tc_integ('Read')
2023-03-04 02:19:15 +01:00
endif
2023-02-06 19:00:35 +01:00
call wall_time(time1)
print*, ' Wall time for tc_grad_and_lapl_ao_test = ', time1 - time0
2023-03-17 19:23:07 +01:00
END_PROVIDER
2023-02-06 19:00:35 +01:00
! ---