LCOV - code coverage report
Current view: top level - src - hfx_helpers.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:ccc2433) Lines: 20 20 100.0 %
Date: 2024-04-25 07:09:54 Functions: 2 2 100.0 %

          Line data    Source code
       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             : ! **************************************************************************************************
      14             : MODULE hfx_helpers
      15             : #include "./base/base_uses.f90"
      16             :    IMPLICIT NONE
      17             :    PRIVATE
      18             : 
      19             :    PUBLIC :: count_cells_perd, &
      20             :              next_image_cell_perd
      21             : 
      22             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'hfx_helpers'
      23             : 
      24             : !***
      25             : 
      26             : CONTAINS
      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        2654 :    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             : 
      43        2654 :       count_cells_perd = 0
      44        5756 :       DO i = -shell*perd(1), shell*perd(1)
      45       10618 :          DO j = -shell*perd(2), shell*perd(2)
      46       20186 :             DO k = -shell*perd(3), shell*perd(3)
      47       17084 :                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        2654 :    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        3094 :    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        3094 :       found = .FALSE.
      69       12376 :       shell = SUM(m**2)
      70        2508 :       outer: DO
      71        9404 :          DO i = -shell*perd(1), shell*perd(1)
      72       21182 :          DO j = -shell*perd(2), shell*perd(2)
      73       63490 :             inner: DO k = -shell*perd(3), shell*perd(3)
      74       47910 :                IF (.NOT. (i**2 + j**2 + k**2 == shell)) CYCLE inner
      75        8804 :                IF (found) THEN
      76       12376 :                   m = (/i, j, k/)
      77             :                   EXIT outer
      78             :                END IF
      79       66868 :                IF (ALL(M .EQ. (/i, j, k/))) found = .TRUE.
      80             :             END DO inner
      81             :          END DO
      82             :          END DO
      83        2508 :          shell = shell + 1
      84             :       END DO outer
      85        3094 :    END SUBROUTINE next_image_cell_perd
      86             : 
      87             : ! **************************************************************************************************
      88             : 
      89             : END MODULE hfx_helpers

Generated by: LCOV version 1.15