LCOV - code coverage report
Current view: top level - src - input_cp2k_mp2.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:42dac4a) Lines: 100.0 % 781 781
Test Date: 2025-07-25 12:55:17 Functions: 100.0 % 25 25

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2025 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief input section for MP2
      10              : !> \par History
      11              : !>      05.2011 created
      12              : !> \author MDB
      13              : ! **************************************************************************************************
      14              : MODULE input_cp2k_mp2
      15              :    USE bibliography, ONLY: &
      16              :       Bates2013, DelBen2012, DelBen2013, DelBen2015, DelBen2015b, Rybkin2016, Wilhelm2016a, &
      17              :       Wilhelm2016b, Wilhelm2017, Wilhelm2018, Stein2022, Stein2024, Bussy2023
      18              :    USE cp_eri_mme_interface, ONLY: create_eri_mme_section
      19              :    USE cp_output_handling, ONLY: add_last_numeric, &
      20              :                                  cp_print_key_section_create, &
      21              :                                  debug_print_level, &
      22              :                                  high_print_level, &
      23              :                                  low_print_level, &
      24              :                                  medium_print_level, &
      25              :                                  silent_print_level
      26              :    USE cp_units, ONLY: cp_unit_to_cp2k
      27              :    USE input_constants, ONLY: &
      28              :       bse_fulldiag, bse_iterdiag, bse_tda, bse_abba, bse_both, &
      29              :       bse_screening_w0, bse_screening_tdhf, bse_screening_rpa, bse_screening_alpha, &
      30              :       bse_iter_both_cond, bse_iter_en_cond, bse_iter_res_cond, bse_singlet, &
      31              :       bse_triplet, do_eri_gpw, do_eri_mme, do_eri_os, do_potential_coulomb, do_potential_id, &
      32              :       do_potential_long, do_potential_mix_cl, do_potential_short, do_potential_truncated, &
      33              :       do_potential_tshpsc, eri_default, gaussian, gw_no_print_exx, gw_pade_approx, gw_print_exx, &
      34              :       gw_read_exx, gw_skip_for_regtest, gw_two_pole_model, kp_weights_W_auto, &
      35              :       kp_weights_W_tailored, kp_weights_W_uniform, mp2_method_direct, mp2_method_gpw, &
      36              :       mp2_method_none, numerical, ot_precond_full_all, ot_precond_full_kinetic, &
      37              :       ot_precond_full_single, ot_precond_full_single_inverse, ot_precond_none, &
      38              :       ot_precond_s_inverse, ri_default, ri_rpa_g0w0_crossing_bisection, &
      39              :       ri_rpa_g0w0_crossing_newton, ri_rpa_g0w0_crossing_z_shot, soc_lda, soc_none, soc_pbe, &
      40              :       wfc_mm_style_gemm, wfc_mm_style_syrk, z_solver_cg, z_solver_pople, z_solver_richardson, &
      41              :       z_solver_sd, rpa_exchange_none, rpa_exchange_axk, rpa_exchange_sosex, G0W0, evGW0, evGW, &
      42              :       sigma_none, sigma_PBE0_S1, sigma_PBE0_S2, sigma_PBE_S1, sigma_PBE_S2
      43              :    USE input_cp2k_hfx, ONLY: create_hfx_section
      44              :    USE input_cp2k_kpoints, ONLY: create_kpoint_set_section
      45              :    USE input_keyword_types, ONLY: keyword_create, &
      46              :                                   keyword_release, &
      47              :                                   keyword_type
      48              :    USE input_section_types, ONLY: section_add_keyword, &
      49              :                                   section_add_subsection, &
      50              :                                   section_create, &
      51              :                                   section_release, &
      52              :                                   section_type
      53              : 
      54              :    USE input_val_types, ONLY: char_t, &
      55              :                               integer_t, &
      56              :                               logical_t, &
      57              :                               real_t
      58              :    USE kinds, ONLY: dp
      59              :    USE string_utilities, ONLY: newline, &
      60              :                                s2a
      61              : #include "./base/base_uses.f90"
      62              : 
      63              :    IMPLICIT NONE
      64              :    PRIVATE
      65              : 
      66              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_mp2'
      67              : 
      68              :    PUBLIC :: create_mp2_section
      69              : 
      70              : CONTAINS
      71              : 
      72              : ! **************************************************************************************************
      73              : !> \brief creates the input section for the mp2 part
      74              : !> \param section the section to create
      75              : !> \author MDB
      76              : ! **************************************************************************************************
      77        64714 :    SUBROUTINE create_mp2_section(section)
      78              :       TYPE(section_type), POINTER                        :: section
      79              : 
      80              :       TYPE(keyword_type), POINTER                        :: keyword
      81              :       TYPE(section_type), POINTER                        :: print_key, subsection
      82              : 
      83        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
      84              :       CALL section_create(section, __LOCATION__, name="WF_CORRELATION", &
      85              :                           description="Sets up the wavefunction-based correlation methods as MP2, "// &
      86              :                           "RI-MP2, RI-SOS-MP2, RI-RPA and GW (inside RI-RPA). ", &
      87              :                           n_keywords=4, n_subsections=7, repeats=.TRUE., &
      88              :                           citations=(/DelBen2012, DelBen2013, DelBen2015, DelBen2015b, Rybkin2016, &
      89              :                                       Wilhelm2016a, Wilhelm2016b, Wilhelm2017, Wilhelm2018, Stein2022, &
      90       841282 :                                       Stein2024, Bussy2023/))
      91              : 
      92        64714 :       NULLIFY (keyword, subsection)
      93              : 
      94              :       CALL keyword_create( &
      95              :          keyword, __LOCATION__, &
      96              :          name="MEMORY", &
      97              :          description="Maximum allowed total memory usage during MP2 methods [MiB].", &
      98              :          usage="MEMORY 1500 ", &
      99        64714 :          default_r_val=1.024E+3_dp)
     100        64714 :       CALL section_add_keyword(section, keyword)
     101        64714 :       CALL keyword_release(keyword)
     102              : 
     103              :       CALL keyword_create( &
     104              :          keyword, __LOCATION__, &
     105              :          name="E_GAP", &
     106              :          description="Gap energy for integration grids in Hartree. Defaults to -1.0 (automatic determination). "// &
     107              :          "Recommended to set if several RPA or SOS-MP2 gradient calculations are requested or to be restarted. "// &
     108              :          "In this way, differences of integration grids across different runs are removed as CP2K "// &
     109              :          "does not include derivatives thereof.", &
     110              :          usage="E_GAP  0.5", &
     111        64714 :          default_r_val=-1.0_dp)
     112        64714 :       CALL section_add_keyword(section, keyword)
     113        64714 :       CALL keyword_release(keyword)
     114              : 
     115              :       CALL keyword_create( &
     116              :          keyword, __LOCATION__, &
     117              :          name="E_RANGE", &
     118              :          description="Energy range (ratio of largest and smallest) energy difference "// &
     119              :          "of unoccupied and occupied orbitals for integration grids. Defaults to 0.0 (automatic determination). "// &
     120              :          "Recommended to set if several RPA or SOS-MP2 gradient calculations are requested or to be restarted. "// &
     121              :          "In this way, differences of integration grids across different runs are removed as CP2K "// &
     122              :          "does not include derivatives thereof.", &
     123              :          usage="E_RANGE  10.0", &
     124        64714 :          default_r_val=-1.0_dp)
     125        64714 :       CALL section_add_keyword(section, keyword)
     126        64714 :       CALL keyword_release(keyword)
     127              : 
     128              :       CALL keyword_create( &
     129              :          keyword, __LOCATION__, &
     130              :          name="SCALE_S", &
     131              :          description="Scaling factor of the singlet energy component (opposite spin, OS) of the "// &
     132              :          "MP2, RI-MP2 and SOS-MP2 correlation energy. ", &
     133              :          usage="SCALE_S  1.0", &
     134        64714 :          default_r_val=1.0_dp)
     135        64714 :       CALL section_add_keyword(section, keyword)
     136        64714 :       CALL keyword_release(keyword)
     137              : 
     138              :       CALL keyword_create( &
     139              :          keyword, __LOCATION__, &
     140              :          name="SCALE_T", &
     141              :          description="Scaling factor of the triplet energy component (same spin, SS) of the MP2 "// &
     142              :          "and RI-MP2 correlation energy.", &
     143              :          usage="SCALE_T  1.0", &
     144        64714 :          default_r_val=1.0_dp)
     145        64714 :       CALL section_add_keyword(section, keyword)
     146        64714 :       CALL keyword_release(keyword)
     147              : 
     148              :       CALL keyword_create( &
     149              :          keyword, __LOCATION__, &
     150              :          name="GROUP_SIZE", &
     151              :          variants=(/"NUMBER_PROC"/), &
     152              :          description="Group size used in the computation of GPW and MME integrals and the MP2 correlation energy. "// &
     153              :          "The group size must be a divisor of the total number of MPI ranks. "// &
     154              :          "A smaller group size (for example the number of MPI ranks per node) "// &
     155              :          "accelerates the computation of integrals but a too large group size increases communication costs. "// &
     156              :          "A too small group size may lead to out of memory.", &
     157              :          usage="GROUP_SIZE 2", &
     158       129428 :          default_i_val=1)
     159        64714 :       CALL section_add_keyword(section, keyword)
     160        64714 :       CALL keyword_release(keyword)
     161              : 
     162        64714 :       NULLIFY (subsection)
     163        64714 :       CALL create_mp2_details_section(subsection)
     164        64714 :       CALL section_add_subsection(section, subsection)
     165        64714 :       CALL section_release(subsection)
     166              : 
     167        64714 :       CALL create_ri_mp2(subsection)
     168        64714 :       CALL section_add_subsection(section, subsection)
     169        64714 :       CALL section_release(subsection)
     170              : 
     171        64714 :       CALL create_ri_rpa(subsection)
     172        64714 :       CALL section_add_subsection(section, subsection)
     173        64714 :       CALL section_release(subsection)
     174              : 
     175        64714 :       CALL create_ri_laplace(subsection)
     176        64714 :       CALL section_add_subsection(section, subsection)
     177        64714 :       CALL section_release(subsection)
     178              : 
     179              :       ! here we generate an imag. time subsection to use with RPA or Laplace-SOS-MP2
     180        64714 :       CALL create_low_scaling(subsection)
     181        64714 :       CALL section_add_subsection(section, subsection)
     182        64714 :       CALL section_release(subsection)
     183              : 
     184        64714 :       CALL create_ri_section(subsection)
     185        64714 :       CALL section_add_subsection(section, subsection)
     186        64714 :       CALL section_release(subsection)
     187              : 
     188        64714 :       CALL create_integrals_section(subsection)
     189        64714 :       CALL section_add_subsection(section, subsection)
     190        64714 :       CALL section_release(subsection)
     191              : 
     192        64714 :       CALL create_canonical_gradients(subsection)
     193        64714 :       CALL section_add_subsection(section, subsection)
     194        64714 :       CALL section_release(subsection)
     195              : 
     196        64714 :       NULLIFY (print_key)
     197              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PRINT", &
     198              :                                        description="Controls the printing basic info about WFC methods", &
     199        64714 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     200        64714 :       CALL section_add_subsection(section, print_key)
     201        64714 :       CALL section_release(print_key)
     202              : 
     203        64714 :    END SUBROUTINE create_mp2_section
     204              : 
     205              : ! **************************************************************************************************
     206              : !> \brief ...
     207              : !> \param section ...
     208              : ! **************************************************************************************************
     209        64714 :    SUBROUTINE create_mp2_details_section(section)
     210              :       TYPE(section_type), POINTER                        :: section
     211              : 
     212              :       TYPE(keyword_type), POINTER                        :: keyword
     213              : 
     214        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     215              :       CALL section_create(section, __LOCATION__, name="MP2", &
     216              :                           description="Parameters influencing MP2 (non-RI).", &
     217        64714 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
     218              : 
     219        64714 :       NULLIFY (keyword)
     220              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     221              :                           description="Activates MP2 calculations.", &
     222              :                           usage="&MP2 .TRUE.", &
     223        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     224        64714 :       CALL section_add_keyword(section, keyword)
     225        64714 :       CALL keyword_release(keyword)
     226              : 
     227              :       CALL keyword_create( &
     228              :          keyword, __LOCATION__, &
     229              :          name="METHOD", &
     230              :          citations=(/DelBen2012, DelBen2013/), &
     231              :          description="Method that is used to compute the MP2 energy.", &
     232              :          usage="METHOD MP2_GPW", &
     233              :          enum_c_vals=s2a("NONE", "DIRECT_CANONICAL", "MP2_GPW"), &
     234              :          enum_i_vals=(/mp2_method_none, mp2_method_direct, mp2_method_gpw/), &
     235              :          enum_desc=s2a("Skip MP2 calculation.", &
     236              :                        "Use the direct mp2 canonical approach.", &
     237              :                        "Use the GPW approach to MP2."), &
     238       194142 :          default_i_val=mp2_method_direct)
     239        64714 :       CALL section_add_keyword(section, keyword)
     240        64714 :       CALL keyword_release(keyword)
     241              : 
     242              :       CALL keyword_create( &
     243              :          keyword, __LOCATION__, &
     244              :          name="BIG_SEND", &
     245              :          description="Influencing the direct canonical MP2 method: Send big "// &
     246              :          "messages between processes (useful for >48 processors).", &
     247              :          usage="BIG_SEND", &
     248              :          default_l_val=.TRUE., &
     249        64714 :          lone_keyword_l_val=.TRUE.)
     250        64714 :       CALL section_add_keyword(section, keyword)
     251        64714 :       CALL keyword_release(keyword)
     252              : 
     253        64714 :    END SUBROUTINE create_mp2_details_section
     254              : 
     255              : ! **************************************************************************************************
     256              : !> \brief ...
     257              : !> \param section ...
     258              : ! **************************************************************************************************
     259        64714 :    SUBROUTINE create_ri_mp2(section)
     260              :       TYPE(section_type), POINTER                        :: section
     261              : 
     262              :       TYPE(keyword_type), POINTER                        :: keyword
     263              : 
     264        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     265              :       CALL section_create(section, __LOCATION__, name="RI_MP2", &
     266              :                           description="Parameters influencing the RI-MP2 method. RI-MP2 supports gradients.", &
     267              :                           n_keywords=3, n_subsections=1, repeats=.FALSE., &
     268       129428 :                           citations=(/DelBen2013/))
     269              : 
     270        64714 :       NULLIFY (keyword)
     271              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     272              :                           description="Putting the &RI_MP2 section activates RI-MP2 calculation.", &
     273              :                           usage="&RI_MP2 .TRUE.", &
     274        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     275        64714 :       CALL section_add_keyword(section, keyword)
     276        64714 :       CALL keyword_release(keyword)
     277              : 
     278              :       CALL keyword_create(keyword, __LOCATION__, name="BLOCK_SIZE", &
     279              :                           variants=(/"MESSAGE_SIZE"/), &
     280              :                           description="Determines the blocking used for communication in RI-MP2. Larger BLOCK_SIZE "// &
     281              :                           "reduces communication but requires more memory. The default (-1) is automatic.", &
     282              :                           usage="BLOCK_SIZE 2", &
     283       129428 :                           default_i_val=-1)
     284        64714 :       CALL section_add_keyword(section, keyword)
     285        64714 :       CALL keyword_release(keyword)
     286              : 
     287              :       CALL keyword_create(keyword, __LOCATION__, name="NUMBER_INTEGRATION_GROUPS", &
     288              :                           description="Sets the number of integration groups of the communication scheme in RI-MP2. "// &
     289              :                           "Integrals will be replicated such that each integration group has all integrals available. "// &
     290              :                           "Must be a divisor of the number of subgroups (see GROUP_SIZE keyword in the WF_CORRELATION "// &
     291              :                           "section. Smaller groups reduce the communication costs but increase the memory developments. "// &
     292              :                           "If the provided value is non-positive or not a divisor of the number of subgroups, "// &
     293              :                           "the number of integration groups is determined automatically (default).", &
     294              :                           usage="NUMBER_INTEGRATION_GROUPS 2", &
     295        64714 :                           default_i_val=-1)
     296        64714 :       CALL section_add_keyword(section, keyword)
     297        64714 :       CALL keyword_release(keyword)
     298              : 
     299              :       CALL keyword_create( &
     300              :          keyword, __LOCATION__, &
     301              :          name="PRINT_DGEMM_INFO", &
     302              :          description="Print details about all DGEMM calls.", &
     303              :          lone_keyword_l_val=.TRUE., &
     304        64714 :          default_l_val=.FALSE.)
     305        64714 :       CALL section_add_keyword(section, keyword)
     306        64714 :       CALL keyword_release(keyword)
     307              : 
     308        64714 :    END SUBROUTINE create_ri_mp2
     309              : 
     310              : ! **************************************************************************************************
     311              : !> \brief ...
     312              : !> \param section ...
     313              : ! **************************************************************************************************
     314        64714 :    SUBROUTINE create_opt_ri_basis(section)
     315              :       TYPE(section_type), POINTER                        :: section
     316              : 
     317              :       TYPE(keyword_type), POINTER                        :: keyword
     318              : 
     319        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     320              :       CALL section_create(section, __LOCATION__, name="OPT_RI_BASIS", &
     321              :                           description="Parameters influencing the optimization of the RI MP2 basis. "// &
     322              :                           "Only exponents of non-contracted auxiliary basis can be optimized. "// &
     323              :                           "An initial RI auxiliary basis has to be specified.", &
     324              :                           n_keywords=6, n_subsections=0, repeats=.FALSE., &
     325       129428 :                           citations=(/DelBen2013/))
     326        64714 :       NULLIFY (keyword)
     327              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     328              :                           description="Putting the &OPT_RI_BASIS section activates optimization of RI basis.", &
     329              :                           usage="&OPT_RI_BASIS .TRUE.", &
     330        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     331        64714 :       CALL section_add_keyword(section, keyword)
     332        64714 :       CALL keyword_release(keyword)
     333              : 
     334              :       CALL keyword_create(keyword, __LOCATION__, name="DELTA_I_REL", &
     335              :                           variants=(/"DI_REL"/), &
     336              :                           description="Target accuracy in the relative deviation of the amplitudes calculated with "// &
     337              :                           "and without RI approximation, (more details in Chem.Phys.Lett.294(1998)143).", &
     338              :                           usage="DELTA_I_REL  1.0E-6_dp", &
     339       129428 :                           default_r_val=1.0E-6_dp)
     340        64714 :       CALL section_add_keyword(section, keyword)
     341        64714 :       CALL keyword_release(keyword)
     342              : 
     343              :       CALL keyword_create(keyword, __LOCATION__, name="DELTA_RI", &
     344              :                           variants=(/"DRI"/), &
     345              :                           description="Target accuracy in the absolute difference between the RI-MP2 "// &
     346              :                           "and the exact MP2 energy, DRI=ABS(E_MP2-E_RI-MP2).", &
     347              :                           usage="DELTA_RI  1.0E-6_dp", &
     348       129428 :                           default_r_val=5.0E-6_dp)
     349        64714 :       CALL section_add_keyword(section, keyword)
     350        64714 :       CALL keyword_release(keyword)
     351              : 
     352              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_DERIV", &
     353              :                           variants=(/"EPS_NUM_DERIV"/), &
     354              :                           description="The derivatives of the MP2 energy with respect to the "// &
     355              :                           "exponents of the basis are calculated numerically. "// &
     356              :                           "The change in the exponent a_i employed for the numerical evaluation "// &
     357              :                           "is defined as h_i=EPS_DERIV*a_i.", &
     358              :                           usage="EPS_DERIV  1.0E-3_dp", &
     359       129428 :                           default_r_val=1.0E-3_dp)
     360        64714 :       CALL section_add_keyword(section, keyword)
     361        64714 :       CALL keyword_release(keyword)
     362              : 
     363              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
     364              :                           variants=(/"MAX_NUM_ITER"/), &
     365              :                           description="Specifies the maximum number of steps in the RI basis optimization.", &
     366              :                           usage="MAX_ITER 100", &
     367       129428 :                           default_i_val=50)
     368        64714 :       CALL section_add_keyword(section, keyword)
     369        64714 :       CALL keyword_release(keyword)
     370              : 
     371              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_FUNC", &
     372              :                           description="Specifies the number of function, for each angular momentum (s, p, d ...), "// &
     373              :                           "employed in the automatically generated initial guess. "// &
     374              :                           "This will be effective only if RI_AUX_BASIS_SET in the KIND section is not specified.", &
     375              :                           usage="NUM_FUNC {number of s func.} {number of p func.} ...", &
     376        64714 :                           n_var=-1, default_i_vals=(/-1/), type_of_var=integer_t)
     377        64714 :       CALL section_add_keyword(section, keyword)
     378        64714 :       CALL keyword_release(keyword)
     379              : 
     380              :       CALL keyword_create(keyword, __LOCATION__, name="BASIS_SIZE", &
     381              :                           description="Specifies the size of the auxiliary basis set automatically "// &
     382              :                           "generated as initial guess. This will be effective only if RI_AUX_BASIS_SET "// &
     383              :                           "in the KIND section and NUM_FUNC are not specified.", &
     384              :                           usage="BASIS_SIZE  (MEDIUM|LARGE|VERY_LARGE)", &
     385              :                           enum_c_vals=s2a("MEDIUM", "LARGE", "VERY_LARGE"), &
     386              :                           enum_i_vals=(/0, 1, 2/), &
     387        64714 :                           default_i_val=0)
     388        64714 :       CALL section_add_keyword(section, keyword)
     389        64714 :       CALL keyword_release(keyword)
     390              : 
     391        64714 :    END SUBROUTINE create_opt_ri_basis
     392              : 
     393              : ! **************************************************************************************************
     394              : !> \brief ...
     395              : !> \param section ...
     396              : ! **************************************************************************************************
     397        64714 :    SUBROUTINE create_ri_laplace(section)
     398              :       TYPE(section_type), POINTER                        :: section
     399              : 
     400              :       TYPE(keyword_type), POINTER                        :: keyword
     401              : 
     402        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     403              :       CALL section_create(section, __LOCATION__, name="RI_SOS_MP2", &
     404              :                           description="Parameters influencing the RI-SOS-MP2-Laplace method", &
     405              :                           n_keywords=3, n_subsections=1, repeats=.FALSE., &
     406       129428 :                           citations=(/DelBen2013/))
     407              : 
     408        64714 :       NULLIFY (keyword)
     409              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     410              :                           description="Putting the &RI_SOS_MP2 section activates RI-SOS-MP2 calculation.", &
     411              :                           usage="&RI_SOS_MP2 .TRUE.", &
     412        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     413        64714 :       CALL section_add_keyword(section, keyword)
     414        64714 :       CALL keyword_release(keyword)
     415              : 
     416              :       CALL keyword_create( &
     417              :          keyword, __LOCATION__, name="QUADRATURE_POINTS", &
     418              :          variants=(/"LAPLACE_NUM_QUAD_POINTS"/), &
     419              :          description="Number of quadrature points for the numerical integration in the RI-SOS-MP2-Laplace method.", &
     420              :          usage="QUADRATURE_POINTS 6", &
     421       129428 :          default_i_val=5)
     422        64714 :       CALL section_add_keyword(section, keyword)
     423        64714 :       CALL keyword_release(keyword)
     424              : 
     425              :       CALL keyword_create( &
     426              :          keyword, __LOCATION__, name="NUM_INTEG_GROUPS", &
     427              :          description="Number of groups for the integration in the Laplace method. Each groups processes "// &
     428              :          "the same amount of quadrature points. It must be a divisor of the number of quadrature points and "// &
     429              :          "NUM_INTEG_GROUPS*GROUP_SIZE must be a divisor of the total number of processes. The default (-1) is automatic.", &
     430              :          usage="NUM_INTEG_GROUPS 2", &
     431        64714 :          default_i_val=-1)
     432        64714 :       CALL section_add_keyword(section, keyword)
     433        64714 :       CALL keyword_release(keyword)
     434              : 
     435        64714 :    END SUBROUTINE create_ri_laplace
     436              : 
     437              : ! **************************************************************************************************
     438              : !> \brief ...
     439              : !> \param section ...
     440              : ! **************************************************************************************************
     441        64714 :    SUBROUTINE create_canonical_gradients(section)
     442              :       TYPE(section_type), POINTER                        :: section
     443              : 
     444              :       TYPE(keyword_type), POINTER                        :: keyword
     445              :       TYPE(section_type), POINTER                        :: subsection
     446              : 
     447        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     448              :       CALL section_create(section, __LOCATION__, name="CANONICAL_GRADIENTS", &
     449              :                           description="Parameters influencing gradient calculations of canonical RI methods. "// &
     450              :                           "Ignored if the IM_TIME section is set.", &
     451              :                           n_keywords=3, n_subsections=1, repeats=.FALSE., &
     452       323570 :                           citations=(/DelBen2015b, Rybkin2016, Stein2022, Stein2024/))
     453              : 
     454        64714 :       NULLIFY (subsection, keyword)
     455        64714 :       CALL create_cphf(subsection)
     456        64714 :       CALL section_add_subsection(section, subsection)
     457        64714 :       CALL section_release(subsection)
     458              : 
     459              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_CANONICAL", &
     460              :                           description="Threshold under which a given ij or ab pair is considered to be degenerate and "// &
     461              :                           "its contribution to the density matrix is calculated directly. "// &
     462              :                           "Ignored in case of energy-only calculation.", &
     463              :                           usage="EPS_CANONICAL 1.0E-8", type_of_var=real_t, &
     464        64714 :                           default_r_val=1.0E-7_dp)
     465        64714 :       CALL section_add_keyword(section, keyword)
     466        64714 :       CALL keyword_release(keyword)
     467              : 
     468              :       CALL keyword_create( &
     469              :          keyword, __LOCATION__, &
     470              :          name="FREE_HFX_BUFFER", &
     471              :          description="Free the buffer containing the 4 center integrals used in the Hartree-Fock exchange calculation. "// &
     472              :          "Ignored for energy-only calculations. May fail.", &
     473              :          usage="FREE_HFX_BUFFER", &
     474              :          default_l_val=.FALSE., &
     475        64714 :          lone_keyword_l_val=.TRUE.)
     476        64714 :       CALL section_add_keyword(section, keyword)
     477        64714 :       CALL keyword_release(keyword)
     478              : 
     479              :       CALL keyword_create( &
     480              :          keyword, __LOCATION__, &
     481              :          name="DOT_PRODUCT_BLKSIZE", &
     482              :          description="Dot products for the calculation of the RPA/SOS-MP2 density matrices "// &
     483              :          "are calculated in batches of the size given by this keyword. Larger block sizes "// &
     484              :          "improve the performance but reduce the numerical accuracy. Recommended block sizes are multiples of the number of "// &
     485              :          "doubles per cache line (usually 8). Ignored with MP2 gradients. Set it to -1 to prevent blocking.", &
     486        64714 :          default_i_val=-1)
     487        64714 :       CALL section_add_keyword(section, keyword)
     488        64714 :       CALL keyword_release(keyword)
     489              : 
     490              :       CALL keyword_create( &
     491              :          keyword, __LOCATION__, &
     492              :          name="MAX_PARALLEL_COMM", &
     493              :          description="Sets the maximum number of parallel communication steps of the non-blocking communication scheme. "// &
     494              :          "The number of channels is determined from the available memory. If set to a value smaller than one, "// &
     495              :          "CP2K will use all memory for communication. A value of one enforces the blocking communication scheme "// &
     496              :          "increasing the communication costs.", &
     497        64714 :          default_i_val=2)
     498        64714 :       CALL section_add_keyword(section, keyword)
     499        64714 :       CALL keyword_release(keyword)
     500              : 
     501        64714 :    END SUBROUTINE create_canonical_gradients
     502              : 
     503              : ! **************************************************************************************************
     504              : !> \brief ...
     505              : !> \param section ...
     506              : ! **************************************************************************************************
     507        64714 :    SUBROUTINE create_ri_rpa(section)
     508              :       TYPE(section_type), POINTER                        :: section
     509              : 
     510              :       TYPE(keyword_type), POINTER                        :: keyword
     511              :       TYPE(section_type), POINTER                        :: subsection
     512              : 
     513        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     514              :       CALL section_create(section, __LOCATION__, name="RI_RPA", &
     515              :                           description="Parameters influencing RI-RPA and GW.", &
     516              :                           n_keywords=8, n_subsections=4, repeats=.FALSE., &
     517       194142 :                           citations=(/DelBen2013, DelBen2015/))
     518              : 
     519        64714 :       NULLIFY (keyword, subsection)
     520              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     521              :                           description="Putting the &RI_RPA section activates RI-RPA calculation.", &
     522              :                           usage="&RI_RPA .TRUE.", &
     523        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     524        64714 :       CALL section_add_keyword(section, keyword)
     525        64714 :       CALL keyword_release(keyword)
     526              : 
     527              :       CALL keyword_create( &
     528              :          keyword, __LOCATION__, &
     529              :          name="SIGMA_FUNCTIONAL", &
     530              :          description="Determine parametrization for sigma-functional", &
     531              :          usage="SIGMA_FUNCTIONAL PBE_S2", &
     532              :          enum_c_vals=s2a("NONE", "PBE0_S1", "PBE0_S2", "PBE_S1", "PBE_S2"), &
     533              :          enum_i_vals=(/sigma_none, sigma_PBE0_S1, sigma_PBE0_S2, sigma_PBE_S1, sigma_PBE_S2/), &
     534              :          enum_desc=s2a("No sigma functional calculation", &
     535              :                        "use parameters based on PBE0 with S1 set.", &
     536              :                        "use parameters based on PBE0 with S2 set.", &
     537              :                        "use parameters based on PBE with S1 set.", &
     538              :                        "use parameters based on PBE with S2 set." &
     539              :                        ), &
     540        64714 :          default_i_val=sigma_none)
     541        64714 :       CALL section_add_keyword(section, keyword)
     542        64714 :       CALL keyword_release(keyword)
     543              : 
     544              :       CALL keyword_create(keyword, __LOCATION__, name="QUADRATURE_POINTS", &
     545              :                           variants=(/"RPA_NUM_QUAD_POINTS"/), &
     546              :                           description="Number of quadrature points for the numerical integration in the RI-RPA method.", &
     547              :                           usage="QUADRATURE_POINTS 60", &
     548       129428 :                           default_i_val=40)
     549        64714 :       CALL section_add_keyword(section, keyword)
     550        64714 :       CALL keyword_release(keyword)
     551              : 
     552              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_INTEG_GROUPS", &
     553              :                           description="Number of groups for the integration in the Laplace method. Each groups processes "// &
     554              :                           "the same amount of quadrature points. It must be a divisor of the number of quadrature points and "// &
     555              :                           "NUM_INTEG_GROUPS*GROUP_SIZE must be a divisor of the total number of processes. "// &
     556              :                           "The default (-1) is automatic.", &
     557              :                           usage="NUM_INTEG_GROUPS 2", &
     558        64714 :                           default_i_val=-1)
     559        64714 :       CALL section_add_keyword(section, keyword)
     560        64714 :       CALL keyword_release(keyword)
     561              : 
     562              :       CALL keyword_create(keyword, __LOCATION__, &
     563              :                           name="MM_STYLE", &
     564              :                           description="Matrix multiplication style for the Q matrix.", &
     565              :                           usage="MM_STYLE GEMM", &
     566              :                           enum_c_vals=s2a("GEMM", "SYRK"), &
     567              :                           enum_i_vals=(/wfc_mm_style_gemm, wfc_mm_style_syrk/), &
     568              :                           enum_desc=s2a("Use pdgemm: more flops, maybe faster.", &
     569              :                                         "Use pdysrk: fewer flops, maybe slower."), &
     570        64714 :                           default_i_val=wfc_mm_style_gemm)
     571        64714 :       CALL section_add_keyword(section, keyword)
     572        64714 :       CALL keyword_release(keyword)
     573              : 
     574              :       CALL keyword_create( &
     575              :          keyword, __LOCATION__, &
     576              :          name="MINIMAX_QUADRATURE", &
     577              :          variants=(/"MINIMAX"/), &
     578              :          description="Use the Minimax quadrature scheme for performing the numerical integration. "// &
     579              :          "Maximum number of quadrature point limited to 20.", &
     580              :          usage="MINIMAX_QUADRATURE", &
     581              :          default_l_val=.FALSE., &
     582       129428 :          lone_keyword_l_val=.TRUE.)
     583        64714 :       CALL section_add_keyword(section, keyword)
     584        64714 :       CALL keyword_release(keyword)
     585              : 
     586              :       CALL keyword_create( &
     587              :          keyword, __LOCATION__, &
     588              :          name="RSE", &
     589              :          variants=(/"SE"/), &
     590              :          description="Decide whether to add singles correction.", &
     591              :          usage="RSE", &
     592              :          default_l_val=.FALSE., &
     593       129428 :          lone_keyword_l_val=.TRUE.)
     594        64714 :       CALL section_add_keyword(section, keyword)
     595        64714 :       CALL keyword_release(keyword)
     596              : 
     597              :       CALL keyword_create( &
     598              :          keyword, __LOCATION__, &
     599              :          name="ADMM", &
     600              :          description="Decide whether to perform ADMM in the exact exchange calc. for RPA and/or GW. "// &
     601              :          "The ADMM XC correction is governed by the AUXILIARY_DENSITY_MATRIX_METHOD section in &DFT. "// &
     602              :          "In most cases, the Hartree-Fock exchange is not too expensive and there is no need for ADMM, "// &
     603              :          "ADMM can however provide significant speedup and memory savings in case of diffuse basis sets. "// &
     604              :          "If it is a GW bandgap calculations, RI_SIGMA_X can also be used. ", &
     605              :          usage="ADMM", &
     606              :          default_l_val=.FALSE., &
     607        64714 :          lone_keyword_l_val=.TRUE.)
     608        64714 :       CALL section_add_keyword(section, keyword)
     609        64714 :       CALL keyword_release(keyword)
     610              : 
     611              :       CALL keyword_create( &
     612              :          keyword, __LOCATION__, &
     613              :          name="SCALE_RPA", &
     614              :          description="Scales RPA energy contributions (RPA, exchange correction).", &
     615              :          usage="SCALE_RPA 1.0", &
     616        64714 :          default_r_val=1.0_dp)
     617        64714 :       CALL section_add_keyword(section, keyword)
     618        64714 :       CALL keyword_release(keyword)
     619              : 
     620              :       CALL keyword_create( &
     621              :          keyword, __LOCATION__, &
     622              :          name="PRINT_DGEMM_INFO", &
     623              :          description="Print details about all DGEMM calls.", &
     624              :          lone_keyword_l_val=.TRUE., &
     625        64714 :          default_l_val=.FALSE.)
     626        64714 :       CALL section_add_keyword(section, keyword)
     627        64714 :       CALL keyword_release(keyword)
     628              : 
     629              :       ! here we generate a hfx subsection to use in the case EXX has to be computed after RPA
     630        64714 :       CALL create_hfx_section(subsection)
     631        64714 :       CALL section_add_subsection(section, subsection)
     632        64714 :       CALL section_release(subsection)
     633              : 
     634              :       ! here we generate a G0W0 subsection to use if G0W0 is desired
     635        64714 :       CALL create_ri_g0w0(subsection)
     636        64714 :       CALL section_add_subsection(section, subsection)
     637        64714 :       CALL section_release(subsection)
     638              : 
     639              :       ! here we the RPA exchange section
     640        64714 :       CALL create_rpa_exchange(subsection)
     641        64714 :       CALL section_add_subsection(section, subsection)
     642        64714 :       CALL section_release(subsection)
     643              : 
     644        64714 :    END SUBROUTINE create_ri_rpa
     645              : 
     646              : ! **************************************************************************************************
     647              : !> \brief ...
     648              : !> \param section ...
     649              : ! **************************************************************************************************
     650        64714 :    SUBROUTINE create_rpa_exchange(section)
     651              :       TYPE(section_type), POINTER                        :: section
     652              : 
     653              :       TYPE(keyword_type), POINTER                        :: keyword
     654              : 
     655        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     656              :       CALL section_create(section, __LOCATION__, name="EXCHANGE_CORRECTION", &
     657              :                           description="Parameters influencing exchange corrections to RPA. No gradients available.", &
     658        64714 :                           n_keywords=3, n_subsections=1, repeats=.FALSE.)
     659              : 
     660        64714 :       NULLIFY (keyword)
     661              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     662              :                           description="Choose the kind of exchange correction.", &
     663              :                           usage="&EXCHANGE_CORRECTION AXK", &
     664              :                           enum_c_vals=s2a("NONE", "AXK", "SOSEX"), &
     665              :                           enum_i_vals=(/rpa_exchange_none, rpa_exchange_axk, rpa_exchange_sosex/), &
     666              :                           enum_desc=s2a("Apply no exchange correction.", &
     667              :                                         "Apply Approximate eXchange Kernel (AXK) correction.", &
     668              :                                         "Apply Second Order Screened eXchange (SOSEX) correction."), &
     669        64714 :                           default_i_val=rpa_exchange_none)
     670        64714 :       CALL section_add_keyword(section, keyword)
     671        64714 :       CALL keyword_release(keyword)
     672              : 
     673              :       CALL keyword_create( &
     674              :          keyword, __LOCATION__, &
     675              :          name="BLOCK_SIZE", &
     676              :          description="Choose the block size of the contraction step. Larger block sizes improve performance but "// &
     677              :          "require more memory (quadratically!, number of stored elements: $o^2\cdot N_B^2$). "// &
     678              :          "Nonpositive numbers turn off blocking.", &
     679              :          usage="BLOCK_SIZE 1", &
     680        64714 :          default_i_val=1)
     681        64714 :       CALL section_add_keyword(section, keyword)
     682        64714 :       CALL keyword_release(keyword)
     683              : 
     684              :       CALL keyword_create( &
     685              :          keyword, __LOCATION__, &
     686              :          name="USE_HFX_IMPLEMENTATION", &
     687              :          description="Use a HF-based implementation with RI_RPA%HF section. Recommended for large systems.", &
     688              :          usage="USE_HFX_IMPLEMENTATION T", &
     689        64714 :          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     690        64714 :       CALL section_add_keyword(section, keyword)
     691        64714 :       CALL keyword_release(keyword)
     692              : 
     693        64714 :    END SUBROUTINE create_rpa_exchange
     694              : 
     695              : ! **************************************************************************************************
     696              : !> \brief ...
     697              : !> \param section ...
     698              : ! **************************************************************************************************
     699        64714 :    SUBROUTINE create_ri_g0w0(section)
     700              :       TYPE(section_type), POINTER                        :: section
     701              : 
     702              :       TYPE(keyword_type), POINTER                        :: keyword
     703              :       TYPE(section_type), POINTER                        :: subsection
     704              : 
     705        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
     706              :       CALL section_create(section, __LOCATION__, name="GW", &
     707              :                           description="Parameters influencing GW calculations on molecules, "// &
     708              :                           "see also 'Electronic band structure from GW', "// &
     709              :                           "https://manual.cp2k.org/trunk/methods/properties/bandstructure_gw.html.", &
     710        64714 :                           n_keywords=24, n_subsections=1, repeats=.FALSE.)
     711              : 
     712        64714 :       NULLIFY (keyword, subsection)
     713              : 
     714              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     715              :                           description="Activates GW calculations.", &
     716              :                           usage="&GW .TRUE.", &
     717        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     718        64714 :       CALL section_add_keyword(section, keyword)
     719        64714 :       CALL keyword_release(keyword)
     720              : 
     721              :       CALL keyword_create(keyword, __LOCATION__, name="SELF_CONSISTENCY", &
     722              :                           description="Decide the level of self-consistency of eigenvalues "// &
     723              :                           "(= quasiparticle energies = single-electron energies) in GW. "// &
     724              :                           "Updates of Kohn-Sham orbitals (for example qsGW) are not implemented. "// &
     725              :                           "For details which type of eigenvalue self-consistency might be good, "// &
     726              :                           "please consult Golze, Dvorak, Rinke, Front. Chem. 2019.", &
     727              :                           usage="SELF_CONSISTENCY evGW0", &
     728              :                           enum_c_vals=s2a("G0W0", "evGW0", "evGW"), &
     729              :                           enum_i_vals=(/G0W0, evGW0, evGW/), &
     730              :                           enum_desc=s2a("Use DFT eigenvalues; not update.", &
     731              :                                         "Update DFT eigenvalues in G, not in W.", &
     732              :                                         "Update DFT eigenvalues in G and W."), &
     733        64714 :                           default_i_val=G0W0)
     734        64714 :       CALL section_add_keyword(section, keyword)
     735        64714 :       CALL keyword_release(keyword)
     736              : 
     737              :       CALL keyword_create(keyword, __LOCATION__, name="CORR_MOS_OCC", &
     738              :                           variants=(/"CORR_OCC"/), &
     739              :                           description="Number of occupied MOs whose energies are corrected in GW. "// &
     740              :                           "Counting beginning from HOMO, e.g. 3 corrected occ. MOs correspond "// &
     741              :                           "to correction of HOMO, HOMO-1 and HOMO-2. Numerical effort and "// &
     742              :                           "storage of RI-G0W0 increase linearly with this number. In case you "// &
     743              :                           "want to correct all occ. MOs, insert either a negative number or "// &
     744              :                           "a number larger than the number of occ. MOs. Invoking CORR_MOS_OCC -2 "// &
     745              :                           "together with a BSE cutoff, sets a sufficiently large CORR_MOS_OCC "// &
     746              :                           "for the given BSE cutoff deduced from DFT eigenvalues.", &
     747              :                           usage="CORR_OCC 3", &
     748       129428 :                           default_i_val=10)
     749        64714 :       CALL section_add_keyword(section, keyword)
     750        64714 :       CALL keyword_release(keyword)
     751              : 
     752              :       CALL keyword_create(keyword, __LOCATION__, name="CORR_MOS_VIRT", &
     753              :                           variants=(/"CORR_VIRT"/), &
     754              :                           description="Number of virtual MOs whose energies are corrected by GW. "// &
     755              :                           "Counting beginning from LUMO, e.g. 3 corrected occ. MOs correspond "// &
     756              :                           "to correction of LUMO, LUMO+1 and LUMO+2. Numerical effort and "// &
     757              :                           "storage of RI-G0W0 increase linearly with this number. In case you "// &
     758              :                           "want to correct all virt. MOs, insert either a negative number or "// &
     759              :                           "a number larger than the number of virt. MOs. Invoking CORR_MOS_VIRT -2 "// &
     760              :                           "together with a BSE cutoff, sets a sufficiently large CORR_MOS_VIRT "// &
     761              :                           "for the given BSE cutoff deduced from DFT eigenvalues.", &
     762              :                           usage="CORR_VIRT 3", &
     763       129428 :                           default_i_val=10)
     764        64714 :       CALL section_add_keyword(section, keyword)
     765        64714 :       CALL keyword_release(keyword)
     766              : 
     767              :       CALL keyword_create(keyword, __LOCATION__, name="NUMB_POLES", &
     768              :                           description="Number of poles for the fitting. Usually, two poles are sufficient. ", &
     769              :                           usage="NUMB_POLES 2", &
     770        64714 :                           default_i_val=2)
     771        64714 :       CALL section_add_keyword(section, keyword)
     772        64714 :       CALL keyword_release(keyword)
     773              : 
     774              :       CALL keyword_create(keyword, __LOCATION__, name="OMEGA_MAX_FIT", &
     775              :                           description="Determines fitting range for the self-energy on the imaginary axis: "// &
     776              :                           "[0, OMEGA_MAX_FIT] for virt orbitals, [-OMEGA_MAX_FIT,0] for occ orbitals. "// &
     777              :                           "Unit: Hartree. Default: 0.734996 H = 20 eV. ", &
     778              :                           usage="OMEGA_MAX_FIT 0.5", &
     779        64714 :                           default_r_val=0.734996_dp)
     780        64714 :       CALL section_add_keyword(section, keyword)
     781        64714 :       CALL keyword_release(keyword)
     782              : 
     783              :       CALL keyword_create(keyword, __LOCATION__, name="CROSSING_SEARCH", &
     784              :                           description="Determines, how the self_energy is evaluated on the real axis.", &
     785              :                           usage="CROSSING_SEARCH Z_SHOT", &
     786              :                           enum_c_vals=s2a("Z_SHOT", "NEWTON", "BISECTION"), &
     787              :                           enum_i_vals=(/ri_rpa_g0w0_crossing_z_shot, &
     788              :                                         ri_rpa_g0w0_crossing_newton, ri_rpa_g0w0_crossing_bisection/), &
     789              :                           enum_desc=s2a("Calculate the derivative of Sigma and out of it Z. Then extrapolate using Z.", &
     790              :                                         "Make a Newton-Raphson fix point iteration.", &
     791              :                                         "Make a bisection fix point iteration."), &
     792        64714 :                           default_i_val=ri_rpa_g0w0_crossing_newton)
     793        64714 :       CALL section_add_keyword(section, keyword)
     794        64714 :       CALL keyword_release(keyword)
     795              : 
     796              :       CALL keyword_create(keyword, __LOCATION__, name="FERMI_LEVEL_OFFSET", &
     797              :                           description="Fermi level for occ. orbitals: e_HOMO + FERMI_LEVEL_OFFSET; "// &
     798              :                           "Fermi level for virt. orbitals: e_LUMO - FERMI_LEVEL_OFFSET. "// &
     799              :                           "In case e_homo + FERMI_LEVEL_OFFSET < e_lumo - FERMI_LEVEL_OFFSET, "// &
     800              :                           "we set Fermi level = (e_HOMO+e_LUMO)/2. For cubic-scaling GW, the Fermi level "// &
     801              :                           "is always equal to (e_HOMO+e_LUMO)/2 regardless of FERMI_LEVEL_OFFSET.", &
     802              :                           usage="FERMI_LEVEL_OFFSET 1.0E-2", &
     803        64714 :                           default_r_val=2.0E-2_dp)
     804        64714 :       CALL section_add_keyword(section, keyword)
     805        64714 :       CALL keyword_release(keyword)
     806              : 
     807              :       CALL keyword_create(keyword, __LOCATION__, name="HEDIN_SHIFT", &
     808              :                           description="If true, use Hedin's shift in G0W0, evGW and evGW0 "// &
     809              :                           "(aka scGW0). Details see in Li et al. JCTC 18, 7570 "// &
     810              :                           "(2022), Figure 1. G0W0 with Hedin's shift should give "// &
     811              :                           "similar GW eigenvalues as evGW0; at a lower "// &
     812              :                           "computational cost.", &
     813              :                           usage="HEDIN_SHIFT", &
     814              :                           default_l_val=.FALSE., &
     815        64714 :                           lone_keyword_l_val=.TRUE.)
     816        64714 :       CALL section_add_keyword(section, keyword)
     817        64714 :       CALL keyword_release(keyword)
     818              : 
     819              :       CALL keyword_create(keyword, __LOCATION__, name="EV_GW_ITER", &
     820              :                           description="Maximum number of iterations for eigenvalue "// &
     821              :                           "self-consistency cycle. The computational effort of GW scales "// &
     822              :                           "linearly with this number. In case of choosing "// &
     823              :                           "GW_SELF_CONSISTENCY EVGW, the code sets EV_GW_ITER 10.", &
     824              :                           usage="EV_GW_ITER 3", &
     825        64714 :                           default_i_val=1)
     826        64714 :       CALL section_add_keyword(section, keyword)
     827        64714 :       CALL keyword_release(keyword)
     828              : 
     829              :       CALL keyword_create(keyword, __LOCATION__, name="SC_GW0_ITER", &
     830              :                           description="Maximum number of iterations for GW0 "// &
     831              :                           "self-consistency cycle. The computational effort "// &
     832              :                           "of GW is not much affected by the number of scGW0 cycles. "// &
     833              :                           "In case of choosing "// &
     834              :                           "GW_SELF_CONSISTENCY EVGW0, the code sets SC_GW0_ITER 10.", &
     835              :                           usage="SC_GW0_ITER 3", &
     836        64714 :                           default_i_val=1)
     837        64714 :       CALL section_add_keyword(section, keyword)
     838        64714 :       CALL keyword_release(keyword)
     839              : 
     840              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
     841              :                           description="Target accuracy for the eigenvalue self-consistency. "// &
     842              :                           "If the G0W0 HOMO-LUMO gap differs by less than the "// &
     843              :                           "target accuracy during the iteration, the eigenvalue "// &
     844              :                           "self-consistency cycle stops. Unit: Hartree.", &
     845              :                           usage="EPS_ITER 0.00005", &
     846              :                           default_r_val=cp_unit_to_cp2k(value=0.00136_dp, unit_str="eV"), &
     847        64714 :                           unit_str="eV")
     848              : 
     849        64714 :       CALL section_add_keyword(section, keyword)
     850        64714 :       CALL keyword_release(keyword)
     851              : 
     852              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_EXX", &
     853              :                           description="Print exchange self-energy minus exchange correlation potential for Gamma-only "// &
     854              :                           "calculation (PRINT). For a GW calculation with k-points we use this output as "// &
     855              :                           "exchange self-energy (READ). This is a temporary solution because the hybrid MPI/OMP "// &
     856              :                           "parallelization in the HFX by Manuel Guidon conflicts with the parallelization in "// &
     857              :                           "low-scaling GW k-points which is most efficient with maximum number of MPI tasks and "// &
     858              :                           "minimum number of OMP threads. For HFX by M. Guidon, the density matrix is "// &
     859              :                           "fully replicated on every MPI rank which necessitates a high number of OMP threads per MPI "// &
     860              :                           "rank for large systems to prevent out of memory. "// &
     861              :                           "Such a high number of OMP threads would slow down the GW calculation "// &
     862              :                           "severely. Therefore, it was decided to temporarily divide the GW k-point calculation in a "// &
     863              :                           "Gamma-only HF calculation with high number of OMP threads to prevent out of memory and "// &
     864              :                           "a GW k-point calculation with 1 OMP thread per MPI rank reading the previousHF output.", &
     865              :                           usage="PRINT_EXX TRUE", &
     866              :                           enum_c_vals=s2a("TRUE", "FALSE", "READ", "SKIP_FOR_REGTEST"), &
     867              :                           enum_i_vals=(/gw_print_exx, gw_no_print_exx, gw_read_exx, gw_skip_for_regtest/), &
     868              :                           enum_desc=s2a("Please, put TRUE for Gamma only calculation to get the exchange self-energy. "// &
     869              :                                         "If 'SIGMA_X' and the corresponding values for the exchange-energy are written, "// &
     870              :                                         "the writing has been successful", &
     871              :                                         "FALSE is needed if you want to do nothing here.", &
     872              :                                         "Please, put READ for the k-point GW calculation to read the exact exchange. "// &
     873              :                                         "You have to provide an output file including the exact exchange. This file "// &
     874              :                                         "has to be named 'exx.dat'.", &
     875              :                                         "SKIP_FOR_REGTEST is only used for the GW k-point regtest where no exchange "// &
     876              :                                         "self-energy is computed."), &
     877        64714 :                           default_i_val=gw_no_print_exx)
     878        64714 :       CALL section_add_keyword(section, keyword)
     879        64714 :       CALL keyword_release(keyword)
     880              : 
     881              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_SELF_ENERGY", &
     882              :                           description="If true, print the self-energy for all levels for real energy "// &
     883              :                           "together with the straight line to see the quasiparticle energy as intersection. "// &
     884              :                           "In addition, prints the self-energy for imaginary frequencies together with the Pade fit.", &
     885              :                           usage="PRINT_SELF_ENERGY", &
     886              :                           default_l_val=.FALSE., &
     887        64714 :                           lone_keyword_l_val=.TRUE.)
     888        64714 :       CALL section_add_keyword(section, keyword)
     889        64714 :       CALL keyword_release(keyword)
     890              : 
     891              :       CALL keyword_create(keyword, __LOCATION__, name="RI_SIGMA_X", &
     892              :                           description="If true, the exchange self-energy is calculated approximatively with RI. "// &
     893              :                           "If false, the Hartree-Fock implementation in CP2K is used.", &
     894              :                           usage="RI_SIGMA_X", &
     895              :                           default_l_val=.TRUE., &
     896        64714 :                           lone_keyword_l_val=.TRUE.)
     897        64714 :       CALL section_add_keyword(section, keyword)
     898        64714 :       CALL keyword_release(keyword)
     899              : 
     900              :       CALL keyword_create(keyword, __LOCATION__, name="IC_CORR_LIST", &
     901              :                           description="List of image charge correction from a previous calculation to be applied in G0W0 "// &
     902              :                           "or evGW. Keyword is active, if the first entry is positive (since IC corrections are positive "// &
     903              :                           "occupied MOs. The start corresponds to the first corrected GW level.", &
     904              :                           usage="IC_CORR_LIST <REAL> ... <REAL>", &
     905              :                           default_r_vals=(/-1.0_dp/), &
     906        64714 :                           type_of_var=real_t, n_var=-1, unit_str="eV")
     907        64714 :       CALL section_add_keyword(section, keyword)
     908        64714 :       CALL keyword_release(keyword)
     909              : 
     910              :       CALL keyword_create(keyword, __LOCATION__, name="IC_CORR_LIST_BETA", &
     911              :                           description="IC_CORR_LIST for beta spins in case of open shell calculation.", &
     912              :                           usage="IC_CORR_LIST_BETA <REAL> ... <REAL>", &
     913              :                           default_r_vals=(/-1.0_dp/), &
     914        64714 :                           type_of_var=real_t, n_var=-1, unit_str="eV")
     915        64714 :       CALL section_add_keyword(section, keyword)
     916        64714 :       CALL keyword_release(keyword)
     917              : 
     918              :       CALL keyword_create(keyword, __LOCATION__, name="PERIODIC_CORRECTION", &
     919              :                           description="If true, the periodic correction scheme is used employing k-points. "// &
     920              :                           "Method is not recommended to use, use instead PERIODIC_LOW_SCALING which much "// &
     921              :                           "more accurate than the periodic correction.", &
     922              :                           usage="PERIODIC_CORRECTION", &
     923              :                           default_l_val=.FALSE., &
     924        64714 :                           lone_keyword_l_val=.TRUE.)
     925        64714 :       CALL section_add_keyword(section, keyword)
     926        64714 :       CALL keyword_release(keyword)
     927              : 
     928              :       CALL keyword_create(keyword, __LOCATION__, name="IMAGE_CHARGE_MODEL", &
     929              :                           variants=(/"IC"/), &
     930              :                           description="If true, an image charge model is applied to mimic the renormalization of "// &
     931              :                           "electronic levels of a molecule at a metallic surface. For this calculation, the molecule "// &
     932              :                           "has to be reflected on the desired xy image plane. The coordinates of the reflected molecule "// &
     933              :                           "have to be added to the coord file as ghost atoms. For the ghost atoms, identical basis sets "// &
     934              :                           "the normal atoms have to be used.", &
     935              :                           usage="IC TRUE", &
     936              :                           default_l_val=.FALSE., &
     937       129428 :                           lone_keyword_l_val=.TRUE.)
     938        64714 :       CALL section_add_keyword(section, keyword)
     939        64714 :       CALL keyword_release(keyword)
     940              : 
     941              :       CALL keyword_create(keyword, __LOCATION__, name="ANALYTIC_CONTINUATION", &
     942              :                           description="Defines which type of analytic continuation for the self energy is used", &
     943              :                           usage="ANALYTIC_CONTINUATION", &
     944              :                           enum_c_vals=s2a("TWO_POLE", "PADE"), &
     945              :                           enum_i_vals=(/gw_two_pole_model, gw_pade_approx/), &
     946              :                           enum_desc=s2a("Use 'two-pole' model.", &
     947              :                                         "Use Pade approximation."), &
     948        64714 :                           default_i_val=gw_pade_approx)
     949        64714 :       CALL section_add_keyword(section, keyword)
     950        64714 :       CALL keyword_release(keyword)
     951              : 
     952              :       CALL keyword_create(keyword, __LOCATION__, name="NPARAM_PADE", &
     953              :                           description="Number of parameters for the Pade approximation "// &
     954              :                           "when using the latter for the analytic continuation of the "// &
     955              :                           "self energy. 16 parameters (corresponding to 8 poles) are "// &
     956              :                           "are recommended.", &
     957              :                           usage="NPARAM_PADE 16", &
     958        64714 :                           default_i_val=16)
     959        64714 :       CALL section_add_keyword(section, keyword)
     960        64714 :       CALL keyword_release(keyword)
     961              : 
     962              :       CALL keyword_create(keyword, __LOCATION__, name="GAMMA_ONLY_SIGMA", &
     963              :                           variants=(/"GAMMA"/), &
     964              :                           description="If true, the correlation self-energy is only computed at the Gamma point. "// &
     965              :                           "The Gamma point itself is obtained by averaging over all kpoints of the DFT mesh.", &
     966              :                           usage="GAMMA TRUE", &
     967              :                           default_l_val=.FALSE., &
     968       129428 :                           lone_keyword_l_val=.TRUE.)
     969        64714 :       CALL section_add_keyword(section, keyword)
     970        64714 :       CALL keyword_release(keyword)
     971              : 
     972              :       CALL keyword_create(keyword, __LOCATION__, name="UPDATE_XC_ENERGY", &
     973              :                           description="If true, the Hartree-Fock and RPA total energy are printed and the total energy "// &
     974              :                           "is corrected using exact exchange and the RPA correlation energy.", &
     975              :                           usage="UPDATE_XC_ENERGY", &
     976              :                           default_l_val=.FALSE., &
     977        64714 :                           lone_keyword_l_val=.TRUE.)
     978        64714 :       CALL section_add_keyword(section, keyword)
     979        64714 :       CALL keyword_release(keyword)
     980              : 
     981              :       CALL keyword_create(keyword, __LOCATION__, name="KPOINTS_SELF_ENERGY", &
     982              :                           description="Specify number of k-points for the k-point grid of the self-energy. Internally, a "// &
     983              :                           "Monkhorst-Pack grid is used. A dense k-point grid may be necessary to compute an accurate density "// &
     984              :                           "of state from GW. Large self-energy k-meshes do not cost much more computation time.", &
     985              :                           usage="KPOINTS_SELF_ENERGY  nx  ny  nz", repeats=.TRUE., &
     986        64714 :                           n_var=3, type_of_var=integer_t, default_i_vals=(/0, 0, 0/))
     987        64714 :       CALL section_add_keyword(section, keyword)
     988        64714 :       CALL keyword_release(keyword)
     989              : 
     990              :       CALL keyword_create(keyword, __LOCATION__, name="REGULARIZATION_MINIMAX", &
     991              :                           description="Tikhonov regularization for computing weights of the Fourier transform "// &
     992              :                           "from imaginary time to imaginary frequency and vice versa. Needed for large minimax "// &
     993              :                           "grids with 20 or more points and a small range.", &
     994              :                           usage="REGULARIZATION_MINIMAX 1.0E-6", &
     995        64714 :                           default_r_val=0.0_dp)
     996        64714 :       CALL section_add_keyword(section, keyword)
     997        64714 :       CALL keyword_release(keyword)
     998              : 
     999              :       CALL keyword_create(keyword, __LOCATION__, name="SOC", &
    1000              :                           description="Calculate the spin-orbit splitting of the eigenvalues/band structure "// &
    1001              :                           "using the spin-orbit part of the GTH pseudos parametrized in Hartwigsen, Goedecker, "// &
    1002              :                           "Hutter, Phys. Rev. B 58, 3641 (1998), Eq. 19, "// &
    1003              :                           "parameters in Table I.", &
    1004              :                           usage="SOC", &
    1005              :                           enum_c_vals=s2a("NONE", "LDA", "PBE"), &
    1006              :                           enum_i_vals=(/soc_none, soc_lda, soc_pbe/), &
    1007              :                           enum_desc=s2a("No SOC.", &
    1008              :                                         "Use parameters from LDA (PADE) pseudopotential.", &
    1009              :                                         "Use parameters from PBE pseudopotential."), &
    1010        64714 :                           default_i_val=soc_none)
    1011        64714 :       CALL section_add_keyword(section, keyword)
    1012        64714 :       CALL keyword_release(keyword)
    1013              : 
    1014              :       CALL keyword_create(keyword, __LOCATION__, name="SOC_ENERGY_WINDOW", &
    1015              :                           description="For perturbative SOC calculation, only "// &
    1016              :                           "take frontier levels in an energy window "// &
    1017              :                           "[E_HOMO - SOC_ENERGY_WINDOW/2 , E_LUMO + SOC_ENERGY_WINDOW/2 "// &
    1018              :                           "into account for the diagonalization of H^GW,SOC.", &
    1019              :                           usage="SOC_ENERGY_WINDOW 20.0_eV", &
    1020              :                           default_r_val=cp_unit_to_cp2k(value=50.0_dp, unit_str="eV"), &
    1021        64714 :                           unit_str="eV")
    1022        64714 :       CALL section_add_keyword(section, keyword)
    1023        64714 :       CALL keyword_release(keyword)
    1024              : 
    1025              :       ! here we generate a subsection for the periodic GW correction
    1026        64714 :       CALL create_periodic_gw_correction_section(subsection)
    1027        64714 :       CALL section_add_subsection(section, subsection)
    1028        64714 :       CALL section_release(subsection)
    1029              : 
    1030              :       ! here we generate a subsection for Bethe-Salpeter
    1031        64714 :       CALL create_bse_section(subsection)
    1032        64714 :       CALL section_add_subsection(section, subsection)
    1033        64714 :       CALL section_release(subsection)
    1034              : 
    1035              :       ! here we generate a subsection for image charge calculations
    1036        64714 :       CALL create_ic_section(subsection)
    1037        64714 :       CALL section_add_subsection(section, subsection)
    1038        64714 :       CALL section_release(subsection)
    1039              : 
    1040              :       ! here we generate a subsection for calculating the GW band structures
    1041        64714 :       CALL create_kpoint_set_section(subsection)
    1042        64714 :       CALL section_add_subsection(section, subsection)
    1043        64714 :       CALL section_release(subsection)
    1044              : 
    1045              :       ! here we generate a subsection for additional printing
    1046        64714 :       CALL create_print_section(subsection)
    1047        64714 :       CALL section_add_subsection(section, subsection)
    1048        64714 :       CALL section_release(subsection)
    1049              : 
    1050        64714 :    END SUBROUTINE create_ri_g0w0
    1051              : 
    1052              : ! **************************************************************************************************
    1053              : !> \brief ...
    1054              : !> \param section ...
    1055              : ! **************************************************************************************************
    1056        64714 :    SUBROUTINE create_print_section(section)
    1057              :       TYPE(section_type), POINTER                        :: section
    1058              : 
    1059              :       TYPE(keyword_type), POINTER                        :: keyword
    1060              :       TYPE(section_type), POINTER                        :: gw_dos_section, print_key
    1061              : 
    1062        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1063        64714 :       NULLIFY (print_key, keyword)
    1064        64714 :       NULLIFY (gw_dos_section, keyword)
    1065              :       CALL section_create(section, __LOCATION__, name="PRINT", &
    1066              :                           description="Section of possible print options specific for the GW code.", &
    1067        64714 :                           n_keywords=0, n_subsections=2, repeats=.FALSE.)
    1068              : 
    1069              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "LOCAL_BANDGAP", &
    1070              :                                        description="Prints a local bandgap E_gap(r), derived from the local density of "// &
    1071              :                                        "states rho(r,E). Details and formulae in the SI of the periodic GW paper (2023).", &
    1072              :                                        print_level=high_print_level, add_last=add_last_numeric, &
    1073              :                                        filename="LOCAL_BANDGAP", &
    1074        64714 :                                        common_iter_levels=3)
    1075              : 
    1076              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_WINDOW", &
    1077              :                           description="Energy window in the LDOS for searching the gap.", &
    1078              :                           usage="ENERGY_WINDOW 6.0", &
    1079              :                           default_r_val=cp_unit_to_cp2k(value=6.0_dp, unit_str="eV"), &
    1080        64714 :                           unit_str="eV")
    1081        64714 :       CALL section_add_keyword(print_key, keyword)
    1082        64714 :       CALL keyword_release(keyword)
    1083              : 
    1084              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_SPACING", &
    1085              :                           description="Energy spacing of the LDOS for searching the gap.", &
    1086              :                           usage="ENERGY_SPACING 0.03", &
    1087              :                           default_r_val=cp_unit_to_cp2k(value=0.03_dp, unit_str="eV"), &
    1088        64714 :                           unit_str="eV")
    1089        64714 :       CALL section_add_keyword(print_key, keyword)
    1090        64714 :       CALL keyword_release(keyword)
    1091              : 
    1092              :       CALL keyword_create(keyword, __LOCATION__, name="LDOS_THRESHOLD_GAP", &
    1093              :                           description="Relative LDOS threshold that determines the local bandgap.", &
    1094              :                           usage="LDOS_THRESHOLD_GAP 0.1", &
    1095        64714 :                           default_r_val=0.1_dp)
    1096        64714 :       CALL section_add_keyword(print_key, keyword)
    1097        64714 :       CALL keyword_release(keyword)
    1098              : 
    1099              :       CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
    1100              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1101              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1102              :                           " 1 number valid for all components.", &
    1103        64714 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=(/2, 2, 2/), type_of_var=integer_t)
    1104        64714 :       CALL section_add_keyword(print_key, keyword)
    1105        64714 :       CALL keyword_release(keyword)
    1106              : 
    1107        64714 :       CALL section_add_subsection(section, print_key)
    1108        64714 :       CALL section_release(print_key)
    1109              : 
    1110              :       CALL section_create(gw_dos_section, __LOCATION__, name="GW_DOS", &
    1111              :                           description="Section for printing the spectral function.", &
    1112        64714 :                           n_keywords=6, n_subsections=0, repeats=.FALSE.)
    1113              : 
    1114              :       CALL keyword_create(keyword, __LOCATION__, name="LOWER_BOUND", &
    1115              :                           description="Lower bound for GW-DOS in eV.", &
    1116              :                           usage="LOWER_BOUND -20.0", &
    1117              :                           default_r_val=cp_unit_to_cp2k(value=-20.0_dp, unit_str="eV"), &
    1118        64714 :                           unit_str="eV")
    1119        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1120        64714 :       CALL keyword_release(keyword)
    1121              : 
    1122              :       CALL keyword_create(keyword, __LOCATION__, name="UPPER_BOUND", &
    1123              :                           description="Upper bound for GW-DOS in eV.", &
    1124              :                           usage="UPPER_BOUND 5.0", &
    1125              :                           default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="eV"), &
    1126        64714 :                           unit_str="eV")
    1127        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1128        64714 :       CALL keyword_release(keyword)
    1129              : 
    1130              :       CALL keyword_create(keyword, __LOCATION__, name="STEP", &
    1131              :                           description="Difference of two consecutive energy levels for GW-DOS.", &
    1132              :                           usage="STEP 0.1", &
    1133              :                           default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="eV"), &
    1134        64714 :                           unit_str="eV")
    1135        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1136        64714 :       CALL keyword_release(keyword)
    1137              : 
    1138              :       CALL keyword_create(keyword, __LOCATION__, name="MIN_LEVEL_SPECTRAL", &
    1139              :                           description="Lowest energy level to print the self energy to files.", &
    1140              :                           usage="MIN_LEVEL_SPECTRAL 3", &
    1141        64714 :                           default_i_val=1)
    1142        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1143        64714 :       CALL keyword_release(keyword)
    1144              : 
    1145              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_LEVEL_SPECTRAL", &
    1146              :                           description="Highest energy level to print the self energy to files.", &
    1147              :                           usage="MAX_LEVEL_SPECTRAL 6", &
    1148        64714 :                           default_i_val=0)
    1149        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1150        64714 :       CALL keyword_release(keyword)
    1151              : 
    1152              :       CALL keyword_create(keyword, __LOCATION__, name="MIN_LEVEL_SELF_ENERGY", &
    1153              :                           description="Lowest energy level to print the self energy to files.", &
    1154              :                           usage="MIN_LEVEL_SELF_ENERGY 3", &
    1155        64714 :                           default_i_val=1)
    1156        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1157        64714 :       CALL keyword_release(keyword)
    1158              : 
    1159              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_LEVEL_SELF_ENERGY", &
    1160              :                           description="Highest energy level to print the self energy to files.", &
    1161              :                           usage="MAX_LEVEL_SELF_ENERGY 6", &
    1162        64714 :                           default_i_val=0)
    1163        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1164        64714 :       CALL keyword_release(keyword)
    1165              : 
    1166              :       CALL keyword_create(keyword, __LOCATION__, name="BROADENING", &
    1167              :                           description="Broadening parameter for spectral function.", &
    1168              :                           usage="BROADENING 0.001", &
    1169              :                           default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="eV"), &
    1170        64714 :                           unit_str="eV")
    1171        64714 :       CALL section_add_keyword(gw_dos_section, keyword)
    1172        64714 :       CALL keyword_release(keyword)
    1173              : 
    1174        64714 :       CALL section_add_subsection(section, gw_dos_section)
    1175        64714 :       CALL section_release(gw_dos_section)
    1176              : 
    1177        64714 :    END SUBROUTINE
    1178              : 
    1179              : ! **************************************************************************************************
    1180              : !> \brief ...
    1181              : !> \param section ...
    1182              : ! **************************************************************************************************
    1183        64714 :    SUBROUTINE create_periodic_gw_correction_section(section)
    1184              :       TYPE(section_type), POINTER                        :: section
    1185              : 
    1186              :       TYPE(keyword_type), POINTER                        :: keyword
    1187              : 
    1188        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1189              :       CALL section_create(section, __LOCATION__, name="PERIODIC_CORRECTION", &
    1190              :                           description="Parameters influencing correction for periodic GW. Old method, "// &
    1191              :                           "not recommended to use", &
    1192        64714 :                           n_keywords=12, n_subsections=1, repeats=.FALSE.)
    1193              : 
    1194        64714 :       NULLIFY (keyword)
    1195              : 
    1196              :       CALL keyword_create(keyword, __LOCATION__, name="KPOINTS", &
    1197              :                           description="Specify number of k-points for a single k-point grid. Internally, a "// &
    1198              :                           "Monkhorst-Pack grid is used. Typically, even numbers are chosen such that the Gamma "// &
    1199              :                           "point is excluded from the k-point mesh.", &
    1200              :                           usage="KPOINTS  nx  ny  nz", repeats=.TRUE., &
    1201        64714 :                           n_var=3, type_of_var=integer_t, default_i_vals=(/16, 16, 16/))
    1202        64714 :       CALL section_add_keyword(section, keyword)
    1203        64714 :       CALL keyword_release(keyword)
    1204              : 
    1205              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_KP_GRIDS", &
    1206              :                           description="Number of k-point grids around the Gamma point with different resolution. "// &
    1207              :                           "E.g. for KPOINTS 4 4 4 and NUM_KP_GRIDS 3, there will be a 3x3x3 Monkhorst-Pack (MP) k-point "// &
    1208              :                           "grid for the whole Brillouin zone (excluding Gamma), another 3x3x3 MP grid with smaller  "// &
    1209              :                           "spacing around Gamma (again excluding Gamma) and a very fine 4x4x4 MP grid around Gamma.", &
    1210              :                           usage="NUM_KP_GRIDS 5", &
    1211        64714 :                           default_i_val=1)
    1212        64714 :       CALL section_add_keyword(section, keyword)
    1213        64714 :       CALL keyword_release(keyword)
    1214              : 
    1215              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_KPOINT", &
    1216              :                           description="If the absolute value of a k-point is below EPS_KPOINT, this kpoint is "// &
    1217              :                           "neglected since the Gamma point is not included in the periodic correction.", &
    1218              :                           usage="EPS_KPOINT 1.0E-4", &
    1219        64714 :                           default_r_val=1.0E-05_dp)
    1220        64714 :       CALL section_add_keyword(section, keyword)
    1221        64714 :       CALL keyword_release(keyword)
    1222              : 
    1223              :       CALL keyword_create(keyword, __LOCATION__, name="MO_COEFF_GAMMA", &
    1224              :                           description="If true, only the MO coefficients at the Gamma point are used for the periodic  "// &
    1225              :                           "correction. Otherwise, the MO coeffs are computed at every k-point which is much more "// &
    1226              :                           "expensive. It should be okay to use the Gamma MO coefficients.", &
    1227              :                           usage="MO_COEFF_GAMMA", &
    1228              :                           default_l_val=.TRUE., &
    1229        64714 :                           lone_keyword_l_val=.TRUE.)
    1230        64714 :       CALL section_add_keyword(section, keyword)
    1231        64714 :       CALL keyword_release(keyword)
    1232              : 
    1233              :       CALL keyword_create(keyword, __LOCATION__, name="AVERAGE_DEGENERATE_LEVELS", &
    1234              :                           variants=(/"ADL"/), &
    1235              :                           description="If true, the correlation self-energy of degenerate levels is averaged.", &
    1236              :                           usage="AVERAGE_DEGENERATE_LEVELS", &
    1237              :                           default_l_val=.TRUE., &
    1238       129428 :                           lone_keyword_l_val=.TRUE.)
    1239        64714 :       CALL section_add_keyword(section, keyword)
    1240        64714 :       CALL keyword_release(keyword)
    1241              : 
    1242              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_EIGENVAL", &
    1243              :                           description="Threshold for considering levels as degenerate. Unit: Hartree.", &
    1244              :                           usage="EPS_EIGENVAL 1.0E-5", &
    1245        64714 :                           default_r_val=2.0E-04_dp)
    1246        64714 :       CALL section_add_keyword(section, keyword)
    1247        64714 :       CALL keyword_release(keyword)
    1248              : 
    1249              :       CALL keyword_create(keyword, __LOCATION__, name="EXTRAPOLATE_KPOINTS", &
    1250              :                           variants=(/"EXTRAPOLATE"/), &
    1251              :                           description="If true, extrapolates the k-point mesh. Only working if k-point mesh numbers are "// &
    1252              :                           "divisible by 4, e.g. 8x8x8 or 12x12x12 is recommended.", &
    1253              :                           usage="EXTRAPOLATE_KPOINTS FALSE", &
    1254              :                           default_l_val=.TRUE., &
    1255       129428 :                           lone_keyword_l_val=.TRUE.)
    1256        64714 :       CALL section_add_keyword(section, keyword)
    1257        64714 :       CALL keyword_release(keyword)
    1258              : 
    1259              :       CALL keyword_create(keyword, __LOCATION__, name="DO_AUX_BAS_GW", &
    1260              :                           description="If true, use a different basis for the periodic correction. This can be necessary "// &
    1261              :                           "in case a diffused basis is used for GW to converge the HOMO-LUMO gap. In this case, "// &
    1262              :                           "numerical problems may occur due to diffuse functions in the basis. This keyword only works if "// &
    1263              :                           "AUX_GW <basis set>  is specified in the kind section for every atom kind.", &
    1264              :                           usage="DO_AUX_BAS_GW TRUE", &
    1265              :                           default_l_val=.FALSE., &
    1266        64714 :                           lone_keyword_l_val=.TRUE.)
    1267        64714 :       CALL section_add_keyword(section, keyword)
    1268        64714 :       CALL keyword_release(keyword)
    1269              : 
    1270              :       CALL keyword_create(keyword, __LOCATION__, name="FRACTION_AUX_MOS", &
    1271              :                           description="Fraction how many MOs are used in the auxiliary basis.", &
    1272              :                           usage="FRACTION_AUX_MOS 0.6", &
    1273        64714 :                           default_r_val=0.5_dp)
    1274        64714 :       CALL section_add_keyword(section, keyword)
    1275        64714 :       CALL keyword_release(keyword)
    1276              : 
    1277              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_OMEGA_POINTS", &
    1278              :                           description="Number of Clenshaw-Curtis integration points for the periodic correction in cubic- "// &
    1279              :                           "scaling GW. This variable is a dummy variable for canonical N^4 GW calculations.", &
    1280              :                           usage="NUM_OMEGA_POINTS 200", &
    1281        64714 :                           default_i_val=300)
    1282        64714 :       CALL section_add_keyword(section, keyword)
    1283        64714 :       CALL keyword_release(keyword)
    1284              : 
    1285        64714 :    END SUBROUTINE
    1286              : 
    1287              : ! **************************************************************************************************
    1288              : !> \brief ...
    1289              : !> \param section ...
    1290              : ! **************************************************************************************************
    1291        64714 :    SUBROUTINE create_bse_section(section)
    1292              :       TYPE(section_type), POINTER                        :: section
    1293              : 
    1294              :       TYPE(keyword_type), POINTER                        :: keyword
    1295              :       TYPE(section_type), POINTER                        :: subsection
    1296              : 
    1297        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1298              :       CALL section_create(section, __LOCATION__, name="BSE", &
    1299              :                           description="Parameters for a calculation solving the Bethe-Salpeter equation "// &
    1300              :                           "(BSE) for electronic excitations. The full BSE "// &
    1301              :                           "$\left( \begin{array}{cc}A &  B\\B &  A\end{array} \right)$ "// &
    1302              :                           "$\left( \begin{array}{cc}\mathbf{X}^{(n)}\\\mathbf{Y}^{(n)}\end{array} \right) = "// &
    1303              :                           "\Omega^{(n)}\left(\begin{array}{cc}1&0\\0&-1\end{array}\right)$ "// &
    1304              :                           "$\left(\begin{array}{cc}\mathbf{X}^{(n)}\\\mathbf{Y}^{(n)}\end{array}\right)$ "// &
    1305              :                           "enables, for example, the computation of electronic excitation energies $\Omega^{(n)}$ "// &
    1306              :                           "as well as optical properties. The BSE can be solved by diagonalizing "// &
    1307              :                           "the full ABBA-matrix or by setting B=0, i.e. within the Tamm-Dancoff approximation (TDA). "// &
    1308              :                          "Preliminary reference: Eq. (35) in PRB 92, 045209 (2015); http://dx.doi.org/10.1103/PhysRevB.92.045209", &
    1309        64714 :                           n_keywords=8, n_subsections=3, repeats=.FALSE.)
    1310              : 
    1311        64714 :       NULLIFY (keyword)
    1312              : 
    1313              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1314              :                           description="Activates BSE calculations.", &
    1315              :                           usage="&BSE .TRUE.", &
    1316        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1317        64714 :       CALL section_add_keyword(section, keyword)
    1318        64714 :       CALL keyword_release(keyword)
    1319              : 
    1320              :       CALL keyword_create(keyword, __LOCATION__, name="SPIN_CONFIG", &
    1321              :                           description="Choose between calculation of singlet or triplet excitation (cf. given Reference above).", &
    1322              :                           usage="SPIN_CONFIG TRIPLET", &
    1323              :                           enum_c_vals=s2a("SINGLET", "TRIPLET"), &
    1324              :                           enum_i_vals=(/bse_singlet, bse_triplet/), &
    1325              :                           enum_desc=s2a("Computes singlet excitations.", &
    1326              :                                         "Computes triplet excitations."), &
    1327        64714 :                           default_i_val=bse_singlet)
    1328        64714 :       CALL section_add_keyword(section, keyword)
    1329        64714 :       CALL keyword_release(keyword)
    1330              : 
    1331              :       CALL keyword_create(keyword, __LOCATION__, name="BSE_DIAG_METHOD", &
    1332              :                           description="Method for BSE calculations. "// &
    1333              :                           "Choose between full or iterative diagonalization.", &
    1334              :                           usage="BSE_DIAG_METHOD FULLDIAG", &
    1335              :                           enum_c_vals=s2a("FULLDIAG", "ITERDIAG"), &
    1336              :                           enum_i_vals=(/bse_fulldiag, bse_iterdiag/), &
    1337              :                           enum_desc=s2a("Fully diagonalizes the BSE matrices within the chosen level of approximation.", &
    1338              :                                         "Iterative diagonalization has not been implemented yet."), &
    1339        64714 :                           default_i_val=bse_fulldiag)
    1340        64714 :       CALL section_add_keyword(section, keyword)
    1341        64714 :       CALL keyword_release(keyword)
    1342              : 
    1343              :       CALL keyword_create(keyword, __LOCATION__, name="TDA", &
    1344              :                           description="Level of approximation applied to BSE calculations. "// &
    1345              :                           "Choose between Tamm Dancoff approximation (TDA) and/or diagonalization of the full ABBA-matrix.", &
    1346              :                           usage="TDA ON", &
    1347              :                           enum_c_vals=s2a("ON", "OFF", "TDA+ABBA"), &
    1348              :                           enum_i_vals=(/bse_tda, bse_abba, bse_both/), &
    1349              :                           enum_desc=s2a("The TDA is applied, i.e. B=0.", &
    1350              :                                         "The ABBA-matrix is diagonalized, i.e. the TDA is not applied.", &
    1351              :                                         "The BSE is solved within the TDA (B=0) as well as for the full ABBA-matrix."), &
    1352        64714 :                           default_i_val=bse_tda)
    1353        64714 :       CALL section_add_keyword(section, keyword)
    1354        64714 :       CALL keyword_release(keyword)
    1355              : 
    1356              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_CUTOFF_OCC", &
    1357              :                           description="Remove all orbitals with indices i,j from A_ia,jb and B_ia,jb with energy difference "// &
    1358              :                           "to HOMO level larger than the given energy cutoff, i.e. "// &
    1359              :                "$\varepsilon_i\in[\varepsilon_{i=\text{HOMO}}^{GW}-E_\text{cut}^\text{occ},\varepsilon_{i=\text{HOMO}}^{GW}]$. "// &
    1360              :                           "Can be used to accelerate runtime and reduce memory consumption.", &
    1361              :                           usage="ENERGY_CUTOFF_OCC 10.0", unit_str="eV", &
    1362        64714 :                           type_of_var=real_t, default_r_val=-1.0_dp)
    1363        64714 :       CALL section_add_keyword(section, keyword)
    1364        64714 :       CALL keyword_release(keyword)
    1365              : 
    1366              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_CUTOFF_EMPTY", &
    1367              :                           description="Remove all orbitals with indices a,b from A_ia,jb and B_ia,jb with energy difference "// &
    1368              :                           "to LUMO level larger than the given energy cutoff, i.e. "// &
    1369              :              "$\varepsilon_a\in[\varepsilon_{a=\text{LUMO}}^{GW},\varepsilon_{a=\text{LUMO}}^{GW}+E_\text{cut}^\text{empty}]$. "// &
    1370              :                           "Can be used to accelerate runtime and reduce memory consumption.", &
    1371              :                           usage="ENERGY_CUTOFF_EMPTY 10.0", unit_str="eV", &
    1372        64714 :                           type_of_var=real_t, default_r_val=-1.0_dp)
    1373        64714 :       CALL section_add_keyword(section, keyword)
    1374        64714 :       CALL keyword_release(keyword)
    1375              : 
    1376              :       CALL keyword_create(keyword, __LOCATION__, name="BSE_DEBUG_PRINT", &
    1377              :                           description="Activates debug print statements in the BSE calculation.", &
    1378              :                           usage="BSE_DEBUG_PRINT .TRUE.", &
    1379        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1380        64714 :       CALL section_add_keyword(section, keyword)
    1381        64714 :       CALL keyword_release(keyword)
    1382              : 
    1383              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_PRINT_EXC", &
    1384              :                           description="Number of printed excitation levels with respective "// &
    1385              :                           "energies and oscillator strengths. Does not affect computation time.", &
    1386              :                           usage="NUM_PRINT_EXC 25", &
    1387        64714 :                           default_i_val=25)
    1388        64714 :       CALL section_add_keyword(section, keyword)
    1389        64714 :       CALL keyword_release(keyword)
    1390              : 
    1391              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_PRINT_EXC_DESCR", &
    1392              :                           description="Number of excitation levels for which the exciton "// &
    1393              :                           "descriptors are computed. Negative or too large "// &
    1394              :                           "NUM_PRINT_EXC_DESCR defaults to NUM_PRINT_EXC.", &
    1395              :                           usage="NUM_PRINT_EXC_DESCR 5", &
    1396        64714 :                           default_i_val=0)
    1397        64714 :       CALL section_add_keyword(section, keyword)
    1398        64714 :       CALL keyword_release(keyword)
    1399              : 
    1400              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_DIRECTIONAL_EXC_DESCR", &
    1401              :                           description="Activates printing of exciton descriptors per direction.", &
    1402              :                           usage="PRINT_DIRECTIONAL_EXC_DESCR .TRUE.", &
    1403        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1404        64714 :       CALL section_add_keyword(section, keyword)
    1405        64714 :       CALL keyword_release(keyword)
    1406              : 
    1407              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_X", &
    1408              :                           description="Threshold for printing contributions of singleparticle "// &
    1409              :                           "transitions, i.e. elements of the eigenvectors $X_{ia}^{(n)}$ and $Y_{ia}^{(n)}$.", &
    1410              :                           usage="EPS_X 0.1", &
    1411        64714 :                           type_of_var=real_t, default_r_val=0.1_dp)
    1412        64714 :       CALL section_add_keyword(section, keyword)
    1413        64714 :       CALL keyword_release(keyword)
    1414              : 
    1415              :       CALL keyword_create(keyword, __LOCATION__, name="USE_KS_ENERGIES", &
    1416              :                           description="Uses KS energies instead of GW quasiparticle energies.", &
    1417              :                           usage="USE_KS_ENERGIES .TRUE.", &
    1418        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1419        64714 :       CALL section_add_keyword(section, keyword)
    1420        64714 :       CALL keyword_release(keyword)
    1421              : 
    1422        64714 :       NULLIFY (subsection)
    1423        64714 :       CALL create_bse_screening_section(subsection)
    1424        64714 :       CALL section_add_subsection(section, subsection)
    1425        64714 :       CALL section_release(subsection)
    1426              : 
    1427        64714 :       NULLIFY (subsection)
    1428        64714 :       CALL create_bse_iterat_section(subsection)
    1429        64714 :       CALL section_add_subsection(section, subsection)
    1430        64714 :       CALL section_release(subsection)
    1431              : 
    1432        64714 :       NULLIFY (subsection)
    1433        64714 :       CALL create_bse_spectrum_section(subsection)
    1434        64714 :       CALL section_add_subsection(section, subsection)
    1435        64714 :       CALL section_release(subsection)
    1436              : 
    1437        64714 :       NULLIFY (subsection)
    1438        64714 :       CALL create_bse_nto_section(subsection)
    1439        64714 :       CALL section_add_subsection(section, subsection)
    1440        64714 :       CALL section_release(subsection)
    1441              : 
    1442        64714 :    END SUBROUTINE
    1443              : 
    1444        64714 :    SUBROUTINE create_bse_screening_section(section)
    1445              :       TYPE(section_type), POINTER                        :: section
    1446              : 
    1447              :       TYPE(keyword_type), POINTER                        :: keyword
    1448              : 
    1449        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1450              : 
    1451              :       CALL section_create(section, __LOCATION__, name="SCREENING_IN_W", &
    1452              :                           description="Screening $\epsilon$ applied to $W(\omega=0)=\epsilon^{-1}(\omega=0) v $ "// &
    1453              :                           "in the BSE calculation. Besides default BSE, i.e. $W_0$ (screening with DFT energies), "// &
    1454              :                           "a fixed $\alpha = \epsilon^{-1}(\omega)$ can be applied, which is similar to the mixing "// &
    1455              :                           "parameter for hybrid functionals in LR-TDDFT. In addition, the keywords TDHF "// &
    1456              :                           "(no screening - $\alpha = 1$) and RPA (infinite screening - $\alpha = 0$) can be applied.", &
    1457        64714 :                           n_keywords=2, n_subsections=0, repeats=.FALSE.)
    1458              : 
    1459        64714 :       NULLIFY (keyword)
    1460              : 
    1461              :       CALL keyword_create( &
    1462              :          keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1463              :          description="Shortcut for the most common functional combinations.", &
    1464              :          usage="&xc_functional BLYP", &
    1465              :          enum_c_vals=s2a("W_0", "TDHF", "RPA", "ALPHA"), &
    1466              :          enum_i_vals=(/bse_screening_w0, bse_screening_tdhf, bse_screening_rpa, bse_screening_alpha/), &
    1467              :          enum_desc=s2a("The Coulomb interaction is screened by applying DFT energies "// &
    1468              :                        "$\varepsilon_p^{DFT}$, which is typically used for GW-BSE and "// &
    1469              :                        "often labeled as $W_0$.", &
    1470              :                        "The Coulomb interaction is not screened, i.e. $W_{pq,rs}(\omega=0) "// &
    1471              :                        "\rightarrow v_{pq,rs}$ enters.", &
    1472              :                        "Infinite screening is applied, i.e. $W_{pq,rs}(\omega=0) \rightarrow 0$.", &
    1473              :                        "Arbitrary screening parameter. Specify within section."), &
    1474              :          default_i_val=bse_screening_w0, &
    1475        64714 :          lone_keyword_i_val=bse_screening_w0)
    1476        64714 :       CALL section_add_keyword(section, keyword)
    1477        64714 :       CALL keyword_release(keyword)
    1478              : 
    1479              :       CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
    1480              :                           description="Screening parameter similar to the mixing in hybrid functionals used in TDDFT. "// &
    1481              :                           "$\alpha$ mimicks the screening $\epsilon^{-1}(\omega)$ and enforces $W = \alpha v$ "// &
    1482              :                           "in the BSE calculation.", &
    1483              :                           usage="ALPHA 0.25", &
    1484        64714 :                           type_of_var=real_t, default_r_val=-1.00_dp)
    1485        64714 :       CALL section_add_keyword(section, keyword)
    1486        64714 :       CALL keyword_release(keyword)
    1487              : 
    1488        64714 :    END SUBROUTINE create_bse_screening_section
    1489              : 
    1490        64714 :    SUBROUTINE create_bse_nto_section(print_key)
    1491              :       TYPE(section_type), POINTER                        :: print_key
    1492              : 
    1493              :       TYPE(keyword_type), POINTER                        :: keyword
    1494              : 
    1495        64714 :       CPASSERT(.NOT. ASSOCIATED(print_key))
    1496              : 
    1497              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="NTO_ANALYSIS", &
    1498              :                                 description="Perform a natural transition orbital analysis, i.e. the transition density matrix "// &
    1499              :                             "$T^{(n)}=\left( \begin{array}{cc}0& {X}^{(n)}\\ \left({Y}^{(n)} \right)^T & 0\end{array} \right)$ "// &
    1500              :                                        "is decomposed into its singular values "// &
    1501              :                                        "$T^{(n)} = {U}^{(n)} {\Lambda^{(n)}} \left({V}^{(n)}\right)^T$ "// &
    1502              :                                        "in order to compute the NTO pairs "// &
    1503              :                    "$\phi_I^{(n)}(\mathbf{r}_e) = \sum_{p=1}^{N_b} \varphi_p(\mathbf{r}_e) V_{p,I}^{(n)}$ for the electron and "// &
    1504              :                             "$\chi_I^{(n)}(\mathbf{r}_h) = \sum_{q=1}^{N_b} \varphi_q(\mathbf{r}_h) U_{q,I}^{(n)}$ for the hole.", &
    1505              :                                        print_level=debug_print_level + 1, &  ! Corresponds to "off" as default behavior
    1506        64714 :                                        filename="BSE-NTO_ANALYSIS")        ! All other print levels will trigger the analysis
    1507              :       ! cf. input/cp_output_handling.F:cp_print_key_section_create
    1508              : 
    1509        64714 :       NULLIFY (keyword)
    1510              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_NTO_EIGVAL", &
    1511              :                           description="Threshold for NTO eigenvalues, i.e. only "// &
    1512              :                           "${\left(\lambda_I^{(n)}\right)}^2$ > EPS_NTO_EIGVAL are considered.", &
    1513              :                           usage="EPS_NTO_EIGVAL 0.01", &
    1514              :                           n_var=1, &
    1515              :                           type_of_var=real_t, &
    1516        64714 :                           default_r_val=0.01_dp)
    1517        64714 :       CALL section_add_keyword(print_key, keyword)
    1518        64714 :       CALL keyword_release(keyword)
    1519              : 
    1520              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_OSC_STR", &
    1521              :                           description="Threshold of oscillator strengths $f^{(n)}$ for an excitation level. "// &
    1522              :                           "In case, the excitation level n has a smaller oscillator strength, the "// &
    1523              :                           "NTOs for this excitation level are not printed.", &
    1524              :                           usage="EPS_OSC_STR 0.01", &
    1525              :                           n_var=1, &
    1526              :                           type_of_var=real_t, &
    1527        64714 :                           default_r_val=-1.0_dp)
    1528        64714 :       CALL section_add_keyword(print_key, keyword)
    1529        64714 :       CALL keyword_release(keyword)
    1530              : 
    1531              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_PRINT_EXC_NTOS", &
    1532              :                           description="Number of excitation level $n$ up to which NTOs are printed. "// &
    1533              :                           "By default, this is set to NUM_PRINT_EXC. Negative or too large "// &
    1534              :                           "NUM_PRINT_EXC_NTOS defaults to NUM_PRINT_EXC.", &
    1535              :                           usage="NUM_PRINT_EXC_NTOS 5", &
    1536              :                           n_var=1, &
    1537              :                           type_of_var=integer_t, &
    1538        64714 :                           default_i_val=-1)
    1539        64714 :       CALL section_add_keyword(print_key, keyword)
    1540        64714 :       CALL keyword_release(keyword)
    1541              : 
    1542              :       CALL keyword_create(keyword, __LOCATION__, name="STATE_LIST", &
    1543              :                           description="Specifies a list of excitation levels $n$ for which NTOs are printed. "// &
    1544              :                           "Overrides NUM_PRINT_EXC_NTOS.", &
    1545              :                           usage="STATE_LIST {integer} {integer} .. {integer}", &
    1546        64714 :                           n_var=-1, type_of_var=integer_t)
    1547        64714 :       CALL section_add_keyword(print_key, keyword)
    1548        64714 :       CALL keyword_release(keyword)
    1549              : 
    1550              :       CALL keyword_create(keyword, __LOCATION__, name="CUBE_FILES", &
    1551              :                           description="Print NTOs on Cube Files", &
    1552              :                           usage="CUBE_FILES {logical}", repeats=.FALSE., n_var=1, &
    1553        64714 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE., type_of_var=logical_t)
    1554        64714 :       CALL section_add_keyword(print_key, keyword)
    1555        64714 :       CALL keyword_release(keyword)
    1556              : 
    1557              :       CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
    1558              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1559              :                           "(larger values result in smaller cube files). Provide 3 numbers (for X,Y,Z) or"// &
    1560              :                           " 1 number valid for all components.", &
    1561        64714 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=(/2, 2, 2/), type_of_var=integer_t)
    1562        64714 :       CALL section_add_keyword(print_key, keyword)
    1563        64714 :       CALL keyword_release(keyword)
    1564              : 
    1565              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1566              :                           description="append the cube files when they already exist", &
    1567        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1568        64714 :       CALL section_add_keyword(print_key, keyword)
    1569        64714 :       CALL keyword_release(keyword)
    1570              : 
    1571        64714 :    END SUBROUTINE create_bse_nto_section
    1572              : 
    1573        64714 :    SUBROUTINE create_bse_spectrum_section(section)
    1574              :       TYPE(section_type), POINTER                        :: section
    1575              : 
    1576              :       TYPE(keyword_type), POINTER                        :: keyword
    1577              : 
    1578        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1579              :       CALL section_create(section, __LOCATION__, name="BSE_SPECTRUM", &
    1580              :                           description="Parameters influencing the output of the optical absorption spectrum, i.e. "// &
    1581              :                           "the dynamical dipole polarizability tensor $\alpha_{\mu,\mu'}(\omega)$ "// &
    1582              :                           "($\mu,\mu'\in\{x,y,z\}$), obtained from a BSE calculation, which is defined as "// &
    1583              :                           "$ \alpha_{\mu,\mu'}(\omega) = \sum_n \frac{2 E^{(n)} d^{(n)}_{\mu} d^{(n)}_{\mu'}} "// &
    1584              :                           "{(\omega+i\eta)^2-\left(\Omega^{(n)}\right)^2} $. "// &
    1585              :                           "The printed file will contain the specified frequency range $\omega$ and the "// &
    1586              :                           "corresponding imaginary part of the average $\bar{\alpha}(\omega)=\frac{1}{3}\mathrm{Tr} "// &
    1587              :                           "\left[ \alpha_{\mu,\mu'}(\omega)\right]$ as well as of the elements of $\alpha_{\mu,\mu'}(\omega)$.", &
    1588        64714 :                           n_keywords=9, n_subsections=0, repeats=.FALSE.)
    1589              : 
    1590        64714 :       NULLIFY (keyword)
    1591              : 
    1592              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1593              :                           description="Activates printing of optical absorption spectrum from the BSE calculation.", &
    1594              :                           usage="&BSE .TRUE.", &
    1595        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1596        64714 :       CALL section_add_keyword(section, keyword)
    1597        64714 :       CALL keyword_release(keyword)
    1598              : 
    1599              :       CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY_STEP_SIZE", &
    1600              :                           description="Step size of frequencies for the optical absorption spectrum.", &
    1601              :                           usage="FREQUENCY_STEP_SIZE 0.1", unit_str="eV", &
    1602              :                           type_of_var=real_t, &
    1603        64714 :                           default_r_val=cp_unit_to_cp2k(value=0.1_dp, unit_str="eV"))
    1604        64714 :       CALL section_add_keyword(section, keyword)
    1605        64714 :       CALL keyword_release(keyword)
    1606              : 
    1607              :       CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY_STARTING_POINT", &
    1608              :                           description="First frequency to print in the optical absorption spectrum.", &
    1609              :                           usage="FREQUENCY_STARTING_POINT 0", unit_str="eV", &
    1610        64714 :                           type_of_var=real_t, default_r_val=0.0_dp)
    1611        64714 :       CALL section_add_keyword(section, keyword)
    1612        64714 :       CALL keyword_release(keyword)
    1613              : 
    1614              :       CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY_END_POINT", &
    1615              :                           description="Last frequency to print in the optical absorption spectrum.", &
    1616              :                           usage="FREQUENCY_END_POINT 0", unit_str="eV", &
    1617              :                           type_of_var=real_t, &
    1618        64714 :                           default_r_val=cp_unit_to_cp2k(value=100.0_dp, unit_str="eV"))
    1619        64714 :       CALL section_add_keyword(section, keyword)
    1620        64714 :       CALL keyword_release(keyword)
    1621              : 
    1622              :       CALL keyword_create(keyword, __LOCATION__, name="ETA_LIST", &
    1623              :                           description="List of broadening of the peaks in the optical absorption spectrum.", &
    1624              :                           usage="ETA_LIST 0.01 ...", unit_str="eV", &
    1625              :                           default_r_vals=(/cp_unit_to_cp2k(value=0.01_dp, unit_str="eV")/), &
    1626       129428 :                           type_of_var=real_t, n_var=-1)
    1627        64714 :       CALL section_add_keyword(section, keyword)
    1628        64714 :       CALL keyword_release(keyword)
    1629              : 
    1630        64714 :    END SUBROUTINE
    1631              : 
    1632              : ! **************************************************************************************************
    1633              : !> \brief ...
    1634              : !> \param section ...
    1635              : ! **************************************************************************************************
    1636        64714 :    SUBROUTINE create_bse_iterat_section(section)
    1637              :       TYPE(section_type), POINTER                        :: section
    1638              : 
    1639              :       TYPE(keyword_type), POINTER                        :: keyword
    1640              : 
    1641        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1642              :       CALL section_create(section, __LOCATION__, name="BSE_ITERAT", &
    1643              :                           description="Parameters influencing the iterative Bethe-Salpeter calculation. "// &
    1644              :                           "The iterative solver has not been fully implemented yet.", &
    1645        64714 :                           n_keywords=9, n_subsections=0, repeats=.FALSE.)
    1646              : 
    1647        64714 :       NULLIFY (keyword)
    1648              : 
    1649              :       CALL keyword_create(keyword, __LOCATION__, name="DAVIDSON_ABORT_COND", &
    1650              :                           description="Desired abortion condition for Davidson solver", &
    1651              :                           usage="DAVIDSON_ABORT_COND OR", &
    1652              :                           enum_c_vals=s2a("EN", "RES", "OR"), &
    1653              :                           enum_i_vals=(/bse_iter_en_cond, bse_iter_res_cond, bse_iter_both_cond/), &
    1654              :                           enum_desc=s2a("Uses energy threshold for successfully exiting solver.", &
    1655              :                                         "Uses residual threshold for successfully exiting solver.", &
    1656              :                                         "Uses either energy or residual threshold for successfully exiting solver."), &
    1657        64714 :                           default_i_val=bse_iter_en_cond)
    1658        64714 :       CALL section_add_keyword(section, keyword)
    1659        64714 :       CALL keyword_release(keyword)
    1660              : 
    1661              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_EXC_EN", &
    1662              :                           description="Number of lowest excitation energies to be computed.", &
    1663              :                           usage="NUM_EXC_EN 3", &
    1664        64714 :                           default_i_val=3)
    1665        64714 :       CALL section_add_keyword(section, keyword)
    1666        64714 :       CALL keyword_release(keyword)
    1667              : 
    1668              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_ADD_START_Z_SPACE", &
    1669              :                           description="Determines the initial dimension of the subspace as "// &
    1670              :                           "dim = (NUM_EXC_EN+NUM_ADD_START_Z_SPACE)", &
    1671              :                           usage="NUM_ADD_START_Z_SPACE 1", &
    1672        64714 :                           default_i_val=0)
    1673        64714 :       CALL section_add_keyword(section, keyword)
    1674        64714 :       CALL keyword_release(keyword)
    1675              : 
    1676              :       CALL keyword_create(keyword, __LOCATION__, name="FAC_MAX_Z_SPACE", &
    1677              :                           description="Factor to determine maximum dimension of the Davidson subspace. "// &
    1678              :                           "dimension = (NUM_EXC_EN+NUM_ADD_START_Z_SPACE)*FAC_MAX_Z_SPACE", &
    1679              :                           usage="FAC_MAX_Z_SPACE 5", &
    1680        64714 :                           default_i_val=5)
    1681        64714 :       CALL section_add_keyword(section, keyword)
    1682        64714 :       CALL keyword_release(keyword)
    1683              : 
    1684              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_NEW_T", &
    1685              :                           description="Number of new t vectors added. "// &
    1686              :                           "Must be smaller/equals (NUM_EXC_EN+NUM_ADD_START_Z_SPACE)", &
    1687              :                           usage="NUM_NEW_T 4", &
    1688        64714 :                           default_i_val=1)
    1689        64714 :       CALL section_add_keyword(section, keyword)
    1690        64714 :       CALL keyword_release(keyword)
    1691              : 
    1692              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_RES", &
    1693              :                           description="Threshold for stopping the iteration for computing the transition energies. "// &
    1694              :                           "If the residuals inside the Davidson space change by less than EPS_RES (in eV), the iteration "// &
    1695              :                           "stops.", &
    1696              :                           usage="EPS_RES 0.001", unit_str="eV", &
    1697        64714 :                           type_of_var=real_t, default_r_val=0.001_dp)
    1698        64714 :       CALL section_add_keyword(section, keyword)
    1699        64714 :       CALL keyword_release(keyword)
    1700              : 
    1701              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_EXC_EN", &
    1702              :                           description="Threshold for stopping the iteration for computing the transition energies. "// &
    1703              :                           "If the desired excitation energies change by less than EPS_EXC_EN (in eV), the iteration "// &
    1704              :                           "stops.", &
    1705              :                           usage="EPS_EXC_EN 0.001", unit_str="eV", &
    1706        64714 :                           type_of_var=real_t, default_r_val=0.001_dp)
    1707        64714 :       CALL section_add_keyword(section, keyword)
    1708        64714 :       CALL keyword_release(keyword)
    1709              : 
    1710              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_DAVIDSON_ITER", &
    1711              :                           description="Maximum number of iterations for determining the transition energies.", &
    1712              :                           usage="NUM_DAVIDSON_ITER 100", &
    1713        64714 :                           default_i_val=100)
    1714        64714 :       CALL section_add_keyword(section, keyword)
    1715        64714 :       CALL keyword_release(keyword)
    1716              : 
    1717              :       CALL keyword_create(keyword, __LOCATION__, name="Z_SPACE_ENERGY_CUTOFF", &
    1718              :                           description="Cutoff (in eV) for maximal energy difference entering the A matrix. "// &
    1719              :                           "Per default and for negative values, there is no cutoff applied.", &
    1720              :                           usage="Z_SPACE_ENERGY_CUTOFF 60", unit_str="eV", &
    1721        64714 :                           type_of_var=real_t, default_r_val=-1.0_dp)
    1722        64714 :       CALL section_add_keyword(section, keyword)
    1723        64714 :       CALL keyword_release(keyword)
    1724        64714 :    END SUBROUTINE
    1725              : 
    1726              : ! **************************************************************************************************
    1727              : !> \brief ...
    1728              : !> \param section ...
    1729              : ! **************************************************************************************************
    1730        64714 :    SUBROUTINE create_ic_section(section)
    1731              :       TYPE(section_type), POINTER                        :: section
    1732              : 
    1733              :       TYPE(keyword_type), POINTER                        :: keyword
    1734              : 
    1735        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1736              :       CALL section_create(section, __LOCATION__, name="IC", &
    1737              :                           description="Parameters influencing the image charge correction. "// &
    1738              :                           "The image plane is always an xy plane, so adjust the molecule according "// &
    1739              :                           "to that. ", &
    1740        64714 :                           n_keywords=3, n_subsections=1, repeats=.FALSE.)
    1741              : 
    1742        64714 :       NULLIFY (keyword)
    1743              : 
    1744              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_IC_LIST", &
    1745              :                           description="If true, the image charge correction values are printed in a list, "// &
    1746              :                           "such that it can be used as input for a subsequent evGW calculation.", &
    1747              :                           usage="PRINT_IC_LIST .TRUE.", &
    1748              :                           default_l_val=.FALSE., &
    1749        64714 :                           lone_keyword_l_val=.TRUE.)
    1750        64714 :       CALL section_add_keyword(section, keyword)
    1751        64714 :       CALL keyword_release(keyword)
    1752              : 
    1753              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_DIST", &
    1754              :                           description="Threshold where molecule and image molecule have to coincide. ", &
    1755              :                           usage="EPS_DIST 0.1", unit_str="angstrom", &
    1756        64714 :                           type_of_var=real_t, default_r_val=3.0E-02_dp, repeats=.FALSE.)
    1757        64714 :       CALL section_add_keyword(section, keyword)
    1758        64714 :       CALL keyword_release(keyword)
    1759              : 
    1760        64714 :    END SUBROUTINE
    1761              : 
    1762              : ! **************************************************************************************************
    1763              : !> \brief ...
    1764              : !> \param section ...
    1765              : ! **************************************************************************************************
    1766        64714 :    SUBROUTINE create_low_scaling(section)
    1767              :       TYPE(section_type), POINTER                        :: section
    1768              : 
    1769              :       TYPE(keyword_type), POINTER                        :: keyword
    1770              :       TYPE(section_type), POINTER                        :: subsection
    1771              : 
    1772        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    1773              :       CALL section_create( &
    1774              :          section, __LOCATION__, name="LOW_SCALING", &
    1775              :          description="Cubic scaling RI-RPA, GW and Laplace-SOS-MP2 method using the imaginary time formalism. "// &
    1776              :          "EPS_GRID in WFC_GPW section controls accuracy / req. memory for 3-center integrals. "// &
    1777              :          "SORT_BASIS EXP should be specified in DFT section.", &
    1778              :          n_keywords=12, n_subsections=2, repeats=.FALSE., &
    1779       258856 :          citations=(/Wilhelm2016b, Wilhelm2018, Bussy2023/))
    1780              : 
    1781        64714 :       NULLIFY (keyword)
    1782              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1783              :                           description="Activates cubic-scaling RPA, GW and Laplace-SOS-MP2 calculations.", &
    1784              :                           usage="&LOW_SCALING .TRUE.", &
    1785        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1786        64714 :       CALL section_add_keyword(section, keyword)
    1787        64714 :       CALL keyword_release(keyword)
    1788              : 
    1789              :       CALL keyword_create(keyword, __LOCATION__, name="MEMORY_CUT", &
    1790              :                           description="Reduces memory for sparse tensor contractions by this factor. "// &
    1791              :                           "A high value leads to some loss of performance. "// &
    1792              :                           "This memory reduction factor applies to storage of the tensors 'M occ' / 'M virt' "// &
    1793              :                           "but does not reduce storage of '3c ints'.", &
    1794              :                           usage="MEMORY_CUT 16", &
    1795        64714 :                           default_i_val=5)
    1796        64714 :       CALL section_add_keyword(section, keyword)
    1797        64714 :       CALL keyword_release(keyword)
    1798              : 
    1799              :       CALL keyword_create(keyword, __LOCATION__, name="MEMORY_INFO", &
    1800              :                           description="Decide whether to print memory info on the sparse matrices.", &
    1801              :                           usage="MEMORY_INFO", &
    1802              :                           default_l_val=.FALSE., &
    1803        64714 :                           lone_keyword_l_val=.TRUE.)
    1804        64714 :       CALL section_add_keyword(section, keyword)
    1805        64714 :       CALL keyword_release(keyword)
    1806              : 
    1807              :       CALL keyword_create( &
    1808              :          keyword, __LOCATION__, name="EPS_FILTER", &
    1809              :          description="Determines a threshold for the DBCSR based multiply. "// &
    1810              :          "Normally, this EPS_FILTER determines accuracy and timing of low-scaling RPA and GW calculations.", &
    1811              :          usage="EPS_FILTER 1.0E-10 ", type_of_var=real_t, &
    1812        64714 :          default_r_val=1.0E-9_dp)
    1813        64714 :       CALL section_add_keyword(section, keyword)
    1814        64714 :       CALL keyword_release(keyword)
    1815              : 
    1816              :       CALL keyword_create( &
    1817              :          keyword, __LOCATION__, name="EPS_FILTER_FACTOR", &
    1818              :          description="Multiply EPS_FILTER with this factor to determine filter epsilon "// &
    1819              :          "for DBCSR based multiply P(it)=(Mocc(it))^T*Mvirt(it) "// &
    1820              :          "Default should be kept.", &
    1821              :          type_of_var=real_t, &
    1822        64714 :          default_r_val=10.0_dp)
    1823        64714 :       CALL section_add_keyword(section, keyword)
    1824        64714 :       CALL keyword_release(keyword)
    1825              : 
    1826              :       CALL keyword_create( &
    1827              :          keyword, __LOCATION__, &
    1828              :          name="EPS_STORAGE_SCALING", &
    1829              :          variants=(/"EPS_STORAGE"/), &
    1830              :          description="Scaling factor to scale EPS_FILTER. Storage threshold for compression "// &
    1831              :          "will be EPS_FILTER*EPS_STORAGE_SCALING.", &
    1832       129428 :          default_r_val=1.0E-3_dp)
    1833        64714 :       CALL section_add_keyword(section, keyword)
    1834        64714 :       CALL keyword_release(keyword)
    1835              : 
    1836              :       CALL keyword_create( &
    1837              :          keyword, __LOCATION__, &
    1838              :          name="DO_KPOINTS", &
    1839              :          description="Besides in DFT, this keyword has to be switched on if one wants to do kpoints in. "// &
    1840              :          "cubic RPA.", &
    1841              :          usage="DO_KPOINTS", &
    1842              :          default_l_val=.FALSE., &
    1843        64714 :          lone_keyword_l_val=.TRUE.)
    1844        64714 :       CALL section_add_keyword(section, keyword)
    1845        64714 :       CALL keyword_release(keyword)
    1846              : 
    1847              :       CALL keyword_create( &
    1848              :          keyword, __LOCATION__, name="KPOINTS", &
    1849              :          description="Keyword activates periodic, low-scaling GW calculations (&LOW_SCALING section also needed). "// &
    1850              :          "For periodic calculations, kpoints are used for the density response, the "// &
    1851              :          "Coulomb interaction and the screened Coulomb interaction. For 2d periodic systems, e.g. xz "// &
    1852              :          "periodicity, please also specify KPOINTS, e.g.  N_x  1  N_z.", &
    1853              :          usage="KPOINTS  N_x  N_y  N_z", &
    1854        64714 :          n_var=3, type_of_var=integer_t, default_i_vals=(/0, 0, 0/))
    1855        64714 :       CALL section_add_keyword(section, keyword)
    1856        64714 :       CALL keyword_release(keyword)
    1857              : 
    1858              :       CALL keyword_create( &
    1859              :          keyword, __LOCATION__, &
    1860              :          name="KPOINT_WEIGHTS_W", &
    1861              :          description="For kpoints in low-scaling GW, a Monkhorst-Pack mesh is used. The screened Coulomb "// &
    1862              :          "interaction W(k) needs special care near the Gamma point (e.g. in 3d, W(k) diverges at the "// &
    1863              :          "Gamma point with W(k) ~ k^alpha). KPOINT_WEIGHTS_W decides how the weights of the "// &
    1864              :          "Monkhorst-Pack mesh are chosen to compute W(R) = int_BZ W(k) exp(ikR) dk (BZ=Brllouin zone). ", &
    1865              :          usage="KPOINT_WEIGHTS_W AUTO", &
    1866              :          enum_c_vals=s2a("TAILORED", "AUTO", "UNIFORM"), &
    1867              :          enum_i_vals=(/kp_weights_W_tailored, kp_weights_W_auto, kp_weights_W_uniform/), &
    1868              :          enum_desc=s2a("Choose k-point integration weights such that the function f(k)=k^alpha is "// &
    1869              :                        "exactly integrated. alpha is specified using EXPONENT_TAILORED_WEIGHTS.", &
    1870              :                        "As 'TAILORED', but alpha is chosen automatically according to dimensionality "// &
    1871              :                        "(3D: alpha = -2 for 3D, 2D: alpha = -1 for exchange self-energy, uniform "// &
    1872              :                        "weights for correlation self-energy).", &
    1873              :                        "Choose the same weight for every k-point (original Monkhorst-Pack method)."), &
    1874        64714 :          default_i_val=kp_weights_W_uniform)
    1875        64714 :       CALL section_add_keyword(section, keyword)
    1876        64714 :       CALL keyword_release(keyword)
    1877              : 
    1878              :       CALL keyword_create( &
    1879              :          keyword, __LOCATION__, &
    1880              :          name="EXPONENT_TAILORED_WEIGHTS", &
    1881              :          description="Gives the exponent of exactly integrated function in case 'KPOINT_WEIGHTS_W "// &
    1882              :          "TAILORED' is chosen.", &
    1883              :          usage="EXPONENT_TAILORED_WEIGHTS -2", &
    1884        64714 :          default_r_val=-2.0_dp)
    1885        64714 :       CALL section_add_keyword(section, keyword)
    1886        64714 :       CALL keyword_release(keyword)
    1887              : 
    1888              :       CALL keyword_create( &
    1889              :          keyword, __LOCATION__, &
    1890              :          name="REGULARIZATION_RI", &
    1891              :          description="Parameter to reduce the expansion coefficients in RI for periodic GW. Larger parameter "// &
    1892              :          "means smaller expansion coefficients that leads to a more stable calculation at the price "// &
    1893              :          "of a slightly worse RI approximation. In case the parameter 0.0 is chosen, ordinary RI is used.", &
    1894              :          usage="REGULARIZATION_RI 1.0E-4", &
    1895        64714 :          default_r_val=0.0_dp)
    1896        64714 :       CALL section_add_keyword(section, keyword)
    1897        64714 :       CALL keyword_release(keyword)
    1898              : 
    1899              :       CALL keyword_create( &
    1900              :          keyword, __LOCATION__, &
    1901              :          name="EPS_EIGVAL_S", &
    1902              :          description="Parameter to reduce the expansion coefficients in RI for periodic GW. Removes all "// &
    1903              :          "eigenvectors and eigenvalues of S_PQ(k) that are smaller than EPS_EIGVAL_S. ", &
    1904              :          usage="EPS_EIGVAL_S 1.0E-3", &
    1905        64714 :          default_r_val=0.0_dp)
    1906        64714 :       CALL section_add_keyword(section, keyword)
    1907        64714 :       CALL keyword_release(keyword)
    1908              : 
    1909              :       CALL keyword_create( &
    1910              :          keyword, __LOCATION__, &
    1911              :          name="EPS_EIGVAL_S_GAMMA", &
    1912              :          description="Parameter to reduce the expansion coefficients in RI for periodic GW. Removes all "// &
    1913              :          "eigenvectors and eigenvalues of M_PQ(k=0) that are smaller than EPS_EIGVAL_S. ", &
    1914              :          usage="EPS_EIGVAL_S_GAMMA 1.0E-3", &
    1915        64714 :          default_r_val=0.0_dp)
    1916        64714 :       CALL section_add_keyword(section, keyword)
    1917        64714 :       CALL keyword_release(keyword)
    1918              : 
    1919              :       CALL keyword_create( &
    1920              :          keyword, __LOCATION__, &
    1921              :          name="MAKE_CHI_POS_DEFINITE", &
    1922              :          description="If true, makes eigenvalue decomposition of chi(iw,k) and removes negative "// &
    1923              :          "eigenvalues. May increase computational cost significantly. Only recommended to try in case "// &
    1924              :          "Cholesky decomposition of epsilon(iw,k) fails.", &
    1925              :          usage="MAKE_CHI_POS_DEFINITE", &
    1926              :          default_l_val=.TRUE., &
    1927        64714 :          lone_keyword_l_val=.TRUE.)
    1928        64714 :       CALL section_add_keyword(section, keyword)
    1929        64714 :       CALL keyword_release(keyword)
    1930              : 
    1931              :       CALL keyword_create( &
    1932              :          keyword, __LOCATION__, &
    1933              :          name="MAKE_OVERLAP_MAT_AO_POS_DEFINITE", &
    1934              :          description="If true, makes eigenvalue decomposition of S_mu,nu(k) and removes negative "// &
    1935              :          "eigenvalues. Slightly increases computational cost. Only recommended to try in case "// &
    1936              :          "Cholesky decomposition of S_mu,nu(k) fails (error message: Cholesky decompose failed: "// &
    1937              :          "matrix is not positive definite or ill-conditioned; when calling create_kp_and_calc_kp_orbitals).", &
    1938              :          usage="MAKE_OVERLAP_MAT_AO_POS_DEFINITE", &
    1939              :          default_l_val=.FALSE., &
    1940        64714 :          lone_keyword_l_val=.TRUE.)
    1941        64714 :       CALL section_add_keyword(section, keyword)
    1942        64714 :       CALL keyword_release(keyword)
    1943              : 
    1944              :       CALL keyword_create( &
    1945              :          keyword, __LOCATION__, &
    1946              :          name="DO_EXTRAPOLATE_KPOINTS", &
    1947              :          description="If true, use a larger k-mesh to extrapolate the k-point integration of W. "// &
    1948              :          "For example, in 2D, when using  KPOINTS 4 4 1, an additional 6x6x1 mesh will be used to "// &
    1949              :          "extrapolate the k-point integration of W with N_k^-0.5, where Nk is the number of k-points.", &
    1950              :          usage="DO_EXTRAPOLATE_KPOINTS FALSE", &
    1951              :          default_l_val=.TRUE., &
    1952        64714 :          lone_keyword_l_val=.TRUE.)
    1953        64714 :       CALL section_add_keyword(section, keyword)
    1954        64714 :       CALL keyword_release(keyword)
    1955              : 
    1956              :       CALL keyword_create( &
    1957              :          keyword, __LOCATION__, &
    1958              :          name="TRUNC_COULOMB_RI_X", &
    1959              :          description="If true, use the truncated Coulomb operator for the exchange-self-energy in "// &
    1960              :          "periodic GW.", &
    1961              :          usage="TRUNC_COULOMB_RI_X", &
    1962              :          default_l_val=.TRUE., &
    1963        64714 :          lone_keyword_l_val=.TRUE.)
    1964        64714 :       CALL section_add_keyword(section, keyword)
    1965        64714 :       CALL keyword_release(keyword)
    1966              : 
    1967              :       CALL keyword_create( &
    1968              :          keyword, __LOCATION__, &
    1969              :          name="REL_CUTOFF_TRUNC_COULOMB_RI_X", &
    1970              :          description="Only active in case TRUNC_COULOMB_RI_X = True. Normally, relative cutoff = 0.5 is "// &
    1971              :          "good choice; still needs to be evaluated for RI schemes. ", &
    1972              :          usage="REL_CUTOFF_TRUNC_COULOMB_RI_X 0.3", &
    1973        64714 :          default_r_val=0.5_dp)
    1974        64714 :       CALL section_add_keyword(section, keyword)
    1975        64714 :       CALL keyword_release(keyword)
    1976              : 
    1977              :       CALL keyword_create( &
    1978              :          keyword, __LOCATION__, &
    1979              :          name="KEEP_QUADRATURE", &
    1980              :          variants=s2a("KEEP_WEIGHTS", "KEEP_QUAD", "KEEP_WEIGHT"), &
    1981              :          description="Keep the Laplace quadrature defined at the first energy evaluations throughout "// &
    1982              :          "the run. Allows to have consistent force evaluations.", &
    1983              :          usage="KEEP_QUADRATURE", &
    1984              :          default_l_val=.TRUE., &
    1985        64714 :          lone_keyword_l_val=.TRUE.)
    1986        64714 :       CALL section_add_keyword(section, keyword)
    1987        64714 :       CALL keyword_release(keyword)
    1988              : 
    1989              :       CALL keyword_create( &
    1990              :          keyword, __LOCATION__, &
    1991              :          name="K_MESH_G_FACTOR", &
    1992              :          description="The k-mesh for the Green's function can be chosen to be larger than the k-mesh for "// &
    1993              :          "W (without much higher computational cost). The factor given here multiplies the mesh for W to obtain "// &
    1994              :          "the k-mesh for G. Example: factor 4, k-mesh for W: 4x4x1 -> k-mesh for G: 16x16x1 (z-dir. is "// &
    1995              :          "non-periodic).", &
    1996        64714 :          default_i_val=1)
    1997        64714 :       CALL section_add_keyword(section, keyword)
    1998        64714 :       CALL keyword_release(keyword)
    1999              : 
    2000              :       CALL keyword_create( &
    2001              :          keyword, __LOCATION__, &
    2002              :          name="MIN_BLOCK_SIZE", &
    2003              :          description="Minimum tensor block size. Adjusting this value may have minor effect on "// &
    2004              :          "performance but default should be good enough.", &
    2005        64714 :          default_i_val=5)
    2006        64714 :       CALL section_add_keyword(section, keyword)
    2007        64714 :       CALL keyword_release(keyword)
    2008              : 
    2009              :       CALL keyword_create( &
    2010              :          keyword, __LOCATION__, &
    2011              :          name="MIN_BLOCK_SIZE_MO", &
    2012              :          description="Tensor block size for MOs. Only relevant for GW calculations. "// &
    2013              :          "The memory consumption of GW scales as O(MIN_BLOCK_SIZE_MO). It is recommended to "// &
    2014              :          "set this parameter to a smaller number if GW runs out of memory. "// &
    2015              :          "Otherwise the default should not be changed.", &
    2016        64714 :          default_i_val=64)
    2017        64714 :       CALL section_add_keyword(section, keyword)
    2018        64714 :       CALL keyword_release(keyword)
    2019              : 
    2020        64714 :       NULLIFY (subsection)
    2021        64714 :       CALL create_low_scaling_cphf(subsection)
    2022        64714 :       CALL section_add_subsection(section, subsection)
    2023        64714 :       CALL section_release(subsection)
    2024              : 
    2025        64714 :    END SUBROUTINE
    2026              : 
    2027              : ! **************************************************************************************************
    2028              : !> \brief ...
    2029              : !> \param section ...
    2030              : ! **************************************************************************************************
    2031        64714 :    SUBROUTINE create_wfc_gpw(section)
    2032              :       TYPE(section_type), POINTER                        :: section
    2033              : 
    2034              :       TYPE(keyword_type), POINTER                        :: keyword
    2035              : 
    2036        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2037              :       CALL section_create(section, __LOCATION__, name="WFC_GPW", &
    2038              :                           description="Parameters for the GPW approach in Wavefunction-based Correlation methods", &
    2039        64714 :                           n_keywords=5, n_subsections=0, repeats=.FALSE.)
    2040              : 
    2041        64714 :       NULLIFY (keyword)
    2042              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_GRID", &
    2043              :                           description="Determines a threshold for the GPW based integration", &
    2044              :                           usage="EPS_GRID 1.0E-9 ", type_of_var=real_t, &
    2045        64714 :                           default_r_val=1.0E-8_dp)
    2046        64714 :       CALL section_add_keyword(section, keyword)
    2047        64714 :       CALL keyword_release(keyword)
    2048              : 
    2049              :       CALL keyword_create( &
    2050              :          keyword, __LOCATION__, name="EPS_FILTER", &
    2051              :          description="Determines a threshold for the DBCSR based multiply (usually 10 times smaller than EPS_GRID). "// &
    2052              :          "Normally, this EPS_FILTER determines accuracy and timing of cubic-scaling RPA calculation.", &
    2053              :          usage="EPS_FILTER 1.0E-10 ", type_of_var=real_t, &
    2054        64714 :          default_r_val=1.0E-9_dp)
    2055        64714 :       CALL section_add_keyword(section, keyword)
    2056        64714 :       CALL keyword_release(keyword)
    2057              : 
    2058              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF", &
    2059              :                           description="The cutoff of the finest grid level in the MP2 gpw integration.", &
    2060              :                           usage="CUTOFF 300", type_of_var=real_t, &
    2061        64714 :                           default_r_val=300.0_dp)
    2062        64714 :       CALL section_add_keyword(section, keyword)
    2063        64714 :       CALL keyword_release(keyword)
    2064              : 
    2065              :       CALL keyword_create(keyword, __LOCATION__, name="REL_CUTOFF", &
    2066              :                           variants=(/"RELATIVE_CUTOFF"/), &
    2067              :                           description="Determines the grid at which a Gaussian is mapped.", &
    2068              :                           usage="REL_CUTOFF 50", type_of_var=real_t, &
    2069       129428 :                           default_r_val=50.0_dp)
    2070        64714 :       CALL section_add_keyword(section, keyword)
    2071        64714 :       CALL keyword_release(keyword)
    2072              : 
    2073              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_LEVEL", &
    2074              :                           variants=(/"IOLEVEL"/), &
    2075              :                           description="How much output is written by the individual groups.", &
    2076              :                           usage="PRINT_LEVEL HIGH", &
    2077              :                           default_i_val=silent_print_level, enum_c_vals= &
    2078              :                           s2a("SILENT", "LOW", "MEDIUM", "HIGH", "DEBUG"), &
    2079              :                           enum_desc=s2a("Almost no output", &
    2080              :                                         "Little output", "Quite some output", "Lots of output", &
    2081              :                                         "Everything is written out, useful for debugging purposes only"), &
    2082              :                           enum_i_vals=(/silent_print_level, low_print_level, medium_print_level, &
    2083       129428 :                                         high_print_level, debug_print_level/))
    2084        64714 :       CALL section_add_keyword(section, keyword)
    2085        64714 :       CALL keyword_release(keyword)
    2086              : 
    2087              :       CALL keyword_create( &
    2088              :          keyword, __LOCATION__, name="EPS_PGF_ORB_S", &
    2089              :          description="Screening for overlap matrix in RI. Usually, it is best to choose this parameter "// &
    2090              :          "to be very small since the inversion of overlap matrix might be ill-conditioned.", &
    2091              :          usage="EPS_PGF_ORB_S 1.0E-10 ", type_of_var=real_t, &
    2092        64714 :          default_r_val=1.0E-10_dp)
    2093        64714 :       CALL section_add_keyword(section, keyword)
    2094        64714 :       CALL keyword_release(keyword)
    2095              : 
    2096        64714 :    END SUBROUTINE create_wfc_gpw
    2097              : 
    2098              : ! **************************************************************************************************
    2099              : !> \brief ...
    2100              : !> \param section ...
    2101              : ! **************************************************************************************************
    2102        64714 :    SUBROUTINE create_cphf(section)
    2103              :       TYPE(section_type), POINTER                        :: section
    2104              : 
    2105              :       TYPE(keyword_type), POINTER                        :: keyword
    2106              : 
    2107        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2108              :       CALL section_create( &
    2109              :          section, __LOCATION__, name="CPHF", &
    2110              :          description="Parameters influencing the solution of the Z-vector equations in MP2 gradients calculations.", &
    2111              :          n_keywords=2, n_subsections=0, repeats=.FALSE., &
    2112       129428 :          citations=(/DelBen2013/))
    2113              : 
    2114        64714 :       NULLIFY (keyword)
    2115              : 
    2116              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
    2117              :                           variants=(/"MAX_NUM_ITER"/), &
    2118              :                           description="Maximum number of iterations allowed for the solution of the Z-vector equations.", &
    2119              :                           usage="MAX_ITER  50", &
    2120       129428 :                           default_i_val=30)
    2121        64714 :       CALL section_add_keyword(section, keyword)
    2122        64714 :       CALL keyword_release(keyword)
    2123              : 
    2124              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_EVERY", &
    2125              :                           description="Restart iteration every given number of steps.", &
    2126              :                           usage="RESTART_EVERY 5", &
    2127        64714 :                           default_i_val=5)
    2128        64714 :       CALL section_add_keyword(section, keyword)
    2129        64714 :       CALL keyword_release(keyword)
    2130              : 
    2131              :       CALL keyword_create(keyword, __LOCATION__, name="SOLVER_METHOD", &
    2132              :                           description="Chose solver of the z-vector equations.", &
    2133              :                           usage="SOLVER_METHOD POPLE", enum_c_vals= &
    2134              :                           s2a("POPLE", "CG", "RICHARDSON", "SD"), &
    2135              :                           enum_desc=s2a("Pople's method (Default).", &
    2136              :                                         "Conjugated gradient method (equivalent to Pople).", &
    2137              :                                         "Richardson iteration", &
    2138              :                                         "Steepest Descent iteration"), &
    2139              :                           enum_i_vals=(/z_solver_pople, z_solver_cg, z_solver_richardson, z_solver_sd/), &
    2140        64714 :                           default_i_val=z_solver_pople)
    2141        64714 :       CALL section_add_keyword(section, keyword)
    2142        64714 :       CALL keyword_release(keyword)
    2143              : 
    2144              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_CONV", &
    2145              :                           description="Convergence threshold for the solution of the Z-vector equations. "// &
    2146              :                           "The Z-vector equations have the form of a linear system of equations Ax=b, "// &
    2147              :                           "convergence is achieved when |Ax-b|<=EPS_CONV.", &
    2148              :                           usage="EPS_CONV 1.0E-6", type_of_var=real_t, &
    2149        64714 :                           default_r_val=1.0E-4_dp)
    2150        64714 :       CALL section_add_keyword(section, keyword)
    2151        64714 :       CALL keyword_release(keyword)
    2152              : 
    2153              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_STEP_SIZE", &
    2154              :                           description="Scaling factor of each step.", &
    2155              :                           usage="SCALE_STEP_SIZE 1.0", &
    2156        64714 :                           default_r_val=1.0_dp)
    2157        64714 :       CALL section_add_keyword(section, keyword)
    2158        64714 :       CALL keyword_release(keyword)
    2159              : 
    2160              :       CALL keyword_create(keyword, __LOCATION__, name="ENFORCE_DECREASE", &
    2161              :                           description="Restarts if residual does not decrease.", &
    2162              :                           usage="ENFORCE_DECREASE T", &
    2163              :                           lone_keyword_l_val=.TRUE., &
    2164        64714 :                           default_l_val=.FALSE.)
    2165        64714 :       CALL section_add_keyword(section, keyword)
    2166        64714 :       CALL keyword_release(keyword)
    2167              : 
    2168              :       CALL keyword_create(keyword, __LOCATION__, name="DO_POLAK_RIBIERE", &
    2169              :                           description="Use a Polak-Ribiere update of the search vector in CG instead of the Fletcher "// &
    2170              :                           "Reeves update. Improves the convergence with modified step sizes. "// &
    2171              :                           "Ignored with other methods than CG.", &
    2172              :                           usage="DO_POLAK_RIBIERE T", &
    2173              :                           lone_keyword_l_val=.TRUE., &
    2174        64714 :                           default_l_val=.FALSE.)
    2175        64714 :       CALL section_add_keyword(section, keyword)
    2176        64714 :       CALL keyword_release(keyword)
    2177              : 
    2178              :       CALL keyword_create(keyword, __LOCATION__, name="RECALC_RESIDUAL", &
    2179              :                           description="Recalculates residual in every step.", &
    2180              :                           usage="RECALC_RESIDUAL T", &
    2181              :                           lone_keyword_l_val=.TRUE., &
    2182        64714 :                           default_l_val=.FALSE.)
    2183        64714 :       CALL section_add_keyword(section, keyword)
    2184        64714 :       CALL keyword_release(keyword)
    2185              : 
    2186        64714 :    END SUBROUTINE create_cphf
    2187              : 
    2188              : ! **************************************************************************************************
    2189              : !> \brief ...
    2190              : !> \param section ...
    2191              : ! **************************************************************************************************
    2192        64714 :    SUBROUTINE create_low_scaling_cphf(section)
    2193              :       TYPE(section_type), POINTER                        :: section
    2194              : 
    2195              :       TYPE(keyword_type), POINTER                        :: keyword
    2196              : 
    2197        64714 :       NULLIFY (keyword)
    2198              : 
    2199        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2200              :       CALL section_create(section, __LOCATION__, name="CPHF", &
    2201              :                           description="Parameters influencing the solution of the Z-vector equations "// &
    2202              :                           "in low-scaling Laplace-SOS-MP2 gradients calculations.", &
    2203        64714 :                           n_keywords=5, n_subsections=0, repeats=.FALSE.)
    2204              : 
    2205              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_CONV", &
    2206              :                           description="Target accuracy for Z-vector euation solution.", &
    2207        64714 :                           usage="EPS_CONV 1.e-6", default_r_val=1.e-6_dp)
    2208        64714 :       CALL section_add_keyword(section, keyword)
    2209        64714 :       CALL keyword_release(keyword)
    2210              : 
    2211              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
    2212              :                           description="Maximum number of conjugate gradient iteration to be performed for one optimization.", &
    2213        64714 :                           usage="MAX_ITER 200", default_i_val=50)
    2214        64714 :       CALL section_add_keyword(section, keyword)
    2215        64714 :       CALL keyword_release(keyword)
    2216              : 
    2217              :       CALL keyword_create( &
    2218              :          keyword, __LOCATION__, name="PRECONDITIONER", &
    2219              :          description="Type of preconditioner to be used with all minimization schemes. "// &
    2220              :          "They differ in effectiveness, cost of construction, cost of application. "// &
    2221              :          "Properly preconditioned minimization can be orders of magnitude faster than doing nothing.", &
    2222              :          usage="PRECONDITIONER FULL_ALL", &
    2223              :          default_i_val=ot_precond_full_all, &
    2224              :          enum_c_vals=s2a("FULL_ALL", "FULL_SINGLE_INVERSE", "FULL_SINGLE", "FULL_KINETIC", "FULL_S_INVERSE", &
    2225              :                          "NONE"), &
    2226              :          enum_desc=s2a("Most effective state selective preconditioner based on diagonalization, "// &
    2227              :                        "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
    2228              :                        "This preconditioner is recommended for almost all systems, except very large systems where "// &
    2229              :                        "make_preconditioner would dominate the total computational cost.", &
    2230              :                        "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
    2231              :                        "but cheaper to construct, "// &
    2232              :                        "might be somewhat less robust. Recommended for large systems.", &
    2233              :                        "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
    2234              :                        "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
    2235              :                        "use for very large systems.", &
    2236              :                        "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
    2237              :                        "skip preconditioning"), &
    2238              :          enum_i_vals=(/ot_precond_full_all, ot_precond_full_single_inverse, ot_precond_full_single, &
    2239        64714 :                        ot_precond_full_kinetic, ot_precond_s_inverse, ot_precond_none/))
    2240        64714 :       CALL section_add_keyword(section, keyword)
    2241        64714 :       CALL keyword_release(keyword)
    2242              : 
    2243              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_GAP", &
    2244              :                           description="Energy gap estimate [a.u.] for preconditioning", &
    2245              :                           usage="ENERGY_GAP 0.1", &
    2246        64714 :                           default_r_val=0.2_dp)
    2247        64714 :       CALL section_add_keyword(section, keyword)
    2248        64714 :       CALL keyword_release(keyword)
    2249              : 
    2250        64714 :    END SUBROUTINE create_low_scaling_cphf
    2251              : 
    2252              : ! **************************************************************************************************
    2253              : !> \brief ...
    2254              : !> \param section ...
    2255              : ! **************************************************************************************************
    2256        64714 :    SUBROUTINE create_mp2_potential(section)
    2257              :       TYPE(section_type), POINTER                        :: section
    2258              : 
    2259              :       TYPE(keyword_type), POINTER                        :: keyword
    2260              : 
    2261        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2262              :       CALL section_create(section, __LOCATION__, name="INTERACTION_POTENTIAL", &
    2263              :                           description="Parameters the interaction potential in computing the biel integrals", &
    2264        64714 :                           n_keywords=4, n_subsections=0, repeats=.FALSE.)
    2265              : 
    2266        64714 :       NULLIFY (keyword)
    2267              :       CALL keyword_create( &
    2268              :          keyword, __LOCATION__, &
    2269              :          name="POTENTIAL_TYPE", &
    2270              :          description="Which interaction potential should be used "// &
    2271              :          "(Coulomb, TShPSC operator).", &
    2272              :          usage="POTENTIAL_TYPE TSHPSC", &
    2273              :          enum_c_vals=s2a("COULOMB", "TShPSC", "LONGRANGE", "SHORTRANGE", "TRUNCATED", "MIX_CL", "IDENTITY"), &
    2274              :          enum_i_vals=(/do_potential_coulomb, &
    2275              :                        do_potential_TShPSC, &
    2276              :                        do_potential_long, &
    2277              :                        do_potential_short, &
    2278              :                        do_potential_truncated, &
    2279              :                        do_potential_mix_cl, &
    2280              :                        do_potential_id/), &
    2281              :          enum_desc=s2a("Coulomb potential: 1/r", &
    2282              :                        "| Range | TShPSC |"//newline// &
    2283              :                        "| ----- | ------ |"//newline// &
    2284              :                        "| $ x \leq R_c $ | $ 1/x - s/R_c $ |"//newline// &
    2285              :                        "| $ R_c < x \leq nR_c $ | "// &
    2286              :                        "$ (1 - s)/R_c - (x - R_c)/R_c^2 + (x - R_c)^2/R_c^3 - "// &
    2287              :                        "(2n^2 - 7n + 9 - 4s)(x - R_c)^3/(R_c^4(n^2 - 2n + 1)(n - 1)) + "// &
    2288              :                        "(6-3s - 4n + n^2)(x - R_c)^4/(R_c^5(n^4 - 4n^3 + 6n^2 - 4n + 1)) $ "// &
    2289              :                        "(4th order polynomial) | "//newline// &
    2290              :                        "| $ x > nR_c $ | $ 0 $ | "//newline, &
    2291              :                        "Longrange Coulomb potential: $ \operatorname{erf}(wr)/r $", &
    2292              :                        "Shortrange Coulomb potential: $ \operatorname{erfc}(wr)/r $", &
    2293              :                        "Truncated Coulomb potential", &
    2294              :                        "Mixed Coulomb/Longrange Coulomb potential", &
    2295              :                        "Delta potential"), &
    2296        64714 :          default_i_val=do_potential_coulomb)
    2297        64714 :       CALL section_add_keyword(section, keyword)
    2298        64714 :       CALL keyword_release(keyword)
    2299              : 
    2300              :       CALL keyword_create(keyword, __LOCATION__, name="TRUNCATION_RADIUS", &
    2301              :                           variants=(/"CUTOFF_RADIUS"/), &
    2302              :                           description="Determines truncation radius for the truncated potentials. "// &
    2303              :                           "Only valid when doing truncated calculations", &
    2304              :                           usage="TRUNCATION_RADIUS 10.0", type_of_var=real_t, &
    2305              :                           default_r_val=10.0_dp, &
    2306       129428 :                           unit_str="angstrom")
    2307        64714 :       CALL section_add_keyword(section, keyword)
    2308        64714 :       CALL keyword_release(keyword)
    2309              : 
    2310              :       CALL keyword_create( &
    2311              :          keyword, __LOCATION__, &
    2312              :          name="POTENTIAL_DATA", &
    2313              :          variants=s2a("TShPSC_DATA", "T_C_G_DATA"), &
    2314              :          description="Location of the file TShPSC.dat or t_c_g.dat that contains the data for the "// &
    2315              :          "evaluation of the evaluation of the truncated potentials", &
    2316              :          usage="TShPSC_DATA t_sh_p_s_c.dat", &
    2317        64714 :          default_c_val="t_sh_p_s_c.dat")
    2318        64714 :       CALL section_add_keyword(section, keyword)
    2319        64714 :       CALL keyword_release(keyword)
    2320              : 
    2321              :       CALL keyword_create( &
    2322              :          keyword, __LOCATION__, &
    2323              :          name="OMEGA", &
    2324              :          description="Range separation parameter for the longrange or shortrange potential. "// &
    2325              :          "Only valid when longrange or shortrange potential is requested.", &
    2326              :          usage="OMEGA 0.5", type_of_var=real_t, &
    2327        64714 :          default_r_val=0.5_dp)
    2328        64714 :       CALL section_add_keyword(section, keyword)
    2329        64714 :       CALL keyword_release(keyword)
    2330              : 
    2331              :       CALL keyword_create( &
    2332              :          keyword, __LOCATION__, &
    2333              :          name="SCALE_COULOMB", &
    2334              :          description="Scaling factor of (truncated) Coulomb potential in mixed (truncated) Coulomb/Longrange potential. "// &
    2335              :          "Only valid when mixed potential is requested.", &
    2336              :          usage="SCALE_COULOMB 0.5", type_of_var=real_t, &
    2337        64714 :          default_r_val=1.0_dp)
    2338        64714 :       CALL section_add_keyword(section, keyword)
    2339        64714 :       CALL keyword_release(keyword)
    2340              : 
    2341              :       CALL keyword_create( &
    2342              :          keyword, __LOCATION__, &
    2343              :          name="SCALE_LONGRANGE", &
    2344              :          description="Scaling factor of longrange Coulomb potential in mixed (truncated) Coulomb/Longrange potential. "// &
    2345              :          "Only valid when mixed potential is requested.", &
    2346              :          usage="SCALE_LONGRANGE 0.5", type_of_var=real_t, &
    2347        64714 :          default_r_val=1.0_dp)
    2348        64714 :       CALL section_add_keyword(section, keyword)
    2349        64714 :       CALL keyword_release(keyword)
    2350              : 
    2351        64714 :    END SUBROUTINE create_mp2_potential
    2352              : 
    2353              : ! **************************************************************************************************
    2354              : !> \brief ...
    2355              : !> \param section ...
    2356              : ! **************************************************************************************************
    2357        64714 :    SUBROUTINE create_ri_section(section)
    2358              :       TYPE(section_type), POINTER                        :: section
    2359              : 
    2360              :       TYPE(keyword_type), POINTER                        :: keyword
    2361              :       TYPE(section_type), POINTER                        :: subsection
    2362              : 
    2363        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2364              :       CALL section_create(section, __LOCATION__, name="RI", &
    2365              :                           description="Parameters influencing resolution of the identity (RI) that is "// &
    2366              :                           "used in RI-MP2, RI-RPA, RI-SOS-MP2 and GW (inside RI-RPA).", &
    2367        64714 :                           n_keywords=6, n_subsections=2, repeats=.FALSE.)
    2368              : 
    2369        64714 :       NULLIFY (subsection)
    2370        64714 :       CALL create_RI_metric_section(subsection)
    2371        64714 :       CALL section_add_subsection(section, subsection)
    2372        64714 :       CALL section_release(subsection)
    2373              : 
    2374        64714 :       CALL create_opt_ri_basis(subsection)
    2375        64714 :       CALL section_add_subsection(section, subsection)
    2376        64714 :       CALL section_release(subsection)
    2377              : 
    2378        64714 :       NULLIFY (keyword)
    2379              :       CALL keyword_create( &
    2380              :          keyword, __LOCATION__, &
    2381              :          name="ROW_BLOCK", &
    2382              :          variants=(/"ROW_BLOCK_SIZE"/), &
    2383              :          description="Size of the row block used in the SCALAPACK block cyclic data distribution. "// &
    2384              :          "Default is (ROW_BLOCK=-1) is automatic. "// &
    2385              :          "A proper choice can speedup the parallel matrix multiplication in the case of RI-RPA and RI-SOS-MP2-Laplace.", &
    2386              :          usage="ROW_BLOCK 512", &
    2387       129428 :          default_i_val=-1)
    2388        64714 :       CALL section_add_keyword(section, keyword)
    2389        64714 :       CALL keyword_release(keyword)
    2390              : 
    2391              :       CALL keyword_create( &
    2392              :          keyword, __LOCATION__, &
    2393              :          name="COL_BLOCK", &
    2394              :          variants=(/"COL_BLOCK_SIZE"/), &
    2395              :          description="Size of the column block used in the SCALAPACK block cyclic data distribution. "// &
    2396              :          "Default is (COL_BLOCK=-1) is automatic. "// &
    2397              :          "A proper choice can speedup the parallel matrix multiplication in the case of RI-RPA and RI-SOS-MP2-Laplace.", &
    2398              :          usage="COL_BLOCK 512", &
    2399       129428 :          default_i_val=-1)
    2400        64714 :       CALL section_add_keyword(section, keyword)
    2401        64714 :       CALL keyword_release(keyword)
    2402              : 
    2403              :       CALL keyword_create( &
    2404              :          keyword, __LOCATION__, &
    2405              :          name="CALC_COND_NUM", &
    2406              :          variants=(/"CALC_CONDITION_NUMBER"/), &
    2407              :          description="Calculate the condition number of the (P|Q) matrix for the RI methods.", &
    2408              :          usage="CALC_COND_NUM", &
    2409              :          default_l_val=.FALSE., &
    2410       129428 :          lone_keyword_l_val=.TRUE.)
    2411        64714 :       CALL section_add_keyword(section, keyword)
    2412        64714 :       CALL keyword_release(keyword)
    2413              : 
    2414              :       CALL keyword_create(keyword, __LOCATION__, name="DO_SVD", &
    2415              :                           description="Wether to perform a singular value decomposition instead of the Cholesky decomposition "// &
    2416              :                           "of the potential operator in the RI basis. Computationally expensive but numerically more stable. "// &
    2417              :                           "It reduces the computational costs of some subsequent steps. Recommended when a longrange Coulomb "// &
    2418              :                           "potential is employed.", &
    2419              :                           usage="DO_SVD  .TRUE.", &
    2420        64714 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2421        64714 :       CALL section_add_keyword(section, keyword)
    2422        64714 :       CALL keyword_release(keyword)
    2423              : 
    2424              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_SVD", &
    2425              :                           description="Determines the upper bound of eigenvectors to be removed during the SVD (see DO_SVD).", &
    2426              :                           usage="EPS_SVD  1E-5", &
    2427        64714 :                           default_r_val=0.0_dp)
    2428        64714 :       CALL section_add_keyword(section, keyword)
    2429        64714 :       CALL keyword_release(keyword)
    2430              : 
    2431              :       CALL keyword_create(keyword, __LOCATION__, name="ERI_BLKSIZE", &
    2432              :                           description="block sizes for tensors (only used if ERI_METHOD=MME). First value "// &
    2433              :                           "is the block size for ORB basis, second value is the block size for RI_AUX basis.", &
    2434              :                           usage="ERI_BLKSIZE", &
    2435              :                           n_var=2, &
    2436        64714 :                           default_i_vals=(/4, 16/))
    2437        64714 :       CALL section_add_keyword(section, keyword)
    2438        64714 :       CALL keyword_release(keyword)
    2439              : 
    2440        64714 :    END SUBROUTINE create_ri_section
    2441              : 
    2442              : ! **************************************************************************************************
    2443              : !> \brief ...
    2444              : !> \param section ...
    2445              : ! **************************************************************************************************
    2446        64714 :    SUBROUTINE create_integrals_section(section)
    2447              :       TYPE(section_type), POINTER                        :: section
    2448              : 
    2449              :       TYPE(keyword_type), POINTER                        :: keyword
    2450              :       TYPE(section_type), POINTER                        :: subsection
    2451              : 
    2452        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2453              :       CALL section_create(section, __LOCATION__, name="INTEGRALS", &
    2454              :                           description="Parameters controlling how to compute integrals that are needed "// &
    2455              :                           "in MP2, RI-MP2, RI-RPA, RI-SOS-MP2 and GW (inside RI-RPA).", &
    2456        64714 :                           n_keywords=2, n_subsections=3, repeats=.FALSE.)
    2457              : 
    2458        64714 :       NULLIFY (subsection)
    2459        64714 :       CALL create_eri_mme_section(subsection)
    2460        64714 :       CALL section_add_subsection(section, subsection)
    2461        64714 :       CALL section_release(subsection)
    2462              : 
    2463        64714 :       CALL create_wfc_gpw(subsection)
    2464        64714 :       CALL section_add_subsection(section, subsection)
    2465        64714 :       CALL section_release(subsection)
    2466              : 
    2467        64714 :       CALL create_mp2_potential(subsection)
    2468        64714 :       CALL section_add_subsection(section, subsection)
    2469        64714 :       CALL section_release(subsection)
    2470              : 
    2471        64714 :       NULLIFY (keyword)
    2472              :       CALL keyword_create(keyword, __LOCATION__, name="ERI_METHOD", &
    2473              :                           description="Method for calculating periodic electron repulsion integrals "// &
    2474              :                           "(MME method is faster but experimental, forces not yet implemented). "// &
    2475              :                           "Obara-Saika (OS) for the Coulomb operator can only be used for non-periodic calculations.", &
    2476              :                           usage="ERI_METHOD MME", &
    2477              :                           enum_c_vals=s2a("DEFAULT", "GPW", "MME", "OS"), &
    2478              :                           enum_i_vals=(/eri_default, do_eri_gpw, do_eri_mme, do_eri_os/), &
    2479              :                           enum_desc=s2a("Use default ERI method (for periodic systems: GPW, for molecules: OS, "// &
    2480              :                                         "for MP2 and RI-MP2: GPW in any case).", &
    2481              :                                         "Uses Gaussian Plane Wave method [DelBen2013].", &
    2482              :                                         "Uses MiniMax-Ewald method (experimental, ERI_MME subsection, only for fully periodic "// &
    2483              :                                         "systems with orthorhombic cells).", &
    2484              :                                         "Use analytical Obara-Saika method."), &
    2485        64714 :                           default_i_val=eri_default)
    2486        64714 :       CALL section_add_keyword(section, keyword)
    2487        64714 :       CALL keyword_release(keyword)
    2488              : 
    2489              :       CALL keyword_create(keyword, __LOCATION__, name="SIZE_LATTICE_SUM", &
    2490              :                           description="Size of sum range L. ", &
    2491              :                           usage="SIZE_LATTICE_SUM  10", &
    2492        64714 :                           default_i_val=5)
    2493        64714 :       CALL section_add_keyword(section, keyword)
    2494        64714 :       CALL keyword_release(keyword)
    2495              : 
    2496        64714 :    END SUBROUTINE create_integrals_section
    2497              : 
    2498              : ! **************************************************************************************************
    2499              : !> \brief ...
    2500              : !> \param section ...
    2501              : ! **************************************************************************************************
    2502        64714 :    SUBROUTINE create_RI_metric_section(section)
    2503              :       TYPE(section_type), POINTER                        :: section
    2504              : 
    2505              :       TYPE(keyword_type), POINTER                        :: keyword
    2506              : 
    2507        64714 :       CPASSERT(.NOT. ASSOCIATED(section))
    2508              :       CALL section_create(section, __LOCATION__, name="RI_METRIC", &
    2509              :                           description="Sets up RI metric", &
    2510        64714 :                           repeats=.FALSE.)
    2511              : 
    2512        64714 :       NULLIFY (keyword)
    2513              :       CALL keyword_create( &
    2514              :          keyword, __LOCATION__, &
    2515              :          name="POTENTIAL_TYPE", &
    2516              :          description="Decides which operator/metric is used for resolution of the identity (RI).", &
    2517              :          usage="POTENTIAL_TYPE DEFAULT", &
    2518              :          enum_c_vals=s2a("DEFAULT", "COULOMB", "IDENTITY", "LONGRANGE", "SHORTRANGE", "TRUNCATED"), &
    2519              :          enum_i_vals=(/ri_default, do_potential_coulomb, do_potential_id, do_potential_long, &
    2520              :                        do_potential_short, do_potential_truncated/), &
    2521              :          enum_desc=s2a("Use Coulomb metric for RI-MP2 and normal-scaling RI-SOS-MP2, RI-RPA and GW. "// &
    2522              :                        "Use Overlap metric for low-scaling RI-SOS-MP2, RI-RPA and GW for periodic systems. "// &
    2523              :                        "Use truncated Coulomb metric for low-scaling RI-SOS-MP2, RI-RPA and GW for non-periodic systems.", &
    2524              :                        "Coulomb metric: 1/r. Recommended for RI-MP2,", &
    2525              :                        "Overlap metric: delta(r).", &
    2526              :                        "Longrange metric: erf(omega*r)/r. Not recommended with DO_SVD .TRUE.", &
    2527              :                        "Shortrange metric: erfc(omega*r)/r", &
    2528              :                        "Truncated Coulomb metric: if (r &lt; R_c) 1/r else 0. More "// &
    2529              :                        "accurate than IDENTITY for non-periodic systems. Recommended for low-scaling methods."), &
    2530        64714 :          default_i_val=ri_default)
    2531        64714 :       CALL section_add_keyword(section, keyword)
    2532        64714 :       CALL keyword_release(keyword)
    2533              : 
    2534        64714 :       NULLIFY (keyword)
    2535              :       CALL keyword_create( &
    2536              :          keyword, __LOCATION__, &
    2537              :          name="OMEGA", &
    2538              :          description="The range parameter for the short/long range operator (in 1/a0).", &
    2539              :          usage="OMEGA 0.5", &
    2540        64714 :          default_r_val=0.0_dp)
    2541        64714 :       CALL section_add_keyword(section, keyword)
    2542        64714 :       CALL keyword_release(keyword)
    2543              : 
    2544              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
    2545              :                           description="The cutoff radius (in Angstrom) for the truncated Coulomb operator.", &
    2546              :                           usage="CUTOFF_RADIUS 3.0", default_r_val=cp_unit_to_cp2k(value=3.0_dp, unit_str="angstrom"), &
    2547        64714 :                           type_of_var=real_t, unit_str="angstrom")
    2548        64714 :       CALL section_add_keyword(section, keyword)
    2549        64714 :       CALL keyword_release(keyword)
    2550              : 
    2551              :       CALL keyword_create( &
    2552              :          keyword, __LOCATION__, &
    2553              :          name="T_C_G_DATA", &
    2554              :          description="Location of the file t_c_g.dat that contains the data for the "// &
    2555              :          "evaluation of the truncated gamma function ", &
    2556        64714 :          default_c_val="t_c_g.dat")
    2557        64714 :       CALL section_add_keyword(section, keyword)
    2558        64714 :       CALL keyword_release(keyword)
    2559              : 
    2560              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_RANGE", &
    2561              :                           description="The threshold to determine the effective range of the short range "// &
    2562              :                           "RI metric: erfc(omega*eff_range)/eff_range = EPS_RANGE", &
    2563              :                           default_r_val=1.0E-08_dp, &
    2564        64714 :                           repeats=.FALSE.)
    2565        64714 :       CALL section_add_keyword(section, keyword)
    2566        64714 :       CALL keyword_release(keyword)
    2567              : 
    2568        64714 :    END SUBROUTINE create_RI_metric_section
    2569              : 
    2570              : END MODULE input_cp2k_mp2
        

Generated by: LCOV version 2.0-1