LCOV - code coverage report
Current view: top level - src - qs_dispersion_utils.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 228 784 29.1 %
Date: 2024-12-21 06:28:57 Functions: 6 6 100.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 Set disperson types for DFT calculations
      10             : !> \author JGH (04.2014)
      11             : ! **************************************************************************************************
      12             : MODULE qs_dispersion_utils
      13             : 
      14             :    USE atomic_kind_types,               ONLY: atomic_kind_type,&
      15             :                                               get_atomic_kind
      16             :    USE cp_log_handling,                 ONLY: cp_get_default_logger,&
      17             :                                               cp_logger_type
      18             :    USE cp_output_handling,              ONLY: cp_print_key_finished_output,&
      19             :                                               cp_print_key_unit_nr
      20             :    USE input_constants,                 ONLY: &
      21             :         vdw_nl_DRSLL, vdw_nl_LMKLL, vdw_nl_RVV10, vdw_pairpot_dftd2, vdw_pairpot_dftd3, &
      22             :         vdw_pairpot_dftd3bj, vdw_pairpot_dftd4, xc_vdw_fun_nonloc, xc_vdw_fun_pairpot
      23             :    USE input_section_types,             ONLY: section_vals_get_subs_vals,&
      24             :                                               section_vals_type,&
      25             :                                               section_vals_val_get
      26             :    USE kinds,                           ONLY: default_string_length,&
      27             :                                               dp
      28             :    USE physcon,                         ONLY: bohr,&
      29             :                                               kjmol
      30             :    USE qs_dispersion_types,             ONLY: qs_atom_dispersion_type,&
      31             :                                               qs_dispersion_type
      32             :    USE qs_environment_types,            ONLY: get_qs_env,&
      33             :                                               qs_environment_type
      34             :    USE qs_kind_types,                   ONLY: get_qs_kind,&
      35             :                                               qs_kind_type
      36             :    USE string_utilities,                ONLY: uppercase
      37             : #include "./base/base_uses.f90"
      38             : 
      39             :    IMPLICIT NONE
      40             : 
      41             :    PRIVATE
      42             : 
      43             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_dispersion_utils'
      44             : 
      45             :    PUBLIC :: qs_dispersion_env_set, qs_write_dispersion
      46             :    PUBLIC :: cellhash
      47             : 
      48             : ! **************************************************************************************************
      49             : CONTAINS
      50             : ! **************************************************************************************************
      51             : !> \brief ...
      52             : !> \param dispersion_env ...
      53             : !> \param xc_section ...
      54             : ! **************************************************************************************************
      55        5440 :    SUBROUTINE qs_dispersion_env_set(dispersion_env, xc_section)
      56             :       TYPE(qs_dispersion_type), POINTER                  :: dispersion_env
      57             :       TYPE(section_vals_type), POINTER                   :: xc_section
      58             : 
      59             :       LOGICAL                                            :: exfun, explicit
      60        5440 :       REAL(dp), POINTER                                  :: params(:), scal(:)
      61             :       TYPE(section_vals_type), POINTER                   :: nl_section, pp_section, vdw_section, &
      62             :                                                             xc_fun_section
      63             : 
      64           0 :       CPASSERT(ASSOCIATED(dispersion_env))
      65             : 
      66             :       ! set general defaults
      67        5440 :       dispersion_env%doabc = .FALSE.
      68        5440 :       dispersion_env%c9cnst = .FALSE.
      69        5440 :       dispersion_env%lrc = .FALSE.
      70        5440 :       dispersion_env%srb = .FALSE.
      71        5440 :       dispersion_env%verbose = .FALSE.
      72        5440 :       dispersion_env%nd3_exclude_pair = 0
      73        5440 :       NULLIFY (dispersion_env%c6ab, dispersion_env%maxci, dispersion_env%r0ab, dispersion_env%rcov, &
      74        5440 :                dispersion_env%r2r4, dispersion_env%cn, dispersion_env%cnkind, dispersion_env%cnlist, &
      75        5440 :                dispersion_env%d3_exclude_pair)
      76        5440 :       NULLIFY (dispersion_env%q_mesh, dispersion_env%kernel, dispersion_env%d2phi_dk2, &
      77        5440 :                dispersion_env%d2y_dx2)
      78        5440 :       NULLIFY (dispersion_env%sab_vdw, dispersion_env%sab_cn)
      79        5440 :       NULLIFY (dispersion_env%dftd_section)
      80        5440 :       NULLIFY (vdw_section, xc_fun_section)
      81        5440 :       vdw_section => section_vals_get_subs_vals(xc_section, "vdw_potential")
      82        5440 :       xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
      83        5440 :       CALL section_vals_val_get(vdw_section, "POTENTIAL_TYPE", i_val=dispersion_env%type)
      84        5440 :       IF (dispersion_env%type == xc_vdw_fun_pairpot) THEN
      85          94 :          NULLIFY (pp_section)
      86          94 :          pp_section => section_vals_get_subs_vals(vdw_section, "PAIR_POTENTIAL")
      87          94 :          CALL section_vals_val_get(pp_section, "VERBOSE_OUTPUT", l_val=dispersion_env%verbose)
      88          94 :          CALL section_vals_val_get(pp_section, "TYPE", i_val=dispersion_env%pp_type)
      89          94 :          IF (dispersion_env%pp_type == vdw_pairpot_dftd2) THEN
      90             :             ! functional parameters for Grimme D2 type
      91          20 :             CALL section_vals_val_get(pp_section, "EXP_PRE", r_val=dispersion_env%exp_pre)
      92          20 :             CALL section_vals_val_get(pp_section, "SCALING", explicit=explicit)
      93          20 :             IF (.NOT. explicit) THEN
      94           8 :                CALL section_vals_val_get(pp_section, "REFERENCE_FUNCTIONAL", explicit=exfun)
      95           8 :                CPASSERT(exfun)
      96           8 :                CALL qs_scaling_dftd2(dispersion_env%scaling, vdw_section)
      97             :             ELSE
      98          12 :                CALL section_vals_val_get(pp_section, "SCALING", r_val=dispersion_env%scaling)
      99             :             END IF
     100             :          ELSE
     101          74 :             dispersion_env%exp_pre = 0._dp
     102          74 :             dispersion_env%scaling = 0._dp
     103             :          END IF
     104          94 :          IF (dispersion_env%pp_type == vdw_pairpot_dftd3 .OR. &
     105             :              dispersion_env%pp_type == vdw_pairpot_dftd3bj) THEN
     106             :             ! functional parameters for Grimme DFT-D3 type
     107          60 :             CALL section_vals_val_get(pp_section, "EPS_CN", r_val=dispersion_env%eps_cn)
     108          60 :             CALL section_vals_val_get(pp_section, "CALCULATE_C9_TERM", l_val=dispersion_env%doabc)
     109          60 :             CALL section_vals_val_get(pp_section, "REFERENCE_C9_TERM", l_val=dispersion_env%c9cnst)
     110          60 :             CALL section_vals_val_get(pp_section, "LONG_RANGE_CORRECTION", l_val=dispersion_env%lrc)
     111          60 :             CALL section_vals_val_get(pp_section, "SHORT_RANGE_CORRECTION", l_val=dispersion_env%srb)
     112          60 :             CALL section_vals_val_get(pp_section, "SHORT_RANGE_CORRECTION_PARAMETERS", r_vals=params)
     113         600 :             dispersion_env%srb_params(1:4) = params(1:4)
     114             :             ! KG corrections
     115          60 :             CALL section_vals_val_get(pp_section, "MOLECULE_CORRECTION", l_val=dispersion_env%domol)
     116          60 :             CALL section_vals_val_get(pp_section, "MOLECULE_CORRECTION_C8", r_val=dispersion_env%kgc8)
     117          60 :             IF (dispersion_env%pp_type == vdw_pairpot_dftd3) THEN
     118          42 :                CALL section_vals_val_get(pp_section, "D3_SCALING", explicit=explicit)
     119          18 :             ELSE IF (dispersion_env%pp_type == vdw_pairpot_dftd3bj) THEN
     120          18 :                CALL section_vals_val_get(pp_section, "D3BJ_SCALING", explicit=explicit)
     121             :             END IF
     122          60 :             IF (.NOT. explicit) THEN
     123          54 :                CALL section_vals_val_get(pp_section, "REFERENCE_FUNCTIONAL", explicit=exfun)
     124          54 :                CPASSERT(exfun)
     125          54 :                IF (dispersion_env%pp_type == vdw_pairpot_dftd3) THEN
     126             :                   CALL qs_scaling_dftd3(dispersion_env%s6, dispersion_env%sr6, &
     127          38 :                                         dispersion_env%s8, vdw_section)
     128          16 :                ELSE IF (dispersion_env%pp_type == vdw_pairpot_dftd3bj) THEN
     129             :                   CALL qs_scaling_dftd3bj(dispersion_env%s6, dispersion_env%a1, dispersion_env%s8, &
     130          16 :                                           dispersion_env%a2, vdw_section)
     131             :                END IF
     132             :             ELSE
     133           6 :                IF (dispersion_env%pp_type == vdw_pairpot_dftd3) THEN
     134             :                   ! zero damping
     135           4 :                   CALL section_vals_val_get(pp_section, "D3_SCALING", r_vals=scal)
     136           4 :                   dispersion_env%s6 = scal(1)
     137           4 :                   dispersion_env%sr6 = scal(2)
     138           4 :                   dispersion_env%s8 = scal(3)
     139           4 :                   dispersion_env%a1 = 0.0_dp
     140           4 :                   dispersion_env%a2 = 0.0_dp
     141           2 :                ELSE IF (dispersion_env%pp_type == vdw_pairpot_dftd3bj) THEN
     142             :                   ! BJ damping
     143           2 :                   CALL section_vals_val_get(pp_section, "D3BJ_SCALING", r_vals=scal)
     144           2 :                   dispersion_env%s6 = scal(1)
     145           2 :                   dispersion_env%a1 = scal(2)
     146           2 :                   dispersion_env%s8 = scal(3)
     147           2 :                   dispersion_env%a2 = scal(4)
     148           2 :                   dispersion_env%sr6 = 0.0_dp
     149             :                END IF
     150             :             END IF
     151             :          ELSE
     152          34 :             dispersion_env%s6 = 0._dp
     153          34 :             dispersion_env%sr6 = 0._dp
     154          34 :             dispersion_env%s8 = 0._dp
     155          34 :             dispersion_env%a1 = 0._dp
     156          34 :             dispersion_env%a2 = 0._dp
     157          34 :             dispersion_env%eps_cn = 0._dp
     158             :          END IF
     159          94 :          IF (dispersion_env%pp_type == vdw_pairpot_dftd4) THEN
     160          14 :             CALL section_vals_val_get(pp_section, "D4_SCALING", explicit=explicit)
     161          14 :             IF (.NOT. explicit) THEN
     162          14 :                CALL section_vals_val_get(pp_section, "REFERENCE_FUNCTIONAL", explicit=exfun)
     163          14 :                IF (.NOT. exfun) THEN
     164           0 :                   CPABORT("D4 vdW REFERENCE_FUNCTIONAL or D4_SCALING expected")
     165             :                ELSE
     166             :                   CALL section_vals_val_get(vdw_section, &
     167             :                                             "PAIR_POTENTIAL%REFERENCE_FUNCTIONAL", &
     168          14 :                                             c_val=dispersion_env%ref_functional)
     169             :                END IF
     170             :             ELSE
     171           0 :                CALL section_vals_val_get(pp_section, "D4_SCALING", r_vals=scal)
     172           0 :                dispersion_env%s6 = scal(1)
     173           0 :                dispersion_env%a1 = scal(2)
     174           0 :                dispersion_env%s8 = scal(3)
     175           0 :                dispersion_env%a2 = scal(4)
     176           0 :                dispersion_env%sr6 = 0.0_dp
     177           0 :                dispersion_env%ref_functional = "none"
     178             :             END IF
     179          14 :             CALL section_vals_val_get(pp_section, "EPS_CN", r_val=dispersion_env%eps_cn)
     180             :             CALL section_vals_val_get(pp_section, "D4_REFERENCE_CODE", &
     181          14 :                                       l_val=dispersion_env%d4_reference_code)
     182          14 :             CALL section_vals_val_get(pp_section, "D4_DEBUG", l_val=dispersion_env%d4_debug)
     183          14 :             CALL section_vals_val_get(pp_section, "D4_CUTOFF", r_val=dispersion_env%rc_d4)
     184          14 :             CALL section_vals_val_get(pp_section, "D4_CN_CUTOFF", r_val=dispersion_env%rc_cn)
     185          14 :             CALL section_vals_val_get(pp_section, "FACTOR_S9_TERM", r_val=dispersion_env%s9)
     186             :             !C9 term default=T for D4
     187          14 :             CALL section_vals_val_get(pp_section, "CALCULATE_C9_TERM", explicit=exfun)
     188          14 :             IF (exfun) THEN
     189           8 :                CALL section_vals_val_get(pp_section, "CALCULATE_C9_TERM", l_val=dispersion_env%doabc)
     190             :             ELSE
     191           6 :                dispersion_env%doabc = .TRUE.
     192             :             END IF
     193             :          END IF
     194          94 :          CALL section_vals_val_get(pp_section, "R_CUTOFF", r_val=dispersion_env%rc_disp)
     195             :          CALL section_vals_val_get(pp_section, "PARAMETER_FILE_NAME", &
     196          94 :                                    c_val=dispersion_env%parameter_file_name)
     197             :          ! set DFTD section for output handling
     198          94 :          dispersion_env%dftd_section => pp_section
     199        5346 :       ELSE IF (dispersion_env%type == xc_vdw_fun_nonloc) THEN
     200          46 :          NULLIFY (nl_section)
     201          46 :          nl_section => section_vals_get_subs_vals(vdw_section, "NON_LOCAL")
     202          46 :          CALL section_vals_val_get(nl_section, "VERBOSE_OUTPUT", l_val=dispersion_env%verbose)
     203             :          CALL section_vals_val_get(nl_section, "KERNEL_FILE_NAME", &
     204          46 :                                    c_val=dispersion_env%kernel_file_name)
     205          46 :          CALL section_vals_val_get(nl_section, "TYPE", i_val=dispersion_env%nl_type)
     206          46 :          CALL section_vals_val_get(nl_section, "CUTOFF", r_val=dispersion_env%pw_cutoff)
     207          46 :          CALL section_vals_val_get(nl_section, "PARAMETERS", r_vals=params)
     208          46 :          CALL section_vals_val_get(nl_section, "SCALE", r_val=dispersion_env%scale_rvv10)
     209          46 :          dispersion_env%b_value = params(1)
     210          46 :          dispersion_env%c_value = params(2)
     211             :       END IF
     212        5440 :    END SUBROUTINE qs_dispersion_env_set
     213             : 
     214             : ! **************************************************************************************************
     215             : !> \brief ...
     216             : !> \param qs_env ...
     217             : !> \param dispersion_env ...
     218             : !> \param ounit ...
     219             : ! **************************************************************************************************
     220        6330 :    SUBROUTINE qs_write_dispersion(qs_env, dispersion_env, ounit)
     221             :       TYPE(qs_environment_type), POINTER                 :: qs_env
     222             :       TYPE(qs_dispersion_type), POINTER                  :: dispersion_env
     223             :       INTEGER, INTENT(in), OPTIONAL                      :: ounit
     224             : 
     225             :       CHARACTER(LEN=2)                                   :: symbol
     226             :       INTEGER                                            :: i, ikind, nkind, output_unit
     227        6330 :       TYPE(atomic_kind_type), DIMENSION(:), POINTER      :: atomic_kind_set
     228             :       TYPE(cp_logger_type), POINTER                      :: logger
     229             :       TYPE(qs_atom_dispersion_type), POINTER             :: disp
     230        6330 :       TYPE(qs_kind_type), DIMENSION(:), POINTER          :: qs_kind_set
     231             :       TYPE(section_vals_type), POINTER                   :: dft_section
     232             : 
     233        6330 :       IF (PRESENT(ounit)) THEN
     234           0 :          output_unit = ounit
     235             :       ELSE
     236        6330 :          NULLIFY (logger)
     237        6330 :          logger => cp_get_default_logger()
     238             : 
     239        6330 :          dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
     240             :          output_unit = cp_print_key_unit_nr(logger, dft_section, &
     241        6330 :                                             "PRINT%DFT_CONTROL_PARAMETERS", extension=".Log")
     242             :       END IF
     243             : 
     244        6330 :       IF (output_unit > 0) THEN
     245             :          ! vdW type specific output
     246        1418 :          IF (dispersion_env%type == xc_vdw_fun_pairpot) THEN
     247          58 :             WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T67,'Pair Potential')")
     248             :             ! Pair potentials
     249          58 :             IF (dispersion_env%pp_type == vdw_pairpot_dftd2) THEN
     250           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T35,'DFT-D2')")
     251           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T35,'Potential Form: S. Grimme, JCC 27: 1787 (2006)')")
     252           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T35,'Cutoff Radius [Bohr]:',T73,F8.2)") dispersion_env%rc_disp
     253           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T35,'Scaling Factor:',T73,F8.4)") dispersion_env%scaling
     254           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T35,'Exp Prefactor for Damping:',T73,F8.1)") dispersion_env%exp_pre
     255           8 :                CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
     256           8 :                nkind = SIZE(atomic_kind_set)
     257          19 :                DO ikind = 1, nkind
     258          11 :                   CALL get_atomic_kind(atomic_kind_set(ikind), element_symbol=symbol)
     259          11 :                   CALL get_qs_kind(qs_kind_set(ikind), dispersion=disp)
     260          19 :                   IF (disp%defined) THEN
     261             :                      WRITE (output_unit, fmt="(' vdW PARAMETER| ',T18,'Atom=',A2, "// &
     262             :                             "T28,'C6[J*nm^6*mol^-1]=',F8.4,T63,'r(vdW)[A]=',F8.4)") &
     263          11 :                         symbol, disp%c6/(1000._dp*bohr**6/kjmol), disp%vdw_radii/bohr
     264             :                   ELSE
     265           0 :                      WRITE (output_unit, fmt="(' vdW PARAMETER| ',T20,'Atom=',A2,T70,'not defined')")
     266             :                   END IF
     267             :                END DO
     268          50 :             ELSE IF (dispersion_env%pp_type == vdw_pairpot_dftd3) THEN
     269           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'DFT-D3 (Version 3.1)')")
     270           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Potential Form: S. Grimme et al, JCP 132: 154104 (2010)')")
     271           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Zero Damping')")
     272           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Cutoff Radius [Bohr]:',T73,F8.2)") dispersion_env%rc_disp
     273           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'s6 Scaling Factor:',T73,F8.4)") dispersion_env%s6
     274           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'sr6 Scaling Factor:',T73,F8.4)") dispersion_env%sr6
     275           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'s8 Scaling Factor:',T73,F8.4)") dispersion_env%s8
     276           8 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Cutoff for CN calculation:',T69,E12.4)") dispersion_env%eps_cn
     277           8 :                IF (dispersion_env%nd3_exclude_pair > 0) THEN
     278           0 :                   DO i = 1, dispersion_env%nd3_exclude_pair
     279             :                      WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Excluded Pairs: ',T76,I2,' ',I2)") &
     280           0 :                         dispersion_env%d3_exclude_pair(i, :)
     281             :                   END DO
     282             :                END IF
     283          42 :             ELSE IF (dispersion_env%pp_type == vdw_pairpot_dftd3bj) THEN
     284          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'DFT-D3 (Version 3.1)')")
     285          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Potential Form: S. Grimme et al, JCP 132: 154104 (2010)')")
     286          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'BJ Damping: S. Grimme et al, JCC 32: 1456 (2011)')")
     287          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Cutoff Radius [Bohr]:',T73,F8.2)") dispersion_env%rc_disp
     288          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'s6 Scaling Factor:',T73,F8.4)") dispersion_env%s6
     289          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'a1 Damping Factor:',T73,F8.4)") dispersion_env%a1
     290          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'s8 Scaling Factor:',T73,F8.4)") dispersion_env%s8
     291          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'a2 Damping Factor:',T73,F8.4)") dispersion_env%a2
     292          39 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Cutoff for CN calculation:',T69,E12.4)") dispersion_env%eps_cn
     293          39 :                IF (dispersion_env%nd3_exclude_pair > 0) THEN
     294           0 :                   DO i = 1, dispersion_env%nd3_exclude_pair
     295             :                      WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'Excluded Kind Pairs: ',T76,I2,' ',I2)") &
     296           0 :                         dispersion_env%d3_exclude_pair(i, :)
     297             :                   END DO
     298             :                END IF
     299           3 :             ELSE IF (dispersion_env%pp_type == vdw_pairpot_dftd4) THEN
     300           3 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'DFT-D4(Version 3.6.0)')")
     301           3 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'see https://github.com/dftd4/dftd4')")
     302           3 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'E. Caldeweyher et al, PCCP 22: 8499 (2020)')")
     303           3 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'E. Caldeweyher et al, JCP 150: 154122 (2019)')")
     304           3 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T26,'E. Caldeweyher et al, JCP 147: 034112 (2017)')")
     305             :             END IF
     306        1360 :          ELSE IF (dispersion_env%type == xc_vdw_fun_nonloc) THEN
     307          13 :             WRITE (output_unit, fmt="(' vdW POTENTIAL| ',T61,'Non-local Functional')")
     308             :             WRITE (output_unit, &
     309          13 :                    fmt="(' vdW POTENTIAL| ','Implementation: G. Roman-Perez, J. Soler, PRL 103: 096102 (2009)')")
     310             :             WRITE (output_unit, &
     311          13 :                    fmt="(' vdW POTENTIAL| ',T38,' T. Thonhauser et al, PRB 76: 125112 (2007)')")
     312             :             WRITE (output_unit, &
     313          13 :                    fmt="(' vdW POTENTIAL| ',T22,' R. Sabatini et al, J.Phys:Condens Matter 24: 424209 (2012)')")
     314             :             WRITE (output_unit, &
     315          13 :                    fmt="(' vdW POTENTIAL| ',T16,' Based on QE implementation by Brian Kolb, Timo Thonhauser (2009)')")
     316          13 :             SELECT CASE (dispersion_env%nl_type)
     317             :             CASE DEFAULT
     318             :                ! unknown functional
     319           0 :                CPABORT("")
     320             :             CASE (vdw_nl_DRSLL)
     321             :                WRITE (output_unit, &
     322           8 :                       fmt="(' vdW POTENTIAL| ','DRSLL Functional:           M. Dion et al, PRL 92: 246401 (2004)')")
     323             :             CASE (vdw_nl_LMKLL)
     324             :                WRITE (output_unit, &
     325           3 :                       fmt="(' vdW POTENTIAL| ','LMKLL Functional:            K. Lee et al, PRB 82: 081101 (2010)')")
     326             :             CASE (vdw_nl_RVV10)
     327             :                WRITE (output_unit, &
     328          13 :                       fmt="(' vdW POTENTIAL| ','RVV10 Functional:    R. Sabatini et al, PRB 87: 041108(R) (2013)')")
     329             :             END SELECT
     330          13 :             IF (dispersion_env%verbose) THEN
     331             :                WRITE (output_unit, &
     332          12 :                       fmt="(' vdW POTENTIAL| ','         Carrying out vdW-DF run using the following parameters:')")
     333             :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ','Nqs =',I8,'        Nr_points =',I8,'       r_max =',F10.3)") &
     334          12 :                   dispersion_env%nqs, dispersion_env%nr_points, dispersion_env%r_max
     335          12 :                WRITE (output_unit, fmt="(' vdW POTENTIAL| ','q_mesh =')")
     336         252 :                WRITE (output_unit, fmt="(8X,4F18.8)") (dispersion_env%q_mesh(i), i=1, dispersion_env%nqs)
     337             :                WRITE (output_unit, &
     338             :                       fmt="(' vdW POTENTIAL| ','Density cutoff for convolution [a.u.]:',T71,F10.1)") &
     339          12 :                   dispersion_env%pw_cutoff
     340             :             END IF
     341             :          END IF
     342             :       END IF
     343        6330 :       IF (.NOT. PRESENT(ounit)) THEN
     344             :          CALL cp_print_key_finished_output(output_unit, logger, dft_section, &
     345        6330 :                                            "PRINT%DFT_CONTROL_PARAMETERS")
     346             :       END IF
     347             : 
     348        6330 :    END SUBROUTINE qs_write_dispersion
     349             : 
     350             : ! **************************************************************************************************
     351             : !> \brief ...
     352             : !> \param scaling ...
     353             : !> \param vdw_section ...
     354             : ! **************************************************************************************************
     355           8 :    SUBROUTINE qs_scaling_dftd2(scaling, vdw_section)
     356             :       REAL(KIND=dp), INTENT(inout)                       :: scaling
     357             :       TYPE(section_vals_type), POINTER                   :: vdw_section
     358             : 
     359             :       CHARACTER(LEN=default_string_length)               :: functional
     360             : 
     361           8 :       CALL section_vals_val_get(vdw_section, "PAIR_POTENTIAL%REFERENCE_FUNCTIONAL", c_val=functional)
     362             : 
     363           8 :       SELECT CASE (TRIM(functional))
     364             :       CASE DEFAULT
     365             :          ! unknown functional
     366           0 :          CPABORT("No DFT-D2 s6 value available for this functional:"//TRIM(functional))
     367             :       CASE ("BLYP")
     368           2 :          scaling = 1.20_dp
     369             :       CASE ("B3LYP")
     370           0 :          scaling = 1.05_dp
     371             :       CASE ("TPSS")
     372           0 :          scaling = 1.00_dp
     373             :       CASE ("PBE")
     374           6 :          scaling = 0.75_dp
     375             :       CASE ("PBE0")
     376           0 :          scaling = 0.6_dp
     377             :       CASE ("B2PLYP")
     378           0 :          scaling = 0.55_dp
     379             :       CASE ("BP86")
     380           0 :          scaling = 1.05_dp
     381             :       CASE ("B97")
     382           8 :          scaling = 1.25_dp
     383             :       END SELECT
     384             : 
     385           8 :    END SUBROUTINE qs_scaling_dftd2
     386             : 
     387             : ! **************************************************************************************************
     388             : !> \brief ...
     389             : !> \param s6 ...
     390             : !> \param sr6 ...
     391             : !> \param s8 ...
     392             : !> \param vdw_section ...
     393             : ! **************************************************************************************************
     394          38 :    SUBROUTINE qs_scaling_dftd3(s6, sr6, s8, vdw_section)
     395             : 
     396             :       REAL(KIND=dp), INTENT(inout)                       :: s6, sr6, s8
     397             :       TYPE(section_vals_type), POINTER                   :: vdw_section
     398             : 
     399             :       CHARACTER(LEN=default_string_length)               :: functional
     400             : 
     401          38 :       CALL section_vals_val_get(vdw_section, "PAIR_POTENTIAL%REFERENCE_FUNCTIONAL", c_val=functional)
     402          38 :       CALL uppercase(functional)
     403             :       ! values for different functionals from:
     404             :       ! https://www.chemie.uni-bonn.de/grimme/de/software/dft-d3
     405             :       ! L. Goerigk et al. PCCP 2017, 32147-32744, SI
     406          38 :       SELECT CASE (TRIM(functional))
     407             :       CASE DEFAULT
     408             :          ! unknown functional
     409           0 :          CPABORT("No DFT-D3 values available for this functional:"//TRIM(functional))
     410             :       CASE ("B1B95")
     411           0 :          s6 = 1.000_dp
     412           0 :          sr6 = 1.613_dp
     413           0 :          s8 = 1.868_dp
     414             :       CASE ("B2GPPLYP")
     415             :          ! L. Goerigk and S. Grimme
     416             :          ! J. Chem. Theory Comput. 2011, 7, 291-309; doi:10.1021/ct100466k
     417           0 :          s6 = 0.56_dp
     418           0 :          sr6 = 1.586_dp
     419           0 :          s8 = 0.760_dp
     420             :       CASE ("B2PLYP")
     421             :          ! L. Goerigk and S. Grimme
     422             :          ! J. Chem. Theory Comput. 2011, 7, 291-309; doi:10.1021/ct100466k
     423           2 :          s6 = 0.64_dp
     424           2 :          sr6 = 1.427_dp
     425           2 :          s8 = 1.022_dp
     426             :       CASE ("DSD-BLYP")
     427             :          ! L. Goerigk and S. Grimme
     428             :          ! J. Chem. Theory Comput. 2011, 7, 291-309; doi:10.1021/ct100466k
     429           0 :          s6 = 0.50_dp
     430           0 :          sr6 = 1.569_dp
     431           0 :          s8 = 0.705_dp
     432             :       CASE ("B3LYP")
     433             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     434             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     435           0 :          s6 = 1.000_dp
     436           0 :          sr6 = 1.261_dp
     437           0 :          s8 = 1.703_dp
     438             :       CASE ("B97-D")
     439             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     440             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     441           0 :          s6 = 1.000_dp
     442           0 :          sr6 = 0.892_dp
     443           0 :          s8 = 0.909_dp
     444             :       CASE ("BHLYP")
     445           0 :          s6 = 1.000_dp
     446           0 :          sr6 = 1.370_dp
     447           0 :          s8 = 1.442_dp
     448             :       CASE ("BLYP")
     449             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     450             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     451           0 :          s6 = 1.000_dp
     452           0 :          sr6 = 1.094_dp
     453           0 :          s8 = 1.682_dp
     454             :       CASE ("BP86")
     455             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     456             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     457           0 :          s6 = 1.000_dp
     458           0 :          sr6 = 1.139_dp
     459           0 :          s8 = 1.683_dp
     460             :       CASE ("BPBE")
     461           0 :          s6 = 1.000_dp
     462           0 :          sr6 = 1.087_dp
     463           0 :          s8 = 2.033_dp
     464             :       CASE ("MPWLYP")
     465           0 :          s6 = 1.000_dp
     466           0 :          sr6 = 1.239_dp
     467           0 :          s8 = 1.098_dp
     468             :       CASE ("PBE")
     469             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     470             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     471          36 :          s6 = 1.000_dp
     472          36 :          sr6 = 1.217_dp
     473          36 :          s8 = 0.722_dp
     474             :       CASE ("PBEHPBE")
     475           0 :          s6 = 1.000_dp
     476           0 :          sr6 = 1.5703_dp
     477           0 :          s8 = 1.4010_dp
     478             :       CASE ("PBE0")
     479             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     480             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     481           0 :          s6 = 1.000_dp
     482           0 :          sr6 = 1.287_dp
     483           0 :          s8 = 0.928_dp
     484             :       CASE ("PW6B95")
     485             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     486             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     487           0 :          s6 = 1.000_dp
     488           0 :          sr6 = 1.532_dp
     489           0 :          s8 = 0.862_dp
     490             :       CASE ("PWB6K")
     491           0 :          s6 = 1.000_dp
     492           0 :          sr6 = 1.660_dp
     493           0 :          s8 = 0.550_dp
     494             :       CASE ("REVPBE")
     495             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     496             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     497           0 :          s6 = 1.000_dp
     498           0 :          sr6 = 0.923_dp
     499           0 :          s8 = 1.010_dp
     500             :       CASE ("RPBE")
     501           0 :          s6 = 1.000_dp
     502           0 :          sr6 = 0.872_dp
     503           0 :          s8 = 0.514_dp
     504             :       CASE ("TPSS")
     505             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     506             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     507           0 :          s6 = 1.000_dp
     508           0 :          sr6 = 1.166_dp
     509           0 :          s8 = 1.105_dp
     510             :       CASE ("TPSS0")
     511             :          ! S. Grimme, J. Antony, S. Ehrlich, and H. Krieg
     512             :          ! J. Chem. Phys. 132,154104 (2010); doi:10.1063/1.3382344
     513           0 :          s6 = 1.000_dp
     514           0 :          sr6 = 1.252_dp
     515           0 :          s8 = 1.242_dp
     516             :       CASE ("TPSSH")
     517           0 :          s6 = 1.000_dp
     518           0 :          sr6 = 1.223_dp
     519           0 :          s8 = 1.219_dp
     520             :       CASE ("B1LYP")
     521           0 :          s6 = 1.000_dp
     522           0 :          sr6 = 1.3725_dp
     523           0 :          s8 = 1.9467_dp
     524             :       CASE ("B1P86")
     525           0 :          s6 = 1.000_dp
     526           0 :          sr6 = 1.1815_dp
     527           0 :          s8 = 1.1209_dp
     528             :       CASE ("B3P86")
     529           0 :          s6 = 1.000_dp
     530           0 :          sr6 = 1.1897_dp
     531           0 :          s8 = 1.1961_dp
     532             :       CASE ("B3PW91")
     533           0 :          s6 = 1.000_dp
     534           0 :          sr6 = 1.176_dp
     535           0 :          s8 = 1.775_dp
     536             :       CASE ("BMK")
     537           0 :          s6 = 1.000_dp
     538           0 :          sr6 = 1.931_dp
     539           0 :          s8 = 2.168_dp
     540             :       CASE ("CAMB3LYP")
     541           0 :          s6 = 1.000_dp
     542           0 :          sr6 = 1.378_dp
     543           0 :          s8 = 1.217_dp
     544             :       CASE ("LCWPBE")
     545           0 :          s6 = 1.000_dp
     546           0 :          sr6 = 1.355_dp
     547           0 :          s8 = 1.279_dp
     548             :       CASE ("M052X")
     549           0 :          s6 = 1.000_dp
     550           0 :          sr6 = 1.417_dp
     551           0 :          s8 = 0.000_dp
     552             :       CASE ("M05")
     553           0 :          s6 = 1.000_dp
     554           0 :          sr6 = 1.373_dp
     555           0 :          s8 = 0.595_dp
     556             :       CASE ("M062X")
     557           0 :          s6 = 1.000_dp
     558           0 :          sr6 = 1.619_dp
     559           0 :          s8 = 0.000_dp
     560             :       CASE ("M06HF")
     561           0 :          s6 = 1.000_dp
     562           0 :          sr6 = 1.446_dp
     563           0 :          s8 = 0.000_dp
     564             :       CASE ("M06L")
     565           0 :          s6 = 1.000_dp
     566           0 :          sr6 = 1.581_dp
     567           0 :          s8 = 0.000_dp
     568             :       CASE ("M06N")
     569           0 :          s6 = 1.000_dp
     570           0 :          sr6 = 1.325_dp
     571           0 :          s8 = 0.000_dp
     572             :       CASE ("HCTH120")
     573           0 :          s6 = 1.000_dp
     574           0 :          sr6 = 1.221_dp
     575           0 :          s8 = 1.206_dp
     576             :       CASE ("HCTH407")
     577           0 :          s6 = 1.000_dp
     578           0 :          sr6 = 4.0426_dp
     579           0 :          s8 = 2.7694_dp
     580             :       CASE ("MPW2PLYP")
     581           0 :          s6 = 1.000_dp
     582           0 :          sr6 = 1.5527_dp
     583           0 :          s8 = 0.7529_dp
     584             :       CASE ("PKZB")
     585           0 :          s6 = 1.000_dp
     586           0 :          sr6 = 0.6327_dp
     587           0 :          s8 = 0.000_dp
     588             :       CASE ("PTPSS")
     589           0 :          s6 = 0.750_dp
     590           0 :          sr6 = 1.541_dp
     591           0 :          s8 = 0.879_dp
     592             :       CASE ("PWPB95")
     593           0 :          s6 = 0.820_dp
     594           0 :          sr6 = 1.557_dp
     595           0 :          s8 = 0.705_dp
     596             :       CASE ("OLYP")
     597           0 :          s6 = 1.000_dp
     598           0 :          sr6 = 0.806_dp
     599           0 :          s8 = 1.764_dp
     600             :       CASE ("OPBE")
     601           0 :          s6 = 1.000_dp
     602           0 :          sr6 = 0.837_dp
     603           0 :          s8 = 2.055_dp
     604             :       CASE ("OTPSS")
     605           0 :          s6 = 1.000_dp
     606           0 :          sr6 = 1.128_dp
     607           0 :          s8 = 1.494_dp
     608             :       CASE ("PBE1KCIS")
     609           0 :          s6 = 1.000_dp
     610           0 :          sr6 = 3.6355_dp
     611           0 :          s8 = 1.7934_dp
     612             :       CASE ("PBE38")
     613           0 :          s6 = 1.000_dp
     614           0 :          sr6 = 1.333_dp
     615           0 :          s8 = 0.998_dp
     616             :       CASE ("PBEH1PBE")
     617           0 :          s6 = 1.000_dp
     618           0 :          sr6 = 1.3719_dp
     619           0 :          s8 = 1.0430_dp
     620             :       CASE ("PBESOL")
     621           0 :          s6 = 1.000_dp
     622           0 :          sr6 = 1.345_dp
     623           0 :          s8 = 0.612_dp
     624             :       CASE ("REVSSB")
     625           0 :          s6 = 1.000_dp
     626           0 :          sr6 = 1.221_dp
     627           0 :          s8 = 0.560_dp
     628             :       CASE ("REVTPSS")
     629           0 :          s6 = 1.000_dp
     630           0 :          sr6 = 1.3491_dp
     631           0 :          s8 = 1.3666_dp
     632             :       CASE ("SSB")
     633           0 :          s6 = 1.000_dp
     634           0 :          sr6 = 1.215_dp
     635           0 :          s8 = 0.663_dp
     636             :       CASE ("B97-1")
     637           0 :          s6 = 1.000_dp
     638           0 :          sr6 = 3.7924_dp
     639           0 :          s8 = 1.6418_dp
     640             :       CASE ("B97-2")
     641           0 :          s6 = 1.000_dp
     642           0 :          sr6 = 1.7066_dp
     643           0 :          s8 = 2.4661_dp
     644             :       CASE ("B98")
     645           0 :          s6 = 1.000_dp
     646           0 :          sr6 = 2.6895_dp
     647           0 :          s8 = 1.9078_dp
     648             :       CASE ("BOP")
     649           0 :          s6 = 1.000_dp
     650           0 :          sr6 = 0.929_dp
     651           0 :          s8 = 1.975_dp
     652             :       CASE ("HISS")
     653           0 :          s6 = 1.000_dp
     654           0 :          sr6 = 1.3338_dp
     655           0 :          s8 = 0.7615_dp
     656             :       CASE ("HSE03")
     657           0 :          s6 = 1.000_dp
     658           0 :          sr6 = 1.3944_dp
     659           0 :          s8 = 1.0156_dp
     660             :       CASE ("HSE06")
     661           0 :          s6 = 1.000_dp
     662           0 :          sr6 = 1.129_dp
     663           0 :          s8 = 0.109_dp
     664             :       CASE ("M08HX")
     665           0 :          s6 = 1.000_dp
     666           0 :          sr6 = 1.6247_dp
     667           0 :          s8 = 0.000_dp
     668             :       CASE ("MN15L")
     669           0 :          s6 = 1.000_dp
     670           0 :          sr6 = 3.3388_dp
     671           0 :          s8 = 0.000_dp
     672             :       CASE ("MPWPW91")
     673           0 :          s6 = 1.0000_dp
     674           0 :          sr6 = 1.3725_dp
     675           0 :          s8 = 1.9467_dp
     676             :       CASE ("MPW1B95")
     677           0 :          s6 = 1.000_dp
     678           0 :          sr6 = 1.605_dp
     679           0 :          s8 = 1.118_dp
     680             :       CASE ("MPW1KCIS")
     681           0 :          s6 = 1.000_dp
     682           0 :          sr6 = 1.7231_dp
     683           0 :          s8 = 2.2917_dp
     684             :       CASE ("MPW1LYP")
     685           0 :          s6 = 1.000_dp
     686           0 :          sr6 = 2.0512_dp
     687           0 :          s8 = 1.9529_dp
     688             :       CASE ("MPW1PW91")
     689           0 :          s6 = 1.000_dp
     690           0 :          sr6 = 1.2892_dp
     691           0 :          s8 = 1.4758_dp
     692             :       CASE ("MPWB1K")
     693           0 :          s6 = 1.000_dp
     694           0 :          sr6 = 1.671_dp
     695           0 :          s8 = 1.061_dp
     696             :       CASE ("MPWKCIS1K")
     697           0 :          s6 = 1.000_dp
     698           0 :          sr6 = 1.4853_dp
     699           0 :          s8 = 1.7553_dp
     700             :       CASE ("O3LYP")
     701           0 :          s6 = 1.000_dp
     702           0 :          sr6 = 1.4060_dp
     703           0 :          s8 = 1.8058_dp
     704             :       CASE ("PW1PW")
     705           0 :          s6 = 1.000_dp
     706           0 :          sr6 = 1.4968_dp
     707           0 :          s8 = 1.1786_dp
     708             :       CASE ("PW91P86")
     709           0 :          s6 = 1.0000_dp
     710           0 :          sr6 = 2.1040_dp
     711           0 :          s8 = 0.8747_dp
     712             :       CASE ("REVPBE0")
     713           0 :          s6 = 1.000_dp
     714           0 :          sr6 = 0.949_dp
     715           0 :          s8 = 0.792_dp
     716             :       CASE ("REVPBE38")
     717           0 :          s6 = 1.000_dp
     718           0 :          sr6 = 1.021_dp
     719           0 :          s8 = 0.862_dp
     720             :       CASE ("REVTPSSh")
     721           0 :          s6 = 1.000_dp
     722           0 :          sr6 = 1.3224_dp
     723           0 :          s8 = 1.2504_dp
     724             :       CASE ("REVTPSS0")
     725           0 :          s6 = 1.000_dp
     726           0 :          sr6 = 1.2881_dp
     727           0 :          s8 = 1.0649_dp
     728             :       CASE ("TPSS1KCIS")
     729           0 :          s6 = 1.000_dp
     730           0 :          sr6 = 1.7729_dp
     731           0 :          s8 = 2.0902_dp
     732             :       CASE ("THCTHHYB")
     733           0 :          s6 = 1.000_dp
     734           0 :          sr6 = 1.5001_dp
     735           0 :          s8 = 1.6302_dp
     736             :       CASE ("RPW86PBE")
     737           0 :          s6 = 1.000_dp
     738           0 :          sr6 = 1.224_dp
     739           0 :          s8 = 0.901_dp
     740             :       CASE ("SCAN")
     741           0 :          s6 = 1.000_dp
     742           0 :          sr6 = 1.324_dp
     743           0 :          s8 = 0.000_dp
     744             :       CASE ("THCTH")
     745           0 :          s6 = 1.000_dp
     746           0 :          sr6 = 0.932_dp
     747           0 :          s8 = 0.5662_dp
     748             :       CASE ("XLYP")
     749           0 :          s6 = 1.0000_dp
     750           0 :          sr6 = 0.9384_dp
     751           0 :          s8 = 0.7447_dp
     752             :       CASE ("X3LYP")
     753           0 :          s6 = 1.000_dp
     754           0 :          sr6 = 1.0000_dp
     755          38 :          s8 = 0.2990_dp
     756             :       END SELECT
     757             : 
     758          38 :    END SUBROUTINE qs_scaling_dftd3
     759             : 
     760             : ! **************************************************************************************************
     761             : !> \brief ...
     762             : !> \param s6 ...
     763             : !> \param a1 ...
     764             : !> \param s8 ...
     765             : !> \param a2 ...
     766             : !> \param vdw_section ...
     767             : ! **************************************************************************************************
     768          16 :    SUBROUTINE qs_scaling_dftd3bj(s6, a1, s8, a2, vdw_section)
     769             :       REAL(KIND=dp), INTENT(inout)                       :: s6, a1, s8, a2
     770             :       TYPE(section_vals_type), POINTER                   :: vdw_section
     771             : 
     772             :       CHARACTER(LEN=default_string_length)               :: functional
     773             : 
     774          16 :       CALL section_vals_val_get(vdw_section, "PAIR_POTENTIAL%REFERENCE_FUNCTIONAL", c_val=functional)
     775             : 
     776             :       ! values for different functionals from:
     777             :       ! http://www.thch.uni-bonn.de/tc/downloads/DFT-D3/functionalsbj.html
     778             :       ! L. Goerigk et al. PCCP 2017, 32147-32744, SI
     779          16 :       SELECT CASE (TRIM(functional))
     780             :       CASE DEFAULT
     781             :          ! unknown functional
     782           0 :          CPABORT("No DFT-D3(BJ) values available for this functional:"//TRIM(functional))
     783             :       CASE ("B1B95")
     784           0 :          s6 = 1.0000_dp
     785           0 :          a1 = 0.2092_dp
     786           0 :          s8 = 1.4507_dp
     787           0 :          a2 = 5.5545_dp
     788             :       CASE ("B2GPPLYP")
     789           0 :          s6 = 0.5600_dp
     790           0 :          a1 = 0.0000_dp
     791           0 :          s8 = 0.2597_dp
     792           0 :          a2 = 6.3332_dp
     793             :       CASE ("B3PW91")
     794           0 :          s6 = 1.0000_dp
     795           0 :          a1 = 0.4312_dp
     796           0 :          s8 = 2.8524_dp
     797           0 :          a2 = 4.4693_dp
     798             :       CASE ("BHLYP")
     799           0 :          s6 = 1.0000_dp
     800           0 :          a1 = 0.2793_dp
     801           0 :          s8 = 1.0354_dp
     802           0 :          a2 = 4.9615_dp
     803             :       CASE ("BMK")
     804           0 :          s6 = 1.0000_dp
     805           0 :          a1 = 0.1940_dp
     806           0 :          s8 = 2.0860_dp
     807           0 :          a2 = 5.9197_dp
     808             :       CASE ("BOP")
     809           0 :          s6 = 1.0000_dp
     810           0 :          a1 = 0.4870_dp
     811           0 :          s8 = 3.2950_dp
     812           0 :          a2 = 3.5043_dp
     813             :       CASE ("BPBE")
     814           0 :          s6 = 1.0000_dp
     815           0 :          a1 = 0.4567_dp
     816           0 :          s8 = 4.0728_dp
     817           0 :          a2 = 4.3908_dp
     818             :       CASE ("B97-3c")
     819           4 :          s6 = 1.0000_dp
     820           4 :          a1 = 0.3700_dp
     821           4 :          s8 = 1.5000_dp
     822           4 :          a2 = 4.1000_dp
     823             :       CASE ("CAMB3LYP")
     824           0 :          s6 = 1.0000_dp
     825           0 :          a1 = 0.3708_dp
     826           0 :          s8 = 2.0674_dp
     827           0 :          a2 = 5.4743_dp
     828             :       CASE ("DSDBLYP")
     829           0 :          s6 = 0.5000_dp
     830           0 :          a1 = 0.0000_dp
     831           0 :          s8 = 0.2130_dp
     832           0 :          a2 = 6.0519_dp
     833             :       CASE ("DSDPBEP86")
     834           0 :          s6 = 0.4180_dp
     835           0 :          a1 = 0.0000_dp
     836           0 :          s8 = 0.0000_dp
     837           0 :          a2 = 5.6500_dp
     838             :       CASE ("DSDPBEB95")
     839           0 :          s6 = 0.6100_dp
     840           0 :          a1 = 0.0000_dp
     841           0 :          s8 = 0.0000_dp
     842           0 :          a2 = 6.2000_dp
     843             :       CASE ("LCWPBE")
     844           0 :          s6 = 1.0000_dp
     845           0 :          a1 = 0.3919_dp
     846           0 :          s8 = 1.8541_dp
     847           0 :          a2 = 5.0897_dp
     848             :       CASE ("LCWhPBE")
     849           0 :          s6 = 1.0000_dp
     850           0 :          a1 = 0.2746_dp
     851           0 :          s8 = 1.1908_dp
     852           0 :          a2 = 5.3157_dp
     853             :       CASE ("MPW1B95")
     854           0 :          s6 = 1.0000_dp
     855           0 :          a1 = 0.1955_dp
     856           0 :          s8 = 1.0508_dp
     857           0 :          a2 = 6.4177_dp
     858             :       CASE ("MPW2PLYP")
     859           0 :          s6 = 0.6600_dp
     860           0 :          a1 = 0.4105_dp
     861           0 :          s8 = 0.6223_dp
     862           0 :          a2 = 5.0136_dp
     863             :       CASE ("MPWB1K")
     864           0 :          s6 = 1.0000_dp
     865           0 :          a1 = 0.1474_dp
     866           0 :          s8 = 0.9499_dp
     867           0 :          a2 = 6.6223_dp
     868             :       CASE ("MPWLYP")
     869           0 :          s6 = 1.0000_dp
     870           0 :          a1 = 0.4831_dp
     871           0 :          s8 = 2.0077_dp
     872           0 :          a2 = 4.5323_dp
     873             :       CASE ("OLYP")
     874           0 :          s6 = 1.0000_dp
     875           0 :          a1 = 0.5299_dp
     876           0 :          s8 = 2.6205_dp
     877           0 :          a2 = 2.8065_dp
     878             :       CASE ("OPBE")
     879           0 :          s6 = 1.0000_dp
     880           0 :          a1 = 0.5512_dp
     881           0 :          s8 = 3.3816_dp
     882           0 :          a2 = 2.9444_dp
     883             :       CASE ("OTPSS")
     884           0 :          s6 = 1.0000_dp
     885           0 :          a1 = 0.4634_dp
     886           0 :          s8 = 2.7495_dp
     887           0 :          a2 = 4.3153_dp
     888             :       CASE ("PBE38")
     889           0 :          s6 = 1.0000_dp
     890           0 :          a1 = 0.3995_dp
     891           0 :          s8 = 1.4623_dp
     892           0 :          a2 = 5.1405_dp
     893             :       CASE ("PBEsol")
     894           0 :          s6 = 1.0000_dp
     895           0 :          a1 = 0.4466_dp
     896           0 :          s8 = 2.9491_dp
     897           0 :          a2 = 6.1742_dp
     898             :       CASE ("PTPSS")
     899           0 :          s6 = 0.7500_dp
     900           0 :          a1 = 0.0000_dp
     901           0 :          s8 = 0.2804_dp
     902           0 :          a2 = 6.5745_dp
     903             :       CASE ("PWB6K")
     904           0 :          s6 = 1.0000_dp
     905           0 :          a1 = 0.1805_dp
     906           0 :          s8 = 0.9383_dp
     907           0 :          a2 = 7.7627_dp
     908             :       CASE ("revSSB")
     909           0 :          s6 = 1.0000_dp
     910           0 :          a1 = 0.4720_dp
     911           0 :          s8 = 0.4389_dp
     912           0 :          a2 = 4.0986_dp
     913             :       CASE ("SSB")
     914           0 :          s6 = 1.0000_dp
     915           0 :          a1 = -0.0952_dp
     916           0 :          s8 = -0.1744_dp
     917           0 :          a2 = 5.2170_dp
     918             :       CASE ("TPSSh")
     919           0 :          s6 = 1.0000_dp
     920           0 :          a1 = 0.4529_dp
     921           0 :          s8 = 2.2382_dp
     922           0 :          a2 = 4.6550_dp
     923             :       CASE ("HCTH120")
     924           0 :          s6 = 1.0000_dp
     925           0 :          a1 = 0.3563_dp
     926           0 :          s8 = 1.0821_dp
     927           0 :          a2 = 4.3359_dp
     928             :       CASE ("B2PLYP")
     929           0 :          s6 = 0.6400_dp
     930           0 :          a1 = 0.3065_dp
     931           0 :          s8 = 0.9147_dp
     932           0 :          a2 = 5.0570_dp
     933             :       CASE ("B1LYP")
     934           0 :          s6 = 1.0000_dp
     935           0 :          a1 = 0.1986_dp
     936           0 :          s8 = 2.1167_dp
     937           0 :          a2 = 5.3875_dp
     938             :       CASE ("B1P86")
     939           0 :          s6 = 1.0000_dp
     940           0 :          a1 = 0.4724_dp
     941           0 :          s8 = 3.5681_dp
     942           0 :          a2 = 4.9858_dp
     943             :       CASE ("B3LYP")
     944           0 :          s6 = 1.0000_dp
     945           0 :          a1 = 0.3981_dp
     946           0 :          s8 = 1.9889_dp
     947           0 :          a2 = 4.4211_dp
     948             :       CASE ("B3P86")
     949           0 :          s6 = 1.0000_dp
     950           0 :          a1 = 0.4601_dp
     951           0 :          s8 = 3.3211_dp
     952           0 :          a2 = 4.9294_dp
     953             :       CASE ("B97-1")
     954           0 :          s6 = 1.0000_dp
     955           0 :          a1 = 0.0000_dp
     956           0 :          s8 = 0.4814_dp
     957           0 :          a2 = 6.2279_dp
     958             :       CASE ("B97-2")
     959           0 :          s6 = 1.0000_dp
     960           0 :          a1 = 0.0000_dp
     961           0 :          s8 = 0.9448_dp
     962           0 :          a2 = 5.4603_dp
     963             :       CASE ("B97-D")
     964           0 :          s6 = 1.0000_dp
     965           0 :          a1 = 0.5545_dp
     966           0 :          s8 = 2.2609_dp
     967           0 :          a2 = 3.2297_dp
     968             :       CASE ("B98")
     969           0 :          s6 = 1.0000_dp
     970           0 :          a1 = 0.0000_dp
     971           0 :          s8 = 0.7086_dp
     972           0 :          a2 = 6.0672_dp
     973             :       CASE ("BLYP")
     974           2 :          s6 = 1.0000_dp
     975           2 :          a1 = 0.4298_dp
     976           2 :          s8 = 2.6996_dp
     977           2 :          a2 = 4.2359_dp
     978             :       CASE ("BP86")
     979           0 :          s6 = 1.0000_dp
     980           0 :          a1 = 0.3946_dp
     981           0 :          s8 = 3.2822_dp
     982           0 :          a2 = 4.8516_dp
     983             :       CASE ("DSD-BLYP")
     984           0 :          s6 = 0.5000_dp
     985           0 :          a1 = 0.0000_dp
     986           0 :          s8 = 0.2130_dp
     987           0 :          a2 = 6.0519_dp
     988             :       CASE ("HCTH407")
     989           0 :          s6 = 1.0000_dp
     990           0 :          a1 = 0.0000_dp
     991           0 :          s8 = 0.6490_dp
     992           0 :          a2 = 4.8162_dp
     993             :       CASE ("HISS")
     994           0 :          s6 = 1.0000_dp
     995           0 :          a1 = 0.0000_dp
     996           0 :          s8 = 1.6112_dp
     997           0 :          a2 = 7.3539_dp
     998             :       CASE ("HSE03")
     999           0 :          s6 = 1.0000_dp
    1000           0 :          a1 = 0.0000_dp
    1001           0 :          s8 = 1.1243_dp
    1002           0 :          a2 = 6.8889_dp
    1003             :       CASE ("HSE06")
    1004           0 :          s6 = 1.0000_dp
    1005           0 :          a1 = 0.3830_dp
    1006           0 :          s8 = 2.3100_dp
    1007           0 :          a2 = 5.6850_dp
    1008             :       CASE ("M11")
    1009           0 :          s6 = 1.0000_dp
    1010           0 :          a1 = 0.0000_dp
    1011           0 :          s8 = 2.8112_dp
    1012           0 :          a2 = 10.1389_dp
    1013             :       CASE ("MN12SX")
    1014           0 :          s6 = 1.0000_dp
    1015           0 :          a1 = 0.0983_dp
    1016           0 :          s8 = 1.1674_dp
    1017           0 :          a2 = 8.0259_dp
    1018             :       CASE ("MN15")
    1019           0 :          s6 = 1.0000_dp
    1020           0 :          a1 = 2.0971_dp
    1021           0 :          s8 = 0.7862_dp
    1022           0 :          a2 = 7.5923_dp
    1023             :       CASE ("mPWPW91")
    1024           0 :          s6 = 1.0000_dp
    1025           0 :          a1 = 0.3168_dp
    1026           0 :          s8 = 1.7974_dp
    1027           0 :          a2 = 4.7732_dp
    1028             :       CASE ("MPW1PW91")
    1029           0 :          s6 = 1.0000_dp
    1030           0 :          a1 = 0.3342_dp
    1031           0 :          s8 = 1.8744_dp
    1032           0 :          a2 = 4.9819_dp
    1033             :       CASE ("MPW1KCIS")
    1034           0 :          s6 = 1.0000_dp
    1035           0 :          a1 = 0.0576_dp
    1036           0 :          s8 = 1.0893_dp
    1037           0 :          a2 = 5.5314_dp
    1038             :       CASE ("MPWKCIS1K")
    1039           0 :          s6 = 1.0000_dp
    1040           0 :          a1 = 0.0855_dp
    1041           0 :          s8 = 1.2875_dp
    1042           0 :          a2 = 5.8961_dp
    1043             :       CASE ("N12SX")
    1044           0 :          s6 = 1.0000_dp
    1045           0 :          a1 = 0.3283_dp
    1046           0 :          s8 = 2.4900_dp
    1047           0 :          a2 = 5.7898_dp
    1048             :       CASE ("O3LYP")
    1049           0 :          s6 = 1.0000_dp
    1050           0 :          a1 = 0.0963_dp
    1051           0 :          s8 = 1.8171_dp
    1052           0 :          a2 = 5.9940_dp
    1053             :       CASE ("PBE0")
    1054           0 :          s6 = 1.0000_dp
    1055           0 :          a1 = 0.4145_dp
    1056           0 :          s8 = 1.2177_dp
    1057           0 :          a2 = 4.8593_dp
    1058             :       CASE ("PBE")
    1059          10 :          s6 = 1.0000_dp
    1060          10 :          a1 = 0.4289_dp
    1061          10 :          s8 = 0.7875_dp
    1062          10 :          a2 = 4.4407_dp
    1063             :       CASE ("PBEhPBE")
    1064           0 :          s6 = 1.0000_dp
    1065           0 :          a1 = 0.0000_dp
    1066           0 :          s8 = 1.1152_dp
    1067           0 :          a2 = 6.7184_dp
    1068             :       CASE ("PBEh1PBE")
    1069           0 :          s6 = 1.0000_dp
    1070           0 :          a1 = 0.0000_dp
    1071           0 :          s8 = 1.4877_dp
    1072           0 :          a2 = 7.0385_dp
    1073             :       CASE ("PBE1KCIS")
    1074           0 :          s6 = 1.0000_dp
    1075           0 :          a1 = 0.0000_dp
    1076           0 :          s8 = 0.7688_dp
    1077           0 :          a2 = 6.2794_dp
    1078             :       CASE ("PW6B95")
    1079           0 :          s6 = 1.0000_dp
    1080           0 :          a1 = 0.2076_dp
    1081           0 :          s8 = 0.7257_dp
    1082           0 :          a2 = 6.3750_dp
    1083             :       CASE ("PWPB95")
    1084           0 :          s6 = 0.8200_dp
    1085           0 :          a1 = 0.0000_dp
    1086           0 :          s8 = 0.2904_dp
    1087           0 :          a2 = 7.3141_dp
    1088             :       CASE ("revPBE0")
    1089           0 :          s6 = 1.0000_dp
    1090           0 :          a1 = 0.4679_dp
    1091           0 :          s8 = 1.7588_dp
    1092           0 :          a2 = 3.7619_dp
    1093             :       CASE ("revPBE38")
    1094           0 :          s6 = 1.0000_dp
    1095           0 :          a1 = 0.4309_dp
    1096           0 :          s8 = 1.4760_dp
    1097           0 :          a2 = 3.9446_dp
    1098             :       CASE ("revPBE")
    1099           0 :          s6 = 1.0000_dp
    1100           0 :          a1 = 0.5238_dp
    1101           0 :          s8 = 2.3550_dp
    1102           0 :          a2 = 3.5016_dp
    1103             :       CASE ("revTPSS")
    1104           0 :          s6 = 1.0000_dp
    1105           0 :          a1 = 0.4426_dp
    1106           0 :          s8 = 1.4023_dp
    1107           0 :          a2 = 4.4723_dp
    1108             :       CASE ("revTPSS0")
    1109           0 :          s6 = 1.0000_dp
    1110           0 :          a1 = 0.2218_dp
    1111           0 :          s8 = 1.6151_dp
    1112           0 :          a2 = 5.7985_dp
    1113             :       CASE ("revTPSSh")
    1114           0 :          s6 = 1.0000_dp
    1115           0 :          a1 = 0.2660_dp
    1116           0 :          s8 = 1.4076_dp
    1117           0 :          a2 = 5.3761_dp
    1118             :       CASE ("RPBE")
    1119           0 :          s6 = 1.0000_dp
    1120           0 :          a1 = 0.1820_dp
    1121           0 :          s8 = 0.8318_dp
    1122           0 :          a2 = 4.0094_dp
    1123             :       CASE ("RPW86PBE")
    1124           0 :          s6 = 1.0000_dp
    1125           0 :          a1 = 0.4613_dp
    1126           0 :          s8 = 1.3845_dp
    1127           0 :          a2 = 4.5062_dp
    1128             :       CASE ("SCAN")
    1129           0 :          s6 = 1.0000_dp
    1130           0 :          a1 = 0.538_dp
    1131           0 :          s8 = 0.0000_dp
    1132           0 :          a2 = 5.420_dp
    1133             :       CASE ("SOGGA11X")
    1134           0 :          s6 = 1.0000_dp
    1135           0 :          a1 = 0.1330_dp
    1136           0 :          s8 = 1.1426_dp
    1137           0 :          a2 = 5.7381_dp
    1138             :       CASE ("TPSS0")
    1139           0 :          s6 = 1.0000_dp
    1140           0 :          a1 = 0.3768_dp
    1141           0 :          s8 = 1.2576_dp
    1142           0 :          a2 = 4.5865_dp
    1143             :       CASE ("TPSS1KCIS")
    1144           0 :          s6 = 1.0000_dp
    1145           0 :          a1 = 0.0000_dp
    1146           0 :          s8 = 1.0542_dp
    1147           0 :          a2 = 6.0201_dp
    1148             :       CASE ("TPSS")
    1149           0 :          s6 = 1.0000_dp
    1150           0 :          a1 = 0.4535_dp
    1151           0 :          s8 = 1.9435_dp
    1152           0 :          a2 = 4.4752_dp
    1153             :       CASE ("tHCTH")
    1154           0 :          s6 = 1.0000_dp
    1155           0 :          a1 = 0.0000_dp
    1156           0 :          s8 = 1.2626_dp
    1157           0 :          a2 = 5.6162_dp
    1158             :       CASE ("tHCTHhyb")
    1159           0 :          s6 = 1.0000_dp
    1160           0 :          a1 = 0.0000_dp
    1161           0 :          s8 = 0.9585_dp
    1162           0 :          a2 = 6.2303_dp
    1163             :       CASE ("XLYP")
    1164           0 :          s6 = 1.0000_dp
    1165           0 :          a1 = 0.0809_dp
    1166           0 :          s8 = 1.5669_dp
    1167           0 :          a2 = 5.3166_dp
    1168             :       CASE ("X3LYP")
    1169           0 :          s6 = 1.0000_dp
    1170           0 :          a1 = 0.2022_dp
    1171           0 :          s8 = 1.5744_dp
    1172          16 :          a2 = 5.4184_dp
    1173             :       END SELECT
    1174             : 
    1175          16 :    END SUBROUTINE qs_scaling_dftd3bj
    1176             : 
    1177             : ! **************************************************************************************************
    1178             : !> \brief ...
    1179             : !> \param cell ...
    1180             : !> \param ncell ...
    1181             : !> \return ...
    1182             : ! **************************************************************************************************
    1183     3498288 :    FUNCTION cellhash(cell, ncell) RESULT(hash)
    1184             :       INTEGER, DIMENSION(3), INTENT(IN)                  :: cell, ncell
    1185             :       INTEGER                                            :: hash
    1186             : 
    1187             :       INTEGER                                            :: ix, iy, iz, nx, ny, nz
    1188             : 
    1189    13993152 :       CPASSERT(ALL(ABS(cell) <= ncell))
    1190             : 
    1191     3498288 :       ix = cell(1)
    1192     3498288 :       IF (ix /= 0) THEN
    1193     2969392 :          ix = 2*ABS(ix) - (1 + SIGN(1, ix))/2
    1194             :       END IF
    1195     3498288 :       iy = cell(2)
    1196     3498288 :       IF (iy /= 0) THEN
    1197     2969404 :          iy = 2*ABS(iy) - (1 + SIGN(1, iy))/2
    1198             :       END IF
    1199     3498288 :       iz = cell(3)
    1200     3498288 :       IF (iz /= 0) THEN
    1201     2969404 :          iz = 2*ABS(iz) - (1 + SIGN(1, iz))/2
    1202             :       END IF
    1203             : 
    1204     3498288 :       nx = 2*ncell(1) + 1
    1205     3498288 :       ny = 2*ncell(2) + 1
    1206     3498288 :       nz = 2*ncell(3) + 1
    1207             : 
    1208     3498288 :       hash = ix*ny*nz + iy*nz + iz + 1
    1209             : 
    1210     3498288 :    END FUNCTION cellhash
    1211             : ! **************************************************************************************************
    1212             : 
    1213             : END MODULE qs_dispersion_utils
    1214             : 

Generated by: LCOV version 1.15