LCOV - code coverage report
Current view: top level - src - input_cp2k_xas.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:06f838d) Lines: 100.0 % 317 317
Test Date: 2026-06-05 07:04:50 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 XAS section of the input
      10              : !> \par History
      11              : !>      10.2005 moved out of input_cp2k [fawzi]
      12              : !>      07.2024 moved out of input_cp2k_dft [JGH]
      13              : !> \author fawzi
      14              : ! **************************************************************************************************
      15              : MODULE input_cp2k_xas
      16              :    USE bibliography,                    ONLY: Iannuzzi2007,&
      17              :                                               Shigeta2001
      18              :    USE cp_output_handling,              ONLY: add_last_numeric,&
      19              :                                               cp_print_key_section_create,&
      20              :                                               debug_print_level,&
      21              :                                               high_print_level,&
      22              :                                               low_print_level
      23              :    USE input_constants,                 ONLY: &
      24              :         do_potential_coulomb, do_potential_id, do_potential_short, do_potential_truncated, &
      25              :         gaussian, ot_mini_cg, ot_mini_diis, tddfpt_singlet, tddfpt_spin_cons, tddfpt_spin_flip, &
      26              :         tddfpt_triplet, xas_1s_type, xas_2p_type, xas_2s_type, xas_3d_type, xas_3p_type, &
      27              :         xas_3s_type, xas_4d_type, xas_4f_type, xas_4p_type, xas_4s_type, xas_dip_len, xas_dip_vel, &
      28              :         xas_dscf, xas_none, xas_not_excited, xas_tdp_by_index, xas_tdp_by_kind, xas_tp_fh, &
      29              :         xas_tp_flex, xas_tp_hh, xas_tp_xfh, xas_tp_xhh, xes_tp_val
      30              :    USE input_cp2k_loc,                  ONLY: create_localize_section,&
      31              :                                               print_wanniers
      32              :    USE input_cp2k_print_dft,            ONLY: add_dos_keywords
      33              :    USE input_cp2k_scf,                  ONLY: create_scf_section
      34              :    USE input_cp2k_xc,                   ONLY: create_xc_fun_section
      35              :    USE input_keyword_types,             ONLY: keyword_create,&
      36              :                                               keyword_release,&
      37              :                                               keyword_type
      38              :    USE input_section_types,             ONLY: section_add_keyword,&
      39              :                                               section_add_subsection,&
      40              :                                               section_create,&
      41              :                                               section_release,&
      42              :                                               section_type
      43              :    USE input_val_types,                 ONLY: char_t,&
      44              :                                               integer_t,&
      45              :                                               lchar_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_xas'
      55              : 
      56              :    PUBLIC :: create_xas_section, create_xas_tdp_section
      57              : 
      58              : CONTAINS
      59              : 
      60              : ! **************************************************************************************************
      61              : !> \brief Create the XAS-specific PDOS print section.
      62              : !> \param print_key the PDOS print section
      63              : ! **************************************************************************************************
      64        30818 :    SUBROUTINE create_xas_pdos_section(print_key)
      65              : 
      66              :       TYPE(section_type), POINTER                        :: print_key
      67              : 
      68              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PDOS", &
      69              :                                        description="Print out the XAS PDOS projected per kind and angular momentum", &
      70        30818 :                                        print_level=debug_print_level, common_iter_levels=1, filename="")
      71        30818 :       CALL add_dos_keywords(print_key, xas_mode=.TRUE.)
      72              : 
      73        30818 :    END SUBROUTINE create_xas_pdos_section
      74              : 
      75              : ! **************************************************************************************************
      76              : !> \brief makes the input section for core-level spectroscopy simulations
      77              : !> \param section ...
      78              : !> \par History
      79              : !>      03.2005 created [MI]
      80              : ! **************************************************************************************************
      81        10278 :    SUBROUTINE create_xas_section(section)
      82              :       TYPE(section_type), POINTER                        :: section
      83              : 
      84              :       TYPE(keyword_type), POINTER                        :: keyword
      85              :       TYPE(section_type), POINTER                        :: print_key, subsection
      86              : 
      87        10278 :       CPASSERT(.NOT. ASSOCIATED(section))
      88              :       CALL section_create(section, __LOCATION__, name="xas", &
      89              :                        description="Controls transition-potential and delta-SCF calculations of core-level excitation spectra. "// &
      90              :                           "The occupied states from which the excitations are calculated should be specified. "// &
      91              :                           "Localization of the orbitals may be useful.", &
      92              :                           n_keywords=10, n_subsections=1, repeats=.FALSE., &
      93        20556 :                           citations=[Iannuzzi2007])
      94              : 
      95        10278 :       NULLIFY (keyword, subsection, print_key)
      96              : 
      97              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
      98              :                           description="controls the activation of core-level spectroscopy simulations", &
      99              :                           usage="&XAS T", &
     100              :                           default_l_val=.FALSE., &
     101        10278 :                           lone_keyword_l_val=.TRUE.)
     102        10278 :       CALL section_add_keyword(section, keyword)
     103        10278 :       CALL keyword_release(keyword)
     104              : 
     105              :       CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
     106              :                           variants=["XAS_METHOD"], &
     107              :                           description="Method to be used to calculate core-level excitation spectra", &
     108              :                           usage="METHOD TP_HH", &
     109              :                           default_i_val=xas_none, &
     110              :                           enum_c_vals=s2a("NONE", "TP_HH", "TP_FH", "TP_VAL", "TP_XHH", "TP_XFH", "DSCF", "TP_FLEX"), &
     111              :                           enum_desc=s2a( &
     112              :                           "No core electron spectroscopy", "Transition potential half-hole", &
     113              :                           "Transition potential full-hole", "Hole in homo for X-ray emission only ", &
     114              :                           "Transition potential excited half-hole", &
     115              :                           "Transition potential excited full-hole ", &
     116              :                           "DSCF calculations to compute the first (core)excited state", &
     117              :                           "Transition potential with generalized core occupation and total number of electrons"), &
     118              :                           enum_i_vals=[xas_none, xas_tp_hh, xas_tp_fh, xes_tp_val, xas_tp_xhh, &
     119        20556 :                                        xas_tp_xfh, xas_dscf, xas_tp_flex])
     120        10278 :       CALL section_add_keyword(section, keyword)
     121        10278 :       CALL keyword_release(keyword)
     122              : 
     123              :       CALL keyword_create(keyword, __LOCATION__, name="XAS_CORE", &
     124              :                           description="Occupation of the core state in XAS calculation by TP_FLEX.", &
     125              :                           usage="XAS_CORE 0.5", &
     126        10278 :                           default_r_val=0.5_dp)
     127        10278 :       CALL section_add_keyword(section, keyword)
     128        10278 :       CALL keyword_release(keyword)
     129              : 
     130              :       CALL keyword_create(keyword, __LOCATION__, name="XAS_TOT_EL", &
     131              :                           description="Total number of electrons for spin channel alpha, in XAS calculation by TP_FLEX. "// &
     132              :                           "If it is a negative value, the number of electrons is set to GS number of electrons "// &
     133              :                           "minus the amount subtracted from the core state", &
     134              :                           usage="XAS_TOT_EL 10", &
     135        10278 :                           default_r_val=-1._dp)
     136        10278 :       CALL section_add_keyword(section, keyword)
     137        10278 :       CALL keyword_release(keyword)
     138              : 
     139              :       CALL keyword_create(keyword, __LOCATION__, name="XES_CORE", &
     140              :                           description="Occupation of the core state in XES calculation by TP_VAL. "// &
     141              :                           "The HOMO is emptied by the same amount.", &
     142              :                           usage="XES_CORE 0.5", &
     143        10278 :                           default_r_val=1._dp)
     144        10278 :       CALL section_add_keyword(section, keyword)
     145        10278 :       CALL keyword_release(keyword)
     146              : 
     147              :       CALL keyword_create(keyword, __LOCATION__, name="XES_EMPTY_HOMO", &
     148              :                           description="Set the occupation of the HOMO in XES calculation by TP_VAL. "// &
     149              :                           "The HOMO can be emptied or not, if the core is still full.", &
     150              :                           usage="XES_EMPTY_HOMO", &
     151              :                           default_l_val=.FALSE., &
     152        10278 :                           lone_keyword_l_val=.TRUE.)
     153        10278 :       CALL section_add_keyword(section, keyword)
     154        10278 :       CALL keyword_release(keyword)
     155              : 
     156              :       CALL keyword_create(keyword, __LOCATION__, name="DIPOLE_FORM", &
     157              :                           variants=["DIP_FORM"], &
     158              :                           description="Type of integral to get the oscillator strengths "// &
     159              :                           "in the diipole approximation", &
     160              :                           usage="DIPOLE_FORM string", &
     161              :                           default_i_val=xas_dip_vel, &
     162              :                           enum_c_vals=s2a("LENGTH", "VELOCITY"), &
     163              :                           enum_desc=s2a("Length form &lang; i | e r | j &rang;", &
     164              :                                         "Velocity form &lang; i | d/dr | j &rang;"), &
     165        20556 :                           enum_i_vals=[xas_dip_len, xas_dip_vel])
     166        10278 :       CALL section_add_keyword(section, keyword)
     167        10278 :       CALL keyword_release(keyword)
     168              : 
     169              : !   replace the specialized keyword with standard scf section
     170              : !    scf_env is added to xas_env
     171              : 
     172        10278 :       NULLIFY (subsection)
     173        10278 :       CALL create_scf_section(subsection)
     174        10278 :       CALL section_add_subsection(section, subsection)
     175        10278 :       CALL section_release(subsection)
     176              : 
     177              :       CALL keyword_create(keyword, __LOCATION__, name="STATE_TYPE", &
     178              :                           variants=["TYPE"], &
     179              :                           description="Type of the orbitals that are excited for the xas spectra calculation", &
     180              :                           usage="STATE_TYPE 1S", &
     181              :                           default_i_val=xas_1s_type, &
     182              :                           enum_c_vals=s2a("1S", "2S", "2P", "3S", "3P", "3D", "4S", "4P", "4D", "4F"), &
     183              :                           enum_desc=s2a("1s orbitals", "2s orbitals", "2p orbitals", "3s orbitals", "3p orbitals", &
     184              :                                         "3d orbitals", "4s orbitals", "4p orbitals", "4d orbitals", "4f orbitals"), &
     185              :                           enum_i_vals=[xas_1s_type, xas_2s_type, xas_2p_type, xas_3s_type, xas_3p_type, xas_3d_type, &
     186        20556 :                                        xas_4s_type, xas_4p_type, xas_4d_type, xas_4f_type])
     187        10278 :       CALL section_add_keyword(section, keyword)
     188        10278 :       CALL keyword_release(keyword)
     189              : 
     190              :       CALL keyword_create(keyword, __LOCATION__, name="STATE_SEARCH", &
     191              :                           description="# of states where to look for the one to be excited", &
     192              :                           usage="STATE_SEARCH 1", &
     193        10278 :                           default_i_val=-1)
     194        10278 :       CALL section_add_keyword(section, keyword)
     195        10278 :       CALL keyword_release(keyword)
     196              : 
     197              :       CALL keyword_create(keyword, __LOCATION__, name="SPIN_CHANNEL", &
     198              :                           description="# Spin channel of the excited orbital", &
     199              :                           usage="SPIN_CHANNEL 1", &
     200        10278 :                           default_i_val=1)
     201        10278 :       CALL section_add_keyword(section, keyword)
     202        10278 :       CALL keyword_release(keyword)
     203              : 
     204              :       CALL keyword_create(keyword, __LOCATION__, name="ATOMS_LIST", &
     205              :                           variants=["AT_LIST"], &
     206              :                           description="Indexes of the atoms to be excited. "// &
     207              :                           "This keyword can be repeated several times "// &
     208              :                           "(useful if you have to specify many indexes).", &
     209              :                           usage="ATOMS_LIST {integer}  {integer} ..  {integer} ", &
     210        20556 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     211        10278 :       CALL section_add_keyword(section, keyword)
     212        10278 :       CALL keyword_release(keyword)
     213              : 
     214              :       CALL keyword_create(keyword, __LOCATION__, name="OVERLAP_THRESHOLD", &
     215              :                           description="Threshold for including more than one initial core excited state "// &
     216              :                           "per atom. The threshold is taken relative to the maximum overlap.", &
     217        10278 :                           usage="OVERLAP_THRESHOLD 8.e-1", default_r_val=1.0_dp)
     218        10278 :       CALL section_add_keyword(section, keyword)
     219        10278 :       CALL keyword_release(keyword)
     220              : 
     221              :       CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_LIST", &
     222              :                           variants=["ORBITAL_LIST"], &
     223              :                           description="Indices of the localized orbitals to be excited. "// &
     224              :                           "This keyword can be repeated several times "// &
     225              :                           "(useful if you have to specify many indexes).", &
     226              :                           usage="ORBITAL_LIST {integer}  {integer} ..  {integer} ", &
     227        20556 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     228        10278 :       CALL section_add_keyword(section, keyword)
     229        10278 :       CALL keyword_release(keyword)
     230              : 
     231              :       CALL keyword_create(keyword, __LOCATION__, name="ADDED_MOS", &
     232              :                           description="Number of additional MOS added spin up only", &
     233        10278 :                           usage="ADDED_MOS {integer}", default_i_val=-1)
     234        10278 :       CALL section_add_keyword(section, keyword)
     235        10278 :       CALL keyword_release(keyword)
     236              : 
     237              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER_ADDED", &
     238              :                           description="maximum number of iteration in calculation of added orbitals", &
     239        10278 :                           usage="MAX_ITER_ADDED 100", default_i_val=2999)
     240        10278 :       CALL section_add_keyword(section, keyword)
     241        10278 :       CALL keyword_release(keyword)
     242              : 
     243              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_ADDED", &
     244              :                           description="target accuracy incalculation of the added orbitals", &
     245        10278 :                           usage="EPS_ADDED 1.e-6", default_r_val=1.0e-5_dp)
     246        10278 :       CALL section_add_keyword(section, keyword)
     247        10278 :       CALL keyword_release(keyword)
     248              : 
     249              :       CALL keyword_create(keyword, __LOCATION__, name="NGAUSS", &
     250              :                           description="Number of gto's for the expansion of the STO "// &
     251              :                           "of the type given by STATE_TYPE", &
     252        10278 :                           usage="NGAUSS {integer}", default_i_val=3)
     253        10278 :       CALL section_add_keyword(section, keyword)
     254        10278 :       CALL keyword_release(keyword)
     255              : 
     256              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART", &
     257              :                           description="Restart the excited state if the restart file exists", &
     258              :                           usage="RESTART", &
     259        10278 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     260        10278 :       CALL section_add_keyword(section, keyword)
     261        10278 :       CALL keyword_release(keyword)
     262              : 
     263              :       CALL keyword_create(keyword, __LOCATION__, name="WFN_RESTART_FILE_NAME", &
     264              :                           variants=["RESTART_FILE_NAME"], &
     265              :                           description="Root of the file names where to read the MOS from "// &
     266              :                           "which to restart the calculation of the core level excited states", &
     267              :                           usage="WFN_RESTART_FILE_NAME <FILENAME>", &
     268        20556 :                           type_of_var=lchar_t)
     269        10278 :       CALL section_add_keyword(section, keyword)
     270        10278 :       CALL keyword_release(keyword)
     271              : 
     272        10278 :       CALL create_localize_section(subsection)
     273        10278 :       CALL section_add_subsection(section, subsection)
     274        10278 :       CALL section_release(subsection)
     275              : 
     276              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
     277              :                           description="printing of information during the core-level spectroscopy simulation", &
     278        10278 :                           repeats=.FALSE.)
     279              : 
     280              :       ! Add printing of wannier infos
     281        10278 :       CALL print_wanniers(subsection)
     282              : 
     283              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "iteration_info", &
     284              :                                        description="Controls the printing of basic iteration information during the XAS SCF.", &
     285        10278 :                                        print_level=low_print_level, filename="__STD_OUT__")
     286              :       CALL keyword_create(keyword, __LOCATION__, name="time_cumul", &
     287              :                           description="If the printkey is activated switches the printing of timings"// &
     288              :                           " to cumulative (over the SCF).", &
     289        10278 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     290        10278 :       CALL section_add_keyword(print_key, keyword)
     291        10278 :       CALL keyword_release(keyword)
     292        10278 :       CALL section_add_subsection(subsection, print_key)
     293        10278 :       CALL section_release(print_key)
     294              : 
     295              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "program_run_info", &
     296              :                                        description="Controls the printing of basic iteration information in CLS", &
     297        10278 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     298        10278 :       CALL section_add_subsection(subsection, print_key)
     299        10278 :       CALL section_release(print_key)
     300              : 
     301              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "XES_SPECTRUM", &
     302              :                                        description="Controls the dumping of the CLS output files containing the emission spectra", &
     303        10278 :                                        print_level=low_print_level, common_iter_levels=3, filename="")
     304        10278 :       CALL section_add_subsection(subsection, print_key)
     305        10278 :       CALL section_release(print_key)
     306              : 
     307              :       CALL cp_print_key_section_create( &
     308              :          print_key, __LOCATION__, "XAS_SPECTRUM", &
     309              :          description="Controls the dumping of the CLS output files containing the absorption spectra", &
     310        10278 :          print_level=low_print_level, common_iter_levels=3, filename="")
     311        10278 :       CALL section_add_subsection(subsection, print_key)
     312        10278 :       CALL section_release(print_key)
     313              : 
     314        10278 :       CALL create_xas_pdos_section(print_key)
     315        10278 :       CALL section_add_subsection(subsection, print_key)
     316        10278 :       CALL section_release(print_key)
     317              : 
     318              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
     319              :                                        description="Controls the dumping of MO restart file during the SCF. "// &
     320              :                                        "of a Core-Level-Spectroscopy calculation. For each new excited atom, "// &
     321              :                                        "one different restart file is dumped. These restart files should be "// &
     322              :                                        "employed only to restart the same type of CLS calculation, "// &
     323              :                                        "i.e. with the same core potential.", &
     324              :                                        print_level=low_print_level, common_iter_levels=3, each_iter_names=s2a("XAS_SCF"), &
     325        10278 :                                        add_last=add_last_numeric, each_iter_values=[3], filename="")
     326        10278 :       CALL section_add_subsection(subsection, print_key)
     327        10278 :       CALL section_release(print_key)
     328              : 
     329              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "FULL_RESTART", &
     330              :                                        description="Controls the dumping of a standard MO restart file "// &
     331              :                                        "where coefficients and occupation numbers are those of the TP scheme, "// &
     332              :                                        "i.e. with emptied core state.", &
     333              :                                        print_level=high_print_level, common_iter_levels=3, each_iter_names=s2a("XAS_SCF"), &
     334        10278 :                                        add_last=add_last_numeric, each_iter_values=[3], filename="")
     335        10278 :       CALL section_add_subsection(subsection, print_key)
     336        10278 :       CALL section_release(print_key)
     337              : 
     338              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CLS_FUNCTION_CUBES", &
     339              :                                        description="Controls the printing of the relaxed orbitals ", &
     340        10278 :                                        print_level=high_print_level, common_iter_levels=3, add_last=add_last_numeric, filename="")
     341              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
     342              :                           description="The stride (X,Y,Z) used to write the cube file "// &
     343              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
     344              :                           " 1 number valid for all components.", &
     345        10278 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
     346        10278 :       CALL section_add_keyword(print_key, keyword)
     347        10278 :       CALL keyword_release(keyword)
     348              : 
     349              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LU_BOUNDS", &
     350              :                           variants=["CUBES_LU"], &
     351              :                           description="The lower and upper index of the states to be printed as cube", &
     352              :                           usage="CUBES_LU_BOUNDS integer integer", &
     353        20556 :                           n_var=2, default_i_vals=[0, -2], type_of_var=integer_t)
     354        10278 :       CALL section_add_keyword(print_key, keyword)
     355        10278 :       CALL keyword_release(keyword)
     356              : 
     357              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LIST", &
     358              :                           description="Indexes of the states to be printed as cube files "// &
     359              :                           "This keyword can be repeated several times "// &
     360              :                           "(useful if you have to specify many indexes).", &
     361              :                           usage="CUBES_LIST 1 2", &
     362        10278 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     363        10278 :       CALL section_add_keyword(print_key, keyword)
     364        10278 :       CALL keyword_release(keyword)
     365              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
     366              :                           description="append the cube files when they already exist", &
     367        10278 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     368        10278 :       CALL section_add_keyword(print_key, keyword)
     369        10278 :       CALL keyword_release(keyword)
     370              : 
     371        10278 :       CALL section_add_subsection(subsection, print_key)
     372        10278 :       CALL section_release(print_key)
     373              : 
     374        10278 :       CALL section_add_subsection(section, subsection)
     375        10278 :       CALL section_release(subsection)
     376              : 
     377        10278 :    END SUBROUTINE create_xas_section
     378              : 
     379              : ! **************************************************************************************************
     380              : !> \brief makes the input section for core-level spectroscopy simulations using
     381              : !>        linear response TDDFT
     382              : !> \param section ...
     383              : !> \par History
     384              : !>      11.2017 created [AB]
     385              : ! **************************************************************************************************
     386        20540 :    SUBROUTINE create_xas_tdp_section(section)
     387              :       TYPE(section_type), POINTER                        :: section
     388              : 
     389              :       TYPE(keyword_type), POINTER                        :: keyword
     390              :       TYPE(section_type), POINTER                        :: print_key, subsection, subsubsection, &
     391              :                                                             subsubsubsection
     392              : 
     393        20540 :       NULLIFY (keyword, print_key, subsection, subsubsection, subsubsubsection)
     394              : 
     395        20540 :       CPASSERT(.NOT. ASSOCIATED(section))
     396              :       CALL section_create(section, __LOCATION__, name="XAS_TDP", &
     397              :                           description="XAS simulations using linear-response TDDFT. Excitation from "// &
     398              :                           "specified core orbitals is considered one at a time. In case of high "// &
     399              :                           "symmetry structures, donor core orbitals should be localized.", &
     400        20540 :                           n_keywords=19, n_subsections=4, repeats=.FALSE.)
     401              : 
     402        20540 :       NULLIFY (keyword, subsection, print_key)
     403              : 
     404              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     405              :                           description="controls the activation of XAS simulations with linear "// &
     406              :                           "response TDDFT.", &
     407              :                           usage="&TDP_XAS {logical}", &
     408              :                           default_l_val=.FALSE., &
     409        20540 :                           lone_keyword_l_val=.TRUE.)
     410        20540 :       CALL section_add_keyword(section, keyword)
     411        20540 :       CALL keyword_release(keyword)
     412              : 
     413              :       CALL keyword_create(keyword, __LOCATION__, name="CHECK_ONLY", &
     414              :                           description="This keyword defines whether the full calculation should "// &
     415              :                           "be done or not. If set to .TRUE., only the determination "// &
     416              :                           "of donor MOs is conducted. This run option allows for "// &
     417              :                           "cheap verification of the input parameters", &
     418              :                           usage="CHECK_ONLY {logical}", &
     419              :                           default_l_val=.FALSE., &
     420              :                           lone_keyword_l_val=.TRUE., &
     421        20540 :                           repeats=.FALSE.)
     422        20540 :       CALL section_add_keyword(section, keyword)
     423        20540 :       CALL keyword_release(keyword)
     424              : 
     425              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_FROM_FILE", &
     426              :                           variants=s2a("RESTART_FILENAME", "RST_FILENAME", "RESTART_FILE", "RST_FILE"), &
     427              :                           description="By providing a RESTART file containing the linear-response "// &
     428              :                           "orbitals and excitations energies from a previous calculation, "// &
     429              :                           "all computations are skipped except for the corresponding "// &
     430              :                           "PDOS and/or CUBE file printing as defined in the PRINT "// &
     431              :                           "subsection. Basis sets and geometry need to be consistent.", &
     432              :                           usage="RESTART_FROM_FILE <FILENAME>", &
     433        20540 :                           type_of_var=char_t, n_var=-1)
     434        20540 :       CALL section_add_keyword(section, keyword)
     435        20540 :       CALL keyword_release(keyword)
     436              : 
     437              :       CALL keyword_create(keyword, __LOCATION__, name="EXCITATIONS", &
     438              :                           variants=["EXCITATION"], &
     439              :                           description="Specify the type of excitation to consider. In case of a "// &
     440              :                           "restricted closed-shell ground state calculation, "// &
     441              :                           "RCS_SINGLET or/and RCS_TRIPLET can be chosen. In case of a "// &
     442              :                           "open-shell ground state calculation (either UKS or ROKS), "// &
     443              :                           "standard spin conserving excitation (OS_SPIN_CONS) or/and "// &
     444              :                           "spin-flip excitation (OS_SPIN_FLIP) can be chosen.", &
     445              :                           usage="EXCITATIONS {string}", &
     446              :                           repeats=.TRUE., &
     447              :                           default_i_val=tddfpt_singlet, &
     448              :                           enum_c_vals=s2a("RCS_SINGLET", "RCS_TRIPLET", "OS_SPIN_CONS", "OS_SPIN_FLIP"), &
     449              :                           enum_desc=s2a("Singlet excitation on top of restricted closed-shell ground state", &
     450              :                                         "Triplet excitation on top of restricted closed-shell ground state", &
     451              :                                         "Spin-conserving excitations on top of open-shell ground state", &
     452              :                                         "Spin-flip excitation on top of open-shell ground state"), &
     453        41080 :                           enum_i_vals=[tddfpt_singlet, tddfpt_triplet, tddfpt_spin_cons, tddfpt_spin_flip])
     454        20540 :       CALL section_add_keyword(section, keyword)
     455        20540 :       CALL keyword_release(keyword)
     456              : 
     457              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_PGF_XAS", &
     458              :                           variants=s2a("EPS_PGF", "EPS_PGF_XAS_TDP"), &
     459              :                           description="The threshold used to determine the spatial extent of all "// &
     460              :                           "primitive Gaussian functions used for the construction "// &
     461              :                           "of neighbor lists in the XAS_TDP method. "// &
     462              :                           "By default, takes the value of QS%EPS_PGF_ORB. Useful if "// &
     463              :                           "the former value is tiny due to possible ground state HFX "// &
     464              :                           "contributions.", &
     465              :                           usage="EPS_PGF_XAS {real}", &
     466        20540 :                           type_of_var=real_t)
     467        20540 :       CALL section_add_keyword(section, keyword)
     468        20540 :       CALL keyword_release(keyword)
     469              : 
     470              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
     471              :                           variants=s2a("EPS_FILTER_MATRIX"), &
     472              :                           description="The threshold used for sparse matrix operations", &
     473              :                           usage="EPS_FILTER {real}", &
     474              :                           type_of_var=real_t, &
     475        20540 :                           default_r_val=1.0E-10_dp)
     476        20540 :       CALL section_add_keyword(section, keyword)
     477        20540 :       CALL keyword_release(keyword)
     478              : 
     479              :       CALL keyword_create(keyword, __LOCATION__, name="DIPOLE_FORM", &
     480              :                           variants=["DIP_FORM"], &
     481              :                           description="Type of integral to get the oscillator strengths "// &
     482              :                           "in the dipole approximation", &
     483              :                           usage="DIPOLE_FORM {string}", &
     484              :                           default_i_val=xas_dip_vel, &
     485              :                           enum_c_vals=s2a("LENGTH", "VELOCITY"), &
     486              :                           enum_desc=s2a("Length form &lang; 0 | e r | n &rang;", &
     487              :                                         "Velocity form &lang; 0 | d/dr | n &rang;"), &
     488        41080 :                           enum_i_vals=[xas_dip_len, xas_dip_vel])
     489        20540 :       CALL section_add_keyword(section, keyword)
     490        20540 :       CALL keyword_release(keyword)
     491              : 
     492              :       CALL keyword_create(keyword, __LOCATION__, name="QUADRUPOLE", &
     493              :                           variants=s2a("DO_QUADRUPOLE", "DO_QUAD", "QUAD"), &
     494              :                           description="Compute the electric quadrupole contribution to the "// &
     495              :                           "oscillator strenghts (in the length representation with "// &
     496              :                           "the origin set on the relevant excited atom)", &
     497              :                           usage="QUADRUPOLE {logical}", &
     498              :                           default_l_val=.FALSE., &
     499        20540 :                           lone_keyword_l_val=.TRUE.)
     500        20540 :       CALL section_add_keyword(section, keyword)
     501        20540 :       CALL keyword_release(keyword)
     502              : 
     503              :       CALL keyword_create(keyword, __LOCATION__, name="XYZ_DIPOLE", &
     504              :                           variants=s2a("DIPOLE_XYZ"), &
     505              :                           description="Whether the detailed contributions of the dipole oscillator "// &
     506              :                           "strengths along the X,Y,Z directions should be printed.", &
     507              :                           usage="XYZ_DIPOLE {logical}", &
     508              :                           default_l_val=.FALSE., &
     509        20540 :                           lone_keyword_l_val=.TRUE.)
     510        20540 :       CALL section_add_keyword(section, keyword)
     511        20540 :       CALL keyword_release(keyword)
     512              : 
     513              :       CALL keyword_create(keyword, __LOCATION__, name="SPIN_DIPOLE", &
     514              :                           variants=s2a("DIPOLE_SPIN"), &
     515              :                           description="Whether the detailed contributions of the dipole oscillator "// &
     516              :                           "strengths for alpha and beta spins should be printed.", &
     517              :                           usage="SPIN_DIPOLE {logical}", &
     518              :                           default_l_val=.FALSE., &
     519        20540 :                           lone_keyword_l_val=.TRUE.)
     520        20540 :       CALL section_add_keyword(section, keyword)
     521        20540 :       CALL keyword_release(keyword)
     522              : 
     523              : !  the GW2X correction subsection
     524              :       CALL section_create(subsection, __LOCATION__, name="GW2X", &
     525              :                           description="Specifications for the GW2X calculation of core "// &
     526              :                           "ionization potentials. Note that donor states need to be actively "// &
     527              :                           "localized using the LOCALIZE keyword in DONOR_STATES. N_SEARCH "// &
     528              :                           "should be kept to the minimum, such that only core states are localized.", &
     529              :                           citations=[Shigeta2001], &
     530              :                           n_keywords=8, &
     531              :                           n_subsections=0, &
     532        41080 :                           repeats=.FALSE.)
     533              : 
     534              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     535              :                           description="Enables the GW2X correction of the core ionization potentials", &
     536              :                           usage="&GW2X {logical}", &
     537              :                           default_l_val=.FALSE., &
     538        20540 :                           lone_keyword_l_val=.TRUE.)
     539        20540 :       CALL section_add_keyword(subsection, keyword)
     540        20540 :       CALL keyword_release(keyword)
     541              : 
     542              :       CALL keyword_create(keyword, __LOCATION__, name="XPS_ONLY", &
     543              :                           description="If set to .TRUE., only run GW2X calculations for XPS "// &
     544              :                           "spectroscopy and ignore all XAS calculations. It is still "// &
     545              :                           "required to define the DONOR_STATES and KERNEL%EXACT_EXCHANGE "// &
     546              :                           "subsections.", &
     547              :                           default_l_val=.FALSE., &
     548        20540 :                           lone_keyword_l_val=.TRUE.)
     549        20540 :       CALL section_add_keyword(subsection, keyword)
     550        20540 :       CALL keyword_release(keyword)
     551              : 
     552              :       CALL keyword_create(keyword, __LOCATION__, name="BATCH_SIZE", &
     553              :                           description="MOs batch size for batched tensor contraction. Larger "// &
     554              :                           "size is faster, but uses more memory. Default should be safe "// &
     555              :                           "in most cases.", &
     556        20540 :                           default_i_val=64)
     557        20540 :       CALL section_add_keyword(subsection, keyword)
     558        20540 :       CALL keyword_release(keyword)
     559              : 
     560              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_GW2X", &
     561              :                           description="Convergence threshold for GW2X iterations (in eV)", &
     562        20540 :                           default_r_val=1.E-2_dp)
     563        20540 :       CALL section_add_keyword(subsection, keyword)
     564        20540 :       CALL keyword_release(keyword)
     565              : 
     566              :       CALL keyword_create(keyword, __LOCATION__, name="C_OS", &
     567              :                           description="Opposite-spin scling factor. SCS => 6/5, SOS => 1.3", &
     568        20540 :                           default_r_val=1.0_dp)
     569        20540 :       CALL section_add_keyword(subsection, keyword)
     570        20540 :       CALL keyword_release(keyword)
     571              : 
     572              :       CALL keyword_create(keyword, __LOCATION__, name="C_SS", &
     573              :                           description="Same-spin scling factor. SCS => 1/3, SOS => 0.0", &
     574        20540 :                           default_r_val=1.0_dp)
     575        20540 :       CALL section_add_keyword(subsection, keyword)
     576        20540 :       CALL keyword_release(keyword)
     577              : 
     578              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_GW2X_ITER", &
     579              :                           description="Maximum number of iterations for GW2X", &
     580        20540 :                           default_i_val=10)
     581        20540 :       CALL section_add_keyword(subsection, keyword)
     582        20540 :       CALL keyword_release(keyword)
     583              : 
     584              :       CALL keyword_create(keyword, __LOCATION__, name="PSEUDO_CANONICAL", &
     585              :                           variants=["PSEUDO_CANO"], &
     586              :                           description="Whether the pseudo-canonical version of GW2X should be used "// &
     587              :                           "(versus only using the diagonal of the generalized Fock matrix)", &
     588        41080 :                           default_l_val=.TRUE.)
     589        20540 :       CALL section_add_keyword(subsection, keyword)
     590        20540 :       CALL keyword_release(keyword)
     591              : 
     592        20540 :       CALL section_add_subsection(section, subsection)
     593        20540 :       CALL section_release(subsection)
     594              : 
     595              : !  The donor state subsection
     596              : 
     597              :       CALL section_create(subsection, __LOCATION__, name="DONOR_STATES", &
     598              :                           description="Specifications for the donor states from which core "// &
     599              :                           "electrons are excited", &
     600              :                           n_keywords=6, &
     601              :                           n_subsections=0, &
     602        20540 :                           repeats=.FALSE.)
     603              : 
     604              :       CALL keyword_create(keyword, __LOCATION__, name="DEFINE_EXCITED", &
     605              :                           description="Whether the atoms to be excited should be defined by "// &
     606              :                           "a list of atom indices or by a list of atom kinds.", &
     607              :                           usage="DEFINE_EXCITED {string}", &
     608              :                           default_i_val=xas_tdp_by_index, &
     609              :                           enum_c_vals=s2a("BY_INDEX", "BY_KIND"), &
     610              :                           enum_i_vals=[xas_tdp_by_index, xas_tdp_by_kind], &
     611              :                           enum_desc=s2a("Excited atoms are defined by a list of indices", &
     612        20540 :                                         "Excited atoms are defined by a list of atomic kinds"))
     613        20540 :       CALL section_add_keyword(subsection, keyword)
     614        20540 :       CALL keyword_release(keyword)
     615              : 
     616              :       CALL keyword_create(keyword, __LOCATION__, name="ATOM_LIST", &
     617              :                           variants=["AT_LIST"], &
     618              :                           description="Indices of the atoms to be excited. "// &
     619              :                           "Keyword only taken into account if DEFINE_EXCITED = BY_INDEX", &
     620              :                           usage="ATOM_LIST {integer}  {integer} ..  {integer} ", &
     621        41080 :                           n_var=-1, type_of_var=integer_t, repeats=.FALSE.)
     622        20540 :       CALL section_add_keyword(subsection, keyword)
     623        20540 :       CALL keyword_release(keyword)
     624              : 
     625              :       CALL keyword_create(keyword, __LOCATION__, name="KIND_LIST", &
     626              :                           description="Kind of atoms to be excited. "// &
     627              :                           "All atoms of the specified kinds are considered. "// &
     628              :                           "Keyword only taken into account if DEFINE_EXCITED = BY_KIND", &
     629              :                           usage="KIND_LIST {string}  {string} ..  {string} ", &
     630        20540 :                           n_var=-1, type_of_var=char_t, repeats=.FALSE.)
     631        20540 :       CALL section_add_keyword(subsection, keyword)
     632        20540 :       CALL keyword_release(keyword)
     633              : 
     634              :       CALL keyword_create(keyword, __LOCATION__, name="STATE_TYPES", &
     635              :                           variants=["TYPES"], &
     636              :                           description="Types of orbitals that are excited, for each atom/kind, "// &
     637              :                           "in order to do LR-TDDFT driven xas spectra calculation. "// &
     638              :                           "This keyword MUST have the same number of entries as the relevant "// &
     639              :                           "KIND_LIST or ATOM_LIST. The order of the specified state types must "// &
     640              :                           "correspond to the order of the relevant kinds/indices. "// &
     641              :                           "This keyword can be repeated, useful when multiple orbital types "// &
     642              :                           "should be excited for specific kinds/atoms.", &
     643              :                           n_var=-1, default_i_val=xas_not_excited, repeats=.TRUE., &
     644              :                           usage="STATE_TYPES {string}  {string} .. {string}", &
     645              :                           enum_c_vals=s2a("1S", "2S", "2P", "NE"), &
     646              :                           enum_desc=s2a("1s orbital", "2s orbital", "2p orbitals", "not excited"), &
     647        41080 :                           enum_i_vals=[xas_1s_type, xas_2s_type, xas_2p_type, xas_not_excited])
     648        20540 :       CALL section_add_keyword(subsection, keyword)
     649        20540 :       CALL keyword_release(keyword)
     650              : 
     651              :       CALL keyword_create(keyword, __LOCATION__, name="N_SEARCH", &
     652              :                           description="Number of MOs (per spin) to search to find specified donor core "// &
     653              :                           "orbitals, starting from the lowest in energy and upward. By default, "// &
     654              :                           "all HOMOs are searched. If the LOCALIZE keyword is used, "// &
     655              :                           "then all searched states are first localized.", &
     656              :                           usage="N_SEARCH {integer}", &
     657        20540 :                           default_i_val=-1)
     658        20540 :       CALL section_add_keyword(subsection, keyword)
     659        20540 :       CALL keyword_release(keyword)
     660              : 
     661              :       CALL keyword_create(keyword, __LOCATION__, name="LOCALIZE", &
     662              :                           variants=s2a("LOC", "DO_LOC"), &
     663              :                           description="Whether the N_SEARCH potential donor states should be "// &
     664              :                           "actively localized. Necessary in case of excited atoms "// &
     665              :                           "equivalent under symmetry or GW2X correction.", &
     666              :                           usage="LOCALIZE {logical}", &
     667              :                           default_l_val=.FALSE., &
     668        20540 :                           lone_keyword_l_val=.TRUE.)
     669        20540 :       CALL section_add_keyword(subsection, keyword)
     670        20540 :       CALL keyword_release(keyword)
     671              : 
     672        20540 :       CALL section_add_subsection(section, subsection)
     673        20540 :       CALL section_release(subsection)
     674              : ! End of the donor states subsection
     675              : 
     676              : ! The OT solver subsection
     677              :       CALL section_create(subsection, __LOCATION__, name="OT_SOLVER", &
     678              :                           description="Specifications for the iterative OT solver. Note: only "// &
     679              :                           "available within the Tamm-Dancoff approximation. Recommanded if excitations "// &
     680              :                           "from multiple donor states take place.", &
     681              :                           n_keywords=4, &
     682              :                           n_subsections=0, &
     683        20540 :                           repeats=.FALSE.)
     684              : 
     685              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     686              :                           description="Enables the usage of the OT iterator solver", &
     687              :                           usage="&OT_SOLVER {logical}", &
     688              :                           default_l_val=.FALSE., &
     689        20540 :                           lone_keyword_l_val=.TRUE.)
     690        20540 :       CALL section_add_keyword(subsection, keyword)
     691        20540 :       CALL keyword_release(keyword)
     692              : 
     693              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
     694              :                           description="Maximum number of iterations allowed for the OT solver", &
     695              :                           usage="MAX_ITER {integer}", &
     696        20540 :                           default_i_val=50)
     697        20540 :       CALL section_add_keyword(subsection, keyword)
     698        20540 :       CALL keyword_release(keyword)
     699              : 
     700              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
     701              :                           description="Convergence threshold for the OT solver", &
     702              :                           usage="EPS_ITER {double}", &
     703        20540 :                           default_r_val=1.0E-4_dp)
     704        20540 :       CALL section_add_keyword(subsection, keyword)
     705        20540 :       CALL keyword_release(keyword)
     706              : 
     707              :       CALL keyword_create(keyword, __LOCATION__, name="MINIMIZER", &
     708              :                           description="Minimizer to be used with the OT solver", &
     709              :                           usage="MINIMIZER DIIS", &
     710              :                           default_i_val=ot_mini_diis, &
     711              :                           enum_c_vals=s2a("CG", "DIIS"), &
     712              :                           enum_desc=s2a("Conjugated gradient: safer", &
     713              :                                         "Direct inversion of the iterative subspace: faster"), &
     714        20540 :                           enum_i_vals=[ot_mini_cg, ot_mini_diis])
     715        20540 :       CALL section_add_keyword(subsection, keyword)
     716        20540 :       CALL keyword_release(keyword)
     717              : 
     718        20540 :       CALL section_add_subsection(section, subsection)
     719        20540 :       CALL section_release(subsection)
     720              : ! End of the OT solver subsection
     721              : 
     722              :       CALL keyword_create(keyword, __LOCATION__, name="SPIN_ORBIT_COUPLING", &
     723              :                           variants=["SOC"], &
     724              :                           description="Whether spin-orbit coupling should be added. "// &
     725              :                           "Note: only applies for spin-restricted calculations with "// &
     726              :                           "singlet and triplet excitations OR spin-unrestricted "// &
     727              :                           "calculations with both spin-conserving and spin-flip.", &
     728              :                           usage="SOC {logical}", &
     729              :                           default_l_val=.FALSE., &
     730        41080 :                           lone_keyword_l_val=.TRUE.)
     731        20540 :       CALL section_add_keyword(section, keyword)
     732        20540 :       CALL keyword_release(keyword)
     733              : 
     734              :       CALL keyword_create(keyword, __LOCATION__, name="TAMM_DANCOFF", &
     735              :                           variants=["TDA"], &
     736              :                           description="Whether the Tamm-Dancoff approximation should be used.", &
     737              :                           usage="TAMM_DANCOFF {logical}", &
     738              :                           default_l_val=.TRUE., &
     739        41080 :                           lone_keyword_l_val=.TRUE.)
     740        20540 :       CALL section_add_keyword(section, keyword)
     741        20540 :       CALL keyword_release(keyword)
     742              : 
     743              :       CALL keyword_create(keyword, __LOCATION__, name="GRID", &
     744              :                           variants=["ATOMIC_GRID"], &
     745              :                           description="Specification of the atomic angular and radial grids for "// &
     746              :                           "a given atomic kind. This keyword can/should be repeated "// &
     747              :                           "for each excited kind. The default grid dimensions are "// &
     748              :                           "those set for the GAPW ground state calculation. These "// &
     749              :                           "grids are used for the xc-kernel integration. "// &
     750              :                           "Usage: GRID < KIND > < LEBEDEV_GRID > < RADIAL_GRID >", &
     751              :                           usage="GRID {string} {integer} {integer}", &
     752        41080 :                           n_var=3, type_of_var=char_t, repeats=.TRUE.)
     753        20540 :       CALL section_add_keyword(section, keyword)
     754        20540 :       CALL keyword_release(keyword)
     755              : 
     756              :       CALL keyword_create(keyword, __LOCATION__, name="N_EXCITED", &
     757              :                           variants=["N_ROOTS"], &
     758              :                           description="The number of excited states to compute per donor "// &
     759              :                           "molecular orbital. (e.g. if 2p excitations, "// &
     760              :                           "3*N_EXCITED excited states are considered). "// &
     761              :                           "If N_EXCITED is set to -1, all excitations are considered", &
     762              :                           usage="N_EXCITED {integer}", &
     763        41080 :                           default_i_val=-1)
     764        20540 :       CALL section_add_keyword(section, keyword)
     765        20540 :       CALL keyword_release(keyword)
     766              : 
     767              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_RANGE", &
     768              :                           variants=s2a("E_RANGE"), &
     769              :                           description="The energy range in eV for which excitations are considered. "// &
     770              :                           "Only excitated states within the range of: first excitation "// &
     771              :                           "energy + ENERGY_RANGE are kept. If ENERGY_RANGE "// &
     772              :                           "and N_EXCITED are specified, the former has priority. "// &
     773              :                           "Negative values are ignored and N_EXCITED takes over.", &
     774              :                           usage="ENERGY_RANGE {real}", &
     775        20540 :                           default_r_val=-1.0_dp)
     776        20540 :       CALL section_add_keyword(section, keyword)
     777        20540 :       CALL keyword_release(keyword)
     778              : 
     779              : !  The KERNEL subsection
     780              :       CALL section_create(subsection, __LOCATION__, name="KERNEL", &
     781              :                           description="Defines how the kernel is built in terms of functionals.", &
     782              :                           n_keywords=1, &
     783              :                           n_subsections=1, &
     784        20540 :                           repeats=.FALSE.)
     785              : 
     786              :       CALL keyword_create(keyword, __LOCATION__, name="RI_REGION", &
     787              :                           variants=["RI_RADIUS"], &
     788              :                           description="The region defined by a sphere of the given radius around "// &
     789              :                           "the excited atom defining which RI_XAS basis elements are "// &
     790              :                           "considered for the RI projection of the density. Each basis "// &
     791              :                           "element which center is in this region is taken. The density "// &
     792              :                           "for a given excited atom is expressed as : "// &
     793              :                           "sum_ijkl P_ij (ijk) S_kl^-1 xi_l, where P_ij is the density "// &
     794              :                           "matrix, i,j span the orbital basis and k,l the RI_XAS basis "// &
     795              :                           "in the region. The larger the radius, the more basis "// &
     796              :                           "functions to expand the density. However, it is assumed "// &
     797              :                           "that it is a small number and the code does not scale well "// &
     798              :                           "as the number of RI basis elements gets too large. "// &
     799              :                           "Expressed in Angstrom. If the radius is set to 0.0, only "// &
     800              :                           "the RI basis elements centered on the excited atom are used.", &
     801              :                           usage="RI_REGION {real}", &
     802        41080 :                           default_r_val=0.0_dp)
     803        20540 :       CALL section_add_keyword(subsection, keyword)
     804        20540 :       CALL keyword_release(keyword)
     805              : 
     806              : !  The XC_FUNCTIONAL subsubsection
     807        20540 :       CALL create_xc_fun_section(subsubsection)
     808        20540 :       CALL section_add_subsection(subsection, subsubsection)
     809        20540 :       CALL section_release(subsubsection)
     810              : 
     811              : ! The EXACT_EXCHANGE subsubsection
     812              :       CALL section_create(subsubsection, __LOCATION__, name="EXACT_EXCHANGE", &
     813              :                           description="Whether exact-exchange should be added to the kernel and "// &
     814              :                           "if so, with which fraction and operator.", &
     815              :                           n_keywords=7, &
     816              :                           n_subsections=1, &
     817        20540 :                           repeats=.FALSE.)
     818              : 
     819              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     820              :                           description="Enables the addition of exact exchange to the kernel.", &
     821              :                           usage="&EXACT_EXCHANGE {logical}", &
     822              :                           default_l_val=.FALSE., &
     823        20540 :                           lone_keyword_l_val=.TRUE.)
     824        20540 :       CALL section_add_keyword(subsubsection, keyword)
     825        20540 :       CALL keyword_release(keyword)
     826              : 
     827              :       CALL keyword_create(keyword, __LOCATION__, name="POTENTIAL_TYPE", &
     828              :                           variants=s2a("OP", "OPERATOR", "POTENTIAL"), &
     829              :                           description="The type of operator used for exact exchange. The standard "// &
     830              :                           "Coulomb operator cannot be used in periodic systems.", &
     831              :                           usage="OPERATOR {string}", &
     832              :                           repeats=.FALSE., &
     833              :                           default_i_val=do_potential_coulomb, &
     834              :                           enum_c_vals=s2a("COULOMB", "TRUNCATED", "SHORTRANGE"), &
     835              :                           enum_desc=s2a("Standard Coulomb operator: 1/r", &
     836              :                                         "Truncated Coulomb operator: 1/r if r < R_c, 0 otherwise ", &
     837              :                                         "Short range: erfc(omega*r)/r"), &
     838              :                           enum_i_vals=[do_potential_coulomb, do_potential_truncated, &
     839        20540 :                                        do_potential_short])
     840        20540 :       CALL section_add_keyword(subsubsection, keyword)
     841        20540 :       CALL keyword_release(keyword)
     842              : 
     843              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     844              :                           variants=s2a("R_C", "RC", "RANGE"), &
     845              :                           description="The cutoff radius (in Angstrom) for the truncated Coulomb operator.", &
     846              :                           usage="CUTOFF_RADIUS {double}", &
     847              :                           default_r_val=0.0_dp, &
     848        20540 :                           repeats=.FALSE.)
     849        20540 :       CALL section_add_keyword(subsubsection, keyword)
     850        20540 :       CALL keyword_release(keyword)
     851              : 
     852              :       CALL keyword_create(keyword, __LOCATION__, name="T_C_G_DATA", &
     853              :                           description="Location of the file t_c_g.dat that contains the data for the "// &
     854              :                           "evaluation of the truncated gamma function ", &
     855              :                           usage="T_C_G_DATA {string}", &
     856        20540 :                           default_c_val="t_c_g.dat")
     857        20540 :       CALL section_add_keyword(subsubsection, keyword)
     858        20540 :       CALL keyword_release(keyword)
     859              : 
     860              :       CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
     861              :                           description="The range parameter for the short range operator (in 1/a0).", &
     862              :                           usage="OMEGA {double}", &
     863              :                           default_r_val=0.0_dp, &
     864        20540 :                           repeats=.FALSE.)
     865        20540 :       CALL section_add_keyword(subsubsection, keyword)
     866        20540 :       CALL keyword_release(keyword)
     867              : 
     868              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_RANGE", &
     869              :                           description="The threshold to determine the effective range of the short range "// &
     870              :                           "operator: erfc(omega*eff_range)/eff_range = EPS_RANGE", &
     871              :                           usage="EPS_RANGE = {double}", &
     872              :                           default_r_val=1.0E-6_dp, &
     873        20540 :                           repeats=.FALSE.)
     874        20540 :       CALL section_add_keyword(subsubsection, keyword)
     875        20540 :       CALL keyword_release(keyword)
     876              : 
     877              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_SCREENING", &
     878              :                           variants=s2a("EPS_SCREEN"), &
     879              :                           description="A threshold to determine which primitive 3-center integrals "// &
     880              :                           "are kept for contraction, as the latter operation can be "// &
     881              :                           "expensive (especially for large basis sets ). "// &
     882              :                           "If |(ab|c)| < EPS_SCREENING, it is discarded.", &
     883              :                           default_r_val=1.0E-8_dp, &
     884        20540 :                           repeats=.FALSE.)
     885        20540 :       CALL section_add_keyword(subsubsection, keyword)
     886        20540 :       CALL keyword_release(keyword)
     887              : 
     888              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE", &
     889              :                           variants=s2a("FRACTION"), &
     890              :                           description="Scaling of the exact exchange contribution.", &
     891        20540 :                           default_r_val=1.0_dp)
     892        20540 :       CALL section_add_keyword(subsubsection, keyword)
     893        20540 :       CALL keyword_release(keyword)
     894              : 
     895              :       !The RI metric subsection
     896              :       CALL section_create(subsubsubsection, __LOCATION__, name="RI_METRIC", &
     897              :                           description="This subsection allows for the definition of an exchange "// &
     898              :                           "RI metric that is different from the main exchange potential. "// &
     899              :                           "By default (i.e. if this subsection is ignored), the "// &
     900              :                           "exchange kernel is computed in the V approximation: "// &
     901              :                           "(ab|ij) = (ab|P) V^-1 (Q|ij), where V = (P|Q). With a RI "// &
     902              :                           "metric, we have a 2 step RI involving the metric potential "// &
     903              :                           "for the 3-center integrals: "// &
     904              :                           "(ab|ij) = (ab!P) (P!Q)^-1 (Q|R) (R!S)^-1 (S!ij), where | "// &
     905              :                           "stands for the exchange potential and ! for the metric "// &
     906              :                           "potential. This allows for drastic screening of the "// &
     907              :                           "3-center integrals by selecting shorter range metric.", &
     908              :                           n_keywords=5, &
     909              :                           n_subsections=0, &
     910        20540 :                           repeats=.FALSE.)
     911              : 
     912              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     913              :                           description="Enables the use of a RI metric.", &
     914              :                           usage="&EXACT_EXCHANGE {logical}", &
     915              :                           default_l_val=.FALSE., &
     916        20540 :                           lone_keyword_l_val=.TRUE.)
     917        20540 :       CALL section_add_keyword(subsubsubsection, keyword)
     918        20540 :       CALL keyword_release(keyword)
     919              : 
     920              :       CALL keyword_create(keyword, __LOCATION__, name="POTENTIAL_TYPE", &
     921              :                           variants=s2a("OP", "OPERATOR", "POTENTIAL"), &
     922              :                           description="The type of operator used for the metric.", &
     923              :                           usage="OPERATOR {string}", &
     924              :                           repeats=.FALSE., &
     925              :                           default_i_val=do_potential_id, &
     926              :                           enum_c_vals=s2a("OVERLAP", "TRUNCATED", "SHORTRANGE"), &
     927              :                           enum_desc=s2a("Overlap operator (=identity)", &
     928              :                                         "Truncated Coulomb operator: 1/r if r < R_c, 0 otherwise ", &
     929              :                                         "Short range: erfc(omega*r)/r"), &
     930              :                           enum_i_vals=[do_potential_id, do_potential_truncated, &
     931        20540 :                                        do_potential_short])
     932        20540 :       CALL section_add_keyword(subsubsubsection, keyword)
     933        20540 :       CALL keyword_release(keyword)
     934              : 
     935              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
     936              :                           variants=s2a("R_C", "RC", "RANGE"), &
     937              :                           description="The cutoff radius (in Angstrom) for the truncated Coulomb operator.", &
     938              :                           usage="CUTOFF_RADIUS {double}", &
     939              :                           default_r_val=0.0_dp, &
     940        20540 :                           repeats=.FALSE.)
     941        20540 :       CALL section_add_keyword(subsubsubsection, keyword)
     942        20540 :       CALL keyword_release(keyword)
     943              : 
     944              :       CALL keyword_create(keyword, __LOCATION__, name="T_C_G_DATA", &
     945              :                           description="Location of the file t_c_g.dat that contains the data for the "// &
     946              :                           "evaluation of the truncated gamma function ", &
     947              :                           usage="T_C_G_DATA {string}", &
     948        20540 :                           default_c_val="t_c_g.dat")
     949        20540 :       CALL section_add_keyword(subsubsubsection, keyword)
     950        20540 :       CALL keyword_release(keyword)
     951              : 
     952              :       CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
     953              :                           description="The range parameter for the short range operator (in 1/a0).", &
     954              :                           usage="OMEGA {double}", &
     955              :                           default_r_val=0.0_dp, &
     956        20540 :                           repeats=.FALSE.)
     957        20540 :       CALL section_add_keyword(subsubsubsection, keyword)
     958        20540 :       CALL keyword_release(keyword)
     959              : 
     960        20540 :       CALL section_add_subsection(subsubsection, subsubsubsection)
     961        20540 :       CALL section_release(subsubsubsection)
     962              : 
     963        20540 :       CALL section_add_subsection(subsection, subsubsection)
     964        20540 :       CALL section_release(subsubsection)
     965              : 
     966        20540 :       CALL section_add_subsection(section, subsection)
     967        20540 :       CALL section_release(subsection)
     968              : ! End of Kernel subsection
     969              : 
     970              :       CALL section_create(subsection, __LOCATION__, "PRINT", "Controls the printing of information during "// &
     971        20540 :                           "XAS TDP calculations", repeats=.FALSE.)
     972              : 
     973              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="SPECTRUM", &
     974              :                                        description="Controls the dumping of the XAS TDP spectrum in output files", &
     975        20540 :                                        print_level=low_print_level, filename="", common_iter_levels=3)
     976        20540 :       CALL section_add_subsection(subsection, print_key)
     977        20540 :       CALL section_release(print_key)
     978              : 
     979              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="RESTART_WFN", &
     980              :                                        description="Controles the dumping of a MO restart file for a given "// &
     981              :                                        "excited state index. Only for K-edge RKS calculations. "// &
     982              :                                        "Can be repeated to get multiple *.wfn files at once.", &
     983        20540 :                                        print_level=debug_print_level, filename="", common_iter_levels=1)
     984              :       CALL keyword_create(keyword, __LOCATION__, name="EXCITED_STATE_INDEX", variants=["INDEX"], &
     985              :                           description="The index of the excited state that should be dumped", &
     986        41080 :                           usage="INDEX {int}", default_i_val=1, repeats=.TRUE.)
     987        20540 :       CALL section_add_keyword(print_key, keyword)
     988        20540 :       CALL keyword_release(keyword)
     989              : 
     990        20540 :       CALL section_add_subsection(subsection, print_key)
     991        20540 :       CALL section_release(print_key)
     992              : 
     993        20540 :       CALL create_xas_pdos_section(print_key)
     994        20540 :       CALL section_add_subsection(subsection, print_key)
     995        20540 :       CALL section_release(print_key)
     996              : 
     997              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CUBES", &
     998              :                                        description="Controls the printing of the linear-response orbitals "// &
     999              :                                        "as *.cube files.", &
    1000              :                                        print_level=high_print_level, common_iter_levels=1, &
    1001        20540 :                                        add_last=add_last_numeric, filename="")
    1002              : 
    1003              :       CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
    1004              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1005              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1006              :                           " 1 number valid for all components.", &
    1007        20540 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1008        20540 :       CALL section_add_keyword(print_key, keyword)
    1009        20540 :       CALL keyword_release(keyword)
    1010              : 
    1011              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LU_BOUNDS", &
    1012              :                           variants=["CUBES_LU"], &
    1013              :                           description="The lower and upper index of the excited states to be printed as cube", &
    1014              :                           usage="CUBES_LU_BOUNDS integer integer", &
    1015        41080 :                           n_var=2, default_i_vals=[1, 0], type_of_var=integer_t)
    1016        20540 :       CALL section_add_keyword(print_key, keyword)
    1017        20540 :       CALL keyword_release(keyword)
    1018              : 
    1019              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LIST", &
    1020              :                           description="Indexes of the excited states to be printed as cube files "// &
    1021              :                           "This keyword can be repeated several times "// &
    1022              :                           "(useful if you have to specify many indexes).", &
    1023              :                           usage="CUBES_LIST 1 2", &
    1024        20540 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
    1025        20540 :       CALL section_add_keyword(print_key, keyword)
    1026        20540 :       CALL keyword_release(keyword)
    1027              : 
    1028              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1029              :                           description="append the cube files when they already exist", &
    1030        20540 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1031        20540 :       CALL section_add_keyword(print_key, keyword)
    1032        20540 :       CALL keyword_release(keyword)
    1033              : 
    1034        20540 :       CALL section_add_subsection(subsection, print_key)
    1035        20540 :       CALL section_release(print_key)
    1036              : 
    1037              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
    1038              :                                        description="Controls the dumping of LR-orbitals coefficients "// &
    1039              :                                        "and corresponding excitation energies such that "// &
    1040              :                                        "the program can be restarted for PDOS or CUBE "// &
    1041              :                                        "printing without the heavy computing.", &
    1042        20540 :                                        print_level=high_print_level, filename="", common_iter_levels=3)
    1043        20540 :       CALL section_add_subsection(subsection, print_key)
    1044        20540 :       CALL section_release(print_key)
    1045              : 
    1046        20540 :       CALL section_add_subsection(section, subsection)
    1047        20540 :       CALL section_release(subsection)
    1048              : 
    1049        20540 :    END SUBROUTINE create_xas_tdp_section
    1050              : 
    1051              : END MODULE input_cp2k_xas
        

Generated by: LCOV version 2.0-1