LCOV - code coverage report
Current view: top level - src/xc - xc_derivative_desc.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:262480d) Lines: 18 50 36.0 %
Date: 2024-11-22 07:00:40 Functions: 2 4 50.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 Module with functions to handle derivative descriptors.
      10             : !>      derivative description are strings have the following form
      11             : !>      "rhorhorhoa" which means that it is a forth order
      12             : !>      derivative, twice with respect to rho, once with respect to rhoa
      13             : !>      and once with respect to drhoa.
      14             : !>      Possible derivatives are:
      15             : !>      - rho: total density
      16             : !>      - norm_drho: norm of the gradient of the total density
      17             : !>      - rhoa, rhob: alpha and beta spin density (with LSD)
      18             : !>      - norm_drhoa, norm_drhob: norm of the gradient of the alpha and beta
      19             : !>        spin density
      20             : !>      - tau: the local kinetic part
      21             : !>      - taua, taub: the kinetic part of the different spins
      22             : !> \note
      23             : !>       add drhox, drhoy, drhoz, drhoax,...?
      24             : !> \author thomas & fawzi
      25             : ! **************************************************************************************************
      26             : MODULE xc_derivative_desc
      27             : 
      28             :    USE util,                            ONLY: sort
      29             : #include "../base/base_uses.f90"
      30             : 
      31             :    IMPLICIT NONE
      32             : 
      33             :    PRIVATE
      34             : 
      35             :    INTEGER, PARAMETER, PUBLIC :: &
      36             :       deriv_rho = 1, &
      37             :       deriv_rhoa = 2, &
      38             :       deriv_rhob = 3, &
      39             :       deriv_norm_drho = 4, &
      40             :       deriv_norm_drhoa = 5, &
      41             :       deriv_norm_drhob = 6, &
      42             :       deriv_tau = 7, &
      43             :       deriv_tau_a = 8, &
      44             :       deriv_tau_b = 9, &
      45             :       deriv_laplace_rho = 10, &
      46             :       deriv_laplace_rhoa = 11, &
      47             :       deriv_laplace_rhob = 12
      48             : 
      49             :    INTEGER, PARAMETER :: MAX_LABEL_LENGTH = 12
      50             : 
      51             :    LOGICAL, PARAMETER :: debug_this_module = .FALSE.
      52             : 
      53             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xc_derivative_desc'
      54             : 
      55             :    PUBLIC :: desc_to_id, id_to_desc, create_split_desc, standardize_desc
      56             : 
      57             : CONTAINS
      58             : 
      59             : ! **************************************************************************************************
      60             : !> \brief ...
      61             : !> \param desc ...
      62             : !> \return ...
      63             : ! **************************************************************************************************
      64           0 :    FUNCTION desc_to_id(desc) RESULT(id)
      65             :       CHARACTER(LEN=*), INTENT(IN)                       :: desc
      66             :       INTEGER                                            :: id
      67             : 
      68           0 :       SELECT CASE (TRIM(desc))
      69             :       CASE ("rho")
      70           0 :          id = deriv_rho
      71             :       CASE ("rhoa")
      72           0 :          id = deriv_rhoa
      73             :       CASE ("rhob")
      74           0 :          id = deriv_rhob
      75             :       CASE ("norm_drho")
      76           0 :          id = deriv_norm_drho
      77             :       CASE ("norm_drhoa")
      78           0 :          id = deriv_norm_drhoa
      79             :       CASE ("norm_drhob")
      80           0 :          id = deriv_norm_drhob
      81             :       CASE ("tau")
      82           0 :          id = deriv_tau
      83             :       CASE ("tau_a")
      84           0 :          id = deriv_tau_a
      85             :       CASE ("tau_b")
      86           0 :          id = deriv_tau_b
      87             :       CASE ("laplace_rho")
      88           0 :          id = deriv_laplace_rho
      89             :       CASE ("laplace_rhoa")
      90           0 :          id = deriv_laplace_rhoa
      91             :       CASE ("laplace_rhob")
      92           0 :          id = deriv_laplace_rhob
      93             :       CASE DEFAULT
      94           0 :          CPABORT("Unknown derivative variable: "//desc)
      95             :       END SELECT
      96             : 
      97           0 :    END FUNCTION desc_to_id
      98             : 
      99             : ! **************************************************************************************************
     100             : !> \brief ...
     101             : !> \param id ...
     102             : !> \return ...
     103             : ! **************************************************************************************************
     104           0 :    FUNCTION id_to_desc(id) RESULT(desc)
     105             :       INTEGER, INTENT(IN)                                :: id
     106             :       CHARACTER(LEN=MAX_LABEL_LENGTH)                    :: desc
     107             : 
     108           0 :       SELECT CASE (id)
     109             :       CASE (deriv_rho)
     110           0 :          desc = "rho"
     111             :       CASE (deriv_rhoa)
     112           0 :          desc = "rhoa"
     113             :       CASE (deriv_rhob)
     114           0 :          desc = "rhob"
     115             :       CASE (deriv_norm_drho)
     116           0 :          desc = "norm_drho"
     117             :       CASE (deriv_norm_drhoa)
     118           0 :          desc = "norm_drhoa"
     119             :       CASE (deriv_norm_drhob)
     120           0 :          desc = "norm_drhob"
     121             :       CASE (deriv_tau)
     122           0 :          desc = "tau"
     123             :       CASE (deriv_tau_a)
     124           0 :          desc = "tau_a"
     125             :       CASE (deriv_tau_b)
     126           0 :          desc = "tau_b"
     127             :       CASE (deriv_laplace_rho)
     128           0 :          desc = "laplace_rho"
     129             :       CASE (deriv_laplace_rhoa)
     130           0 :          desc = "laplace_rhoa"
     131             :       CASE (deriv_laplace_rhob)
     132           0 :          desc = "laplace_rhob"
     133             :       CASE DEFAULT
     134           0 :          CPABORT("Unknown derivative id!")
     135             :       END SELECT
     136             : 
     137           0 :    END FUNCTION id_to_desc
     138             : 
     139             : ! **************************************************************************************************
     140             : !> \brief ...
     141             : !> \param desc ...
     142             : !> \param split_desc ...
     143             : ! **************************************************************************************************
     144      563614 :    SUBROUTINE create_split_desc(desc, split_desc)
     145             :       INTEGER, DIMENSION(:), INTENT(IN)                  :: desc
     146             :       INTEGER, DIMENSION(:), POINTER                     :: split_desc
     147             : 
     148      563614 :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: indices
     149             : 
     150     1513885 :       ALLOCATE (split_desc(SIZE(desc)))
     151      563614 :       IF (SIZE(desc) > 0) THEN
     152      773314 :          ALLOCATE (indices(SIZE(desc)))
     153      817313 :          split_desc = desc
     154      386657 :          CALL sort(split_desc, SIZE(desc), indices)
     155      386657 :          DEALLOCATE (indices)
     156             :       END IF
     157             : 
     158      563614 :    END SUBROUTINE create_split_desc
     159             : 
     160             : ! **************************************************************************************************
     161             : !> \brief ...
     162             : !> \param desc ...
     163             : !> \param split_desc ...
     164             : ! **************************************************************************************************
     165     2307698 :    SUBROUTINE standardize_desc(desc, split_desc)
     166             :       INTEGER, DIMENSION(:), INTENT(IN)                  :: desc
     167             :       INTEGER, ALLOCATABLE, DIMENSION(:), INTENT(OUT)    :: split_desc
     168             : 
     169     2307698 :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: indices
     170             : 
     171     6500327 :       ALLOCATE (split_desc(SIZE(desc)))
     172     2307698 :       IF (SIZE(desc) > 0) THEN
     173     3769862 :          ALLOCATE (indices(SIZE(desc)))
     174     4629108 :          split_desc(:) = desc
     175     1884931 :          CALL sort(split_desc, SIZE(desc), indices)
     176     1884931 :          DEALLOCATE (indices)
     177             :       END IF
     178             : 
     179     2307698 :    END SUBROUTINE standardize_desc
     180             : 
     181             : END MODULE xc_derivative_desc

Generated by: LCOV version 1.15