(git:374b731)
Loading...
Searching...
No Matches
ewald_methods_tb.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Calculation of Ewald contributions in DFTB
10!> \author JGH
11! **************************************************************************************************
13 USE atprop_types, ONLY: atprop_type
14 USE cell_types, ONLY: cell_type
15 USE dgs, ONLY: dg_sum_patch,&
20 USE ewald_pw_types, ONLY: ewald_pw_get,&
22 USE kinds, ONLY: dp
23 USE mathconstants, ONLY: fourpi,&
25 USE message_passing, ONLY: mp_comm_type,&
28 USE pme_tools, ONLY: get_center,&
31 USE pw_grids, ONLY: get_pw_grid_info
32 USE pw_methods, ONLY: pw_copy,&
33 pw_derive,&
44 USE pw_types, ONLY: pw_c1d_gs_type,&
60 USE spme, ONLY: get_patch
62 USE virial_types, ONLY: virial_type
63#include "./base/base_uses.f90"
64
65 IMPLICIT NONE
66
67 PRIVATE
68
69 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ewald_methods_tb'
70
72
73CONTAINS
74
75! **************************************************************************************************
76!> \brief ...
77!> \param ewald_env ...
78!> \param ewald_pw ...
79!> \param particle_set ...
80!> \param box ...
81!> \param gmcharge ...
82!> \param mcharge ...
83!> \param calculate_forces ...
84!> \param virial ...
85!> \param use_virial ...
86!> \param atprop ...
87! **************************************************************************************************
88 SUBROUTINE tb_spme_evaluate(ewald_env, ewald_pw, particle_set, box, &
89 gmcharge, mcharge, calculate_forces, virial, use_virial, atprop)
90
91 TYPE(ewald_environment_type), POINTER :: ewald_env
92 TYPE(ewald_pw_type), POINTER :: ewald_pw
93 TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particle_set
94 TYPE(cell_type), POINTER :: box
95 REAL(kind=dp), DIMENSION(:, :), INTENT(inout) :: gmcharge
96 REAL(kind=dp), DIMENSION(:), INTENT(in) :: mcharge
97 LOGICAL, INTENT(in) :: calculate_forces
98 TYPE(virial_type), POINTER :: virial
99 LOGICAL, INTENT(in) :: use_virial
100 TYPE(atprop_type), OPTIONAL, POINTER :: atprop
101
102 CHARACTER(len=*), PARAMETER :: routinen = 'tb_spme_evaluate'
103
104 INTEGER :: handle, i, ig, ipart, j, n, npart, &
105 o_spline, p1
106 INTEGER, ALLOCATABLE, DIMENSION(:, :) :: center
107 INTEGER, DIMENSION(3) :: nd, npts
108 REAL(kind=dp) :: alpha, dvols, fat(3), ffa, ffb, fint, vgc
109 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: delta
110 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: rhos
111 REAL(kind=dp), DIMENSION(3, 3) :: f_stress, h_stress
112 TYPE(greens_fn_type), POINTER :: green
113 TYPE(mp_comm_type) :: group
114 TYPE(mp_para_env_type), POINTER :: para_env
115 TYPE(pw_c1d_gs_type), DIMENSION(3) :: dphi_g
116 TYPE(pw_c1d_gs_type), POINTER :: phi_g, phib_g, rhob_g
117 TYPE(pw_grid_type), POINTER :: grid_spme
118 TYPE(pw_poisson_type), POINTER :: poisson_env
119 TYPE(pw_pool_type), POINTER :: pw_pool
120 TYPE(pw_r3d_rs_type), POINTER :: rhob_r
121 TYPE(realspace_grid_desc_type), POINTER :: rs_desc
122 TYPE(realspace_grid_type) :: rden, rpot
123 TYPE(realspace_grid_type), ALLOCATABLE, &
124 DIMENSION(:) :: drpot
125
126 CALL timeset(routinen, handle)
127 !-------------- INITIALISATION ---------------------
128 CALL ewald_env_get(ewald_env, alpha=alpha, o_spline=o_spline, group=group, &
129 para_env=para_env)
130 NULLIFY (green, poisson_env, pw_pool)
131 CALL ewald_pw_get(ewald_pw, pw_big_pool=pw_pool, rs_desc=rs_desc, &
132 poisson_env=poisson_env)
133 CALL pw_poisson_rebuild(poisson_env)
134 green => poisson_env%green_fft
135 grid_spme => pw_pool%pw_grid
136
137 CALL get_pw_grid_info(grid_spme, dvol=dvols, npts=npts)
138
139 npart = SIZE(particle_set)
140
141 n = o_spline
142 ALLOCATE (rhos(n, n, n))
143
144 CALL rs_grid_create(rden, rs_desc)
145 CALL rs_grid_set_box(grid_spme, rs=rden)
146 CALL rs_grid_zero(rden)
147
148 ALLOCATE (center(3, npart), delta(3, npart))
149 CALL get_center(particle_set, box, center, delta, npts, n)
150
151 !-------------- DENSITY CALCULATION ----------------
152 ipart = 0
153 DO
154 CALL set_list(particle_set, npart, center, p1, rden, ipart)
155 IF (p1 == 0) EXIT
156
157 ! calculate function on small boxes
158 CALL get_patch(particle_set, delta, green, p1, rhos, is_core=.false., &
159 is_shell=.false., unit_charge=.true.)
160 rhos(:, :, :) = rhos(:, :, :)*mcharge(p1)
161
162 ! add boxes to real space grid (big box)
163 CALL dg_sum_patch(rden, rhos, center(:, p1))
164 END DO
165
166 NULLIFY (rhob_r)
167 ALLOCATE (rhob_r)
168 CALL pw_pool%create_pw(rhob_r)
169
170 CALL transfer_rs2pw(rden, rhob_r)
171
172 ! transform density to G space and add charge function
173 NULLIFY (rhob_g)
174 ALLOCATE (rhob_g)
175 CALL pw_pool%create_pw(rhob_g)
176 CALL pw_transfer(rhob_r, rhob_g)
177 ! update charge function
178 CALL pw_multiply_with(rhob_g, green%p3m_charge)
179
180 !-------------- ELECTROSTATIC CALCULATION -----------
181
182 ! allocate intermediate arrays
183 DO i = 1, 3
184 CALL pw_pool%create_pw(dphi_g(i))
185 END DO
186 NULLIFY (phi_g)
187 ALLOCATE (phi_g)
188 CALL pw_pool%create_pw(phi_g)
189 IF (use_virial) THEN
190 CALL pw_poisson_solve(poisson_env, rhob_g, vgc, phi_g, dphi_g, h_stress=h_stress)
191 ELSE
192 CALL pw_poisson_solve(poisson_env, rhob_g, vgc, phi_g, dphi_g)
193 END IF
194
195 CALL rs_grid_create(rpot, rs_desc)
196 CALL rs_grid_set_box(grid_spme, rs=rpot)
197
198 ! Atomic Stress
199 IF (PRESENT(atprop)) THEN
200 IF (ASSOCIATED(atprop)) THEN
201 IF (atprop%stress .AND. use_virial) THEN
202
203 CALL rs_grid_zero(rpot)
204 CALL pw_zero(rhob_g)
205 CALL pw_multiply(rhob_g, phi_g, green%p3m_charge)
206 CALL pw_transfer(rhob_g, rhob_r)
207 CALL transfer_pw2rs(rpot, rhob_r)
208 ipart = 0
209 DO
210 CALL set_list(particle_set, npart, center, p1, rden, ipart)
211 IF (p1 == 0) EXIT
212 ! calculate function on small boxes
213 CALL get_patch(particle_set, delta, green, p1, rhos, is_core=.false., &
214 is_shell=.false., unit_charge=.true.)
215 CALL dg_sum_patch_force_1d(rpot, rhos, center(:, p1), fint)
216 atprop%atstress(1, 1, p1) = atprop%atstress(1, 1, p1) + 0.5_dp*mcharge(p1)*fint*dvols
217 atprop%atstress(2, 2, p1) = atprop%atstress(2, 2, p1) + 0.5_dp*mcharge(p1)*fint*dvols
218 atprop%atstress(3, 3, p1) = atprop%atstress(3, 3, p1) + 0.5_dp*mcharge(p1)*fint*dvols
219 END DO
220
221 NULLIFY (phib_g)
222 ALLOCATE (phib_g)
223 CALL pw_pool%create_pw(phib_g)
224 ffa = (0.5_dp/alpha)**2
225 ffb = 1.0_dp/fourpi
226 DO i = 1, 3
227 DO ig = grid_spme%first_gne0, grid_spme%ngpts_cut_local
228 phib_g%array(ig) = ffb*dphi_g(i)%array(ig)*(1.0_dp + ffa*grid_spme%gsq(ig))
229 phib_g%array(ig) = phib_g%array(ig)*green%influence_fn%array(ig)
230 END DO
231 IF (grid_spme%have_g0) phib_g%array(1) = 0.0_dp
232 DO j = 1, i
233 nd = 0
234 nd(j) = 1
235 CALL pw_copy(phib_g, rhob_g)
236 CALL pw_derive(rhob_g, nd)
237 CALL pw_multiply_with(rhob_g, green%p3m_charge)
238 CALL pw_transfer(rhob_g, rhob_r)
239 CALL transfer_pw2rs(rpot, rhob_r)
240
241 ipart = 0
242 DO
243 CALL set_list(particle_set, npart, center, p1, rden, ipart)
244 IF (p1 == 0) EXIT
245 ! calculate function on small boxes
246 CALL get_patch(particle_set, delta, green, p1, rhos, &
247 is_core=.false., is_shell=.false., unit_charge=.true.)
248 ! integrate box and potential
249 CALL dg_sum_patch_force_1d(rpot, rhos, center(:, p1), fint)
250 atprop%atstress(i, j, p1) = atprop%atstress(i, j, p1) + fint*dvols*mcharge(p1)
251 IF (i /= j) atprop%atstress(j, i, p1) = atprop%atstress(j, i, p1) + fint*dvols*mcharge(p1)
252 END DO
253
254 END DO
255 END DO
256 CALL pw_pool%give_back_pw(phib_g)
257 DEALLOCATE (phib_g)
258
259 END IF
260 END IF
261 END IF
262
263 CALL pw_pool%give_back_pw(rhob_g)
264 DEALLOCATE (rhob_g)
265
266 CALL rs_grid_zero(rpot)
267 CALL pw_multiply_with(phi_g, green%p3m_charge)
268 CALL pw_transfer(phi_g, rhob_r)
269 CALL pw_pool%give_back_pw(phi_g)
270 DEALLOCATE (phi_g)
271 CALL transfer_pw2rs(rpot, rhob_r)
272
273 !---------- END OF ELECTROSTATIC CALCULATION --------
274
275 !------------- STRESS TENSOR CALCULATION ------------
276
277 IF (use_virial) THEN
278 DO i = 1, 3
279 DO j = i, 3
280 f_stress(i, j) = pw_integral_a2b(dphi_g(i), dphi_g(j))
281 f_stress(j, i) = f_stress(i, j)
282 END DO
283 END DO
284 ffa = (1.0_dp/fourpi)*(0.5_dp/alpha)**2
285 virial%pv_virial = virial%pv_virial - (ffa*f_stress - h_stress)/real(para_env%num_pe, dp)
286 END IF
287
288 !--------END OF STRESS TENSOR CALCULATION -----------
289
290 IF (calculate_forces) THEN
291 ! move derivative of potential to real space grid and
292 ! multiply by charge function in g-space
293 ALLOCATE (drpot(3))
294 DO i = 1, 3
295 CALL rs_grid_create(drpot(i), rs_desc)
296 CALL rs_grid_set_box(grid_spme, rs=drpot(i))
297 CALL pw_multiply_with(dphi_g(i), green%p3m_charge)
298 CALL pw_transfer(dphi_g(i), rhob_r)
299 CALL pw_pool%give_back_pw(dphi_g(i))
300 CALL transfer_pw2rs(drpot(i), rhob_r)
301 END DO
302 ELSE
303 DO i = 1, 3
304 CALL pw_pool%give_back_pw(dphi_g(i))
305 END DO
306 END IF
307 CALL pw_pool%give_back_pw(rhob_r)
308 DEALLOCATE (rhob_r)
309
310 !----------------- FORCE CALCULATION ----------------
311
312 ipart = 0
313 DO
314
315 CALL set_list(particle_set, npart, center, p1, rden, ipart)
316 IF (p1 == 0) EXIT
317
318 ! calculate function on small boxes
319 CALL get_patch(particle_set, delta, green, p1, rhos, is_core=.false., &
320 is_shell=.false., unit_charge=.true.)
321
322 CALL dg_sum_patch_force_1d(rpot, rhos, center(:, p1), fint)
323 gmcharge(p1, 1) = gmcharge(p1, 1) + fint*dvols
324
325 IF (calculate_forces) THEN
326 CALL dg_sum_patch_force_3d(drpot, rhos, center(:, p1), fat)
327 gmcharge(p1, 2) = gmcharge(p1, 2) - fat(1)*dvols
328 gmcharge(p1, 3) = gmcharge(p1, 3) - fat(2)*dvols
329 gmcharge(p1, 4) = gmcharge(p1, 4) - fat(3)*dvols
330 END IF
331
332 END DO
333
334 !--------------END OF FORCE CALCULATION -------------
335
336 !------------------CLEANING UP ----------------------
337
338 CALL rs_grid_release(rden)
339 CALL rs_grid_release(rpot)
340 IF (calculate_forces) THEN
341 DO i = 1, 3
342 CALL rs_grid_release(drpot(i))
343 END DO
344 DEALLOCATE (drpot)
345 END IF
346 DEALLOCATE (rhos)
347 DEALLOCATE (center, delta)
348
349 CALL timestop(handle)
350
351 END SUBROUTINE tb_spme_evaluate
352
353! **************************************************************************************************
354!> \brief ...
355!> \param gmcharge ...
356!> \param mcharge ...
357!> \param alpha ...
358!> \param n_list ...
359!> \param virial ...
360!> \param use_virial ...
361!> \param atprop ...
362! **************************************************************************************************
363 SUBROUTINE tb_ewald_overlap(gmcharge, mcharge, alpha, n_list, virial, use_virial, atprop)
364
365 REAL(kind=dp), DIMENSION(:, :), INTENT(inout) :: gmcharge
366 REAL(kind=dp), DIMENSION(:), INTENT(in) :: mcharge
367 REAL(kind=dp), INTENT(in) :: alpha
368 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
369 POINTER :: n_list
370 TYPE(virial_type), POINTER :: virial
371 LOGICAL, INTENT(IN) :: use_virial
372 TYPE(atprop_type), OPTIONAL, POINTER :: atprop
373
374 CHARACTER(LEN=*), PARAMETER :: routinen = 'tb_ewald_overlap'
375
376 INTEGER :: handle, i, iatom, jatom, nmat
377 REAL(kind=dp) :: dfr, dr, fr, pfr, rij(3)
379 DIMENSION(:), POINTER :: nl_iterator
380
381 CALL timeset(routinen, handle)
382
383 nmat = SIZE(gmcharge, 2)
384
385 CALL neighbor_list_iterator_create(nl_iterator, n_list)
386 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
387 CALL get_iterator_info(nl_iterator, iatom=iatom, jatom=jatom, r=rij)
388
389 dr = sqrt(sum(rij(:)**2))
390 IF (dr > 1.e-10) THEN
391 fr = erfc(alpha*dr)/dr
392 gmcharge(iatom, 1) = gmcharge(iatom, 1) + mcharge(jatom)*fr
393 gmcharge(jatom, 1) = gmcharge(jatom, 1) + mcharge(iatom)*fr
394 IF (nmat > 1) THEN
395 dfr = -2._dp*alpha*exp(-alpha*alpha*dr*dr)*oorootpi/dr - fr/dr
396 dfr = -dfr/dr
397 DO i = 2, nmat
398 gmcharge(iatom, i) = gmcharge(iatom, i) - rij(i - 1)*mcharge(jatom)*dfr
399 gmcharge(jatom, i) = gmcharge(jatom, i) + rij(i - 1)*mcharge(iatom)*dfr
400 END DO
401 END IF
402 IF (use_virial) THEN
403 IF (iatom == jatom) THEN
404 pfr = -0.5_dp*dfr*mcharge(iatom)*mcharge(jatom)
405 ELSE
406 pfr = -dfr*mcharge(iatom)*mcharge(jatom)
407 END IF
408 CALL virial_pair_force(virial%pv_virial, -pfr, rij, rij)
409 IF (PRESENT(atprop)) THEN
410 IF (ASSOCIATED(atprop)) THEN
411 IF (atprop%stress) THEN
412 CALL virial_pair_force(atprop%atstress(:, :, iatom), -0.5_dp*pfr, rij, rij)
413 CALL virial_pair_force(atprop%atstress(:, :, jatom), -0.5_dp*pfr, rij, rij)
414 END IF
415 END IF
416 END IF
417 END IF
418 END IF
419
420 END DO
421 CALL neighbor_list_iterator_release(nl_iterator)
422
423 CALL timestop(handle)
424
425 END SUBROUTINE tb_ewald_overlap
426
427! **************************************************************************************************
428!> \brief ...
429!> \param ewald_env ...
430!> \param ewald_pw ...
431!> \param particle_set ...
432!> \param box ...
433!> \param gmcharge ...
434!> \param mcharge ...
435! **************************************************************************************************
436 SUBROUTINE tb_spme_zforce(ewald_env, ewald_pw, particle_set, box, gmcharge, mcharge)
437
438 TYPE(ewald_environment_type), POINTER :: ewald_env
439 TYPE(ewald_pw_type), POINTER :: ewald_pw
440 TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particle_set
441 TYPE(cell_type), POINTER :: box
442 REAL(kind=dp), DIMENSION(:, :), INTENT(inout) :: gmcharge
443 REAL(kind=dp), DIMENSION(:), INTENT(in) :: mcharge
444
445 CHARACTER(len=*), PARAMETER :: routinen = 'tb_spme_zforce'
446
447 INTEGER :: handle, i, ipart, n, npart, o_spline, p1
448 INTEGER, ALLOCATABLE, DIMENSION(:, :) :: center
449 INTEGER, DIMENSION(3) :: npts
450 REAL(kind=dp) :: alpha, dvols, fat(3), fint, vgc
451 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: delta
452 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: rhos
453 TYPE(greens_fn_type), POINTER :: green
454 TYPE(mp_comm_type) :: group
455 TYPE(mp_para_env_type), POINTER :: para_env
456 TYPE(pw_c1d_gs_type), DIMENSION(3) :: dphi_g
457 TYPE(pw_c1d_gs_type), POINTER :: phi_g, rhob_g
458 TYPE(pw_grid_type), POINTER :: grid_spme
459 TYPE(pw_poisson_type), POINTER :: poisson_env
460 TYPE(pw_pool_type), POINTER :: pw_pool
461 TYPE(pw_r3d_rs_type), POINTER :: rhob_r
462 TYPE(realspace_grid_desc_type), POINTER :: rs_desc
463 TYPE(realspace_grid_type) :: rden, rpot
464 TYPE(realspace_grid_type), DIMENSION(3) :: drpot
465
466 CALL timeset(routinen, handle)
467 !-------------- INITIALISATION ---------------------
468 CALL ewald_env_get(ewald_env, alpha=alpha, o_spline=o_spline, group=group, &
469 para_env=para_env)
470 NULLIFY (green, poisson_env, pw_pool)
471 CALL ewald_pw_get(ewald_pw, pw_big_pool=pw_pool, rs_desc=rs_desc, &
472 poisson_env=poisson_env)
473 CALL pw_poisson_rebuild(poisson_env)
474 green => poisson_env%green_fft
475 grid_spme => pw_pool%pw_grid
476
477 CALL get_pw_grid_info(grid_spme, dvol=dvols, npts=npts)
478
479 npart = SIZE(particle_set)
480
481 n = o_spline
482 ALLOCATE (rhos(n, n, n))
483
484 CALL rs_grid_create(rden, rs_desc)
485 CALL rs_grid_set_box(grid_spme, rs=rden)
486 CALL rs_grid_zero(rden)
487
488 ALLOCATE (center(3, npart), delta(3, npart))
489 CALL get_center(particle_set, box, center, delta, npts, n)
490
491 !-------------- DENSITY CALCULATION ----------------
492 ipart = 0
493 DO
494 CALL set_list(particle_set, npart, center, p1, rden, ipart)
495 IF (p1 == 0) EXIT
496
497 ! calculate function on small boxes
498 CALL get_patch(particle_set, delta, green, p1, rhos, is_core=.false., &
499 is_shell=.false., unit_charge=.true.)
500 rhos(:, :, :) = rhos(:, :, :)*mcharge(p1)
501
502 ! add boxes to real space grid (big box)
503 CALL dg_sum_patch(rden, rhos, center(:, p1))
504 END DO
505
506 NULLIFY (rhob_r)
507 ALLOCATE (rhob_r)
508 CALL pw_pool%create_pw(rhob_r)
509
510 CALL transfer_rs2pw(rden, rhob_r)
511
512 ! transform density to G space and add charge function
513 NULLIFY (rhob_g)
514 ALLOCATE (rhob_g)
515 CALL pw_pool%create_pw(rhob_g)
516 CALL pw_transfer(rhob_r, rhob_g)
517 ! update charge function
518 CALL pw_multiply_with(rhob_g, green%p3m_charge)
519
520 !-------------- ELECTROSTATIC CALCULATION -----------
521
522 ! allocate intermediate arrays
523 DO i = 1, 3
524 CALL pw_pool%create_pw(dphi_g(i))
525 END DO
526 NULLIFY (phi_g)
527 ALLOCATE (phi_g)
528 CALL pw_pool%create_pw(phi_g)
529 CALL pw_poisson_solve(poisson_env, rhob_g, vgc, phi_g, dphi_g)
530
531 CALL rs_grid_create(rpot, rs_desc)
532 CALL rs_grid_set_box(grid_spme, rs=rpot)
533
534 CALL pw_pool%give_back_pw(rhob_g)
535 DEALLOCATE (rhob_g)
536
537 CALL rs_grid_zero(rpot)
538 CALL pw_multiply_with(phi_g, green%p3m_charge)
539 CALL pw_transfer(phi_g, rhob_r)
540 CALL pw_pool%give_back_pw(phi_g)
541 DEALLOCATE (phi_g)
542 CALL transfer_pw2rs(rpot, rhob_r)
543
544 !---------- END OF ELECTROSTATIC CALCULATION --------
545
546 ! move derivative of potential to real space grid and
547 ! multiply by charge function in g-space
548 DO i = 1, 3
549 CALL rs_grid_create(drpot(i), rs_desc)
550 CALL rs_grid_set_box(grid_spme, rs=drpot(i))
551 CALL pw_multiply_with(dphi_g(i), green%p3m_charge)
552 CALL pw_transfer(dphi_g(i), rhob_r)
553 CALL pw_pool%give_back_pw(dphi_g(i))
554 CALL transfer_pw2rs(drpot(i), rhob_r)
555 END DO
556 CALL pw_pool%give_back_pw(rhob_r)
557 DEALLOCATE (rhob_r)
558
559 !----------------- FORCE CALCULATION ----------------
560
561 ipart = 0
562 DO
563
564 CALL set_list(particle_set, npart, center, p1, rden, ipart)
565 IF (p1 == 0) EXIT
566
567 ! calculate function on small boxes
568 CALL get_patch(particle_set, delta, green, p1, rhos, is_core=.false., &
569 is_shell=.false., unit_charge=.true.)
570
571 CALL dg_sum_patch_force_1d(rpot, rhos, center(:, p1), fint)
572 gmcharge(p1, 1) = gmcharge(p1, 1) + fint*dvols
573
574 CALL dg_sum_patch_force_3d(drpot, rhos, center(:, p1), fat)
575 gmcharge(p1, 2) = gmcharge(p1, 2) - fat(1)*dvols
576 gmcharge(p1, 3) = gmcharge(p1, 3) - fat(2)*dvols
577 gmcharge(p1, 4) = gmcharge(p1, 4) - fat(3)*dvols
578
579 END DO
580
581 !--------------END OF FORCE CALCULATION -------------
582
583 !------------------CLEANING UP ----------------------
584
585 CALL rs_grid_release(rden)
586 CALL rs_grid_release(rpot)
587 DO i = 1, 3
588 CALL rs_grid_release(drpot(i))
589 END DO
590 DEALLOCATE (rhos)
591 DEALLOCATE (center, delta)
592
593 CALL timestop(handle)
594
595 END SUBROUTINE tb_spme_zforce
596
597END MODULE ewald_methods_tb
598
Holds information on atomic properties.
Handles all functions related to the CELL.
Definition cell_types.F:15
Definition dgs.F:13
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
Calculation of Ewald contributions in DFTB.
subroutine, public tb_spme_zforce(ewald_env, ewald_pw, particle_set, box, gmcharge, mcharge)
...
subroutine, public tb_ewald_overlap(gmcharge, mcharge, alpha, n_list, virial, use_virial, atprop)
...
subroutine, public tb_spme_evaluate(ewald_env, ewald_pw, particle_set, box, gmcharge, mcharge, calculate_forces, virial, use_virial, atprop)
...
subroutine, public ewald_pw_get(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, poisson_env, dg)
get the ewald_pw environment to the correct program.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public oorootpi
real(kind=dp), parameter, public fourpi
Interface to the message passing library MPI.
Define the data structure for the particle information.
Tools common both to PME and SPME.
Definition pme_tools.F:15
subroutine, public get_center(part, box, center, delta, npts, n)
...
Definition pme_tools.F:131
subroutine, public set_list(part, npart, center, p1, rs, ipart, core_center)
...
Definition pme_tools.F:46
This module defines the grid data type and some basic operations on it.
Definition pw_grids.F:36
subroutine, public get_pw_grid_info(pw_grid, id_nr, mode, vol, dvol, npts, ngpts, ngpts_cut, dr, cutoff, orthorhombic, gvectors, gsquare)
Access to information stored in the pw_grid_type.
Definition pw_grids.F:184
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
subroutine, public rs_grid_create(rs, desc)
...
subroutine, public transfer_pw2rs(rs, pw)
...
subroutine, public rs_grid_set_box(pw_grid, rs)
Set box matrix info for real space grid This is needed for variable cell simulations.
subroutine, public transfer_rs2pw(rs, pw)
...
subroutine, public rs_grid_release(rs_grid)
releases the given rs grid (see doc/ReferenceCounting.html)
subroutine, public rs_grid_zero(rs)
Initialize grid to zero.
Calculate the electrostatic energy by the Smooth Particle Ewald method.
Definition spme.F:14
pure subroutine, public virial_pair_force(pv_virial, f0, force, rab)
Computes the contribution to the stress tensor from two-body pair-wise forces.
type for the atomic properties
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
stores all the informations relevant to an mpi environment
contains all the informations needed by the fft based poisson solvers
environment for the poisson solver
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...