LCOV - code coverage report
Current view: top level - src - input_cp2k_mp2.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 760 760 100.0 %
Date: 2024-11-21 06:45:46 Functions: 24 24 100.0 %

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

Generated by: LCOV version 1.15