LCOV - code coverage report
Current view: top level - src - qs_dispersion_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 40 41 97.6 %
Date: 2024-12-21 06:28:57 Functions: 1 5 20.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 Definition of disperson types for DFT calculations
      10             : !> \author JGH (20.10.2008)
      11             : ! **************************************************************************************************
      12             : MODULE qs_dispersion_types
      13             : 
      14             :    USE eeq_input,                       ONLY: eeq_solver_type
      15             :    USE input_section_types,             ONLY: section_vals_type
      16             :    USE kinds,                           ONLY: default_string_length,&
      17             :                                               dp
      18             :    USE qs_neighbor_list_types,          ONLY: neighbor_list_set_p_type,&
      19             :                                               release_neighbor_list_sets
      20             : #include "./base/base_uses.f90"
      21             : 
      22             :    IMPLICIT NONE
      23             : 
      24             :    PRIVATE
      25             : 
      26             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_dispersion_types'
      27             : 
      28             : ! **************************************************************************************************
      29             :    INTEGER, PARAMETER                       :: dftd2_pp = 1
      30             :    INTEGER, PARAMETER                       :: dftd3_pp = 2
      31             :    INTEGER, PARAMETER                       :: dftd4_pp = 3
      32             : 
      33             :    TYPE qs_dispersion_type
      34             :       INTEGER                                :: TYPE = -1
      35             :       INTEGER                                :: pp_type = -1
      36             :       INTEGER                                :: nl_type = -1
      37             :       CHARACTER(LEN=default_string_length)   :: ref_functional = ""
      38             :       REAL(KIND=dp)                          :: scaling = -1.0_dp
      39             :       REAL(KIND=dp)                          :: rc_disp = -1.0_dp
      40             :       REAL(KIND=dp)                          :: rc_d4 = -1.0_dp
      41             :       REAL(KIND=dp)                          :: rc_cn = -1.0_dp
      42             :       REAL(KIND=dp)                          :: exp_pre = -1.0_dp
      43             :       TYPE(section_vals_type), POINTER       :: dftd_section => NULL()
      44             :       LOGICAL                                :: verbose = .FALSE. !extended output
      45             :       CHARACTER(LEN=default_string_length)   :: parameter_file_name = ""
      46             :       CHARACTER(LEN=default_string_length)   :: kernel_file_name = ""
      47             :       !charges
      48             :       LOGICAL                                :: ext_charges = .FALSE.
      49             :       REAL(KIND=dp), DIMENSION(:), POINTER   :: charges => NULL() !charges for D4
      50             :       REAL(KIND=dp), DIMENSION(:), POINTER   :: dcharges => NULL() !derivatives of D4 energy wrt charges
      51             :       TYPE(eeq_solver_type)                  :: eeq_sparam ! parameters for EEQ solver
      52             :       !DFT-D3 global parameters
      53             :       INTEGER                                :: max_elem = -1 !elements parametrized
      54             :       INTEGER                                :: maxc = -1 !max coordination number references per element
      55             :       REAL(KIND=dp)                          :: k1 = -1.0_dp, k2 = -1.0_dp, k3 = -1.0_dp !ad hoc parameters
      56             :       REAL(KIND=dp)                          :: alp = -1.0_dp !ad hoc parameters
      57             :       REAL(KIND=dp)                          :: s6 = -1.0_dp, s8 = -1.0_dp, sr6 = -1.0_dp !scaling parameters
      58             :       REAL(KIND=dp)                          :: a1 = -1.0_dp, a2 = -1.0_dp !BJ scaling parameters
      59             :       REAL(KIND=dp)                          :: eps_cn = -1.0_dp
      60             :       LOGICAL                                :: d4_reference_code = .FALSE. !Use D4 calculation from ext. library
      61             :       LOGICAL                                :: d4_debug = .FALSE. !Output debug information for D4
      62             :       LOGICAL                                :: doabc = .FALSE. !neglect C9 terms
      63             :       LOGICAL                                :: c9cnst = .FALSE. !use constant c9 terms
      64             :       LOGICAL                                :: lrc = .FALSE. !calculate a long range correction
      65             :       LOGICAL                                :: srb = .FALSE. !calculate a short range bond correction
      66             :       REAL(KIND=dp), DIMENSION(4)            :: srb_params = -1.0_dp ! parameters for SRB (s,g,t1,t2)
      67             :       REAL(KIND=dp)                          :: s9 = -1.0_dp !scale the many-body dispersion energy (default=1.0), dftd4
      68             :       TYPE(neighbor_list_set_p_type), &
      69             :          DIMENSION(:), POINTER               :: sab_vdw => NULL(), sab_cn => NULL() ! neighborlists for pair interactions
      70             :       REAL(KIND=dp), DIMENSION(:, :, :, :, :), POINTER &
      71             :          :: c6ab => NULL()
      72             :       INTEGER, DIMENSION(:), POINTER         :: maxci => NULL()
      73             :       REAL(KIND=dp), DIMENSION(:, :), POINTER :: r0ab => NULL()
      74             :       REAL(KIND=dp), DIMENSION(:), POINTER   :: rcov => NULL() !covalent radii
      75             :       REAL(KIND=dp), DIMENSION(:), POINTER   :: eneg => NULL() !electronegativity
      76             :       REAL(KIND=dp), DIMENSION(:), POINTER   :: r2r4 => NULL() !atomic <r^2>/<r^4> values
      77             :       INTEGER                                :: cnfun = 1 ! CN function to be used
      78             :       REAL(KIND=dp), DIMENSION(:), POINTER   :: cn => NULL()
      79             :       TYPE(cn_kind_list), DIMENSION(:), POINTER  :: cnkind => NULL()
      80             :       TYPE(cn_atom_list), DIMENSION(:), POINTER  :: cnlist => NULL()
      81             :       ! KG molecular corrections
      82             :       LOGICAL                                :: domol = .FALSE.
      83             :       REAL(KIND=dp)                          :: kgc8 = -1.0_dp !s8 scaling parameter
      84             :       !vdW-DF variables
      85             :       REAL(KIND=dp)                          :: pw_cutoff = -1.0_dp
      86             :       !parameters for the rVV10 functional
      87             :       REAL(KIND=dp)                          :: b_value = -1.0_dp, c_value = -1.0_dp, scale_rvv10 = -1.0_dp
      88             :       INTEGER                                :: nqs = -1, nr_points = -1
      89             :       !! The number of q points and radial points
      90             :       !! used in generating the kernel phi(q1*r, q2*r)
      91             :       !! (see DION 14-16 and SOLER 3)
      92             :       REAL(KIND=dp)                          :: r_max = -1.0_dp, q_cut = -1.0_dp, q_min = -1.0_dp, dk = -1.0_dp
      93             :       !! The maximum value of r, the maximum and minimum
      94             :       !! values of q and the k-space spacing of grid points.
      95             :       !! Note that, during a vdW run, values of q0 found
      96             :       !! larger than q_cut will be saturated (SOLER 6-7) to
      97             :       !! q_cut
      98             :       REAL(KIND=dp), DIMENSION(:), POINTER    :: q_mesh => NULL() !! The values of all the q points used
      99             :       REAL(KIND=dp), DIMENSION(:, :, :), POINTER &
     100             :          :: kernel => NULL() !! A matrix holding the Fourier transformed kernel function
     101             :       !! for each pair of q values.  The ordering is
     102             :       !! kernel(k_point, q1_value, q2_value)
     103             :       REAL(KIND=dp), DIMENSION(:, :, :), POINTER &
     104             :          :: d2phi_dk2 => NULL() !! A matrix holding the second derivatives of the above
     105             :       !! kernel matrix at each of the q points.  Stored as
     106             :       !! d2phi_dk2(k_point, q1_value, q2_value)
     107             :       REAL(KIND=dp), DIMENSION(:, :), POINTER  :: d2y_dx2 => NULL() !! 2nd derivatives of q_mesh for interpolation
     108             :       INTEGER, DIMENSION(:, :), POINTER  :: d3_exclude_pair => NULL()
     109             :       INTEGER  :: nd3_exclude_pair = -1
     110             :    END TYPE qs_dispersion_type
     111             : 
     112             :    TYPE qs_atom_dispersion_type
     113             :       INTEGER                                :: TYPE = -1
     114             :       LOGICAL                                :: defined = .FALSE.
     115             :       REAL(KIND=dp)                          :: vdw_radii = -1.0_dp !van der Waals radii
     116             :       REAL(KIND=dp)                          :: c6 = -1.0_dp !c6 coefficients
     117             :    END TYPE qs_atom_dispersion_type
     118             : 
     119             :    TYPE cn_kind_list
     120             :       REAL(KIND=dp)                          :: cnum = -1.0_dp
     121             :       INTEGER                                :: kind = -1
     122             :    END TYPE cn_kind_list
     123             :    TYPE cn_atom_list
     124             :       REAL(KIND=dp)                          :: cnum = -1.0_dp
     125             :       INTEGER                                :: natom = -1
     126             :       INTEGER, DIMENSION(:), POINTER          :: atom => NULL()
     127             :    END TYPE cn_atom_list
     128             : 
     129             : ! **************************************************************************************************
     130             : 
     131             :    PUBLIC :: qs_atom_dispersion_type, qs_dispersion_type
     132             :    PUBLIC :: dftd2_pp, dftd3_pp, dftd4_pp
     133             :    PUBLIC :: qs_dispersion_release
     134             : 
     135             : ! **************************************************************************************************
     136             : CONTAINS
     137             : ! **************************************************************************************************
     138             : !> \brief ...
     139             : !> \param dispersion_env ...
     140             : ! **************************************************************************************************
     141        7635 :    SUBROUTINE qs_dispersion_release(dispersion_env)
     142             : 
     143             :       TYPE(qs_dispersion_type), POINTER                  :: dispersion_env
     144             : 
     145             :       INTEGER                                            :: i
     146             : 
     147        7635 :       IF (ASSOCIATED(dispersion_env)) THEN
     148             :          ! DFT-D3 arrays
     149        7626 :          IF (ASSOCIATED(dispersion_env%maxci)) THEN
     150        1006 :             DEALLOCATE (dispersion_env%maxci)
     151             :          END IF
     152        7626 :          IF (ASSOCIATED(dispersion_env%c6ab)) THEN
     153         362 :             DEALLOCATE (dispersion_env%c6ab)
     154             :          END IF
     155        7626 :          IF (ASSOCIATED(dispersion_env%r0ab)) THEN
     156         362 :             DEALLOCATE (dispersion_env%r0ab)
     157             :          END IF
     158        7626 :          IF (ASSOCIATED(dispersion_env%rcov)) THEN
     159        1062 :             DEALLOCATE (dispersion_env%rcov)
     160             :          END IF
     161        7626 :          IF (ASSOCIATED(dispersion_env%eneg)) THEN
     162        1006 :             DEALLOCATE (dispersion_env%eneg)
     163             :          END IF
     164        7626 :          IF (ASSOCIATED(dispersion_env%r2r4)) THEN
     165         362 :             DEALLOCATE (dispersion_env%r2r4)
     166             :          END IF
     167        7626 :          IF (ASSOCIATED(dispersion_env%cn)) THEN
     168        1006 :             DEALLOCATE (dispersion_env%cn)
     169             :          END IF
     170        7626 :          IF (ASSOCIATED(dispersion_env%cnkind)) THEN
     171           6 :             DEALLOCATE (dispersion_env%cnkind)
     172             :          END IF
     173        7626 :          IF (ASSOCIATED(dispersion_env%cnlist)) THEN
     174           6 :             DO i = 1, SIZE(dispersion_env%cnlist)
     175           6 :                DEALLOCATE (dispersion_env%cnlist(i)%atom)
     176             :             END DO
     177           2 :             DEALLOCATE (dispersion_env%cnlist)
     178             :          END IF
     179             :          ! vdD-DF
     180        7626 :          IF (ASSOCIATED(dispersion_env%q_mesh)) THEN
     181          46 :             DEALLOCATE (dispersion_env%q_mesh)
     182             :          END IF
     183        7626 :          IF (ASSOCIATED(dispersion_env%kernel)) THEN
     184          46 :             DEALLOCATE (dispersion_env%kernel)
     185             :          END IF
     186        7626 :          IF (ASSOCIATED(dispersion_env%d2phi_dk2)) THEN
     187          46 :             DEALLOCATE (dispersion_env%d2phi_dk2)
     188             :          END IF
     189        7626 :          IF (ASSOCIATED(dispersion_env%d2y_dx2)) THEN
     190          46 :             DEALLOCATE (dispersion_env%d2y_dx2)
     191             :          END IF
     192        7626 :          IF (ASSOCIATED(dispersion_env%d3_exclude_pair)) THEN
     193           2 :             DEALLOCATE (dispersion_env%d3_exclude_pair)
     194             :          END IF
     195             :          ! neighborlists
     196        7626 :          CALL release_neighbor_list_sets(dispersion_env%sab_vdw)
     197        7626 :          CALL release_neighbor_list_sets(dispersion_env%sab_cn)
     198             :          ! charges
     199        7626 :          IF (ASSOCIATED(dispersion_env%charges)) THEN
     200         630 :             DEALLOCATE (dispersion_env%charges)
     201             :          END IF
     202        7626 :          IF (ASSOCIATED(dispersion_env%dcharges)) THEN
     203           2 :             DEALLOCATE (dispersion_env%dcharges)
     204             :          END IF
     205             : 
     206        7626 :          DEALLOCATE (dispersion_env)
     207             : 
     208             :       END IF
     209             : 
     210        7635 :    END SUBROUTINE qs_dispersion_release
     211             : 
     212           0 : END MODULE qs_dispersion_types
     213             : 

Generated by: LCOV version 1.15