25#include "../base/base_uses.f90"
30 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
31 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mt_util'
33 INTEGER,
PARAMETER,
PUBLIC ::
mt2d = 1101, &
52 special_dimension, slab_size, super_ref_pw_grid)
55 INTEGER,
INTENT(IN) :: method
56 REAL(kind=
dp),
INTENT(in) :: alpha
57 INTEGER,
INTENT(IN) :: special_dimension
58 REAL(kind=
dp),
INTENT(in) :: slab_size
61 CHARACTER(len=*),
PARAMETER :: routinen =
'MTin_create_screen_fn'
63 INTEGER :: handle, ig, iz
64 REAL(kind=
dp) :: alpha2, g2, g3d, gxy, gz, zlength
69 CALL timeset(routinen, handle)
70 NULLIFY (vloc, vlocg, pw_pool_aux)
75 IF (
ASSOCIATED(super_ref_pw_grid))
THEN
78 NULLIFY (screen_function)
79 ALLOCATE (screen_function)
80 CALL pw_pool%create_pw(screen_function)
85 ALLOCATE (vloc, vlocg)
86 IF (
ASSOCIATED(pw_pool_aux))
THEN
87 CALL pw_pool_aux%create_pw(vloc)
88 CALL pw_pool_aux%create_pw(vlocg)
90 CALL pw_pool%create_pw(vloc)
91 CALL pw_pool%create_pw(vlocg)
93 CALL mt0din(vloc, alpha)
95 CALL pw_axpy(vlocg, screen_function)
96 IF (
ASSOCIATED(pw_pool_aux))
THEN
97 CALL pw_pool_aux%give_back_pw(vloc)
98 CALL pw_pool_aux%give_back_pw(vlocg)
100 CALL pw_pool%give_back_pw(vloc)
101 CALL pw_pool%give_back_pw(vlocg)
103 DEALLOCATE (vloc, vlocg)
108 DO ig = screen_function%pw_grid%first_gne0, screen_function%pw_grid%ngpts_cut_local
109 g2 = screen_function%pw_grid%gsq(ig)
111 screen_function%array(ig) = screen_function%array(ig) - g3d*exp(-g2/(4.0e0_dp*alpha2))
113 IF (screen_function%pw_grid%have_g0) &
114 screen_function%array(1) = screen_function%array(1) +
fourpi/(4.0e0_dp*alpha2)
116 iz = special_dimension
118 DO ig = screen_function%pw_grid%first_gne0, screen_function%pw_grid%ngpts_cut_local
119 gz = screen_function%pw_grid%g(iz, ig)
120 g2 = screen_function%pw_grid%gsq(ig)
121 gxy = sqrt(abs(g2 - gz*gz))
123 screen_function%array(ig) = -g3d*cos(gz*zlength/2.0_dp)*exp(-gxy*zlength/2.0_dp)
125 IF (screen_function%pw_grid%have_g0) screen_function%array(1) =
pi*zlength*zlength/2.0_dp
127 iz = special_dimension
128 CALL mt1din(screen_function)
129 cpabort(
"MT1D unimplemented")
132 CALL timestop(handle)
143 SUBROUTINE mt0din(Vloc, alpha)
145 REAL(kind=
dp),
INTENT(in) :: alpha
147 CHARACTER(len=*),
PARAMETER :: routinen =
'mt0din'
149 INTEGER :: handle, i, ii, j, jj, k, kk
150 INTEGER,
DIMENSION(:),
POINTER :: glb
151 INTEGER,
DIMENSION(:, :),
POINTER :: bo
152 REAL(kind=
dp) :: dx, dy, dz, fact, omega, r, r2, x, y, &
154 REAL(kind=
dp),
DIMENSION(3) :: box, box2
157 CALL timeset(routinen, handle)
160 bo => grid%bounds_local
161 glb => grid%bounds(1, :)
163 box = real(grid%npts, kind=
dp)*grid%dr
171 DO k = bo(1, 3), bo(2, 3)
172 z = real(k - glb(3),
dp)*dz;
IF (z .GT. box2(3)) z = box(3) - z
175 DO j = bo(1, 2), bo(2, 2)
176 y = real(j - glb(2),
dp)*dy;
IF (y .GT. box2(2)) y = box(2) - y
179 DO i = bo(1, 1), bo(2, 1)
180 x = real(i - glb(1),
dp)*dx;
IF (x .GT. box2(1)) x = box(1) - x
183 IF (r .GT. 1.0e-10_dp)
THEN
184 vloc%array(ii, jj, kk) = erf(alpha*r)/r*fact
186 vloc%array(ii, jj, kk) = 2.0_dp*alpha*
oorootpi*fact
194 CALL timestop(handle)
195 END SUBROUTINE mt0din
204 SUBROUTINE mt1din(screen_function)
207 CHARACTER(len=*),
PARAMETER :: routinen =
'mt1din'
210 REAL(kind=
dp) :: dx, dy, dz, omega
211 REAL(kind=
dp),
DIMENSION(3) :: box, box2
214 CALL timeset(routinen, handle)
215 grid => screen_function%pw_grid
216 box = real(grid%npts, kind=
dp)*grid%dr
223 CALL timestop(handle)
224 END SUBROUTINE mt1din
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public martyna1999
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public oorootpi
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public fourpi
integer, parameter, public mt0d
integer, parameter, public mt2d
subroutine, public mtin_create_screen_fn(screen_function, pw_pool, method, alpha, special_dimension, slab_size, super_ref_pw_grid)
Initialize the Martyna && Tuckerman Poisson Solver.
integer, parameter, public mt1d
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public pw_pool_release(pool)
releases the given pool (see cp2k/doc/ReferenceCounting.html)
subroutine, public pw_pool_create(pool, pw_grid, max_cache)
creates a pool for pw
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...