LCOV - code coverage report
Current view: top level - src - qs_nlcc_methods.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:9ccafda) Lines: 100.0 % 23 23
Test Date: 2026-10-15 00:55:44 Functions: 100.0 % 1 1

            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              : ! **************************************************************************************************
       9              : !> \brief Common Gaussian representation of nonlinear core densities.
      10              : ! **************************************************************************************************
      11              : MODULE qs_nlcc_methods
      12              :    USE external_potential_types,        ONLY: get_potential,&
      13              :                                               gth_potential_type,&
      14              :                                               sgp_potential_type
      15              :    USE kinds,                           ONLY: dp
      16              :    USE qs_kind_types,                   ONLY: get_qs_kind,&
      17              :                                               qs_kind_type
      18              : #include "./base/base_uses.f90"
      19              : 
      20              :    IMPLICIT NONE
      21              :    PRIVATE
      22              :    PUBLIC :: get_nlcc_gaussians
      23              : 
      24              : CONTAINS
      25              : 
      26              : ! **************************************************************************************************
      27              : !> \brief Return rho(r) = sum_i exp(-r**2/(2*alpha(i)**2)) *
      28              : !>        sum_j cval(j,i)*(r/alpha(i))**(2*j-2).
      29              : !>        The same representation is used for collocation and force integration.
      30              : !> \param qs_kind Atomic kind carrying a GTH or separable Gaussian potential.
      31              : !> \param alpha Gaussian widths; an empty array indicates no core correction.
      32              : !> \param nct Number of radial polynomial coefficients for each Gaussian.
      33              : !> \param cval Radial polynomial coefficients, including the density normalization.
      34              : ! **************************************************************************************************
      35          484 :    SUBROUTINE get_nlcc_gaussians(qs_kind, alpha, nct, cval)
      36              :       TYPE(qs_kind_type), INTENT(IN)                     :: qs_kind
      37              :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:), &
      38              :          INTENT(OUT)                                     :: alpha
      39              :       INTEGER, ALLOCATABLE, DIMENSION(:), INTENT(OUT)    :: nct
      40              :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :), &
      41              :          INTENT(OUT)                                     :: cval
      42              : 
      43              :       INTEGER                                            :: nexp
      44          484 :       INTEGER, DIMENSION(:), POINTER                     :: gth_nct
      45              :       LOGICAL                                            :: nlcc
      46          484 :       REAL(KIND=dp), DIMENSION(:), POINTER               :: a_nlcc, c_nlcc, gth_alpha
      47          484 :       REAL(KIND=dp), DIMENSION(:, :), POINTER            :: gth_cval
      48              :       TYPE(gth_potential_type), POINTER                  :: gth_potential
      49              :       TYPE(sgp_potential_type), POINTER                  :: sgp_potential
      50              : 
      51          484 :       CALL get_qs_kind(qs_kind, gth_potential=gth_potential, sgp_potential=sgp_potential)
      52          484 :       IF (ASSOCIATED(gth_potential)) THEN
      53              :          CALL get_potential(gth_potential, nlcc_present=nlcc, nexp_nlcc=nexp, &
      54          460 :                             alpha_nlcc=gth_alpha, nct_nlcc=gth_nct, cval_nlcc=gth_cval)
      55          460 :          IF (nlcc) THEN
      56         2256 :             ALLOCATE (alpha(nexp), nct(nexp), cval(SIZE(gth_cval, 1), nexp))
      57          564 :             alpha(:) = gth_alpha(1:nexp)
      58          564 :             nct(:) = gth_nct(1:nexp)
      59         1692 :             cval(:, :) = gth_cval(:, 1:nexp)
      60          294 :             RETURN
      61              :          END IF
      62           24 :       ELSE IF (ASSOCIATED(sgp_potential)) THEN
      63              :          CALL get_potential(sgp_potential, has_nlcc=nlcc, n_nlcc=nexp, &
      64           24 :                             a_nlcc=a_nlcc, c_nlcc=c_nlcc)
      65           24 :          IF (nlcc) THEN
      66          588 :             CPASSERT(ALL(a_nlcc(1:nexp) > 0.0_dp))
      67              :             ! SGP stores exponents in exp(-a*r**2), whereas GTH stores widths.
      68           72 :             ALLOCATE (alpha(nexp), nct(nexp), cval(1, nexp))
      69          588 :             alpha(:) = 1.0_dp/SQRT(2.0_dp*a_nlcc(1:nexp))
      70          588 :             nct = 1
      71          588 :             cval(1, :) = c_nlcc(1:nexp)
      72              :             RETURN
      73              :          END IF
      74              :       END IF
      75          190 :       ALLOCATE (alpha(0), nct(0), cval(0, 0))
      76              : 
      77          484 :    END SUBROUTINE get_nlcc_gaussians
      78              : 
      79              : END MODULE qs_nlcc_methods
        

Generated by: LCOV version 2.0-1