mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-27 05:35:28 -04:00
Drop toolchain patch for tblite
- No evidence shows these patches actually affect the tblite code path, and calculation settings should not be controlled through environment variables. - Spack recipe doesn't contain them, needs to keep dependency behavior consistent.
This commit is contained in:
parent
d1612e3f20
commit
678e60fa4e
3 changed files with 1 additions and 1793 deletions
|
|
@ -1,574 +0,0 @@
|
|||
diff --git a/src/dftd4/cutoff.f90 b/src/dftd4/cutoff.f90
|
||||
index 86a856b..40f299f 100644
|
||||
--- a/src/dftd4/cutoff.f90
|
||||
+++ b/src/dftd4/cutoff.f90
|
||||
@@ -20,7 +20,7 @@ module dftd4_cutoff
|
||||
implicit none
|
||||
private
|
||||
|
||||
- public :: realspace_cutoff, get_lattice_points, smooth_cutoff
|
||||
+ public :: realspace_cutoff, get_lattice_points, smooth_cutoff, apply_smooth_width_env
|
||||
|
||||
|
||||
!> Coordination number cutoff
|
||||
@@ -53,7 +53,7 @@ module dftd4_cutoff
|
||||
real(wp) :: disp3 = disp3_default
|
||||
|
||||
!> Width of smooth two-body interaction cutoff
|
||||
- real(wp) :: width2 = 0.0_wp
|
||||
+ real(wp) :: width2 = 0.05_wp
|
||||
|
||||
!> Width of smooth three-body interaction cutoff
|
||||
real(wp) :: width3 = 0.0_wp
|
||||
@@ -70,6 +70,46 @@ module dftd4_cutoff
|
||||
contains
|
||||
|
||||
|
||||
+subroutine apply_smooth_width_env(cutoff)
|
||||
+
|
||||
+ type(realspace_cutoff), intent(inout) :: cutoff
|
||||
+
|
||||
+ call get_smooth_width("DFTD4_DISP2_SMOOTH_WIDTH", "TBLITE_D4_DISP2_SMOOTH_WIDTH", &
|
||||
+ & cutoff%disp2, cutoff%width2)
|
||||
+ call get_smooth_width("DFTD4_DISP3_SMOOTH_WIDTH", "TBLITE_D4_DISP3_SMOOTH_WIDTH", &
|
||||
+ & cutoff%disp3, cutoff%width3)
|
||||
+
|
||||
+end subroutine apply_smooth_width_env
|
||||
+
|
||||
+
|
||||
+subroutine get_smooth_width(env1, env2, cutoff, width)
|
||||
+
|
||||
+ character(len=*), intent(in) :: env1, env2
|
||||
+ real(wp), intent(in) :: cutoff
|
||||
+ real(wp), intent(inout) :: width
|
||||
+
|
||||
+ character(len=64) :: env
|
||||
+ integer :: stat, io
|
||||
+ real(wp) :: env_width
|
||||
+
|
||||
+ call get_environment_variable(env1, env, status=stat)
|
||||
+ if (stat /= 0 .or. len_trim(env) == 0) then
|
||||
+ call get_environment_variable(env2, env, status=stat)
|
||||
+ end if
|
||||
+ if (stat == 0 .and. len_trim(env) > 0) then
|
||||
+ read(env, *, iostat=io) env_width
|
||||
+ if (io == 0) then
|
||||
+ if (env_width > 0.0_wp .and. env_width < cutoff) then
|
||||
+ width = env_width
|
||||
+ else
|
||||
+ width = 0.0_wp
|
||||
+ end if
|
||||
+ end if
|
||||
+ end if
|
||||
+
|
||||
+end subroutine get_smooth_width
|
||||
+
|
||||
+
|
||||
!> Smooth polynomial switch for realspace cutoffs
|
||||
pure subroutine smooth_cutoff(r, cutoff, width, sw, dswdr)
|
||||
|
||||
diff --git a/src/dftd4/damping/atm.f90 b/src/dftd4/damping/atm.f90
|
||||
index c6162c9..3f4f46a 100644
|
||||
--- a/src/dftd4/damping/atm.f90
|
||||
+++ b/src/dftd4/damping/atm.f90
|
||||
@@ -145,23 +145,16 @@ subroutine get_atm_dispersion_energy(mol, trans, cutoff, width, s9, a1, a2, alp,
|
||||
real(wp) :: r0ij, r0jk, r0ik, r0, r1, r2, r3, r5, rr, fdmp, ang
|
||||
real(wp) :: cutoff2, c9, dE, alp3, swij, swjk, swik, dswdr, sw
|
||||
|
||||
- ! Thread-private arrays for reduction
|
||||
- ! Set to 0 explicitly as the shared variants are potentially non-zero (inout)
|
||||
- real(wp), allocatable :: energy_local(:)
|
||||
|
||||
cutoff2 = cutoff*cutoff
|
||||
alp3 = alp / 3.0_wp
|
||||
|
||||
- !$omp parallel default(none) &
|
||||
+ !$omp parallel do schedule(dynamic) default(none) reduction(+:energy) &
|
||||
!$omp shared(mol, trans, c6, s9, a1, a2, alp3, r4r2, cutoff2, cutoff, width) &
|
||||
!$omp private(iat, jat, kat, izp, jzp, kzp, jtr, ktr, vij, vjk, vik, &
|
||||
!$omp& r2ij, r2jk, r2ik, rij, rjk, rik, c6ij, c6jk, c6ik, triple, &
|
||||
!$omp& r0ij, r0jk, r0ik, r0, r1, r2, r3, r5, rr, fdmp, ang, c9, dE, &
|
||||
- !$omp& swij, swjk, swik, dswdr, sw) &
|
||||
- !$omp shared(energy) &
|
||||
- !$omp private(energy_local)
|
||||
- allocate(energy_local(size(energy, 1)), source=0.0_wp)
|
||||
- !$omp do schedule(dynamic)
|
||||
+ !$omp& swij, swjk, swik, dswdr, sw)
|
||||
do iat = 1, mol%nat
|
||||
izp = mol%id(iat)
|
||||
do jat = 1, iat
|
||||
@@ -212,20 +205,15 @@ subroutine get_atm_dispersion_energy(mol, trans, cutoff, width, s9, a1, a2, alp,
|
||||
rr = ang*fdmp
|
||||
|
||||
dE = rr * c9 * triple * third * sw
|
||||
- energy_local(iat) = energy_local(iat) - dE
|
||||
- energy_local(jat) = energy_local(jat) - dE
|
||||
- energy_local(kat) = energy_local(kat) - dE
|
||||
+ energy(iat) = energy(iat) - dE
|
||||
+ energy(jat) = energy(jat) - dE
|
||||
+ energy(kat) = energy(kat) - dE
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
- !$omp end do
|
||||
- !$omp critical (get_atm_dispersion_energy_)
|
||||
- energy(:) = energy(:) + energy_local(:)
|
||||
- !$omp end critical (get_atm_dispersion_energy_)
|
||||
- deallocate(energy_local)
|
||||
- !$omp end parallel
|
||||
+ !$omp end parallel do
|
||||
|
||||
end subroutine get_atm_dispersion_energy
|
||||
|
||||
@@ -293,34 +281,19 @@ subroutine get_atm_dispersion_derivs(mol, trans, cutoff, width, s9, a1, a2, alp,
|
||||
real(wp) :: dGij(3), dGjk(3), dGik(3), dS(3, 3)
|
||||
real(wp) :: swij, swjk, swik, dswijdr, dswjkdr, dswikdr, sw
|
||||
|
||||
- ! Thread-private arrays for reduction
|
||||
- ! Set to 0 explicitly as the shared variants are potentially non-zero (inout)
|
||||
- real(wp), allocatable :: energy_local(:)
|
||||
- real(wp), allocatable :: dEdcn_local(:)
|
||||
- real(wp), allocatable :: dEdq_local(:)
|
||||
- real(wp), allocatable :: gradient_local(:, :)
|
||||
- real(wp), allocatable :: sigma_local(:, :)
|
||||
|
||||
cutoff2 = cutoff*cutoff
|
||||
alp3 = alp / 3.0_wp
|
||||
|
||||
- !$omp parallel default(none) &
|
||||
+ !$omp parallel do schedule(dynamic) default(none) &
|
||||
+ !$omp reduction(+:energy, gradient, sigma, dEdcn, dEdq) &
|
||||
!$omp shared(mol, trans, c6, s9, a1, a2, alp, alp3, r4r2, cutoff2, &
|
||||
!$omp& cutoff, width, dc6dcn, dc6dq) &
|
||||
!$omp private(iat, jat, kat, izp, jzp, kzp, jtr, ktr, vij, vjk, vik, &
|
||||
!$omp& r2ij, r2jk, r2ik, rij, rjk, rik, c6ij, c6jk, c6ik, triple, &
|
||||
!$omp& r0ij, r0jk, r0ik, r0, r1, r2, r3, r5, rr, fdmp, dfdmp, ang, dang, &
|
||||
!$omp& c9, dE, dE0, dE_third, dGij, dGjk, dGik, dS, swij, swjk, swik, &
|
||||
- !$omp& dswijdr, dswjkdr, dswikdr, sw) &
|
||||
- !$omp shared(energy, gradient, sigma, dEdcn, dEdq) &
|
||||
- !$omp private(energy_local, gradient_local, sigma_local, dEdcn_local, &
|
||||
- !$omp& dEdq_local)
|
||||
- allocate(energy_local(size(energy, 1)), source=0.0_wp)
|
||||
- allocate(dEdcn_local(size(dEdcn, 1)), source=0.0_wp)
|
||||
- allocate(dEdq_local(size(dEdq, 1)), source=0.0_wp)
|
||||
- allocate(gradient_local(size(gradient, 1), size(gradient, 2)), source=0.0_wp)
|
||||
- allocate(sigma_local(size(sigma, 1), size(sigma, 2)), source=0.0_wp)
|
||||
- !$omp do schedule(dynamic)
|
||||
+ !$omp& dswijdr, dswjkdr, dswikdr, sw)
|
||||
do iat = 1, mol%nat
|
||||
izp = mol%id(iat)
|
||||
do jat = 1, iat
|
||||
@@ -399,55 +372,42 @@ subroutine get_atm_dispersion_derivs(mol, trans, cutoff, width, s9, a1, a2, alp,
|
||||
|
||||
dE = dE0 * triple * sw
|
||||
dE_third = dE * third
|
||||
- energy_local(iat) = energy_local(iat) - dE_third
|
||||
- energy_local(jat) = energy_local(jat) - dE_third
|
||||
- energy_local(kat) = energy_local(kat) - dE_third
|
||||
+ energy(iat) = energy(iat) - dE_third
|
||||
+ energy(jat) = energy(jat) - dE_third
|
||||
+ energy(kat) = energy(kat) - dE_third
|
||||
|
||||
- gradient_local(:, iat) = gradient_local(:, iat) &
|
||||
+ gradient(:, iat) = gradient(:, iat) &
|
||||
& - (dGij + dGik) * triple
|
||||
- gradient_local(:, jat) = gradient_local(:, jat) &
|
||||
+ gradient(:, jat) = gradient(:, jat) &
|
||||
& + (dGij - dGjk) * triple
|
||||
- gradient_local(:, kat) = gradient_local(:, kat) &
|
||||
+ gradient(:, kat) = gradient(:, kat) &
|
||||
& + (dGik + dGjk) * triple
|
||||
|
||||
dS(:, :) = spread(dGij, 1, 3) * spread(vij, 2, 3)&
|
||||
& + spread(dGik, 1, 3) * spread(vik, 2, 3)&
|
||||
& + spread(dGjk, 1, 3) * spread(vjk, 2, 3)
|
||||
|
||||
- sigma_local(:, :) = sigma_local + dS * triple
|
||||
+ sigma(:, :) = sigma(:, :) + dS * triple
|
||||
|
||||
- dEdcn_local(iat) = dEdcn_local(iat) - dE * 0.5_wp &
|
||||
+ dEdcn(iat) = dEdcn(iat) - dE * 0.5_wp &
|
||||
& * (dc6dcn(iat, jat) / c6ij + dc6dcn(iat, kat) / c6ik)
|
||||
- dEdcn_local(jat) = dEdcn_local(jat) - dE * 0.5_wp &
|
||||
+ dEdcn(jat) = dEdcn(jat) - dE * 0.5_wp &
|
||||
& * (dc6dcn(jat, iat) / c6ij + dc6dcn(jat, kat) / c6jk)
|
||||
- dEdcn_local(kat) = dEdcn_local(kat) - dE * 0.5_wp &
|
||||
+ dEdcn(kat) = dEdcn(kat) - dE * 0.5_wp &
|
||||
& * (dc6dcn(kat, iat) / c6ik + dc6dcn(kat, jat) / c6jk)
|
||||
|
||||
- dEdq_local(iat) = dEdq_local(iat) - dE * 0.5_wp &
|
||||
+ dEdq(iat) = dEdq(iat) - dE * 0.5_wp &
|
||||
& * (dc6dq(iat, jat) / c6ij + dc6dq(iat, kat) / c6ik)
|
||||
- dEdq_local(jat) = dEdq_local(jat) - dE * 0.5_wp &
|
||||
+ dEdq(jat) = dEdq(jat) - dE * 0.5_wp &
|
||||
& * (dc6dq(jat, iat) / c6ij + dc6dq(jat, kat) / c6jk)
|
||||
- dEdq_local(kat) = dEdq_local(kat) - dE * 0.5_wp &
|
||||
+ dEdq(kat) = dEdq(kat) - dE * 0.5_wp &
|
||||
& * (dc6dq(kat, iat) / c6ik + dc6dq(kat, jat) / c6jk)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
- !$omp end do
|
||||
- !$omp critical (get_atm_dispersion_derivs_)
|
||||
- energy(:) = energy(:) + energy_local(:)
|
||||
- dEdcn(:) = dEdcn(:) + dEdcn_local(:)
|
||||
- dEdq(:) = dEdq(:) + dEdq_local(:)
|
||||
- gradient(:, :) = gradient(:, :) + gradient_local(:, :)
|
||||
- sigma(:, :) = sigma(:, :) + sigma_local(:, :)
|
||||
- !$omp end critical (get_atm_dispersion_derivs_)
|
||||
- deallocate(energy_local)
|
||||
- deallocate(dEdcn_local)
|
||||
- deallocate(dEdq_local)
|
||||
- deallocate(gradient_local)
|
||||
- deallocate(sigma_local)
|
||||
- !$omp end parallel
|
||||
+ !$omp end parallel do
|
||||
|
||||
end subroutine get_atm_dispersion_derivs
|
||||
|
||||
diff --git a/src/dftd4/damping/rational.f90 b/src/dftd4/damping/rational.f90
|
||||
index 9d359c9..87e8f6b 100644
|
||||
--- a/src/dftd4/damping/rational.f90
|
||||
+++ b/src/dftd4/damping/rational.f90
|
||||
@@ -152,20 +152,13 @@ subroutine get_dispersion_energy(self, mol, trans, cutoff, width, r4r2, c6, ener
|
||||
real(wp) :: vec(3), r2, r, cutoff2, r0ij, rrij, c6ij, t6, t8, edisp, dE
|
||||
real(wp) :: sw, dswdr
|
||||
|
||||
- ! Thread-private array for reduction
|
||||
- ! Set to 0 explicitly as the shared variants are potentially non-zero (inout)
|
||||
- real(wp), allocatable :: energy_local(:)
|
||||
|
||||
cutoff2 = cutoff*cutoff
|
||||
|
||||
- !$omp parallel default(none) &
|
||||
+ !$omp parallel do schedule(runtime) default(none) reduction(+:energy) &
|
||||
!$omp shared(mol, self, c6, trans, cutoff2, cutoff, width, r4r2) &
|
||||
!$omp private(iat, jat, izp, jzp, jtr, vec, r2, r0ij, rrij, c6ij, &
|
||||
- !$omp& t6, t8, edisp, dE, r, sw, dswdr) &
|
||||
- !$omp shared(energy) &
|
||||
- !$omp private(energy_local)
|
||||
- allocate(energy_local(size(energy, 1)), source=0.0_wp)
|
||||
- !$omp do schedule(runtime)
|
||||
+ !$omp& t6, t8, edisp, dE, r, sw, dswdr)
|
||||
do iat = 1, mol%nat
|
||||
izp = mol%id(iat)
|
||||
do jat = 1, iat
|
||||
@@ -188,19 +181,14 @@ subroutine get_dispersion_energy(self, mol, trans, cutoff, width, r4r2, c6, ener
|
||||
|
||||
dE = -c6ij*edisp * 0.5_wp
|
||||
|
||||
- energy_local(iat) = energy_local(iat) + dE
|
||||
+ energy(iat) = energy(iat) + dE
|
||||
if (iat /= jat) then
|
||||
- energy_local(jat) = energy_local(jat) + dE
|
||||
+ energy(jat) = energy(jat) + dE
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
- !$omp end do
|
||||
- !$omp critical (get_dispersion_energy_)
|
||||
- energy(:) = energy(:) + energy_local(:)
|
||||
- !$omp end critical (get_dispersion_energy_)
|
||||
- deallocate(energy_local)
|
||||
- !$omp end parallel
|
||||
+ !$omp end parallel do
|
||||
|
||||
end subroutine get_dispersion_energy
|
||||
|
||||
@@ -256,29 +244,14 @@ subroutine get_dispersion_derivs(self, mol, trans, cutoff, width, r4r2, c6, dc6d
|
||||
real(wp) :: edisp0, gdisp0, edisp, gdisp, sw, dswdr
|
||||
real(wp) :: dE, dG(3), dS(3, 3)
|
||||
|
||||
- ! Thread-private arrays for reduction
|
||||
- ! Set to 0 explicitly as the shared variants are potentially non-zero (inout)
|
||||
- real(wp), allocatable :: energy_local(:)
|
||||
- real(wp), allocatable :: dEdcn_local(:)
|
||||
- real(wp), allocatable :: dEdq_local(:)
|
||||
- real(wp), allocatable :: gradient_local(:, :)
|
||||
- real(wp), allocatable :: sigma_local(:, :)
|
||||
|
||||
cutoff2 = cutoff*cutoff
|
||||
|
||||
- !$omp parallel default(none) &
|
||||
+ !$omp parallel do schedule(runtime) default(none) &
|
||||
+ !$omp reduction(+:energy, gradient, sigma, dEdcn, dEdq) &
|
||||
!$omp shared(mol, self, c6, dc6dcn, dc6dq, trans, cutoff2, cutoff, width, r4r2) &
|
||||
!$omp private(iat, jat, izp, jzp, jtr, vec, r2, r0ij, rrij, c6ij, t6, t8, &
|
||||
- !$omp& d6, d8, edisp0, gdisp0, edisp, gdisp, dE, dG, dS, r, sw, dswdr) &
|
||||
- !$omp shared(energy, gradient, sigma, dEdcn, dEdq) &
|
||||
- !$omp private(energy_local, gradient_local, sigma_local, dEdcn_local, &
|
||||
- !$omp& dEdq_local)
|
||||
- allocate(energy_local(size(energy, 1)), source=0.0_wp)
|
||||
- allocate(dEdcn_local(size(dEdcn, 1)), source=0.0_wp)
|
||||
- allocate(dEdq_local(size(dEdq, 1)), source=0.0_wp)
|
||||
- allocate(gradient_local(size(gradient, 1), size(gradient, 2)), source=0.0_wp)
|
||||
- allocate(sigma_local(size(sigma, 1), size(sigma, 2)), source=0.0_wp)
|
||||
- !$omp do schedule(runtime)
|
||||
+ !$omp& d6, d8, edisp0, gdisp0, edisp, gdisp, dE, dG, dS, r, sw, dswdr)
|
||||
do iat = 1, mol%nat
|
||||
izp = mol%id(iat)
|
||||
do jat = 1, iat
|
||||
@@ -310,35 +283,22 @@ subroutine get_dispersion_derivs(self, mol, trans, cutoff, width, r4r2, c6, dc6d
|
||||
dG(:) = -c6ij*gdisp*vec
|
||||
dS(:, :) = spread(dG, 1, 3) * spread(vec, 2, 3) * 0.5_wp
|
||||
|
||||
- energy_local(iat) = energy_local(iat) + dE
|
||||
- dEdcn_local(iat) = dEdcn_local(iat) - dc6dcn(iat, jat) * edisp
|
||||
- dEdq_local(iat) = dEdq_local(iat) - dc6dq(iat, jat) * edisp
|
||||
- sigma_local(:, :) = sigma_local + dS
|
||||
+ energy(iat) = energy(iat) + dE
|
||||
+ dEdcn(iat) = dEdcn(iat) - dc6dcn(iat, jat) * edisp
|
||||
+ dEdq(iat) = dEdq(iat) - dc6dq(iat, jat) * edisp
|
||||
+ sigma(:, :) = sigma(:, :) + dS
|
||||
if (iat /= jat) then
|
||||
- energy_local(jat) = energy_local(jat) + dE
|
||||
- dEdcn_local(jat) = dEdcn_local(jat) - dc6dcn(jat, iat) * edisp
|
||||
- dEdq_local(jat) = dEdq_local(jat) - dc6dq(jat, iat) * edisp
|
||||
- gradient_local(:, iat) = gradient_local(:, iat) + dG
|
||||
- gradient_local(:, jat) = gradient_local(:, jat) - dG
|
||||
- sigma_local(:, :) = sigma_local + dS
|
||||
+ energy(jat) = energy(jat) + dE
|
||||
+ dEdcn(jat) = dEdcn(jat) - dc6dcn(jat, iat) * edisp
|
||||
+ dEdq(jat) = dEdq(jat) - dc6dq(jat, iat) * edisp
|
||||
+ gradient(:, iat) = gradient(:, iat) + dG
|
||||
+ gradient(:, jat) = gradient(:, jat) - dG
|
||||
+ sigma(:, :) = sigma(:, :) + dS
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
- !$omp end do
|
||||
- !$omp critical (get_dispersion_derivs_)
|
||||
- energy(:) = energy(:) + energy_local(:)
|
||||
- dEdcn(:) = dEdcn(:) + dEdcn_local(:)
|
||||
- dEdq(:) = dEdq(:) + dEdq_local(:)
|
||||
- gradient(:, :) = gradient(:, :) + gradient_local(:, :)
|
||||
- sigma(:, :) = sigma(:, :) + sigma_local(:, :)
|
||||
- !$omp end critical (get_dispersion_derivs_)
|
||||
- deallocate(energy_local)
|
||||
- deallocate(dEdcn_local)
|
||||
- deallocate(dEdq_local)
|
||||
- deallocate(gradient_local)
|
||||
- deallocate(sigma_local)
|
||||
- !$omp end parallel
|
||||
+ !$omp end parallel do
|
||||
|
||||
end subroutine get_dispersion_derivs
|
||||
|
||||
@@ -429,21 +389,14 @@ subroutine get_pairwise_dispersion2(self, mol, trans, cutoff, width, r4r2, c6, e
|
||||
real(wp) :: vec(3), r2, r, cutoff2, r0ij, rrij, c6ij, t6, t8, edisp, dE
|
||||
real(wp) :: sw, dswdr
|
||||
|
||||
- ! Thread-private array for reduction
|
||||
- ! Set to 0 explicitly as the shared variants are potentially non-zero (inout)
|
||||
- real(wp), allocatable :: energy_local(:, :)
|
||||
|
||||
if (abs(self%s6) < epsilon(1.0_wp) .and. abs(self%s8) < epsilon(1.0_wp)) return
|
||||
cutoff2 = cutoff*cutoff
|
||||
|
||||
- !$omp parallel default(none) &
|
||||
+ !$omp parallel do schedule(runtime) default(none) reduction(+:energy) &
|
||||
!$omp shared(mol, self, c6, trans, cutoff2, cutoff, width, r4r2) &
|
||||
!$omp private(iat, jat, izp, jzp, jtr, vec, r2, r0ij, rrij, c6ij, &
|
||||
- !$omp& t6, t8, edisp, dE, r, sw, dswdr) &
|
||||
- !$omp shared(energy) &
|
||||
- !$omp private(energy_local)
|
||||
- allocate(energy_local(size(energy, 1), size(energy, 2)), source=0.0_wp)
|
||||
- !$omp do schedule(runtime)
|
||||
+ !$omp& t6, t8, edisp, dE, r, sw, dswdr)
|
||||
do iat = 1, mol%nat
|
||||
izp = mol%id(iat)
|
||||
do jat = 1, iat
|
||||
@@ -466,19 +419,14 @@ subroutine get_pairwise_dispersion2(self, mol, trans, cutoff, width, r4r2, c6, e
|
||||
|
||||
dE = -c6ij*edisp * 0.5_wp
|
||||
|
||||
- energy_local(jat, iat) = energy_local(jat, iat) + dE
|
||||
+ energy(jat, iat) = energy(jat, iat) + dE
|
||||
if (iat /= jat) then
|
||||
- energy_local(iat, jat) = energy_local(iat, jat) + dE
|
||||
+ energy(iat, jat) = energy(iat, jat) + dE
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
- !$omp end do
|
||||
- !$omp critical (get_pairwise_dispersion2_)
|
||||
- energy(:, :) = energy(:, :) + energy_local(:, :)
|
||||
- !$omp end critical (get_pairwise_dispersion2_)
|
||||
- deallocate(energy_local)
|
||||
- !$omp end parallel
|
||||
+ !$omp end parallel do
|
||||
|
||||
end subroutine get_pairwise_dispersion2
|
||||
|
||||
@@ -517,24 +465,17 @@ subroutine get_pairwise_dispersion3(self, mol, trans, cutoff, width, r4r2, c6, e
|
||||
real(wp) :: r0ij, r0jk, r0ik, r0, r1, r2, r3, r5, rr, fdmp, ang
|
||||
real(wp) :: cutoff2, c9, dE, alp3, swij, swjk, swik, dswdr, sw
|
||||
|
||||
- ! Thread-private arrays for reduction
|
||||
- ! Set to 0 explicitly as the shared variants are potentially non-zero (inout)
|
||||
- real(wp), allocatable :: energy_local(:, :)
|
||||
|
||||
if (abs(self%s9) < epsilon(1.0_wp)) return
|
||||
cutoff2 = cutoff*cutoff
|
||||
alp3 = self%alp / 3.0_wp
|
||||
|
||||
- !$omp parallel default(none) &
|
||||
+ !$omp parallel do schedule(runtime) default(none) reduction(+:energy) &
|
||||
!$omp shared(mol, trans, c6, r4r2, cutoff2, cutoff, width, alp3, self) &
|
||||
!$omp private(iat, jat, kat, izp, jzp, kzp, jtr, ktr, vij, vjk, vik, &
|
||||
!$omp& r2ij, r2jk, r2ik, rij, rjk, rik, c6ij, c6jk, c6ik, triple, &
|
||||
!$omp& r0ij, r0jk, r0ik, r0, r1, r2, r3, r5, rr, fdmp, ang, c9, dE, &
|
||||
- !$omp& swij, swjk, swik, dswdr, sw) &
|
||||
- !$omp shared(energy) &
|
||||
- !$omp private(energy_local)
|
||||
- allocate(energy_local(size(energy, 1), size(energy, 2)), source=0.0_wp)
|
||||
- !$omp do schedule(runtime)
|
||||
+ !$omp& swij, swjk, swik, dswdr, sw)
|
||||
do iat = 1, mol%nat
|
||||
izp = mol%id(iat)
|
||||
do jat = 1, iat
|
||||
@@ -585,23 +526,18 @@ subroutine get_pairwise_dispersion3(self, mol, trans, cutoff, width, r4r2, c6, e
|
||||
rr = ang*fdmp
|
||||
|
||||
dE = rr * c9 * triple * sixth * sw
|
||||
- energy_local(jat, iat) = energy_local(jat, iat) - dE
|
||||
- energy_local(kat, iat) = energy_local(kat, iat) - dE
|
||||
- energy_local(iat, jat) = energy_local(iat, jat) - dE
|
||||
- energy_local(kat, jat) = energy_local(kat, jat) - dE
|
||||
- energy_local(iat, kat) = energy_local(iat, kat) - dE
|
||||
- energy_local(jat, kat) = energy_local(jat, kat) - dE
|
||||
+ energy(jat, iat) = energy(jat, iat) - dE
|
||||
+ energy(kat, iat) = energy(kat, iat) - dE
|
||||
+ energy(iat, jat) = energy(iat, jat) - dE
|
||||
+ energy(kat, jat) = energy(kat, jat) - dE
|
||||
+ energy(iat, kat) = energy(iat, kat) - dE
|
||||
+ energy(jat, kat) = energy(jat, kat) - dE
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
- !$omp end do
|
||||
- !$omp critical (get_pairwise_dispersion3_)
|
||||
- energy(:, :) = energy(:, :) + energy_local(:, :)
|
||||
- !$omp end critical (get_pairwise_dispersion3_)
|
||||
- deallocate(energy_local)
|
||||
- !$omp end parallel
|
||||
+ !$omp end parallel do
|
||||
|
||||
end subroutine get_pairwise_dispersion3
|
||||
|
||||
diff --git a/src/dftd4/disp.f90 b/src/dftd4/disp.f90
|
||||
index 73253ce..8524cef 100644
|
||||
--- a/src/dftd4/disp.f90
|
||||
+++ b/src/dftd4/disp.f90
|
||||
@@ -18,7 +18,7 @@
|
||||
module dftd4_disp
|
||||
use, intrinsic :: iso_fortran_env, only : error_unit
|
||||
use dftd4_blas, only : d4_gemv
|
||||
- use dftd4_cutoff, only : realspace_cutoff, get_lattice_points
|
||||
+ use dftd4_cutoff, only : realspace_cutoff, get_lattice_points, apply_smooth_width_env
|
||||
use dftd4_damping, only : damping_param
|
||||
use dftd4_data, only : get_covalent_rad
|
||||
use dftd4_model, only : dispersion_model
|
||||
@@ -70,9 +70,12 @@ subroutine get_dispersion(mol, disp, param, cutoff, energy, gradient, sigma)
|
||||
real(wp), allocatable :: dEdcn(:), dEdq(:), energies(:)
|
||||
real(wp), allocatable :: lattr(:, :)
|
||||
type(error_type), allocatable :: error
|
||||
+ type(realspace_cutoff) :: cutoff_eff
|
||||
|
||||
mref = maxval(disp%ref)
|
||||
grad = present(gradient).or.present(sigma)
|
||||
+ cutoff_eff = cutoff
|
||||
+ call apply_smooth_width_env(cutoff_eff)
|
||||
|
||||
if (.not. allocated(disp%mchrg)) then
|
||||
write(error_unit, '("[Error]:", 1x, a)') "Not supported for non-self-consistent D4 version"
|
||||
@@ -80,8 +83,8 @@ subroutine get_dispersion(mol, disp, param, cutoff, energy, gradient, sigma)
|
||||
end if
|
||||
|
||||
allocate(cn(mol%nat))
|
||||
- call get_lattice_points(mol%periodic, mol%lattice, cutoff%cn, lattr)
|
||||
- call get_coordination_number(mol, lattr, cutoff%cn, disp%rcov, disp%en, cn)
|
||||
+ call get_lattice_points(mol%periodic, mol%lattice, cutoff_eff%cn, lattr)
|
||||
+ call get_coordination_number(mol, lattr, cutoff_eff%cn, disp%rcov, disp%en, cn)
|
||||
|
||||
allocate(q(mol%nat))
|
||||
if (grad) allocate(dqdr(3, mol%nat, mol%nat), dqdL(3, 3, mol%nat))
|
||||
@@ -109,8 +112,8 @@ subroutine get_dispersion(mol, disp, param, cutoff, energy, gradient, sigma)
|
||||
sigma(:, :) = 0.0_wp
|
||||
end if
|
||||
|
||||
- call get_lattice_points(mol%periodic, mol%lattice, cutoff%disp2, lattr)
|
||||
- call param%get_dispersion2(mol, lattr, cutoff%disp2, cutoff%width2, disp%r4r2, &
|
||||
+ call get_lattice_points(mol%periodic, mol%lattice, cutoff_eff%disp2, lattr)
|
||||
+ call param%get_dispersion2(mol, lattr, cutoff_eff%disp2, cutoff_eff%width2, disp%r4r2, &
|
||||
& c6, dc6dcn, dc6dq, energies, dEdcn, dEdq, gradient, sigma)
|
||||
if (grad) then
|
||||
call d4_gemv(dqdr, dEdq, gradient, beta=1.0_wp)
|
||||
@@ -121,11 +124,11 @@ subroutine get_dispersion(mol, disp, param, cutoff, energy, gradient, sigma)
|
||||
call disp%weight_references(mol, cn, q, gwvec, gwdcn, gwdq)
|
||||
call disp%get_atomic_c6(mol, gwvec, gwdcn, gwdq, c6, dc6dcn, dc6dq)
|
||||
|
||||
- call get_lattice_points(mol%periodic, mol%lattice, cutoff%disp3, lattr)
|
||||
- call param%get_dispersion3(mol, lattr, cutoff%disp3, cutoff%width3, disp%r4r2, &
|
||||
+ call get_lattice_points(mol%periodic, mol%lattice, cutoff_eff%disp3, lattr)
|
||||
+ call param%get_dispersion3(mol, lattr, cutoff_eff%disp3, cutoff_eff%width3, disp%r4r2, &
|
||||
& c6, dc6dcn, dc6dq, energies, dEdcn, dEdq, gradient, sigma)
|
||||
if (grad) then
|
||||
- call add_coordination_number_derivs(mol, lattr, cutoff%cn, &
|
||||
+ call add_coordination_number_derivs(mol, lattr, cutoff_eff%cn, &
|
||||
& disp%rcov, disp%en, dEdcn, gradient, sigma)
|
||||
end if
|
||||
|
||||
@@ -213,6 +216,7 @@ subroutine get_pairwise_dispersion(mol, disp, param, cutoff, energy2, energy3)
|
||||
integer :: mref
|
||||
real(wp), allocatable :: cn(:), q(:), gwvec(:, :, :), c6(:, :), lattr(:, :)
|
||||
type(error_type), allocatable :: error
|
||||
+ type(realspace_cutoff) :: cutoff_eff
|
||||
|
||||
if (.not. allocated(disp%mchrg)) then
|
||||
write(error_unit, '("[Error]:", 1x, a)') "Not supported for non-self-consistent D4 version"
|
||||
@@ -220,10 +224,12 @@ subroutine get_pairwise_dispersion(mol, disp, param, cutoff, energy2, energy3)
|
||||
end if
|
||||
|
||||
mref = maxval(disp%ref)
|
||||
+ cutoff_eff = cutoff
|
||||
+ call apply_smooth_width_env(cutoff_eff)
|
||||
|
||||
allocate(cn(mol%nat))
|
||||
- call get_lattice_points(mol%periodic, mol%lattice, cutoff%cn, lattr)
|
||||
- call get_coordination_number(mol, lattr, cutoff%cn, disp%rcov, disp%en, cn)
|
||||
+ call get_lattice_points(mol%periodic, mol%lattice, cutoff_eff%cn, lattr)
|
||||
+ call get_coordination_number(mol, lattr, cutoff_eff%cn, disp%rcov, disp%en, cn)
|
||||
|
||||
allocate(q(mol%nat))
|
||||
call get_charges(disp%mchrg, mol, error, q)
|
||||
@@ -240,16 +246,16 @@ subroutine get_pairwise_dispersion(mol, disp, param, cutoff, energy2, energy3)
|
||||
|
||||
energy2(:, :) = 0.0_wp
|
||||
energy3(:, :) = 0.0_wp
|
||||
- call get_lattice_points(mol%periodic, mol%lattice, cutoff%disp2, lattr)
|
||||
- call param%get_pairwise_dispersion2(mol, lattr, cutoff%disp2, cutoff%width2, &
|
||||
+ call get_lattice_points(mol%periodic, mol%lattice, cutoff_eff%disp2, lattr)
|
||||
+ call param%get_pairwise_dispersion2(mol, lattr, cutoff_eff%disp2, cutoff_eff%width2, &
|
||||
& disp%r4r2, c6, energy2)
|
||||
|
||||
q(:) = 0.0_wp
|
||||
call disp%weight_references(mol, cn, q, gwvec)
|
||||
call disp%get_atomic_c6(mol, gwvec, c6=c6)
|
||||
|
||||
- call get_lattice_points(mol%periodic, mol%lattice, cutoff%disp3, lattr)
|
||||
- call param%get_pairwise_dispersion3(mol, lattr, cutoff%disp3, cutoff%width3, &
|
||||
+ call get_lattice_points(mol%periodic, mol%lattice, cutoff_eff%disp3, lattr)
|
||||
+ call param%get_pairwise_dispersion3(mol, lattr, cutoff_eff%disp3, cutoff_eff%width3, &
|
||||
& disp%r4r2, c6, energy3)
|
||||
|
||||
end subroutine get_pairwise_dispersion
|
||||
|
|
@ -36,12 +36,6 @@ case "$with_tblite" in
|
|||
[ -d tblite-${tblite_ver} ] && rm -rf tblite-${tblite_ver}
|
||||
tar -xJf tblite-${tblite_ver}.tar.xz
|
||||
cd tblite-${tblite_ver}
|
||||
|
||||
patch -l -d subprojects/s-dftd3 -p1 < "${SCRIPT_DIR}/stage8/simple-dftd3-${tblite_sdftd3_ver}-gradient-fixes.patch" \
|
||||
> simple_dftd3_gradient_fixes.patch.log 2>&1 || tail_excerpt simple_dftd3_gradient_fixes.patch.log
|
||||
patch -l -d subprojects/dftd4 -p1 < "${SCRIPT_DIR}/stage8/dftd4-${tblite_dftd4_ver}-gradient-fixes.patch" \
|
||||
> dftd4_gradient_fixes.patch.log 2>&1 || tail_excerpt dftd4_gradient_fixes.patch.log
|
||||
|
||||
mkdir -p build && cd build
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \
|
||||
|
|
@ -52,9 +46,7 @@ case "$with_tblite" in
|
|||
.. \
|
||||
> cmake.log 2>&1 || tail_excerpt cmake.log
|
||||
make install -j $(get_nprocs) > make.log 2>&1 || tail_excerpt make.log
|
||||
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" \
|
||||
"${SCRIPT_DIR}/stage8/simple-dftd3-${tblite_sdftd3_ver}-gradient-fixes.patch" \
|
||||
"${SCRIPT_DIR}/stage8/dftd4-${tblite_dftd4_ver}-gradient-fixes.patch"
|
||||
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})"
|
||||
cd ..
|
||||
fi
|
||||
;;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue