1
0
mirror of https://github.com/TREX-CoE/irpjast.git synced 2024-12-22 12:23:57 +01:00

Jee derivatives full (To be tested)

This commit is contained in:
Panadestein 2020-12-14 13:40:47 +01:00
parent a1da70a829
commit c8dd05f555
10 changed files with 262 additions and 4299 deletions

View File

@ -1,8 +1,8 @@
IRPF90 = irpf90 --codelet=factor_een:100000 IRPF90 = irpf90 #-a -d
FC = gfortran FC = gfortran
FCFLAGS= -O2 -march=native -ffree-line-length-none -I . FCFLAGS= -O2 -ffree-line-length-none -I .
NINJA = ninja NINJA = ninja
ARCHIVE= ar crs AR = ar
RANLIB = ranlib RANLIB = ranlib
SRC= SRC=

29
codelet_factor_een.f Normal file
View File

@ -0,0 +1,29 @@
program codelet_factor_een
implicit none
integer :: i
double precision :: ticks_0, ticks_1, cpu_0, cpu_1
integer, parameter :: irp_imax = 100000
call provide_factor_een
double precision :: irp_rdtsc
call cpu_time(cpu_0)
ticks_0 = irp_rdtsc()
do i=1,irp_imax
call bld_factor_een
enddo
ticks_1 = irp_rdtsc()
call cpu_time(cpu_1)
print *, 'factor_een'
print *, '-----------'
print *, 'Cycles:'
print *, (ticks_1-ticks_0)/dble(irp_imax)
print *, 'Seconds:'
print *, (cpu_1-cpu_0)/dble(irp_imax)
end

View File

@ -1,120 +1,112 @@
BEGIN_PROVIDER [ double precision, factor_een ] BEGIN_PROVIDER [ double precision, factor_een ]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! ! ElectronE-electron-nuclei contribution to Jastrow factor
END_DOC END_DOC
integer :: i,j,a,p,k,l,lmax,m integer :: i, j, a, p, k, l, lmax, m
double precision :: riam, rjam_cn, rial, rjal, rijk double precision :: riam, rjam_cn, rial, rjal, rijk
double precision :: cn double precision :: cn
factor_een = 0.0d0 factor_een = 0.0d0
do p=2,ncord do p = 2, ncord
do k=0,p-1 do k = 0, p - 1
if (k /= 0) then if (k /= 0) then
lmax = p-k lmax = p - k
else else
lmax = p-k-2 lmax = p - k - 2
endif
do l=0,lmax
if ( iand(p-k-l,1) == 1) then
cycle
endif endif
m = (p-k-l)/2 do l = 0, lmax
if ( iand(p - k - l, 1) == 1) cycle
do a=1, nnuc m = (p - k - l) / 2
cn = cord_vect_lkp(l,k,p,typenuc_arr(a)) do a = 1, nnuc
do j=1, nelec cn = cord_vect_lkp(l, k, p, typenuc_arr(a))
rjal = rescale_een_n(j,a,l) do j = 1, nelec
rjam_cn = rescale_een_n(j,a,m) * cn rjal = rescale_een_n(j, a, l)
do i=1, j-1 rjam_cn = rescale_een_n(j, a, m) * cn
rial = rescale_een_n(i,a,l) do i = 1, j - 1
riam = rescale_een_n(i,a,m) rial = rescale_een_n(i, a, l)
rijk = rescale_een_e(i,j,k) riam = rescale_een_n(i, a, m)
factor_een = factor_een + & rijk = rescale_een_e(i, j, k)
rijk * (rial+rjal) * riam * rjam_cn factor_een = factor_een + &
enddo rijk * (rial + rjal) * riam * rjam_cn
enddo enddo
enddo
enddo
enddo enddo
enddo
enddo
enddo
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, factor_een_deriv_e, (4,nelec) ] BEGIN_PROVIDER [ double precision, factor_een_deriv_e, (4, nelec) ]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! dimensions 1-3 : dx,dy,dz ! Dimensions 1-3 : dx, dy, dz
! ! Dimension 4 : d2x + d2y + d2z
! Rdimension 4 : d2x + d2y + d2z
END_DOC END_DOC
integer :: i,j,a,p,k,l,lmax,m integer :: i, ii, j, a, p, k, l, lmax, m
double precision :: riam, rjam_cn, rial, rjal, rijk double precision :: riam, rjam_cn, rial, rjal, rijk
double precision, dimension(4) :: driam, drjam_cn, drial, drjal, drijk double precision, dimension(4) :: driam, drjam_cn, drial, drjal, drijk, x
double precision :: cn, v1, v2, l1, l2, d1, d2 double precision :: cn, v1, v2, d1, d2, lap
factor_een_deriv_e = 0.0d0 factor_een_deriv_e = 0.0d0
do p=2,ncord do p = 2, ncord
do k=0,p-1 do k = 0 , p - 1
if (k /= 0) then if (k /= 0) then
lmax = p-k lmax = p - k
else else
lmax = p-k-2 lmax = p - k - 2
endif
do l=0,lmax
if ( iand(p-k-l,1) == 1) then
cycle
endif endif
m = (p-k-l)/2
do a=1, nnuc do l = 0, lmax
cn = cord_vect_lkp(l,k,p,typenuc_arr(a)) if ( iand(p - k - l, 1) == 1) cycle
do j=1, nelec m = (p - k - l) / 2
rjal = rescale_een_n(j,a,l)
rjam_cn = rescale_een_n(j,a,m) * cn do a = 1, nnuc
do ii=1,4 cn = cord_vect_lkp(l, k, p, typenuc_arr(a))
drjal(ii) = rescale_een_n_deriv_e(ii,j,a,l)
drjam_cn(ii) = rescale_een_n_deriv_e(ii,j,a,m) * cn do j = 1, nelec
enddo factor_een_deriv_e(:, j) = 0.d0
factor_een_deriv_e(:,j) = 0.d0 rjal = rescale_een_n(j, a, l)
do i=1, nelec rjam_cn = rescale_een_n(j, a, m) * cn
rial = rescale_een_n(i,a,l)
riam = rescale_een_n(i,a,m) do ii = 1, 4
rijk = rescale_een_e(i,j,k) drjal(ii) = rescale_een_n_deriv_e(ii, j, a, l)
do ii=1,4 drjam_cn(ii) = rescale_een_n_deriv_e(ii, j, a, m) * cn
drijk(ii) = rescale_een_e_deriv_e(ii,i,j,k) enddo
do i = 1, nelec
rial = rescale_een_n(i, a, l)
riam = rescale_een_n(i, a, m)
rijk = rescale_een_e(i, j, k)
do ii = 1, 4
drijk(ii) = rescale_een_e_deriv_e(ii, i, j, k)
enddo
lap = 0.0d0
x(1:3) = 0.0d0
x(4) = 2.0d0
v1 = rijk * (rial + rjal)
v2 = rjam_cn * riam
do ii = 1, 4
d1 = drijk(ii) * (rial + rjal) + rijk * (rial + drjal(ii))
d2 = drjam_cn(ii) * riam
factor_een_deriv_e(ii, j) = factor_een_deriv_e(ii, j) + &
v1 * d2 + d1 * v2 + x(ii) * lap
lap = lap + d1 * d2
enddo
enddo
enddo enddo
l1 = 0.d0 enddo
l2 = 0.d0
x(1:3) = 0.d0
x(4) = 2.d0
do ii=1,4
v1 = rijk * (rial+rjal)
v2 = rjam_cn * riam
d1 = drijk(ii) * (rial+rjal) + rijk * (rial+drjal(ii))
d2 = drjam_cn(ii) * riam
l1 = l1 + drijk(ii) * (rial+drjal(ii))
l2 = l2 + drjam_cn(ii) * riam
factor_een_deriv_e(ii,j) = factor_een_deriv_e(ii,j) + &
v1 * d2 + d1 * v2 + x(ii) * (l1 + l2)
enddo
factor_een_deriv_e(ii,j) = factor_een_deriv_e(ii,j) + &
v1 * d2 + d1 * v2
enddo
enddo
enddo enddo
enddo
enddo
enddo
enddo enddo
factor_een_deriv_e = 0.5d0 * factor_een_deriv_e factor_een_deriv_e = 0.5d0 * factor_een_deriv_e
END_PROVIDER END_PROVIDER

BIN
irp_rdtsc.o Normal file

Binary file not shown.

BIN
jastrow Executable file

Binary file not shown.

View File

@ -7,11 +7,8 @@ BEGIN_PROVIDER [ double precision, jastrow_full ]
print *, "J_ee = ", factor_ee print *, "J_ee = ", factor_ee
print *, "J_en = ", factor_en print *, "J_en = ", factor_en
print *, "J_enn_naive = ", factor_een_naive
print *, "J_een = ", factor_een print *, "J_een = ", factor_een
print *, "J = J_ee + J_en + J_een = ", factor_ee + factor_en + factor_een print *, "J = J_ee + J_en + J_een = ", factor_ee + factor_en + factor_een
print *, "J = J_ee + J_en + J_een_naive = ", factor_ee + factor_en + factor_een_naive
!print *, "J_enn_prog = ", factor_een_prog
jastrow_full = dexp(factor_ee + factor_en + factor_een) jastrow_full = dexp(factor_ee + factor_en + factor_een)

View File

@ -11,7 +11,7 @@ BEGIN_PROVIDER [ integer, typenuc ]
&BEGIN_PROVIDER [integer, typenuc_arr, (nnuc)] &BEGIN_PROVIDER [integer, typenuc_arr, (nnuc)]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! Number of nuclei ! Type of the nuclei
END_DOC END_DOC
typenuc = 1 typenuc = 1
typenuc_arr = (/1, 1/) typenuc_arr = (/1, 1/)

View File

@ -73,24 +73,24 @@ END_PROVIDER
BEGIN_PROVIDER [ double precision, cord_vect_lkp, (0:ncord-1, 0:ncord-1, 2:ncord, typenuc) ] BEGIN_PROVIDER [ double precision, cord_vect_lkp, (0:ncord-1, 0:ncord-1, 2:ncord, typenuc) ]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! ! Creates c-tensor with right order of the indexes p, k, l
END_DOC END_DOC
integer :: alpha, l,k,p,lmax,cindex integer :: alpha, l, k, p, lmax, cindex
cord_vect_lkp = 0.d0 cord_vect_lkp = 0.0d0
cindex = 0 cindex = 0
do alpha=1,typenuc do alpha = 1, typenuc
do p = 2, ncord do p = 2, ncord
do k = p-1, 0, -1 do k = p - 1, 0, -1
if ( k /= 0 ) then if ( k /= 0 ) then
lmax = p - k lmax = p - k
else else
lmax = p - k - 2 lmax = p - k - 2
end if end if
do l = lmax, 0, -1 do l = lmax, 0, -1
if (iand(p-k-l,1) == 1) cycle if (iand(p - k - l, 1) == 1) cycle
cindex = cindex + 1 cindex = cindex + 1
cord_vect_lkp(l,k,p,alpha) = cord_vect(cindex, alpha) cord_vect_lkp(l, k, p, alpha) = cord_vect(cindex, alpha)
end do end do
end do end do
end do end do

View File

@ -22,9 +22,9 @@ BEGIN_PROVIDER [ double precision, rescale_ee, (nelec, nelec) ]
integer :: i, j integer :: i, j
do j = 1, nelec do j = 1, nelec
do i = 1, nelec do i = 1, nelec
rescale_ee(i, j) = (1.0d0 - dexp(-kappa * elec_dist(i, j))) * kappa_inv rescale_ee(i, j) = (1.0d0 - dexp(-kappa * elec_dist(i, j))) * kappa_inv
enddo enddo
enddo enddo
END_PROVIDER END_PROVIDER
@ -36,9 +36,9 @@ BEGIN_PROVIDER [ double precision, rescale_en, (nelec, nnuc) ]
integer :: i, j integer :: i, j
do j = 1, nnuc do j = 1, nnuc
do i = 1, nelec do i = 1, nelec
rescale_en(i, j) = (1.d0 - dexp(-kappa * elnuc_dist(i, j))) * kappa_inv rescale_en(i, j) = (1.d0 - dexp(-kappa * elnuc_dist(i, j))) * kappa_inv
enddo enddo
enddo enddo
END_PROVIDER END_PROVIDER
@ -50,27 +50,25 @@ BEGIN_PROVIDER [double precision, rescale_een_e, (nelec, nelec, 0:ncord)]
integer :: i, j, l integer :: i, j, l
double precision :: kappa_l double precision :: kappa_l
do l=0,ncord do l = 0, ncord
kappa_l = -dble(l) * kappa kappa_l = -dble(l) * kappa
do j = 1, nelec do j = 1, nelec
do i = 1, nelec do i = 1, nelec
rescale_een_e(i, j, l) = kappa_l * elec_dist(i, j) rescale_een_e(i, j, l) = kappa_l * elec_dist(i, j)
enddo
enddo enddo
enddo
enddo enddo
! More efficient to compute the exp of array than to do it in the loops
rescale_een_e = dexp(rescale_een_e) rescale_een_e = dexp(rescale_een_e)
! Later we use a formula looping on i and j=1->j-1. We need to set Rjj=0 to do l = 0, ncord
! enable looping of j=1,nelec do l=0,ncord do j = 1, nelec
do l=0,ncord rescale_een_e(j, j, l) = 0.d0
do j=1,nelec enddo
rescale_een_e(j, j, l) = 0.d0
enddo
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [double precision, rescale_een_n, (4, nelec, nnuc, 0:ncord)] BEGIN_PROVIDER [double precision, rescale_een_n, (nelec, nnuc, 0:ncord)]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! R = exp(-kappa r) for electron-electron for $J_{een}$ ! R = exp(-kappa r) for electron-electron for $J_{een}$
@ -78,43 +76,138 @@ BEGIN_PROVIDER [double precision, rescale_een_n, (4, nelec, nnuc, 0:ncord)]
integer :: i, j, l integer :: i, j, l
double precision :: kappa_l double precision :: kappa_l
do l=0,ncord do l = 0, ncord
kappa_l = - dble(l) * kappa kappa_l = - dble(l) * kappa
do j = 1, nnuc do j = 1, nnuc
do i = 1, nelec do i = 1, nelec
rescale_een_n(i, j, l) = kappa_l * elnuc_dist(i, j) rescale_een_n(i, j, l) = kappa_l * elnuc_dist(i, j)
enddo enddo
enddo enddo
enddo enddo
rescale_een_n = dexp(rescale_een_n) rescale_een_n = dexp(rescale_een_n)
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [double precision, rescale_een_n_deriv_e, (4,nelec, nnuc, 0:ncord)] BEGIN_PROVIDER [double precision, rescale_een_n_deriv_e, (4, nelec, nnuc, 0:ncord)]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! R = exp(-kappa r) for electron-electron for $J_{een}$ ! Derivative of the scaled distance J_{een} wrt R_{ia}
END_DOC END_DOC
integer :: i, j, l integer :: i, ii, j, l, a
double precision :: kappa_l double precision :: kappa_l
do l=0,ncord do l = 0, ncord
kappa_l = - dble(l) * kappa kappa_l = - dble(l) * kappa
do j = 1, nnuc do a = 1, nnuc
do i = 1, nelec do i = 1, nelec
do ii=1,4 ! r'(x) \lor r''(x)
rescale_een_n_deriv_e(ii, i, j, l) = & do ii = 1, 4
kappa_l * elnuc_dist_deriv_e(ii,i,j) rescale_een_n_deriv_e(ii, i, a, l) = &
kappa_l * elnuc_dist_deriv_e(ii, i, a)
enddo
! \left(r''(x)+r'(x)^2\right)
rescale_een_n_deriv_e(4, i, a, l) = rescale_een_n_deriv_e(4, i, a, l) + &
rescale_een_n_deriv_e(1, i, a, l) * rescale_een_n_deriv_e(1, i, a, l) + &
rescale_een_n_deriv_e(2, i, a, l) * rescale_een_n_deriv_e(2, i, a, l) + &
rescale_een_n_deriv_e(3, i, a, l) * rescale_een_n_deriv_e(3, i, a, l)
! \times e^{r(x)}
do ii = 1, 4
rescale_een_n_deriv_e(ii, i, a, l) = &
rescale_een_n_deriv_e(ii, i, a, l) * rescale_een_n(i, a, l)
enddo
enddo enddo
rescale_een_n_deriv_e(4, i, j, l) = rescale_een_n_deriv_e(4, i, j, l) + & enddo
rescale_een_n_deriv_e(1, i, j, l) * rescale_een_n_deriv_e(1, i, j, l) + &
rescale_een_n_deriv_e(2, i, j, l) * rescale_een_n_deriv_e(2, i, j, l) + &
rescale_een_n_deriv_e(3, i, j, l) * rescale_een_n_deriv_e(3, i, j, l)
do ii=1,4
rescale_een_n_deriv_e(ii, i, j, l) = &
rescale_een_n_deriv_e(ii,i,j, l) * rescale_een_n(i, j, l)
enddo
enddo
enddo
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [double precision, elnuc_dist_deriv_e, (4, nelec, nnuc)]
BEGIN_DOC
! Derivative of R_{ia} wrt x
! Dimensions 1-3 : dx, dy, dz
! Dimension 4 : d2x + d2y + d2z
END_DOC
implicit none
integer :: i, ii, a
double precision :: ria_inv, lap
do a = 1, nnuc
do i = 1, nelec
ria_inv = 1.0d0 / elnuc_dist(i, a)
lap = 0.0d0
do ii = 1, 3
elnuc_dist_deriv_e(ii, i, a) = (elec_coord(i, ii) - nuc_coord(a, ii)) * ria_inv
lap = ria_inv - elnuc_dist_deriv_e(ii, i, a) * elnuc_dist_deriv_e(ii, i, a) * ria_inv
end do
elnuc_dist_deriv_e(4, i, a) = lap
end do
end do
END_PROVIDER
BEGIN_PROVIDER [double precision, rescale_een_e_deriv_e, (4, nelec, nelec, 0:ncord)]
BEGIN_DOC
! Derivative of the scaled distance J_{een} wrt R_{ia}
END_DOC
implicit none
integer :: i, ii, j, l
double precision :: kappa_l
do l = 0, ncord
kappa_l = - dble(l) * kappa
do j = 1, nelec
do i = 1, nelec
! r'(x) \lor r''(x)
do ii = 1, 4
rescale_een_e_deriv_e(ii, i, j, l) = &
kappa_l * elec_dist_deriv_e(ii, i, j)
enddo
! \left(r''(x)+r'(x)^2\right)
rescale_een_e_deriv_e(4, i, j, l) = rescale_een_e_deriv_e(4, i, j, l) + &
rescale_een_e_deriv_e(1, i, j, l) * rescale_een_e_deriv_e(1, i, j, l) + &
rescale_een_e_deriv_e(2, i, j, l) * rescale_een_e_deriv_e(2, i, j, l) + &
rescale_een_e_deriv_e(3, i, j, l) * rescale_een_e_deriv_e(3, i, j, l)
! \times e^{r(x)}
do ii = 1, 4
rescale_een_e_deriv_e(ii, i, j, l) = &
rescale_een_e_deriv_e(ii, i, j, l) * rescale_een_e(i, j, l)
enddo
enddo
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [double precision, elec_dist_deriv_e, (4, nelec, nelec)]
BEGIN_DOC
! Derivative of R_{ij} wrt x
! Dimensions 1-3 : dx, dy, dz
! Dimension 4 : d2x + d2y + d2z
END_DOC
implicit none
integer :: i, ii, j
double precision :: rij_inv, lap
do j = 1, nnuc
do i = 1, nelec
rij_inv = 1.0d0 / elec_dist(i, j)
lap = 0.0d0
do ii = 1, 3
elec_dist_deriv_e(ii, i, j) = (elec_coord(i, ii) - elec_coord(j, ii)) * rij_inv
lap = rij_inv - elec_dist_deriv_e(ii, i, j) * elec_dist_deriv_e(ii, i, j) * rij_inv
end do
elnuc_dist_deriv_e(4, i, j) = lap
end do
end do
END_PROVIDER

4148
tt

File diff suppressed because it is too large Load Diff