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
FCFLAGS= -O2 -march=native -ffree-line-length-none -I .
FCFLAGS= -O2 -ffree-line-length-none -I .
NINJA = ninja
ARCHIVE= ar crs
AR = ar
RANLIB = ranlib
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,7 +1,7 @@
BEGIN_PROVIDER [ double precision, factor_een ]
implicit none
BEGIN_DOC
!
! ElectronE-electron-nuclei contribution to Jastrow factor
END_DOC
integer :: i, j, a, p, k, l, lmax, m
double precision :: riam, rjam_cn, rial, rjal, rijk
@ -16,13 +16,9 @@ BEGIN_PROVIDER [ double precision, factor_een ]
else
lmax = p - k - 2
endif
do l = 0, lmax
if ( iand(p-k-l,1) == 1) then
cycle
endif
if ( iand(p - k - l, 1) == 1) cycle
m = (p - k - l) / 2
do a = 1, nnuc
cn = cord_vect_lkp(l, k, p, typenuc_arr(a))
do j = 1, nelec
@ -37,7 +33,6 @@ BEGIN_PROVIDER [ double precision, factor_een ]
enddo
enddo
enddo
enddo
enddo
enddo
@ -47,14 +42,13 @@ END_PROVIDER
BEGIN_PROVIDER [ double precision, factor_een_deriv_e, (4, nelec) ]
implicit none
BEGIN_DOC
! dimensions 1-3 : dx,dy,dz
!
! Rdimension 4 : d2x + d2y + d2z
! Dimensions 1-3 : dx, dy, dz
! Dimension 4 : d2x + d2y + d2z
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, dimension(4) :: driam, drjam_cn, drial, drjal, drijk
double precision :: cn, v1, v2, l1, l2, d1, d2
double precision, dimension(4) :: driam, drjam_cn, drial, drjal, drijk, x
double precision :: cn, v1, v2, d1, d2, lap
factor_een_deriv_e = 0.0d0
@ -67,54 +61,52 @@ BEGIN_PROVIDER [ double precision, factor_een_deriv_e, (4,nelec) ]
endif
do l = 0, lmax
if ( iand(p-k-l,1) == 1) then
cycle
endif
if ( iand(p - k - l, 1) == 1) cycle
m = (p - k - l) / 2
do a = 1, nnuc
cn = cord_vect_lkp(l, k, p, typenuc_arr(a))
do j = 1, nelec
factor_een_deriv_e(:, j) = 0.d0
rjal = rescale_een_n(j, a, l)
rjam_cn = rescale_een_n(j, a, m) * cn
do ii = 1, 4
drjal(ii) = rescale_een_n_deriv_e(ii, j, a, l)
drjam_cn(ii) = rescale_een_n_deriv_e(ii, j, a, m) * cn
enddo
factor_een_deriv_e(:,j) = 0.d0
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
l1 = 0.d0
l2 = 0.d0
x(1:3) = 0.d0
x(4) = 2.d0
do ii=1,4
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
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
v1 * d2 + d1 * v2 + x(ii) * lap
lap = lap + d1 * d2
enddo
enddo
enddo
enddo
enddo
enddo
enddo
factor_een_deriv_e = 0.5d0 * factor_een_deriv_e
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_en = ", factor_en
print *, "J_enn_naive = ", factor_een_naive
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_naive = ", factor_ee + factor_en + factor_een_naive
!print *, "J_enn_prog = ", factor_een_prog
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)]
implicit none
BEGIN_DOC
! Number of nuclei
! Type of the nuclei
END_DOC
typenuc = 1
typenuc_arr = (/1, 1/)

View File

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

View File

@ -58,11 +58,9 @@ BEGIN_PROVIDER [double precision, rescale_een_e, (nelec, nelec, 0:ncord)]
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)
! Later we use a formula looping on i and j=1->j-1. We need to set Rjj=0 to
! enable looping of j=1,nelec do l=0,ncord
do l = 0, ncord
do j = 1, nelec
rescale_een_e(j, j, l) = 0.d0
@ -70,7 +68,7 @@ BEGIN_PROVIDER [double precision, rescale_een_e, (nelec, nelec, 0:ncord)]
enddo
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
BEGIN_DOC
! R = exp(-kappa r) for electron-electron for $J_{een}$
@ -92,29 +90,124 @@ END_PROVIDER
BEGIN_PROVIDER [double precision, rescale_een_n_deriv_e, (4, nelec, nnuc, 0:ncord)]
implicit none
BEGIN_DOC
! R = exp(-kappa r) for electron-electron for $J_{een}$
! Derivative of the scaled distance J_{een} wrt R_{ia}
END_DOC
integer :: i, j, l
integer :: i, ii, j, l, a
double precision :: kappa_l
do l = 0, ncord
kappa_l = - dble(l) * kappa
do j = 1, nnuc
do a = 1, nnuc
do i = 1, nelec
! r'(x) \lor r''(x)
do ii = 1, 4
rescale_een_n_deriv_e(ii, i, j, l) = &
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
rescale_een_n_deriv_e(4, i, j, l) = rescale_een_n_deriv_e(4, i, j, l) + &
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)
! \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, j, l) = &
rescale_een_n_deriv_e(ii,i,j, l) * rescale_een_n(i, j, l)
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
enddo
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