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

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief function that build the xc section of the input
      10              : !> \par History
      11              : !>      10.2009 moved out of input_cp2k_dft [jgh]
      12              : !> \author fawzi
      13              : ! **************************************************************************************************
      14              : MODULE input_cp2k_xc
      15              :    USE bibliography,                    ONLY: &
      16              :         Becke1988, Becke1997, BeckeRoussel1989, Caldeweyher2020, Chai2008, Goedecker1996, &
      17              :         Grimme2006, Grimme2010, Grimme2011, Heyd2004, Kruse2012, Lee1988, Ortiz1994, Perdew1981, &
      18              :         Perdew1996, Perdew2008, Proynov2007, Tao2003, Tran2013, Vosko1980, Wellendorff2012, &
      19              :         Zhang1998
      20              :    USE cp_output_handling,              ONLY: add_last_numeric,&
      21              :                                               cp_print_key_section_create,&
      22              :                                               high_print_level
      23              :    USE eeq_input,                       ONLY: create_eeq_control_section
      24              :    USE input_constants,                 ONLY: &
      25              :         do_adiabatic_hybrid_mcy3, do_adiabatic_model_pade, do_libxc_cpu, do_libxc_gpu, &
      26              :         fxc_funct_gga, fxc_funct_lda, fxc_funct_pade, fxc_none, gaussian, slater, vdw_nl_drsll, &
      27              :         vdw_nl_lmkll, vdw_nl_rvv10, vdw_pairpot_dftd2, vdw_pairpot_dftd2chg, vdw_pairpot_dftd3, &
      28              :         vdw_pairpot_dftd3bj, vdw_pairpot_dftd4, xc_funct_b3lyp, xc_funct_beefvdw, xc_funct_blyp, &
      29              :         xc_funct_bp, xc_funct_hcth120, xc_funct_no_shortcut, xc_funct_olyp, xc_funct_pade, &
      30              :         xc_funct_pbe, xc_funct_pbe0, xc_funct_tpss, xc_none, xc_pot_energy_none, &
      31              :         xc_pot_energy_sum_eigenvalues, xc_pot_energy_xc_functional, xc_vdw_fun_none, &
      32              :         xc_vdw_fun_nonloc, xc_vdw_fun_pairpot
      33              :    USE input_cp2k_hfx,                  ONLY: create_hfx_section
      34              :    USE input_cp2k_mp2,                  ONLY: create_mp2_section
      35              :    USE input_keyword_types,             ONLY: keyword_create,&
      36              :                                               keyword_release,&
      37              :                                               keyword_type
      38              :    USE input_section_types,             ONLY: section_add_keyword,&
      39              :                                               section_add_subsection,&
      40              :                                               section_create,&
      41              :                                               section_release,&
      42              :                                               section_type
      43              :    USE input_val_types,                 ONLY: char_t,&
      44              :                                               integer_t,&
      45              :                                               real_t
      46              :    USE kinds,                           ONLY: dp
      47              :    USE string_utilities,                ONLY: s2a
      48              :    USE xc_input_constants,              ONLY: &
      49              :         c_pw92, c_pw92dmc, c_pw92vmc, c_pz, c_pzdmc, c_pzvmc, do_vwn3, do_vwn5, ke_lc, ke_llp, &
      50              :         ke_ol1, ke_ol2, ke_pbe, ke_pw86, ke_pw91, ke_t92, pz_orig, skala_gapw_atom_composite_grid, &
      51              :         skala_gapw_common_grid, skala_gapw_cp2k_default, skala_gapw_direct_valence, &
      52              :         skala_gapw_paw_one_center, skala_gapw_paw_one_center_split, xalpha, xc_b97_3c, &
      53              :         xc_b97_grimme, xc_b97_mardirossian, xc_b97_orig, xc_deriv_collocate, xc_deriv_nn10_smooth, &
      54              :         xc_deriv_nn50_smooth, xc_deriv_pw, xc_deriv_spline2, xc_deriv_spline2_smooth, &
      55              :         xc_deriv_spline3, xc_deriv_spline3_smooth, xc_pbe_orig, xc_pbe_rev, xc_pbe_sol, &
      56              :         xc_rho_nn10, xc_rho_nn50, xc_rho_no_smooth, xc_rho_spline2_smooth, xc_rho_spline3_smooth, &
      57              :         xgga_b88x, xgga_ev93, xgga_opt, xgga_pbex, xgga_pw86, xgga_pw91, xgga_revpbe
      58              :    USE xc_libxc,                        ONLY: libxc_add_sections
      59              : #include "./base/base_uses.f90"
      60              : 
      61              :    IMPLICIT NONE
      62              :    PRIVATE
      63              : 
      64              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      65              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_xc'
      66              : 
      67              :    PUBLIC :: create_xc_section, create_xc_fun_section
      68              : 
      69              : CONTAINS
      70              : 
      71              : ! **************************************************************************************************
      72              : !> \brief creates the structure of the section needed to select the xc functional
      73              : !> \param section the section that will be created
      74              : !> \author fawzi
      75              : ! **************************************************************************************************
      76        14663 :    SUBROUTINE create_xc_fun_section(section)
      77              :       TYPE(section_type), POINTER                        :: section
      78              : 
      79              :       TYPE(keyword_type), POINTER                        :: keyword
      80              :       TYPE(section_type), POINTER                        :: subsection
      81              : 
      82        14663 :       CPASSERT(.NOT. ASSOCIATED(section))
      83              :       CALL section_create(section, __LOCATION__, name="xc_functional", &
      84              :                           description="The eXchange-Correlation functional to use. In case of hybrid functionals, all scaling "// &
      85              :                           "parameters and potential types have to be specified in the HF section except from a few "// &
      86              :                           "predefined combinations (see _SECTION_PARAMETERS_ below). CP2K does NOT set it up "// &
      87              :                           "automatically not even for LibXC functionals.", &
      88              :                           n_keywords=0, n_subsections=4, repeats=.FALSE., &
      89              :                           citations=[Ortiz1994, Becke1988, Perdew1996, Zhang1998, Lee1988, &
      90              :                                      Heyd2004, Vosko1980, Goedecker1996, Perdew1981, &
      91       175956 :                                      Tao2003, Wellendorff2012])
      92              : 
      93        14663 :       NULLIFY (subsection, keyword)
      94              :       CALL keyword_create( &
      95              :          keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
      96              :          description="Shortcut for the most common functional combinations. These make use of the implementations provided by "// &
      97              :          "native CP2K (without LibXC). In case of hybrid functionals (B3LYP, PBE0), set the "// &
      98              :          "accuracy-related and system-dependent parameters in the HF section (especially MAX_MEMORY, EPS_SCHWARZ, "// &
      99              :          "CUTOFF_RADIUS, POTENTIAL_TYPE) as these are not set automatically.", &
     100              :          usage="&xc_functional BLYP", &
     101              :          enum_c_vals=s2a("B3LYP", "PBE0", "BLYP", "BP", "PADE", "LDA", "PBE", &
     102              :                          "TPSS", "HCTH120", "OLYP", "BEEFVDW", "NO_SHORTCUT", "NONE"), &
     103              :          enum_i_vals=[xc_funct_b3lyp, xc_funct_pbe0, xc_funct_blyp, xc_funct_bp, xc_funct_pade, xc_funct_pade, xc_funct_pbe, &
     104              :                       xc_funct_tpss, xc_funct_hcth120, xc_funct_olyp, xc_funct_beefvdw, xc_funct_no_shortcut, xc_none], &
     105              :          enum_desc=s2a("B3LYP", &
     106              :                        "PBE0 (see note in section XC/XC_FUNCTIONAL/PBE)", &
     107              :                        "BLYP", "BP", "PADE", "Alias for PADE", &
     108              :                        "PBE (see note in section XC/XC_FUNCTIONAL/PBE)", &
     109              :                        "TPSS (not available with LSD, use LIBXC version instead)", "HCTH120", "OLYP", &
     110              :                        "BEEFVDW", "NO_SHORTCUT", "NONE"), &
     111              :          default_i_val=xc_funct_no_shortcut, &
     112        14663 :          lone_keyword_i_val=xc_funct_no_shortcut)
     113        14663 :       CALL section_add_keyword(section, keyword)
     114        14663 :       CALL keyword_release(keyword)
     115              : 
     116              :       CALL section_create(subsection, __LOCATION__, name="BECKE88", &
     117              :                           description="Uses the Becke 88 exchange functional", &
     118              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     119        29326 :                           citations=[Becke1988])
     120              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     121              :                           description="activates the functional", &
     122        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     123        14663 :       CALL section_add_keyword(subsection, keyword)
     124        14663 :       CALL keyword_release(keyword)
     125              :       CALL keyword_create( &
     126              :          keyword, __LOCATION__, name="scale_x", &
     127              :          description="scales the exchange part of the functional", &
     128        14663 :          default_r_val=1._dp)
     129        14663 :       CALL section_add_keyword(subsection, keyword)
     130        14663 :       CALL keyword_release(keyword)
     131              : 
     132        14663 :       CALL section_add_subsection(section, subsection)
     133        14663 :       CALL section_release(subsection)
     134              : 
     135              :       CALL section_create(subsection, __LOCATION__, name="LYP_ADIABATIC", &
     136              :                           description="Uses the LYP correlation functional in an adiabatic fashion", &
     137              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     138        29326 :                           citations=[Lee1988])
     139              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     140              :                           description="activates the functional", &
     141        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     142        14663 :       CALL section_add_keyword(subsection, keyword)
     143        14663 :       CALL keyword_release(keyword)
     144              :       CALL keyword_create(keyword, __LOCATION__, name="LAMBDA", &
     145              :                           description="Defines the parameter of the adiabatic curve.", &
     146        14663 :                           default_r_val=1._dp)
     147        14663 :       CALL section_add_keyword(subsection, keyword)
     148        14663 :       CALL keyword_release(keyword)
     149              : 
     150        14663 :       CALL section_add_subsection(section, subsection)
     151        14663 :       CALL section_release(subsection)
     152              : 
     153              :       CALL section_create(subsection, __LOCATION__, name="BECKE88_LR_ADIABATIC", &
     154              :                           description="Uses the Becke 88 longrange exchange functional in an adiabatic fashion", &
     155              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     156        29326 :                           citations=[Becke1988])
     157              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     158              :                           description="activates the functional", &
     159        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     160        14663 :       CALL section_add_keyword(subsection, keyword)
     161        14663 :       CALL keyword_release(keyword)
     162              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     163              :                           description="scales the exchange part of the functional", &
     164        14663 :                           default_r_val=1._dp)
     165        14663 :       CALL section_add_keyword(subsection, keyword)
     166        14663 :       CALL keyword_release(keyword)
     167              :       CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
     168              :                           description="Potential parameter in erf(omega*r)/r", &
     169        14663 :                           default_r_val=1._dp)
     170        14663 :       CALL section_add_keyword(subsection, keyword)
     171        14663 :       CALL keyword_release(keyword)
     172              :       CALL keyword_create(keyword, __LOCATION__, name="LAMBDA", &
     173              :                           description="Defines the parameter of the adiabatic curve", &
     174        14663 :                           default_r_val=1._dp)
     175        14663 :       CALL section_add_keyword(subsection, keyword)
     176        14663 :       CALL keyword_release(keyword)
     177              : 
     178        14663 :       CALL section_add_subsection(section, subsection)
     179        14663 :       CALL section_release(subsection)
     180              : 
     181              :       CALL section_create(subsection, __LOCATION__, name="BECKE88_LR", &
     182              :                           description="Uses the Becke 88 longrange exchange functional", &
     183              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     184        29326 :                           citations=[Becke1988])
     185              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     186              :                           description="activates the functional", &
     187        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     188        14663 :       CALL section_add_keyword(subsection, keyword)
     189        14663 :       CALL keyword_release(keyword)
     190              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     191              :                           description="scales the exchange part of the functional", &
     192        14663 :                           default_r_val=1._dp)
     193        14663 :       CALL section_add_keyword(subsection, keyword)
     194        14663 :       CALL keyword_release(keyword)
     195              :       CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
     196              :                           description="Potential parameter in erf(omega*r)/r", &
     197        14663 :                           default_r_val=1._dp)
     198        14663 :       CALL section_add_keyword(subsection, keyword)
     199        14663 :       CALL keyword_release(keyword)
     200              : 
     201        14663 :       CALL section_add_subsection(section, subsection)
     202        14663 :       CALL section_release(subsection)
     203              : 
     204              :       CALL section_create(subsection, __LOCATION__, name="LYP", &
     205              :                           description="Uses the LYP functional", &
     206              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     207        29326 :                           citations=[Lee1988])
     208              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     209              :                           description="activates the functional", &
     210        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     211        14663 :       CALL section_add_keyword(subsection, keyword)
     212        14663 :       CALL keyword_release(keyword)
     213              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     214              :                           description="scales the correlation part of the functional", &
     215        14663 :                           default_r_val=1._dp)
     216        14663 :       CALL section_add_keyword(subsection, keyword)
     217        14663 :       CALL keyword_release(keyword)
     218        14663 :       CALL section_add_subsection(section, subsection)
     219        14663 :       CALL section_release(subsection)
     220              : 
     221              :       CALL section_create(subsection, __LOCATION__, name="PADE", &
     222              :                           description="Uses the PADE functional", &
     223              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     224        29326 :                           citations=[Goedecker1996])
     225              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     226              :                           description="activates the functional", &
     227        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     228        14663 :       CALL section_add_keyword(subsection, keyword)
     229        14663 :       CALL keyword_release(keyword)
     230        14663 :       CALL section_add_subsection(section, subsection)
     231        14663 :       CALL section_release(subsection)
     232              : 
     233              :       CALL section_create(subsection, __LOCATION__, name="HCTH", &
     234              :                           description="Uses the HCTH class of functionals", &
     235        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     236              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_SET", &
     237              :                           description="Which version of the parameters should be used", &
     238              :                           usage="PARAMETER_SET 407", &
     239              :                           enum_c_vals=["93 ", "120", "147", "407", "HLE"], &
     240              :                           enum_i_vals=[93, 120, 147, 407, 408], &
     241        87978 :                           default_i_val=120)
     242        14663 :       CALL section_add_keyword(subsection, keyword)
     243        14663 :       CALL keyword_release(keyword)
     244              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     245              :                           description="activates the functional", &
     246        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     247        14663 :       CALL section_add_keyword(subsection, keyword)
     248        14663 :       CALL keyword_release(keyword)
     249        14663 :       CALL section_add_subsection(section, subsection)
     250        14663 :       CALL section_release(subsection)
     251              : 
     252              :       CALL section_create(subsection, __LOCATION__, name="OPTX", &
     253              :                           description="Uses the OPTX functional", &
     254        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     255              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     256              :                           description="activates the functional", &
     257        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     258        14663 :       CALL section_add_keyword(subsection, keyword)
     259        14663 :       CALL keyword_release(keyword)
     260              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     261              :                           description="scales the exchange part of the functional", &
     262        14663 :                           default_r_val=1._dp)
     263        14663 :       CALL section_add_keyword(subsection, keyword)
     264        14663 :       CALL keyword_release(keyword)
     265              :       CALL keyword_create(keyword, __LOCATION__, name="a1", &
     266              :                           description="OPTX a1 coefficient", &
     267        14663 :                           default_r_val=1.05151_dp)
     268        14663 :       CALL section_add_keyword(subsection, keyword)
     269        14663 :       CALL keyword_release(keyword)
     270              :       CALL keyword_create(keyword, __LOCATION__, name="a2", &
     271              :                           description="OPTX a2 coefficient", &
     272        14663 :                           default_r_val=1.43169_dp)
     273        14663 :       CALL section_add_keyword(subsection, keyword)
     274        14663 :       CALL keyword_release(keyword)
     275              :       CALL keyword_create(keyword, __LOCATION__, name="gamma", &
     276              :                           description="OPTX gamma coefficient", &
     277        14663 :                           default_r_val=0.006_dp)
     278        14663 :       CALL section_add_keyword(subsection, keyword)
     279        14663 :       CALL keyword_release(keyword)
     280        14663 :       CALL section_add_subsection(section, subsection)
     281        14663 :       CALL section_release(subsection)
     282              : 
     283        14663 :       CALL libxc_add_sections(section)
     284              : 
     285              :       CALL section_create(subsection, __LOCATION__, name="CS1", &
     286              :                           description="Uses the CS1 functional", &
     287        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     288              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     289              :                           description="activates the functional", &
     290        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     291        14663 :       CALL section_add_keyword(subsection, keyword)
     292        14663 :       CALL keyword_release(keyword)
     293        14663 :       CALL section_add_subsection(section, subsection)
     294        14663 :       CALL section_release(subsection)
     295              : 
     296              :       CALL section_create(subsection, __LOCATION__, name="XGGA", &
     297              :                           description="Uses one of the XGGA functionals (optimized versions of "// &
     298              :                           "some of these functionals might be available outside this section).", &
     299        14663 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     300              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     301              :                           description="activates the functional", &
     302        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     303        14663 :       CALL section_add_keyword(subsection, keyword)
     304        14663 :       CALL keyword_release(keyword)
     305              :       CALL keyword_create(keyword, __LOCATION__, name="FUNCTIONAL", &
     306              :                           description="Which one of the XGGA functionals should be used", &
     307              :                           usage="FUNCTIONAL PW86X", &
     308              :                           enum_c_vals=[ &
     309              :                           "BECKE88X", &
     310              :                           "PW86X   ", &
     311              :                           "PW91X   ", &
     312              :                           "PBEX    ", &
     313              :                           "REV_PBEX", &
     314              :                           "OPTX    ", &
     315              :                           "EV93    "], &
     316              :                           enum_i_vals=[xgga_b88x, xgga_pw86, xgga_pw91, xgga_pbex, xgga_revpbe, xgga_opt, xgga_ev93], &
     317       117304 :                           default_i_val=xgga_b88x)
     318        14663 :       CALL section_add_keyword(subsection, keyword)
     319        14663 :       CALL keyword_release(keyword)
     320        14663 :       CALL section_add_subsection(section, subsection)
     321        14663 :       CALL section_release(subsection)
     322              : 
     323              :       CALL section_create(subsection, __LOCATION__, name="KE_GGA", &
     324              :                           description="Uses one of the KE_GGA functionals (optimized versions of "// &
     325              :                           "some of these functionals might be available outside this section). "// &
     326              :                           "These functionals are needed for the computation of the kinetic "// &
     327              :                           "energy in the Kim-Gordon method.", &
     328        14663 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     329              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     330              :                           description="activates the functional", &
     331        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     332        14663 :       CALL section_add_keyword(subsection, keyword)
     333        14663 :       CALL keyword_release(keyword)
     334              :       CALL keyword_create(keyword, __LOCATION__, name="FUNCTIONAL", &
     335              :                           description="Which one of the KE_GGA functionals should be used", &
     336              :                           usage="FUNCTIONAL (OL1|OL2|LLP|PW86|PW91|LC|T92|PBE)", &
     337              :                           enum_c_vals=["OL1 ", "OL2 ", "LLP ", "PW86", "PW91", "LC  ", "T92 ", "PBE "], &
     338              :                           enum_i_vals=[ke_ol1, ke_ol2, ke_llp, ke_pw86, ke_pw91, ke_lc, ke_t92, ke_pbe], &
     339              :                           enum_desc=s2a("Uses first Ou-Yang and Levy functional, currently not producing correct results", &
     340              :                                         "Uses second Ou-Yang and Levy functional, currently not producing correct results", &
     341              :                                         "Uses Lee, Lee, and Parr functional", &
     342              :                                         "Uses Perdew and Wang's 1986 functional", &
     343              :                                         "Uses Perdew and Wang's 1991 functional", &
     344              :                                         "Uses Lembarki and Chermette functional", &
     345              :                                         "Uses Thakkar functional", &
     346              :                                         "Uses the 1996 functional of Perdew, Burke and Ernzerhof"), &
     347       131967 :                           default_i_val=ke_llp)
     348        14663 :       CALL section_add_keyword(subsection, keyword)
     349        14663 :       CALL keyword_release(keyword)
     350        14663 :       CALL section_add_subsection(section, subsection)
     351        14663 :       CALL section_release(subsection)
     352              : 
     353              :       CALL section_create(subsection, __LOCATION__, name="P86C", &
     354              :                           description="Uses the P86C functional", &
     355        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     356              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     357              :                           description="activates the functional", &
     358        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     359        14663 :       CALL section_add_keyword(subsection, keyword)
     360        14663 :       CALL keyword_release(keyword)
     361              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     362              :                           description="scales the correlation part of the functional", &
     363        14663 :                           default_r_val=1._dp)
     364        14663 :       CALL section_add_keyword(subsection, keyword)
     365        14663 :       CALL keyword_release(keyword)
     366        14663 :       CALL section_add_subsection(section, subsection)
     367        14663 :       CALL section_release(subsection)
     368              : 
     369              :       CALL section_create(subsection, __LOCATION__, name="PW92", &
     370              :                           description="Uses the PerdewWang correlation functional.", &
     371        14663 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     372              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     373              :                           description="activates the functional", &
     374        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     375        14663 :       CALL section_add_keyword(subsection, keyword)
     376        14663 :       CALL keyword_release(keyword)
     377              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE", &
     378              :                           description="Scaling of the energy functional", &
     379        14663 :                           default_r_val=1.0_dp)
     380        14663 :       CALL section_add_keyword(subsection, keyword)
     381        14663 :       CALL keyword_release(keyword)
     382              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETRIZATION", &
     383              :                           description="Which one of parametrizations should be used", &
     384              :                           usage="PARAMETRIZATION DMC", &
     385              :                           enum_c_vals=[ &
     386              :                           "ORIGINAL", &
     387              :                           "DMC     ", &
     388              :                           "VMC     "], &
     389              :                           enum_i_vals=[c_pw92, c_pw92dmc, c_pw92vmc], &
     390        58652 :                           default_i_val=c_pw92)
     391        14663 :       CALL section_add_keyword(subsection, keyword)
     392        14663 :       CALL keyword_release(keyword)
     393        14663 :       CALL section_add_subsection(section, subsection)
     394        14663 :       CALL section_release(subsection)
     395              : 
     396              :       CALL section_create(subsection, __LOCATION__, name="PZ81", &
     397              :                           description="Uses the PZ functional.", &
     398              :                           n_keywords=1, n_subsections=0, repeats=.FALSE., &
     399        43989 :                           citations=[Perdew1981, Ortiz1994])
     400              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     401              :                           description="activates the functional", &
     402        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     403        14663 :       CALL section_add_keyword(subsection, keyword)
     404        14663 :       CALL keyword_release(keyword)
     405              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETRIZATION", &
     406              :                           description="Which one of parametrizations should be used", &
     407              :                           usage="PARAMETRIZATION DMC", &
     408              :                           enum_c_vals=[ &
     409              :                           "ORIGINAL", &
     410              :                           "DMC     ", &
     411              :                           "VMC     "], &
     412              :                           enum_i_vals=[c_pz, c_pzdmc, c_pzvmc], &
     413        58652 :                           default_i_val=pz_orig)
     414        14663 :       CALL section_add_keyword(subsection, keyword)
     415        14663 :       CALL keyword_release(keyword)
     416              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     417              :                           description="scales the correlation part of the functional", &
     418        14663 :                           default_r_val=1._dp)
     419        14663 :       CALL section_add_keyword(subsection, keyword)
     420        14663 :       CALL keyword_release(keyword)
     421        14663 :       CALL section_add_subsection(section, subsection)
     422        14663 :       CALL section_release(subsection)
     423              : 
     424              :       CALL section_create(subsection, __LOCATION__, name="TFW", &
     425              :                           description="Uses the TFW functional", &
     426        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     427              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     428              :                           description="activates the functional", &
     429        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     430        14663 :       CALL section_add_keyword(subsection, keyword)
     431        14663 :       CALL keyword_release(keyword)
     432        14663 :       CALL section_add_subsection(section, subsection)
     433        14663 :       CALL section_release(subsection)
     434              : 
     435              :       CALL section_create(subsection, __LOCATION__, name="TF", &
     436              :                           description="Uses the TF functional", &
     437        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     438              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     439              :                           description="activates the functional", &
     440        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     441        14663 :       CALL section_add_keyword(subsection, keyword)
     442        14663 :       CALL keyword_release(keyword)
     443        14663 :       CALL section_add_subsection(section, subsection)
     444        14663 :       CALL section_release(subsection)
     445              : 
     446              :       CALL section_create(subsection, __LOCATION__, name="VWN", &
     447              :                           description="Uses the VWN functional", &
     448              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     449        29326 :                           citations=[Vosko1980])
     450              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     451              :                           description="activates the functional", &
     452        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     453        14663 :       CALL section_add_keyword(subsection, keyword)
     454        14663 :       CALL keyword_release(keyword)
     455              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     456              :                           description="scales the correlation part of the functional", &
     457        14663 :                           default_r_val=1._dp)
     458        14663 :       CALL section_add_keyword(subsection, keyword)
     459        14663 :       CALL keyword_release(keyword)
     460              : 
     461              :       CALL keyword_create(keyword, __LOCATION__, name="FUNCTIONAL_TYPE", &
     462              :                           description="Which version of the VWN functional should be used", &
     463              :                           usage="FUNCTIONAL_TYPE VWN5", &
     464              :                           enum_c_vals=s2a("VWN5", "VWN3"), &
     465              :                           enum_i_vals=[do_vwn5, do_vwn3], &
     466              :                           enum_desc=s2a("This is the recommended (correct) version of the VWN functional", &
     467              :                                         "This version is the default in Gaussian, but not recommended. "// &
     468              :                                         "Notice that it is also employed in Gaussian's default version of B3LYP"), &
     469        14663 :                           default_i_val=do_vwn5)
     470              : 
     471        14663 :       CALL section_add_keyword(subsection, keyword)
     472        14663 :       CALL keyword_release(keyword)
     473        14663 :       CALL section_add_subsection(section, subsection)
     474        14663 :       CALL section_release(subsection)
     475              : 
     476              :       CALL section_create(subsection, __LOCATION__, name="XALPHA", &
     477              :                           description="Uses the XALPHA (SLATER) functional.", &
     478        14663 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     479              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     480              :                           description="activates the functional", &
     481        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     482        14663 :       CALL section_add_keyword(subsection, keyword)
     483        14663 :       CALL keyword_release(keyword)
     484              :       CALL keyword_create(keyword, __LOCATION__, name="XA", &
     485              :                           description="Value of the xa parameter (this does not change the exponent, "// &
     486              :                           "just the mixing)", &
     487        14663 :                           usage="XA 0.7", default_r_val=2._dp/3._dp)
     488        14663 :       CALL section_add_keyword(subsection, keyword)
     489        14663 :       CALL keyword_release(keyword)
     490              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     491              :                           description="scales the exchange part of the functional", &
     492        14663 :                           default_r_val=1._dp)
     493        14663 :       CALL section_add_keyword(subsection, keyword)
     494        14663 :       CALL keyword_release(keyword)
     495        14663 :       CALL section_add_subsection(section, subsection)
     496        14663 :       CALL section_release(subsection)
     497              : 
     498              :       CALL section_create(subsection, __LOCATION__, name="TPSS", &
     499              :                           description="Uses the TPSS functional. Note, that there is no LSD version available. "// &
     500              :                           "In such cases, use the LIBXC version instead.", &
     501              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     502        29326 :                           citations=[Tao2003])
     503              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     504              :                           description="Activates the functional", &
     505        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     506        14663 :       CALL section_add_keyword(subsection, keyword)
     507        14663 :       CALL keyword_release(keyword)
     508              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     509              :                           description="scales the exchange part of the functional", &
     510        14663 :                           default_r_val=1._dp)
     511        14663 :       CALL section_add_keyword(subsection, keyword)
     512        14663 :       CALL keyword_release(keyword)
     513              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     514              :                           description="scales the correlation part of the functional", &
     515        14663 :                           default_r_val=1._dp)
     516        14663 :       CALL section_add_keyword(subsection, keyword)
     517        14663 :       CALL keyword_release(keyword)
     518        14663 :       CALL section_add_subsection(section, subsection)
     519        14663 :       CALL section_release(subsection)
     520              : 
     521              :       CALL section_create(subsection, __LOCATION__, name="PBE", &
     522              :                           description="Uses the PBE functional", &
     523              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     524        58652 :                           citations=[Perdew1996, Zhang1998, Perdew2008])
     525              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     526              :                           description="activates the functional", &
     527        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     528        14663 :       CALL section_add_keyword(subsection, keyword)
     529        14663 :       CALL keyword_release(keyword)
     530              :       CALL keyword_create(keyword, __LOCATION__, name="parametrization", &
     531              :                           description="switches between the different "// &
     532              :                           "parametrizations of the functional. "// &
     533              :                           "Note: Beta parameters used have only 5 significant digits, "// &
     534              :                           "as published. For higher precision and program comparison "// &
     535              :                           "use the LIBXC library.", &
     536              :                           enum_i_vals=[xc_pbe_orig, xc_pbe_rev, xc_pbe_sol], &
     537              :                           enum_c_vals=["ORIG  ", "revPBE", "PBEsol"], &
     538              :                           enum_desc=["original PBE                        ", &
     539              :                                      "revised PBE (revPBE)                ", &
     540              :                                      "PBE for solids and surfaces (PBEsol)"], &
     541       102641 :                           default_i_val=xc_pbe_orig)
     542        14663 :       CALL section_add_keyword(subsection, keyword)
     543        14663 :       CALL keyword_release(keyword)
     544              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     545              :                           description="scales the exchange part of the functional", &
     546        14663 :                           default_r_val=1._dp)
     547        14663 :       CALL section_add_keyword(subsection, keyword)
     548        14663 :       CALL keyword_release(keyword)
     549              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     550              :                           description="scales the correlation part of the functional", &
     551        14663 :                           default_r_val=1._dp)
     552        14663 :       CALL section_add_keyword(subsection, keyword)
     553        14663 :       CALL keyword_release(keyword)
     554        14663 :       CALL section_add_subsection(section, subsection)
     555        14663 :       CALL section_release(subsection)
     556              : 
     557        14663 :       CALL create_gauxc_section(subsection)
     558        14663 :       CALL section_add_subsection(section, subsection)
     559        14663 :       CALL section_release(subsection)
     560              : 
     561              :       CALL section_create(subsection, __LOCATION__, name="XWPBE", &
     562              :                           description="Uses the short range PBE functional", &
     563              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     564        29326 :                           citations=[Heyd2004])
     565              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     566              :                           description="activates the functional", &
     567        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     568        14663 :       CALL section_add_keyword(subsection, keyword)
     569        14663 :       CALL keyword_release(keyword)
     570              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     571              :                           description="scales the exchange part of the functional", &
     572        14663 :                           default_r_val=1._dp)
     573        14663 :       CALL section_add_keyword(subsection, keyword)
     574        14663 :       CALL keyword_release(keyword)
     575              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x0", &
     576              :                           description="scales the exchange part of the original hole PBE-functional", &
     577        14663 :                           default_r_val=0.0_dp)
     578        14663 :       CALL section_add_keyword(subsection, keyword)
     579        14663 :       CALL keyword_release(keyword)
     580              :       CALL keyword_create(keyword, __LOCATION__, name="omega", &
     581              :                           description="screening parameter", &
     582        14663 :                           default_r_val=1._dp)
     583        14663 :       CALL section_add_keyword(subsection, keyword)
     584        14663 :       CALL keyword_release(keyword)
     585        14663 :       CALL section_add_subsection(section, subsection)
     586        14663 :       CALL section_release(subsection)
     587              : 
     588              :       CALL section_create(subsection, __LOCATION__, name="BECKE97", &
     589              :                           description="Uses the Becke 97 exchange correlation functional", &
     590              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     591        43989 :                           citations=[Becke1997, Grimme2006])
     592              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     593              :                           description="activates the functional", &
     594        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     595        14663 :       CALL section_add_keyword(subsection, keyword)
     596        14663 :       CALL keyword_release(keyword)
     597              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     598              :                 description="scales the exchange part of the functional, if -1 the default for the given parametrization is used", &
     599        14663 :                           default_r_val=-1._dp)
     600        14663 :       CALL section_add_keyword(subsection, keyword)
     601        14663 :       CALL keyword_release(keyword)
     602              :       CALL keyword_create(keyword, __LOCATION__, name="scale_c", &
     603              :                           description="scales the correlation part of the functional", &
     604        14663 :                           default_r_val=1._dp)
     605        14663 :       CALL section_add_keyword(subsection, keyword)
     606        14663 :       CALL keyword_release(keyword)
     607              :       CALL keyword_create(keyword, __LOCATION__, name="parametrization", &
     608              :                           description="switches between the B97 and Grimme parametrization ", &
     609              :                           enum_i_vals=[xc_b97_orig, xc_b97_grimme, xc_b97_grimme, xc_b97_mardirossian, xc_b97_3c], &
     610              :                           enum_c_vals=["ORIG      ", "B97GRIMME ", "B97_GRIMME", "wB97X-V   ", "B97-3c    "], &
     611        87978 :                           default_i_val=xc_b97_orig)
     612        14663 :       CALL section_add_keyword(subsection, keyword)
     613        14663 :       CALL keyword_release(keyword)
     614              : 
     615        14663 :       CALL section_add_subsection(section, subsection)
     616        14663 :       CALL section_release(subsection)
     617              : 
     618              :       CALL section_create(subsection, __LOCATION__, name="BECKE_ROUSSEL", &
     619              :                           description="Becke Roussel exchange hole model. Can be used "// &
     620              :                           "as long range correction with a truncated coulomb potential", &
     621              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     622        43989 :                           citations=[BeckeRoussel1989, Proynov2007])
     623              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     624              :                           description="activates the functional", &
     625        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     626        14663 :       CALL section_add_keyword(subsection, keyword)
     627        14663 :       CALL keyword_release(keyword)
     628              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     629              :                           description="scales the exchange part of the functional", &
     630        14663 :                           default_r_val=1._dp)
     631        14663 :       CALL section_add_keyword(subsection, keyword)
     632        14663 :       CALL keyword_release(keyword)
     633              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     634              :                           description="Defines the cutoff radius for the truncation. "// &
     635              :                           "If put to zero, the standard full range potential will be used", &
     636        14663 :                           usage="CUTOFF_RADIUS 2.0", default_r_val=0.0_dp)
     637        14663 :       CALL section_add_keyword(subsection, keyword)
     638        14663 :       CALL keyword_release(keyword)
     639              :       CALL keyword_create(keyword, __LOCATION__, name="GAMMA", &
     640              :                           description="Parameter in the exchange hole. "// &
     641              :                           "Usually this is put to 1.0 or 0.8", &
     642        14663 :                           usage="GAMMA 0.8", default_r_val=1.0_dp)
     643        14663 :       CALL section_add_keyword(subsection, keyword)
     644        14663 :       CALL keyword_release(keyword)
     645        14663 :       CALL section_add_subsection(section, subsection)
     646        14663 :       CALL section_release(subsection)
     647              : 
     648              :       CALL section_create(subsection, __LOCATION__, name="LDA_HOLE_T_C_LR", &
     649              :                           description="LDA exchange hole model in truncated coulomb potential", &
     650        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     651              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     652              :                           description="activates the functional", &
     653        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     654        14663 :       CALL section_add_keyword(subsection, keyword)
     655        14663 :       CALL keyword_release(keyword)
     656              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_X", &
     657              :                           description="scales the exchange part of the functional", &
     658        14663 :                           default_r_val=1._dp)
     659        14663 :       CALL section_add_keyword(subsection, keyword)
     660        14663 :       CALL keyword_release(keyword)
     661              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     662              :                           description="Defines cutoff for lower integration boundary", &
     663        14663 :                           default_r_val=0.0_dp, unit_str="angstrom")
     664        14663 :       CALL section_add_keyword(subsection, keyword)
     665        14663 :       CALL keyword_release(keyword)
     666        14663 :       CALL section_add_subsection(section, subsection)
     667        14663 :       CALL section_release(subsection)
     668              : 
     669              :       CALL section_create(subsection, __LOCATION__, name="PBE_HOLE_T_C_LR", &
     670              :                           description="PBE exchange hole model in trucanted coulomb potential", &
     671        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     672              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     673              :                           description="activates the functional", &
     674        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     675        14663 :       CALL section_add_keyword(subsection, keyword)
     676        14663 :       CALL keyword_release(keyword)
     677              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_X", &
     678              :                           description="scales the exchange part of the functional", &
     679        14663 :                           default_r_val=1._dp)
     680        14663 :       CALL section_add_keyword(subsection, keyword)
     681        14663 :       CALL keyword_release(keyword)
     682              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     683              :                           description="Defines cutoff for lower integration boundary", &
     684        14663 :                           default_r_val=1.0_dp, unit_str="angstrom")
     685        14663 :       CALL section_add_keyword(subsection, keyword)
     686        14663 :       CALL keyword_release(keyword)
     687        14663 :       CALL section_add_subsection(section, subsection)
     688        14663 :       CALL section_release(subsection)
     689              : 
     690              :       CALL section_create(subsection, __LOCATION__, name="GV09", &
     691              :                           description="Combination of three different exchange hole models", &
     692        14663 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     693              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     694              :                           description="activates the functional", &
     695        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     696        14663 :       CALL section_add_keyword(subsection, keyword)
     697        14663 :       CALL keyword_release(keyword)
     698              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_X", &
     699              :                           description="scales the exchange part of the functional", &
     700        14663 :                           default_r_val=1._dp)
     701        14663 :       CALL section_add_keyword(subsection, keyword)
     702        14663 :       CALL keyword_release(keyword)
     703              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     704              :                           description="Defines cutoff for lower integration boundary", &
     705        14663 :                           default_r_val=0.0_dp, unit_str="angstrom")
     706        14663 :       CALL section_add_keyword(subsection, keyword)
     707        14663 :       CALL keyword_release(keyword)
     708              :       CALL keyword_create(keyword, __LOCATION__, name="GAMMA", &
     709              :                           description="Parameter for Becke Roussel hole", &
     710        14663 :                           default_r_val=1.0_dp)
     711        14663 :       CALL section_add_keyword(subsection, keyword)
     712        14663 :       CALL keyword_release(keyword)
     713        14663 :       CALL section_add_subsection(section, subsection)
     714        14663 :       CALL section_release(subsection)
     715              : 
     716              :       CALL section_create(subsection, __LOCATION__, name="BEEF", & !rk: BEEF Exchange
     717              :                           description="Uses the BEEFvdW exchange functional", &
     718              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     719        29326 :                           citations=[Wellendorff2012])
     720              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     721              :                           description="activates the functional", &
     722        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
     723        14663 :       CALL section_add_keyword(subsection, keyword)
     724        14663 :       CALL keyword_release(keyword)
     725              :       CALL keyword_create(keyword, __LOCATION__, name="scale_x", &
     726              :                           description="scales the exchange part of the functional", &
     727        14663 :                           default_r_val=1._dp)
     728        14663 :       CALL section_add_keyword(subsection, keyword)
     729        14663 :       CALL keyword_release(keyword)
     730        14663 :       CALL section_add_subsection(section, subsection)
     731        14663 :       CALL section_release(subsection)
     732              : 
     733        14663 :    END SUBROUTINE create_xc_fun_section
     734              : 
     735              : ! **************************************************************************************************
     736              : !> \brief creates the structure of the section needed to select an xc potential
     737              : !> \param section the section that will be created
     738              : !> \author thomas chassaing
     739              : ! **************************************************************************************************
     740        11732 :    SUBROUTINE create_xc_potential_section(section)
     741              :       TYPE(section_type), POINTER                        :: section
     742              : 
     743              :       TYPE(keyword_type), POINTER                        :: keyword
     744              :       TYPE(section_type), POINTER                        :: subsection
     745              : 
     746        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
     747              :       CALL section_create(section, __LOCATION__, name="xc_potential", &
     748              :                           description="The xc potential to use (CAREFUL: xc potential here refers "// &
     749              :                           "to potentials that are not derived from an xc functional, but rather are "// &
     750              :                           "modelled directly. Therefore there is no consistent xc energy available. "// &
     751              :                           "To still get an energy expression, see ENERGY below", &
     752        11732 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
     753              : 
     754        11732 :       NULLIFY (subsection, keyword)
     755              :       CALL section_create(subsection, __LOCATION__, name="SAOP", &
     756              :                           description="Uses the SAOP potential", &
     757        11732 :                           n_keywords=3, n_subsections=0, repeats=.TRUE.)
     758              :       CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
     759              :                           description="Value of the alpha parameter (default = 1.19).", &
     760        11732 :                           usage="ALPHA 1.19", default_r_val=1.19_dp)
     761        11732 :       CALL section_add_keyword(subsection, keyword)
     762        11732 :       CALL keyword_release(keyword)
     763              :       CALL keyword_create(keyword, __LOCATION__, name="BETA", &
     764              :                           description="Value of the beta parameter (default = 0.01).", &
     765        11732 :                           usage="BETA 0.01", default_r_val=0.01_dp)
     766        11732 :       CALL section_add_keyword(subsection, keyword)
     767        11732 :       CALL keyword_release(keyword)
     768              :       CALL keyword_create(keyword, __LOCATION__, name="K_RHO", &
     769              :                           description="Value of the K_rho parameter (default = 0.42).", &
     770        11732 :                           usage="K_RHO 0.42", default_r_val=0.42_dp)
     771        11732 :       CALL section_add_keyword(subsection, keyword)
     772        11732 :       CALL keyword_release(keyword)
     773        11732 :       CALL section_add_subsection(section, subsection)
     774        11732 :       CALL section_release(subsection)
     775              : 
     776              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY", &
     777              :                           description="How to determine the total energy.", &
     778              :                           usage="ENERGY [NONE,XC_FUNCTIONAL,SUM_EIGENVALUES", &
     779              :                           enum_c_vals=s2a("NONE", "XC_FUNCTIONAL", "FUNCTIONAL", "SUM_EIGENVALUES", "SOE"), &
     780              :                           enum_i_vals=[xc_pot_energy_none, &
     781              :                                        xc_pot_energy_xc_functional, &
     782              :                                        xc_pot_energy_xc_functional, &
     783              :                                        xc_pot_energy_sum_eigenvalues, &
     784              :                                        xc_pot_energy_sum_eigenvalues], &
     785        11732 :                           default_i_val=xc_pot_energy_none)
     786        11732 :       CALL section_add_keyword(section, keyword)
     787        11732 :       CALL keyword_release(keyword)
     788              : 
     789        11732 :    END SUBROUTINE create_xc_potential_section
     790              : 
     791              : ! **************************************************************************************************
     792              : !> \brief creates the structure of the section needed to select an xc kernel
     793              : !> \param section the section that will be created
     794              : !> \author JGH
     795              : ! **************************************************************************************************
     796        11732 :    SUBROUTINE create_xc_kernel_section(section)
     797              :       TYPE(section_type), POINTER                        :: section
     798              : 
     799              :       TYPE(keyword_type), POINTER                        :: keyword
     800              : 
     801        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
     802              :       CALL section_create(section, __LOCATION__, name="XC_KERNEL", &
     803              :                           description="The xc kernel to use (CAREFUL: xc kernel here refers "// &
     804              :                           "to kernels that are not derived from an xc functional, but rather are "// &
     805              :                           "modelled directly. This kernel will be used in a TDDFPT calculation. "// &
     806              :                           "Cannot be combined with XC_FUNCTIONAL or XC_POTENTIAL.", &
     807        11732 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
     808              : 
     809        11732 :       NULLIFY (keyword)
     810              :       CALL keyword_create( &
     811              :          keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     812              :          description="Selection of kernel functionals.", &
     813              :          usage="&XC_KERNEL LDAfxc", &
     814              :          enum_c_vals=s2a("PADEfxc", "LDAfxc", "GGAfxc", "NONE"), &
     815              :          enum_i_vals=[fxc_funct_pade, fxc_funct_lda, fxc_funct_gga, fxc_none], &
     816              :          enum_desc=s2a("Fxc based on LDA PADE approximation", &
     817              :                        "Fxc based on LDA functionals", &
     818              :                        "Fxc model from fit to PBE functional", &
     819              :                        "NONE"), &
     820              :          default_i_val=fxc_none, &
     821        11732 :          lone_keyword_i_val=fxc_none)
     822        11732 :       CALL section_add_keyword(section, keyword)
     823        11732 :       CALL keyword_release(keyword)
     824              : 
     825              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER", &
     826              :                           description="List of parameters specific to the kernel function", &
     827              :                           usage="PARAMETER <REAL> .. <REAL>", &
     828        11732 :                           type_of_var=real_t, n_var=-1)
     829        11732 :       CALL section_add_keyword(section, keyword)
     830        11732 :       CALL keyword_release(keyword)
     831              :       CALL keyword_create(keyword, __LOCATION__, name="GAMMA", &
     832              :                           description="B97 GAMMA parameters [gx, gab, gaa]", &
     833              :                           usage="GAMMA <REAL> <REAL> <REAL>", &
     834              :                           default_r_vals=[0.004_dp, 0.006_dp, 0.2_dp], &
     835        11732 :                           type_of_var=real_t, n_var=3)
     836        11732 :       CALL section_add_keyword(section, keyword)
     837        11732 :       CALL keyword_release(keyword)
     838              :       CALL keyword_create(keyword, __LOCATION__, name="C_XAA", &
     839              :                           description="B97 C parameters for exchange", &
     840              :                           usage="C_XAA <REAL> <REAL> <REAL>", &
     841              :                           default_r_vals=[1.0_dp, 0.63_dp, 0.94_dp], &
     842        11732 :                           type_of_var=real_t, n_var=3)
     843        11732 :       CALL section_add_keyword(section, keyword)
     844        11732 :       CALL keyword_release(keyword)
     845              :       CALL keyword_create(keyword, __LOCATION__, name="C_CAB", &
     846              :                           description="B97 C parameters for same spin correlation.", &
     847              :                           usage="C_CAB <REAL> <REAL> <REAL>", &
     848              :                           default_r_vals=[1.0_dp, 0.75_dp, -4.60_dp], &
     849        11732 :                           type_of_var=real_t, n_var=3)
     850        11732 :       CALL section_add_keyword(section, keyword)
     851        11732 :       CALL keyword_release(keyword)
     852              :       CALL keyword_create(keyword, __LOCATION__, name="C_CAA", &
     853              :                           description="B97 C parameters for opposite spin correlation.", &
     854              :                           usage="C_CAA <REAL> <REAL> <REAL>", &
     855              :                           default_r_vals=[0.17_dp, 2.35_dp, -2.55_dp], &
     856        11732 :                           type_of_var=real_t, n_var=3)
     857        11732 :       CALL section_add_keyword(section, keyword)
     858        11732 :       CALL keyword_release(keyword)
     859              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_X", &
     860              :                           description="Scaling parameter for exchange kernel.", &
     861        11732 :                           usage="SCALE_X 0.2", default_r_val=1.0_dp)
     862        11732 :       CALL section_add_keyword(section, keyword)
     863        11732 :       CALL keyword_release(keyword)
     864              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_C", &
     865              :                           description="Scaling parameter for correlation kernel.", &
     866        11732 :                           usage="SCALE_C 0.2", default_r_val=1.0_dp)
     867        11732 :       CALL section_add_keyword(section, keyword)
     868        11732 :       CALL keyword_release(keyword)
     869              : 
     870        11732 :    END SUBROUTINE create_xc_kernel_section
     871              : 
     872              : ! **************************************************************************************************
     873              : !> \brief creates the structure of the section needed to select an hfx kernel
     874              : !> \param section the section that will be created
     875              : !> \author JGH
     876              : ! **************************************************************************************************
     877        11732 :    SUBROUTINE create_hfx_kernel_section(section)
     878              :       TYPE(section_type), POINTER                        :: section
     879              : 
     880              :       TYPE(keyword_type), POINTER                        :: keyword
     881              :       TYPE(section_type), POINTER                        :: subsection
     882              : 
     883        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
     884              :       CALL section_create(section, __LOCATION__, name="HFX_KERNEL", &
     885              :                           description="The hfx kernel to use. Cannot be combined with HF section.", &
     886        11732 :                           n_keywords=1, n_subsections=2, repeats=.FALSE.)
     887              : 
     888        11732 :       NULLIFY (subsection, keyword)
     889              :       CALL keyword_create(keyword, __LOCATION__, name="DO_HFXSR", &
     890              :                           description="Switch to use the HFXSR (short range) kernel.", &
     891              :                           usage="DO_HFXSR T/F", default_l_val=.FALSE., &
     892        11732 :                           lone_keyword_l_val=.TRUE.)
     893        11732 :       CALL section_add_keyword(section, keyword)
     894        11732 :       CALL keyword_release(keyword)
     895        11732 :       NULLIFY (subsection, keyword)
     896              :       CALL keyword_create(keyword, __LOCATION__, name="HFXSR_PRIMBAS", &
     897              :                           description="Default number of primitives in ADMM basis in HFXSR. "// &
     898              :                           "0 indicates the use of a contracted minimal basis. ", &
     899        11732 :                           usage="HFXSR_PRIMBAS 3", default_i_val=0)
     900        11732 :       CALL section_add_keyword(section, keyword)
     901        11732 :       CALL keyword_release(keyword)
     902              : 
     903        11732 :       CALL create_hfx_section(subsection)
     904        11732 :       CALL section_add_subsection(section, subsection)
     905        11732 :       CALL section_release(subsection)
     906              : 
     907              :       CALL section_create(subsection, __LOCATION__, name="HFXLR", &
     908              :                           description="Uses the HFXLR (long range) kernel", &
     909        11732 :                           n_keywords=2, n_subsections=0, repeats=.FALSE.)
     910              :       CALL keyword_create(keyword, __LOCATION__, name="RCUT", &
     911              :                           description="Value of lower range cutoff of interaction [Bohr]", &
     912        11732 :                           usage="RCUT 5.00", default_r_val=6.00_dp, unit_str="bohr")
     913        11732 :       CALL section_add_keyword(subsection, keyword)
     914        11732 :       CALL keyword_release(keyword)
     915              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE", &
     916              :                           description="Scaling parameter for HFX kernel.", &
     917        11732 :                           usage="SCALE 0.25", default_r_val=1.00_dp)
     918        11732 :       CALL section_add_keyword(subsection, keyword)
     919        11732 :       CALL keyword_release(keyword)
     920        11732 :       CALL section_add_subsection(section, subsection)
     921        11732 :       CALL section_release(subsection)
     922              : 
     923        11732 :    END SUBROUTINE create_hfx_kernel_section
     924              : ! **************************************************************************************************
     925              : !> \brief creates the structure of the section needed for vdW potentials
     926              : !> \param section the section that will be created
     927              : !> \author jgh
     928              : ! **************************************************************************************************
     929        11732 :    SUBROUTINE create_vdw_potential_section(section)
     930              :       TYPE(section_type), POINTER                        :: section
     931              : 
     932              :       TYPE(keyword_type), POINTER                        :: keyword
     933              :       TYPE(section_type), POINTER                        :: newsection, print_key, subsection
     934              : 
     935        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
     936              :       CALL section_create(section, __LOCATION__, name="vdw_potential", &
     937              :                           description="This section combines all possible additional dispersion "// &
     938              :                           "corrections to the normal XC functionals. This can be more functionals "// &
     939              :                           "or simple empirical pair potentials. ", &
     940              :                           citations=[grimme2006, Tran2013], &
     941        35196 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
     942              : 
     943        11732 :       NULLIFY (subsection, keyword)
     944              :       CALL keyword_create(keyword, __LOCATION__, name="POTENTIAL_TYPE", &
     945              :                           variants=s2a("DISPERSION_FUNCTIONAL"), &
     946              :                           description="Type of dispersion/vdW functional or potential to use", &
     947              :                           usage="POTENTIAL_TYPE (NONE|PAIR_POTENTIAL|NON_LOCAL)", &
     948              :                           enum_c_vals=s2a("NONE", "PAIR_POTENTIAL", "NON_LOCAL"), &
     949              :                           enum_i_vals=[xc_vdw_fun_none, xc_vdw_fun_pairpot, xc_vdw_fun_nonloc], &
     950              :                           enum_desc=s2a("No dispersion/van der Waals functional.", &
     951              :                                         "Pair potential van der Waals density functional, "// &
     952              :                                         "including Grimme's empirical DFT-D methods.", &
     953              :                                         "Nonlocal van der Waals density functional; more "// &
     954              :                                         "rigorous in principle, but significantly more "// &
     955              :                                         "time-consuming."), &
     956        11732 :                           default_i_val=xc_vdw_fun_none)
     957        11732 :       CALL section_add_keyword(section, keyword)
     958        11732 :       CALL keyword_release(keyword)
     959              : 
     960              :       CALL section_create(subsection, __LOCATION__, name="PAIR_POTENTIAL", &
     961              :                           description="Information on the pair potential to calculate dispersion", &
     962        11732 :                           n_keywords=5, n_subsections=0, repeats=.TRUE.)
     963              :       CALL keyword_create(keyword, __LOCATION__, name="R_CUTOFF", &
     964              :                           variants=s2a("D3_CUTOFF", "D4_3B_CUTOFF"), &
     965              :                           description="Range of potential. The cutoff will be 2 times this value. "// &
     966              :                           "In the case of D4 it will be used for the 3-body term", &
     967              :                           usage="R_CUTOFF 20.0", default_r_val=20.0_dp, &
     968        11732 :                           unit_str="angstrom")
     969        11732 :       CALL section_add_keyword(subsection, keyword)
     970        11732 :       CALL keyword_release(keyword)
     971              :       CALL keyword_create(keyword, __LOCATION__, name="D4_CUTOFF", &
     972              :                           description="Range of potential. The cutoff will be 2 times this value. "// &
     973              :                           "Only used for the 2-body term of D4", &
     974              :                           usage="D4_CUTOFF 30.0", default_r_val=20.0_dp, &
     975        11732 :                           unit_str="angstrom")
     976        11732 :       CALL section_add_keyword(subsection, keyword)
     977        11732 :       CALL keyword_release(keyword)
     978              :       CALL keyword_create(keyword, __LOCATION__, name="D4_CUTOFF_WIDTH", &
     979              :                           variants=["D4_2B_CUTOFF_WIDTH"], &
     980              :                           description="Width of the smooth cutoff for the 2-body term of D4. "// &
     981              :                           "A value of zero disables smoothing.", &
     982              :                           usage="D4_CUTOFF_WIDTH 0.05", default_r_val=0.05_dp, &
     983        23464 :                           unit_str="bohr")
     984        11732 :       CALL section_add_keyword(subsection, keyword)
     985        11732 :       CALL keyword_release(keyword)
     986              :       CALL keyword_create(keyword, __LOCATION__, name="D4_3B_CUTOFF_WIDTH", &
     987              :                           description="Width of the smooth cutoff for the 3-body term of D4. "// &
     988              :                           "A value of zero disables smoothing.", &
     989              :                           usage="D4_3B_CUTOFF_WIDTH 0.0", default_r_val=0.0_dp, &
     990        11732 :                           unit_str="bohr")
     991        11732 :       CALL section_add_keyword(subsection, keyword)
     992        11732 :       CALL keyword_release(keyword)
     993              :       CALL keyword_create(keyword, __LOCATION__, name="D4_CN_CUTOFF", &
     994              :                           description="Coordination number cutoff for D4", &
     995              :                           usage="D4_CN_CUTOFF 30.0", default_r_val=-1.0_dp, &
     996        11732 :                           unit_str="angstrom")
     997        11732 :       CALL section_add_keyword(subsection, keyword)
     998        11732 :       CALL keyword_release(keyword)
     999              :       CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
    1000              :                           description="Type of potential", &
    1001              :                           citations=[grimme2006, Chai2008, grimme2010, grimme2011, Caldeweyher2020], &
    1002              :                           usage="TYPE (DFTD2|DFTD2(CHG)|DFTD3|DFTD3(BJ)|DFTD4)", &
    1003              :                           enum_c_vals=s2a("DFTD2", "DFTD2(CHG)", "DFTD3", "DFTD3(BJ)", "DFTD4"), &
    1004              :                           enum_i_vals=[vdw_pairpot_dftd2, vdw_pairpot_dftd2chg, vdw_pairpot_dftd3, &
    1005              :                                        vdw_pairpot_dftd3bj, vdw_pairpot_dftd4], &
    1006              :                           enum_desc=s2a("Grimme D2 method", &
    1007              :                                         "D2 with Chai-Head-Gordon damping (wB97X-D, a=6, alpha=12)", &
    1008              :                                         "Grimme D3 method (zero damping)", &
    1009              :                                         "Grimme D3 method (Becke-Johnson damping)", &
    1010              :                                         "Grimme D4 method"), &
    1011        70392 :                           default_i_val=vdw_pairpot_dftd3bj)
    1012        11732 :       CALL section_add_keyword(subsection, keyword)
    1013        11732 :       CALL keyword_release(keyword)
    1014              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_FILE_NAME", &
    1015              :                           description="Name of the parameter file, may include a path (not used for D4)", &
    1016              :                           usage="PARAMETER_FILE_NAME <FILENAME>", &
    1017        11732 :                           default_lc_val="dftd3.dat")
    1018        11732 :       CALL section_add_keyword(subsection, keyword)
    1019        11732 :       CALL keyword_release(keyword)
    1020              :       CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_FUNCTIONAL", &
    1021              :                           description="Use parameters for this specific density functional. "// &
    1022              :                           "For DFTD2(CHG), use WB97X-D. "// &
    1023              :                           "For available DFT-D4 functionals and parameters see: "// &
    1024              :                           "<https://github.com/dftd4/dftd4/blob/main/src/dftd4/param.f90>. "// &
    1025              :                           "For available D3 and D3(BJ) parameters see: "// &
    1026              :                           "<https://www.chemie.uni-bonn.de/grimme/de/software/dft-d3>. "// &
    1027              :                           "For Skala with D3(BJ), SKALA selects the B3LYP D3(BJ) parameters.", &
    1028              :                           usage="REFERENCE_FUNCTIONAL <functional>", &
    1029        11732 :                           type_of_var=char_t)
    1030        11732 :       CALL section_add_keyword(subsection, keyword)
    1031        11732 :       CALL keyword_release(keyword)
    1032              :       CALL keyword_create(keyword, __LOCATION__, name="D4_REFERENCE_CODE", &
    1033              :                           description="Calculate D4 energy using external library entirely. "// &
    1034              :                           "Not recommended if you are using an MPI version of CP2K, because "// &
    1035              :                           "DFT-D4 package does not support MPI parallelization. Note that "// &
    1036              :                           "the external library is always needed no matter if this option "// &
    1037              :                           "is triggered or not.", &
    1038              :                           usage="D4_REFERENCE_CODE", default_l_val=.FALSE., &
    1039        11732 :                           lone_keyword_l_val=.TRUE.)
    1040        11732 :       CALL section_add_keyword(subsection, keyword)
    1041        11732 :       CALL keyword_release(keyword)
    1042              :       CALL keyword_create(keyword, __LOCATION__, name="D4_DEBUG", &
    1043              :                           description="Debug output for D4 method using reference code; "// &
    1044              :                           "requires D4_REFERENCE_CODE F to work and VERBOSE_OUTPUT T to "// &
    1045              :                           "show the debugging result.", &
    1046              :                           usage="D4_DEBUG", default_l_val=.FALSE., &
    1047        11732 :                           lone_keyword_l_val=.TRUE.)
    1048        11732 :       CALL section_add_keyword(subsection, keyword)
    1049        11732 :       CALL keyword_release(keyword)
    1050              :       CALL keyword_create(keyword, __LOCATION__, name="D3_REFERENCE_CODE", &
    1051              :                           description="Use D3 damping parameters from s-dftd3 library instead of built-in values. "// &
    1052              :                           "Requires s-dftd3 library to be compiled in.", &
    1053              :                           usage="D3_REFERENCE_CODE", default_l_val=.FALSE., &
    1054        11732 :                           lone_keyword_l_val=.TRUE.)
    1055        11732 :       CALL section_add_keyword(subsection, keyword)
    1056        11732 :       CALL keyword_release(keyword)
    1057              :       CALL keyword_create(keyword, __LOCATION__, name="D2_SCALING", &
    1058              :                           variants=["SCALING"], &
    1059              :                           description="XC Functional dependent scaling parameter. If omitted, CP2K attempts"// &
    1060              :                           " to guess the xc functional that is in use and sets the associated scaling parameter.", &
    1061        23464 :                           usage="SCALING 0.2", default_r_val=0._dp)
    1062        11732 :       CALL section_add_keyword(subsection, keyword)
    1063        11732 :       CALL keyword_release(keyword)
    1064              :       CALL keyword_create(keyword, __LOCATION__, name="D2_EXP_PRE", &
    1065              :                           variants=["EXP_PRE"], &
    1066              :                           description="Prefactor in exponential damping factor (DFT-D2 potential). "// &
    1067              :                           "Not applicable to DFTD2(CHG).", &
    1068        23464 :                           usage="D2_EXP_PRE 20.", default_r_val=20._dp)
    1069        11732 :       CALL section_add_keyword(subsection, keyword)
    1070        11732 :       CALL keyword_release(keyword)
    1071              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_CN", &
    1072              :                           description="Cutoff value for coordination number function (DFT-D3 method)", &
    1073        11732 :                           usage="EPS_CN 1.e-6_dp", default_r_val=1.e-6_dp)
    1074        11732 :       CALL section_add_keyword(subsection, keyword)
    1075        11732 :       CALL keyword_release(keyword)
    1076              :       CALL keyword_create(keyword, __LOCATION__, name="D3_SCALING", &
    1077              :                           description="XC Functional dependent scaling parameters (s6,sr6,s8) for the DFT-D3 method."// &
    1078              :                           " If omitted, CP2K attempts"// &
    1079              :                           " to guess the xc functional from REFERENCE_FUNCTIONAL and sets the associated scaling parameter.", &
    1080              :                           usage="D3_SCALING 1.0 1.0 1.0", n_var=3, &
    1081        11732 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp])
    1082        11732 :       CALL section_add_keyword(subsection, keyword)
    1083        11732 :       CALL keyword_release(keyword)
    1084              :       CALL keyword_create(keyword, __LOCATION__, name="D3BJ_SCALING", &
    1085              :                           description="XC Functional dependent scaling parameters (s6,a1,s8,a2) for the DFT-D3(BJ) method."// &
    1086              :                           " If omitted, CP2K attempts"// &
    1087              :                           " to guess the xc functional from REFERENCE_FUNCTIONAL and sets the associated scaling parameter.", &
    1088              :                           usage="D3BJ_SCALING 1.0 1.0 1.0 1.0", n_var=4, &
    1089        11732 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp])
    1090        11732 :       CALL section_add_keyword(subsection, keyword)
    1091        11732 :       CALL keyword_release(keyword)
    1092              :       CALL keyword_create(keyword, __LOCATION__, name="D4_SCALING", &
    1093              :                           description="XC Functional dependent scaling parameters (s6,a1,s8,a2) for the DFT-D4 method."// &
    1094              :                           " If omitted, CP2K attempts"// &
    1095              :                           " to guess the xc functional from REFERENCE_FUNCTIONAL and sets the associated scaling parameter.", &
    1096              :                           usage="D4_SCALING 1.0 1.0 1.0 1.0", n_var=4, &
    1097        11732 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp])
    1098        11732 :       CALL section_add_keyword(subsection, keyword)
    1099        11732 :       CALL keyword_release(keyword)
    1100              :       CALL keyword_create(keyword, __LOCATION__, name="CALCULATE_C9_TERM", &
    1101              :                           description="Calculate C9 terms in DFT-D3 model", &
    1102              :                           usage="CALCULATE_C9_TERM", default_l_val=.FALSE., &
    1103        11732 :                           lone_keyword_l_val=.TRUE.)
    1104        11732 :       CALL section_add_keyword(subsection, keyword)
    1105        11732 :       CALL keyword_release(keyword)
    1106              :       CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_C9_TERM", &
    1107              :                           description="Calculate C9 terms in DFT-D3 model using reference coordination numbers", &
    1108              :                           usage="REFERENCE_C9_TERM", default_l_val=.FALSE., &
    1109        11732 :                           lone_keyword_l_val=.TRUE.)
    1110        11732 :       CALL section_add_keyword(subsection, keyword)
    1111        11732 :       CALL keyword_release(keyword)
    1112              :       CALL keyword_create(keyword, __LOCATION__, name="FACTOR_S9_TERM", &
    1113              :                           description="S9 prefactor of the many-body term in the DFT-D4 method.", &
    1114        11732 :                           usage="FACTOR_S9_TERM 1.e-0", default_r_val=1.00_dp)
    1115        11732 :       CALL section_add_keyword(subsection, keyword)
    1116        11732 :       CALL keyword_release(keyword)
    1117              :       CALL keyword_create(keyword, __LOCATION__, name="LONG_RANGE_CORRECTION", &
    1118              :                           description="Calculate a long range correction to the DFT-D3 model."// &
    1119              :                           " WARNING: Use with care! Only for isotropic dense systems.", &
    1120              :                           usage="LONG_RANGE_CORRECTION", default_l_val=.FALSE., &
    1121        11732 :                           lone_keyword_l_val=.TRUE.)
    1122        11732 :       CALL section_add_keyword(subsection, keyword)
    1123        11732 :       CALL keyword_release(keyword)
    1124              :       CALL keyword_create(keyword, __LOCATION__, name="SHORT_RANGE_CORRECTION", &
    1125              :                           description="Calculate a short-range bond correction to the DFT-D3 model", &
    1126              :                           usage="SHORT_RANGE_CORRECTION", default_l_val=.FALSE., &
    1127        11732 :                           lone_keyword_l_val=.TRUE.)
    1128        11732 :       CALL section_add_keyword(subsection, keyword)
    1129        11732 :       CALL keyword_release(keyword)
    1130              :       CALL keyword_create(keyword, __LOCATION__, name="SHORT_RANGE_CORRECTION_PARAMETERS", &
    1131              :                           description="Parameters for the short-range bond correction to the DFT-D3 model. "// &
    1132              :                           "s*(za*zb)^t1*EXP(-g*dr*r0ab^t2), parameters: s, g, t1, t2 "// &
    1133              :                           "Defaults: s=0.08, g=10.0, t1=0.5, t2=-1.0 ", &
    1134              :                           usage="SHORT_RANGE_CORRECTION_PARAMETERS", default_r_vals=[0.08_dp, 10.0_dp, 0.5_dp, -1.0_dp], &
    1135        11732 :                           n_var=4, type_of_var=real_t)
    1136        11732 :       CALL section_add_keyword(subsection, keyword)
    1137        11732 :       CALL keyword_release(keyword)
    1138              :       ! KG molecular corrections
    1139              :       CALL keyword_create(keyword, __LOCATION__, name="MOLECULE_CORRECTION", &
    1140              :                           description="Calculate a intermolecular correction to the DFT-D3 model", &
    1141              :                           usage="MOLECULE_CORRECTION", default_l_val=.FALSE., &
    1142        11732 :                           lone_keyword_l_val=.TRUE.)
    1143        11732 :       CALL section_add_keyword(subsection, keyword)
    1144        11732 :       CALL keyword_release(keyword)
    1145              :       CALL keyword_create(keyword, __LOCATION__, name="MOLECULE_CORRECTION_C8", &
    1146              :                           description="Calculate a intermolecular correction to the C8 term in the DFT-D3 model", &
    1147        11732 :                           usage="MOLECULE_CORRECTION_C8  1.0 ", default_r_val=0.0_dp)
    1148        11732 :       CALL section_add_keyword(subsection, keyword)
    1149        11732 :       CALL keyword_release(keyword)
    1150              :       CALL keyword_create(keyword, __LOCATION__, name="VERBOSE_OUTPUT", &
    1151              :                           description="Extensive output for the DFT-D2 and DFT-D3 models."// &
    1152              :                           " Needs PRINT_DFTD section to be specified.", &
    1153              :                           usage="VERBOSE_OUTPUT", default_l_val=.FALSE., &
    1154        11732 :                           lone_keyword_l_val=.TRUE.)
    1155        11732 :       CALL section_add_keyword(subsection, keyword)
    1156        11732 :       CALL keyword_release(keyword)
    1157              : 
    1158              :       ! Set coordination numbers by atom numbers
    1159              :       CALL keyword_create(keyword, __LOCATION__, name="D3_EXCLUDE_KIND", &
    1160              :                           description="Specifies the atomic kinds excluded in the DFT-D3 calculation.", &
    1161              :                           usage="D3_EXCLUDE_KIND kind1 kind2 ... ", repeats=.FALSE., &
    1162        11732 :                           n_var=-1, type_of_var=integer_t)
    1163        11732 :       CALL section_add_keyword(subsection, keyword)
    1164        11732 :       CALL keyword_release(keyword)
    1165              : 
    1166              :       ! Ignore selected pair interactins
    1167              :       CALL keyword_create(keyword, __LOCATION__, name="D3_EXCLUDE_KIND_PAIR", &
    1168              :                           description="Specifies the atomic kinds for interactions excluded from the DFT-D3 calculation.", &
    1169              :                           usage="D3_EXCLUDE_KIND_PAIR kind1 kind2 ", repeats=.TRUE., &
    1170        11732 :                           n_var=2, type_of_var=integer_t)
    1171        11732 :       CALL section_add_keyword(subsection, keyword)
    1172        11732 :       CALL keyword_release(keyword)
    1173              : 
    1174              :       ! Set coordination numbers by atom kinds
    1175              :       CALL keyword_create(keyword, __LOCATION__, name="KIND_COORDINATION_NUMBERS", &
    1176              :                           description="Specifies the coordination number for a kind for the C9 term in DFT-D3.", &
    1177              :                           usage="KIND_COORDINATION_NUMBERS CN kind ", repeats=.TRUE., &
    1178        11732 :                           n_var=-1, type_of_var=char_t)
    1179        11732 :       CALL section_add_keyword(subsection, keyword)
    1180        11732 :       CALL keyword_release(keyword)
    1181              :       ! Set coordination numbers by atom numbers
    1182              :       CALL keyword_create(keyword, __LOCATION__, name="ATOM_COORDINATION_NUMBERS", &
    1183              :                           description="Specifies the coordination number of a set of atoms for the C9 term in DFT-D3.", &
    1184              :                           usage="ATOM_COORDINATION_NUMBERS CN atom1 atom2 ... ", repeats=.TRUE., &
    1185        11732 :                           n_var=-1, type_of_var=char_t)
    1186        11732 :       CALL section_add_keyword(subsection, keyword)
    1187        11732 :       CALL keyword_release(keyword)
    1188              : 
    1189              :       ! parameter specification atom by atom
    1190              :       CALL keyword_create(keyword, __LOCATION__, name="ATOMPARM", &
    1191              :                           description="Specifies parameters for atom types (in atomic units). If "// &
    1192              :                           "not provided default parameters are used (DFT-D2).", &
    1193              :                           usage="ATOMPARM <ELEMENT> <C6_parameter> <vdw_radii>", &
    1194        11732 :                           repeats=.TRUE., n_var=-1, type_of_var=char_t)
    1195        11732 :       CALL section_add_keyword(subsection, keyword)
    1196        11732 :       CALL keyword_release(keyword)
    1197              : 
    1198        11732 :       NULLIFY (print_key)
    1199              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PRINT_DFTD", &
    1200              :                                        description="Controls the printing of some info about DFTD contributions", &
    1201        11732 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1202        11732 :       CALL section_add_subsection(subsection, print_key)
    1203        11732 :       CALL section_release(print_key)
    1204              : 
    1205        11732 :       NULLIFY (newsection)
    1206        11732 :       CALL create_eeq_control_section(newsection)
    1207        11732 :       CALL section_add_subsection(subsection, newsection)
    1208        11732 :       CALL section_release(newsection)
    1209              : 
    1210        11732 :       CALL section_add_subsection(section, subsection)
    1211        11732 :       CALL section_release(subsection)
    1212              : 
    1213              :       ! nonlocal section
    1214        11732 :       NULLIFY (subsection, keyword)
    1215              :       CALL section_create(subsection, __LOCATION__, name="NON_LOCAL", &
    1216              :                           description="Information on the non local part of dispersion functionals. "// &
    1217              :                           "Correct functionals require a corresponding setting of XC_FUNCTIONAL.", &
    1218        11732 :                           n_keywords=0, n_subsections=0, repeats=.TRUE.)
    1219              : 
    1220              :       CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
    1221              :                           description="Type of functional (the corresponding kernel data file should be selected). "// &
    1222              :                           "Allows for common forms such as vdW-DF, vdW-DF2, optB88-vdW, rVV10.", &
    1223              :                           usage="TYPE DRSLL", &
    1224              :                           enum_c_vals=s2a("DRSLL", "LMKLL", "RVV10"), &
    1225              :                           enum_i_vals=[vdw_nl_DRSLL, vdw_nl_LMKLL, vdw_nl_RVV10], &
    1226              :                           enum_desc=s2a("Dion-Rydberg-Schroeder-Langreth-Lundqvist nonlocal van der Waals density functional", &
    1227              :                                         "Lee-Murray-Kong-Lundqvist-Langreth nonlocal van der Waals density functional", &
    1228              :                                         "Revised Vydrov-van Voorhis nonlocal van der Waals density functional"), &
    1229              :                           citations=[Tran2013], &
    1230        23464 :                           default_i_val=vdw_nl_DRSLL)
    1231        11732 :       CALL section_add_keyword(subsection, keyword)
    1232        11732 :       CALL keyword_release(keyword)
    1233              :       CALL keyword_create(keyword, __LOCATION__, name="VERBOSE_OUTPUT", &
    1234              :                           description="Extensive output for non local functionals", &
    1235              :                           usage="VERBOSE_OUTPUT", default_l_val=.FALSE., &
    1236        11732 :                           lone_keyword_l_val=.TRUE.)
    1237        11732 :       CALL section_add_keyword(subsection, keyword)
    1238        11732 :       CALL keyword_release(keyword)
    1239              :       CALL keyword_create(keyword, __LOCATION__, name="KERNEL_FILE_NAME", &
    1240              :                           description="Name of the kernel data file, may include a path. "// &
    1241              :                           "vdW_kernel_table.dat is for DRSLL and LMKLL and "// &
    1242              :                           "rVV10_kernel_table.dat is for rVV10.", &
    1243              :                           usage="KERNEL_FILE_NAME <FILENAME>", &
    1244        11732 :                           default_lc_val="vdW_kernel_table.dat")
    1245        11732 :       CALL section_add_keyword(subsection, keyword)
    1246        11732 :       CALL keyword_release(keyword)
    1247              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF", &
    1248              :                           description="The cutoff of the FFT grid used in the calculation "// &
    1249              :                           "of the nonlocal vdW functional [Ry].", &
    1250              :                           usage="CUTOFF 300", &
    1251        11732 :                           default_r_val=-1._dp, unit_str="Ry")
    1252        11732 :       CALL section_add_keyword(subsection, keyword)
    1253        11732 :       CALL keyword_release(keyword)
    1254              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETERS", &
    1255              :                           description="Parameters b and C of the rVV10 functional", &
    1256              :                           usage="PARAMETERS 6.3 0.0093", &
    1257        11732 :                           type_of_var=real_t, default_r_vals=[6.3_dp, 0.0093_dp], n_var=2)
    1258        11732 :       CALL section_add_keyword(subsection, keyword)
    1259        11732 :       CALL keyword_release(keyword)
    1260              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE", &
    1261              :                           description="Scales the energy contribution of the rVV10 functional", &
    1262              :                           usage="SCALE 1.0", &
    1263        11732 :                           type_of_var=real_t, default_r_val=1.0_dp)
    1264        11732 :       CALL section_add_keyword(subsection, keyword)
    1265        11732 :       CALL keyword_release(keyword)
    1266              : 
    1267        11732 :       CALL section_add_subsection(section, subsection)
    1268        11732 :       CALL section_release(subsection)
    1269              : 
    1270        11732 :    END SUBROUTINE create_vdw_potential_section
    1271              : 
    1272              : ! **************************************************************************************************
    1273              : !> \brief creates the structure of the section needed for gCP potentials
    1274              : !> \param section the section that will be created
    1275              : !> \author jgh
    1276              : ! **************************************************************************************************
    1277        11732 :    SUBROUTINE create_gcp_potential_section(section)
    1278              :       TYPE(section_type), POINTER                        :: section
    1279              : 
    1280              :       TYPE(keyword_type), POINTER                        :: keyword
    1281              : 
    1282        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
    1283              :       CALL section_create(section, __LOCATION__, name="gcp_potential", &
    1284              :                           description="This section combines geometrical counterpoise potentials."// &
    1285              :                           " This is a simple empirical pair potential to correct for BSSE. ", &
    1286              :                           citations=[Kruse2012], &
    1287        23464 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
    1288              : 
    1289        11732 :       NULLIFY (keyword)
    1290              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_FILE_NAME", &
    1291              :                           description="Name of the parameter file, may include a path", &
    1292              :                           usage="PARAMETER_FILE_NAME <FILENAME>", &
    1293        11732 :                           default_lc_val="---")
    1294        11732 :       CALL section_add_keyword(section, keyword)
    1295        11732 :       CALL keyword_release(keyword)
    1296              : 
    1297              :       CALL keyword_create(keyword, __LOCATION__, name="GLOBAL_PARAMETERS", &
    1298              :                           description="Global parameters of the gCP method."// &
    1299              :                           " Parameters are sigma, alpha, beta, eta from the original paper.", &
    1300              :                           usage="GLOBAL_PARAMETERS 1.0 1.0 1.0 1.0", n_var=4, &
    1301        11732 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp])
    1302        11732 :       CALL section_add_keyword(section, keyword)
    1303        11732 :       CALL keyword_release(keyword)
    1304              : 
    1305              :       CALL keyword_create(keyword, __LOCATION__, name="DELTA_ENERGY", &
    1306              :                           description="Specify the delta energy [Hartree] term for an atom kind", &
    1307              :                           usage="DELTA_ENERGY  type value", &
    1308        35196 :                           type_of_var=char_t, repeats=.TRUE., n_var=-1, default_c_vals=["XX ", "0.0"])
    1309        11732 :       CALL section_add_keyword(section, keyword)
    1310        11732 :       CALL keyword_release(keyword)
    1311              : 
    1312              :       CALL keyword_create(keyword, __LOCATION__, name="VERBOSE", &
    1313              :                           description="Verbose output for gCP calculation", &
    1314              :                           usage="VERBOSE logical_value", &
    1315        11732 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1316        11732 :       CALL section_add_keyword(section, keyword)
    1317        11732 :       CALL keyword_release(keyword)
    1318              : 
    1319        11732 :    END SUBROUTINE create_gcp_potential_section
    1320              : 
    1321              : ! **************************************************************************************************
    1322              : !> \brief creates the structure of the GAUXC section
    1323              : !> \param section the section that will be created
    1324              : !> \author fawzi
    1325              : ! **************************************************************************************************
    1326        14663 :    SUBROUTINE create_gauxc_section(section)
    1327              :       TYPE(section_type), POINTER                        :: section
    1328              : 
    1329              :       TYPE(keyword_type), POINTER                        :: keyword
    1330              : 
    1331        14663 :       CPASSERT(.NOT. ASSOCIATED(section))
    1332              :       CALL section_create(section, __LOCATION__, name="GAUXC", &
    1333              :                           description="Use exchange-correlation functionals provided by GauXC. "// &
    1334              :                           "The current CP2K bridge uses GauXC's molecular quadrature. Periodic inputs "// &
    1335              :                           "are limited to isolated validation cells and are not compact periodic "// &
    1336              :                           "material calculations.", &
    1337        14663 :                           n_keywords=30, n_subsections=0, repeats=.FALSE.)
    1338              : 
    1339        14663 :       NULLIFY (keyword)
    1340              : 
    1341              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1342              :                           description="activates the functional", &
    1343        14663 :                           lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
    1344        14663 :       CALL section_add_keyword(section, keyword)
    1345        14663 :       CALL keyword_release(keyword)
    1346              : 
    1347              :       CALL keyword_create(keyword, __LOCATION__, name="FUNCTIONAL", &
    1348              :                           description="Functional name used to create the GauXC integrator. "// &
    1349              :                           "If MODEL is set, this optional base functional defaults to PBE and "// &
    1350              :                           "does not need to be specified for MODEL SKALA inputs.", &
    1351        14663 :                           default_c_val="PBE")
    1352        14663 :       CALL section_add_keyword(section, keyword)
    1353        14663 :       CALL keyword_release(keyword)
    1354              : 
    1355              :       CALL keyword_create(keyword, __LOCATION__, name="MODEL", &
    1356              :                           description="GauXC Skala model name or path. Use NONE for conventional GauXC. "// &
    1357              :                           "MODEL SKALA selects the installed Skala-1.1 model when available; "// &
    1358              :                           "other Skala models are supplied as .fun files or model names. "// &
    1359              :                           "NLCC pseudopotentials are rejected by the direct molecular GauXC "// &
    1360              :                           "Skala path. Pseudopotential GAPW PAW_ONE_CENTER and the CP2K-native "// &
    1361              :                           "SKALA grid path include NLCC in their reconstructed primitive fields.", &
    1362              :                           usage="MODEL SKALA", &
    1363        14663 :                           default_c_val="NONE")
    1364        14663 :       CALL section_add_keyword(section, keyword)
    1365        14663 :       CALL keyword_release(keyword)
    1366              : 
    1367              :       CALL keyword_create( &
    1368              :          keyword, __LOCATION__, name="PSEUDOPOTENTIAL_GAPW_REPRESENTATION", &
    1369              :          description="Select the density representation used by an active GauXC model for "// &
    1370              :          "METHOD GAPW/GAPW_XC kinds with GTH or ECP pseudopotentials. "// &
    1371              :          "DIRECT_VALENCE treats those kinds as GPW_TYPE and evaluates the model on "// &
    1372              :          "the direct valence density; this is the default for non-local models such "// &
    1373              :          "as Skala. PAW_ONE_CENTER combines the smooth and all hard-minus-soft "// &
    1374              :          "one-center primitive fields before one model evaluation, retaining all 15 pairwise "// &
    1375              :          "spin-gradient cross terms (14 additional to the smooth-density baseline) and the "// &
    1376              :          "non-local couplings. PAW_ONE_CENTER_SPLIT is a diagnostic that evaluates smooth, hard, "// &
    1377              :          "and soft fields separately. CP2K_DEFAULT retains the representation selected "// &
    1378              :          "by KIND%GPW_TYPE, basis hardness, and DFT%QS%FORCE_PAW. All-electron kinds "// &
    1379              :          "and conventional GauXC MODEL NONE calculations are unaffected. In a mixed "// &
    1380              :          "all-electron/pseudopotential calculation, the selector applies per kind: "// &
    1381              :          "all-electron kinds retain their one-center reconstruction while pseudopotential "// &
    1382              :          "kinds follow the selected representation. No mixed-system-specific input is needed.", &
    1383              :          usage="PSEUDOPOTENTIAL_GAPW_REPRESENTATION DIRECT_VALENCE", &
    1384              :          enum_c_vals=s2a("DIRECT_VALENCE", "PAW_ONE_CENTER", "CP2K_DEFAULT", &
    1385              :                          "PAW_ONE_CENTER_SPLIT"), &
    1386              :          enum_i_vals=[skala_gapw_direct_valence, skala_gapw_paw_one_center, &
    1387              :                       skala_gapw_cp2k_default, skala_gapw_paw_one_center_split], &
    1388              :          enum_desc=s2a("Use the direct pseudopotential valence density", &
    1389              :                        "Reconstruct the GAPW primitive fields before model evaluation", &
    1390              :                        "Use the representation selected by the ordinary CP2K GAPW rules", &
    1391              :                        "Diagnose the separate smooth plus hard-minus-soft energy expression"), &
    1392        14663 :          default_i_val=skala_gapw_direct_valence)
    1393        14663 :       CALL section_add_keyword(section, keyword)
    1394        14663 :       CALL keyword_release(keyword)
    1395              : 
    1396              :       CALL keyword_create(keyword, __LOCATION__, name="GRID", &
    1397              :                           description="Atomic grid size for GauXC. Skala defaults to SUPERFINE "// &
    1398              :                           "unless this keyword is set explicitly.", &
    1399              :                           usage="GRID fine", &
    1400              :                           enum_c_vals=s2a("FINE", "ULTRAFINE", "SUPERFINE", "GM3", "GM5"), &
    1401              :                           enum_i_vals=[1, 2, 3, 4, 5], &
    1402              :                           enum_desc=s2a("Fine grid (default)", &
    1403              :                                         "Ultra fine grid", &
    1404              :                                         "Super fine grid", &
    1405              :                                         "GM3 grid", &
    1406              :                                         "GM5 grid"), &
    1407        14663 :                           default_i_val=1)
    1408        14663 :       CALL section_add_keyword(section, keyword)
    1409        14663 :       CALL keyword_release(keyword)
    1410              : 
    1411              :       CALL keyword_create(keyword, __LOCATION__, name="RADIAL_QUADRATURE", &
    1412              :                           description="Radial quadrature scheme for GauXC", &
    1413              :                           usage="RADIAL_QUADRATURE muraknowles", &
    1414              :                           enum_c_vals=s2a("MURAKNOWLES", "BECKE", "TREUTLERAHLRICHS", "MURRAYHANDYLAMING"), &
    1415              :                           enum_i_vals=[1, 2, 3, 4], &
    1416              :                           enum_desc=s2a("Mura-Knowles radial quadrature (default)", &
    1417              :                                         "Becke radial quadrature", &
    1418              :                                         "Treutler-Ahlrichs radial quadrature", &
    1419              :                                         "Murray-Handy-Laming radial quadrature"), &
    1420        14663 :                           default_i_val=1)
    1421        14663 :       CALL section_add_keyword(section, keyword)
    1422        14663 :       CALL keyword_release(keyword)
    1423              : 
    1424              :       CALL keyword_create(keyword, __LOCATION__, name="PRUNING_SCHEME", &
    1425              :                           description="Pruning scheme for GauXC. Skala defaults to UNPRUNED "// &
    1426              :                           "unless this keyword is set explicitly.", &
    1427              :                           usage="PRUNING_SCHEME robust", &
    1428              :                           enum_c_vals=s2a("ROBUST", "TREUTLER", "UNPRUNED"), &
    1429              :                           enum_i_vals=[1, 2, 3], &
    1430              :                           enum_desc=s2a("Robust pruning (default)", &
    1431              :                                         "Treutler pruning", &
    1432              :                                         "Unpruned grid"), &
    1433        14663 :                           default_i_val=1)
    1434        14663 :       CALL section_add_keyword(section, keyword)
    1435        14663 :       CALL keyword_release(keyword)
    1436              : 
    1437              :       CALL keyword_create(keyword, __LOCATION__, name="BATCH_SIZE", &
    1438              :                           description="Batch size for GauXC evaluation", &
    1439              :                           usage="BATCH_SIZE 512", &
    1440        14663 :                           default_i_val=512)
    1441        14663 :       CALL section_add_keyword(section, keyword)
    1442        14663 :       CALL keyword_release(keyword)
    1443              : 
    1444              :       CALL keyword_create(keyword, __LOCATION__, name="DEVICE_RUNTIME_FILL_FRACTION", &
    1445              :                           description="Fraction of currently available GPU memory preallocated by "// &
    1446              :                           "a GauXC device runtime. Lower values leave more memory for Skala "// &
    1447              :                           "Torch inference; this keyword is used only with LB_EXECUTION_SPACE DEVICE.", &
    1448              :                           usage="DEVICE_RUNTIME_FILL_FRACTION 0.1", &
    1449        14663 :                           default_r_val=0.1_dp)
    1450        14663 :       CALL section_add_keyword(section, keyword)
    1451        14663 :       CALL keyword_release(keyword)
    1452              : 
    1453              :       CALL keyword_create(keyword, __LOCATION__, name="MODEL_ATOM_CHUNK_SIZE", &
    1454              :                           description="Atom chunk size for GauXC Skala Torch inference. "// &
    1455              :                           "A positive value evaluates the Torch model atom block by atom block; "// &
    1456              :                           "zero disables chunking; the default leaves GauXC's model-specific policy "// &
    1457              :                           "or the GAUXC_ONEDFT_ATOM_CHUNK_SIZE environment variable in control.", &
    1458              :                           usage="MODEL_ATOM_CHUNK_SIZE 3", &
    1459        14663 :                           default_i_val=-1)
    1460        14663 :       CALL section_add_keyword(section, keyword)
    1461        14663 :       CALL keyword_release(keyword)
    1462              : 
    1463              :       CALL keyword_create(keyword, __LOCATION__, name="PERIODIC_REFERENCE", &
    1464              :                           description="Explicitly opt into the limited isolated-cell GauXC reference "// &
    1465              :                           "path for periodic CP2K inputs. This path is restricted to Gamma-only, "// &
    1466              :                           "single-image METHOD GPW calculations with GTH pseudopotentials and uses "// &
    1467              :                           "GauXC's molecular quadrature; compact periodic materials require a "// &
    1468              :                           "dedicated periodic GauXC interface.", &
    1469              :                           usage="PERIODIC_REFERENCE T", &
    1470        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1471        14663 :       CALL section_add_keyword(section, keyword)
    1472        14663 :       CALL keyword_release(keyword)
    1473              : 
    1474              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID", &
    1475              :                           description="Experimental CP2K-native real-space-grid path for SKALA "// &
    1476              :                           "TorchScript models. This bypasses GauXC molecular quadrature and supports "// &
    1477              :                           "isolated, partially periodic, and fully periodic METHOD GPW cells with "// &
    1478              :                           "GTH/ECP pseudopotentials and METHOD GAPW/GAPW_XC cells. GAPW with "// &
    1479              :                           "GTH/ECP pseudopotentials supports direct-valence and PAW-like one-center "// &
    1480              :                           "density representations; GAPW all-electron reconstructs the all-electron "// &
    1481              :                           "primitive fields. The current implementation is limited "// &
    1482              :                           "to a single GAUXC functional and provides energy, VXC, and experimental "// &
    1483              :                           "analytical nuclear-gradient/stress evaluations. K-point runs use CP2K's "// &
    1484              :                           "standard k-point and symmetry-reduction infrastructure; CPU k-point "// &
    1485              :                           "runs require mutually compatible BLAS, ScaLAPACK, OpenMP, and LibTorch "// &
    1486              :                           "runtimes, while CUDA evaluation is selected explicitly. "// &
    1487              :                           "Energy/VXC runs split the Torch evaluation into atom blocks by default "// &
    1488              :                           "and route dynamic features and gradients between MPI ranks. "// &
    1489              :                           "PAW-like GAPW+GTH/ECP and METHOD GAPW_XC combine selectable hard/soft "// &
    1490              :                           "primitive fields before constructing the nonlinear SKALA features. ROKS, "// &
    1491              :                           "ADMM, and non-k-point multiple-image calculations are not implemented.", &
    1492              :                           usage="NATIVE_GRID T", &
    1493        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1494        14663 :       CALL section_add_keyword(section, keyword)
    1495        14663 :       CALL keyword_release(keyword)
    1496              : 
    1497              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_MODEL_FP64", &
    1498              :                           description="Promote float32 numerical state and explicit floating-point casts "// &
    1499              :                           "in the native SKALA TorchScript model to double precision. Trained parameter "// &
    1500              :                           "values are retained exactly. This improves SCF and geometry-derivative "// &
    1501              :                           "consistency for mixed-precision exports. Disable to retain the export's "// &
    1502              :                           "original numerical precision.", &
    1503              :                           usage="NATIVE_GRID_MODEL_FP64 T", &
    1504        14663 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1505        14663 :       CALL section_add_keyword(section, keyword)
    1506        14663 :       CALL keyword_release(keyword)
    1507              : 
    1508              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_USE_CUDA", &
    1509              :                           description="Evaluate the experimental CP2K-native SKALA GPW TorchScript "// &
    1510              :                           "model on CUDA when libtorch CUDA support is available. This requires a "// &
    1511              :                           "CUDA-compatible SKALA model export; MODEL SKALA first checks "// &
    1512              :                           "GAUXC_SKALA_CUDA_MODEL in this mode and otherwise falls back to "// &
    1513              :                           "SKALA_MODEL. The portable default uses CPU tensors.", &
    1514              :                           usage="NATIVE_GRID_USE_CUDA T", &
    1515        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1516        14663 :       CALL section_add_keyword(section, keyword)
    1517        14663 :       CALL keyword_release(keyword)
    1518              : 
    1519              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_CUDA_DEVICE", &
    1520              :                           description="CUDA device used by the experimental CP2K-native SKALA GPW "// &
    1521              :                           "TorchScript path when NATIVE_GRID_USE_CUDA is enabled. A negative value "// &
    1522              :                           "maps the MPI-local rank to one of the CUDA devices visible to the process; "// &
    1523              :                           "CUDA exports with device-specific TorchScript constants may require a "// &
    1524              :                           "rank-local CUDA_VISIBLE_DEVICES list. A non-negative value selects that "// &
    1525              :                           "visible CUDA device explicitly.", &
    1526              :                           usage="NATIVE_GRID_CUDA_DEVICE -1", &
    1527        14663 :                           default_i_val=-1)
    1528        14663 :       CALL section_add_keyword(section, keyword)
    1529        14663 :       CALL keyword_release(keyword)
    1530              : 
    1531              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_ATOM_PARTITION", &
    1532              :                           description="Atom partition used to build the experimental CP2K-native "// &
    1533              :                           "SKALA COMMON_GRID feature block. HARD assigns each native grid point to "// &
    1534              :                           "the nearest periodic atom and is intended for legacy energy/VXC-only runs. "// &
    1535              :                           "SMOOTH uses a Becke-like fuzzy-cell partition on the native grid and creates "// &
    1536              :                           "weighted atom rows. Internal atom-grid weights vanish through a smooth taper "// &
    1537              :                           "when sparse rows reach the partition cutoff. Analytical atom forces and stress "// &
    1538              :                           "include both the partition and taper derivatives in the SKALA feature response.", &
    1539              :                           usage="NATIVE_GRID_ATOM_PARTITION SMOOTH", &
    1540              :                           enum_c_vals=s2a("HARD", "SMOOTH"), &
    1541              :                           enum_i_vals=[1, 2], &
    1542              :                           enum_desc=s2a("Assign each grid point to the nearest atom", &
    1543              :                                         "Use a smooth Becke-like native-grid atom partition"), &
    1544        14663 :                           default_i_val=2)
    1545        14663 :       CALL section_add_keyword(section, keyword)
    1546        14663 :       CALL keyword_release(keyword)
    1547              : 
    1548              :       CALL keyword_create( &
    1549              :          keyword, __LOCATION__, name="NATIVE_GRID_LAYOUT", &
    1550              :          description="Select the numerical layout for native-grid Skala irrespective of the "// &
    1551              :          "electronic core representation. ATOM_COMPOSITE, the default, evaluates complete "// &
    1552              :          "atom-centered radial/Lebedev blocks. GPW and pseudopotential direct-valence fields "// &
    1553              :          "are interpolated from CP2K's plane-wave grid; GAPW primitive fields are combined "// &
    1554              :          "before nonlinear feature construction. The matching interpolation, partition, and "// &
    1555              :          "one-center adjoints return VXC, forces, and stress to CP2K. Mixed all-electron and "// &
    1556              :          "pseudopotential kinds use the same syntax and are reconstructed per kind. COMMON_GRID retains "// &
    1557              :          "evaluation on CP2K's regular real-space grid as a cutoff-sensitive reference and "// &
    1558              :          "diagnostic layout; mixed core representations require ATOM_COMPOSITE.", &
    1559              :          usage="NATIVE_GRID_LAYOUT ATOM_COMPOSITE", &
    1560              :          enum_c_vals=s2a("COMMON_GRID", "ATOM_COMPOSITE"), &
    1561              :          enum_i_vals=[skala_gapw_common_grid, skala_gapw_atom_composite_grid], &
    1562              :          enum_desc=s2a("Evaluate on the common regular real-space grid", &
    1563              :                        "Use image-partitioned atom-centered grids"), &
    1564        14663 :          default_i_val=skala_gapw_atom_composite_grid)
    1565        14663 :       CALL section_add_keyword(section, keyword)
    1566        14663 :       CALL keyword_release(keyword)
    1567              : 
    1568              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_GAPW_DENSITY_PARTITION", &
    1569              :                           description="Hard/soft one-center primitive-field contribution used by "// &
    1570              :                           "METHOD GAPW and METHOD GAPW_XC. With PAW_ONE_CENTER, HARD_MINUS_SOFT "// &
    1571              :                           "combines smooth, hard, and soft density, gradient, and kinetic-energy-density "// &
    1572              :                           "fields before a single nonlinear SKALA evaluation. It is the default. For "// &
    1573              :                           "pseudopotential PAW/one-center GAPW this is distinct from KIND%GPW_TYPE, "// &
    1574              :                           "which uses the regular-grid valence-density approximation. "// &
    1575              :                           "HARD_ONLY, SOFT_ONLY, and NONE are diagnostic variants.", &
    1576              :                           usage="NATIVE_GRID_GAPW_DENSITY_PARTITION HARD_MINUS_SOFT", &
    1577              :                           enum_c_vals=s2a("HARD_MINUS_SOFT", "HARD_ONLY", "SOFT_ONLY", "NONE"), &
    1578              :                           enum_i_vals=[1, 2, 3, 4], &
    1579              :                           enum_desc=s2a("Use the hard-minus-soft GAPW one-center correction", &
    1580              :                                         "Use only the hard one-center density", &
    1581              :                                         "Use only the soft one-center density with the GAPW sign", &
    1582              :                                         "Disable the GAPW one-center SKALA correction"), &
    1583        14663 :                           default_i_val=1)
    1584        14663 :       CALL section_add_keyword(section, keyword)
    1585        14663 :       CALL keyword_release(keyword)
    1586              : 
    1587              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_GAPW_COMPOSITE_REFERENCE", &
    1588              :                           description="Evaluate native-grid SKALA for METHOD GAPW or GAPW_XC on "// &
    1589              :                           "rho and tau reconstructed as smooth plus hard-minus-soft before nonlinear "// &
    1590              :                           "feature construction on one common regular grid. No separate one-center "// &
    1591              :                           "SKALA energy is added. This expensive, cutoff-sensitive diagnostic is "// &
    1592              :                           "intended to validate the nonlinear hard/soft cross terms.", &
    1593              :                           usage="NATIVE_GRID_GAPW_COMPOSITE_REFERENCE T", &
    1594        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1595        14663 :       CALL section_add_keyword(section, keyword)
    1596        14663 :       CALL keyword_release(keyword)
    1597              : 
    1598              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_GAPW_COMPOSITE_DIRECT_AO", &
    1599              :                           description="Use direct full-ORB rho and tau collocation for the native-grid "// &
    1600              :                           "GAPW composite diagnostic. This is the variational all-electron "// &
    1601              :                           "counterpart of the reconstructed smooth plus hard-minus-soft fields and "// &
    1602              :                           "provides a reference for their common-grid adjoint.", &
    1603              :                           usage="NATIVE_GRID_GAPW_COMPOSITE_DIRECT_AO T", &
    1604        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1605        14663 :       CALL section_add_keyword(section, keyword)
    1606        14663 :       CALL keyword_release(keyword)
    1607              : 
    1608              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_GAPW_ATOM_COMPOSITE_REFERENCE", &
    1609              :                           description="Replace the native smooth plus separate GAPW one-center SKALA "// &
    1610              :                           "terms by one atom-centered evaluation of smooth plus hard-minus-soft "// &
    1611              :                           "primitive fields before nonlinear feature construction. The smooth PW "// &
    1612              :                           "and one-center VXC adjoints are returned consistently. MPI ranks assemble "// &
    1613              :                           "the atom rows collectively; one communicator root evaluates the model and "// &
    1614              :                           "broadcasts the energy and feature adjoints.", &
    1615              :                           usage="NATIVE_GRID_GAPW_ATOM_COMPOSITE_REFERENCE T", &
    1616        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1617        14663 :       CALL section_add_keyword(section, keyword)
    1618        14663 :       CALL keyword_release(keyword)
    1619              : 
    1620              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_GAPW_ATOM_COMPOSITE_DIAGNOSTIC", &
    1621              :                           description="Evaluate an energy-only GAPW diagnostic on the combined "// &
    1622              :                           "smooth plus one-center hard-minus-soft density before nonlinear SKALA "// &
    1623              :                           "feature construction. The smooth native-grid density is interpolated to "// &
    1624              :                           "the atom-centered GAPW quadrature and all atomic grids are evaluated in "// &
    1625              :                           "one model call. This single-rank diagnostic does not replace the active "// &
    1626              :                           "XC energy or potential.", &
    1627              :                           usage="NATIVE_GRID_GAPW_ATOM_COMPOSITE_DIAGNOSTIC T", &
    1628        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1629        14663 :       CALL section_add_keyword(section, keyword)
    1630        14663 :       CALL keyword_release(keyword)
    1631              : 
    1632              :       CALL keyword_create(keyword, __LOCATION__, &
    1633              :                           name="NATIVE_GRID_GAPW_ATOM_COMPOSITE_COMPONENTS", &
    1634              :                           description="Select which one-center hard-minus-soft fields enter the "// &
    1635              :                           "atom-composite SKALA diagnostic. FULL combines rho, gradient, and tau; "// &
    1636              :                           "RHO_GRAD and TAU isolate the corresponding reconstruction; SMOOTH "// &
    1637              :                           "uses only interpolated smooth fields.", &
    1638              :                           usage="NATIVE_GRID_GAPW_ATOM_COMPOSITE_COMPONENTS FULL", &
    1639              :                           enum_c_vals=s2a("FULL", "RHO_GRAD", "TAU", "SMOOTH"), &
    1640              :                           enum_i_vals=[1, 2, 3, 4], &
    1641              :                           enum_desc=s2a("Combine rho, gradient, and tau corrections", &
    1642              :                                         "Combine only rho and gradient corrections", &
    1643              :                                         "Combine only the tau correction", &
    1644              :                                         "Use only interpolated smooth fields"), &
    1645        14663 :                           default_i_val=1)
    1646        14663 :       CALL section_add_keyword(section, keyword)
    1647        14663 :       CALL keyword_release(keyword)
    1648              : 
    1649              :       CALL keyword_create(keyword, __LOCATION__, &
    1650              :                           name="NATIVE_GRID_GAPW_ATOM_COMPOSITE_FD_STEP", &
    1651              :                           description="Central finite-difference step used by the atom-composite "// &
    1652              :                           "feature-VXC diagnostic.", &
    1653              :                           usage="NATIVE_GRID_GAPW_ATOM_COMPOSITE_FD_STEP 3.0E-3", &
    1654        14663 :                           default_r_val=3.0E-3_dp)
    1655        14663 :       CALL section_add_keyword(section, keyword)
    1656        14663 :       CALL keyword_release(keyword)
    1657              : 
    1658              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_ATOM_CHUNKS", &
    1659              :                           description="Split the experimental CP2K-native SKALA GPW TorchScript "// &
    1660              :                           "evaluation into contiguous atom blocks. MPI runs evaluate one atom block per "// &
    1661              :                           "rank, while single-rank runs can still use atom subchunks to reduce peak CUDA "// &
    1662              :                           "memory. Dynamic feature rows and VXC gradients are routed between their "// &
    1663              :                           "local grid and atom-block owner ranks. This is enabled by default; set it to "// &
    1664              :                           "false to retain the replicated global feature block. ATOM_COMPOSITE also "// &
    1665              :                           "subchunks energy, VXC, force, and stress evaluations along independent atomic "// &
    1666              :                           "blocks; COMMON_GRID analytical force and stress runs retain the full "// &
    1667              :                           "differentiable tensor graph.", &
    1668              :                           usage="NATIVE_GRID_ATOM_CHUNKS T", &
    1669        14663 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1670        14663 :       CALL section_add_keyword(section, keyword)
    1671        14663 :       CALL keyword_release(keyword)
    1672              : 
    1673              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_ATOM_CHUNK_ROUTING", &
    1674              :                           description="Compatibility alias for the routed experimental CP2K-native "// &
    1675              :                           "SKALA GPW atom chunks. This implies NATIVE_GRID_ATOM_CHUNKS.", &
    1676              :                           usage="NATIVE_GRID_ATOM_CHUNK_ROUTING T", &
    1677        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1678        14663 :       CALL section_add_keyword(section, keyword)
    1679        14663 :       CALL keyword_release(keyword)
    1680              : 
    1681              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_ATOM_CHUNK_MAX_ROWS", &
    1682              :                           description="Maximum number of atom-grid rows evaluated by one TorchScript "// &
    1683              :                           "call in the experimental CP2K-native SKALA GPW atom-chunk path. A positive "// &
    1684              :                           "value splits each rank-local atom chunk into contiguous atom subchunks "// &
    1685              :                           "whose padded Torch row count stays below the limit. Atomic blocks are not "// &
    1686              :                           "divided, so one block can exceed the requested limit. Zero disables "// &
    1687              :                           "subchunking; -1 selects an automatic padded-row cap.", &
    1688              :                           usage="NATIVE_GRID_ATOM_CHUNK_MAX_ROWS 250000", &
    1689        14663 :                           default_i_val=-1)
    1690        14663 :       CALL section_add_keyword(section, keyword)
    1691        14663 :       CALL keyword_release(keyword)
    1692              : 
    1693              :       CALL keyword_create(keyword, __LOCATION__, name="NATIVE_GRID_DIAGNOSTICS", &
    1694              :                           description="Print diagnostic integrals of the CP2K-native SKALA GPW feature "// &
    1695              :                           "block, including electron count, spin moment, and summed grid weights.", &
    1696              :                           usage="NATIVE_GRID_DIAGNOSTICS T", &
    1697        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1698        14663 :       CALL section_add_keyword(section, keyword)
    1699        14663 :       CALL keyword_release(keyword)
    1700              : 
    1701              :       CALL keyword_create(keyword, __LOCATION__, name="MOLECULAR_VIRIAL", &
    1702              :                           description="Print a molecular XC virial diagnostic computed from GauXC "// &
    1703              :                           "nuclear gradients. This is not an analytical periodic stress tensor.", &
    1704              :                           usage="MOLECULAR_VIRIAL T", &
    1705        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1706        14663 :       CALL section_add_keyword(section, keyword)
    1707        14663 :       CALL keyword_release(keyword)
    1708              : 
    1709              :       CALL keyword_create(keyword, __LOCATION__, name="MOLECULAR_VIRIAL_DEBUG", &
    1710              :                           description="Check the GauXC molecular XC virial diagnostic against a "// &
    1711              :                           "finite-difference affine scaling of the molecular coordinates.", &
    1712              :                           usage="MOLECULAR_VIRIAL_DEBUG T", &
    1713        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1714        14663 :       CALL section_add_keyword(section, keyword)
    1715        14663 :       CALL keyword_release(keyword)
    1716              : 
    1717              :       CALL keyword_create(keyword, __LOCATION__, name="MOLECULAR_VIRIAL_DEBUG_DX", &
    1718              :                           description="Dimensionless finite-difference step for MOLECULAR_VIRIAL_DEBUG.", &
    1719              :                           usage="MOLECULAR_VIRIAL_DEBUG_DX 1.0E-4", &
    1720        14663 :                           default_r_val=1.0E-4_dp)
    1721        14663 :       CALL section_add_keyword(section, keyword)
    1722        14663 :       CALL keyword_release(keyword)
    1723              : 
    1724              :       CALL keyword_create(keyword, __LOCATION__, name="LB_EXECUTION_SPACE", &
    1725              :                           description="Execution space for load balancer in GauXC", &
    1726              :                           usage="LB_EXECUTION_SPACE host", &
    1727              :                           enum_c_vals=s2a("HOST", "DEVICE"), &
    1728              :                           enum_i_vals=[1, 2], &
    1729              :                           enum_desc=s2a("Run on host (default)", &
    1730              :                                         "Run on device"), &
    1731        14663 :                           default_i_val=1)
    1732        14663 :       CALL section_add_keyword(section, keyword)
    1733        14663 :       CALL keyword_release(keyword)
    1734              : 
    1735              :       CALL keyword_create(keyword, __LOCATION__, name="INT_EXECUTION_SPACE", &
    1736              :                           description="Execution space for integrator in GauXC", &
    1737              :                           usage="INT_EXECUTION_SPACE host", &
    1738              :                           enum_c_vals=s2a("HOST", "DEVICE"), &
    1739              :                           enum_i_vals=[1, 2], &
    1740              :                           enum_desc=s2a("Run on host (default)", &
    1741              :                                         "Run on device"), &
    1742        14663 :                           default_i_val=1)
    1743        14663 :       CALL section_add_keyword(section, keyword)
    1744        14663 :       CALL keyword_release(keyword)
    1745              : 
    1746              :       CALL keyword_create(keyword, __LOCATION__, name="LWD_KERNEL", &
    1747              :                           description="Local work driver kernel used by the GauXC integrator. "// &
    1748              :                           "AUTO uses SCHEME1-CUTLASS for device SKALA when GauXC provides it "// &
    1749              :                           "and otherwise uses GauXC's default for the selected execution space. "// &
    1750              :                           "DEFAULT always uses GauXC's default. "// &
    1751              :                           "Device builds with CUTLASS support can use SCHEME1-CUTLASS to run "// &
    1752              :                           "the grouped local potential update through CUTLASS.", &
    1753              :                           usage="LWD_KERNEL AUTO", &
    1754        14663 :                           default_c_val="AUTO")
    1755        14663 :       CALL section_add_keyword(section, keyword)
    1756        14663 :       CALL keyword_release(keyword)
    1757              : 
    1758              :       CALL keyword_create(keyword, __LOCATION__, name="SKALA_RUNTIME", &
    1759              :                           description="MPI communicator policy for GauXC Skala. AUTO uses "// &
    1760              :                           "the force-evaluation communicator for closed-shell calculations and a "// &
    1761              :                           "rank-local replicated runtime for open-shell calculations. MPI forces the "// &
    1762              :                           "force-evaluation communicator. SELF forces the previous replicated mode.", &
    1763              :                           usage="SKALA_RUNTIME AUTO", &
    1764              :                           enum_c_vals=s2a("AUTO", "MPI", "SELF"), &
    1765              :                           enum_i_vals=[1, 2, 3], &
    1766              :                           enum_desc=s2a("Closed-shell MPI, open-shell replicated (default)", &
    1767              :                                         "Use the force-evaluation MPI communicator", &
    1768              :                                         "Use rank-local replicated GauXC runtimes"), &
    1769        14663 :                           default_i_val=1)
    1770        14663 :       CALL section_add_keyword(section, keyword)
    1771        14663 :       CALL keyword_release(keyword)
    1772              : 
    1773              :       CALL keyword_create(keyword, __LOCATION__, name="MODEL_GRADIENT_RUNTIME", &
    1774              :                           description="MPI communicator policy for GauXC Skala nuclear gradients. "// &
    1775              :                           "AUTO uses distributed analytical gradients when the GauXC PR #222 fix is "// &
    1776              :                           "verified and energy/VXC uses MPI; otherwise it retains rank-local gradients. "// &
    1777              :                           "MPI requires verified support and an MPI energy/VXC runtime. SELF forces "// &
    1778              :                           "rank-local gradients. AUTO never overrides SKALA_RUNTIME's open-shell safeguard.", &
    1779              :                           usage="MODEL_GRADIENT_RUNTIME AUTO", &
    1780              :                           enum_c_vals=s2a("AUTO", "MPI", "SELF"), &
    1781              :                           enum_i_vals=[1, 2, 3], &
    1782              :                           enum_desc=s2a("Use verified MPI gradients or safe replicated fallback (default)", &
    1783              :                                         "Use the force-evaluation MPI communicator when supported", &
    1784              :                                         "Use rank-local replicated gradient runtimes"), &
    1785        14663 :                           default_i_val=1)
    1786        14663 :       CALL section_add_keyword(section, keyword)
    1787        14663 :       CALL keyword_release(keyword)
    1788              : 
    1789              :       CALL keyword_create(keyword, __LOCATION__, name="FORCE_NUMERICAL_GRADIENT", &
    1790              :                           description="Force central finite differences for the GauXC molecular XC "// &
    1791              :                           "nuclear gradient, using a displacement of 1.0E-4 bohr at fixed AO density. "// &
    1792              :                           "Diagnostic option; costs six XC energy evaluations per atom. Does not "// &
    1793              :                           "affect NATIVE_GRID or the CP2K one-center contribution.", &
    1794              :                           usage="FORCE_NUMERICAL_GRADIENT T", &
    1795        14663 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1796        14663 :       CALL section_add_keyword(section, keyword)
    1797        14663 :       CALL keyword_release(keyword)
    1798              : 
    1799              :       CALL keyword_create(keyword, __LOCATION__, name="OUTPUT_PATH", &
    1800              :                           description="Optional path to an existing directory for GauXC HDF5 debug output. "// &
    1801              :                           "If set, molecule and basis set data are written as separate HDF5 files.", &
    1802              :                           usage="OUTPUT_PATH /path/to/output", &
    1803        14663 :                           default_c_val="")
    1804        14663 :       CALL section_add_keyword(section, keyword)
    1805        14663 :       CALL keyword_release(keyword)
    1806              : 
    1807        14663 :    END SUBROUTINE create_gauxc_section
    1808              : 
    1809              : ! **************************************************************************************************
    1810              : !> \brief creates the input section for the xc part
    1811              : !> \param section the section to create
    1812              : !> \author fawzi
    1813              : ! **************************************************************************************************
    1814        11732 :    SUBROUTINE create_xc_section(section)
    1815              :       TYPE(section_type), POINTER                        :: section
    1816              : 
    1817              :       INTEGER                                            :: default_libxc_backend
    1818              :       TYPE(keyword_type), POINTER                        :: keyword
    1819              :       TYPE(section_type), POINTER                        :: subsection
    1820              : 
    1821        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
    1822              :       CALL section_create(section, __LOCATION__, name="xc", &
    1823              :                           description="Parameters needed for the calculation of the eXchange and Correlation potential", &
    1824        11732 :                           n_keywords=6, n_subsections=2, repeats=.FALSE.)
    1825              : 
    1826        11732 :       NULLIFY (subsection, keyword)
    1827              : 
    1828              :       CALL keyword_create(keyword, __LOCATION__, name="density_cutoff", &
    1829              :                           description="The cutoff on the density used by the xc calculation", &
    1830        11732 :                           usage="density_cutoff 1.e-11", default_r_val=1.0e-10_dp)
    1831        11732 :       CALL section_add_keyword(section, keyword)
    1832        11732 :       CALL keyword_release(keyword)
    1833              : 
    1834              :       CALL keyword_create(keyword, __LOCATION__, name="gradient_cutoff", &
    1835              :                           description="The cutoff on the gradient of the density used by the "// &
    1836              :                           "xc calculation", &
    1837        11732 :                           usage="gradient_cutoff 1.e-11", default_r_val=1.0e-10_dp)
    1838        11732 :       CALL section_add_keyword(section, keyword)
    1839        11732 :       CALL keyword_release(keyword)
    1840              : 
    1841              :       CALL keyword_create(keyword, __LOCATION__, name="DENSITY_SMOOTH_CUTOFF_RANGE", &
    1842              :                           description="Parameter for the smoothing procedure in xc calculation", &
    1843        11732 :                           usage="DENSITY_SMOOTH_CUTOFF_RANGE {real}", default_r_val=0.0_dp)
    1844        11732 :       CALL section_add_keyword(section, keyword)
    1845        11732 :       CALL keyword_release(keyword)
    1846              : 
    1847              :       CALL keyword_create(keyword, __LOCATION__, name="tau_cutoff", &
    1848              :                           description="The cutoff on tau used by the xc calculation", &
    1849        11732 :                           usage="tau_cutoff 1.e-11", default_r_val=1.0e-10_dp)
    1850        11732 :       CALL section_add_keyword(section, keyword)
    1851        11732 :       CALL keyword_release(keyword)
    1852              : 
    1853              :       ! The GPU backend is the default on builds with a device path; HOST is the
    1854              :       ! only option without one, and DEVICE aborts when no GPU is usable.
    1855              : #if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_LIBXC)
    1856              :       default_libxc_backend = do_libxc_gpu
    1857              : #else
    1858        11732 :       default_libxc_backend = do_libxc_cpu
    1859              : #endif
    1860              :       CALL keyword_create(keyword, __LOCATION__, name="LIBXC_GPU_BACKEND", &
    1861              :                           description="Runtime device/host backend selection for LibXC. "// &
    1862              :                           "DEVICE selects the GPU backend (the default on GPU "// &
    1863              :                           "builds), HOST the CPU backend. DEVICE is an error "// &
    1864              :                           "(abort) when no usable GPU is found at runtime; HOST "// &
    1865              :                           "always runs.", &
    1866              :                           usage="LIBXC_GPU_BACKEND HOST", &
    1867              :                           default_i_val=default_libxc_backend, &
    1868              :                           enum_i_vals=[do_libxc_gpu, do_libxc_cpu], &
    1869              :                           enum_c_vals=s2a("DEVICE", "HOST"), &
    1870        11732 :                           enum_desc=s2a("LibXC GPU backend", "LibXC CPU backend"))
    1871        11732 :       CALL section_add_keyword(section, keyword)
    1872        11732 :       CALL keyword_release(keyword)
    1873              : 
    1874              :       CALL section_create(subsection, __LOCATION__, name="xc_grid", & !FM to do
    1875              :                           description="The xc parameters used when calculating the xc on the grid", &
    1876        11732 :                           n_keywords=6, n_subsections=0, repeats=.FALSE.)
    1877              :       CALL keyword_create(keyword, __LOCATION__, name="xc_smooth_rho", &
    1878              :                           description="The density smoothing used for the xc calculation", &
    1879              :                           usage="xc_smooth_rho nn10", default_i_val=xc_rho_no_smooth, &
    1880              :                           enum_c_vals=s2a("NONE", "NN50", "NN10", "SPLINE2", "NN6", "SPLINE3", "NN4"), &
    1881              :                           enum_i_vals=[xc_rho_no_smooth, xc_rho_nn50, xc_rho_nn10, &
    1882              :                                        xc_rho_spline2_smooth, xc_rho_spline2_smooth, xc_rho_spline3_smooth, &
    1883        11732 :                                        xc_rho_spline3_smooth])
    1884        11732 :       CALL section_add_keyword(subsection, keyword)
    1885        11732 :       CALL keyword_release(keyword)
    1886              : 
    1887              :       CALL keyword_create(keyword, __LOCATION__, name="xc_deriv", &
    1888              :                           description="The method used to compute the derivatives", &
    1889              :                           usage="xc_deriv NN10_SMOOTH", default_i_val=xc_deriv_pw, &
    1890              :                           enum_c_vals=s2a("PW", "SPLINE3", "SPLINE2", "NN50_SMOOTH", "NN10_SMOOTH", &
    1891              :                                           "SPLINE2_SMOOTH", "NN6_SMOOTH", "SPLINE3_SMOOTH", "NN4_SMOOTH", "COLLOCATE"), &
    1892              :                           enum_i_vals=[xc_deriv_pw, xc_deriv_spline3, xc_deriv_spline2, &
    1893              :                                        xc_deriv_nn50_smooth, xc_deriv_nn10_smooth, xc_deriv_spline2_smooth, &
    1894              :                                        xc_deriv_spline2_smooth, xc_deriv_spline3_smooth, xc_deriv_spline3_smooth, &
    1895        11732 :                                        xc_deriv_collocate])
    1896        11732 :       CALL section_add_keyword(subsection, keyword)
    1897        11732 :       CALL keyword_release(keyword)
    1898              : 
    1899              :       CALL keyword_create(keyword, __LOCATION__, name="use_finer_grid", &
    1900              :                           description="Uses a finer grid only to calculate the xc", &
    1901              :                           usage="use_finer_grid", default_l_val=.FALSE., &
    1902        11732 :                           lone_keyword_l_val=.TRUE.)
    1903        11732 :       CALL section_add_keyword(subsection, keyword)
    1904        11732 :       CALL keyword_release(keyword)
    1905              : 
    1906              :       CALL keyword_create(keyword, __LOCATION__, name="fine_grid_factor", &
    1907              :                           description="Factor by which the XC grid cutoff is increased when USE_FINER_GRID is active. "// &
    1908              :                           "This setting has no effect unless USE_FINER_GRID is enabled. The default of 4.0 preserves "// &
    1909              :                           "the historical finer XC grid. Smaller factors can reduce the finer-grid cost, but should "// &
    1910              :                           "be checked together with the regular MGRID cutoff convergence.", &
    1911              :                           usage="FINE_GRID_FACTOR 4.0", default_r_val=4.0_dp, &
    1912        23464 :                           variants=["FINE_XC_FACTOR"])
    1913        11732 :       CALL section_add_keyword(subsection, keyword)
    1914        11732 :       CALL keyword_release(keyword)
    1915              : 
    1916              :       CALL keyword_create(keyword, __LOCATION__, name="2ND_DERIV_ANALYTICAL", &
    1917              :                           description="Use analytical formulas or finite differences for 2nd derivatives of XC", &
    1918              :                           usage="2ND_DERIV_ANALYTICAL logical", default_l_val=.TRUE., &
    1919        11732 :                           lone_keyword_l_val=.TRUE.)
    1920        11732 :       CALL section_add_keyword(section, keyword)
    1921        11732 :       CALL keyword_release(keyword)
    1922              : 
    1923              :       CALL keyword_create(keyword, __LOCATION__, name="3RD_DERIV_ANALYTICAL", &
    1924              :                           description="Use analytical formulas or finite differences for 3rd derivatives of XC", &
    1925              :                           usage="3RD_DERIV_ANALYTICAL logical", default_l_val=.FALSE., &
    1926        11732 :                           lone_keyword_l_val=.TRUE.)
    1927        11732 :       CALL section_add_keyword(section, keyword)
    1928        11732 :       CALL keyword_release(keyword)
    1929              : 
    1930              :       CALL keyword_create(keyword, __LOCATION__, name="STEP_SIZE", &
    1931              :                           description="Step size in terms of the first order potential for the numerical "// &
    1932              :                           "evaluation of XC derivatives", &
    1933        11732 :                           usage="STEP_SIZE 1.0E-3", default_r_val=1e-3_dp)
    1934        11732 :       CALL section_add_keyword(section, keyword)
    1935        11732 :       CALL keyword_release(keyword)
    1936              : 
    1937              :       CALL keyword_create(keyword, __LOCATION__, name="NSTEPS", &
    1938              :                           description="Number of steps to consider in each direction for the numerical "// &
    1939              :                           "evaluation of XC derivatives. Must be a value from 1 to 4 (Default: 3).", &
    1940        11732 :                           usage="NSTEPS 4", default_i_val=3)
    1941        11732 :       CALL section_add_keyword(section, keyword)
    1942        11732 :       CALL keyword_release(keyword)
    1943              : 
    1944        11732 :       CALL section_add_subsection(section, subsection)
    1945        11732 :       CALL section_release(subsection)
    1946              : 
    1947        11732 :       CALL create_xc_fun_section(subsection)
    1948        11732 :       CALL section_add_subsection(section, subsection)
    1949        11732 :       CALL section_release(subsection)
    1950              : 
    1951        11732 :       CALL create_hfx_section(subsection)
    1952        11732 :       CALL section_add_subsection(section, subsection)
    1953        11732 :       CALL section_release(subsection)
    1954              : 
    1955        11732 :       CALL create_mp2_section(subsection)
    1956        11732 :       CALL section_add_subsection(section, subsection)
    1957        11732 :       CALL section_release(subsection)
    1958              : 
    1959        11732 :       CALL create_adiabatic_section(subsection)
    1960        11732 :       CALL section_add_subsection(section, subsection)
    1961        11732 :       CALL section_release(subsection)
    1962              : 
    1963        11732 :       CALL create_xc_potential_section(subsection)
    1964        11732 :       CALL section_add_subsection(section, subsection)
    1965        11732 :       CALL section_release(subsection)
    1966              : 
    1967        11732 :       CALL create_xc_kernel_section(subsection)
    1968        11732 :       CALL section_add_subsection(section, subsection)
    1969        11732 :       CALL section_release(subsection)
    1970              : 
    1971        11732 :       CALL create_hfx_kernel_section(subsection)
    1972        11732 :       CALL section_add_subsection(section, subsection)
    1973        11732 :       CALL section_release(subsection)
    1974              : 
    1975        11732 :       CALL create_vdw_potential_section(subsection)
    1976        11732 :       CALL section_add_subsection(section, subsection)
    1977        11732 :       CALL section_release(subsection)
    1978              : 
    1979        11732 :       CALL create_gcp_potential_section(subsection)
    1980        11732 :       CALL section_add_subsection(section, subsection)
    1981        11732 :       CALL section_release(subsection)
    1982              : 
    1983        11732 :    END SUBROUTINE create_xc_section
    1984              : 
    1985              : ! **************************************************************************************************
    1986              : !> \brief creates the section for adiabatic hybrid functionals
    1987              : !> \param section ...
    1988              : !> \author Manuel Guidon
    1989              : ! **************************************************************************************************
    1990        11732 :    SUBROUTINE create_adiabatic_section(section)
    1991              :       TYPE(section_type), POINTER                        :: section
    1992              : 
    1993              :       TYPE(keyword_type), POINTER                        :: keyword
    1994              : 
    1995        11732 :       CPASSERT(.NOT. ASSOCIATED(section))
    1996              :       CALL section_create(section, __LOCATION__, name="ADIABATIC_RESCALING", &
    1997              :                           description="Parameters for self interaction corrected hybrid functionals", &
    1998        11732 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
    1999        11732 :       NULLIFY (keyword)
    2000              :       CALL keyword_create( &
    2001              :          keyword, __LOCATION__, &
    2002              :          name="FUNCTIONAL_TYPE", &
    2003              :          description="Which Hybrid functional should be used. "// &
    2004              :          "(Has to be consistent with the definitions in XC and HF).", &
    2005              :          usage="FUNCTIONAL_TYPE MCY3", &
    2006              :          enum_c_vals=s2a("MCY3"), &
    2007              :          enum_i_vals=[do_adiabatic_hybrid_mcy3], &
    2008              :          enum_desc=s2a("Use MCY3 hybrid functional"), &
    2009        11732 :          default_i_val=do_adiabatic_hybrid_mcy3)
    2010        11732 :       CALL section_add_keyword(section, keyword)
    2011        11732 :       CALL keyword_release(keyword)
    2012              : 
    2013        11732 :       NULLIFY (keyword)
    2014              :       CALL keyword_create( &
    2015              :          keyword, __LOCATION__, &
    2016              :          name="LAMBDA", &
    2017              :          description="The point to be used along the adiabatic curve (0 &lt; &lambda; &lt; 1)", &
    2018              :          usage="LAMBDA 0.71", &
    2019        11732 :          default_r_val=0.71_dp)
    2020        11732 :       CALL section_add_keyword(section, keyword)
    2021        11732 :       CALL keyword_release(keyword)
    2022              : 
    2023        11732 :       NULLIFY (keyword)
    2024              :       CALL keyword_create( &
    2025              :          keyword, __LOCATION__, &
    2026              :          name="OMEGA", &
    2027              :          description="Long-range parameter", &
    2028              :          usage="OMEGA 0.2", &
    2029        11732 :          default_r_val=0.2_dp)
    2030        11732 :       CALL section_add_keyword(section, keyword)
    2031        11732 :       CALL keyword_release(keyword)
    2032              : 
    2033        11732 :       NULLIFY (keyword)
    2034              :       CALL keyword_create( &
    2035              :          keyword, __LOCATION__, &
    2036              :          name="FUNCTIONAL_MODEL", &
    2037              :          description="Which model for the coupling constant integration should be used. ", &
    2038              :          usage="FUNCTIONAL_MODEL PADE", &
    2039              :          enum_c_vals=s2a("PADE"), &
    2040              :          enum_i_vals=[do_adiabatic_model_pade], &
    2041              :          enum_desc=s2a("Use pade model: W(lambda)=a+(b*lambda)/(1+c*lambda)"), &
    2042        11732 :          default_i_val=do_adiabatic_model_pade)
    2043        11732 :       CALL section_add_keyword(section, keyword)
    2044        11732 :       CALL keyword_release(keyword)
    2045        11732 :    END SUBROUTINE create_adiabatic_section
    2046              : 
    2047              : END MODULE input_cp2k_xc
        

Generated by: LCOV version 2.0-1