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, &
49 REAL(kind=
dp),
INTENT(IN) :: g(3)
50 INTEGER,
INTENT(IN) :: special_dimension
51 REAL(kind=
dp),
INTENT(IN) :: slab_size
52 REAL(kind=
dp),
INTENT(OUT) :: kernel, strain(3, 3)
54 INTEGER :: alpha, beta
55 REAL(kind=
dp) :: f, g2, k, parallel(3), q, radius
57 cpassert(special_dimension >= 1 .AND. special_dimension <= 3)
58 cpassert(slab_size > 0.0_dp)
61 IF (g2 == 0.0_dp)
THEN
64 kernel =
pi*slab_size**2/2.0_dp
68 parallel(special_dimension) = 0.0_dp
70 radius = slab_size/2.0_dp
71 q = cos(g(special_dimension)*radius)*exp(-k*radius)
76 IF (k == 0.0_dp)
RETURN
78 IF (alpha == special_dimension) cycle
80 IF (beta == special_dimension) cycle
81 strain(alpha, beta) =
fourpi/g2*g(alpha)*g(beta)*(2.0_dp*f/g2 - q*radius/k)
82 strain(beta, alpha) = strain(alpha, beta)
99 special_dimension, slab_size, super_ref_pw_grid)
102 INTEGER,
INTENT(IN) :: method
103 REAL(kind=
dp),
INTENT(in) :: alpha
104 INTEGER,
INTENT(IN) :: special_dimension
105 REAL(kind=
dp),
INTENT(in) :: slab_size
108 CHARACTER(len=*),
PARAMETER :: routinen =
'MTin_create_screen_fn'
110 INTEGER :: handle, ig, iz
111 REAL(kind=
dp) :: alpha2, g2, g3d, gxy, gz, zlength
116 CALL timeset(routinen, handle)
117 NULLIFY (vloc, vlocg, pw_pool_aux)
122 IF (
ASSOCIATED(super_ref_pw_grid))
THEN
125 NULLIFY (screen_function)
126 ALLOCATE (screen_function)
127 CALL pw_pool%create_pw(screen_function)
131 NULLIFY (vloc, vlocg)
132 ALLOCATE (vloc, vlocg)
133 IF (
ASSOCIATED(pw_pool_aux))
THEN
134 CALL pw_pool_aux%create_pw(vloc)
135 CALL pw_pool_aux%create_pw(vlocg)
137 CALL pw_pool%create_pw(vloc)
138 CALL pw_pool%create_pw(vlocg)
140 CALL mt0din(vloc, alpha)
142 CALL pw_axpy(vlocg, screen_function)
143 IF (
ASSOCIATED(pw_pool_aux))
THEN
144 CALL pw_pool_aux%give_back_pw(vloc)
145 CALL pw_pool_aux%give_back_pw(vlocg)
147 CALL pw_pool%give_back_pw(vloc)
148 CALL pw_pool%give_back_pw(vlocg)
150 DEALLOCATE (vloc, vlocg)
155 DO ig = screen_function%pw_grid%first_gne0, screen_function%pw_grid%ngpts_cut_local
156 g2 = screen_function%pw_grid%gsq(ig)
158 screen_function%array(ig) = screen_function%array(ig) - g3d*exp(-g2/(4.0e0_dp*alpha2))
160 IF (screen_function%pw_grid%have_g0)
THEN
161 screen_function%array(1) = screen_function%array(1) +
fourpi/(4.0e0_dp*alpha2)
164 iz = special_dimension
166 DO ig = screen_function%pw_grid%first_gne0, screen_function%pw_grid%ngpts_cut_local
167 gz = screen_function%pw_grid%g(iz, ig)
168 g2 = screen_function%pw_grid%gsq(ig)
169 gxy = sqrt(abs(g2 - gz*gz))
171 screen_function%array(ig) = -g3d*cos(gz*zlength/2.0_dp)*exp(-gxy*zlength/2.0_dp)
173 IF (screen_function%pw_grid%have_g0) screen_function%array(1) =
pi*zlength*zlength/2.0_dp
175 iz = special_dimension
176 CALL mt1din(screen_function)
177 cpabort(
"MT1D unimplemented")
180 CALL timestop(handle)
191 SUBROUTINE mt0din(Vloc, alpha)
193 REAL(kind=
dp),
INTENT(in) :: alpha
195 CHARACTER(len=*),
PARAMETER :: routinen =
'mt0din'
197 INTEGER :: handle, i, ii, j, jj, k, kk
198 INTEGER,
DIMENSION(:),
POINTER :: glb
199 INTEGER,
DIMENSION(:, :),
POINTER :: bo
200 REAL(kind=
dp) :: dx, dy, dz, fact, omega, r, r2, x, y, &
202 REAL(kind=
dp),
DIMENSION(3) :: box, box2
205 CALL timeset(routinen, handle)
208 bo => grid%bounds_local
209 glb => grid%bounds(1, :)
211 box = real(grid%npts, kind=
dp)*grid%dr
219 DO k = bo(1, 3), bo(2, 3)
220 z = real(k - glb(3),
dp)*dz;
IF (z > box2(3)) z = box(3) - z
223 DO j = bo(1, 2), bo(2, 2)
224 y = real(j - glb(2),
dp)*dy;
IF (y > box2(2)) y = box(2) - y
227 DO i = bo(1, 1), bo(2, 1)
228 x = real(i - glb(1),
dp)*dx;
IF (x > box2(1)) x = box(1) - x
231 IF (r > 1.0e-10_dp)
THEN
232 vloc%array(ii, jj, kk) = erf(alpha*r)/r*fact
234 vloc%array(ii, jj, kk) = 2.0_dp*alpha*
oorootpi*fact
242 CALL timestop(handle)
243 END SUBROUTINE mt0din
252 SUBROUTINE mt1din(screen_function)
255 CHARACTER(len=*),
PARAMETER :: routinen =
'mt1din'
258 REAL(kind=
dp) :: dx, dy, dz, omega
259 REAL(kind=
dp),
DIMENSION(3) :: box, box2
262 CALL timeset(routinen, handle)
263 grid => screen_function%pw_grid
264 box = real(grid%npts, kind=
dp)*grid%dr
271 CALL timestop(handle)
272 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
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 ...