mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-22 11:33:29 +01:00
1st commit
This commit is contained in:
parent
0c9245d1b3
commit
646607ada4
5
plugins/local/tc_int/NEED
Normal file
5
plugins/local/tc_int/NEED
Normal file
@ -0,0 +1,5 @@
|
||||
tc_keywords
|
||||
jastrow
|
||||
qmckl
|
||||
becke_numerical_grid
|
||||
dft_utils_in_r
|
4
plugins/local/tc_int/README.rst
Normal file
4
plugins/local/tc_int/README.rst
Normal file
@ -0,0 +1,4 @@
|
||||
======
|
||||
tc_int
|
||||
======
|
||||
|
134
plugins/local/tc_int/int2_grad1_u12.irp.f
Normal file
134
plugins/local/tc_int/int2_grad1_u12.irp.f
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine provide_int2_grad1_u12_ao()
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j, m, jpoint
|
||||
integer :: n_blocks, n_rest, n_pass
|
||||
integer :: i_blocks, i_rest, i_pass, ii
|
||||
double precision :: time0, time1
|
||||
double precision :: mem, n_double
|
||||
double precision, allocatable :: tmp(:,:,:)
|
||||
double precision, allocatable :: tmp_grad1_u12(:,:,:)
|
||||
double precision, allocatable :: int2_grad1_u12_ao(:,:,:,:)
|
||||
|
||||
PROVIDE final_weight_at_r_vector_extra aos_in_r_array_extra
|
||||
|
||||
print*, ' start provide_int2_grad1_u12_ao ...'
|
||||
call wall_time(time0)
|
||||
|
||||
|
||||
! 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) = -(1/2) \int dr2 [\grad1 u(r1,r2)]^2 \chi_i(r2) \chi_j(r2)
|
||||
allocate(int2_grad1_u12_ao(ao_num,ao_num,n_points_final_grid,4))
|
||||
|
||||
|
||||
|
||||
call total_memory(mem)
|
||||
mem = max(1.d0, qp_max_mem - mem)
|
||||
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')
|
||||
|
||||
|
||||
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(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
|
||||
|
||||
|
||||
allocate(tmp_grad1_u12(n_points_extra_final_grid,n_blocks,4))
|
||||
|
||||
do i_pass = 1, n_pass
|
||||
ii = (i_pass-1)*n_blocks + 1
|
||||
|
||||
!$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(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
|
||||
|
||||
do m = 1, 4
|
||||
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
|
||||
|
||||
deallocate(tmp_grad1_u12)
|
||||
|
||||
|
||||
if(n_rest .gt. 0) then
|
||||
|
||||
allocate(tmp_grad1_u12(n_points_extra_final_grid,n_rest,4))
|
||||
|
||||
ii = n_pass*n_blocks + 1
|
||||
|
||||
!$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(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
|
||||
|
||||
do m = 1, 4
|
||||
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
|
||||
|
||||
deallocate(tmp_grad1_u12)
|
||||
endif
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
|
||||
! ---
|
||||
|
||||
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(:,:,:,1:3)
|
||||
close(11)
|
||||
|
||||
deallocate(int2_grad1_u12_ao)
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' wall time for provide_int2_grad1_u12_ao (min) = ', (time1-time0) / 60.d0
|
||||
call print_memory_usage()
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
102
plugins/local/tc_int/jast_grad_2e.irp.f
Normal file
102
plugins/local/tc_int/jast_grad_2e.irp.f
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine get_grad1_u12_r1_2e(r1, n_grid2, gradx, grady, gradz)
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! d/dx1 j_2e(1,2)
|
||||
! d/dy1 j_2e(1,2)
|
||||
! d/dz1 j_2e(1,2)
|
||||
!
|
||||
END_DOC
|
||||
|
||||
include 'constants.include.F'
|
||||
|
||||
implicit none
|
||||
integer , intent(in) :: n_grid2
|
||||
double precision, intent(in) :: r1(3)
|
||||
double precision, intent(out) :: gradx(n_grid2)
|
||||
double precision, intent(out) :: grady(n_grid2)
|
||||
double precision, intent(out) :: gradz(n_grid2)
|
||||
|
||||
integer :: jpoint
|
||||
integer :: i_nucl, p, mpA, npA, opA
|
||||
integer :: powmax1, powmax, powmax2
|
||||
double precision :: r2(3)
|
||||
double precision :: tmp, tmp1, tmp2
|
||||
double precision :: rn(3), f1A, grad1_f1A(3), f2A, grad2_f2A(3), g12, grad1_g12(3)
|
||||
double precision, allocatable :: f1A_power(:), f2A_power(:), double_p(:), g12_power(:)
|
||||
|
||||
|
||||
powmax1 = max(maxval(jBH_m), maxval(jBH_n))
|
||||
powmax2 = maxval(jBH_o)
|
||||
powmax = max(powmax1, powmax2)
|
||||
|
||||
allocate(f1A_power(-1:powmax), f2A_power(-1:powmax), g12_power(-1:powmax), double_p(0:powmax))
|
||||
|
||||
do p = 0, powmax
|
||||
double_p(p) = dble(p)
|
||||
enddo
|
||||
|
||||
f1A_power(-1) = 0.d0
|
||||
f2A_power(-1) = 0.d0
|
||||
g12_power(-1) = 0.d0
|
||||
|
||||
f1A_power(0) = 1.d0
|
||||
f2A_power(0) = 1.d0
|
||||
g12_power(0) = 1.d0
|
||||
|
||||
do jpoint = 1, n_points_extra_final_grid ! r2
|
||||
|
||||
r2(1) = final_grid_points_extra(1,jpoint)
|
||||
r2(2) = final_grid_points_extra(2,jpoint)
|
||||
r2(3) = final_grid_points_extra(3,jpoint)
|
||||
|
||||
gradx(jpoint) = 0.d0
|
||||
grady(jpoint) = 0.d0
|
||||
gradz(jpoint) = 0.d0
|
||||
do i_nucl = 1, nucl_num
|
||||
|
||||
rn(1) = nucl_coord(i_nucl,1)
|
||||
rn(2) = nucl_coord(i_nucl,2)
|
||||
rn(3) = nucl_coord(i_nucl,3)
|
||||
|
||||
call jBH_elem_fct_grad(jBH_en(i_nucl), r1, rn, f1A, grad1_f1A)
|
||||
call jBH_elem_fct_grad(jBH_en(i_nucl), r2, rn, f2A, grad2_f2A)
|
||||
call jBH_elem_fct_grad(jBH_ee(i_nucl), r1, r2, g12, grad1_g12)
|
||||
|
||||
! 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
|
||||
do p = 1, powmax2
|
||||
g12_power(p) = g12_power(p-1) * g12
|
||||
enddo
|
||||
|
||||
do p = 1, jBH_size
|
||||
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(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
|
||||
tmp2 = double_p(opA) * g12_power(opA-1) * (f1A_power(mpA) * f2A_power(npA) + f1A_power(npA) * f2A_power(mpA)) * tmp
|
||||
|
||||
gradx(jpoint) = gradx(jpoint) + tmp1 * grad1_f1A(1) + tmp2 * grad1_g12(1)
|
||||
grady(jpoint) = grady(jpoint) + tmp1 * grad1_f1A(2) + tmp2 * grad1_g12(2)
|
||||
gradz(jpoint) = gradz(jpoint) + tmp1 * grad1_f1A(3) + tmp2 * grad1_g12(3)
|
||||
enddo ! p
|
||||
enddo ! i_nucl
|
||||
enddo ! jpoint
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
51
plugins/local/tc_int/jast_grad_full.irp.f
Normal file
51
plugins/local/tc_int/jast_grad_full.irp.f
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine get_grad1_u12_for_tc(ipoint, n_grid2, resx, resy, resz, res)
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! resx(ipoint) = [grad1 u(r1,r2)]_x1
|
||||
! resy(ipoint) = [grad1 u(r1,r2)]_y1
|
||||
! resz(ipoint) = [grad1 u(r1,r2)]_z1
|
||||
! res (ipoint) = -0.5 [grad1 u(r1,r2)]^2
|
||||
!
|
||||
! We use:
|
||||
! grid for r1
|
||||
! extra_grid for r2
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer, intent(in) :: ipoint, n_grid2
|
||||
double precision, intent(out) :: resx(n_grid2), resy(n_grid2), resz(n_grid2), res(n_grid2)
|
||||
|
||||
integer :: jpoint
|
||||
double precision :: env_r1, tmp
|
||||
double precision :: grad1_env(3), r1(3)
|
||||
double precision, allocatable :: env_r2(:)
|
||||
double precision, allocatable :: u2b_r12(:), gradx1_u2b(:), grady1_u2b(:), gradz1_u2b(:)
|
||||
double precision, allocatable :: u2b_mu(:), gradx1_mu(:), grady1_mu(:), gradz1_mu(:)
|
||||
double precision, allocatable :: u2b_nu(:), gradx1_nu(:), grady1_nu(:), gradz1_nu(:)
|
||||
double precision, external :: env_nucl
|
||||
|
||||
r1(1) = final_grid_points(1,ipoint)
|
||||
r1(2) = final_grid_points(2,ipoint)
|
||||
r1(3) = final_grid_points(3,ipoint)
|
||||
|
||||
|
||||
! j2e_type .eq. "Boys_Handy"
|
||||
! env_type .eq. "None"
|
||||
! j1e_type .eq "None"
|
||||
|
||||
call get_grad1_u12_r1_2e(r1, n_grid2, resx(1), resy(1), resz(1))
|
||||
|
||||
do jpoint = 1, n_points_extra_final_grid
|
||||
res(jpoint) = -0.5d0 * (resx(jpoint) * resx(jpoint) + resy(jpoint) * resy(jpoint) + resz(jpoint) * resz(jpoint))
|
||||
enddo
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
! ---
|
||||
|
35
plugins/local/tc_int/jast_utils_bh.irp.f
Normal file
35
plugins/local/tc_int/jast_utils_bh.irp.f
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
! ---
|
||||
|
||||
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 = dsqrt( (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-10) then
|
||||
tmp1 = 1.d0 / (1.d0 + alpha * dist)
|
||||
|
||||
fct = alpha * dist * tmp1
|
||||
tmp2 = alpha * 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
|
||||
|
||||
! ---
|
||||
|
58
plugins/local/tc_int/write_tc_int.irp.f
Normal file
58
plugins/local/tc_int/write_tc_int.irp.f
Normal file
@ -0,0 +1,58 @@
|
||||
! ---
|
||||
|
||||
program write_tc_int
|
||||
|
||||
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
|
||||
|
||||
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')
|
||||
|
||||
if(tc_integ_type .eq. "numeric") then
|
||||
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_extra_grid, 'radial internal grid over')
|
||||
call write_int(6, my_n_pt_a_extra_grid, 'angular internal grid over')
|
||||
endif
|
||||
|
||||
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()
|
||||
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
Loading…
Reference in New Issue
Block a user