26#include "../base/base_uses.f90"
31 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
32 CHARACTER(LEN=*),
PARAMETER,
PRIVATE :: moduleN =
'mt_util'
34 INTEGER,
PARAMETER,
PUBLIC ::
mt2d = 1101, &
50 REAL(kind=
dp),
INTENT(IN) :: g(3)
51 INTEGER,
INTENT(IN) :: special_dimension
52 REAL(kind=
dp),
INTENT(IN) :: slab_size
53 REAL(kind=
dp),
INTENT(OUT) :: kernel, strain(3, 3)
55 INTEGER :: alpha, beta
56 REAL(kind=
dp) :: f, g2, k, parallel(3), q, radius
58 cpassert(special_dimension >= 1 .AND. special_dimension <= 3)
59 cpassert(slab_size > 0.0_dp)
62 IF (g2 == 0.0_dp)
THEN
65 kernel =
pi*slab_size**2/2.0_dp
69 parallel(special_dimension) = 0.0_dp
71 radius = slab_size/2.0_dp
72 q = cos(g(special_dimension)*radius)*exp(-k*radius)
77 IF (k == 0.0_dp)
RETURN
79 IF (alpha == special_dimension) cycle
81 IF (beta == special_dimension) cycle
82 strain(alpha, beta) =
fourpi/g2*g(alpha)*g(beta)*(2.0_dp*f/g2 - q*radius/k)
83 strain(beta, alpha) = strain(alpha, beta)
100 special_dimension, slab_size, super_ref_pw_grid)
103 INTEGER,
INTENT(IN) :: method
104 REAL(kind=
dp),
INTENT(IN) :: alpha
105 INTEGER,
INTENT(IN) :: special_dimension
106 REAL(kind=
dp),
INTENT(IN) :: slab_size
109 CHARACTER(LEN=*),
PARAMETER :: routinen =
'MTin_create_screen_fn'
111 INTEGER :: handle, ig, iz
112 REAL(kind=
dp) :: alpha2, g2, g3d, gxy, gz, zlength
117 CALL timeset(routinen, handle)
118 NULLIFY (vloc, vlocg, pw_pool_aux)
123 IF (
ASSOCIATED(super_ref_pw_grid))
THEN
126 NULLIFY (screen_function)
127 ALLOCATE (screen_function)
128 CALL pw_pool%create_pw(screen_function)
132 NULLIFY (vloc, vlocg)
133 ALLOCATE (vloc, vlocg)
134 IF (
ASSOCIATED(pw_pool_aux))
THEN
135 CALL pw_pool_aux%create_pw(vloc)
136 CALL pw_pool_aux%create_pw(vlocg)
138 CALL pw_pool%create_pw(vloc)
139 CALL pw_pool%create_pw(vlocg)
141 CALL mt0din(vloc, alpha)
143 CALL pw_axpy(vlocg, screen_function)
144 IF (
ASSOCIATED(pw_pool_aux))
THEN
145 CALL pw_pool_aux%give_back_pw(vloc)
146 CALL pw_pool_aux%give_back_pw(vlocg)
148 CALL pw_pool%give_back_pw(vloc)
149 CALL pw_pool%give_back_pw(vlocg)
151 DEALLOCATE (vloc, vlocg)
158 DO ig = screen_function%pw_grid%first_gne0, screen_function%pw_grid%ngpts_cut_local
159 g2 = screen_function%pw_grid%gsq(ig)
161 screen_function%array(ig) = screen_function%array(ig) - g3d*exp(-g2/(4.0e0_dp*alpha2))
164 IF (screen_function%pw_grid%have_g0)
THEN
165 screen_function%array(1) = screen_function%array(1) +
fourpi/(4.0e0_dp*alpha2)
168 iz = special_dimension
172 DO ig = screen_function%pw_grid%first_gne0, screen_function%pw_grid%ngpts_cut_local
173 gz = screen_function%pw_grid%g(iz, ig)
174 g2 = screen_function%pw_grid%gsq(ig)
175 gxy = sqrt(abs(g2 - gz*gz))
177 screen_function%array(ig) = -g3d*cos(gz*zlength/2.0_dp)*exp(-gxy*zlength/2.0_dp)
180 IF (screen_function%pw_grid%have_g0) screen_function%array(1) =
pi*zlength*zlength/2.0_dp
182 iz = special_dimension
183 CALL mt1din(screen_function)
184 cpabort(
"MT1D unimplemented")
187 CALL timestop(handle)
198 SUBROUTINE mt0din(Vloc, alpha)
200 REAL(kind=
dp),
INTENT(IN) :: alpha
202 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mt0din'
204 INTEGER :: handle, i, j, k
205 INTEGER,
DIMENSION(:),
POINTER :: glb
206 INTEGER,
DIMENSION(:, :),
POINTER :: bo
207 REAL(kind=
dp) :: dx, dy, dz, fact, omega, r, r2, x, y, &
209 REAL(kind=
dp),
DIMENSION(3) :: box, box2
212 CALL timeset(routinen, handle)
215 bo => grid%bounds_local
216 glb => grid%bounds(1, :)
218 box = real(grid%npts, kind=
dp)*grid%dr
227 DO k = bo(1, 3), bo(2, 3)
228 z = real(k - glb(3),
dp)*dz;
IF (z > box2(3)) z = box(3) - z
230 DO j = bo(1, 2), bo(2, 2)
231 y = real(j - glb(2),
dp)*dy;
IF (y > box2(2)) y = box(2) - y
233 DO i = bo(1, 1), bo(2, 1)
234 x = real(i - glb(1),
dp)*dx;
IF (x > box2(1)) x = box(1) - x
237 IF (r > 1.0e-10_dp)
THEN
238 vloc%array(i, j, k) = erf(alpha*r)/r*fact
240 vloc%array(i, j, k) = 2.0_dp*alpha*
oorootpi*fact
246 CALL timestop(handle)
247 END SUBROUTINE mt0din
256 SUBROUTINE mt1din(screen_function)
259 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mt1din'
262 REAL(kind=
dp) :: dx, dy, dz, omega
263 REAL(kind=
dp),
DIMENSION(3) :: box, box2
266 CALL timeset(routinen, handle)
267 grid => screen_function%pw_grid
268 box = real(grid%npts, kind=
dp)*grid%dr
275 CALL timestop(handle)
276 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 int_8
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
subroutine, public mt2d_kernel_strain(g, special_dimension, slab_size, kernel, strain)
MT2D Coulomb kernel and its affine strain derivative in the periodic plane.
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 ...