LCOV - code coverage report
Current view: top level - src - input_cp2k_hfx.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:40fb615) Lines: 100.0 % 271 271
Test Date: 2026-07-05 06:50:58 Functions: 100.0 % 8 8

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief function that builds the hartree fock exchange section of the input
      10              : !> \par History
      11              : !>      09.2007 created
      12              : !> \author Manuel Guidon
      13              : ! **************************************************************************************************
      14              : MODULE input_cp2k_hfx
      15              :    USE bibliography, ONLY: Guidon2008, &
      16              :                            Guidon2009, &
      17              :                            Lin2016ACE
      18              :    USE cp_output_handling, ONLY: add_last_numeric, &
      19              :                                  cp_print_key_section_create, &
      20              :                                  high_print_level, &
      21              :                                  medium_print_level
      22              :    USE input_constants, ONLY: &
      23              :       do_potential_coulomb, do_potential_gaussian, do_potential_id, do_potential_long, &
      24              :       do_potential_mix_cl, do_potential_mix_cl_trunc, do_potential_mix_lg, do_potential_short, &
      25              :       do_potential_truncated, ehrenfest, gaussian, hfx_ri_do_2c_cholesky, hfx_ri_do_2c_diag, &
      26              :       hfx_ri_do_2c_iter, hfx_library_is_both, hfx_library_is_libGint, &
      27              :       hfx_library_is_libint
      28              :    USE input_keyword_types, ONLY: keyword_create, &
      29              :                                   keyword_release, &
      30              :                                   keyword_type
      31              :    USE input_section_types, ONLY: section_add_keyword, &
      32              :                                   section_add_subsection, &
      33              :                                   section_create, &
      34              :                                   section_release, &
      35              :                                   section_type
      36              :    USE input_val_types, ONLY: real_t
      37              :    USE kinds, ONLY: dp
      38              :    USE string_utilities, ONLY: s2a
      39              : 
      40              : #include "./base/base_uses.f90"
      41              : 
      42              :    IMPLICIT NONE
      43              :    PRIVATE
      44              : 
      45              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .FALSE.
      46              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_hfx'
      47              :    INTEGER, PARAMETER, PUBLIC                 :: ri_mo = 1, ri_pmat = 2
      48              : 
      49              :    PUBLIC :: create_hfx_section
      50              : 
      51              : CONTAINS
      52              : 
      53              : ! **************************************************************************************************
      54              : !> \brief creates the input section for the hf part
      55              : !> \param section the section to create
      56              : !> \author Manuel Guidon
      57              : ! **************************************************************************************************
      58       249552 :    SUBROUTINE create_hfx_section(section)
      59              :       TYPE(section_type), POINTER                        :: section
      60              : 
      61              :       TYPE(keyword_type), POINTER                        :: keyword
      62              :       TYPE(section_type), POINTER                        :: print_key, subsection
      63              : 
      64       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
      65              :       CALL section_create(section, __LOCATION__, name="HF", &
      66              :                           description="Controls Hartree-Fock exchange for hybrid DFT, Hartree-Fock, "// &
      67              :                           "and related post-Hartree-Fock workflows.", &
      68              :                           n_keywords=5, n_subsections=2, repeats=.TRUE., &
      69       748656 :                           citations=[Guidon2008, Guidon2009])
      70              : 
      71       249552 :       NULLIFY (keyword, print_key, subsection)
      72              : 
      73              :       CALL keyword_create(keyword, __LOCATION__, name="FRACTION", &
      74              :                           description="Fraction of Hartree-Fock exchange to add to the total energy. "// &
      75              :                           "1.0 implies standard Hartree-Fock if used with XC_FUNCTIONAL NONE. "// &
      76              :                           "NOTE: In a mixed potential calculation this should be set to 1.0, otherwise "// &
      77              :                           "all parts are multiplied with this factor. ", &
      78       249552 :                           usage="FRACTION 1.0", default_r_val=1.0_dp)
      79       249552 :       CALL section_add_keyword(section, keyword)
      80       249552 :       CALL keyword_release(keyword)
      81              : 
      82              :       CALL keyword_create(keyword, __LOCATION__, name="TREAT_LSD_IN_CORE", &
      83              :                           description="Determines how spin densities are taken into account. "// &
      84              :                           "If true, the beta spin density is included via a second in core call. "// &
      85              :                           "If false, alpha and beta spins are done in one shot ", &
      86       249552 :                           usage="TREAT_LSD_IN_CORE TRUE", default_l_val=.FALSE.)
      87       249552 :       CALL section_add_keyword(section, keyword)
      88       249552 :       CALL keyword_release(keyword)
      89              : 
      90              :       CALL keyword_create( &
      91              :          keyword, __LOCATION__, &
      92              :          name="HFX_LIBRARY", &
      93              :          description="Which library should be used in the calculation of the HF exchange "// &
      94              :          "(Libint (cpu, default), libGint(gpu, cuda), both(debug,temporary)", &
      95              :          usage="HFX_LIBRARY libGint", &
      96              :          enum_c_vals=s2a("libint", "libGint", "both"), &
      97              :          enum_i_vals=[hfx_library_is_libint, hfx_library_is_libGint, hfx_library_is_both], &
      98              :          enum_desc=s2a("libint: use the libint library to compute the 2 electron integrals for HFX/r", &
      99              :                        "libGint: use the libGint library to accelerate the calculation of the HF "// &
     100              :                        "exchange on (cuda) GPUs /r", &
     101              :                        "both: temporary debug option, will run both libint and libGint and "// &
     102              :                        "check if the fock matrix is within tolerance"), &
     103       249552 :          default_i_val=hfx_library_is_libint)
     104       249552 :       CALL section_add_keyword(section, keyword)
     105       249552 :       CALL keyword_release(keyword)
     106              : 
     107              :       CALL keyword_create(keyword, __LOCATION__, name="PW_HFX", &
     108              :                           description="Compute the Hartree-Fock energy also in the plane wave basis. "// &
     109              :                           "The value is ignored, and intended for debugging only.", &
     110       249552 :                           usage="PW_HFX FALSE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     111       249552 :       CALL section_add_keyword(section, keyword)
     112       249552 :       CALL keyword_release(keyword)
     113              : 
     114              :       CALL keyword_create(keyword, __LOCATION__, name="PW_HFX_BLOCKSIZE", &
     115              :                           description="Improve the performance of pw_hfx at the cost of some additional memory "// &
     116              :                           "by storing the realspace representation of PW_HFX_BLOCKSIZE states.", &
     117       249552 :                           usage="PW_HFX_BLOCKSIZE 20", default_i_val=20)
     118       249552 :       CALL section_add_keyword(section, keyword)
     119       249552 :       CALL keyword_release(keyword)
     120              : 
     121       249552 :       NULLIFY (print_key)
     122              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "HF_INFO", &
     123              :                                        description="Controls the printing basic info about hf method", &
     124       249552 :                                        print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     125       249552 :       CALL section_add_subsection(section, print_key)
     126       249552 :       CALL section_release(print_key)
     127              : 
     128       249552 :       CALL create_hf_pbc_section(subsection)
     129       249552 :       CALL section_add_subsection(section, subsection)
     130       249552 :       CALL section_release(subsection)
     131              : 
     132       249552 :       CALL create_hf_screening_section(subsection)
     133       249552 :       CALL section_add_subsection(section, subsection)
     134       249552 :       CALL section_release(subsection)
     135              : 
     136       249552 :       CALL create_hf_potential_section(subsection)
     137       249552 :       CALL section_add_subsection(section, subsection)
     138       249552 :       CALL section_release(subsection)
     139              : 
     140       249552 :       CALL create_hf_load_balance_section(subsection)
     141       249552 :       CALL section_add_subsection(section, subsection)
     142       249552 :       CALL section_release(subsection)
     143              : 
     144       249552 :       CALL create_hf_memory_section(subsection)
     145       249552 :       CALL section_add_subsection(section, subsection)
     146       249552 :       CALL section_release(subsection)
     147              : 
     148       249552 :       CALL create_hf_ri_section(subsection)
     149       249552 :       CALL section_add_subsection(section, subsection)
     150       249552 :       CALL section_release(subsection)
     151              : 
     152       249552 :       CALL create_hf_ace_section(subsection)
     153       249552 :       CALL section_add_subsection(section, subsection)
     154       249552 :       CALL section_release(subsection)
     155              : 
     156       249552 :    END SUBROUTINE create_hfx_section
     157              : 
     158              : ! **************************************************************************************************
     159              : !> \brief !****f* input_cp2k_dft/create_hf_load_balance_section [1.0] *
     160              : !>
     161              : !>      creates the input section for the hf potential part
     162              : !> \param section the section to create
     163              : !> \author Manuel Guidon
     164              : ! **************************************************************************************************
     165       249552 :    SUBROUTINE create_hf_load_balance_section(section)
     166              :       TYPE(section_type), POINTER                        :: section
     167              : 
     168              :       TYPE(keyword_type), POINTER                        :: keyword
     169              :       TYPE(section_type), POINTER                        :: print_key
     170              : 
     171       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     172              :       CALL section_create(section, __LOCATION__, name="LOAD_BALANCE", &
     173              :                           description="Parameters influencing the load balancing of the HF", &
     174              :                           n_keywords=1, n_subsections=0, repeats=.FALSE., &
     175       499104 :                           citations=[guidon2008])
     176              : 
     177       249552 :       NULLIFY (keyword)
     178              :       CALL keyword_create( &
     179              :          keyword, __LOCATION__, &
     180              :          name="NBINS", &
     181              :          description="Number of bins per process used to group atom quartets.", &
     182              :          usage="NBINS 32", &
     183       249552 :          default_i_val=64)
     184       249552 :       CALL section_add_keyword(section, keyword)
     185       249552 :       CALL keyword_release(keyword)
     186              : 
     187              :       CALL keyword_create( &
     188              :          keyword, __LOCATION__, &
     189              :          name="BLOCK_SIZE", &
     190              :          description="Determines the blocking used for the atomic quartet loops. "// &
     191              :          "A proper choice can speedup the calculation. The default (-1) is automatic.", &
     192              :          usage="BLOCK_SIZE 4", &
     193       249552 :          default_i_val=-1)
     194       249552 :       CALL section_add_keyword(section, keyword)
     195       249552 :       CALL keyword_release(keyword)
     196              : 
     197       249552 :       NULLIFY (keyword)
     198              :       CALL keyword_create( &
     199              :          keyword, __LOCATION__, &
     200              :          name="RANDOMIZE", &
     201              :          description="This flag controls the randomization of the bin assignment to processes. "// &
     202              :          "For highly ordered input structures with a bad load balance, setting "// &
     203              :          "this flag to TRUE might improve.", &
     204              :          usage="RANDOMIZE TRUE", &
     205       249552 :          default_l_val=.FALSE.)
     206       249552 :       CALL section_add_keyword(section, keyword)
     207       249552 :       CALL keyword_release(keyword)
     208              : 
     209       249552 :       NULLIFY (print_key)
     210              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PRINT", &
     211              :                                        description="Controls the printing of info about load balance", &
     212       249552 :                                        print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     213       249552 :       CALL section_add_subsection(section, print_key)
     214              : 
     215       249552 :       CALL keyword_release(keyword)
     216              :       CALL keyword_create(keyword, __LOCATION__, &
     217              :                           name="LOAD_BALANCE_INFO", &
     218              :                           description="Activates the printing of load balance information ", &
     219              :                           default_l_val=.FALSE., &
     220       249552 :                           lone_keyword_l_val=.TRUE.)
     221       249552 :       CALL section_add_keyword(print_key, keyword)
     222       249552 :       CALL keyword_release(keyword)
     223       249552 :       CALL section_release(print_key)
     224              : 
     225       249552 :    END SUBROUTINE create_hf_load_balance_section
     226              : 
     227              : ! **************************************************************************************************
     228              : !> \brief !****f* input_cp2k_dft/create_hf_potential_section [1.0] *
     229              : !>
     230              : !>      creates the input section for the hf potential part
     231              : !> \param section the section to create
     232              : !> \author Manuel Guidon
     233              : ! **************************************************************************************************
     234       249552 :    SUBROUTINE create_hf_potential_section(section)
     235              :       TYPE(section_type), POINTER                        :: section
     236              : 
     237              :       TYPE(keyword_type), POINTER                        :: keyword
     238              : 
     239       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     240              :       CALL section_create(section, __LOCATION__, name="INTERACTION_POTENTIAL", &
     241              :                           description="Defines the Coulomb, range-separated, mixed, or truncated interaction "// &
     242              :                           "operator used for Hartree-Fock exchange.", &
     243              :                           n_keywords=1, n_subsections=0, repeats=.FALSE., &
     244       748656 :                           citations=[guidon2008, guidon2009])
     245              : 
     246       249552 :       NULLIFY (keyword)
     247              :       CALL keyword_create( &
     248              :          keyword, __LOCATION__, &
     249              :          name="POTENTIAL_TYPE", &
     250              :          description="Selects the interaction potential used for Hartree-Fock exchange. "// &
     251              :          "Periodic hybrid calculations commonly use a short-range, truncated, or mixed potential.", &
     252              :          usage="POTENTIAL_TYPE SHORTRANGE", &
     253              :          enum_c_vals=s2a("COULOMB", "SHORTRANGE", "LONGRANGE", "MIX_CL", "GAUSSIAN", &
     254              :                          "MIX_LG", "IDENTITY", "TRUNCATED", "MIX_CL_TRUNC"), &
     255              :          enum_i_vals=[do_potential_coulomb, do_potential_short, do_potential_long, &
     256              :                       do_potential_mix_cl, do_potential_gaussian, do_potential_mix_lg, &
     257              :                       do_potential_id, do_potential_truncated, do_potential_mix_cl_trunc], &
     258              :          enum_desc=s2a("Coulomb potential: $\frac{1}{r}$", &
     259              :                        "Shortrange potential: $\frac{\mathrm{erfc}(\omega \cdot r)}{r}$", &
     260              :                        "Longrange potential: $\frac{\mathrm{erf}(\omega \cdot r)}{r}$", &
     261              :                        "Mix coulomb and longrange potential: $\frac{1}{r} + \frac{\mathrm{erf}(\omega \cdot r)}{r}$", &
     262              :                        "Damped Gaussian potential: $\exp{(-\omega^2 \cdot r^2)}$", &
     263              :                        "Mix Gaussian and longrange potential: "// &
     264              :                        "$\frac{\mathrm{erf}(\omega \cdot r)}{r} + \exp{(-\omega^2 \cdot r^2)}$", &
     265              :                        "Overlap", &
     266              :                        "Truncated coulomb potential: if (r &lt; R_c) 1/r else 0", &
     267              :                        "Truncated Mix coulomb and longrange potential, assumes/requires that the erf has fully decayed at R_c"), &
     268       249552 :          default_i_val=do_potential_coulomb)
     269       249552 :       CALL section_add_keyword(section, keyword)
     270       249552 :       CALL keyword_release(keyword)
     271              : 
     272       249552 :       NULLIFY (keyword)
     273              :       CALL keyword_create( &
     274              :          keyword, __LOCATION__, &
     275              :          name="OMEGA", &
     276              :          description="Parameter $\omega$ for short/longrange interaction", &
     277              :          usage="OMEGA 0.5", &
     278       249552 :          default_r_val=0.0_dp)
     279       249552 :       CALL section_add_keyword(section, keyword)
     280       249552 :       CALL keyword_release(keyword)
     281              : 
     282              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_COULOMB", &
     283              :                           description="Scales Hartree-Fock contribution arising from a coulomb potential. "// &
     284              :                           "Only valid when doing a mixed potential calculation", &
     285       249552 :                           usage="SCALE_COULOMB 1.0", default_r_val=1.0_dp)
     286       249552 :       CALL section_add_keyword(section, keyword)
     287       249552 :       CALL keyword_release(keyword)
     288              : 
     289              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_LONGRANGE", &
     290              :                           description="Scales Hartree-Fock contribution arising from a longrange potential. "// &
     291              :                           "Only valid when doing a mixed potential calculation", &
     292       249552 :                           usage="SCALE_LONGRANGE 1.0", default_r_val=1.0_dp)
     293       249552 :       CALL section_add_keyword(section, keyword)
     294       249552 :       CALL keyword_release(keyword)
     295              : 
     296              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_GAUSSIAN", &
     297              :                           description="Scales Hartree-Fock contribution arising from a gaussian potential. "// &
     298              :                           "Only valid when doing a mixed potential calculation", &
     299       249552 :                           usage="SCALE_GAUSSIAN 1.0", default_r_val=1.0_dp)
     300       249552 :       CALL section_add_keyword(section, keyword)
     301       249552 :       CALL keyword_release(keyword)
     302              : 
     303              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     304              :                           description="Cutoff radius for the truncated $\frac{1}{r}$ potential or the short-range "// &
     305              :                           "$\frac{\mathrm{erfc}(\omega \cdot r)}{r}$ potential. For truncated Coulomb in a "// &
     306              :                           "periodic cell, choose a radius compatible with the cell dimensions. The default value "// &
     307              :                           "for short-range potentials when this keyword is omitted is solved from "// &
     308              :                           "$\frac{\mathrm{erfc}(\omega \cdot r)}{r} = \epsilon_{\mathrm{schwarz}}$ "// &
     309              :                           "by Newton-Raphson method, with $\epsilon_{\mathrm{schwarz}}$ set by SCREENING/EPS_SCHWARZ", &
     310              :                           usage="CUTOFF_RADIUS 10.0", type_of_var=real_t, & ! default_r_val=10.0_dp,&
     311       249552 :                           unit_str="angstrom")
     312       249552 :       CALL section_add_keyword(section, keyword)
     313       249552 :       CALL keyword_release(keyword)
     314              : 
     315              :       CALL keyword_create( &
     316              :          keyword, __LOCATION__, &
     317              :          name="T_C_G_DATA", &
     318              :          description="Location of the file t_c_g.dat that contains the data for the "// &
     319              :          "evaluation of the truncated gamma function ", &
     320              :          usage="T_C_G_DATA /data/t_c_g.dat", &
     321       249552 :          default_c_val="t_c_g.dat")
     322       249552 :       CALL section_add_keyword(section, keyword)
     323       249552 :       CALL keyword_release(keyword)
     324              : 
     325       249552 :    END SUBROUTINE create_hf_potential_section
     326              : 
     327              : !****f* input_cp2k_dft/create_hf_screening_section [1.0] *
     328              : 
     329              : ! **************************************************************************************************
     330              : !> \brief creates the input section for the hf screening part
     331              : !> \param section the section to create
     332              : !> \author Manuel Guidon
     333              : ! **************************************************************************************************
     334       249552 :    SUBROUTINE create_hf_screening_section(section)
     335              :       TYPE(section_type), POINTER                        :: section
     336              : 
     337              :       TYPE(keyword_type), POINTER                        :: keyword
     338              : 
     339       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     340              :       CALL section_create(section, __LOCATION__, name="SCREENING", &
     341              :                           description="Controls screening thresholds for Hartree-Fock exchange integrals.", &
     342              :                           n_keywords=1, n_subsections=0, repeats=.FALSE., &
     343       748656 :                           citations=[guidon2008, guidon2009])
     344              : 
     345       249552 :       NULLIFY (keyword)
     346              :       CALL keyword_create( &
     347              :          keyword, __LOCATION__, &
     348              :          name="EPS_SCHWARZ", &
     349              :          description="Schwarz inequality threshold for screening near-field electronic repulsion integrals. "// &
     350              :          "Tighter values reduce screening error but increase cost.", &
     351              :          usage="EPS_SCHWARZ 1.0E-6", &
     352       249552 :          default_r_val=1.0E-10_dp)
     353       249552 :       CALL section_add_keyword(section, keyword)
     354       249552 :       CALL keyword_release(keyword)
     355              : 
     356       249552 :       NULLIFY (keyword)
     357              :       CALL keyword_create( &
     358              :          keyword, __LOCATION__, &
     359              :          name="EPS_SCHWARZ_FORCES", &
     360              :          description="Schwarz threshold used for force-related electronic repulsion integrals. "// &
     361              :          "This is approximately the force accuracy and should normally be similar to EPS_SCF. "// &
     362              :          "Default value is 100*EPS_SCHWARZ.", &
     363              :          usage="EPS_SCHWARZ_FORCES 1.0E-5", &
     364       249552 :          default_r_val=1.0E-6_dp)
     365       249552 :       CALL section_add_keyword(section, keyword)
     366       249552 :       CALL keyword_release(keyword)
     367              : 
     368       249552 :       NULLIFY (keyword)
     369              :       CALL keyword_create( &
     370              :          keyword, __LOCATION__, &
     371              :          name="SCREEN_P_FORCES", &
     372              :          description="Screens the electronic repulsion integrals for the forces "// &
     373              :          "using the density matrix. Will be disabled for the "// &
     374              :          "response part of forces in MP2/RPA/TDDFT. "// &
     375              :          "This results in a significant speedup for large systems, "// &
     376              :          "but might require a somewhat tigher EPS_SCHWARZ_FORCES.", &
     377              :          usage="SCREEN_P_FORCES TRUE", &
     378       249552 :          default_l_val=.TRUE.)
     379       249552 :       CALL section_add_keyword(section, keyword)
     380       249552 :       CALL keyword_release(keyword)
     381              : 
     382       249552 :       NULLIFY (keyword)
     383              :       CALL keyword_create(keyword, __LOCATION__, name="SCREEN_ON_INITIAL_P", &
     384              :                           description="Screen on an initial density matrix. For the first MD step"// &
     385              :                           " this matrix must be provided by a Restart File.", &
     386       249552 :                           usage="SCREEN_ON_INITIAL_P  TRUE", default_l_val=.FALSE.)
     387       249552 :       CALL section_add_keyword(section, keyword)
     388       249552 :       CALL keyword_release(keyword)
     389              : 
     390       249552 :       NULLIFY (keyword)
     391              :       CALL keyword_create(keyword, __LOCATION__, name="P_SCREEN_CORRECTION_FACTOR", &
     392              :                           description="Recalculates integrals on the fly if the actual density matrix is"// &
     393              :                           " larger by a given factor than the initial one. If the factor is set"// &
     394              :                           " to 0.0_dp, this feature is disabled.", &
     395       249552 :                           usage="P_SCREEN_CORRECTION_FACTOR  0.0_dp", default_r_val=0.0_dp)
     396       249552 :       CALL section_add_keyword(section, keyword)
     397       249552 :       CALL keyword_release(keyword)
     398              : 
     399       249552 :    END SUBROUTINE create_hf_screening_section
     400              : 
     401              : ! **************************************************************************************************
     402              : !> \brief creates the input section for the hf-pbc part
     403              : !> \param section the section to create
     404              : !> \author Manuel Guidon
     405              : ! **************************************************************************************************
     406       249552 :    SUBROUTINE create_hf_pbc_section(section)
     407              :       TYPE(section_type), POINTER                        :: section
     408              : 
     409              :       TYPE(keyword_type), POINTER                        :: keyword
     410              : 
     411       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     412              :       CALL section_create(section, __LOCATION__, name="PERIODIC", &
     413              :                           description="Sets up periodic boundary condition parameters if requested ", &
     414              :                           n_keywords=1, n_subsections=0, repeats=.FALSE., &
     415       748656 :                           citations=[guidon2008, guidon2009])
     416       249552 :       NULLIFY (keyword)
     417              :       CALL keyword_create( &
     418              :          keyword, __LOCATION__, &
     419              :          name="NUMBER_OF_SHELLS", &
     420              :          description="Number of shells taken into account for periodicity. "// &
     421              :          "By default, cp2k tries to automatically evaluate this number. "// &
     422              :          "This algorithm might be to conservative, resulting in some overhead. "// &
     423              :          "You can try to adjust this number in order to make a calculation cheaper. ", &
     424              :          usage="NUMBER_OF_SHELLS 2", &
     425       249552 :          default_i_val=-1)
     426       249552 :       CALL section_add_keyword(section, keyword)
     427       249552 :       CALL keyword_release(keyword)
     428              : 
     429       249552 :    END SUBROUTINE create_hf_pbc_section
     430              : 
     431              : ! **************************************************************************************************
     432              : !> \brief creates the input section for the hf-memory part
     433              : !> \param section the section to create
     434              : !> \author Manuel Guidon
     435              : ! **************************************************************************************************
     436       249552 :    SUBROUTINE create_hf_memory_section(section)
     437              :       TYPE(section_type), POINTER                        :: section
     438              : 
     439              :       TYPE(keyword_type), POINTER                        :: keyword
     440              : 
     441       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     442              :       CALL section_create(section, __LOCATION__, name="MEMORY", &
     443              :                           description="Sets up memory parameters for the storage of the ERI's if requested ", &
     444              :                           n_keywords=1, n_subsections=0, repeats=.FALSE., &
     445       499104 :                           citations=[guidon2008])
     446       249552 :       NULLIFY (keyword)
     447              :       CALL keyword_create( &
     448              :          keyword, __LOCATION__, &
     449              :          name="EPS_STORAGE_SCALING", &
     450              :          variants=["EPS_STORAGE"], &
     451              :          description="Scaling factor to scale eps_schwarz. Storage threshold for compression "// &
     452              :          "will be EPS_SCHWARZ*EPS_STORAGE_SCALING.", &
     453              :          usage="EPS_STORAGE 1.0E-2", &
     454       499104 :          default_r_val=1.0E0_dp)
     455       249552 :       CALL section_add_keyword(section, keyword)
     456       249552 :       CALL keyword_release(keyword)
     457              : 
     458              :       CALL keyword_create( &
     459              :          keyword, __LOCATION__, &
     460              :          name="MAX_MEMORY", &
     461              :          description="Defines the maximum amount of memory [MiB] to be consumed by the full HFX module. "// &
     462              :          "All temporary buffers and helper arrays are subtracted from this number. "// &
     463              :          "What remains will be used for storage of integrals. NOTE: This number "// &
     464              :          "is assumed to represent the memory available to one MPI process. "// &
     465              :          "When running a threaded version, cp2k automatically takes care of "// &
     466              :          "distributing the memory among all the threads within a process.", &
     467              :          usage="MAX_MEMORY 256", &
     468       249552 :          default_i_val=512)
     469       249552 :       CALL section_add_keyword(section, keyword)
     470       249552 :       CALL keyword_release(keyword)
     471              : 
     472              :       CALL keyword_create( &
     473              :          keyword, __LOCATION__, &
     474              :          name="STORAGE_LOCATION", &
     475              :          description="Loaction where ERI's are stored if MAX_DISK_SPACE /=0 "// &
     476              :          "Expects a path to a directory. ", &
     477              :          usage="STORAGE_LOCATION /data/scratch", &
     478       249552 :          default_c_val=".")
     479       249552 :       CALL section_add_keyword(section, keyword)
     480       249552 :       CALL keyword_release(keyword)
     481              : 
     482              :       CALL keyword_create( &
     483              :          keyword, __LOCATION__, &
     484              :          name="MAX_DISK_SPACE", &
     485              :          description="Defines the maximum amount of disk space [MiB] used to store precomputed "// &
     486              :          "compressed four-center integrals. If 0, nothing is stored to disk", &
     487              :          usage="MAX_DISK_SPACE 256", &
     488       249552 :          default_i_val=0)
     489       249552 :       CALL section_add_keyword(section, keyword)
     490       249552 :       CALL keyword_release(keyword)
     491              : 
     492              :       CALL keyword_create(keyword, __LOCATION__, name="TREAT_FORCES_IN_CORE", &
     493              :                           description="Determines whether the derivative ERI's should be stored to RAM or not. "// &
     494              :                           "Only meaningful when performing Ehrenfest MD. "// &
     495              :                           "Memory usage is defined via MAX_MEMORY, i.e. the memory is shared wit the energy ERI's.", &
     496       249552 :                           usage="TREAT_FORCES_IN_CORE TRUE", default_l_val=.FALSE.)
     497       249552 :       CALL section_add_keyword(section, keyword)
     498       249552 :       CALL keyword_release(keyword)
     499              : 
     500       249552 :    END SUBROUTINE create_hf_memory_section
     501              : 
     502              : ! **************************************************************************************************
     503              : !> \brief ...
     504              : !> \param section ...
     505              : ! **************************************************************************************************
     506       249552 :    SUBROUTINE create_hf_ri_section(section)
     507              :       TYPE(section_type), POINTER                        :: section
     508              : 
     509              :       TYPE(keyword_type), POINTER                        :: keyword
     510              :       TYPE(section_type), POINTER                        :: print_key, subsection
     511              : 
     512       249552 :       NULLIFY (keyword, print_key, subsection)
     513              : 
     514       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     515              :       CALL section_create(section, __LOCATION__, name="RI", &
     516              :                           description="Parameters for RI methods in HFX, including RI-HFXk with "// &
     517              :                           "k-point sampling. All keywords relevant to RI-HFXk have an "// &
     518       249552 :                           "alias starting with KP_")
     519              : 
     520              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     521              :                           description="controls the activation of RI", &
     522              :                           usage="&RI T", &
     523              :                           default_l_val=.FALSE., &
     524       249552 :                           lone_keyword_l_val=.TRUE.)
     525       249552 :       CALL section_add_keyword(section, keyword)
     526       249552 :       CALL keyword_release(keyword)
     527              : 
     528              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
     529              :                           description="Filter threshold for DBT tensor contraction.", &
     530              :                           variants=["KP_EPS_FILTER"], &
     531       499104 :                           default_r_val=1.0E-09_dp)
     532       249552 :       CALL section_add_keyword(section, keyword)
     533       249552 :       CALL keyword_release(keyword)
     534              : 
     535              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER_2C", &
     536              :                           description="Filter threshold for 2c integrals. Default should be kept.", &
     537       249552 :                           default_r_val=1.0E-12_dp)
     538       249552 :       CALL section_add_keyword(section, keyword)
     539       249552 :       CALL keyword_release(keyword)
     540              : 
     541              :       CALL keyword_create(keyword, __LOCATION__, &
     542              :                           name="EPS_STORAGE_SCALING", &
     543              :                           description="Scaling factor to scale EPS_FILTER for storage of 3-center integrals. Storage threshold "// &
     544              :                           "will be EPS_FILTER*EPS_STORAGE_SCALING.", &
     545       249552 :                           default_r_val=0.01_dp)
     546       249552 :       CALL section_add_keyword(section, keyword)
     547       249552 :       CALL keyword_release(keyword)
     548              : 
     549              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER_MO", &
     550              :                           description="Filter threshold for contraction of 3-center integrals with MOs. "// &
     551              :                           "Default should be kept.", &
     552       249552 :                           default_r_val=1.0E-12_dp)
     553       249552 :       CALL section_add_keyword(section, keyword)
     554       249552 :       CALL keyword_release(keyword)
     555              : 
     556              :       CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
     557              :                           description="The range parameter for the short range operator (in 1/a0). "// &
     558              :                           "Default is OMEGA from INTERACTION_POTENTIAL. ", &
     559              :                           variants=["KP_OMEGA"], &
     560              :                           default_r_val=0.0_dp, &
     561       499104 :                           repeats=.FALSE.)
     562       249552 :       CALL section_add_keyword(section, keyword)
     563       249552 :       CALL keyword_release(keyword)
     564              : 
     565              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     566              :                           description="The cutoff radius (in Angstroms) for the truncated Coulomb operator. "// &
     567              :                           "Default is CUTOFF_RADIUS from INTERACTION_POTENTIAL. ", &
     568              :                           variants=["KP_CUTOFF_RADIUS"], &
     569              :                           default_r_val=0.0_dp, &
     570              :                           repeats=.FALSE., &
     571       499104 :                           unit_str="angstrom")
     572       249552 :       CALL section_add_keyword(section, keyword)
     573       249552 :       CALL keyword_release(keyword)
     574              : 
     575              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_COULOMB", &
     576              :                           description="Scales Hartree-Fock contribution arising from a coulomb potential. "// &
     577              :                           "Only valid when doing a mixed potential calculation. "// &
     578              :                           "Default is SCALE_COULOMB from INTERACTION_POTENTIAL", &
     579       249552 :                           usage="SCALE_COULOMB 1.0", default_r_val=1.0_dp)
     580       249552 :       CALL section_add_keyword(section, keyword)
     581       249552 :       CALL keyword_release(keyword)
     582              : 
     583              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_LONGRANGE", &
     584              :                           description="Scales Hartree-Fock contribution arising from a longrange potential. "// &
     585              :                           "Only valid when doing a mixed potential calculation. "// &
     586              :                           "Default if SCALE_LONGRANGE from INTERACTION_POTENTIAL", &
     587       249552 :                           usage="SCALE_LONGRANGE 1.0", default_r_val=1.0_dp)
     588       249552 :       CALL section_add_keyword(section, keyword)
     589       249552 :       CALL keyword_release(keyword)
     590              : 
     591              :       CALL keyword_create(keyword, __LOCATION__, name="KP_NGROUPS", &
     592              :                           description="The number of MPI subgroup that work in parallel during the SCF. "// &
     593              :                           "The default value is 1. Using N subgroups should speed up the "// &
     594              :                           "calculation by a factor ~N, at the cost of N times more memory usage.", &
     595              :                           variants=["NGROUPS"], &
     596              :                           usage="KP_NGROUPS {int}", &
     597              :                           repeats=.FALSE., &
     598       499104 :                           default_i_val=1)
     599       249552 :       CALL section_add_keyword(section, keyword)
     600       249552 :       CALL keyword_release(keyword)
     601              : 
     602              :       CALL keyword_create(keyword, __LOCATION__, name="KP_USE_DELTA_P", &
     603              :                           description="This kweyword controls whether the KS matrix at each SCF cycle "// &
     604              :                           "is built by adding the contribution of the denisty difference (wrt to previous step) "// &
     605              :                           "to the KS matrix of the previous step. As the SCF converges, the density fluctuations "// &
     606              :                           "get smaller and sparsity increases, leading to faster SCF steps. Not always "// &
     607              :                           "numerically stable => turn off if SCF struggles to converge.", &
     608              :                           variants=s2a("USE_DELTA_P", "KP_USE_P_DIFF", "USE_P_DIFF"), &
     609              :                           usage="KP_USE_DELTA_P {logical}", &
     610              :                           repeats=.FALSE., &
     611       249552 :                           default_l_val=.TRUE.)
     612       249552 :       CALL section_add_keyword(section, keyword)
     613       249552 :       CALL keyword_release(keyword)
     614              : 
     615              :       CALL keyword_create(keyword, __LOCATION__, name="KP_STACK_SIZE", &
     616              :                           description="When doing contraction over periodic cells of the type: "// &
     617              :                           "T_mu^a,nu^b,P^c = (mu^a nu^b | Q^d) * (Q^d | P^c), with "// &
     618              :                           "a,b,c,d labeling cells, there are in principle Ncells "// &
     619              :                           "contractions taking place. Because a smaller number of "// &
     620              :                           "contractions involving larger tensors is more efficient, "// &
     621              :                           "the tensors can be stacked along the d direction. STCK_SIZE "// &
     622              :                           "controls the size of this stack. Larger stacks are more efficient, "// &
     623              :                           "but required more memory.", &
     624              :                           variants=["STACK_SIZE"], &
     625              :                           usage="KP_STACK_SIZE {int}", &
     626              :                           repeats=.FALSE., &
     627       499104 :                           default_i_val=16)
     628       249552 :       CALL section_add_keyword(section, keyword)
     629       249552 :       CALL keyword_release(keyword)
     630              : 
     631              :       CALL keyword_create(keyword, __LOCATION__, name="KP_RI_BUMP_FACTOR", &
     632              :                           variants=s2a("RI_BUMP", "BUMP", "BUMP_FACTOR"), &
     633              :                           description="In KP-RI-HFX, the extended RI basis set has a bump radius. "// &
     634              :                           "All basis elements within that radius contribute with full weight. "// &
     635              :                           "All basis elements beyond that radius have decaying weight, from "// &
     636              :                           "1 at the bump radius, to zero at the RI extension radius. The "// &
     637              :                           "bump radius is calculated as a fraction of the RI extension radius: "// &
     638              :                           "bump radius = KP_RI_NUMP_FACTOR * RI extension radius", &
     639              :                           default_r_val=0.85_dp, &
     640       249552 :                           repeats=.FALSE.)
     641       249552 :       CALL section_add_keyword(section, keyword)
     642       249552 :       CALL keyword_release(keyword)
     643              : 
     644              :       CALL keyword_create(keyword, __LOCATION__, name="RI_METRIC", &
     645              :                           description="The type of RI operator. "// &
     646              :                           "Default is POTENTIAL_TYPE from INTERACTION_POTENTIAL. "// &
     647              :                           "The standard "// &
     648              :                           "Coulomb operator cannot be used in periodic systems.", &
     649              :                           usage="RI_METRIC {string}", &
     650              :                           repeats=.FALSE., &
     651              :                           variants=["KP_RI_METRIC"], &
     652              :                           default_i_val=0, &
     653              :                           enum_c_vals=s2a("HFX", "COULOMB", "IDENTITY", "TRUNCATED", "SHORTRANGE"), &
     654              :                           enum_desc=s2a("Same as HFX operator", &
     655              :                                         "Standard Coulomb operator: 1/r", &
     656              :                                         "Overlap", &
     657              :                                         "Truncated Coulomb operator: 1/r if (r<R_c), 0 otherwise ", &
     658              :                                         "Short range: erfc(omega*r)/r"), &
     659              :                           enum_i_vals=[0, do_potential_coulomb, do_potential_id, do_potential_truncated, &
     660       499104 :                                        do_potential_short])
     661       249552 :       CALL section_add_keyword(section, keyword)
     662       249552 :       CALL keyword_release(keyword)
     663              : 
     664              :       CALL keyword_create(keyword, __LOCATION__, name="2C_MATRIX_FUNCTIONS", &
     665              :                           description="Methods for matrix inverse and matrix square root.", &
     666              :                           default_i_val=hfx_ri_do_2c_cholesky, &
     667              :                           enum_c_vals=s2a("DIAG", "CHOLESKY", "ITER"), &
     668              :                           enum_desc=s2a("Diagonalization with eigenvalue quenching: stable", &
     669              :                                         "Cholesky: not stable in case of ill-conditioned RI basis", &
     670              :                                         "Iterative algorithms: linear scaling "// &
     671              :                                         "Hotelling's method for inverse and Newton-Schulz iteration for matrix square root"), &
     672       249552 :                           enum_i_vals=[hfx_ri_do_2c_diag, hfx_ri_do_2c_cholesky, hfx_ri_do_2c_iter])
     673       249552 :       CALL section_add_keyword(section, keyword)
     674       249552 :       CALL keyword_release(keyword)
     675              : 
     676              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_EIGVAL", &
     677              :                           description="Throw away linear combinations of RI basis functions with a small eigenvalue, "// &
     678              :                           "this is applied only if 2C_MATRIX_FUNCTIONS DIAG", &
     679       249552 :                           default_r_val=1.0e-7_dp)
     680       249552 :       CALL section_add_keyword(section, keyword)
     681       249552 :       CALL keyword_release(keyword)
     682              : 
     683              :       CALL keyword_create(keyword, __LOCATION__, name="CHECK_2C_MATRIX", &
     684              :                           description="Report accuracy for the inverse/sqrt of the 2-center integral matrix.", &
     685       249552 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     686       249552 :       CALL section_add_keyword(section, keyword)
     687       249552 :       CALL keyword_release(keyword)
     688              : 
     689              :       CALL keyword_create( &
     690              :          keyword, __LOCATION__, &
     691              :          name="CALC_COND_NUM", &
     692              :          variants=["CALC_CONDITION_NUMBER"], &
     693              :          description="Calculate the condition number of integral matrices.", &
     694              :          usage="CALC_COND_NUM", &
     695              :          default_l_val=.FALSE., &
     696       499104 :          lone_keyword_l_val=.TRUE.)
     697       249552 :       CALL section_add_keyword(section, keyword)
     698       249552 :       CALL keyword_release(keyword)
     699              : 
     700              :       CALL keyword_create(keyword, __LOCATION__, name="SQRT_ORDER", &
     701              :                           description="Order of the iteration method for the calculation of "// &
     702              :                           "the sqrt of 2-center integral matrix.", &
     703       249552 :                           default_i_val=3)
     704       249552 :       CALL section_add_keyword(section, keyword)
     705       249552 :       CALL keyword_release(keyword)
     706              : 
     707              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_LANCZOS", &
     708              :                           description="Threshold used for lanczos estimates.", &
     709       249552 :                           default_r_val=1.0E-3_dp)
     710       249552 :       CALL section_add_keyword(section, keyword)
     711       249552 :       CALL keyword_release(keyword)
     712              : 
     713              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_PGF_ORB", &
     714              :                           description="Sets precision of the integral tensors.", &
     715              :                           variants=["KP_EPS_PGF_ORB"], &
     716       499104 :                           default_r_val=1.0E-5_dp)
     717       249552 :       CALL section_add_keyword(section, keyword)
     718       249552 :       CALL keyword_release(keyword)
     719              : 
     720              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER_LANCZOS", &
     721              :                           description="Maximum number of lanczos iterations.", &
     722       249552 :                           usage="MAX_ITER_LANCZOS ", default_i_val=500)
     723       249552 :       CALL section_add_keyword(section, keyword)
     724       249552 :       CALL keyword_release(keyword)
     725              : 
     726              :       CALL keyword_create(keyword, __LOCATION__, name="RI_FLAVOR", &
     727              :                           description="Flavor of RI: how to contract 3-center integrals", &
     728              :                           enum_c_vals=s2a("MO", "RHO"), &
     729              :                           enum_desc=s2a("with MO coefficients", "with density matrix"), &
     730              :                           enum_i_vals=[ri_mo, ri_pmat], &
     731       249552 :                           default_i_val=ri_pmat)
     732       249552 :       CALL section_add_keyword(section, keyword)
     733       249552 :       CALL keyword_release(keyword)
     734              : 
     735              :       CALL keyword_create(keyword, __LOCATION__, name="MIN_BLOCK_SIZE", &
     736              :                           description="Minimum tensor block size.", &
     737       249552 :                           default_i_val=4)
     738       249552 :       CALL section_add_keyword(section, keyword)
     739       249552 :       CALL keyword_release(keyword)
     740              : 
     741              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_BLOCK_SIZE_MO", &
     742              :                           description="Maximum tensor block size for MOs.", &
     743       249552 :                           default_i_val=64)
     744       249552 :       CALL section_add_keyword(section, keyword)
     745       249552 :       CALL keyword_release(keyword)
     746              : 
     747              :       CALL keyword_create(keyword, __LOCATION__, name="MEMORY_CUT", &
     748              :                           description="Memory reduction factor. This keyword controls the batching of tensor "// &
     749              :                           "contractions into smaller, more manageable chunks. The details vary "// &
     750              :                           "depending on the RI_FLAVOR.", &
     751       249552 :                           default_i_val=3)
     752       249552 :       CALL section_add_keyword(section, keyword)
     753       249552 :       CALL keyword_release(keyword)
     754              : 
     755              :       CALL keyword_create(keyword, __LOCATION__, name="FLAVOR_SWITCH_MEMORY_CUT", &
     756              :                           description="Memory reduction factor to be applied upon RI_FLAVOR switching "// &
     757              :                           "from MO to RHO. The RHO flavor typically requires more memory, "// &
     758              :                           "and depending on the ressources available, a higher MEMORY_CUT.", &
     759       249552 :                           default_i_val=3)
     760       249552 :       CALL section_add_keyword(section, keyword)
     761       249552 :       CALL keyword_release(keyword)
     762              : 
     763              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
     764              :                           description="Section of possible print options in the RI-HFX code.", &
     765       249552 :                           n_keywords=0, n_subsections=1, repeats=.FALSE.)
     766              : 
     767              :       CALL keyword_create(keyword, __LOCATION__, name="KP_RI_PROGRESS_BAR", &
     768              :                           variants=s2a("PROGRESS_BAR", "PROGRESS", "KP_PROGRESS", "KP_PROGRESS_BAR"), &
     769              :                           description="Whether a progress bar for individual SCF steps should be printed. "// &
     770              :                           "In RI-HFXk, an expensive triple loop runs over periodic images and "// &
     771              :                           "atomic pairs. This printing option tracks the progress of this loop "// &
     772              :                           "in real time. Note that some work also takes place before the loop "// &
     773              :                           "starts, and the time spent doing it depends on the value of "// &
     774              :                           "KP_STACK_SIZE (larger = faster, but more memory used).", &
     775       249552 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     776       249552 :       CALL section_add_keyword(subsection, keyword)
     777       249552 :       CALL keyword_release(keyword)
     778              : 
     779              :       !TODO: add a incentive to restart from GGA calculation? Test that it improves things
     780              :       CALL keyword_create(keyword, __LOCATION__, name="KP_RI_MEMORY_ESTIMATE", &
     781              :                           variants=s2a("MEMORY_ESTIMATE"), &
     782              :                           description="Calculate and print a rough upper bound estimate of the memory "// &
     783              :                           "required to run a RI-HFXk ENERGY calculation. Note that a fair "// &
     784              :                           "amount of computing must take place before this estimate can be "// &
     785              :                           "produced. If the calculation runs out of memory beforehand, "// &
     786              :                           "use more resources, or change the value of memory related keywords "// &
     787              :                           "(e.g. KP_NGROUPS, interaction potential parameters, KP_STACK_SIZE). "// &
     788              :                           "The estimate is more accurate when restarting from a (GGA) wavefunction. "// &
     789              :                           "Calculations involving forces will require more memory than this estimate.", &
     790       249552 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     791       249552 :       CALL section_add_keyword(subsection, keyword)
     792       249552 :       CALL keyword_release(keyword)
     793              : 
     794              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RI_INFO", &
     795              :                                        description="Controls the printing of DBCSR tensor log in RI HFX.", &
     796       249552 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     797       249552 :       CALL section_add_subsection(subsection, print_key)
     798       249552 :       CALL section_release(print_key)
     799              : 
     800              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RI_DENSITY_COEFFS", &
     801              :                                        description="Controls the printing of the projection of the elecontric "// &
     802              :                                        "density on the RI_HFX basis. n(r) = sum_s c_s*phi_RI_s(r), "// &
     803              :                                        "where c_s = sum_pqr P_pq (pq|r) (r|s)^-1 and | is the RI_METRIC", &
     804              :                                        print_level=high_print_level, filename="RI_DENSITY_COEFFS", &
     805       249552 :                                        common_iter_levels=3)
     806              : 
     807              :       CALL keyword_create(keyword, __LOCATION__, name="MULTIPLY_BY_RI_2C_INTEGRALS", &
     808              :                           variants=s2a("MULT_BY_RI", "MULT_BY_S", "MULT_BY_RI_INTS"), &
     809              :                           description="Whether the RI density coefficients to be printed should "// &
     810              :                           "be pre-multiplied by the RI_METRIC 2c-integrals: (r|s)*C_s. "// &
     811              :                           "Not compatible with the SKIP_RI_METRIC keyword.", &
     812       249552 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     813       249552 :       CALL section_add_keyword(print_key, keyword)
     814       249552 :       CALL keyword_release(keyword)
     815              : 
     816              :       CALL keyword_create(keyword, __LOCATION__, name="SKIP_RI_METRIC", &
     817              :                           variants=s2a("SKIP_INVERSE", "SKIP_2C_INTS", "SKIP_2C_INTEGRALS"), &
     818              :                           description="Skip the calculation, inversion, and contraction of the 2-center RI "// &
     819              :                           "metric integrals. The printed coefficients are only the contraction of the "// &
     820              :                           "density matrix with the 3-center integrals, i.e. c_r = sum_pq P_pq (pq|r) "// &
     821              :                           "Allows for memory savings when printing the RI density coefficients.", &
     822       249552 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     823       249552 :       CALL section_add_keyword(print_key, keyword)
     824       249552 :       CALL keyword_release(keyword)
     825              : 
     826              :       CALL keyword_create(keyword, __LOCATION__, name="FILE_FORMAT", &
     827              :                           description="Format of file containing density fitting coefficients: "// &
     828              :                           "BASIC(default)-original format; EXTENDED-format with basis set info.", &
     829       249552 :                           default_c_val="BASIC")
     830       249552 :       CALL section_add_keyword(print_key, keyword)
     831       249552 :       CALL keyword_release(keyword)
     832              : 
     833       249552 :       CALL section_add_subsection(subsection, print_key)
     834       249552 :       CALL section_release(print_key)
     835              : 
     836              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RI_METRIC_2C_INTS", &
     837              :                                        description="Controls the printing of RI 2-center integrals for the "// &
     838              :                                        "HFX potential.", &
     839              :                                        print_level=high_print_level, filename="RI_2C_INTS", &
     840       249552 :                                        common_iter_levels=3)
     841       249552 :       CALL section_add_subsection(subsection, print_key)
     842       249552 :       CALL section_release(print_key)
     843              : 
     844       249552 :       CALL section_add_subsection(section, subsection)
     845       249552 :       CALL section_release(subsection)
     846              : 
     847       249552 :    END SUBROUTINE create_hf_ri_section
     848              : 
     849              :    ! ACE Keyword section
     850              : 
     851       249552 :    SUBROUTINE create_hf_ace_section(section)
     852              :       TYPE(section_type), POINTER :: section
     853              : 
     854              :       TYPE(keyword_type), POINTER :: keyword
     855              : 
     856       249552 :       CPASSERT(.NOT. ASSOCIATED(section))
     857              :       CALL section_create(section, __LOCATION__, &
     858              :                           name="ACE", &
     859              :                           description="Parameters for the Adaptively Compressed Exchange (ACE) "// &
     860              :                           "operator. ACE replaces the full exchange matrix with a "// &
     861              :                           "low-rank projector K_ACE = -W*W^T after an initial "// &
     862              :                           "full HFX build, reducing cost of subsequent SCF steps. "// &
     863              :                           "NOTE: ACE requires diagonalization-based SCF. "// &
     864              :                           "It is incompatible with orbital transformation (OT) methods "// &
     865              :                           "because OT does not construct MO coefficients.", &
     866              :                           n_keywords=2, &
     867              :                           n_subsections=0, &
     868              :                           repeats=.FALSE., &
     869       499104 :                           citations=[Lin2016ACE])
     870              : 
     871       249552 :       NULLIFY (keyword)
     872              : 
     873              :       ! --- ACTIVE ---
     874              :       CALL keyword_create(keyword, __LOCATION__, &
     875              :                           name="ACTIVE", &
     876              :                           description="Enable the ACE approximation for HFX. "// &
     877              :                           "When .TRUE., the exchange matrix is replaced by "// &
     878              :                           "the ACE projector after the first full build.", &
     879              :                           usage="ACTIVE .TRUE.", &
     880              :                           default_l_val=.FALSE., &
     881       249552 :                           lone_keyword_l_val=.TRUE.)
     882       249552 :       CALL section_add_keyword(section, keyword)
     883       249552 :       CALL keyword_release(keyword)
     884              : 
     885              :       ! --- REBUILD_FREQUENCY ---
     886              :       CALL keyword_create(keyword, __LOCATION__, &
     887              :                           name="REBUILD_FREQUENCY", &
     888              :                           description="Rebuild the ACE projectors W every N SCF steps. "// &
     889              :                           "N=1 means rebuild every step (identical to full HFX, "// &
     890              :                           "use for testing only). N=10-20 is typical for production. "// &
     891              :                           "Projectors are always rebuilt when the structure changes.", &
     892              :                           usage="REBUILD_FREQUENCY 20", &
     893       249552 :                           default_i_val=20)
     894       249552 :       CALL section_add_keyword(section, keyword)
     895       249552 :       CALL keyword_release(keyword)
     896              : 
     897       249552 :    END SUBROUTINE create_hf_ace_section
     898              : 
     899              : END MODULE input_cp2k_hfx
        

Generated by: LCOV version 2.0-1