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

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

Generated by: LCOV version 2.0-1