LCOV - code coverage report
Current view: top level - src - input_cp2k_ec.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1155b05) Lines: 100.0 % 233 233
Test Date: 2026-03-21 06:31:29 Functions: 100.0 % 3 3

            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 build the dft section of the input
      10              : !> \par History
      11              : !>      10.2005 moved out of input_cp2k [fawzi]
      12              : !> \author fawzi
      13              : ! **************************************************************************************************
      14              : MODULE input_cp2k_ec
      15              :    USE bibliography,                    ONLY: Niklasson2003,&
      16              :                                               VandeVondele2012,&
      17              :                                               brehm2018
      18              :    USE cp_output_handling,              ONLY: cp_print_key_section_create,&
      19              :                                               debug_print_level,&
      20              :                                               high_print_level
      21              :    USE cp_units,                        ONLY: cp_unit_to_cp2k
      22              :    USE input_constants,                 ONLY: &
      23              :         bqb_opt_exhaustive, bqb_opt_normal, bqb_opt_off, bqb_opt_patient, bqb_opt_quick, &
      24              :         ec_diagonalization, ec_functional_dc, ec_functional_ext, ec_functional_harris, &
      25              :         ec_ls_solver, ec_matrix_sign, ec_matrix_tc2, ec_matrix_trs4, ec_mo_solver, ec_ot_atomic, &
      26              :         ec_ot_diag, ec_ot_gs, kg_cholesky, ls_cluster_atomic, ls_cluster_molecular, &
      27              :         ls_s_inversion_hotelling, ls_s_inversion_sign_sqrt, ls_s_preconditioner_atomic, &
      28              :         ls_s_preconditioner_molecular, ls_s_preconditioner_none, ls_s_sqrt_ns, ls_s_sqrt_proot, &
      29              :         ls_scf_sign_ns, ls_scf_sign_proot, ot_precond_full_all, ot_precond_full_kinetic, &
      30              :         ot_precond_full_single, ot_precond_full_single_inverse, ot_precond_none, &
      31              :         ot_precond_s_inverse, precond_mlp
      32              :    USE input_cp2k_kpoints,              ONLY: create_kpoints_section
      33              :    USE input_cp2k_mm,                   ONLY: create_dipoles_section
      34              :    USE input_cp2k_voronoi,              ONLY: create_print_voronoi_section
      35              :    USE input_cp2k_xc,                   ONLY: create_xc_section
      36              :    USE input_keyword_types,             ONLY: keyword_create,&
      37              :                                               keyword_release,&
      38              :                                               keyword_type
      39              :    USE input_section_types,             ONLY: section_add_keyword,&
      40              :                                               section_add_subsection,&
      41              :                                               section_create,&
      42              :                                               section_release,&
      43              :                                               section_type
      44              :    USE input_val_types,                 ONLY: char_t,&
      45              :                                               integer_t,&
      46              :                                               real_t
      47              :    USE kinds,                           ONLY: dp
      48              :    USE string_utilities,                ONLY: s2a
      49              : #include "./base/base_uses.f90"
      50              : 
      51              :    IMPLICIT NONE
      52              :    PRIVATE
      53              : 
      54              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_ec'
      55              : 
      56              :    PUBLIC :: create_ec_section
      57              : 
      58              : CONTAINS
      59              : 
      60              : ! **************************************************************************************************
      61              : !> \brief creates the ENERGY CORRECTION section
      62              : !> \param section ...
      63              : !> \author JGH
      64              : ! **************************************************************************************************
      65         9560 :    SUBROUTINE create_ec_section(section)
      66              :       TYPE(section_type), POINTER                        :: section
      67              : 
      68              :       TYPE(keyword_type), POINTER                        :: keyword
      69              :       TYPE(section_type), POINTER                        :: subsection
      70              : 
      71         9560 :       CPASSERT(.NOT. ASSOCIATED(section))
      72              : 
      73         9560 :       NULLIFY (keyword)
      74              :       CALL section_create(section, __LOCATION__, name="ENERGY_CORRECTION", &
      75              :                           description="Sets the various options for the Energy Correction", &
      76         9560 :                           n_keywords=0, n_subsections=2, repeats=.FALSE.)
      77              : 
      78              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
      79              :                           description="Controls the activation of the energy_correction", &
      80              :                           usage="&ENERGY_CORRECTION T", &
      81              :                           default_l_val=.FALSE., &
      82         9560 :                           lone_keyword_l_val=.TRUE.)
      83         9560 :       CALL section_add_keyword(section, keyword)
      84         9560 :       CALL keyword_release(keyword)
      85              : 
      86              :       ! add a special XC section
      87         9560 :       NULLIFY (subsection)
      88         9560 :       CALL create_xc_section(subsection)
      89         9560 :       CALL section_add_subsection(section, subsection)
      90         9560 :       CALL section_release(subsection)
      91              : 
      92              :       ! add a special kpoint section
      93         9560 :       NULLIFY (subsection)
      94         9560 :       CALL create_kpoints_section(subsection)
      95         9560 :       CALL section_add_subsection(section, subsection)
      96         9560 :       CALL section_release(subsection)
      97              : 
      98              :       ! add a section for solver keywords
      99         9560 :       NULLIFY (subsection)
     100         9560 :       CALL create_ec_solver_section(subsection)
     101         9560 :       CALL section_add_subsection(section, subsection)
     102         9560 :       CALL section_release(subsection)
     103              : 
     104              :       ! add a print section for properties
     105         9560 :       NULLIFY (subsection)
     106         9560 :       CALL create_ec_print_section(subsection)
     107         9560 :       CALL section_add_subsection(section, subsection)
     108         9560 :       CALL section_release(subsection)
     109              : 
     110              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_FUNCTIONAL", &
     111              :                           description="Functional used in energy correction", &
     112              :                           usage="ENERGY_FUNCTIONAL HARRIS", &
     113              :                           default_i_val=ec_functional_harris, &
     114              :                           enum_c_vals=s2a("HARRIS", "DCDFT", "EXTERNAL"), &
     115              :                           enum_desc=s2a("Harris functional", &
     116              :                                         "Density-corrected DFT", &
     117              :                                         "External calculated energy"), &
     118         9560 :                           enum_i_vals=[ec_functional_harris, ec_functional_dc, ec_functional_ext])
     119         9560 :       CALL section_add_keyword(section, keyword)
     120         9560 :       CALL keyword_release(keyword)
     121              : 
     122              :       CALL keyword_create(keyword, __LOCATION__, name="HARRIS_BASIS", &
     123              :                           description="Specifies the type of basis to be used for the KG energy correction. "// &
     124              :                           "Options are: (1) the default orbital basis (ORBITAL); "// &
     125              :                           "(2) the primitive functions of the default orbital basis (PRIMITIVE); "// &
     126              :                           "(3) the basis set labeled in Kind section (HARRIS)", &
     127              :                           usage="HARRIS_BASIS ORBITAL", &
     128         9560 :                           type_of_var=char_t, default_c_val="ORBITAL", n_var=-1)
     129         9560 :       CALL section_add_keyword(section, keyword)
     130         9560 :       CALL keyword_release(keyword)
     131              : 
     132              :       CALL keyword_create(keyword, __LOCATION__, name="DEBUG_FORCES", &
     133              :                           description="Additional output to debug energy correction forces.", &
     134         9560 :                           usage="DEBUG_FORCES T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     135         9560 :       CALL section_add_keyword(section, keyword)
     136         9560 :       CALL keyword_release(keyword)
     137              :       CALL keyword_create(keyword, __LOCATION__, name="DEBUG_STRESS", &
     138              :                           description="Additional output to debug energy correction forces.", &
     139         9560 :                           usage="DEBUG_STRESS T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     140         9560 :       CALL section_add_keyword(section, keyword)
     141         9560 :       CALL keyword_release(keyword)
     142              :       CALL keyword_create(keyword, __LOCATION__, name="DEBUG_EXTERNAL_METHOD", &
     143              :                           description="Uses an internal pseudo-energy to test EXTERNAL energy method.", &
     144         9560 :                           usage="DEBUG_EXTERNAL_METHOD T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     145         9560 :       CALL section_add_keyword(section, keyword)
     146         9560 :       CALL keyword_release(keyword)
     147              : 
     148              :       CALL keyword_create(keyword, __LOCATION__, name="SKIP_EC", &
     149              :                           description="Skip EC calculation if ground-state calculation has not converged.", &
     150         9560 :                           usage="SKIP_EC T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     151         9560 :       CALL section_add_keyword(section, keyword)
     152         9560 :       CALL keyword_release(keyword)
     153              : 
     154              :       CALL keyword_create(keyword, __LOCATION__, name="MAO", &
     155              :                           description="Use modified atomic orbitals (MAO) to solve Harris equation", &
     156         9560 :                           usage="MAO T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     157         9560 :       CALL section_add_keyword(section, keyword)
     158         9560 :       CALL keyword_release(keyword)
     159              : 
     160              :       CALL keyword_create(keyword, __LOCATION__, name="MAO_MAX_ITER", &
     161              :                           description="Maximum iterations in MAO optimization. ", &
     162         9560 :                           usage="MAO_MAX_ITER 100 ", default_i_val=0)
     163         9560 :       CALL section_add_keyword(section, keyword)
     164         9560 :       CALL keyword_release(keyword)
     165              : 
     166              :       CALL keyword_create(keyword, __LOCATION__, name="MAO_EPS_GRAD", &
     167              :                           description="Threshold used for MAO iterations. ", &
     168         9560 :                           usage="MAO_EPS_GRAD 1.0E-4 ", default_r_val=1.0E-5_dp)
     169         9560 :       CALL section_add_keyword(section, keyword)
     170         9560 :       CALL keyword_release(keyword)
     171              : 
     172              :       CALL keyword_create(keyword, __LOCATION__, name="MAO_EPS1", &
     173              :                           description="Occupation threshold used to determine number of MAOs."// &
     174              :                           " KIND section MAO keyword sets the minimum.", &
     175         9560 :                           usage="MAO_EPS1 0.001 ", default_r_val=1000.0_dp)
     176         9560 :       CALL section_add_keyword(section, keyword)
     177         9560 :       CALL keyword_release(keyword)
     178              : 
     179              :       CALL keyword_create(keyword, __LOCATION__, name="MAO_IOLEVEL", &
     180              :                           description="Verbosity of MAO output: (0) no output ... (3) fully verbose", &
     181         9560 :                           usage="MAO_IOLEVEL 0 ", default_i_val=1)
     182         9560 :       CALL section_add_keyword(section, keyword)
     183         9560 :       CALL keyword_release(keyword)
     184              : 
     185              :       CALL keyword_create(keyword, __LOCATION__, &
     186              :                           name="ELECTRONIC_TEMPERATURE", &
     187              :                           variants=s2a("ELEC_TEMP", "FD_TEMP"), &
     188              :                           description="Electronic temperature for Harris functional with "// &
     189              :                           "Fermi-Dirac smearing.", &
     190              :                           repeats=.FALSE., &
     191              :                           n_var=1, &
     192              :                           type_of_var=real_t, &
     193              :                           default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="K"), &
     194              :                           unit_str="K", &
     195         9560 :                           usage="ELECTRONIC_TEMPERATURE [K] 300")
     196         9560 :       CALL section_add_keyword(section, keyword)
     197         9560 :       CALL keyword_release(keyword)
     198              : 
     199              :       CALL keyword_create(keyword, __LOCATION__, name="ALGORITHM", &
     200              :                           description="Algorithm used to solve KS equation", &
     201              :                           usage="ALGORITHM DIAGONALIZATION", &
     202              :                           default_i_val=ec_diagonalization, &
     203              :                           enum_c_vals=s2a("DIAGONALIZATION", "MATRIX_SIGN", &
     204              :                                           "TRS4", "TC2", "OT_DIAG"), &
     205              :                           enum_desc=s2a("Diagonalization of KS matrix.", &
     206              :                                         "Matrix Sign algorithm", &
     207              :                                         "Trace resetting trs4 algorithm", &
     208              :                                         "Trace resetting tc2 algorithm", &
     209              :                                         "OT diagonalization"), &
     210              :                           enum_i_vals=[ec_diagonalization, ec_matrix_sign, &
     211         9560 :                                        ec_matrix_trs4, ec_matrix_tc2, ec_ot_diag])
     212         9560 :       CALL section_add_keyword(section, keyword)
     213         9560 :       CALL keyword_release(keyword)
     214              : 
     215              :       CALL keyword_create(keyword, __LOCATION__, name="FACTORIZATION", &
     216              :                           description="Algorithm used to calculate factorization of overlap matrix", &
     217              :                           usage="FACTORIZATION CHOLESKY", &
     218              :                           default_i_val=kg_cholesky, &
     219              :                           enum_c_vals=s2a("CHOLESKY"), &
     220              :                           enum_desc=s2a("Cholesky factorization of overlap matrix"), &
     221         9560 :                           enum_i_vals=[kg_cholesky])
     222         9560 :       CALL section_add_keyword(section, keyword)
     223         9560 :       CALL keyword_release(keyword)
     224              : 
     225              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_DEFAULT", &
     226              :                           description="Threshold used for accuracy estimates within energy correction. ", &
     227         9560 :                           usage="EPS_DEFAULT 1.0E-7 ", default_r_val=1.0E-7_dp)
     228         9560 :       CALL section_add_keyword(section, keyword)
     229         9560 :       CALL keyword_release(keyword)
     230              : 
     231              :       ! Keywords for LS solver of Harris functional
     232              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
     233              :                           description="Threshold used for filtering matrix operations.", &
     234         9560 :                           usage="EPS_FILTER 1.0E-12", default_r_val=1.0E-12_dp)
     235         9560 :       CALL section_add_keyword(section, keyword)
     236         9560 :       CALL keyword_release(keyword)
     237              : 
     238              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_LANCZOS", &
     239              :                           description="Threshold used for lanczos estimates.", &
     240         9560 :                           usage="EPS_LANCZOS 1.0E-4", default_r_val=1.0E-3_dp)
     241         9560 :       CALL section_add_keyword(section, keyword)
     242         9560 :       CALL keyword_release(keyword)
     243              : 
     244              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER_LANCZOS", &
     245              :                           description="Maximum number of lanczos iterations.", &
     246         9560 :                           usage="MAX_ITER_LANCZOS ", default_i_val=128)
     247         9560 :       CALL section_add_keyword(section, keyword)
     248         9560 :       CALL keyword_release(keyword)
     249              : 
     250              :       CALL keyword_create(keyword, __LOCATION__, name="MU", &
     251              :                           description="Value (or initial guess) for the chemical potential,"// &
     252              :                           " i.e. some suitable energy between HOMO and LUMO energy.", &
     253         9560 :                           usage="MU 0.0", default_r_val=-0.1_dp)
     254         9560 :       CALL section_add_keyword(section, keyword)
     255         9560 :       CALL keyword_release(keyword)
     256              : 
     257              :       CALL keyword_create(keyword, __LOCATION__, name="FIXED_MU", &
     258              :                           description="Should the calculation be performed at fixed chemical potential,"// &
     259              :                           " or should it be found fixing the number of electrons", &
     260         9560 :                           usage="FIXED_MU .TRUE.", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     261         9560 :       CALL section_add_keyword(section, keyword)
     262         9560 :       CALL keyword_release(keyword)
     263              : 
     264              :       CALL keyword_create(keyword, __LOCATION__, name="S_PRECONDITIONER", &
     265              :                           description="Preconditions S with some appropriate form.", &
     266              :                           usage="S_PRECONDITIONER MOLECULAR", &
     267              :                           default_i_val=ls_s_preconditioner_atomic, &
     268              :                           enum_c_vals=s2a("NONE", "ATOMIC", "MOLECULAR"), &
     269              :                           enum_desc=s2a("No preconditioner", &
     270              :                                         "Using atomic blocks", &
     271              :                                         "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
     272         9560 :                           enum_i_vals=[ls_s_preconditioner_none, ls_s_preconditioner_atomic, ls_s_preconditioner_molecular])
     273         9560 :       CALL section_add_keyword(section, keyword)
     274         9560 :       CALL keyword_release(keyword)
     275              : 
     276              :       CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_METHOD", &
     277              :                           description="Method for the caclulation of the sqrt of S.", &
     278              :                           usage="S_SQRT_METHOD NEWTONSCHULZ", &
     279              :                           default_i_val=ls_s_sqrt_ns, &
     280              :                           enum_c_vals=s2a("NEWTONSCHULZ", "PROOT"), &
     281              :                           enum_desc=s2a("Using a Newton-Schulz-like iteration", &
     282              :                                         "Using the p-th root method."), &
     283         9560 :                           enum_i_vals=[ls_s_sqrt_ns, ls_s_sqrt_proot])
     284         9560 :       CALL section_add_keyword(section, keyword)
     285         9560 :       CALL keyword_release(keyword)
     286              : 
     287              :       CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_ORDER", &
     288              :                           variants=s2a("SIGN_SQRT_ORDER"), &
     289              :                           description="Order of the iteration method for the calculation of the sqrt of S.", &
     290         9560 :                           usage="S_SQRT_ORDER 3", default_i_val=3)
     291         9560 :       CALL section_add_keyword(section, keyword)
     292         9560 :       CALL keyword_release(keyword)
     293              : 
     294              :       CALL keyword_create(keyword, __LOCATION__, name="SIGN_METHOD", &
     295              :                           description="Method used for the computation of the sign matrix.", &
     296              :                           usage="SIGN_METHOD NEWTONSCHULZ", &
     297              :                           default_i_val=ls_scf_sign_ns, &
     298              :                           citations=[VandeVondele2012, Niklasson2003], &
     299              :                           enum_c_vals=s2a("NEWTONSCHULZ", "PROOT"), &
     300              :                           enum_desc=s2a("Newton-Schulz iteration.", &
     301              :                                         "p-th order root iteration"), &
     302        28680 :                           enum_i_vals=[ls_scf_sign_ns, ls_scf_sign_proot])
     303         9560 :       CALL section_add_keyword(section, keyword)
     304         9560 :       CALL keyword_release(keyword)
     305              : 
     306              :       CALL keyword_create(keyword, __LOCATION__, name="SIGN_ORDER", &
     307              :                           description="Order of the method used for the computation of the sign matrix.", &
     308              :                           usage="SIGN_ORDER 2", &
     309         9560 :                           default_i_val=2)
     310         9560 :       CALL section_add_keyword(section, keyword)
     311         9560 :       CALL keyword_release(keyword)
     312              : 
     313              :       CALL keyword_create(keyword, __LOCATION__, name="DYNAMIC_THRESHOLD", &
     314              :                           description="Should the threshold for the purification be chosen dynamically", &
     315         9560 :                           usage="DYNAMIC_THRESHOLD .TRUE.", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     316         9560 :       CALL section_add_keyword(section, keyword)
     317         9560 :       CALL keyword_release(keyword)
     318              : 
     319              :       CALL keyword_create(keyword, __LOCATION__, name="NON_MONOTONIC", &
     320              :                           description="Should the purification be performed non-monotonically. Relevant for TC2 only.", &
     321         9560 :                           usage="NON_MONOTONIC .TRUE.", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     322         9560 :       CALL section_add_keyword(section, keyword)
     323         9560 :       CALL keyword_release(keyword)
     324              : 
     325              :       CALL keyword_create( &
     326              :          keyword, __LOCATION__, name="MATRIX_CLUSTER_TYPE", &
     327              :          description="Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
     328              :          "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
     329              :          "Furthermore, since screening is on matrix blocks, "// &
     330              :          "slightly more accurate results can be expected with molecular.", &
     331              :          usage="MATRIX_CLUSTER_TYPE MOLECULAR", &
     332              :          default_i_val=ls_cluster_atomic, &
     333              :          enum_c_vals=s2a("ATOMIC", "MOLECULAR"), &
     334              :          enum_desc=s2a("Using atomic blocks", &
     335              :                        "Using molecular blocks."), &
     336         9560 :          enum_i_vals=[ls_cluster_atomic, ls_cluster_molecular])
     337         9560 :       CALL section_add_keyword(section, keyword)
     338         9560 :       CALL keyword_release(keyword)
     339              : 
     340              :       CALL keyword_create(keyword, __LOCATION__, name="S_INVERSION", &
     341              :                           description="Method used to compute the inverse of S.", &
     342              :                           usage="S_INVERSION MOLECULAR", &
     343              :                           default_i_val=ls_s_inversion_sign_sqrt, &
     344              :                           enum_c_vals=s2a("SIGN_SQRT", "HOTELLING"), &
     345              :                           enum_desc=s2a("Using the inverse sqrt as obtained from sign function iterations.", &
     346              :                                         "Using the Hotellign iteration."), &
     347         9560 :                           enum_i_vals=[ls_s_inversion_sign_sqrt, ls_s_inversion_hotelling])
     348         9560 :       CALL section_add_keyword(section, keyword)
     349         9560 :       CALL keyword_release(keyword)
     350              : 
     351              :       CALL keyword_create(keyword, __LOCATION__, name="REPORT_ALL_SPARSITIES", &
     352              :                           description="Run the sparsity report at the end of the SCF", &
     353         9560 :                           usage="REPORT_ALL_SPARSITIES", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     354         9560 :       CALL section_add_keyword(section, keyword)
     355         9560 :       CALL keyword_release(keyword)
     356              : 
     357              :       CALL keyword_create(keyword, __LOCATION__, name="CHECK_S_INV", &
     358              :                           description="Perform an accuracy check on the inverse/sqrt of the s matrix.", &
     359         9560 :                           usage="CHECK_S_INV", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     360         9560 :       CALL section_add_keyword(section, keyword)
     361         9560 :       CALL keyword_release(keyword)
     362              : 
     363              :       CALL keyword_create(keyword, __LOCATION__, name="OT_INITIAL_GUESS", &
     364              :                           description="Initial guess of density matrix used for OT Diagonalization", &
     365              :                           usage="OT_INITIAL_GUESS ATOMIC", &
     366              :                           default_i_val=ec_ot_atomic, &
     367              :                           enum_c_vals=s2a("ATOMIC", "GROUND_STATE"), &
     368              :                           enum_desc=s2a("Generate an atomic density using the atomic code", &
     369              :                                         "Using the ground-state density."), &
     370         9560 :                           enum_i_vals=[ec_ot_atomic, ec_ot_gs])
     371         9560 :       CALL section_add_keyword(section, keyword)
     372         9560 :       CALL keyword_release(keyword)
     373              : 
     374              :       CALL keyword_create( &
     375              :          keyword, __LOCATION__, &
     376              :          name="ADMM", &
     377              :          description="Decide whether to perform ADMM in the exact exchange calc. for DC-DFT. "// &
     378              :          "The ADMM XC correction is governed by the AUXILIARY_DENSITY_MATRIX_METHOD section in &DFT. "// &
     379              :          "In most cases, the Hartree-Fock exchange is not too expensive and there is no need for ADMM, "// &
     380              :          "ADMM can however provide significant speedup and memory savings in case of diffuse basis sets. ", &
     381              :          usage="ADMM", &
     382              :          default_l_val=.FALSE., &
     383         9560 :          lone_keyword_l_val=.TRUE.)
     384         9560 :       CALL section_add_keyword(section, keyword)
     385         9560 :       CALL keyword_release(keyword)
     386              : 
     387              :       CALL keyword_create(keyword, __LOCATION__, name="EXTERNAL_RESPONSE_FILENAME", &
     388              :                           description="Name of the file that contains response information.", &
     389              :                           usage="EXTERNAL_RESPONSE_FILENAME <FILENAME>", &
     390         9560 :                           default_c_val="TREXIO")
     391         9560 :       CALL section_add_keyword(section, keyword)
     392         9560 :       CALL keyword_release(keyword)
     393              : 
     394              :       CALL keyword_create(keyword, __LOCATION__, name="EXTERNAL_RESPONSE_ERROR_FILENAME", &
     395              :                           description="Name of the file that contains response error information.", &
     396              :                           usage="EXTERNAL_RESPONSE_ERROR_FILENAME <FILENAME>", &
     397         9560 :                           default_c_val="TREXIO")
     398         9560 :       CALL section_add_keyword(section, keyword)
     399         9560 :       CALL keyword_release(keyword)
     400              : 
     401              :       CALL keyword_create(keyword, __LOCATION__, name="EXTERNAL_RESULT_FILENAME", &
     402              :                           description="Name of the file that contains results from external response calculation.", &
     403              :                           usage="EXTERNAL_RESULT_FILENAME <FILENAME>", &
     404         9560 :                           default_c_val="CP2K_EXRESP.result")
     405         9560 :       CALL section_add_keyword(section, keyword)
     406         9560 :       CALL keyword_release(keyword)
     407              : 
     408              :       CALL keyword_create( &
     409              :          keyword, __LOCATION__, &
     410              :          name="ERROR_ESTIMATION", &
     411              :          description="Perform an error estimation for the response forces/stress. "// &
     412              :          "Requires error estimates for the RHS of the response equation from input. ", &
     413              :          usage="ERROR_ESTIMATION", &
     414              :          default_l_val=.FALSE., &
     415         9560 :          lone_keyword_l_val=.TRUE.)
     416         9560 :       CALL section_add_keyword(section, keyword)
     417         9560 :       CALL keyword_release(keyword)
     418              : 
     419              :       CALL keyword_create(keyword, __LOCATION__, name="ERROR_ESTIMATION_METHOD", &
     420              :                           description="Method used for error estimation: F(ull); D(ifferenc); E(xtrapolate).", &
     421              :                           usage="ERROR_ESTIMATION_METHOD E", &
     422         9560 :                           default_c_val="E")
     423         9560 :       CALL section_add_keyword(section, keyword)
     424         9560 :       CALL keyword_release(keyword)
     425              : 
     426              :       CALL keyword_create(keyword, __LOCATION__, name="ERROR_CUTOFF", &
     427              :                           description="Cutoff value for error estimation.", &
     428              :                           usage="ERROR_CUTOFF 1.E-6", &
     429         9560 :                           default_r_val=1.E-5_dp)
     430         9560 :       CALL section_add_keyword(section, keyword)
     431         9560 :       CALL keyword_release(keyword)
     432              : 
     433              :       CALL keyword_create(keyword, __LOCATION__, name="ERROR_SUBSPACE_SIZE", &
     434              :                           description="MAX. size of subspace for response vector extrapolation.", &
     435              :                           usage="ERROR_SUBSPACE_SIZE 100", &
     436         9560 :                           default_i_val=250)
     437         9560 :       CALL section_add_keyword(section, keyword)
     438         9560 :       CALL keyword_release(keyword)
     439              : 
     440         9560 :    END SUBROUTINE create_ec_section
     441              : 
     442              : ! **************************************************************************************************
     443              : !> \brief creates the linear scaling solver section
     444              : !> \param section ...
     445              : !> \author Joost VandeVondele [2010-10], JGH [2019-12]
     446              : ! **************************************************************************************************
     447         9560 :    SUBROUTINE create_ec_solver_section(section)
     448              :       TYPE(section_type), POINTER                        :: section
     449              : 
     450              :       TYPE(keyword_type), POINTER                        :: keyword
     451              : 
     452         9560 :       CPASSERT(.NOT. ASSOCIATED(section))
     453              :       CALL section_create(section, __LOCATION__, name="RESPONSE_SOLVER", &
     454              :                           description="Specifies the parameters of the linear scaling solver routines", &
     455              :                           n_keywords=24, n_subsections=3, repeats=.FALSE., &
     456        19120 :                           citations=[VandeVondele2012])
     457              : 
     458         9560 :       NULLIFY (keyword)
     459              : 
     460              :       CALL keyword_create(keyword, __LOCATION__, name="EPS", &
     461              :                           description="Target accuracy for the convergence of the conjugate gradient.", &
     462         9560 :                           usage="EPS 1.e-10", default_r_val=1.e-12_dp)
     463         9560 :       CALL section_add_keyword(section, keyword)
     464         9560 :       CALL keyword_release(keyword)
     465              : 
     466              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
     467              :                           description="Threshold used for filtering matrix operations.", &
     468         9560 :                           usage="EPS_FILTER 1.0E-10", default_r_val=1.0E-10_dp)
     469         9560 :       CALL section_add_keyword(section, keyword)
     470         9560 :       CALL keyword_release(keyword)
     471              : 
     472              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_LANCZOS", &
     473              :                           description="Threshold used for lanczos estimates.", &
     474         9560 :                           usage="EPS_LANCZOS 1.0E-4", default_r_val=1.0E-3_dp)
     475         9560 :       CALL section_add_keyword(section, keyword)
     476         9560 :       CALL keyword_release(keyword)
     477              : 
     478              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
     479              :                           description="Maximum number of conjugate gradient iteration "// &
     480              :                           "to be performed for one optimization.", &
     481         9560 :                           usage="MAX_ITER 200", default_i_val=50)
     482         9560 :       CALL section_add_keyword(section, keyword)
     483         9560 :       CALL keyword_release(keyword)
     484              : 
     485              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER_LANCZOS", &
     486              :                           description="Maximum number of lanczos iterations.", &
     487         9560 :                           usage="MAX_ITER_LANCZOS 128", default_i_val=128)
     488         9560 :       CALL section_add_keyword(section, keyword)
     489         9560 :       CALL keyword_release(keyword)
     490              : 
     491              :       CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
     492              :                           description="Algorithm used to solve response equation. "// &
     493              :                           "Both solver are conjugate gradient based, but use either a vector (MO-coefficient) "// &
     494              :                           "or density matrix formalism in the orthonormal AO-basis to obtain response density", &
     495              :                           usage="METHOD SOLVER", &
     496              :                           default_i_val=ec_ls_solver, &
     497              :                           enum_c_vals=s2a("MO_SOLVER", "AO_ORTHO"), &
     498              :                           enum_desc=s2a("Solver based on MO (vector) formalism", &
     499              :                                         "Solver based on density matrix formalism"), &
     500         9560 :                           enum_i_vals=[ec_mo_solver, ec_ls_solver])
     501         9560 :       CALL section_add_keyword(section, keyword)
     502         9560 :       CALL keyword_release(keyword)
     503              : 
     504              :       CALL keyword_create( &
     505              :          keyword, __LOCATION__, name="PRECONDITIONER", &
     506              :          description="Type of preconditioner to be used with MO conjugate gradient solver. "// &
     507              :          "They differ in effectiveness, cost of construction, cost of application. "// &
     508              :          "Properly preconditioned minimization can be orders of magnitude faster than doing nothing. "// &
     509              :          "Only multi-level conjugate gradient preconditioner (MULTI_LEVEL) available for AO response solver (AO_ORTHO). ", &
     510              :          usage="PRECONDITIONER FULL_ALL", &
     511              :          default_i_val=precond_mlp, &
     512              :          enum_c_vals=s2a("FULL_ALL", "FULL_SINGLE_INVERSE", "FULL_SINGLE", "FULL_KINETIC", "FULL_S_INVERSE", &
     513              :                          "MULTI_LEVEL", "NONE"), &
     514              :          enum_desc=s2a("Most effective state selective preconditioner based on diagonalization, "// &
     515              :                        "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
     516              :                        "This preconditioner is recommended for almost all systems, except very large systems where "// &
     517              :                        "make_preconditioner would dominate the total computational cost.", &
     518              :                        "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
     519              :                        "but cheaper to construct, "// &
     520              :                        "might be somewhat less robust. Recommended for large systems.", &
     521              :                        "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
     522              :                        "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
     523              :                        "use for very large systems.", &
     524              :                        "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
     525              :                        "Based on same CG as AO-solver itself, but uses cheaper linear transformation", &
     526              :                        "skip preconditioning"), &
     527              :          enum_i_vals=[ot_precond_full_all, ot_precond_full_single_inverse, ot_precond_full_single, &
     528         9560 :                       ot_precond_full_kinetic, ot_precond_s_inverse, precond_mlp, ot_precond_none])
     529         9560 :       CALL section_add_keyword(section, keyword)
     530         9560 :       CALL keyword_release(keyword)
     531              : 
     532              :       CALL keyword_create(keyword, __LOCATION__, name="S_PRECONDITIONER", &
     533              :                           description="Preconditions S with some appropriate form.", &
     534              :                           usage="S_PRECONDITIONER MOLECULAR", &
     535              :                           default_i_val=ls_s_preconditioner_atomic, &
     536              :                           enum_c_vals=s2a("NONE", "ATOMIC", "MOLECULAR"), &
     537              :                           enum_desc=s2a("No preconditioner", &
     538              :                                         "Using atomic blocks", &
     539              :                                         "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
     540         9560 :                           enum_i_vals=[ls_s_preconditioner_none, ls_s_preconditioner_atomic, ls_s_preconditioner_molecular])
     541         9560 :       CALL section_add_keyword(section, keyword)
     542         9560 :       CALL keyword_release(keyword)
     543              : 
     544              :       CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_METHOD", &
     545              :                           description="Method for the caclulation of the sqrt of S.", &
     546              :                           usage="S_SQRT_METHOD NEWTONSCHULZ", &
     547              :                           default_i_val=ls_s_sqrt_ns, &
     548              :                           enum_c_vals=s2a("NEWTONSCHULZ", "PROOT"), &
     549              :                           enum_desc=s2a("Using a Newton-Schulz-like iteration", &
     550              :                                         "Using the p-th root method."), &
     551         9560 :                           enum_i_vals=[ls_s_sqrt_ns, ls_s_sqrt_proot])
     552         9560 :       CALL section_add_keyword(section, keyword)
     553         9560 :       CALL keyword_release(keyword)
     554              : 
     555              :       CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_ORDER", &
     556              :                           variants=s2a("SIGN_SQRT_ORDER"), &
     557              :                           description="Order of the iteration method for the calculation of the sqrt of S.", &
     558         9560 :                           usage="S_SQRT_ORDER 3", default_i_val=3)
     559         9560 :       CALL section_add_keyword(section, keyword)
     560         9560 :       CALL keyword_release(keyword)
     561              : 
     562              :       CALL keyword_create( &
     563              :          keyword, __LOCATION__, name="MATRIX_CLUSTER_TYPE", &
     564              :          description="Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
     565              :          "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
     566              :          "Furthermore, since screening is on matrix blocks, "// &
     567              :          "slightly more accurate results can be expected with molecular.", &
     568              :          usage="MATRIX_CLUSTER_TYPE MOLECULAR", &
     569              :          default_i_val=ls_cluster_atomic, &
     570              :          enum_c_vals=s2a("ATOMIC", "MOLECULAR"), &
     571              :          enum_desc=s2a("Using atomic blocks", &
     572              :                        "Using molecular blocks."), &
     573         9560 :          enum_i_vals=[ls_cluster_atomic, ls_cluster_molecular])
     574         9560 :       CALL section_add_keyword(section, keyword)
     575         9560 :       CALL keyword_release(keyword)
     576              : 
     577              :       CALL keyword_create(keyword, __LOCATION__, name="S_INVERSION", &
     578              :                           description="Method used to compute the inverse of S.", &
     579              :                           usage="S_INVERSION MOLECULAR", &
     580              :                           default_i_val=ls_s_inversion_sign_sqrt, &
     581              :                           enum_c_vals=s2a("SIGN_SQRT", "HOTELLING"), &
     582              :                           enum_desc=s2a("Using the inverse sqrt as obtained from sign function iterations.", &
     583              :                                         "Using the Hotellign iteration."), &
     584         9560 :                           enum_i_vals=[ls_s_inversion_sign_sqrt, ls_s_inversion_hotelling])
     585         9560 :       CALL section_add_keyword(section, keyword)
     586         9560 :       CALL keyword_release(keyword)
     587              : 
     588              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART", &
     589              :                           description="Restart the response calculation if the restart file exists", &
     590              :                           usage="RESTART", &
     591         9560 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     592         9560 :       CALL section_add_keyword(section, keyword)
     593         9560 :       CALL keyword_release(keyword)
     594              : 
     595              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_EVERY", &
     596              :                           description="Restart the conjugate gradient after the specified number of iterations.", &
     597         9560 :                           usage="RESTART_EVERY 50", default_i_val=50)
     598         9560 :       CALL section_add_keyword(section, keyword)
     599         9560 :       CALL keyword_release(keyword)
     600              : 
     601         9560 :    END SUBROUTINE create_ec_solver_section
     602              : 
     603              : ! **************************************************************************************************
     604              : !> \brief Create the print dft section
     605              : !> \param section the section to create
     606              : !> \author fbelle - from create_print_dft_section
     607              : ! **************************************************************************************************
     608         9560 :    SUBROUTINE create_ec_print_section(section)
     609              :       TYPE(section_type), POINTER                        :: section
     610              : 
     611              :       TYPE(keyword_type), POINTER                        :: keyword
     612              :       TYPE(section_type), POINTER                        :: print_key
     613              : 
     614         9560 :       CPASSERT(.NOT. ASSOCIATED(section))
     615              :       CALL section_create(section, __LOCATION__, name="PRINT", &
     616              :                           description="Section of possible print options in EC code.", &
     617         9560 :                           n_keywords=0, n_subsections=1, repeats=.FALSE.)
     618              : 
     619         9560 :       NULLIFY (print_key, keyword)
     620              : 
     621              :       ! Output of BQB volumetric files
     622              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="E_DENSITY_BQB", &
     623              :                                        description="Controls the output of the electron density to the losslessly"// &
     624              :                                        " compressed BQB file format, see [Brehm2018]"// &
     625              :                                        " (via LibBQB see <https://brehm-research.de/bqb>)."// &
     626              :                                        " Currently does not work with changing cell vector (NpT ensemble).", &
     627              :                                        print_level=debug_print_level + 1, filename="", &
     628        19120 :                                        citations=[Brehm2018])
     629              : 
     630              :       CALL keyword_create(keyword, __LOCATION__, name="SKIP_FIRST", &
     631              :                           description="Skips the first step of a MD run (avoids duplicate step if restarted).", &
     632         9560 :                           usage="SKIP_FIRST T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     633         9560 :       CALL section_add_keyword(print_key, keyword)
     634         9560 :       CALL keyword_release(keyword)
     635              : 
     636              :       CALL keyword_create(keyword, __LOCATION__, name="STORE_STEP_NUMBER", &
     637              :                           description="Stores the step number and simulation time in the comment line of each BQB"// &
     638              :                           " frame. Switch it off for binary compatibility with original CP2k CUBE files.", &
     639         9560 :                           usage="STORE_STEP_NUMBER F", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     640         9560 :       CALL section_add_keyword(print_key, keyword)
     641         9560 :       CALL keyword_release(keyword)
     642              : 
     643              :       CALL keyword_create(keyword, __LOCATION__, name="CHECK", &
     644              :                           description="Performs an on-the-fly decompression of each compressed BQB frame to check"// &
     645              :                           " whether the volumetric data exactly matches, and aborts the run if not so.", &
     646         9560 :                           usage="CHECK T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     647         9560 :       CALL section_add_keyword(print_key, keyword)
     648         9560 :       CALL keyword_release(keyword)
     649              : 
     650              :       CALL keyword_create(keyword, __LOCATION__, name="OVERWRITE", &
     651              :                           description="Specify this keyword to overwrite the output BQB file if"// &
     652              :                           " it already exists. By default, the data is appended to an existing file.", &
     653         9560 :                           usage="OVERWRITE T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     654         9560 :       CALL section_add_keyword(print_key, keyword)
     655         9560 :       CALL keyword_release(keyword)
     656              : 
     657              :       CALL keyword_create(keyword, __LOCATION__, name="HISTORY", &
     658              :                           description="Controls how many previous steps are taken into account for extrapolation in"// &
     659              :                           " compression. Use a value of 1 to compress the frames independently.", &
     660         9560 :                           usage="HISTORY 10", n_var=1, default_i_val=10, type_of_var=integer_t)
     661         9560 :       CALL section_add_keyword(print_key, keyword)
     662         9560 :       CALL keyword_release(keyword)
     663              : 
     664              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_KEY", &
     665              :                           description="Allows to supply previously optimized compression parameters via a"// &
     666              :                           " parameter key (alphanumeric character sequence starting with 'at')."// &
     667              :                           " Just leave away the 'at' sign here, because CP2k will otherwise"// &
     668              :                           " assume it is a variable name in the input", &
     669         9560 :                           usage="PARAMETER_KEY <KEY>", n_var=1, default_c_val="", type_of_var=char_t)
     670         9560 :       CALL section_add_keyword(print_key, keyword)
     671         9560 :       CALL keyword_release(keyword)
     672              : 
     673              :       CALL keyword_create(keyword, __LOCATION__, name="OPTIMIZE", &
     674              :                           description="Controls the time spent to optimize the parameters for compression efficiency.", &
     675              :                           usage="OPTIMIZE {OFF,QUICK,NORMAL,PATIENT,EXHAUSTIVE}", repeats=.FALSE., n_var=1, &
     676              :                           default_i_val=bqb_opt_quick, &
     677              :                           enum_c_vals=s2a("OFF", "QUICK", "NORMAL", "PATIENT", "EXHAUSTIVE"), &
     678              :                           enum_desc=s2a("No optimization (use defaults)", "Quick optimization", &
     679              :                                         "Standard optimization", "Precise optimization", "Exhaustive optimization"), &
     680         9560 :                           enum_i_vals=[bqb_opt_off, bqb_opt_quick, bqb_opt_normal, bqb_opt_patient, bqb_opt_exhaustive])
     681         9560 :       CALL section_add_keyword(print_key, keyword)
     682         9560 :       CALL keyword_release(keyword)
     683              : 
     684         9560 :       CALL section_add_subsection(section, print_key)
     685         9560 :       CALL section_release(print_key)
     686              : 
     687              :       ! Voronoi Integration via LibVori
     688         9560 :       NULLIFY (print_key)
     689         9560 :       CALL create_print_voronoi_section(print_key)
     690         9560 :       CALL section_add_subsection(section, print_key)
     691         9560 :       CALL section_release(print_key)
     692              : 
     693              :       !Printing of Moments
     694         9560 :       CALL create_dipoles_section(print_key, "MOMENTS", high_print_level)
     695              :       CALL keyword_create( &
     696              :          keyword, __LOCATION__, &
     697              :          name="MAX_MOMENT", &
     698              :          description="Maximum moment to be calculated. Values higher than 1 not implemented under periodic boundaries.", &
     699              :          usage="MAX_MOMENT {integer}", &
     700              :          repeats=.FALSE., &
     701              :          n_var=1, &
     702              :          type_of_var=integer_t, &
     703         9560 :          default_i_val=1)
     704         9560 :       CALL section_add_keyword(print_key, keyword)
     705         9560 :       CALL keyword_release(keyword)
     706              :       CALL keyword_create(keyword, __LOCATION__, &
     707              :                           name="MAGNETIC", &
     708              :                           description="Calculate also magnetic moments, only implemented without periodic boundaries", &
     709              :                           usage="MAGNETIC yes", &
     710              :                           repeats=.FALSE., &
     711              :                           n_var=1, &
     712              :                           default_l_val=.FALSE., &
     713         9560 :                           lone_keyword_l_val=.TRUE.)
     714         9560 :       CALL section_add_keyword(print_key, keyword)
     715         9560 :       CALL keyword_release(keyword)
     716         9560 :       CALL section_add_subsection(section, print_key)
     717         9560 :       CALL section_release(print_key)
     718              : 
     719         9560 :    END SUBROUTINE create_ec_print_section
     720              : 
     721              : END MODULE input_cp2k_ec
        

Generated by: LCOV version 2.0-1