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

Generated by: LCOV version 2.0-1