LCOV - code coverage report
Current view: top level - src/eri_mme - eri_mme_util.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:d0bd076) Lines: 24 24 100.0 %
Date: 2021-09-15 13:52:28 Functions: 2 2 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2021 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Some utility methods used in different contexts.
      10             : !> \par History
      11             : !>       2015 09 created
      12             : !> \author Patrick Seewald
      13             : ! **************************************************************************************************
      14             : 
      15             : MODULE eri_mme_util
      16             : 
      17             :    USE kinds,                           ONLY: dp
      18             :    USE mathconstants,                   ONLY: twopi
      19             : #include "../base/base_uses.f90"
      20             : 
      21             :    IMPLICIT NONE
      22             : 
      23             :    PRIVATE
      24             : 
      25             :    PUBLIC :: G_abs_min, R_abs_min
      26             : CONTAINS
      27             : ! **************************************************************************************************
      28             : !> \brief Find minimum length of R vectors, for a general (not necessarily
      29             : !>        orthorhombic) cell.
      30             : !> \param hmat ...
      31             : !> \return ...
      32             : ! **************************************************************************************************
      33         112 :    FUNCTION R_abs_min(hmat) RESULT(R_m)
      34             :       REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN)         :: hmat
      35             :       REAL(KIND=dp)                                      :: R_m
      36             : 
      37             :       INTEGER                                            :: sx, sy, sz
      38             :       INTEGER, DIMENSION(3)                              :: sxyz
      39             :       REAL(KIND=dp)                                      :: R_sq
      40             :       REAL(KIND=dp), DIMENSION(3)                        :: R
      41             : 
      42         112 :       R_m = 0.0_dp
      43             : 
      44         448 :       DO sx = -1, 1
      45        1456 :       DO sy = -1, 1
      46        4368 :       DO sz = -1, 1
      47        4032 :          IF (.NOT. (sx == 0 .AND. sy == 0 .AND. sz == 0)) THEN
      48       11648 :             sxyz = [sx, sy, sz]
      49       46592 :             R = MATMUL(hmat, sxyz)
      50        2912 :             R_sq = R(1)**2 + R(2)**2 + R(3)**2
      51        2912 :             IF (R_sq < R_m .OR. R_m < EPSILON(R_m)) R_m = R_sq
      52             :          ENDIF
      53             :       ENDDO
      54             :       ENDDO
      55             :       ENDDO
      56         112 :       R_m = SQRT(R_m)
      57             : 
      58         112 :    END FUNCTION R_abs_min
      59             : 
      60             : ! **************************************************************************************************
      61             : !> \brief Find minimum length of G vectors, for a general (not necessarily
      62             : !>        orthorhombic) cell.
      63             : !> \param h_inv ...
      64             : !> \return ...
      65             : ! **************************************************************************************************
      66         112 :    FUNCTION G_abs_min(h_inv) RESULT(G_m)
      67             :       REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN)         :: h_inv
      68             :       REAL(KIND=dp)                                      :: G_m
      69             : 
      70             :       INTEGER                                            :: gx, gy, gz
      71             :       INTEGER, DIMENSION(3)                              :: gxyz
      72             :       REAL(KIND=dp)                                      :: G_sq
      73             :       REAL(KIND=dp), DIMENSION(3)                        :: G
      74             :       REAL(KIND=dp), DIMENSION(3, 3)                     :: H
      75             : 
      76        1456 :       H = twopi*TRANSPOSE(h_inv)
      77             :       G_m = 0.0_dp
      78             : 
      79         448 :       DO gx = -1, 1
      80        1456 :       DO gy = -1, 1
      81        4368 :       DO gz = -1, 1
      82        4032 :          IF (.NOT. (gx == 0 .AND. gy == 0 .AND. gz == 0)) THEN
      83       11648 :             gxyz = [gx, gy, gz]
      84       46592 :             G = MATMUL(H, gxyz)
      85        2912 :             G_sq = G(1)**2 + G(2)**2 + G(3)**2
      86        2912 :             IF (G_sq < G_m .OR. G_m < EPSILON(G_m)) G_m = G_sq
      87             :          ENDIF
      88             :       ENDDO
      89             :       ENDDO
      90             :       ENDDO
      91         112 :       G_m = SQRT(G_m)
      92             : 
      93         112 :    END FUNCTION G_abs_min
      94             : 
      95             : END MODULE eri_mme_util

Generated by: LCOV version 1.15