1!--------------------------------------------------------------------------------------------------!
2!   CP2K: A general program to perform molecular dynamics simulations                              !
3!   Copyright (C) 2000 - 2020  CP2K developers group                                               !
4!--------------------------------------------------------------------------------------------------!
5
6! **************************************************************************************************
7!> \brief input section for MP2
8!> \par History
9!>      05.2011 created
10!> \author MDB
11! **************************************************************************************************
12MODULE input_cp2k_mp2
13   USE bibliography,                    ONLY: &
14        Bates2013, DelBen2012, DelBen2013, DelBen2015, DelBen2015b, Rybkin2016, Wilhelm2016a, &
15        Wilhelm2016b, Wilhelm2017, Wilhelm2018
16   USE cp_eri_mme_interface,            ONLY: create_eri_mme_section
17   USE cp_output_handling,              ONLY: add_last_numeric,&
18                                              cp_print_key_section_create,&
19                                              debug_print_level,&
20                                              high_print_level,&
21                                              low_print_level,&
22                                              medium_print_level,&
23                                              silent_print_level
24   USE cp_units,                        ONLY: cp_unit_to_cp2k
25   USE input_constants,                 ONLY: &
26        do_eri_gpw, do_eri_mme, do_eri_os, do_potential_coulomb, do_potential_id, &
27        do_potential_long, do_potential_short, do_potential_truncated, do_potential_tshpsc, &
28        eri_default, gaussian, gw_no_print_exx, gw_pade_approx, gw_print_exx, gw_read_exx, &
29        gw_skip_for_regtest, gw_two_pole_model, mp2_method_direct, mp2_method_gpw, &
30        mp2_method_none, numerical, ri_default, ri_rpa_g0w0_crossing_bisection, &
31        ri_rpa_g0w0_crossing_newton, ri_rpa_g0w0_crossing_z_shot, wfc_mm_style_gemm, &
32        wfc_mm_style_syrk
33   USE input_cp2k_hfx,                  ONLY: create_hfx_section
34   USE input_keyword_types,             ONLY: keyword_create,&
35                                              keyword_release,&
36                                              keyword_type
37   USE input_section_types,             ONLY: section_add_keyword,&
38                                              section_add_subsection,&
39                                              section_create,&
40                                              section_release,&
41                                              section_type
42   USE input_val_types,                 ONLY: integer_t,&
43                                              real_t
44   USE kinds,                           ONLY: dp
45   USE string_utilities,                ONLY: s2a
46#include "./base/base_uses.f90"
47
48   IMPLICIT NONE
49   PRIVATE
50
51   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_mp2'
52
53   PUBLIC :: create_mp2_section
54
55CONTAINS
56
57! **************************************************************************************************
58!> \brief creates the input section for the mp2 part
59!> \param section the section to create
60!> \author MDB
61! **************************************************************************************************
62   SUBROUTINE create_mp2_section(section)
63      TYPE(section_type), POINTER                        :: section
64
65      CHARACTER(len=*), PARAMETER :: routineN = 'create_mp2_section', &
66         routineP = moduleN//':'//routineN
67
68      TYPE(keyword_type), POINTER                        :: keyword
69      TYPE(section_type), POINTER                        :: subsection
70
71      CPASSERT(.NOT. ASSOCIATED(section))
72      CALL section_create(section, __LOCATION__, name="WF_CORRELATION", &
73                          description="Sets up the wavefunction-based correlation methods as MP2, "// &
74                          "RI-MP2, RI-SOS-MP2, RI-RPA and GW (inside RI-RPA). ", &
75                          n_keywords=4, n_subsections=7, repeats=.TRUE., &
76                          citations=(/DelBen2012, DelBen2013, DelBen2015, DelBen2015b, Rybkin2016, &
77                                      Wilhelm2016a, Wilhelm2016b, Wilhelm2017, Wilhelm2018/))
78
79      NULLIFY (keyword, subsection)
80
81      CALL keyword_create( &
82         keyword, __LOCATION__, &
83         name="MEMORY", &
84         description="Maximum allowed total memory usage during MP2 methods [MiB].", &
85         usage="MEMORY 1500 ", &
86         default_r_val=1.024E+3_dp)
87      CALL section_add_keyword(section, keyword)
88      CALL keyword_release(keyword)
89
90      CALL keyword_create( &
91         keyword, __LOCATION__, &
92         name="SCALE_S", &
93         description="Scaling factor of the singlet energy component (opposite spin, OS) of the "// &
94         "MP2, RI-MP2 and SOS-MP2 correlation energy. ", &
95         usage="SCALE_S  1.0", &
96         default_r_val=1.0_dp)
97      CALL section_add_keyword(section, keyword)
98      CALL keyword_release(keyword)
99
100      CALL keyword_create( &
101         keyword, __LOCATION__, &
102         name="SCALE_T", &
103         description="Scaling factor of the triplet energy component (same spin, SS) of the MP2 "// &
104         "and RI-MP2 correlation energy.", &
105         usage="SCALE_T  1.0", &
106         default_r_val=1.0_dp)
107      CALL section_add_keyword(section, keyword)
108      CALL keyword_release(keyword)
109
110      CALL keyword_create( &
111         keyword, __LOCATION__, &
112         name="GROUP_SIZE", &
113         variants=(/"NUMBER_PROC"/), &
114         description="Group size used in the computation of GPW and MME integrals and the MP2 correlation energy. "// &
115         "A smaller GROUP_SIZE (for example GROUP_SIZE = number of MPI ranks per node) "// &
116         "accelerates the computation of integrals but a too small "// &
117         "GROUP_SIZE may lead to out of memory. To use all processors set GROUP_SIZE -1 "// &
118         "(might lead to VERY high computation times).", &
119         usage="GROUP_SIZE 32", &
120         default_i_val=1)
121      CALL section_add_keyword(section, keyword)
122      CALL keyword_release(keyword)
123
124      NULLIFY (subsection)
125      CALL create_mp2_details_section(subsection)
126      CALL section_add_subsection(section, subsection)
127      CALL section_release(subsection)
128
129      CALL create_ri_mp2(subsection)
130      CALL section_add_subsection(section, subsection)
131      CALL section_release(subsection)
132
133      CALL create_ri_rpa(subsection)
134      CALL section_add_subsection(section, subsection)
135      CALL section_release(subsection)
136
137      CALL create_ri_laplace(subsection)
138      CALL section_add_subsection(section, subsection)
139      CALL section_release(subsection)
140
141      ! here we generate an imag. time subsection to use with RPA or Laplace-SOS-MP2
142      CALL create_low_scaling(subsection)
143      CALL section_add_subsection(section, subsection)
144      CALL section_release(subsection)
145
146      CALL create_ri_section(subsection)
147      CALL section_add_subsection(section, subsection)
148      CALL section_release(subsection)
149
150      CALL create_integrals_section(subsection)
151      CALL section_add_subsection(section, subsection)
152      CALL section_release(subsection)
153
154   END SUBROUTINE create_mp2_section
155
156! **************************************************************************************************
157!> \brief ...
158!> \param section ...
159! **************************************************************************************************
160   SUBROUTINE create_mp2_details_section(section)
161      TYPE(section_type), POINTER                        :: section
162
163      CHARACTER(len=*), PARAMETER :: routineN = 'create_mp2_details_section', &
164         routineP = moduleN//':'//routineN
165
166      TYPE(keyword_type), POINTER                        :: keyword
167      TYPE(section_type), POINTER                        :: print_key
168
169      CPASSERT(.NOT. ASSOCIATED(section))
170      CALL section_create(section, __LOCATION__, name="MP2", &
171                          description="Parameters influencing MP2 (non-RI).", &
172                          n_keywords=3, n_subsections=0, repeats=.FALSE.)
173
174      NULLIFY (keyword)
175      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
176                          description="Activates MP2 calculations.", &
177                          usage="&MP2 .TRUE.", &
178                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
179      CALL section_add_keyword(section, keyword)
180      CALL keyword_release(keyword)
181
182      CALL keyword_create( &
183         keyword, __LOCATION__, &
184         name="METHOD", &
185         citations=(/DelBen2012, DelBen2013/), &
186         description="Method that is used to compute the MP2 energy.", &
187         usage="METHOD MP2_GPW", &
188         enum_c_vals=s2a("NONE", "DIRECT_CANONICAL", "MP2_GPW"), &
189         enum_i_vals=(/mp2_method_none, mp2_method_direct, mp2_method_gpw/), &
190         enum_desc=s2a("Skip MP2 calculation.", &
191                       "Use the direct mp2 canonical approach.", &
192                       "Use the GPW approach to MP2."), &
193         default_i_val=mp2_method_direct)
194      CALL section_add_keyword(section, keyword)
195      CALL keyword_release(keyword)
196
197      NULLIFY (print_key)
198      CALL cp_print_key_section_create(print_key, __LOCATION__, "MP2_INFO", &
199                                       description="Controls the printing basic info about MP2 method", &
200                                       print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
201      CALL section_add_subsection(section, print_key)
202      CALL section_release(print_key)
203
204      CALL keyword_create( &
205         keyword, __LOCATION__, &
206         name="BIG_SEND", &
207         description="Influencing the direct canonical MP2 method: Send big "// &
208         "messages between processes (useful for >48 processors).", &
209         usage="BIG_SEND", &
210         default_l_val=.TRUE., &
211         lone_keyword_l_val=.TRUE.)
212      CALL section_add_keyword(section, keyword)
213      CALL keyword_release(keyword)
214
215   END SUBROUTINE create_mp2_details_section
216
217! **************************************************************************************************
218!> \brief ...
219!> \param section ...
220! **************************************************************************************************
221   SUBROUTINE create_ri_mp2(section)
222      TYPE(section_type), POINTER                        :: section
223
224      CHARACTER(len=*), PARAMETER :: routineN = 'create_ri_mp2', routineP = moduleN//':'//routineN
225
226      TYPE(keyword_type), POINTER                        :: keyword
227      TYPE(section_type), POINTER                        :: subsection
228
229      CPASSERT(.NOT. ASSOCIATED(section))
230      CALL section_create(section, __LOCATION__, name="RI_MP2", &
231                          description="Parameters influencing the RI-MP2 method. RI-MP2 supports gradients.", &
232                          n_keywords=3, n_subsections=1, repeats=.FALSE., &
233                          citations=(/DelBen2013/))
234
235      NULLIFY (keyword)
236      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
237                          description="Putting the &RI_MP2 section activates RI-MP2 calculation.", &
238                          usage="&RI_MP2 .TRUE.", &
239                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
240      CALL section_add_keyword(section, keyword)
241      CALL keyword_release(keyword)
242
243      NULLIFY (subsection)
244      CALL create_cphf(subsection)
245      CALL section_add_subsection(section, subsection)
246      CALL section_release(subsection)
247
248      CALL keyword_create(keyword, __LOCATION__, name="BLOCK_SIZE", &
249                          variants=(/"MESSAGE_SIZE"/), &
250                          description="Determines the blocking used for communication in RI-MP2. Larger BLOCK_SIZE "// &
251                          "reduces communication but requires more memory. The default (-1) is automatic.", &
252                          usage="BLOCK_SIZE 2", &
253                          default_i_val=-1)
254      CALL section_add_keyword(section, keyword)
255      CALL keyword_release(keyword)
256
257      CALL keyword_create(keyword, __LOCATION__, name="EPS_CANONICAL", &
258                          description="Threshold for discriminate if a given ij pairs "// &
259                          "of the unrelaxed MP2 density matrix has to be "// &
260                          "calculated with a canonical reformulation based "// &
261                          "on the occupied eigenvalues differences.", &
262                          usage="EPS_CANONICAL 1.0E-8", type_of_var=real_t, &
263                          default_r_val=1.0E-7_dp)
264      CALL section_add_keyword(section, keyword)
265      CALL keyword_release(keyword)
266
267      CALL keyword_create( &
268         keyword, __LOCATION__, &
269         name="FREE_HFX_BUFFER", &
270         description="Free the buffer containing the 4 center integrals used in the Hartree-Fock exchange calculation. "// &
271         "This will be effective only for gradients calculations, since for the energy only "// &
272         "case, the buffers are released by default. (Right now debugging only).", &
273         usage="FREE_HFX_BUFFER", &
274         default_l_val=.TRUE., &
275         lone_keyword_l_val=.TRUE.)
276      CALL section_add_keyword(section, keyword)
277      CALL keyword_release(keyword)
278
279   END SUBROUTINE create_ri_mp2
280
281! **************************************************************************************************
282!> \brief ...
283!> \param section ...
284! **************************************************************************************************
285   SUBROUTINE create_opt_ri_basis(section)
286      TYPE(section_type), POINTER                        :: section
287
288      CHARACTER(len=*), PARAMETER :: routineN = 'create_opt_ri_basis', &
289         routineP = moduleN//':'//routineN
290
291      TYPE(keyword_type), POINTER                        :: keyword
292
293      CPASSERT(.NOT. ASSOCIATED(section))
294      CALL section_create(section, __LOCATION__, name="OPT_RI_BASIS", &
295                          description="Parameters influencing the optimization of the RI MP2 basis. "// &
296                          "Only exponents of non-contracted auxiliary basis can be optimized. "// &
297                          "An initial RI auxiliary basis has to be specified.", &
298                          n_keywords=6, n_subsections=0, repeats=.FALSE., &
299                          citations=(/DelBen2013/))
300      NULLIFY (keyword)
301      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
302                          description="Putting the &OPT_RI_BASIS section activates optimization of RI basis.", &
303                          usage="&OPT_RI_BASIS .TRUE.", &
304                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
305      CALL section_add_keyword(section, keyword)
306      CALL keyword_release(keyword)
307
308      CALL keyword_create(keyword, __LOCATION__, name="DELTA_I_REL", &
309                          variants=(/"DI_REL"/), &
310                          description="Target accuracy in the relative deviation of the amplitudes calculated with "// &
311                          "and without RI approximation, (more details in Chem.Phys.Lett.294(1998)143).", &
312                          usage="DELTA_I_REL  1.0E-6_dp", &
313                          default_r_val=1.0E-6_dp)
314      CALL section_add_keyword(section, keyword)
315      CALL keyword_release(keyword)
316
317      CALL keyword_create(keyword, __LOCATION__, name="DELTA_RI", &
318                          variants=(/"DRI"/), &
319                          description="Target accuracy in the absolute difference between the RI-MP2 "// &
320                          "and the exact MP2 energy, DRI=ABS(E_MP2-E_RI-MP2).", &
321                          usage="DELTA_RI  1.0E-6_dp", &
322                          default_r_val=5.0E-6_dp)
323      CALL section_add_keyword(section, keyword)
324      CALL keyword_release(keyword)
325
326      CALL keyword_create(keyword, __LOCATION__, name="EPS_DERIV", &
327                          variants=(/"EPS_NUM_DERIV"/), &
328                          description="The derivatives of the MP2 energy with respect to the "// &
329                          "exponents of the basis are calculated numerically. "// &
330                          "The change in the exponent a_i employed for the numerical evaluation "// &
331                          "is defined as h_i=EPS_DERIV*a_i.", &
332                          usage="EPS_DERIV  1.0E-3_dp", &
333                          default_r_val=1.0E-3_dp)
334      CALL section_add_keyword(section, keyword)
335      CALL keyword_release(keyword)
336
337      CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
338                          variants=(/"MAX_NUM_ITER"/), &
339                          description="Specifies the maximum number of steps in the RI basis optimization.", &
340                          usage="MAX_ITER 100", &
341                          default_i_val=50)
342      CALL section_add_keyword(section, keyword)
343      CALL keyword_release(keyword)
344
345      CALL keyword_create(keyword, __LOCATION__, name="NUM_FUNC", &
346                          description="Specifies the number of function, for each angular momentum (s, p, d ...), "// &
347                          "employed in the automatically generated initial guess. "// &
348                          "This will be effective only if RI_AUX_BASIS_SET in the KIND section is not specified.", &
349                          usage="NUM_FUNC {number of s func.} {number of p func.} ...", &
350                          n_var=-1, default_i_vals=(/-1/), type_of_var=integer_t)
351      CALL section_add_keyword(section, keyword)
352      CALL keyword_release(keyword)
353
354      CALL keyword_create(keyword, __LOCATION__, name="BASIS_SIZE", &
355                          description="Specifies the size of the auxiliary basis set automatically "// &
356                          "generated as initial guess. This will be effective only if RI_AUX_BASIS_SET "// &
357                          "in the KIND section and NUM_FUNC are not specified.", &
358                          usage="BASIS_SIZE  (MEDIUM|LARGE|VERY_LARGE)", &
359                          enum_c_vals=s2a("MEDIUM", "LARGE", "VERY_LARGE"), &
360                          enum_i_vals=(/0, 1, 2/), &
361                          default_i_val=0)
362      CALL section_add_keyword(section, keyword)
363      CALL keyword_release(keyword)
364
365   END SUBROUTINE create_opt_ri_basis
366
367! **************************************************************************************************
368!> \brief ...
369!> \param section ...
370! **************************************************************************************************
371   SUBROUTINE create_ri_laplace(section)
372      TYPE(section_type), POINTER                        :: section
373
374      CHARACTER(len=*), PARAMETER :: routineN = 'create_ri_laplace', &
375         routineP = moduleN//':'//routineN
376
377      TYPE(keyword_type), POINTER                        :: keyword
378
379      CPASSERT(.NOT. ASSOCIATED(section))
380      CALL section_create(section, __LOCATION__, name="RI_SOS_MP2", &
381                          description="Parameters influencing the RI-SOS-MP2-Laplace method", &
382                          n_keywords=3, n_subsections=1, repeats=.FALSE., &
383                          citations=(/DelBen2013/))
384
385      NULLIFY (keyword)
386      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
387                          description="Putting the &RI_SOS_MP2 section activates RI-SOS-MP2 calculation.", &
388                          usage="&RI_SOS_MP2 .TRUE.", &
389                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
390      CALL section_add_keyword(section, keyword)
391      CALL keyword_release(keyword)
392
393      CALL keyword_create( &
394         keyword, __LOCATION__, name="QUADRATURE_POINTS", &
395         variants=(/"LAPLACE_NUM_QUAD_POINTS"/), &
396         description="Number of quadrature points for the numerical integration in the RI-SOS-MP2-Laplace method.", &
397         usage="QUADRATURE_POINTS 6", &
398         default_i_val=5)
399      CALL section_add_keyword(section, keyword)
400      CALL keyword_release(keyword)
401
402      CALL keyword_create( &
403         keyword, __LOCATION__, name="SIZE_INTEG_GROUP", &
404         variants=(/"LAPLACE_GROUP_SIZE"/), &
405         description="Group size for the integration in the Laplace method, that is the number of processes involved in "// &
406         "the computation of each integration point. SIZE_INTEG_GROUP has to be a multiple "// &
407         "of GROUP_SIZE in the WF_CORRELATION section. The default (-1) "// &
408         "is automatic.", &
409         usage="SIZE_INTEG_GROUP 16", &
410         default_i_val=-1)
411      CALL section_add_keyword(section, keyword)
412      CALL keyword_release(keyword)
413
414   END SUBROUTINE create_ri_laplace
415
416! **************************************************************************************************
417!> \brief ...
418!> \param section ...
419! **************************************************************************************************
420   SUBROUTINE create_ri_rpa(section)
421      TYPE(section_type), POINTER                        :: section
422
423      CHARACTER(len=*), PARAMETER :: routineN = 'create_ri_rpa', routineP = moduleN//':'//routineN
424
425      TYPE(keyword_type), POINTER                        :: keyword
426      TYPE(section_type), POINTER                        :: subsection
427
428      CPASSERT(.NOT. ASSOCIATED(section))
429      CALL section_create(section, __LOCATION__, name="RI_RPA", &
430                          description="Parameters influencing RI-RPA and GW.", &
431                          n_keywords=8, n_subsections=4, repeats=.FALSE., &
432                          citations=(/DelBen2013, DelBen2015/))
433
434      NULLIFY (keyword, subsection)
435      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
436                          description="Putting the &RI_RPA section activates RI-RPA calculation.", &
437                          usage="&RI_RPA .TRUE.", &
438                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
439      CALL section_add_keyword(section, keyword)
440      CALL keyword_release(keyword)
441
442      CALL keyword_create(keyword, __LOCATION__, name="QUADRATURE_POINTS", &
443                          variants=(/"RPA_NUM_QUAD_POINTS"/), &
444                          description="Number of quadrature points for the numerical integration in the RI-RPA method.", &
445                          usage="QUADRATURE_POINTS 60", &
446                          default_i_val=40)
447      CALL section_add_keyword(section, keyword)
448      CALL keyword_release(keyword)
449
450      CALL keyword_create(keyword, __LOCATION__, name="SIZE_FREQ_INTEG_GROUP", &
451                          variants=(/"RPA_GROUP_SIZE"/), &
452                          description="Group size for frequency integration, that is the number of processes involved in "// &
453                          "the computation of each integration point. SIZE_FREQ_INTEG_GROUP has to be a multiple "// &
454                          "of GROUP_SIZE in the WF_CORRELATION section. The default (-1) "// &
455                          "is automatic.", &
456                          usage="SIZE_FREQ_INTEG_GROUP 16", &
457                          default_i_val=-1)
458      CALL section_add_keyword(section, keyword)
459      CALL keyword_release(keyword)
460
461      CALL keyword_create(keyword, __LOCATION__, &
462                          name="MM_STYLE", &
463                          description="Matrix multiplication style for the Q matrix.", &
464                          usage="MM_STYLE GEMM", &
465                          enum_c_vals=s2a("GEMM", "SYRK"), &
466                          enum_i_vals=(/wfc_mm_style_gemm, wfc_mm_style_syrk/), &
467                          enum_desc=s2a("Use pdgemm: more flops, maybe faster.", &
468                                        "Use pdysrk: fewer flops, maybe slower."), &
469                          default_i_val=wfc_mm_style_gemm)
470      CALL section_add_keyword(section, keyword)
471      CALL keyword_release(keyword)
472
473      CALL keyword_create( &
474         keyword, __LOCATION__, &
475         name="MINIMAX_QUADRATURE", &
476         variants=(/"MINIMAX"/), &
477         description="Use the Minimax quadrature scheme for performing the numerical integration. "// &
478         "Maximum number of quadrature point limited to 20.", &
479         usage="MINIMAX_QUADRATURE", &
480         default_l_val=.FALSE., &
481         lone_keyword_l_val=.TRUE.)
482      CALL section_add_keyword(section, keyword)
483      CALL keyword_release(keyword)
484
485      CALL keyword_create( &
486         keyword, __LOCATION__, &
487         name="RI_AXK", &
488         variants=(/"AXK"/), &
489         description="Decide whether to perform an RPA-AXK calculation.", &
490         usage="RI_AXK", &
491         default_l_val=.FALSE., &
492         lone_keyword_l_val=.TRUE.)
493      CALL section_add_keyword(section, keyword)
494      CALL keyword_release(keyword)
495
496      CALL keyword_create( &
497         keyword, __LOCATION__, &
498         name="RSE", &
499         variants=(/"SE"/), &
500         description="Decide whether to add singles correction.", &
501         usage="RI_AXK", &
502         default_l_val=.FALSE., &
503         lone_keyword_l_val=.TRUE.)
504      CALL section_add_keyword(section, keyword)
505      CALL keyword_release(keyword)
506
507      CALL keyword_create( &
508         keyword, __LOCATION__, &
509         name="ADMM", &
510         description="Decide whether to perform ADMM in the exact exchange calc. for RPA and/or GW. "// &
511         "Not really recommended. In most cases, the Hartree-Fock exchange is not expensive "// &
512         "and there is no need for ADMM. Only in case of diffuse functions for periodic systems "// &
513         "(only reasonable for GW bandgap calculations) exact exchange can be expensive and then, "// &
514         "we recommend using RI for exchange.", &
515         usage="ADMM", &
516         default_l_val=.FALSE., &
517         lone_keyword_l_val=.TRUE.)
518      CALL section_add_keyword(section, keyword)
519      CALL keyword_release(keyword)
520
521      CALL keyword_create( &
522         keyword, __LOCATION__, &
523         name="SCALE_RPA", &
524         description="Scales RPA energy contributions (RPA, AXK).", &
525         usage="SCALE_RPA 1.0", &
526         default_r_val=1.0_dp)
527      CALL section_add_keyword(section, keyword)
528      CALL keyword_release(keyword)
529
530      ! here we generate a hfx subsection to use in the case EXX has to be computed after RPA
531      CALL create_hfx_section(subsection)
532      CALL section_add_subsection(section, subsection)
533      CALL section_release(subsection)
534
535      ! here we generate a G0W0 subsection to use if G0W0 is desired
536      CALL create_ri_g0w0(subsection)
537      CALL section_add_subsection(section, subsection)
538      CALL section_release(subsection)
539
540      ! here we generate a RI_AXK subsection
541      CALL create_ri_axk(subsection)
542      CALL section_add_subsection(section, subsection)
543      CALL section_release(subsection)
544
545   END SUBROUTINE create_ri_rpa
546
547! **************************************************************************************************
548!> \brief ...
549!> \param section ...
550! **************************************************************************************************
551   SUBROUTINE create_ri_axk(section)
552      TYPE(section_type), POINTER                        :: section
553
554      CHARACTER(len=*), PARAMETER :: routineN = 'create_ri_axk', routineP = moduleN//':'//routineN
555
556      !TYPE(section_type), POINTER                        :: subsection
557
558      CPASSERT(.NOT. ASSOCIATED(section))
559      CALL section_create(section, __LOCATION__, name="RI_AXK", &
560                          description="Parameters influencing the RI-RPA-AXK method", &
561                          n_keywords=0, n_subsections=0, repeats=.FALSE., &
562                          citations=(/Bates2013/))
563
564      !NULLIFY (keyword, subsection)
565
566   END SUBROUTINE create_ri_axk
567
568! **************************************************************************************************
569!> \brief ...
570!> \param section ...
571! **************************************************************************************************
572   SUBROUTINE create_ri_g0w0(section)
573      TYPE(section_type), POINTER                        :: section
574
575      CHARACTER(len=*), PARAMETER :: routineN = 'create_ri_g0w0', routineP = moduleN//':'//routineN
576
577      TYPE(keyword_type), POINTER                        :: keyword
578      TYPE(section_type), POINTER                        :: subsection
579
580      CPASSERT(.NOT. ASSOCIATED(section))
581      CALL section_create(section, __LOCATION__, name="GW", &
582                          description="Parameters influencing the RI-G0W0 method", &
583                          n_keywords=24, n_subsections=1, repeats=.FALSE.)
584
585      NULLIFY (keyword, subsection)
586
587      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
588                          description="Activates cubic-scaling RPA, GW and Laplace-SOS-MP2 calculations.", &
589                          usage="&GW .TRUE.", &
590                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
591      CALL section_add_keyword(section, keyword)
592      CALL keyword_release(keyword)
593
594      CALL keyword_create(keyword, __LOCATION__, name="CORR_MOS_OCC", &
595                          variants=(/"CORR_OCC"/), &
596                          description="Number of occupied MOs whose energies are corrected by RI-G0W0. "// &
597                          "Counting beginning from HOMO, e.g. 3 corrected occ. MOs correspond "// &
598                          "to correction of HOMO, HOMO-1 and HOMO-2. Numerical effort and "// &
599                          "storage of RI-G0W0 increase linearly with this number. In case you "// &
600                          "want to correct all occ. MOs, insert a number larger than the number "// &
601                          "of occ. MOs.", &
602                          usage="CORR_OCC 3", &
603                          default_i_val=10)
604      CALL section_add_keyword(section, keyword)
605      CALL keyword_release(keyword)
606
607      CALL keyword_create(keyword, __LOCATION__, name="CORR_MOS_VIRT", &
608                          variants=(/"CORR_VIRT"/), &
609                          description="Number of virtual MOs whose energies are corrected by RI-G0W0. "// &
610                          "Counting beginning from LUMO, e.g. 3 corrected occ. MOs correspond "// &
611                          "to correction of LUMO, LUMO+1 and LUMO+2. Numerical effort and "// &
612                          "storage of RI-G0W0 increase linearly with this number. In case you "// &
613                          "want to correct all virt. MOs, insert a number larger than the number "// &
614                          "of virt. MOs.", &
615                          usage="CORR_VIRT 3", &
616                          default_i_val=10)
617      CALL section_add_keyword(section, keyword)
618      CALL keyword_release(keyword)
619
620      CALL keyword_create(keyword, __LOCATION__, name="NUMB_POLES", &
621                          description="Number of poles for the fitting. Usually, two poles are sufficient. ", &
622                          usage="NUMB_POLES 2", &
623                          default_i_val=2)
624      CALL section_add_keyword(section, keyword)
625      CALL keyword_release(keyword)
626
627      CALL keyword_create(keyword, __LOCATION__, name="OMEGA_MAX_FIT", &
628                          description="Determines fitting range for the self-energy on the imaginary axis: "// &
629                          "[0, OMEGA_MAX_FIT] for virt orbitals, [-OMEGA_MAX_FIT,0] for occ orbitals. "// &
630                          "Unit: Hartree. Default: 0.734996 H = 20 eV. ", &
631                          usage="OMEGA_MAX_FIT 0.5", &
632                          default_r_val=0.734996_dp)
633      CALL section_add_keyword(section, keyword)
634      CALL keyword_release(keyword)
635
636      CALL keyword_create(keyword, __LOCATION__, name="CROSSING_SEARCH", &
637                          description="Determines, how the self_energy is evaluated on the real axis.", &
638                          usage="CROSSING_SEARCH Z_SHOT", &
639                          enum_c_vals=s2a("Z_SHOT", "NEWTON", "BISECTION"), &
640                          enum_i_vals=(/ri_rpa_g0w0_crossing_z_shot, &
641                                        ri_rpa_g0w0_crossing_newton, ri_rpa_g0w0_crossing_bisection/), &
642                          enum_desc=s2a("Calculate the derivative of Sigma and out of it Z. Then extrapolate using Z.", &
643                                        "Make a Newton-Raphson fix point iteration.", &
644                                        "Make a bisection fix point iteration."), &
645                          default_i_val=ri_rpa_g0w0_crossing_newton)
646      CALL section_add_keyword(section, keyword)
647      CALL keyword_release(keyword)
648
649      CALL keyword_create(keyword, __LOCATION__, name="FERMI_LEVEL_OFFSET", &
650                          description="Fermi level for occ. orbitals: e_HOMO + FERMI_LEVEL_OFFSET; "// &
651                          "Fermi level for virt. orbitals: e_LUMO - FERMI_LEVEL_OFFSET. "// &
652                          "In case e_homo + FERMI_LEVEL_OFFSET < e_lumo - FERMI_LEVEL_OFFSET, "// &
653                          "we set Fermi level = (e_HOMO+e_LUMO)/2. For cubic-scaling GW, the Fermi level "// &
654                          "is always equal to (e_HOMO+e_LUMO)/2 regardless of FERMI_LEVEL_OFFSET.", &
655                          usage="FERMI_LEVEL_OFFSET 1.0E-2", &
656                          default_r_val=2.0E-2_dp)
657      CALL section_add_keyword(section, keyword)
658      CALL keyword_release(keyword)
659
660      CALL keyword_create(keyword, __LOCATION__, name="EV_GW_ITER", &
661                          description="Maximum number of iterations for eigenvalue self-consistency cycle. The "// &
662                          "computational effort of GW scales linearly with this number. ", &
663                          usage="EV_GW_ITER 3", &
664                          default_i_val=1)
665      CALL section_add_keyword(section, keyword)
666      CALL keyword_release(keyword)
667
668      CALL keyword_create(keyword, __LOCATION__, name="SC_GW0_ITER", &
669                          description="Maximum number of iterations for GW0 self-consistency cycle. The "// &
670                          "computational effort of GW is not much affected by the number of scGW0 cycles. ", &
671                          usage="SC_GW0_ITER 3", &
672                          default_i_val=1)
673      CALL section_add_keyword(section, keyword)
674      CALL keyword_release(keyword)
675
676      CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
677                          description="Target accuracy for the eigenvalue self-consistency. "// &
678                          "If the G0W0 HOMO-LUMO gap differs by less than the "// &
679                          "target accuracy during the iteration, the eigenvalue "// &
680                          "self-consistency cycle stops. Unit: Hartree.", &
681                          usage="EPS_EV_SC_ITER 0.00005", &
682                          default_r_val=cp_unit_to_cp2k(value=0.00136_dp, unit_str="eV"), &
683                          unit_str="eV")
684
685      CALL section_add_keyword(section, keyword)
686      CALL keyword_release(keyword)
687
688      CALL keyword_create(keyword, __LOCATION__, name="PRINT_EXX", &
689                          description="Print exchange self-energy minus exchange correlation potential for Gamma-only "// &
690                          "calculation (PRINT). For a GW calculation with k-points we use this output as "// &
691                          "exchange self-energy (READ). This is a temporary solution because the hybrid MPI/OMP "// &
692                          "parallelization in the HFX by Manuel Guidon conflicts with the parallelization in "// &
693                          "low-scaling GW k-points which is most efficient with maximum number of MPI tasks and "// &
694                          "minimum number of OMP threads. For HFX by M. Guidon, the density matrix is "// &
695                          "fully replicated on every MPI rank which necessitates a high number of OMP threads per MPI "// &
696                          "rank for large systems to prevent out of memory. "// &
697                          "Such a high number of OMP threads would slow down the GW calculation "// &
698                          "severely. Therefore, it was decided to temporarily divide the GW k-point calculation in a "// &
699                          "Gamma-only HF calculation with high number of OMP threads to prevent out of memory and "// &
700                          "a GW k-point calculation with 1 OMP thread per MPI rank reading the previousHF output.", &
701                          usage="PRINT_EXX TRUE", &
702                          enum_c_vals=s2a("TRUE", "FALSE", "READ", "SKIP_FOR_REGTEST"), &
703                          enum_i_vals=(/gw_print_exx, gw_no_print_exx, gw_read_exx, gw_skip_for_regtest/), &
704                          enum_desc=s2a("Please, put TRUE for Gamma only calculation to get the exchange self-energy. "// &
705                                        "If 'SIGMA_X' and the corresponding values for the exchange-energy are written, "// &
706                                        "the writing has been successful", &
707                                        "FALSE is needed if you want to do nothing here.", &
708                                        "Please, put READ for the k-point GW calculation to read the exact exchange. "// &
709                                        "You have to provide an output file including the exact exchange. This file "// &
710                                        "has to be named 'exx.dat'.", &
711                                        "SKIP_FOR_REGTEST is only used for the GW k-point regtest where no exchange "// &
712                                        "self-energy is computed."), &
713                          default_i_val=gw_no_print_exx)
714      CALL section_add_keyword(section, keyword)
715      CALL keyword_release(keyword)
716
717      CALL keyword_create(keyword, __LOCATION__, name="RI_SIGMA_X", &
718                          description="If true, the exchange self-energy is calculated approximatively with RI. "// &
719                          "This is only recommended in case exact exchange is very costly, e.g. when "// &
720                          "using diffuse basis functions (seems not to work for periodic systems).", &
721                          usage="RI_SIGMA_X", &
722                          default_l_val=.FALSE., &
723                          lone_keyword_l_val=.TRUE.)
724      CALL section_add_keyword(section, keyword)
725      CALL keyword_release(keyword)
726
727      CALL keyword_create(keyword, __LOCATION__, name="IC_CORR_LIST", &
728                          description="List of image charge correction from a previous calculation to be applied in G0W0 "// &
729                          "or evGW. Keyword is active, if the first entry is positive (since IC corrections are positive "// &
730                          "occupied MOs. The start corresponds to the first corrected GW level.", &
731                          usage="IC_CORR_LIST <REAL> ... <REAL>", &
732                          default_r_vals=(/-1.0_dp/), &
733                          type_of_var=real_t, n_var=-1, unit_str="eV")
734      CALL section_add_keyword(section, keyword)
735      CALL keyword_release(keyword)
736
737      CALL keyword_create(keyword, __LOCATION__, name="IC_CORR_LIST_BETA", &
738                          description="IC_CORR_LIST for beta spins in case of open shell calculation.", &
739                          usage="IC_CORR_LIST_BETA <REAL> ... <REAL>", &
740                          default_r_vals=(/-1.0_dp/), &
741                          type_of_var=real_t, n_var=-1, unit_str="eV")
742      CALL section_add_keyword(section, keyword)
743      CALL keyword_release(keyword)
744
745      CALL keyword_create(keyword, __LOCATION__, name="PERIODIC", &
746                          description="If true, the periodic correction scheme is used employing k-points.", &
747                          usage="PERIODIC", &
748                          default_l_val=.FALSE., &
749                          lone_keyword_l_val=.TRUE.)
750      CALL section_add_keyword(section, keyword)
751      CALL keyword_release(keyword)
752
753      CALL keyword_create(keyword, __LOCATION__, name="BSE", &
754                          description="If true, electronic excitation energies are computed from the Bethe-"// &
755                          "Salpeter equation on top of GW eigenvalues.  Parameter of BSE can be adjusted in "// &
756                          "the corresponding section.", &
757                          usage="BSE", &
758                          default_l_val=.FALSE., &
759                          lone_keyword_l_val=.TRUE.)
760      CALL section_add_keyword(section, keyword)
761      CALL keyword_release(keyword)
762
763      CALL keyword_create(keyword, __LOCATION__, name="IMAGE_CHARGE_MODEL", &
764                          variants=(/"IC"/), &
765                          description="If true, an image charge model is applied to mimic the renormalization of "// &
766                          "electronic levels of a molecule at a metallic surface. For this calculation, the molecule "// &
767                          "has to be reflected on the desired xy image plane. The coordinates of the reflected molecule "// &
768                          "have to be added to the coord file as ghost atoms. For the ghost atoms, identical basis sets "// &
769                          "the normal atoms have to be used.", &
770                          usage="IC TRUE", &
771                          default_l_val=.FALSE., &
772                          lone_keyword_l_val=.TRUE.)
773      CALL section_add_keyword(section, keyword)
774      CALL keyword_release(keyword)
775
776      CALL keyword_create(keyword, __LOCATION__, name="ANALYTIC_CONTINUATION", &
777                          description="Defines which type of analytic continuation for the self energy is used", &
778                          usage="ANALYTIC_CONTINUATION", &
779                          enum_c_vals=s2a("TWO_POLE", "PADE"), &
780                          enum_i_vals=(/gw_two_pole_model, gw_pade_approx/), &
781                          enum_desc=s2a("Use 'two-pole' model.", &
782                                        "Use Pade approximation."), &
783                          default_i_val=gw_pade_approx)
784      CALL section_add_keyword(section, keyword)
785      CALL keyword_release(keyword)
786
787      CALL keyword_create(keyword, __LOCATION__, name="NPARAM_PADE", &
788                          description="Number of parameters for the Pade approximation "// &
789                          "when using the latter for the analytic continuation of the "// &
790                          "self energy. 16 parameters (corresponding to 8 poles) are "// &
791                          "are recommended.", &
792                          usage="NPARAM_PADE 16", &
793                          default_i_val=16)
794      CALL section_add_keyword(section, keyword)
795      CALL keyword_release(keyword)
796
797      CALL keyword_create(keyword, __LOCATION__, name="GAMMA_ONLY_SIGMA", &
798                          variants=(/"GAMMA"/), &
799                          description="If true, the correlation self-energy is only computed at the Gamma point. "// &
800                          "The Gamma point itself is obtained by averaging over all kpoints of the DFT mesh.", &
801                          usage="GAMMA TRUE", &
802                          default_l_val=.FALSE., &
803                          lone_keyword_l_val=.TRUE.)
804      CALL section_add_keyword(section, keyword)
805      CALL keyword_release(keyword)
806
807      ! here we generate a subsection for the periodic GW correction
808      CALL create_periodic_gw_correction_section(subsection)
809      CALL section_add_subsection(section, subsection)
810      CALL section_release(subsection)
811
812      ! here we generate a subsection for Bethe-Salpeter
813      CALL create_bse_section(subsection)
814      CALL section_add_subsection(section, subsection)
815      CALL section_release(subsection)
816
817      ! here we generate a subsection for image charge calculations
818      CALL create_ic_section(subsection)
819      CALL section_add_subsection(section, subsection)
820      CALL section_release(subsection)
821
822      ! here we generate a subsection for additional printing
823      CALL create_print_section(subsection)
824      CALL section_add_subsection(section, subsection)
825      CALL section_release(subsection)
826
827   END SUBROUTINE create_ri_g0w0
828
829! **************************************************************************************************
830!> \brief ...
831!> \param section ...
832! **************************************************************************************************
833   SUBROUTINE create_print_section(section)
834      TYPE(section_type), POINTER                        :: section
835
836      CHARACTER(len=*), PARAMETER :: routineN = 'create_print_section', &
837         routineP = moduleN//':'//routineN
838
839      TYPE(keyword_type), POINTER                        :: keyword
840
841      CPASSERT(.NOT. ASSOCIATED(section))
842      CALL section_create(section, __LOCATION__, name="PRINT", &
843                          description="Parameters for GW related output.", &
844                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
845
846      NULLIFY (keyword)
847
848      CALL keyword_create(keyword, __LOCATION__, name="", &
849                          variants=(/"SELF_ENERGY"/), &
850                          description="If true, print the self-energy for all levels for real energy "// &
851                          "together with the straight line to see the quasiparticle energy as intersection.", &
852                          usage="SELF_ENERGY TRUE", &
853                          default_l_val=.FALSE., &
854                          lone_keyword_l_val=.TRUE.)
855      CALL section_add_keyword(section, keyword)
856      CALL keyword_release(keyword)
857
858   END SUBROUTINE
859
860! **************************************************************************************************
861!> \brief ...
862!> \param section ...
863! **************************************************************************************************
864   SUBROUTINE create_periodic_gw_correction_section(section)
865      TYPE(section_type), POINTER                        :: section
866
867      CHARACTER(len=*), PARAMETER :: routineN = 'create_periodic_gw_correction_section', &
868         routineP = moduleN//':'//routineN
869
870      TYPE(keyword_type), POINTER                        :: keyword
871
872      CPASSERT(.NOT. ASSOCIATED(section))
873      CALL section_create(section, __LOCATION__, name="PERIODIC", &
874                          description="Parameters influencing correction for periodic GW.", &
875                          n_keywords=12, n_subsections=1, repeats=.FALSE.)
876
877      NULLIFY (keyword)
878
879      CALL keyword_create(keyword, __LOCATION__, name="KPOINTS", &
880                          description="Specify number of k-points for a single k-point grid. Internally, a "// &
881                          "Monkhorst-Pack grid is used. Typically, even numbers are chosen such that the Gamma "// &
882                          "point is excluded from the k-point mesh.", &
883                          usage="KPOINTS  nx  ny  nz", repeats=.TRUE., &
884                          n_var=3, type_of_var=integer_t, default_i_vals=(/16, 16, 16/))
885      CALL section_add_keyword(section, keyword)
886      CALL keyword_release(keyword)
887
888      CALL keyword_create(keyword, __LOCATION__, name="NUM_KP_GRIDS", &
889                          description="Number of k-point grids around the Gamma point with different resolution. "// &
890                          "E.g. for KPOINTS 4 4 4 and NUM_KP_GRIDS 3, there will be a 3x3x3 Monkhorst-Pack (MP) k-point "// &
891                          "grid for the whole Brillouin zone (excluding Gamma), another 3x3x3 MP grid with smaller  "// &
892                          "spacing around Gamma (again excluding Gamma) and a very fine 4x4x4 MP grid around Gamma.", &
893                          usage="NUM_KP_GRIDS 5", &
894                          default_i_val=1)
895      CALL section_add_keyword(section, keyword)
896      CALL keyword_release(keyword)
897
898      CALL keyword_create(keyword, __LOCATION__, name="EPS_KPOINT", &
899                          description="If the absolute value of a k-point is below EPS_KPOINT, this kpoint is "// &
900                          "neglected since the Gamma point is not included in the periodic correction.", &
901                          usage="EPS_KPOINT 1.0E-4", &
902                          default_r_val=1.0E-05_dp)
903      CALL section_add_keyword(section, keyword)
904      CALL keyword_release(keyword)
905
906      CALL keyword_create(keyword, __LOCATION__, name="MO_COEFF_GAMMA", &
907                          description="If true, only the MO coefficients at the Gamma point are used for the periodic  "// &
908                          "correction. Otherwise, the MO coeffs are computed at every k-point which is much more "// &
909                          "expensive. It should be okay to use the Gamma MO coefficients.", &
910                          usage="MO_COEFF_GAMMA", &
911                          default_l_val=.TRUE., &
912                          lone_keyword_l_val=.TRUE.)
913      CALL section_add_keyword(section, keyword)
914      CALL keyword_release(keyword)
915
916      CALL keyword_create(keyword, __LOCATION__, name="AVERAGE_DEGENERATE_LEVELS", &
917                          variants=(/"ADL"/), &
918                          description="If true, the correlation self-energy of degenerate levels is averaged.", &
919                          usage="AVERAGE_DEGENERATE_LEVELS", &
920                          default_l_val=.TRUE., &
921                          lone_keyword_l_val=.TRUE.)
922      CALL section_add_keyword(section, keyword)
923      CALL keyword_release(keyword)
924
925      CALL keyword_create(keyword, __LOCATION__, name="EPS_EIGENVAL", &
926                          description="Threshold for considering levels as degenerate. Unit: Hartree.", &
927                          usage="EPS_EIGENVAL 1.0E-5", &
928                          default_r_val=2.0E-04_dp)
929      CALL section_add_keyword(section, keyword)
930      CALL keyword_release(keyword)
931
932      CALL keyword_create(keyword, __LOCATION__, name="EXTRAPOLATE_KPOINTS", &
933                          variants=(/"EXTRAPOLATE"/), &
934                          description="If true, extrapolates the k-point mesh. Only working if k-point mesh numbers are "// &
935                          "divisible by 4, e.g. 8x8x8 or 12x12x12 is recommended.", &
936                          usage="EXTRAPOLATE_KPOINTS FALSE", &
937                          default_l_val=.TRUE., &
938                          lone_keyword_l_val=.TRUE.)
939      CALL section_add_keyword(section, keyword)
940      CALL keyword_release(keyword)
941
942      CALL keyword_create(keyword, __LOCATION__, name="DO_AUX_BAS_GW", &
943                          description="If true, use a different basis for the periodic correction. This can be necessary "// &
944                          "in case a diffused basis is used for GW to converge the HOMO-LUMO gap. In this case, "// &
945                          "numerical problems may occur due to diffuse functions in the basis. This keyword only works if "// &
946                          "AUX_GW <basis set>  is specified in the kind section for every atom kind.", &
947                          usage="AUX_BAS_GW TRUE", &
948                          default_l_val=.FALSE., &
949                          lone_keyword_l_val=.TRUE.)
950      CALL section_add_keyword(section, keyword)
951      CALL keyword_release(keyword)
952
953      CALL keyword_create(keyword, __LOCATION__, name="FRACTION_AUX_MOS", &
954                          description="Fraction how many MOs are used in the auxiliary basis.", &
955                          usage="FRACTION_AUX_MOS 0.6", &
956                          default_r_val=0.5_dp)
957      CALL section_add_keyword(section, keyword)
958      CALL keyword_release(keyword)
959
960      CALL keyword_create(keyword, __LOCATION__, name="NUM_OMEGA_POINTS", &
961                          description="Number of Clenshaw-Curtis integration points for the periodic correction in cubic- "// &
962                          "scaling GW. This variable is a dummy variable for canonical N^4 GW calculations.", &
963                          usage="NUM_OMEGA_POINTS 200", &
964                          default_i_val=300)
965      CALL section_add_keyword(section, keyword)
966      CALL keyword_release(keyword)
967
968   END SUBROUTINE
969
970! **************************************************************************************************
971!> \brief ...
972!> \param section ...
973! **************************************************************************************************
974   SUBROUTINE create_bse_section(section)
975      TYPE(section_type), POINTER                        :: section
976
977      CHARACTER(len=*), PARAMETER :: routineN = 'create_bse_section', &
978         routineP = moduleN//':'//routineN
979
980      TYPE(keyword_type), POINTER                        :: keyword
981
982      CPASSERT(.NOT. ASSOCIATED(section))
983      CALL section_create(section, __LOCATION__, name="BSE", &
984                          description="Parameters influencing the Bethe-Salpeter calculations on "// &
985                          "top of GW eigenvalues.", &
986                          n_keywords=12, n_subsections=1, repeats=.FALSE.)
987
988      NULLIFY (keyword)
989
990      CALL keyword_create(keyword, __LOCATION__, name="NUM_Z_VECTORS", &
991                          description="Number Z vectors used in the subspace iterations. This is a convergence "// &
992                          "parameter: Increasing NUM_Z_VECTORS should keep the result constant in case of convergence,.", &
993                          usage="NUM_Z_VECTORS 50", &
994                          default_i_val=20)
995      CALL section_add_keyword(section, keyword)
996      CALL keyword_release(keyword)
997
998      CALL keyword_create(keyword, __LOCATION__, name="THRESHOLD_MIN_TRANS", &
999                          variants=(/"EPS"/), &
1000                          description="Threshold for stopping the iteration for computing the transition energies. "// &
1001                          "If the lowest excitation changes by less than THRESHOLD_MIN_TRANS (in eV), the ieration"// &
1002                          "stops.", &
1003                          usage="THRESHOLD_MIN_TRANS 0.001", &
1004                          default_r_val=0.001_dp)
1005      CALL section_add_keyword(section, keyword)
1006      CALL keyword_release(keyword)
1007
1008      CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
1009                          description="Maximum number of iterations for determining the transition energies.", &
1010                          usage="MAX_ITER 200", &
1011                          default_i_val=200)
1012      CALL section_add_keyword(section, keyword)
1013      CALL keyword_release(keyword)
1014
1015   END SUBROUTINE
1016
1017! **************************************************************************************************
1018!> \brief ...
1019!> \param section ...
1020! **************************************************************************************************
1021   SUBROUTINE create_ic_section(section)
1022      TYPE(section_type), POINTER                        :: section
1023
1024      CHARACTER(len=*), PARAMETER :: routineN = 'create_ic_section', &
1025         routineP = moduleN//':'//routineN
1026
1027      TYPE(keyword_type), POINTER                        :: keyword
1028
1029      CPASSERT(.NOT. ASSOCIATED(section))
1030      CALL section_create(section, __LOCATION__, name="IC", &
1031                          description="Parameters influencing the image charge correction. "// &
1032                          "The image plane is always an xy plane, so adjust the molecule according "// &
1033                          "to that. ", &
1034                          n_keywords=3, n_subsections=1, repeats=.FALSE.)
1035
1036      NULLIFY (keyword)
1037
1038      CALL keyword_create(keyword, __LOCATION__, name="PRINT_IC_LIST", &
1039                          description="If true, the image charge correction values are printed in a list, "// &
1040                          "such that it can be used as input for a subsequent evGW calculation.", &
1041                          usage="PRINT_IC_VALUES", &
1042                          default_l_val=.FALSE., &
1043                          lone_keyword_l_val=.TRUE.)
1044      CALL section_add_keyword(section, keyword)
1045      CALL keyword_release(keyword)
1046
1047      CALL keyword_create(keyword, __LOCATION__, name="EPS_DIST", &
1048                          description="Threshold where molecule and image molecule have to coincide. ", &
1049                          usage="EPS_DIST 0.1", unit_str="angstrom", &
1050                          type_of_var=real_t, default_r_val=3.0E-02_dp, repeats=.FALSE.)
1051      CALL section_add_keyword(section, keyword)
1052      CALL keyword_release(keyword)
1053
1054   END SUBROUTINE
1055
1056! **************************************************************************************************
1057!> \brief ...
1058!> \param section ...
1059! **************************************************************************************************
1060   SUBROUTINE create_low_scaling(section)
1061      TYPE(section_type), POINTER                        :: section
1062
1063      CHARACTER(len=*), PARAMETER :: routineN = 'create_low_scaling', &
1064         routineP = moduleN//':'//routineN
1065
1066      TYPE(keyword_type), POINTER                        :: keyword
1067      TYPE(section_type), POINTER                        :: subsection
1068
1069      CPASSERT(.NOT. ASSOCIATED(section))
1070      CALL section_create( &
1071         section, __LOCATION__, name="LOW_SCALING", &
1072         description="Cubic scaling RI-RPA, GW and Laplace-SOS-MP2 method using the imaginary time formalism. "// &
1073         "EPS_GRID in WFC_GPW section controls accuracy / req. memory for 3-center integrals. "// &
1074         "SORT_BASIS EXP should be specified in DFT section.", &
1075         n_keywords=12, n_subsections=2, repeats=.FALSE.)
1076
1077      NULLIFY (keyword)
1078      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
1079                          description="Activates cubic-scaling RPA, GW and Laplace-SOS-MP2 calculations.", &
1080                          usage="&LOW_SCALING .TRUE.", &
1081                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1082      CALL section_add_keyword(section, keyword)
1083      CALL keyword_release(keyword)
1084
1085      CALL keyword_create(keyword, __LOCATION__, name="MEMORY_CUT", &
1086                          description="Reduces memory for sparse tensor contractions by this factor. "// &
1087                          "A high value leads to some loss of performance. "// &
1088                          "This memory reduction factor applies to storage of the tensors 'M occ' / 'M virt' "// &
1089                          "but does not reduce storage of '3c ints'.", &
1090                          usage="MEMORY_CUT 16", &
1091                          default_i_val=5)
1092      CALL section_add_keyword(section, keyword)
1093      CALL keyword_release(keyword)
1094
1095      CALL keyword_create(keyword, __LOCATION__, name="MEMORY_INFO", &
1096                          description="Decide whether to print memory info on the sparse matrices.", &
1097                          usage="MEMORY_INFO", &
1098                          default_l_val=.FALSE., &
1099                          lone_keyword_l_val=.TRUE.)
1100      CALL section_add_keyword(section, keyword)
1101      CALL keyword_release(keyword)
1102
1103      CALL keyword_create( &
1104         keyword, __LOCATION__, name="EPS_FILTER", &
1105         description="Determines a threshold for the DBCSR based multiply."// &
1106         "Normally, this EPS_FILTER determines accuracy and timing of low-scaling RPA and GW calculations.", &
1107         usage="EPS_FILTER 1.0E-10 ", type_of_var=real_t, &
1108         default_r_val=1.0E-9_dp)
1109      CALL section_add_keyword(section, keyword)
1110      CALL keyword_release(keyword)
1111
1112      CALL keyword_create( &
1113         keyword, __LOCATION__, name="EPS_FILTER_FACTOR", &
1114         description="Multiply EPS_FILTER with this factor to determine filter epsilon "// &
1115         "for DBCSR based multiply P(it)=(Mocc(it))^T*Mvirt(it) "// &
1116         "Default should be kept.", &
1117         type_of_var=real_t, &
1118         default_r_val=10.0_dp)
1119      CALL section_add_keyword(section, keyword)
1120      CALL keyword_release(keyword)
1121
1122      CALL keyword_create( &
1123         keyword, __LOCATION__, &
1124         name="DO_KPOINTS", &
1125         description="Besides in DFT, this keyword has to be switched on if one wants to do kpoints in. "// &
1126         "cubic RPA.", &
1127         usage="DO_KPOINTS", &
1128         default_l_val=.FALSE., &
1129         lone_keyword_l_val=.TRUE.)
1130      CALL section_add_keyword(section, keyword)
1131      CALL keyword_release(keyword)
1132
1133      CALL keyword_create( &
1134         keyword, __LOCATION__, &
1135         name="CUTOFF_W", &
1136         description="Cutoff for screened Coulomb interaction for GW kpoints.", &
1137         usage="CUTOFF_W 0.5", &
1138         default_r_val=0.5_dp)
1139      CALL section_add_keyword(section, keyword)
1140      CALL keyword_release(keyword)
1141
1142      CALL keyword_create( &
1143         keyword, __LOCATION__, name="KPOINTS", &
1144         description="For periodic calculations, using kpoints for the density response and the "// &
1145         "Coulomb operator are strongly recommended. For 2d periodic systems (e.g. xy "// &
1146         "periodicity, please specify KPOINTS  N_x  0  N_z.", &
1147         usage="KPOINTS  N_x  N_y  N_z", &
1148         n_var=3, type_of_var=integer_t, default_i_vals=(/0, 0, 0/))
1149      CALL section_add_keyword(section, keyword)
1150      CALL keyword_release(keyword)
1151
1152      CALL keyword_create( &
1153         keyword, __LOCATION__, &
1154         name="EXP_KPOINTS", &
1155         description="For kpoints in low-scaling GW, a Monkhorst-Pack mesh is used. Because the screened Coulomb "// &
1156         "interaction W(k) diverges at the Gamma point with W(k) ~ k^alpha, we adapt the weights of the "// &
1157         "Monkhorst-Pack mesh to compute int_BZ k^alpha dk (BZ=Brllouin zone) correctly with the Monkhorst-Pack "// &
1158         "mesh. You can enter here the exponent alpha. For solids, the exponent is -2 (known from plane waves), "// &
1159         "for 2d periodic systems -1 and for 1d systems W(k) ~ log(1-cos(a*k)) where a is the length of the unit "// &
1160         "cell in periodic direction. If you enter 1.0, one of these three functions are picked according to the "// &
1161         "periodicity. If you enter a value bigger than 2.0, the ordinary Monkhorst-Pack mesh with identical "// &
1162         "weights is chosen.", &
1163         usage="EXP_KPOINTS -2.0", &
1164         default_r_val=1.0_dp)
1165      CALL section_add_keyword(section, keyword)
1166      CALL keyword_release(keyword)
1167
1168      CALL keyword_create( &
1169         keyword, __LOCATION__, &
1170         name="MIN_BLOCK_SIZE", &
1171         description="Minimum tensor block size. Adjusting this value may have minor effect on "// &
1172         "performance but default should be good enough.", &
1173         default_i_val=5)
1174      CALL section_add_keyword(section, keyword)
1175      CALL keyword_release(keyword)
1176
1177      NULLIFY (subsection)
1178      CALL section_create(subsection, __LOCATION__, name="TEST", &
1179                          description="Manually set performance-critical parameters that are otherwise automatically chosen. "// &
1180                          "This section should not be "// &
1181                          "placed except for testing/debugging.", &
1182                          repeats=.FALSE.)
1183
1184      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
1185                          description="Activates use of parameters in this section.", &
1186                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1187      CALL section_add_keyword(subsection, keyword)
1188      CALL keyword_release(keyword)
1189
1190      CALL keyword_create(keyword, __LOCATION__, name="GROUP_SIZE_3c", &
1191                          description= &
1192                          "Group size used for "// &
1193                          "the multiplication M^occ/virt(it)=(alpha beta P)*D^occ/virt.", &
1194                          usage="GROUP_SIZE_3c 8", &
1195                          default_i_val=1)
1196      CALL section_add_keyword(subsection, keyword)
1197      CALL keyword_release(keyword)
1198
1199      CALL keyword_create(keyword, __LOCATION__, name="GROUP_SIZE_P", &
1200                          description= &
1201                          "Group size used for the calculation of P(it)=(Mocc(it))^T*Mvirt(it). ", &
1202                          usage="GROUP_SIZE_P 8", &
1203                          default_i_val=1)
1204      CALL section_add_keyword(subsection, keyword)
1205      CALL keyword_release(keyword)
1206
1207      CALL section_add_subsection(section, subsection)
1208      CALL section_release(subsection)
1209
1210   END SUBROUTINE
1211
1212! **************************************************************************************************
1213!> \brief ...
1214!> \param section ...
1215! **************************************************************************************************
1216   SUBROUTINE create_wfc_gpw(section)
1217      TYPE(section_type), POINTER                        :: section
1218
1219      CHARACTER(len=*), PARAMETER :: routineN = 'create_wfc_gpw', routineP = moduleN//':'//routineN
1220
1221      TYPE(keyword_type), POINTER                        :: keyword
1222
1223      CPASSERT(.NOT. ASSOCIATED(section))
1224      CALL section_create(section, __LOCATION__, name="WFC_GPW", &
1225                          description="Parameters for the GPW approach in Wavefunction-based Correlation methods", &
1226                          n_keywords=5, n_subsections=0, repeats=.FALSE.)
1227
1228      NULLIFY (keyword)
1229      CALL keyword_create(keyword, __LOCATION__, name="EPS_GRID", &
1230                          description="Determines a threshold for the GPW based integration", &
1231                          usage="EPS_GRID 1.0E-9 ", type_of_var=real_t, &
1232                          default_r_val=1.0E-8_dp)
1233      CALL section_add_keyword(section, keyword)
1234      CALL keyword_release(keyword)
1235
1236      CALL keyword_create( &
1237         keyword, __LOCATION__, name="EPS_FILTER", &
1238         description="Determines a threshold for the DBCSR based multiply (usually 10 times smaller than EPS_GRID)."// &
1239         "Normally, this EPS_FILTER determines accuracy and timing of cubic-scaling RPA calculation.", &
1240         usage="EPS_FILTER 1.0E-10 ", type_of_var=real_t, &
1241         default_r_val=1.0E-9_dp)
1242      CALL section_add_keyword(section, keyword)
1243      CALL keyword_release(keyword)
1244
1245      CALL keyword_create(keyword, __LOCATION__, name="CUTOFF", &
1246                          description="The cutoff of the finest grid level in the MP2 gpw integration.", &
1247                          usage="CUTOFF 300", type_of_var=real_t, &
1248                          default_r_val=300.0_dp)
1249      CALL section_add_keyword(section, keyword)
1250      CALL keyword_release(keyword)
1251
1252      CALL keyword_create(keyword, __LOCATION__, name="REL_CUTOFF", &
1253                          variants=(/"RELATIVE_CUTOFF"/), &
1254                          description="Determines the grid at which a Gaussian is mapped.", &
1255                          usage="REL_CUTOFF 50", type_of_var=real_t, &
1256                          default_r_val=50.0_dp)
1257      CALL section_add_keyword(section, keyword)
1258      CALL keyword_release(keyword)
1259
1260      CALL keyword_create(keyword, __LOCATION__, name="PRINT_LEVEL", &
1261                          variants=(/"IOLEVEL"/), &
1262                          description="How much output is written by the individual groups.", &
1263                          usage="PRINT_LEVEL HIGH", &
1264                          default_i_val=silent_print_level, enum_c_vals= &
1265                          s2a("SILENT", "LOW", "MEDIUM", "HIGH", "DEBUG"), &
1266                          enum_desc=s2a("Almost no output", &
1267                                        "Little output", "Quite some output", "Lots of output", &
1268                                        "Everything is written out, useful for debugging purposes only"), &
1269                          enum_i_vals=(/silent_print_level, low_print_level, medium_print_level, &
1270                                        high_print_level, debug_print_level/))
1271      CALL section_add_keyword(section, keyword)
1272      CALL keyword_release(keyword)
1273
1274      CALL keyword_create( &
1275         keyword, __LOCATION__, name="EPS_PGF_ORB_S", &
1276         description="Screening for overlap matrix in RI. Usually, it is best to choose this parameter "// &
1277         "to be very small since the inversion of overlap matrix might be ill-conditioned.", &
1278         usage="EPS_PGF_ORB_S 1.0E-10 ", type_of_var=real_t, &
1279         default_r_val=1.0E-10_dp)
1280      CALL section_add_keyword(section, keyword)
1281      CALL keyword_release(keyword)
1282
1283   END SUBROUTINE create_wfc_gpw
1284
1285! **************************************************************************************************
1286!> \brief ...
1287!> \param section ...
1288! **************************************************************************************************
1289   SUBROUTINE create_cphf(section)
1290      TYPE(section_type), POINTER                        :: section
1291
1292      CHARACTER(len=*), PARAMETER :: routineN = 'create_cphf', routineP = moduleN//':'//routineN
1293
1294      TYPE(keyword_type), POINTER                        :: keyword
1295
1296      CPASSERT(.NOT. ASSOCIATED(section))
1297      CALL section_create( &
1298         section, __LOCATION__, name="CPHF", &
1299         description="Parameters influencing the solution of the Z-vector equations in MP2 gradients calculations.", &
1300         n_keywords=2, n_subsections=0, repeats=.FALSE., &
1301         citations=(/DelBen2013/))
1302
1303      NULLIFY (keyword)
1304
1305      CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
1306                          variants=(/"MAX_NUM_ITER"/), &
1307                          description="Maximum number of iterations allowed for the solution of the Z-vector equations.", &
1308                          usage="MAX_ITER  50", &
1309                          default_i_val=30)
1310      CALL section_add_keyword(section, keyword)
1311      CALL keyword_release(keyword)
1312
1313      CALL keyword_create(keyword, __LOCATION__, name="EPS_CONV", &
1314                          description="Convergence threshold for the solution of the Z-vector equations. "// &
1315                          "The Z-vector equations have the form of a linear system of equations Ax=b, "// &
1316                          "convergence is achieved when |Ax-b|<=EPS_CONV.", &
1317                          usage="EPS_CONV 1.0E-6", type_of_var=real_t, &
1318                          default_r_val=1.0E-4_dp)
1319      CALL section_add_keyword(section, keyword)
1320      CALL keyword_release(keyword)
1321
1322   END SUBROUTINE create_cphf
1323
1324! **************************************************************************************************
1325!> \brief ...
1326!> \param section ...
1327! **************************************************************************************************
1328   SUBROUTINE create_mp2_potential(section)
1329      TYPE(section_type), POINTER                        :: section
1330
1331      CHARACTER(len=*), PARAMETER :: routineN = 'create_mp2_potential', &
1332         routineP = moduleN//':'//routineN
1333
1334      TYPE(keyword_type), POINTER                        :: keyword
1335
1336      CPASSERT(.NOT. ASSOCIATED(section))
1337      CALL section_create(section, __LOCATION__, name="INTERACTION_POTENTIAL", &
1338                          description="Parameters the interaction potential in computing the biel integrals", &
1339                          n_keywords=4, n_subsections=0, repeats=.FALSE.)
1340
1341      NULLIFY (keyword)
1342      CALL keyword_create( &
1343         keyword, __LOCATION__, &
1344         name="POTENTIAL_TYPE", &
1345         description="Which interaction potential should be used "// &
1346         "(Coulomb, TShPSC operator).", &
1347         usage="POTENTIAL_TYPE TSHPSC", &
1348         enum_c_vals=s2a("COULOMB", "TShPSC", "LONGRANGE"), &
1349         enum_i_vals=(/do_potential_coulomb, &
1350                       do_potential_TShPSC, &
1351                       do_potential_long/), &
1352         enum_desc=s2a("Coulomb potential: 1/r", &
1353                       "TShPSC:<ul><li>1/x - s/Rc for x &le; Rc</li>"// &
1354                       "<li>(1 - s)/Rc - (x - Rc)/Rc^2 + (x - Rc)^2/Rc^3 - "// &
1355                       "(2*n^2 - 7*n + 9 - 4*s)*(x - Rc)^3/(Rc^4*(n^2 - 2*n + 1)*(n - 1)) + "// &
1356                       "(6-3*s - 4*n + n^2)*(x - Rc)^4/(Rc^5*(n^4 - 4*n^3 + 6*n^2 - 4*n + 1)) "// &
1357                       "for Rc &lt; x &le; n*Rc (4th order polynomial)</li>"// &
1358                       "<li>0 for x &gt; n*Rc</li></ul>", &
1359                       "Longrange Coulomg potential: erf(w*r)/r)"), &
1360         default_i_val=do_potential_coulomb)
1361      CALL section_add_keyword(section, keyword)
1362      CALL keyword_release(keyword)
1363
1364      CALL keyword_create(keyword, __LOCATION__, name="TRUNCATION_RADIUS", &
1365                          description="Determines truncation radius for the truncated TShPSC potential. "// &
1366                          "Only valid when doing truncated calculation", &
1367                          usage="TRUNCATION_RADIUS 10.0", type_of_var=real_t, &
1368                          default_r_val=10.0_dp, &
1369                          unit_str="angstrom")
1370      CALL section_add_keyword(section, keyword)
1371      CALL keyword_release(keyword)
1372
1373      CALL keyword_create( &
1374         keyword, __LOCATION__, &
1375         name="TShPSC_DATA", &
1376         description="Location of the file TShPSC.dat that contains the data for the "// &
1377         "evaluation of the TShPSC G0 ", &
1378         usage="TShPSC_DATA t_sh_p_s_c.dat", &
1379         default_c_val="t_sh_p_s_c.dat")
1380      CALL section_add_keyword(section, keyword)
1381      CALL keyword_release(keyword)
1382
1383      CALL keyword_create( &
1384         keyword, __LOCATION__, &
1385         name="OMEGA", &
1386         description="Range separation parameter for the longrange potential. Only valid when longrange potential is requested.", &
1387         usage="OMEGA 0.5", type_of_var=real_t, &
1388         default_r_val=0.5_dp)
1389      CALL section_add_keyword(section, keyword)
1390      CALL keyword_release(keyword)
1391
1392   END SUBROUTINE create_mp2_potential
1393
1394! **************************************************************************************************
1395!> \brief ...
1396!> \param section ...
1397! **************************************************************************************************
1398   SUBROUTINE create_ri_section(section)
1399      TYPE(section_type), POINTER                        :: section
1400
1401      CHARACTER(len=*), PARAMETER :: routineN = 'create_ri_section', &
1402         routineP = moduleN//':'//routineN
1403
1404      TYPE(keyword_type), POINTER                        :: keyword
1405      TYPE(section_type), POINTER                        :: subsection
1406
1407      CPASSERT(.NOT. ASSOCIATED(section))
1408      CALL section_create(section, __LOCATION__, name="RI", &
1409                          description="Parameters influencing resolution of the identity (RI) that is"// &
1410                          "used in RI-MP2, RI-RPA, RI-SOS-MP2 and GW (inside RI-RPA).", &
1411                          n_keywords=6, n_subsections=2, repeats=.FALSE.)
1412
1413      NULLIFY (subsection)
1414      CALL create_RI_metric_section(subsection)
1415      CALL section_add_subsection(section, subsection)
1416      CALL section_release(subsection)
1417
1418      CALL create_opt_ri_basis(subsection)
1419      CALL section_add_subsection(section, subsection)
1420      CALL section_release(subsection)
1421
1422      NULLIFY (keyword)
1423      CALL keyword_create( &
1424         keyword, __LOCATION__, &
1425         name="ROW_BLOCK", &
1426         variants=(/"ROW_BLOCK_SIZE"/), &
1427         description="Size of the row block used in the SCALAPACK block cyclic data distribution."// &
1428         "Default is (ROW_BLOCK=-1) is automatic. "// &
1429         "A proper choice can speedup the parallel matrix multiplication in the case of RI-RPA and RI-SOS-MP2-Laplace.", &
1430         usage="ROW_BLOCK 512", &
1431         default_i_val=-1)
1432      CALL section_add_keyword(section, keyword)
1433      CALL keyword_release(keyword)
1434
1435      CALL keyword_create( &
1436         keyword, __LOCATION__, &
1437         name="COL_BLOCK", &
1438         variants=(/"COL_BLOCK_SIZE"/), &
1439         description="Size of the column block used in the SCALAPACK block cyclic data distribution."// &
1440         "Default is (COL_BLOCK=-1) is automatic. "// &
1441         "A proper choice can speedup the parallel matrix multiplication in the case of RI-RPA and RI-SOS-MP2-Laplace.", &
1442         usage="COL_BLOCK 512", &
1443         default_i_val=-1)
1444      CALL section_add_keyword(section, keyword)
1445      CALL keyword_release(keyword)
1446
1447      CALL keyword_create( &
1448         keyword, __LOCATION__, &
1449         name="CALC_COND_NUM", &
1450         variants=(/"CALC_CONDITION_NUMBER"/), &
1451         description="Calculate the condition number of the (P|Q) matrix for the RI methods.", &
1452         usage="CALC_COND_NUM", &
1453         default_l_val=.FALSE., &
1454         lone_keyword_l_val=.TRUE.)
1455      CALL section_add_keyword(section, keyword)
1456      CALL keyword_release(keyword)
1457
1458      CALL keyword_create(keyword, __LOCATION__, name="DO_SVD", &
1459                          description="Wether to perform a singular value decomposition instead of the Cholesky decomposition "// &
1460                          "of the potential operator in the RI basis. Computationally expensive but numerically more stable. "// &
1461                          "It reduces the computational costs of some subsequent steps. Recommended when a longrange Coulomb "// &
1462                          "potential is employed.", &
1463                          usage="DO_SVD  .TRUE.", &
1464                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1465      CALL section_add_keyword(section, keyword)
1466      CALL keyword_release(keyword)
1467
1468      CALL keyword_create(keyword, __LOCATION__, name="EPS_SVD", &
1469                          description="Include all singular vectors with a singular value smaller than EPS_SVD. "// &
1470                          "Is used to provide info on smallest eigenvalues.", &
1471                          usage="EPS_SVD  1.0e-5", &
1472                          default_r_val=1.0E-3_dp)
1473      CALL section_add_keyword(section, keyword)
1474      CALL keyword_release(keyword)
1475
1476      CALL keyword_create(keyword, __LOCATION__, name="ERI_BLKSIZE", &
1477                          description="block sizes for tensors (only used if ERI_METHOD=MME). First value "// &
1478                          "is the block size for ORB basis, second value is the block size for RI_AUX basis.", &
1479                          usage="ERI_BLKSIZE", &
1480                          n_var=2, &
1481                          default_i_vals=(/4, 16/))
1482      CALL section_add_keyword(section, keyword)
1483      CALL keyword_release(keyword)
1484
1485   END SUBROUTINE create_ri_section
1486
1487! **************************************************************************************************
1488!> \brief ...
1489!> \param section ...
1490! **************************************************************************************************
1491   SUBROUTINE create_integrals_section(section)
1492      TYPE(section_type), POINTER                        :: section
1493
1494      CHARACTER(len=*), PARAMETER :: routineN = 'create_integrals_section', &
1495         routineP = moduleN//':'//routineN
1496
1497      TYPE(keyword_type), POINTER                        :: keyword
1498      TYPE(section_type), POINTER                        :: subsection
1499
1500      CPASSERT(.NOT. ASSOCIATED(section))
1501      CALL section_create(section, __LOCATION__, name="INTEGRALS", &
1502                          description="Parameters controlling how to compute integrals that are needed "// &
1503                          "in MP2, RI-MP2, RI-RPA, RI-SOS-MP2 and GW (inside RI-RPA).", &
1504                          n_keywords=2, n_subsections=3, repeats=.FALSE.)
1505
1506      NULLIFY (subsection)
1507      CALL create_eri_mme_section(subsection)
1508      CALL section_add_subsection(section, subsection)
1509      CALL section_release(subsection)
1510
1511      CALL create_wfc_gpw(subsection)
1512      CALL section_add_subsection(section, subsection)
1513      CALL section_release(subsection)
1514
1515      CALL create_mp2_potential(subsection)
1516      CALL section_add_subsection(section, subsection)
1517      CALL section_release(subsection)
1518
1519      NULLIFY (keyword)
1520      CALL keyword_create(keyword, __LOCATION__, name="ERI_METHOD", &
1521                          description="Method for calculating periodic electron repulsion integrals "// &
1522                          "(MME method is faster but experimental, forces not yet implemented)."// &
1523                          "Obara-Saika (OS) for the Coulomb operator can only be used for non-periodic calculations.", &
1524                          usage="ERI_METHOD MME", &
1525                          enum_c_vals=s2a("DEFAULT", "GPW", "MME", "OS"), &
1526                          enum_i_vals=(/eri_default, do_eri_gpw, do_eri_mme, do_eri_os/), &
1527                          enum_desc=s2a("Use default ERI method (for periodic systems: GPW, for molecules: OS, "// &
1528                                        "for MP2 and RI-MP2: GPW in any case).", &
1529                                        "Uses Gaussian Plane Wave method [DelBen2013].", &
1530                                        "Uses MiniMax-Ewald method (experimental, ERI_MME subsection, only for fully periodic "// &
1531                                        "systems with orthorhombic cells).", &
1532                                        "Use analytical Obara-Saika method."), &
1533                          default_i_val=eri_default)
1534      CALL section_add_keyword(section, keyword)
1535      CALL keyword_release(keyword)
1536
1537      CALL keyword_create(keyword, __LOCATION__, name="SIZE_LATTICE_SUM", &
1538                          description="Size of sum range L. ", &
1539                          usage="SIZE_LATTICE_SUM  10", &
1540                          default_i_val=6)
1541      CALL section_add_keyword(section, keyword)
1542      CALL keyword_release(keyword)
1543
1544   END SUBROUTINE create_integrals_section
1545
1546! **************************************************************************************************
1547!> \brief ...
1548!> \param section ...
1549! **************************************************************************************************
1550   SUBROUTINE create_RI_metric_section(section)
1551      TYPE(section_type), POINTER                        :: section
1552
1553      CHARACTER(len=*), PARAMETER :: routineN = 'create_RI_metric_section', &
1554         routineP = moduleN//':'//routineN
1555
1556      TYPE(keyword_type), POINTER                        :: keyword
1557
1558      CPASSERT(.NOT. ASSOCIATED(section))
1559      CALL section_create(section, __LOCATION__, name="RI_METRIC", &
1560                          description="Sets up RI metric", &
1561                          repeats=.FALSE.)
1562
1563      NULLIFY (keyword)
1564      CALL keyword_create( &
1565         keyword, __LOCATION__, &
1566         name="POTENTIAL_TYPE", &
1567         description="Decides which operator/metric is used for resolution of the identity (RI).", &
1568         usage="POTENTIAL_TYPE DEFAULT", &
1569         enum_c_vals=s2a("DEFAULT", "COULOMB", "IDENTITY", "LONGRANGE", "SHORTRANGE", "TRUNCATED"), &
1570         enum_i_vals=(/ri_default, do_potential_coulomb, do_potential_id, do_potential_long, &
1571                       do_potential_short, do_potential_truncated/), &
1572         enum_desc=s2a("Use Coulomb metric for RI-MP2 and normal-scaling RI-SOS-MP2, RI-RPA and GW. "// &
1573                       "Use Overlap metric for low-scaling RI-SOS-MP2, RI-RPA and GW for periodic systems. "// &
1574                       "Use truncated Coulomb metric for low-scaling RI-SOS-MP2, RI-RPA and GW for non-periodic systems.", &
1575                       "Coulomb metric: 1/r. Recommended for RI-MP2,", &
1576                       "Overlap metric: delta(r).", &
1577                       "Longrange metric: erf(omega*r)/r. Not recommended with DO_SVD .TRUE.", &
1578                       "Shortrange metric: erfc(omega*r)/r", &
1579                       "Truncated Coulomb metric: if (r &lt; R_c) 1/r else 0. More "// &
1580                       "accurate than IDENTITY for non-periodic systems. Recommended for low-scaling methods."), &
1581         default_i_val=ri_default)
1582      CALL section_add_keyword(section, keyword)
1583      CALL keyword_release(keyword)
1584
1585      NULLIFY (keyword)
1586      CALL keyword_create( &
1587         keyword, __LOCATION__, &
1588         name="OMEGA", &
1589         description="The range parameter for the short/long range operator (in 1/a0).", &
1590         usage="OMEGA 0.5", &
1591         default_r_val=0.0_dp)
1592      CALL section_add_keyword(section, keyword)
1593      CALL keyword_release(keyword)
1594
1595      CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
1596                          description="The cutoff radius (in Angstrom) for the truncated Coulomb operator.", &
1597                          usage="CUTOFF_RADIUS 3.0", default_r_val=cp_unit_to_cp2k(value=3.0_dp, unit_str="angstrom"), &
1598                          type_of_var=real_t, unit_str="angstrom")
1599      CALL section_add_keyword(section, keyword)
1600      CALL keyword_release(keyword)
1601
1602      CALL keyword_create( &
1603         keyword, __LOCATION__, &
1604         name="T_C_G_DATA", &
1605         description="Location of the file t_c_g.dat that contains the data for the "// &
1606         "evaluation of the truncated gamma function ", &
1607         default_c_val="t_c_g.dat")
1608      CALL section_add_keyword(section, keyword)
1609      CALL keyword_release(keyword)
1610
1611      CALL keyword_create(keyword, __LOCATION__, name="EPS_RANGE", &
1612                          description="The threshold to determine the effective range of the short range "// &
1613                          "RI metric: erfc(omega*eff_range)/eff_range = EPS_RANGE", &
1614                          default_r_val=1.0E-08_dp, &
1615                          repeats=.FALSE.)
1616      CALL section_add_keyword(section, keyword)
1617      CALL keyword_release(keyword)
1618
1619   END SUBROUTINE create_RI_metric_section
1620
1621END MODULE input_cp2k_mp2
1622