LCOV - code coverage report
Current view: top level - src - hfx_pair_list_methods_unittest.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:123285f) Lines: 94.1 % 17 16
Test Date: 2026-11-04 00:58:17 Functions: 100.0 % 2 2

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8            2 : PROGRAM hfx_pair_list_methods_unittest
       9            2 :    USE hfx_pair_list_methods,           ONLY: min_image_gap_sq
      10              :    USE kinds,                           ONLY: dp
      11              : 
      12              :    IMPLICIT NONE
      13              : 
      14              :    REAL(KIND=dp), PARAMETER :: cells(3, 4) = RESHAPE([ &
      15              :                                                      10.0_dp, 12.0_dp, 14.0_dp, -10.0_dp, -12.0_dp, 14.0_dp, &
      16              :                                                      -10.0_dp, 12.0_dp, 14.0_dp, 10.0_dp, -12.0_dp, -14.0_dp], [3, 4])
      17              :    ! Centre, axial/mixed displacements, opposite corners and a point just outside the cell.
      18              :    REAL(KIND=dp), PARAMETER :: points(3, 8) = RESHAPE([ &
      19              :                                                       0.0_dp, 0.0_dp, 0.0_dp, 4.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 5.0_dp, 0.0_dp, &
      20              :                                                       0.0_dp, 0.0_dp, -6.0_dp, 4.0_dp, -5.0_dp, 6.0_dp, 5.0_dp, 6.0_dp, 7.0_dp, &
      21              :                                                       -5.0_dp, -6.0_dp, -7.0_dp, 5.1_dp, 0.0_dp, 0.0_dp], [3, 8])
      22              :    INTEGER :: axis, icell, ipoint, ix, iy, iz
      23              :    REAL(KIND=dp) :: exact, hmat(3, 3), r(3), shifted(3)
      24              : 
      25           10 :    DO icell = 1, SIZE(cells, 2)
      26            8 :       hmat = 0.0_dp
      27           32 :       DO axis = 1, 3
      28           32 :          hmat(axis, axis) = cells(axis, icell)
      29              :       END DO
      30           74 :       DO ipoint = 1, SIZE(points, 2)
      31          256 :          r = points(:, ipoint)
      32              :          exact = HUGE(1.0_dp)
      33          256 :          DO ix = -1, 1
      34          832 :             DO iy = -1, 1
      35         2496 :                DO iz = -1, 1
      36         1728 :                   IF (ix == 0 .AND. iy == 0 .AND. iz == 0) CYCLE
      37        31616 :                   shifted = r - MATMUL(hmat, REAL([ix, iy, iz], KIND=dp))
      38        12224 :                   exact = MIN(exact, SUM(shifted**2) - SUM(r**2))
      39              :                END DO
      40              :             END DO
      41              :          END DO
      42           72 :          IF (.NOT. (ABS(min_image_gap_sq(r, hmat) - exact) <= 1.0E-10_dp)) THEN
      43            0 :             ERROR STOP "Minimum-image gap differs from the explicit image search"
      44              :          END IF
      45              :       END DO
      46              :    END DO
      47              : 
      48            2 : END PROGRAM hfx_pair_list_methods_unittest
        

Generated by: LCOV version 2.0-1