(git:374b731)
Loading...
Searching...
No Matches
hfx_helpers.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 Some auxiliary functions and subroutines needed for HFX calculations
10!> \par History
11!> 04.2008 created [Manuel Guidon]
12!> \author Manuel Guidon
13! **************************************************************************************************
15#include "./base/base_uses.f90"
16 IMPLICIT NONE
17 PRIVATE
18
19 PUBLIC :: count_cells_perd, &
21
22 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'hfx_helpers'
23
24!***
25
26CONTAINS
27
28! **************************************************************************************************
29!> \brief - Auxiliary function for creating periodic neighbor cells
30!> \param shell number of shells in each coordinate direction
31!> \param perd ...
32!> \return ...
33!> \par History
34!> 09.2007 created [Manuel Guidon]
35!> \author Manuel Guidon
36! **************************************************************************************************
37 FUNCTION count_cells_perd(shell, perd)
38 INTEGER, INTENT(IN) :: shell, perd(3)
39 INTEGER :: count_cells_perd
40
41 INTEGER :: i, j, k
42
44 DO i = -shell*perd(1), shell*perd(1)
45 DO j = -shell*perd(2), shell*perd(2)
46 DO k = -shell*perd(3), shell*perd(3)
47 IF ((i**2 + j**2 + k**2 == shell)) count_cells_perd = count_cells_perd + 1
48 END DO
49 END DO
50 END DO
51 END FUNCTION count_cells_perd
52
53! **************************************************************************************************
54!> \brief - Auxiliary function for creating periodic neighbor cells
55!> \param m ...
56!> \param perd ...
57!> \par History
58!> 09.2007 created [Manuel Guidon]
59!> \author Manuel Guidon
60! **************************************************************************************************
61 SUBROUTINE next_image_cell_perd(m, perd)
62 INTEGER :: m(3)
63 INTEGER, INTENT(IN) :: perd(3)
64
65 INTEGER :: i, j, k, shell
66 LOGICAL :: found
67
68 found = .false.
69 shell = sum(m**2)
70 outer: DO
71 DO i = -shell*perd(1), shell*perd(1)
72 DO j = -shell*perd(2), shell*perd(2)
73 inner: DO k = -shell*perd(3), shell*perd(3)
74 IF (.NOT. (i**2 + j**2 + k**2 == shell)) cycle inner
75 IF (found) THEN
76 m = (/i, j, k/)
77 EXIT outer
78 END IF
79 IF (all(m .EQ. (/i, j, k/))) found = .true.
80 END DO inner
81 END DO
82 END DO
83 shell = shell + 1
84 END DO outer
85 END SUBROUTINE next_image_cell_perd
86
87! **************************************************************************************************
88
89END MODULE hfx_helpers
Some auxiliary functions and subroutines needed for HFX calculations.
Definition hfx_helpers.F:14
integer function, public count_cells_perd(shell, perd)
Auxiliary function for creating periodic neighbor cells
Definition hfx_helpers.F:38
subroutine, public next_image_cell_perd(m, perd)
Auxiliary function for creating periodic neighbor cells
Definition hfx_helpers.F:62