LCOV - code coverage report
Current view: top level - src - input_cp2k_properties_dft.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:123285f) Lines: 99.9 % 1330 1329
Test Date: 2026-11-04 00:58:17 Functions: 100.0 % 29 29

            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              : !>      01.2013 moved out of input_cp2k_dft [MI]
      12              : !> \author MI
      13              : ! **************************************************************************************************
      14              : MODULE input_cp2k_properties_dft
      15              :    USE bibliography, ONLY: Dixon2023, Doll2025, Wong2026, Loring2015, Cerjan2023, Futera2017, &
      16              :                            Hedin1965, &
      17              :                            Hybertsen1986, &
      18              :                            Hartwigsen1998, &
      19              :                            Tyagi2024, &
      20              :                            Tyagi2026, &
      21              :                            Ditler2021, &
      22              :                            Ditler2022, &
      23              :                            Hanasaki2025, &
      24              :                            Hernandez2025, &
      25              :                            Iannuzzi2005, &
      26              :                            Kondov2007, &
      27              :                            KuhneHeskeProdan2020, &
      28              :                            Luber2014, &
      29              :                            Putrino2000, &
      30              :                            Putrino2002, &
      31              :                            Sebastiani2001, &
      32              :                            Weber2009, &
      33              :                            VazdaCruz2021, &
      34              :                            Wilhelm2021, &
      35              :                            Graml2024, &
      36              :                            Duchemin2019, &
      37              :                            Duchemin2021
      38              :    USE cp_output_handling, ONLY: add_last_numeric, &
      39              :                                  cp_print_key_section_create, &
      40              :                                  debug_print_level, &
      41              :                                  high_print_level, &
      42              :                                  low_print_level, &
      43              :                                  medium_print_level, &
      44              :                                  silent_print_level
      45              :    USE cp_units, ONLY: cp_unit_to_cp2k
      46              :    USE input_constants, ONLY: &
      47              :       cohsex_diagonal, cohsex_off, cohsex_qp_update, &
      48              :       current_gauge_atom, current_gauge_r, current_gauge_r_and_step_func, &
      49              :       current_orb_center_atom, current_orb_center_box, current_orb_center_common, &
      50              :       current_orb_center_wannier, do_et_ddapc, do_full_density, do_no_et, do_spin_density, &
      51              :       evGW0, G0W0, &
      52              :       gto_cartesian, gto_spherical, int_ldos_none, int_ldos_x, int_ldos_y, int_ldos_z, oe_gllb, &
      53              :       oe_lb, oe_none, oe_saop, oe_shift, ot_precond_full_all, ot_precond_full_kinetic, &
      54              :       ot_precond_full_single, ot_precond_full_single_inverse, ot_precond_none, &
      55              :       ot_precond_s_inverse, scan_x, scan_xy, scan_xyz, scan_xz, scan_y, scan_yz, scan_z, &
      56              :       tddfpt_dipole_berry, tddfpt_dipole_length, tddfpt_dipole_scf_moment, &
      57              :       tddfpt_dipole_velocity, tddfpt_dipole_velocity_old, tddfpt_kernel_full, tddfpt_kernel_none, &
      58              :       tddfpt_kernel_stda, no_sf_tddfpt, tddfpt_sf_col, tddfpt_sf_noncol, use_mom_ref_coac, &
      59              :       use_mom_ref_com, use_mom_ref_user, use_mom_ref_zero
      60              :    USE input_cp2k_atprop, ONLY: create_atprop_section
      61              :    USE input_cp2k_dft, ONLY: create_interp_section, &
      62              :                              create_mgrid_section
      63              :    USE input_cp2k_mp2, ONLY: create_bse_section
      64              :    USE input_cp2k_qs, ONLY: create_ddapc_restraint_section, &
      65              :                             create_lrigpw_section
      66              :    USE input_cp2k_kpoints, ONLY: create_kpoint_set_section, use_k290_kpoint_backend, use_spglib_kpoint_backend
      67              :    USE input_cp2k_loc, ONLY: create_localize_section
      68              :    USE input_cp2k_resp, ONLY: create_resp_section
      69              :    USE input_cp2k_xc, ONLY: create_xc_section
      70              :    USE input_keyword_types, ONLY: keyword_create, &
      71              :                                   keyword_release, &
      72              :                                   keyword_type
      73              :    USE input_section_types, ONLY: section_add_keyword, &
      74              :                                   section_add_subsection, &
      75              :                                   section_create, &
      76              :                                   section_release, &
      77              :                                   section_type
      78              :    USE input_val_types, ONLY: char_t, enum_t, &
      79              :                               integer_t, &
      80              :                               lchar_t, &
      81              :                               logical_t, &
      82              :                               real_t
      83              :    USE input_cp2k_xas, ONLY: create_xas_tdp_section
      84              :    USE nlo, ONLY: create_nonlinear_optics_section
      85              :    USE kinds, ONLY: dp
      86              :    USE string_utilities, ONLY: s2a
      87              : #include "./base/base_uses.f90"
      88              : 
      89              :    IMPLICIT NONE
      90              :    PRIVATE
      91              : 
      92              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      93              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_properties_dft'
      94              : 
      95              :    PUBLIC :: create_properties_section
      96              : 
      97              : CONTAINS
      98              : 
      99              : ! **************************************************************************************************
     100              : !> \brief Create the PROPERTIES section
     101              : !> \param section the section to create
     102              : !> \author teo
     103              : ! **************************************************************************************************
     104         1462 :    SUBROUTINE create_properties_section(section)
     105              :       TYPE(section_type), POINTER                        :: section
     106              : 
     107              :       TYPE(keyword_type), POINTER                        :: keyword
     108              :       TYPE(section_type), POINTER                        :: subsection
     109              : 
     110         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
     111              :       CALL section_create(section, __LOCATION__, name="PROPERTIES", &
     112              :                           description="This section is used to set up the PROPERTIES calculation.", &
     113         1462 :                           n_keywords=0, n_subsections=7, repeats=.FALSE.)
     114              : 
     115         1462 :       NULLIFY (subsection, keyword)
     116              : 
     117         1462 :       CALL create_linres_section(subsection, create_subsections=.TRUE.)
     118         1462 :       CALL section_add_subsection(section, subsection)
     119         1462 :       CALL section_release(subsection)
     120              : 
     121         1462 :       CALL create_et_coupling_section(subsection)
     122         1462 :       CALL section_add_subsection(section, subsection)
     123         1462 :       CALL section_release(subsection)
     124              : 
     125         1462 :       CALL create_resp_section(subsection)
     126         1462 :       CALL section_add_subsection(section, subsection)
     127         1462 :       CALL section_release(subsection)
     128              : 
     129         1462 :       CALL create_atprop_section(subsection)
     130         1462 :       CALL section_add_subsection(section, subsection)
     131         1462 :       CALL section_release(subsection)
     132              : 
     133              :       CALL cp_print_key_section_create(subsection, __LOCATION__, name="FIT_CHARGE", &
     134              :                                        description="This section is used to print the density derived atomic point charges. "// &
     135              :                                        "The fit of the charges is controlled through the DENSITY_FITTING section", &
     136         1462 :                                        print_level=high_print_level, filename="__STD_OUT__")
     137              :       CALL keyword_create(keyword, __LOCATION__, name="TYPE_OF_DENSITY", &
     138              :                           description="Specifies the type of density used for the fitting", &
     139              :                           usage="TYPE_OF_DENSITY (FULL|SPIN)", &
     140              :                           enum_c_vals=s2a("FULL", "SPIN"), &
     141              :                           enum_i_vals=[do_full_density, do_spin_density], &
     142              :                           enum_desc=s2a("Full density", "Spin density"), &
     143         1462 :                           default_i_val=do_full_density)
     144         1462 :       CALL section_add_keyword(subsection, keyword)
     145         1462 :       CALL keyword_release(keyword)
     146         1462 :       CALL section_add_subsection(section, subsection)
     147         1462 :       CALL section_release(subsection)
     148              : 
     149         1462 :       CALL create_tddfpt2_section(subsection)
     150         1462 :       CALL section_add_subsection(section, subsection)
     151         1462 :       CALL section_release(subsection)
     152              : 
     153         1462 :       CALL create_rixs_section(subsection)
     154         1462 :       CALL section_add_subsection(section, subsection)
     155         1462 :       CALL section_release(subsection)
     156              : 
     157         1462 :       CALL create_nonlinear_optics_section(subsection)
     158         1462 :       CALL section_add_subsection(section, subsection)
     159         1462 :       CALL section_release(subsection)
     160              : 
     161         1462 :       CALL create_kubo_transport_section(subsection)
     162         1462 :       CALL section_add_subsection(section, subsection)
     163         1462 :       CALL section_release(subsection)
     164              : 
     165         1462 :       CALL create_spectral_localizer_section(subsection)
     166         1462 :       CALL section_add_subsection(section, subsection)
     167         1462 :       CALL section_release(subsection)
     168         1462 :       CALL create_quadratic_pseudospectrum_section(subsection)
     169         1462 :       CALL section_add_subsection(section, subsection)
     170         1462 :       CALL section_release(subsection)
     171              : 
     172         1462 :       CALL create_bandstructure_section(subsection)
     173         1462 :       CALL section_add_subsection(section, subsection)
     174         1462 :       CALL section_release(subsection)
     175              : 
     176         1462 :       CALL create_bse_section(subsection, run_bse_from_band_structure_section=.TRUE.)
     177         1462 :       CALL section_add_subsection(section, subsection)
     178         1462 :       CALL section_release(subsection)
     179              : 
     180         1462 :       CALL create_tipscan_section(subsection)
     181         1462 :       CALL section_add_subsection(section, subsection)
     182         1462 :       CALL section_release(subsection)
     183              : 
     184         1462 :    END SUBROUTINE create_properties_section
     185              : 
     186              : ! **************************************************************************************************
     187              : !> \brief creates the input structure used to activate finite-volume Kubo transport
     188              : ! **************************************************************************************************
     189              : 
     190         1462 :    SUBROUTINE create_kubo_transport_section(section)
     191              :       TYPE(section_type), POINTER                        :: section
     192              :       TYPE(keyword_type), POINTER                        :: keyword
     193              : 
     194         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
     195              : 
     196         1462 :       NULLIFY (keyword)
     197              : 
     198              :       CALL section_create(section, __LOCATION__, name="KUBO_TRANSPORT", &
     199              :                           description="Finite-volume Kubo-Greenwood transport coefficients from the "// &
     200              :                           "converged Quickstep Hamiltonian, overlap matrix, and atomic geometry. "// &
     201              :                           "For one- and two-dimensional cells, transport is projected onto the "// &
     202              :                           "periodic subspace and normalized by the periodic length or area.", &
     203              :                           n_keywords=8, n_subsections=0, repeats=.FALSE., &
     204         2924 :                           citations=[KuhneHeskeProdan2020])
     205              : 
     206              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     207              :                           description="Controls the activation of the Kubo transport calculation.", &
     208              :                           default_l_val=.FALSE., &
     209         1462 :                           lone_keyword_l_val=.TRUE.)
     210         1462 :       CALL section_add_keyword(section, keyword)
     211         1462 :       CALL keyword_release(keyword)
     212              : 
     213              :       CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
     214              :                           description="Transport algorithm. DIAGONALIZATION evaluates the finite-volume "// &
     215              :                           "Kubo-Greenwood expression from the explicit spectrum. TD and CHEBYSHEV are "// &
     216              :                           "reserved for future diagonalization-free implementations.", &
     217              :                           usage="METHOD DIAGONALIZATION", &
     218         1462 :                           n_var=1, type_of_var=char_t, default_c_val="DIAGONALIZATION")
     219         1462 :       CALL section_add_keyword(section, keyword)
     220         1462 :       CALL keyword_release(keyword)
     221              : 
     222              :       CALL keyword_create(keyword, __LOCATION__, name="CURRENT_OPERATOR", type_of_var=enum_t, &
     223              :                           description="ATOM_EMBEDDING retains the finite-volume atom-coordinate model. "// &
     224              :                           "PROJECTED_AO uses analytic AO positions and the metric-aware commutator "// &
     225              :                           "H*S^-1*X-X*S^-1*H, with complex spinors when SOC is enabled. "// &
     226              :                           "PROJECTED_AO requires PERIODIC NONE and GPW/GAPW. This is the current of the "// &
     227              :                           "projected AO Hamiltonian. BLOCH evaluates analytic Hamiltonian/overlap k derivatives "// &
     228              :                           "and the AO connection on a full MP_GRID, with optional SOC and intraband terms. "// &
     229              :                           "BLOCH requires a periodic GPW/GAPW calculation.", &
     230         1462 :                           enum_c_vals=s2a("ATOM_EMBEDDING", "PROJECTED_AO", "BLOCH"), enum_i_vals=[0, 1, 2], default_i_val=0)
     231         1462 :       CALL section_add_keyword(section, keyword)
     232         1462 :       CALL keyword_release(keyword)
     233              :       CALL keyword_create(keyword, __LOCATION__, name="SOC", &
     234              :                           description="Add GTH-SOC in the complete AO spinor space after a restricted SCF. "// &
     235              :                           "Requires CURRENT_OPERATOR PROJECTED_AO or BLOCH and SOC pseudopotential parameters. "// &
     236              :                           "Does not perform self-consistent noncollinear DFT. A time-reversal-symmetric "// &
     237         1462 :                           "Hamiltonian has zero net charge Hall response.", default_l_val=.FALSE.)
     238         1462 :       CALL section_add_keyword(section, keyword)
     239         1462 :       CALL keyword_release(keyword)
     240              :       CALL keyword_create(keyword, __LOCATION__, name="HALL_RESPONSE", &
     241              :                           description="Include the antisymmetric DC charge response in the conductivity tensor "// &
     242              :                           "and print its three independent components separately. Requires PROJECTED_AO or BLOCH. "// &
     243              :                           "Uses the same positive scalar DISSIPATION; does not add magnetic order, an applied "// &
     244         1462 :                           "magnetic field, spin Hall currents, or microscopic scattering mechanisms.", default_l_val=.FALSE.)
     245         1462 :       CALL section_add_keyword(section, keyword)
     246         1462 :       CALL keyword_release(keyword)
     247              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_AO", &
     248              :                           description="Safety limit on scalar AO dimension for PROJECTED_AO or BLOCH. "// &
     249         1462 :                           "Dense spinor matrices have dimension 2*NAO when SOC is enabled.", default_i_val=512)
     250         1462 :       CALL section_add_keyword(section, keyword)
     251         1462 :       CALL keyword_release(keyword)
     252              : 
     253              :       CALL keyword_create(keyword, __LOCATION__, name="MP_GRID", &
     254              :                           description="Full Gamma-centered property mesh for CURRENT_OPERATOR BLOCH. "// &
     255              :                           "Independent of SCF sampling and symmetry reduction, at the frozen SCF potential. "// &
     256              :                           "Nonperiodic directions must be one.", &
     257         1462 :                           type_of_var=integer_t, n_var=3, default_i_vals=[1, 1, 1])
     258         1462 :       CALL section_add_keyword(section, keyword)
     259         1462 :       CALL keyword_release(keyword)
     260              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_MEMORY_MB", &
     261              :                           description="Safety bound in MiB on replicated BLOCH array storage per MPI rank. "// &
     262         1462 :                           "Excludes CP2K/DBCSR environment and library workspace.", default_i_val=1024)
     263         1462 :       CALL section_add_keyword(section, keyword)
     264         1462 :       CALL keyword_release(keyword)
     265              : 
     266              :       CALL keyword_create(keyword, __LOCATION__, name="SYMMETRY", &
     267              :                           description="Reconstruct equivalent BLOCH property eigenframes from independent irreducible points. "// &
     268              :                           "Includes atom/AO, cell-image and physical SOC spin transformations. "// &
     269              :                           "Every reconstructed frame is checked against the target H/S and current; "// &
     270              :                           "an inconsistent frozen SCF potential aborts instead of silently changing the response.", &
     271         1462 :                           default_l_val=.FALSE.)
     272         1462 :       CALL section_add_keyword(section, keyword)
     273         1462 :       CALL keyword_release(keyword)
     274              :       CALL keyword_create(keyword, __LOCATION__, name="SYMMETRY_BACKEND", type_of_var=enum_t, &
     275              :                           description="Backend for the independent BLOCH property symmetry mesh.", &
     276              :                           enum_c_vals=s2a("K290", "SPGLIB"), &
     277              :                           enum_i_vals=[use_k290_kpoint_backend, use_spglib_kpoint_backend], &
     278         1462 :                           default_i_val=use_k290_kpoint_backend)
     279         1462 :       CALL section_add_keyword(section, keyword)
     280         1462 :       CALL keyword_release(keyword)
     281              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_SYMMETRY", &
     282         1462 :                           description="Geometric tolerance for BLOCH property symmetry detection.", default_r_val=1.e-6_dp)
     283         1462 :       CALL section_add_keyword(section, keyword)
     284         1462 :       CALL keyword_release(keyword)
     285              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_SYMMETRY_OPERATORS", &
     286              :                           description="Tolerance for target metric, energy-scaled Hamiltonian, and current covariance checks. "// &
     287         1462 :                           "The current error is scaled by max(1,|J|) in atomic units.", default_r_val=1.e-8_dp)
     288         1462 :       CALL section_add_keyword(section, keyword)
     289         1462 :       CALL keyword_release(keyword)
     290              : 
     291              :       CALL keyword_create(keyword, __LOCATION__, name="TEMPERATURE", &
     292              :                           description="Electronic temperature used in the Fermi operator.", &
     293              :                           usage="TEMPERATURE 1.0", &
     294              :                           default_r_val=cp_unit_to_cp2k(value=1.0_dp, unit_str="K"), &
     295         1462 :                           n_var=1, type_of_var=real_t, unit_str="K")
     296         1462 :       CALL section_add_keyword(section, keyword)
     297         1462 :       CALL keyword_release(keyword)
     298              : 
     299              :       CALL keyword_create(keyword, __LOCATION__, name="DISSIPATION", &
     300              :                           description="Dissipation/broadening parameter in the finite-temperature "// &
     301              :                           "Kubo formula.", &
     302              :                           usage="DISSIPATION 300.0", &
     303              :                           default_r_val=cp_unit_to_cp2k(value=300.0_dp, unit_str="K"), &
     304         1462 :                           n_var=1, type_of_var=real_t, unit_str="K")
     305         1462 :       CALL section_add_keyword(section, keyword)
     306         1462 :       CALL keyword_release(keyword)
     307              : 
     308              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_RANGE", &
     309              :                           description="Absolute chemical-potential range. The default 0 0 uses the "// &
     310              :                           "full eigenvalue range of the finite-volume Hamiltonian.", &
     311              :                           usage="ENERGY_RANGE -0.5 0.5", &
     312              :                           default_r_vals=[0.0_dp, 0.0_dp], n_var=2, type_of_var=real_t, &
     313         1462 :                           unit_str="hartree")
     314         1462 :       CALL section_add_keyword(section, keyword)
     315         1462 :       CALL keyword_release(keyword)
     316              : 
     317              :       CALL keyword_create(keyword, __LOCATION__, name="NEUTRAL_MU", &
     318              :                           description="Optional fixed neutral chemical potential. If omitted, the "// &
     319              :                           "neutral point is found from the eigenvalue spectrum and total electron count.", &
     320              :                           usage="NEUTRAL_MU 0.245467619658419", &
     321         1462 :                           n_var=1, type_of_var=real_t, unit_str="hartree")
     322         1462 :       CALL section_add_keyword(section, keyword)
     323         1462 :       CALL keyword_release(keyword)
     324              : 
     325              :       CALL keyword_create(keyword, __LOCATION__, name="N_MU", &
     326              :                           description="Number of chemical-potential grid points.", &
     327              :                           usage="N_MU 200", &
     328         1462 :                           default_i_val=200, n_var=1, type_of_var=integer_t)
     329         1462 :       CALL section_add_keyword(section, keyword)
     330         1462 :       CALL keyword_release(keyword)
     331              : 
     332              :       CALL keyword_create(keyword, __LOCATION__, name="NEUTRAL_GRID", &
     333              :                           description="Number of grid points used to locate the neutral chemical potential.", &
     334              :                           usage="NEUTRAL_GRID 10000", &
     335         1462 :                           default_i_val=10000, n_var=1, type_of_var=integer_t)
     336         1462 :       CALL section_add_keyword(section, keyword)
     337         1462 :       CALL keyword_release(keyword)
     338              : 
     339         1462 :    END SUBROUTINE create_kubo_transport_section
     340              : 
     341              : ! **************************************************************************************************
     342              : !> \brief creates the input structure used to activate
     343              : !>      a resonant inelastic xray scattering (RIXS) calculation
     344              : ! **************************************************************************************************
     345              : 
     346         1462 :    SUBROUTINE create_rixs_section(section)
     347              :       TYPE(section_type), POINTER                        :: section
     348              :       TYPE(section_type), POINTER                        :: subsection, print_key
     349              :       TYPE(keyword_type), POINTER                        :: keyword
     350              : 
     351         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
     352              : 
     353         1462 :       NULLIFY (keyword, subsection, print_key)
     354              : 
     355              :       CALL section_create(section, __LOCATION__, name="RIXS", &
     356              :                           description="Resonant Inelastic Xray Scattering using XAS_TDP and TDDFPT.", &
     357              :                           n_keywords=1, n_subsections=3, repeats=.FALSE., &
     358         2924 :                           citations=[VazdaCruz2021])
     359              : 
     360              :       CALL keyword_create(keyword, __LOCATION__, &
     361              :                           name="_SECTION_PARAMETERS_", &
     362              :                           description="Controls the activation of the RIXS procedure", &
     363              :                           default_l_val=.FALSE., &
     364         1462 :                           lone_keyword_l_val=.TRUE.)
     365         1462 :       CALL section_add_keyword(section, keyword)
     366         1462 :       CALL keyword_release(keyword)
     367              : 
     368              :       CALL keyword_create(keyword, __LOCATION__, name="CORE_STATES", &
     369              :                           description="Number of core excited states to be used in the RIXS "// &
     370              :                           "calculation. Restricting this number reduces computational cost. "// &
     371              :                           "-1 means all available core states will be used.", &
     372         1462 :                           n_var=1, type_of_var=integer_t, default_i_val=-1)
     373         1462 :       CALL section_add_keyword(section, keyword)
     374         1462 :       CALL keyword_release(keyword)
     375              : 
     376              :       CALL keyword_create(keyword, __LOCATION__, name="VALENCE_STATES", &
     377              :                           description="Number of valence excited states to be used in the RIXS "// &
     378              :                           "calculation. Restricting this number reduces computational cost, but "// &
     379              :                           "removes spectral features corresponding to higher excitations. Should be "// &
     380              :                           "used with care. -1 means all available valence states will be used.", &
     381         1462 :                           n_var=1, type_of_var=integer_t, default_i_val=-1)
     382         1462 :       CALL section_add_keyword(section, keyword)
     383         1462 :       CALL keyword_release(keyword)
     384              : 
     385         1462 :       CALL create_tddfpt2_section(subsection)
     386         1462 :       CALL section_add_subsection(section, subsection)
     387         1462 :       CALL section_release(subsection)
     388              : 
     389         1462 :       CALL create_xas_tdp_section(subsection)
     390         1462 :       CALL section_add_subsection(section, subsection)
     391         1462 :       CALL section_release(subsection)
     392              : 
     393              :       CALL section_create(subsection, __LOCATION__, "PRINT", "Controls the printing of information "// &
     394         1462 :                           "during RIXS calculations", repeats=.FALSE.)
     395              : 
     396              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="SPECTRUM", &
     397              :                                        description="Controles the printing of the RIXS spectrum "// &
     398              :                                        "in output files", &
     399              :                                        print_level=low_print_level, filename="", &
     400         1462 :                                        common_iter_levels=3)
     401         1462 :       CALL section_add_subsection(subsection, print_key)
     402         1462 :       CALL section_release(print_key)
     403              : 
     404         1462 :       CALL section_add_subsection(section, subsection)
     405         1462 :       CALL section_release(subsection)
     406              : 
     407         1462 :    END SUBROUTINE create_rixs_section
     408              : 
     409              : ! **************************************************************************************************
     410              : !> \brief creates the input structure used to activate
     411              : !>      a linear response calculation
     412              : !>      Available properties : none
     413              : !> \param section the section to create
     414              : !> \param create_subsections indicates whether or not subsections should be created
     415              : !> \param default_set_tdlr default parameters to be used if called from TDDFPT
     416              : !> \author MI
     417              : ! **************************************************************************************************
     418         4386 :    SUBROUTINE create_linres_section(section, create_subsections, default_set_tdlr)
     419              :       TYPE(section_type), POINTER                        :: section
     420              :       LOGICAL, INTENT(in)                                :: create_subsections
     421              :       LOGICAL, INTENT(IN), OPTIONAL                      :: default_set_tdlr
     422              : 
     423              :       INTEGER                                            :: def_max_iter, def_precond
     424              :       REAL(KIND=DP)                                      :: def_egap, def_eps, def_eps_filter
     425              :       TYPE(keyword_type), POINTER                        :: keyword
     426              :       TYPE(section_type), POINTER                        :: print_key, subsection
     427              : 
     428              :       CHARACTER(len=256)                      :: desc
     429              : 
     430         4386 :       NULLIFY (keyword, print_key)
     431              : 
     432         4386 :       IF (PRESENT(default_set_tdlr)) THEN
     433         2924 :          def_egap = 0.02_dp
     434         2924 :          def_eps = 1.0e-10_dp
     435         2924 :          def_eps_filter = 1.0e-15_dp
     436         2924 :          def_max_iter = 100
     437         2924 :          def_precond = ot_precond_full_single_inverse
     438         2924 :          desc = "Controls the parameters of the LINRES force calculations for excited states."
     439              :       ELSE
     440         1462 :          def_egap = 0.2_dp
     441         1462 :          def_eps = 1.e-6_dp
     442         1462 :          def_eps_filter = 0.0_dp
     443         1462 :          def_max_iter = 50
     444         1462 :          def_precond = ot_precond_none
     445         1462 :          desc = "The linear response is used to calculate one of the following properties: nmr, epr, raman, ..."
     446              :       END IF
     447              : 
     448         4386 :       CPASSERT(.NOT. ASSOCIATED(section))
     449              :       CALL section_create(section, __LOCATION__, name="linres", &
     450              :                           description=desc, n_keywords=5, n_subsections=2, repeats=.FALSE., &
     451        13158 :                           citations=[Putrino2000, Hanasaki2025])
     452              : 
     453              :       CALL keyword_create(keyword, __LOCATION__, name="EPS", &
     454              :                           description="target accuracy for the convergence of the conjugate gradient.", &
     455         4386 :                           usage="EPS 1.e-6", default_r_val=def_eps)
     456         4386 :       CALL section_add_keyword(section, keyword)
     457         4386 :       CALL keyword_release(keyword)
     458              : 
     459              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
     460              :                           description="Filter threshold for response density matrix.", &
     461         4386 :                           usage="EPS_FILTER 1.e-8", default_r_val=def_eps_filter)
     462         4386 :       CALL section_add_keyword(section, keyword)
     463         4386 :       CALL keyword_release(keyword)
     464              : 
     465              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
     466              :                           description="Maximum number of conjugate gradient iteration to be performed for one optimization.", &
     467         4386 :                           usage="MAX_ITER 200", default_i_val=def_max_iter)
     468         4386 :       CALL section_add_keyword(section, keyword)
     469         4386 :       CALL keyword_release(keyword)
     470              : 
     471              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_EVERY", &
     472              :                           description="Restart the conjugate gradient after the specified number of iterations.", &
     473         4386 :                           usage="RESTART_EVERY 200", default_i_val=50)
     474         4386 :       CALL section_add_keyword(section, keyword)
     475         4386 :       CALL keyword_release(keyword)
     476              : 
     477              :       CALL keyword_create( &
     478              :          keyword, __LOCATION__, name="PRECONDITIONER", &
     479              :          description="Type of preconditioner to be used with all minimization schemes. "// &
     480              :          "They differ in effectiveness, cost of construction, cost of application. "// &
     481              :          "Properly preconditioned minimization can be orders of magnitude faster than doing nothing.", &
     482              :          usage="PRECONDITIONER FULL_ALL", &
     483              :          default_i_val=def_precond, &
     484              :          enum_c_vals=s2a("FULL_ALL", "FULL_SINGLE_INVERSE", "FULL_SINGLE", "FULL_KINETIC", "FULL_S_INVERSE", &
     485              :                          "NONE"), &
     486              :          enum_desc=s2a("Most effective state selective preconditioner based on diagonalization, "// &
     487              :                        "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
     488              :                        "This preconditioner is recommended for almost all systems, except very large systems where "// &
     489              :                        "make_preconditioner would dominate the total computational cost.", &
     490              :                        "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
     491              :                        "but cheaper to construct, "// &
     492              :                        "might be somewhat less robust. Recommended for large systems.", &
     493              :                        "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
     494              :                        "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
     495              :                        "use for very large systems.", &
     496              :                        "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
     497              :                        "skip preconditioning"), &
     498              :          enum_i_vals=[ot_precond_full_all, ot_precond_full_single_inverse, ot_precond_full_single, &
     499         4386 :                       ot_precond_full_kinetic, ot_precond_s_inverse, ot_precond_none])
     500         4386 :       CALL section_add_keyword(section, keyword)
     501         4386 :       CALL keyword_release(keyword)
     502              : 
     503              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_GAP", &
     504              :                           description="Energy gap estimate [a.u.] for preconditioning", &
     505              :                           usage="ENERGY_GAP 0.1", &
     506         4386 :                           default_r_val=def_egap)
     507         4386 :       CALL section_add_keyword(section, keyword)
     508         4386 :       CALL keyword_release(keyword)
     509              : 
     510              :       CALL keyword_create(keyword, __LOCATION__, name="EVERY_N_STEP", &
     511              :                           description="Perform a linear response calculation every N-th step for MD run", &
     512         4386 :                           usage="EVERY_N_STEP 50", default_i_val=1)
     513         4386 :       CALL section_add_keyword(section, keyword)
     514         4386 :       CALL keyword_release(keyword)
     515              : 
     516              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART", &
     517              :                           description="Restart the response calculation if the restart file exists", &
     518              :                           usage="RESTART", &
     519         4386 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     520         4386 :       CALL section_add_keyword(section, keyword)
     521         4386 :       CALL keyword_release(keyword)
     522              : 
     523              :       CALL keyword_create(keyword, __LOCATION__, name="WFN_RESTART_FILE_NAME", &
     524              :                           variants=["RESTART_FILE_NAME"], &
     525              :                           description="Root of the file names where to read the response functions from "// &
     526              :                           "which to restart the calculation of the linear response", &
     527              :                           usage="WFN_RESTART_FILE_NAME <FILENAME>", &
     528         8772 :                           type_of_var=lchar_t)
     529         4386 :       CALL section_add_keyword(section, keyword)
     530         4386 :       CALL keyword_release(keyword)
     531              : 
     532         4386 :       IF (create_subsections) THEN
     533         1462 :          NULLIFY (subsection)
     534              : 
     535         1462 :          CALL create_localize_section(subsection)
     536         1462 :          CALL section_add_subsection(section, subsection)
     537         1462 :          CALL section_release(subsection)
     538              : 
     539         1462 :          CALL create_current_section(subsection)
     540         1462 :          CALL section_add_subsection(section, subsection)
     541         1462 :          CALL section_release(subsection)
     542              : 
     543         1462 :          CALL create_nmr_section(subsection)
     544         1462 :          CALL section_add_subsection(section, subsection)
     545         1462 :          CALL section_release(subsection)
     546              : 
     547         1462 :          CALL create_spin_spin_section(subsection)
     548         1462 :          CALL section_add_subsection(section, subsection)
     549         1462 :          CALL section_release(subsection)
     550              : 
     551         1462 :          CALL create_epr_section(subsection)
     552         1462 :          CALL section_add_subsection(section, subsection)
     553         1462 :          CALL section_release(subsection)
     554              : 
     555         1462 :          CALL create_polarizability_section(subsection)
     556         1462 :          CALL section_add_subsection(section, subsection)
     557         1462 :          CALL section_release(subsection)
     558              : 
     559         1462 :          CALL create_dcdr_section(subsection)
     560         1462 :          CALL section_add_subsection(section, subsection)
     561         1462 :          CALL section_release(subsection)
     562              : 
     563         1462 :          CALL create_vcd_section(subsection)
     564         1462 :          CALL section_add_subsection(section, subsection)
     565         1462 :          CALL section_release(subsection)
     566              : 
     567              :          CALL section_create(subsection, __LOCATION__, name="PRINT", &
     568              :                              description="printing of information during the linear response calculation", &
     569         1462 :                              repeats=.FALSE.)
     570              : 
     571              :          CALL cp_print_key_section_create( &
     572              :             print_key, __LOCATION__, "program_run_info", &
     573              :             description="Controls the printing of basic iteration information during the LINRES calculation", &
     574         1462 :             print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     575         1462 :          CALL section_add_subsection(subsection, print_key)
     576         1462 :          CALL section_release(print_key)
     577              : 
     578              :          CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
     579              :                                           description="Controls the dumping of restart file of the response wavefunction. "// &
     580              :                                           "For each set of response functions, i.e. for each perturbation, "// &
     581              :                                           "one different restart file is dumped. These restart files should be "// &
     582              :                                           "employed only to restart the same type of LINRES calculation, "// &
     583              :                                           "i.e. with the same perturbation.", &
     584              :                                           print_level=low_print_level, common_iter_levels=3, each_iter_names=s2a("ITER"), &
     585         1462 :                                           add_last=add_last_numeric, each_iter_values=[3], filename="")
     586         1462 :          CALL section_add_subsection(subsection, print_key)
     587         1462 :          CALL section_release(print_key)
     588              : 
     589         1462 :          CALL section_add_subsection(section, subsection)
     590         1462 :          CALL section_release(subsection)
     591              : 
     592              :       END IF
     593              : 
     594         4386 :    END SUBROUTINE create_linres_section
     595              : 
     596              : ! **************************************************************************************************
     597              : !> \brief creates the input structure used to activate
     598              : !>      calculation of position perturbation  DFPT
     599              : !> \param section ...
     600              : !> \author Sandra Luber, Edward Ditler
     601              : ! **************************************************************************************************
     602         1462 :    SUBROUTINE create_dcdr_section(section)
     603              : 
     604              :       TYPE(section_type), POINTER                        :: section
     605              : 
     606              :       LOGICAL                                            :: failure
     607              :       TYPE(keyword_type), POINTER                        :: keyword
     608              :       TYPE(section_type), POINTER                        :: print_key, subsection
     609              : 
     610         1462 :       failure = .FALSE.
     611         1462 :       NULLIFY (keyword, print_key, subsection)
     612              : 
     613         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
     614              : 
     615              :       IF (.NOT. failure) THEN
     616              :          CALL section_create(section, __LOCATION__, name="DCDR", &
     617              :                              description="Compute analytical gradients the dipole moments.", &
     618         2924 :                              n_keywords=50, n_subsections=1, repeats=.FALSE., citations=[Ditler2021])
     619              : 
     620              :          CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     621              :                              description="Controls the activation of the APT calculation. "// &
     622              :                              "Analytical derivatives are not available for functionals that depend on "// &
     623              :                              "the kinetic energy density; use APT_FD for these functionals.", &
     624              :                              usage="&DCDR T", &
     625              :                              default_l_val=.FALSE., &
     626         1462 :                              lone_keyword_l_val=.TRUE.)
     627         1462 :          CALL section_add_keyword(section, keyword)
     628         1462 :          CALL keyword_release(keyword)
     629              : 
     630              :          CALL keyword_create(keyword, __LOCATION__, name="LIST_OF_ATOMS", &
     631              :                              description="Specifies a list of atoms.", &
     632              :                              usage="LIST_OF_ATOMS {integer} {integer} .. {integer}", repeats=.TRUE., &
     633         1462 :                              n_var=-1, type_of_var=integer_t)
     634         1462 :          CALL section_add_keyword(section, keyword)
     635         1462 :          CALL keyword_release(keyword)
     636              : 
     637              :          CALL keyword_create(keyword, __LOCATION__, name="DISTRIBUTED_ORIGIN", &
     638              :                              variants=["DO_GAUGE"], &
     639              :                              description="Use the distributed origin (DO) gauge?", &
     640              :                              usage="DISTRIBUTED_ORIGIN T", &
     641         2924 :                              default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     642         1462 :          CALL section_add_keyword(section, keyword)
     643         1462 :          CALL keyword_release(keyword)
     644              : 
     645              :          CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_CENTER", &
     646              :                              description="The orbital center.", &
     647              :                              usage="ORBITAL_CENTER WANNIER", &
     648              :                              default_i_val=current_orb_center_wannier, &
     649              :                              enum_c_vals=s2a("WANNIER", "COMMON", "ATOM", "BOX"), &
     650              :                              enum_desc=s2a("Use the Wannier centers.", &
     651              :                                            "Use a common center (works only for an isolate molecule).", &
     652              :                                            "Use the atoms as center.", &
     653              :                                            "Boxing."), &
     654              :                              enum_i_vals=[current_orb_center_wannier, current_orb_center_common, &
     655         1462 :                                           current_orb_center_atom, current_orb_center_box])
     656         1462 :          CALL section_add_keyword(section, keyword)
     657         1462 :          CALL keyword_release(keyword)
     658              : 
     659              :          CALL keyword_create(keyword, __LOCATION__, name="REFERENCE", &
     660              :                              description="Gauge origin of the velocity gauge factor.", &
     661              :                              enum_c_vals=s2a("COM", "COAC", "USER_DEFINED", "ZERO"), &
     662              :                              enum_desc=s2a("Use Center of Mass", &
     663              :                                            "Use Center of Atomic Charges", &
     664              :                                            "Use User-defined Point", &
     665              :                                            "Use Origin of Coordinate System"), &
     666              :                              enum_i_vals=[use_mom_ref_com, &
     667              :                                           use_mom_ref_coac, &
     668              :                                           use_mom_ref_user, &
     669              :                                           use_mom_ref_zero], &
     670         1462 :                              default_i_val=use_mom_ref_zero)
     671         1462 :          CALL section_add_keyword(section, keyword)
     672         1462 :          CALL keyword_release(keyword)
     673              : 
     674              :          CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_POINT", &
     675              :                              description="User-defined reference point of the velocity gauge factor.", &
     676              :                              usage="REFERENCE_POINT x y z", &
     677         1462 :                              repeats=.FALSE., n_var=3, type_of_var=real_t, unit_str='bohr')
     678         1462 :          CALL section_add_keyword(section, keyword)
     679         1462 :          CALL keyword_release(keyword)
     680              : 
     681              :          CALL keyword_create(keyword, __LOCATION__, name="Z_MATRIX_METHOD", &
     682              :                              description="Use Z_matrix method to solve the response equation", &
     683              :                              usage="Z_MATRIX_METHOD T", &
     684         1462 :                              default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     685         1462 :          CALL section_add_keyword(section, keyword)
     686         1462 :          CALL keyword_release(keyword)
     687              : 
     688              :          CALL keyword_create(keyword, __LOCATION__, name="APT_FD", &
     689              :                              description="Use numerical differentiation to compute the APT, "// &
     690              :                              "switches off the calculation of dcdr analytical derivatives. "// &
     691              :                              "Requires RUN_TYPE = ENERGY_FORCE or MD.", &
     692              :                              usage="APT_FD T", &
     693         1462 :                              default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     694         1462 :          CALL section_add_keyword(section, keyword)
     695         1462 :          CALL keyword_release(keyword)
     696              : 
     697              :          CALL keyword_create(keyword, __LOCATION__, name="APT_FD_DE", &
     698              :                              description="Electric field strength (atomic units) to use for finite differences", &
     699              :                              repeats=.FALSE., &
     700              :                              n_var=1, &
     701              :                              type_of_var=real_t, &
     702              :                              default_r_val=0.0003_dp, &
     703         1462 :                              usage="APT_FD_DE 1.0E-4")
     704         1462 :          CALL section_add_keyword(section, keyword)
     705         1462 :          CALL keyword_release(keyword)
     706              : 
     707              :          CALL keyword_create(keyword, __LOCATION__, name="APT_FD_METHOD", &
     708              :                              description="Numerical differentiation method", &
     709              :                              usage="APT_FD_METHOD FD", &
     710              :                              default_i_val=1, &
     711              :                              !enum_c_vals=s2a("FD", "2PNT"), &
     712              :                              enum_c_vals=s2a("2PNT"), &
     713              :                              !enum_desc=s2a("Forward differences.", &
     714              :                              !              "Symmetric two-point differences."), &
     715              :                              enum_desc=s2a("Symmetric two-point differences."), &
     716              :                              !enum_i_vals=(/0, 1/))
     717         1462 :                              enum_i_vals=[1])
     718         1462 :          CALL section_add_keyword(section, keyword)
     719         1462 :          CALL keyword_release(keyword)
     720              : 
     721         1462 :          NULLIFY (subsection)
     722              :          CALL section_create(subsection, __LOCATION__, name="PRINT", &
     723              :                              description="print results of the magnetic dipole moment calculation", &
     724         1462 :                              repeats=.FALSE.)
     725              : 
     726              :          CALL cp_print_key_section_create(print_key, __LOCATION__, "APT", &
     727              :                                           description="Controls the printing of the electric dipole gradient", &
     728         1462 :                                           print_level=low_print_level, add_last=add_last_numeric, filename="")
     729         1462 :          CALL section_add_subsection(subsection, print_key)
     730         1462 :          CALL section_release(print_key)
     731              : 
     732         1462 :          CALL section_add_subsection(section, subsection)
     733         1462 :          CALL section_release(subsection)
     734              : 
     735         1462 :          NULLIFY (subsection)
     736         1462 :          CALL create_interp_section(subsection)
     737         1462 :          CALL section_add_subsection(section, subsection)
     738         1462 :          CALL section_release(subsection)
     739              : 
     740              :       END IF
     741              : 
     742         1462 :    END SUBROUTINE create_dcdr_section
     743              : 
     744              : ! **************************************************************************************************
     745              : !> \brief creates the input structure used to activate
     746              : !>      calculation of VCD spectra using DFPT
     747              : !> \param section ...
     748              : !> \author Sandra Luber, Tomas Zimmermann, Edward Ditler
     749              : ! **************************************************************************************************
     750         1462 :    SUBROUTINE create_vcd_section(section)
     751              : 
     752              :       TYPE(section_type), POINTER                        :: section
     753              : 
     754              :       TYPE(keyword_type), POINTER                        :: keyword
     755              :       TYPE(section_type), POINTER                        :: print_key, subsection
     756              : 
     757         1462 :       NULLIFY (keyword, print_key, subsection)
     758              : 
     759         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
     760              : 
     761              :       CALL section_create(section, __LOCATION__, name="VCD", &
     762              :                           description="Carry out a VCD calculation.", &
     763              :                           n_keywords=50, n_subsections=1, repeats=.FALSE., &
     764         2924 :                           citations=[Ditler2022])
     765              : 
     766              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     767              :                           description="controls the activation of the APT/AAT calculation", &
     768              :                           usage="&VCD T", &
     769              :                           default_l_val=.FALSE., &
     770         1462 :                           lone_keyword_l_val=.TRUE.)
     771         1462 :       CALL section_add_keyword(section, keyword)
     772         1462 :       CALL keyword_release(keyword)
     773              : 
     774              :       CALL keyword_create(keyword, __LOCATION__, name="LIST_OF_ATOMS", &
     775              :                           description="Specifies a list of atoms.", &
     776              :                           usage="LIST_OF_ATOMS {integer} {integer} .. {integer}", repeats=.TRUE., &
     777         1462 :                           n_var=-1, type_of_var=integer_t)
     778         1462 :       CALL section_add_keyword(section, keyword)
     779         1462 :       CALL keyword_release(keyword)
     780              : 
     781              :       CALL keyword_create(keyword, __LOCATION__, name="DISTRIBUTED_ORIGIN", &
     782              :                           variants=["DO_GAUGE"], &
     783              :                           description="Use the distributed origin (DO) gauge?", &
     784              :                           usage="DISTRIBUTED_ORIGIN T", &
     785         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     786         1462 :       CALL section_add_keyword(section, keyword)
     787         1462 :       CALL keyword_release(keyword)
     788              : 
     789              :       CALL keyword_create(keyword, __LOCATION__, name="ORIGIN_DEPENDENT_MFP", &
     790              :                           description="Use the origin dependent MFP operator.", &
     791              :                           usage="ORIGIN_DEPENDENT_MFP T", &
     792         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     793         1462 :       CALL section_add_keyword(section, keyword)
     794         1462 :       CALL keyword_release(keyword)
     795              : 
     796              :       CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_CENTER", &
     797              :                           description="The orbital center.", &
     798              :                           usage="ORBITAL_CENTER WANNIER", &
     799              :                           default_i_val=current_orb_center_wannier, &
     800              :                           enum_c_vals=s2a("WANNIER", "COMMON", "ATOM", "BOX"), &
     801              :                           enum_desc=s2a("Use the Wannier centers.", &
     802              :                                         "Use a common center (works only for an isolate molecule).", &
     803              :                                         "Use the atoms as center.", &
     804              :                                         "Boxing."), &
     805              :                           enum_i_vals=[current_orb_center_wannier, current_orb_center_common, &
     806         1462 :                                        current_orb_center_atom, current_orb_center_box])
     807         1462 :       CALL section_add_keyword(section, keyword)
     808         1462 :       CALL keyword_release(keyword)
     809              : 
     810              :       ! The origin of the magnetic dipole operator (r - MAGNETIC_ORIGIN) x momentum
     811              :       CALL keyword_create(keyword, __LOCATION__, name="MAGNETIC_ORIGIN", &
     812              :                           description="Gauge origin of the magnetic dipole operator.", &
     813              :                           enum_c_vals=s2a("COM", "COAC", "USER_DEFINED", "ZERO"), &
     814              :                           enum_desc=s2a("Use Center of Mass", &
     815              :                                         "Use Center of Atomic Charges", &
     816              :                                         "Use User-defined Point", &
     817              :                                         "Use Origin of Coordinate System"), &
     818              :                           enum_i_vals=[use_mom_ref_com, &
     819              :                                        use_mom_ref_coac, &
     820              :                                        use_mom_ref_user, &
     821              :                                        use_mom_ref_zero], &
     822         1462 :                           default_i_val=use_mom_ref_zero)
     823         1462 :       CALL section_add_keyword(section, keyword)
     824         1462 :       CALL keyword_release(keyword)
     825              : 
     826              :       CALL keyword_create(keyword, __LOCATION__, name="MAGNETIC_ORIGIN_REFERENCE", &
     827              :                           description="User-defined reference point of the magnetic dipole operator.", &
     828              :                           usage="MAGNETIC_ORIGIN_REFERENCE x y z", &
     829         1462 :                           repeats=.FALSE., n_var=3, type_of_var=real_t, unit_str='bohr')
     830         1462 :       CALL section_add_keyword(section, keyword)
     831         1462 :       CALL keyword_release(keyword)
     832              : 
     833              :       ! The origin of the coordinate system
     834              :       CALL keyword_create(keyword, __LOCATION__, name="SPATIAL_ORIGIN", &
     835              :                           description="Gauge origin of the velocity gauge factor/spatial origin.", &
     836              :                           enum_c_vals=s2a("COM", "COAC", "USER_DEFINED", "ZERO"), &
     837              :                           enum_desc=s2a("Use Center of Mass", &
     838              :                                         "Use Center of Atomic Charges", &
     839              :                                         "Use User-defined Point", &
     840              :                                         "Use Origin of Coordinate System"), &
     841              :                           enum_i_vals=[use_mom_ref_com, &
     842              :                                        use_mom_ref_coac, &
     843              :                                        use_mom_ref_user, &
     844              :                                        use_mom_ref_zero], &
     845         1462 :                           default_i_val=use_mom_ref_zero)
     846         1462 :       CALL section_add_keyword(section, keyword)
     847         1462 :       CALL keyword_release(keyword)
     848              : 
     849              :       CALL keyword_create(keyword, __LOCATION__, name="SPATIAL_ORIGIN_REFERENCE", &
     850              :                           description="User-defined reference point of the velocity gauge factor/spatial origin.", &
     851              :                           usage="SPATIAL_ORIGIN_REFERENCE x y z", &
     852         1462 :                           repeats=.FALSE., n_var=3, type_of_var=real_t, unit_str='bohr')
     853         1462 :       CALL section_add_keyword(section, keyword)
     854         1462 :       CALL keyword_release(keyword)
     855              : 
     856         1462 :       NULLIFY (subsection)
     857              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
     858              :                           description="print results of the magnetic dipole moment calculation", &
     859         1462 :                           repeats=.FALSE.)
     860              : 
     861              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "VCD", &
     862              :                                        description="Controls the printing of the APTs and AATs", &
     863         1462 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="")
     864         1462 :       CALL section_add_subsection(subsection, print_key)
     865         1462 :       CALL section_release(print_key)
     866              : 
     867         1462 :       CALL section_add_subsection(section, subsection)
     868         1462 :       CALL section_release(subsection)
     869              : 
     870         1462 :       NULLIFY (subsection)
     871         1462 :       CALL create_interp_section(subsection)
     872         1462 :       CALL section_add_subsection(section, subsection)
     873         1462 :       CALL section_release(subsection)
     874              : 
     875         1462 :    END SUBROUTINE create_vcd_section
     876              : 
     877              : ! **************************************************************************************************
     878              : !> \brief creates the input structure used to activate
     879              : !>      calculation of induced current  DFPT
     880              : !>      Available properties : none
     881              : !> \param section the section to create
     882              : !> \author  MI/VW
     883              : ! **************************************************************************************************
     884         1462 :    SUBROUTINE create_current_section(section)
     885              :       TYPE(section_type), POINTER                        :: section
     886              : 
     887              :       TYPE(keyword_type), POINTER                        :: keyword
     888              :       TYPE(section_type), POINTER                        :: print_key, subsection
     889              : 
     890         1462 :       NULLIFY (keyword, print_key, subsection)
     891              : 
     892         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
     893              :       CALL section_create(section, __LOCATION__, name="current", &
     894              :                           description="The induced current density is calculated by DFPT.", &
     895              :                           n_keywords=4, n_subsections=1, repeats=.FALSE., &
     896         4386 :                           citations=[Sebastiani2001, Weber2009])
     897              : 
     898              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     899              :                           description="controls the activation of the induced current calculation", &
     900              :                           usage="&CURRENT T", &
     901              :                           default_l_val=.FALSE., &
     902         1462 :                           lone_keyword_l_val=.TRUE.)
     903         1462 :       CALL section_add_keyword(section, keyword)
     904         1462 :       CALL keyword_release(keyword)
     905              : 
     906              :       CALL keyword_create(keyword, __LOCATION__, name="GAUGE", &
     907              :                           description="The gauge used to compute the induced current within GAPW.", &
     908              :                           usage="GAUGE R", &
     909              :                           default_i_val=current_gauge_r_and_step_func, &
     910              :                           enum_c_vals=s2a("R", "R_AND_STEP_FUNCTION", "ATOM"), &
     911              :                           enum_desc=s2a("Position gauge (doesnt work well).", &
     912              :                                         "Position and step function for the soft and the local parts, respectively.", &
     913              :                                         "Atoms."), &
     914         1462 :                           enum_i_vals=[current_gauge_r, current_gauge_r_and_step_func, current_gauge_atom])
     915         1462 :       CALL section_add_keyword(section, keyword)
     916         1462 :       CALL keyword_release(keyword)
     917              : 
     918              :       CALL keyword_create(keyword, __LOCATION__, name="GAUGE_ATOM_RADIUS", &
     919              :                           description="Build the gauge=atom using only the atoms within this radius.", &
     920              :                           usage="GAUGE_ATOM_RADIUS 10.0", &
     921              :                           type_of_var=real_t, &
     922              :                           default_r_val=cp_unit_to_cp2k(value=4.0_dp, unit_str="angstrom"), &
     923         1462 :                           unit_str="angstrom")
     924         1462 :       CALL section_add_keyword(section, keyword)
     925         1462 :       CALL keyword_release(keyword)
     926              : 
     927              :       CALL keyword_create(keyword, __LOCATION__, name="USE_OLD_GAUGE_ATOM", &
     928              :                           description="Use the old way to compute the gauge.", &
     929              :                           usage="USE_OLD_GAUGE_ATOM T", &
     930         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     931         1462 :       CALL section_add_keyword(section, keyword)
     932         1462 :       CALL keyword_release(keyword)
     933              : 
     934              :       CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_CENTER", &
     935              :                           description="The orbital center.", &
     936              :                           usage="ORBITAL_CENTER WANNIER", &
     937              :                           default_i_val=current_orb_center_wannier, &
     938              :                           enum_c_vals=s2a("WANNIER", "COMMON", "ATOM", "BOX"), &
     939              :                           enum_desc=s2a("Use the Wannier centers.", &
     940              :                                         "Use a common center (works only for an isolate molecule).", &
     941              :                                         "Use the atoms as center.", &
     942              :                                         "Boxing."), &
     943              :                           enum_i_vals=[current_orb_center_wannier, current_orb_center_common, &
     944         1462 :                                        current_orb_center_atom, current_orb_center_box])
     945         1462 :       CALL section_add_keyword(section, keyword)
     946         1462 :       CALL keyword_release(keyword)
     947              : 
     948              :       CALL keyword_create(keyword, __LOCATION__, name="COMMON_CENTER", &
     949              :                           description="The common center ", usage="COMMON_CENTER 0.0 1.0 0.0", &
     950              :                           n_var=3, default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp], type_of_var=real_t, &
     951         1462 :                           unit_str="angstrom")
     952         1462 :       CALL section_add_keyword(section, keyword)
     953         1462 :       CALL keyword_release(keyword)
     954              : 
     955              :       CALL keyword_create(keyword, __LOCATION__, name="NBOX", &
     956              :                           description="How many boxes along each directions ", usage="NBOX 6 6 5", &
     957         1462 :                           n_var=3, default_i_vals=[4, 4, 4], type_of_var=integer_t)
     958         1462 :       CALL section_add_keyword(section, keyword)
     959         1462 :       CALL keyword_release(keyword)
     960              : 
     961              :       CALL keyword_create(keyword, __LOCATION__, name="CHI_PBC", &
     962              :                           description="Calculate the succeptibility correction to the shift with PBC", &
     963              :                           usage="CHI_PBC T", &
     964         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     965         1462 :       CALL section_add_keyword(section, keyword)
     966         1462 :       CALL keyword_release(keyword)
     967              : 
     968              :       CALL keyword_create(keyword, __LOCATION__, name="FORCE_NO_FULL", &
     969              :                           description="Avoid the calculation of the state dependent perturbation term, "// &
     970              :                           "even if the orbital centers are set at Wannier centers or at Atom centers", &
     971              :                           usage="FORCE_NO_FULL T", &
     972         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     973         1462 :       CALL section_add_keyword(section, keyword)
     974         1462 :       CALL keyword_release(keyword)
     975              : 
     976              :       CALL keyword_create(keyword, __LOCATION__, name="SELECTED_STATES_ON_ATOM_LIST", &
     977              :                           description="Indexes of the atoms for selecting"// &
     978              :                           " the states to be used for the response calculations.", &
     979              :                           usage="SELECTED_STATES_ON_ATOM_LIST 1 2 10", &
     980         1462 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     981         1462 :       CALL section_add_keyword(section, keyword)
     982         1462 :       CALL keyword_release(keyword)
     983              : 
     984              :       CALL keyword_create(keyword, __LOCATION__, name="SELECTED_STATES_ATOM_RADIUS", &
     985              :                           description="Select all the states included in the given radius around each atoms "// &
     986              :                           "in SELECTED_STATES_ON_ATOM_LIST.", &
     987              :                           usage="SELECTED_STATES_ATOM_RADIUS 2.0", &
     988              :                           type_of_var=real_t, &
     989              :                           default_r_val=cp_unit_to_cp2k(value=4.0_dp, unit_str="angstrom"), &
     990         1462 :                           unit_str="angstrom")
     991         1462 :       CALL section_add_keyword(section, keyword)
     992         1462 :       CALL keyword_release(keyword)
     993              : 
     994              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_CURRENT", &
     995              :                           description="Restart the induced current density calculation"// &
     996              :                           " from a previous run (not working yet).", &
     997              :                           usage="RESTART_CURRENT", default_l_val=.FALSE., &
     998         1462 :                           lone_keyword_l_val=.TRUE.)
     999         1462 :       CALL section_add_keyword(section, keyword)
    1000         1462 :       CALL keyword_release(keyword)
    1001              : 
    1002         1462 :       NULLIFY (subsection)
    1003              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    1004              :                           description="print results of induced current density calculation", &
    1005         1462 :                           repeats=.FALSE.)
    1006              : 
    1007              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CURRENT_CUBES", &
    1008              :                                        description="Controls the printing of the induced current density (not working yet).", &
    1009         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1010              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
    1011              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1012              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1013              :                           " 1 number valid for all components (not working yet).", &
    1014         1462 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1015         1462 :       CALL section_add_keyword(print_key, keyword)
    1016         1462 :       CALL keyword_release(keyword)
    1017              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1018              :                           description="append the cube files when they already exist", &
    1019         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1020         1462 :       CALL section_add_keyword(print_key, keyword)
    1021         1462 :       CALL keyword_release(keyword)
    1022              : 
    1023         1462 :       CALL section_add_subsection(subsection, print_key)
    1024         1462 :       CALL section_release(print_key)
    1025              : 
    1026              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESPONSE_FUNCTION_CUBES", &
    1027              :                                        description="Controls the printing of the response functions (not working yet).", &
    1028         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1029              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
    1030              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1031              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1032              :                           " 1 number valid for all components (not working yet).", &
    1033         1462 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1034         1462 :       CALL section_add_keyword(print_key, keyword)
    1035         1462 :       CALL keyword_release(keyword)
    1036              : 
    1037              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LU_BOUNDS", &
    1038              :                           variants=["CUBES_LU"], &
    1039              :                           description="The lower and upper index of the states to be printed as cube (not working yet).", &
    1040              :                           usage="CUBES_LU_BOUNDS integer integer", &
    1041         2924 :                           n_var=2, default_i_vals=[0, -2], type_of_var=integer_t)
    1042         1462 :       CALL section_add_keyword(print_key, keyword)
    1043         1462 :       CALL keyword_release(keyword)
    1044              : 
    1045              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LIST", &
    1046              :                           description="Indexes of the states to be printed as cube files "// &
    1047              :                           "This keyword can be repeated several times "// &
    1048              :                           "(useful if you have to specify many indexes) (not working yet).", &
    1049              :                           usage="CUBES_LIST 1 2", &
    1050         1462 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
    1051         1462 :       CALL section_add_keyword(print_key, keyword)
    1052         1462 :       CALL keyword_release(keyword)
    1053              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1054              :                           description="append the cube files when they already exist", &
    1055         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1056         1462 :       CALL section_add_keyword(print_key, keyword)
    1057         1462 :       CALL keyword_release(keyword)
    1058              : 
    1059         1462 :       CALL section_add_subsection(subsection, print_key)
    1060         1462 :       CALL section_release(print_key)
    1061              : 
    1062         1462 :       CALL section_add_subsection(section, subsection)
    1063         1462 :       CALL section_release(subsection)
    1064              : 
    1065         1462 :       NULLIFY (subsection)
    1066         1462 :       CALL create_interp_section(subsection)
    1067         1462 :       CALL section_add_subsection(section, subsection)
    1068         1462 :       CALL section_release(subsection)
    1069              : 
    1070         1462 :    END SUBROUTINE create_current_section
    1071              : 
    1072              : ! **************************************************************************************************
    1073              : !> \brief creates the input structure used to activate
    1074              : !>         calculation of NMR chemical shift using
    1075              : !>         the induced current obtained from DFPT
    1076              : !>      Available properties : none
    1077              : !> \param section the section to create
    1078              : !> \author  MI/VW
    1079              : ! **************************************************************************************************
    1080         1462 :    SUBROUTINE create_nmr_section(section)
    1081              :       TYPE(section_type), POINTER                        :: section
    1082              : 
    1083              :       TYPE(keyword_type), POINTER                        :: keyword
    1084              :       TYPE(section_type), POINTER                        :: print_key, subsection
    1085              : 
    1086         1462 :       NULLIFY (keyword, print_key, subsection)
    1087              : 
    1088         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    1089              :       CALL section_create(section, __LOCATION__, name="nmr", &
    1090              :                           description="The chemical shift is calculated by DFPT.", &
    1091              :                           n_keywords=5, n_subsections=1, repeats=.FALSE., &
    1092         2924 :                           citations=[Weber2009])
    1093              : 
    1094              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1095              :                           description="controls the activation of the nmr calculation", &
    1096              :                           usage="&NMR T", &
    1097              :                           default_l_val=.FALSE., &
    1098         1462 :                           lone_keyword_l_val=.TRUE.)
    1099         1462 :       CALL section_add_keyword(section, keyword)
    1100         1462 :       CALL keyword_release(keyword)
    1101              : 
    1102              :       CALL keyword_create(keyword, __LOCATION__, name="INTERPOLATE_SHIFT", &
    1103              :                           description="Calculate the soft part of the chemical shift by interpolation ", &
    1104              :                           usage="INTERPOLATE_SHIFT T", &
    1105         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1106         1462 :       CALL section_add_keyword(section, keyword)
    1107         1462 :       CALL keyword_release(keyword)
    1108              : 
    1109              :       CALL keyword_create(keyword, __LOCATION__, name="NICS", &
    1110              :                           description="Calculate the chemical shift in a set of points"// &
    1111              :                           " given from an external file", usage="NICS", &
    1112         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1113         1462 :       CALL section_add_keyword(section, keyword)
    1114         1462 :       CALL keyword_release(keyword)
    1115              : 
    1116              :       CALL keyword_create(keyword, __LOCATION__, name="NICS_FILE_NAME", &
    1117              :                           description="Name of the file with the NICS points coordinates", &
    1118              :                           usage="NICS_FILE_NAME nics_file", &
    1119         1462 :                           default_lc_val="nics_file")
    1120         1462 :       CALL section_add_keyword(section, keyword)
    1121         1462 :       CALL keyword_release(keyword)
    1122              : 
    1123              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_NMR", &
    1124              :                           description="Restart the NMR calculation from a previous run (NOT WORKING YET)", &
    1125              :                           usage="RESTART_NMR", default_l_val=.FALSE., &
    1126         1462 :                           lone_keyword_l_val=.TRUE.)
    1127         1462 :       CALL section_add_keyword(section, keyword)
    1128         1462 :       CALL keyword_release(keyword)
    1129              : 
    1130              :       CALL keyword_create(keyword, __LOCATION__, name="SHIFT_GAPW_RADIUS", &
    1131              :                           description="While computing the local part of the shift (GAPW), "// &
    1132              :                           "the integration is restricted to nuclei that are within this radius.", &
    1133              :                           usage="SHIFT_GAPW_RADIUS 20.0", &
    1134              :                           type_of_var=real_t, &
    1135              :                           default_r_val=cp_unit_to_cp2k(value=60.0_dp, unit_str="angstrom"), &
    1136         1462 :                           unit_str="angstrom")
    1137         1462 :       CALL section_add_keyword(section, keyword)
    1138         1462 :       CALL keyword_release(keyword)
    1139              : 
    1140         1462 :       NULLIFY (subsection)
    1141              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    1142              :                           description="print results of nmr calculation", &
    1143         1462 :                           repeats=.FALSE.)
    1144              : 
    1145              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESPONSE_FUNCTION_CUBES", &
    1146              :                                        description="Controls the printing of the response functions ", &
    1147         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1148              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
    1149              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1150              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1151              :                           " 1 number valid for all components.", &
    1152         1462 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1153         1462 :       CALL section_add_keyword(print_key, keyword)
    1154         1462 :       CALL keyword_release(keyword)
    1155              : 
    1156              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LU_BOUNDS", &
    1157              :                           variants=["CUBES_LU"], &
    1158              :                           description="The lower and upper index of the states to be printed as cube", &
    1159              :                           usage="CUBES_LU_BOUNDS integer integer", &
    1160         2924 :                           n_var=2, default_i_vals=[0, -2], type_of_var=integer_t)
    1161         1462 :       CALL section_add_keyword(print_key, keyword)
    1162         1462 :       CALL keyword_release(keyword)
    1163              : 
    1164              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LIST", &
    1165              :                           description="Indexes of the states to be printed as cube files "// &
    1166              :                           "This keyword can be repeated several times "// &
    1167              :                           "(useful if you have to specify many indexes).", &
    1168              :                           usage="CUBES_LIST 1 2", &
    1169         1462 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
    1170         1462 :       CALL section_add_keyword(print_key, keyword)
    1171         1462 :       CALL keyword_release(keyword)
    1172              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1173              :                           description="append the cube files when they already exist", &
    1174         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1175         1462 :       CALL section_add_keyword(print_key, keyword)
    1176         1462 :       CALL keyword_release(keyword)
    1177              : 
    1178         1462 :       CALL section_add_subsection(subsection, print_key)
    1179         1462 :       CALL section_release(print_key)
    1180              : 
    1181              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CHI_TENSOR", &
    1182              :                                        description="Controls the printing of susceptibility", &
    1183         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1184         1462 :       CALL section_add_subsection(subsection, print_key)
    1185         1462 :       CALL section_release(print_key)
    1186              : 
    1187              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "SHIELDING_TENSOR", &
    1188              :                                        description="Controls the printing of the chemical shift", &
    1189         1462 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="")
    1190              : 
    1191              :       CALL keyword_create(keyword, __LOCATION__, name="ATOMS_LU_BOUNDS", &
    1192              :                           variants=["ATOMS_LU"], &
    1193              :                           description="The lower and upper atomic index for which the tensor is printed", &
    1194              :                           usage="ATOMS_LU_BOUNDS integer integer", &
    1195         2924 :                           n_var=2, default_i_vals=[0, -2], type_of_var=integer_t)
    1196         1462 :       CALL section_add_keyword(print_key, keyword)
    1197         1462 :       CALL keyword_release(keyword)
    1198              : 
    1199              :       CALL keyword_create(keyword, __LOCATION__, name="ATOMS_LIST", &
    1200              :                           description="list of atoms for which the shift is printed into a file ", &
    1201              :                           usage="ATOMS_LIST 1 2", n_var=-1, &
    1202         1462 :                           type_of_var=integer_t, repeats=.TRUE.)
    1203         1462 :       CALL section_add_keyword(print_key, keyword)
    1204         1462 :       CALL keyword_release(keyword)
    1205              : 
    1206         1462 :       CALL section_add_subsection(subsection, print_key)
    1207         1462 :       CALL section_release(print_key)
    1208              : 
    1209         1462 :       CALL section_add_subsection(section, subsection)
    1210         1462 :       CALL section_release(subsection)
    1211              : 
    1212         1462 :       NULLIFY (subsection)
    1213         1462 :       CALL create_interp_section(subsection)
    1214         1462 :       CALL section_add_subsection(section, subsection)
    1215         1462 :       CALL section_release(subsection)
    1216              : 
    1217         1462 :    END SUBROUTINE create_nmr_section
    1218              : 
    1219              : ! **************************************************************************************************
    1220              : !> \brief creates the input structure used to activate
    1221              : !>      calculation of NMR spin-spin coupling (implementation not operating)
    1222              : !>      Available properties : none
    1223              : !> \param section the section to create
    1224              : !> \author  VW
    1225              : ! **************************************************************************************************
    1226         1462 :    SUBROUTINE create_spin_spin_section(section)
    1227              :       TYPE(section_type), POINTER                        :: section
    1228              : 
    1229              :       TYPE(keyword_type), POINTER                        :: keyword
    1230              :       TYPE(section_type), POINTER                        :: print_key, subsection
    1231              : 
    1232         1462 :       NULLIFY (keyword, print_key, subsection)
    1233              : 
    1234         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    1235              :       CALL section_create(section, __LOCATION__, name="spinspin", &
    1236              :                           description="Compute indirect spin-spin coupling constants.", &
    1237         1462 :                           n_keywords=5, n_subsections=1, repeats=.FALSE.)
    1238              : 
    1239              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1240              :                           description="controls the activation of the nmr calculation", &
    1241              :                           usage="&SPINSPIN T", &
    1242              :                           default_l_val=.FALSE., &
    1243         1462 :                           lone_keyword_l_val=.TRUE.)
    1244         1462 :       CALL section_add_keyword(section, keyword)
    1245         1462 :       CALL keyword_release(keyword)
    1246              : 
    1247              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_SPINSPIN", &
    1248              :                           description="Restart the spin-spin calculation from a previous run (NOT WORKING YET)", &
    1249              :                           usage="RESTART_SPINSPIN", default_l_val=.FALSE., &
    1250         1462 :                           lone_keyword_l_val=.TRUE.)
    1251         1462 :       CALL section_add_keyword(section, keyword)
    1252         1462 :       CALL keyword_release(keyword)
    1253              : 
    1254              :       CALL keyword_create(keyword, __LOCATION__, name="ISSC_ON_ATOM_LIST", &
    1255              :                           description="Atoms for which the issc is computed.", &
    1256              :                           usage="ISSC_ON_ATOM_LIST 1 2 10", &
    1257         1462 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
    1258         1462 :       CALL section_add_keyword(section, keyword)
    1259         1462 :       CALL keyword_release(keyword)
    1260              : 
    1261              :       CALL keyword_create(keyword, __LOCATION__, name="DO_FC", &
    1262              :                           description="Compute the Fermi contact contribution", &
    1263              :                           usage="DO_FC F", &
    1264         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1265         1462 :       CALL section_add_keyword(section, keyword)
    1266         1462 :       CALL keyword_release(keyword)
    1267              : 
    1268              :       CALL keyword_create(keyword, __LOCATION__, name="DO_SD", &
    1269              :                           description="Compute the spin-dipolar contribution", &
    1270              :                           usage="DO_SD F", &
    1271         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1272         1462 :       CALL section_add_keyword(section, keyword)
    1273         1462 :       CALL keyword_release(keyword)
    1274              : 
    1275              :       CALL keyword_create(keyword, __LOCATION__, name="DO_PSO", &
    1276              :                           description="Compute the paramagnetic spin-orbit contribution", &
    1277              :                           usage="DO_PSO F", &
    1278         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1279         1462 :       CALL section_add_keyword(section, keyword)
    1280         1462 :       CALL keyword_release(keyword)
    1281              : 
    1282              :       CALL keyword_create(keyword, __LOCATION__, name="DO_DSO", &
    1283              :                           description="Compute the diamagnetic spin-orbit contribution (NOT YET IMPLEMENTED)", &
    1284              :                           usage="DO_DSO F", &
    1285         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1286         1462 :       CALL section_add_keyword(section, keyword)
    1287         1462 :       CALL keyword_release(keyword)
    1288              : 
    1289         1462 :       NULLIFY (subsection)
    1290              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    1291              :                           description="print results of the indirect spin-spin calculation", &
    1292         1462 :                           repeats=.FALSE.)
    1293              : 
    1294              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "K_MATRIX", &
    1295              :                                        description="Controls the printing of the indirect spin-spin matrix", &
    1296         1462 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="")
    1297              : 
    1298              :       CALL keyword_create(keyword, __LOCATION__, name="ATOMS_LIST", &
    1299              :                           description="list of atoms for which the indirect spin-spin is printed into a file ", &
    1300              :                           usage="ATOMS_LIST 1 2", n_var=-1, &
    1301         1462 :                           type_of_var=integer_t, repeats=.TRUE.)
    1302         1462 :       CALL section_add_keyword(print_key, keyword)
    1303         1462 :       CALL keyword_release(keyword)
    1304              : 
    1305         1462 :       CALL section_add_subsection(subsection, print_key)
    1306         1462 :       CALL section_release(print_key)
    1307              : 
    1308         1462 :       CALL section_add_subsection(section, subsection)
    1309         1462 :       CALL section_release(subsection)
    1310              : 
    1311         1462 :       NULLIFY (subsection)
    1312         1462 :       CALL create_interp_section(subsection)
    1313         1462 :       CALL section_add_subsection(section, subsection)
    1314         1462 :       CALL section_release(subsection)
    1315              : 
    1316         1462 :    END SUBROUTINE create_spin_spin_section
    1317              : 
    1318              : ! **************************************************************************************************
    1319              : !> \brief creates the input structure used to activate
    1320              : !>         calculation of EPR using
    1321              : !>         the induced current obtained from DFPT
    1322              : !>      Available properties : none
    1323              : !> \param section the section to create
    1324              : !> \author  VW
    1325              : ! **************************************************************************************************
    1326         1462 :    SUBROUTINE create_epr_section(section)
    1327              :       TYPE(section_type), POINTER                        :: section
    1328              : 
    1329              :       TYPE(keyword_type), POINTER                        :: keyword
    1330              :       TYPE(section_type), POINTER                        :: print_key, subsection, subsubsection
    1331              : 
    1332         1462 :       NULLIFY (keyword, print_key, subsection, subsubsection)
    1333              : 
    1334         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    1335              :       CALL section_create(section, __LOCATION__, name="EPR", &
    1336              :                           description="The g tensor is calculated by DFPT ", &
    1337              :                           n_keywords=5, n_subsections=1, repeats=.FALSE., &
    1338         2924 :                           citations=[Weber2009])
    1339              : 
    1340              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1341              :                           description="controls the activation of the epr calculation", &
    1342              :                           usage="&EPR T", &
    1343              :                           default_l_val=.FALSE., &
    1344         1462 :                           lone_keyword_l_val=.TRUE.)
    1345         1462 :       CALL section_add_keyword(section, keyword)
    1346         1462 :       CALL keyword_release(keyword)
    1347              : 
    1348              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_EPR", &
    1349              :                           description="Restart the EPR calculation from a previous run (NOT WORKING)", &
    1350              :                           usage="RESTART_EPR", default_l_val=.FALSE., &
    1351         1462 :                           lone_keyword_l_val=.TRUE.)
    1352         1462 :       CALL section_add_keyword(section, keyword)
    1353         1462 :       CALL keyword_release(keyword)
    1354              : 
    1355         1462 :       NULLIFY (subsection)
    1356              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    1357              :                           description="print results of epr calculation", &
    1358         1462 :                           repeats=.FALSE.)
    1359              : 
    1360              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "NABLAVKS_CUBES", &
    1361              :                                        description="Controls the printing of the components of nabla v_ks ", &
    1362         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1363              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
    1364              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1365              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1366              :                           " 1 number valid for all components.", &
    1367         1462 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1368         1462 :       CALL section_add_keyword(print_key, keyword)
    1369         1462 :       CALL keyword_release(keyword)
    1370              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1371              :                           description="append the cube files when they already exist", &
    1372         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1373         1462 :       CALL section_add_keyword(print_key, keyword)
    1374         1462 :       CALL keyword_release(keyword)
    1375              : 
    1376         1462 :       CALL section_add_subsection(subsection, print_key)
    1377         1462 :       CALL section_release(print_key)
    1378              : 
    1379              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "G_TENSOR", &
    1380              :                                        description="Controls the printing of the g tensor", &
    1381         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1382         1462 :       CALL create_xc_section(subsubsection)
    1383         1462 :       CALL section_add_subsection(print_key, subsubsection)
    1384         1462 :       CALL section_release(subsubsection)
    1385              : 
    1386              :       CALL keyword_create(keyword, __LOCATION__, name="GAPW_MAX_ALPHA", &
    1387              :                           description="Maximum alpha of GTH potentials allowed on the soft grids ", &
    1388         1462 :                           usage="GAPW_MAX_ALPHA real", default_r_val=5.0_dp)
    1389         1462 :       CALL section_add_keyword(print_key, keyword)
    1390         1462 :       CALL keyword_release(keyword)
    1391              : 
    1392              :       CALL keyword_create(keyword, __LOCATION__, name="SOO_RHO_HARD", &
    1393              :                           description="Whether or not to include the atomic parts of the density "// &
    1394              :                           "in the SOO part of the g tensor", usage="SOO_RHO_HARD", &
    1395         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1396         1462 :       CALL section_add_keyword(print_key, keyword)
    1397         1462 :       CALL keyword_release(keyword)
    1398              : 
    1399         1462 :       CALL section_add_subsection(subsection, print_key)
    1400         1462 :       CALL section_release(print_key)
    1401              : 
    1402              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESPONSE_FUNCTION_CUBES", &
    1403              :                                        description="Controls the printing of the response functions ", &
    1404         1462 :                                        print_level=high_print_level, add_last=add_last_numeric, filename="")
    1405              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
    1406              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1407              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1408              :                           " 1 number valid for all components.", &
    1409         1462 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1410         1462 :       CALL section_add_keyword(print_key, keyword)
    1411         1462 :       CALL keyword_release(keyword)
    1412              : 
    1413              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LU_BOUNDS", &
    1414              :                           variants=["CUBES_LU"], &
    1415              :                           description="The lower and upper index of the states to be printed as cube", &
    1416              :                           usage="CUBES_LU_BOUNDS integer integer", &
    1417         2924 :                           n_var=2, default_i_vals=[0, -2], type_of_var=integer_t)
    1418         1462 :       CALL section_add_keyword(print_key, keyword)
    1419         1462 :       CALL keyword_release(keyword)
    1420              : 
    1421              :       CALL keyword_create(keyword, __LOCATION__, name="CUBES_LIST", &
    1422              :                           description="Indexes of the states to be printed as cube files "// &
    1423              :                           "This keyword can be repeated several times "// &
    1424              :                           "(useful if you have to specify many indexes).", &
    1425              :                           usage="CUBES_LIST 1 2", &
    1426         1462 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
    1427         1462 :       CALL section_add_keyword(print_key, keyword)
    1428         1462 :       CALL keyword_release(keyword)
    1429              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1430              :                           description="append the cube files when they already exist", &
    1431         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1432         1462 :       CALL section_add_keyword(print_key, keyword)
    1433         1462 :       CALL keyword_release(keyword)
    1434              : 
    1435         1462 :       CALL section_add_subsection(subsection, print_key)
    1436         1462 :       CALL section_release(print_key)
    1437              : 
    1438         1462 :       CALL section_add_subsection(section, subsection)
    1439         1462 :       CALL section_release(subsection)
    1440              : 
    1441         1462 :       NULLIFY (subsection)
    1442         1462 :       CALL create_interp_section(subsection)
    1443         1462 :       CALL section_add_subsection(section, subsection)
    1444         1462 :       CALL section_release(subsection)
    1445              : 
    1446         1462 :    END SUBROUTINE create_epr_section
    1447              : 
    1448              : ! **************************************************************************************************
    1449              : !> \brief creates the input structure used to activate
    1450              : !>      calculation of polarizability tensor DFPT
    1451              : !>      Available properties : none
    1452              : !> \param section the section to create
    1453              : !> \author SL
    1454              : ! **************************************************************************************************
    1455         1462 :    SUBROUTINE create_polarizability_section(section)
    1456              : 
    1457              :       TYPE(section_type), POINTER                        :: section
    1458              : 
    1459              :       TYPE(keyword_type), POINTER                        :: keyword
    1460              :       TYPE(section_type), POINTER                        :: print_key, subsection
    1461              : 
    1462         1462 :       NULLIFY (keyword, print_key, subsection)
    1463              : 
    1464         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    1465              :       CALL section_create(section, __LOCATION__, name="POLAR", &
    1466              :                           description="Compute polarizabilities.", &
    1467              :                           n_keywords=5, n_subsections=1, repeats=.FALSE., &
    1468         4386 :                           citations=[Putrino2002, Luber2014])
    1469              : 
    1470              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    1471              :                           description="controls the activation of the polarizability calculation", &
    1472              :                           usage="&POLAR T", &
    1473              :                           default_l_val=.FALSE., &
    1474         1462 :                           lone_keyword_l_val=.TRUE.)
    1475         1462 :       CALL section_add_keyword(section, keyword)
    1476         1462 :       CALL keyword_release(keyword)
    1477              : 
    1478              :       CALL keyword_create(keyword, __LOCATION__, name="DO_RAMAN", &
    1479              :                           description="Compute the electric-dipole--electric-dipole polarizability", &
    1480              :                           usage="DO_RAMAN F", &
    1481         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1482         1462 :       CALL section_add_keyword(section, keyword)
    1483         1462 :       CALL keyword_release(keyword)
    1484              : 
    1485              :       CALL keyword_create(keyword, __LOCATION__, name="PERIODIC_DIPOLE_OPERATOR", &
    1486              :                           description="Type of dipole operator: Berry phase(T) or Local(F)", &
    1487              :                           usage="PERIODIC_DIPOLE_OPERATOR T", &
    1488         1462 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1489         1462 :       CALL section_add_keyword(section, keyword)
    1490         1462 :       CALL keyword_release(keyword)
    1491              : 
    1492         1462 :       NULLIFY (subsection)
    1493              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    1494              :                           description="print results of the polarizability calculation", &
    1495         1462 :                           repeats=.FALSE.)
    1496              : 
    1497              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "POLAR_MATRIX", &
    1498              :                                        description="Controls the printing of the polarizabilities", &
    1499         1462 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="")
    1500              : 
    1501         1462 :       CALL section_add_subsection(subsection, print_key)
    1502         1462 :       CALL section_release(print_key)
    1503         1462 :       CALL section_add_subsection(section, subsection)
    1504         1462 :       CALL section_release(subsection)
    1505              : 
    1506         1462 :       NULLIFY (subsection)
    1507         1462 :       CALL create_interp_section(subsection)
    1508         1462 :       CALL section_add_subsection(section, subsection)
    1509         1462 :       CALL section_release(subsection)
    1510              : 
    1511         1462 :    END SUBROUTINE create_polarizability_section
    1512              : 
    1513              : ! **************************************************************************************************
    1514              : !> \brief creates the section for electron transfer coupling
    1515              : !> \param section ...
    1516              : !> \author fschiff
    1517              : ! **************************************************************************************************
    1518         1462 :    SUBROUTINE create_et_coupling_section(section)
    1519              :       TYPE(section_type), POINTER                        :: section
    1520              : 
    1521              :       TYPE(keyword_type), POINTER                        :: keyword
    1522              :       TYPE(section_type), POINTER                        :: print_key, subsection
    1523              : 
    1524         1462 :       NULLIFY (keyword)
    1525         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    1526              :       CALL section_create(section, __LOCATION__, name="ET_COUPLING", &
    1527              :                           description="specifies the two constraints/restraints for extracting ET coupling elements", &
    1528         4386 :                           n_keywords=1, n_subsections=4, repeats=.FALSE., citations=[Kondov2007, Futera2017])
    1529              : 
    1530         1462 :       NULLIFY (subsection)
    1531         1462 :       CALL create_ddapc_restraint_section(subsection, "DDAPC_RESTRAINT_A")
    1532         1462 :       CALL section_add_subsection(section, subsection)
    1533         1462 :       CALL section_release(subsection)
    1534              : 
    1535         1462 :       NULLIFY (subsection)
    1536         1462 :       CALL create_ddapc_restraint_section(subsection, "DDAPC_RESTRAINT_B")
    1537         1462 :       CALL section_add_subsection(section, subsection)
    1538         1462 :       CALL section_release(subsection)
    1539              : 
    1540         1462 :       NULLIFY (subsection)
    1541         1462 :       CALL create_projection(subsection, "PROJECTION")
    1542         1462 :       CALL section_add_subsection(section, subsection)
    1543         1462 :       CALL section_release(subsection)
    1544              : 
    1545              :       CALL keyword_create(keyword, __LOCATION__, name="TYPE_OF_CONSTRAINT", &
    1546              :                           description="Specifies the type of constraint", &
    1547              :                           usage="TYPE_OF_CONSTRAINT DDAPC", &
    1548              :                           enum_c_vals=s2a("NONE", "DDAPC"), &
    1549              :                           enum_i_vals=[do_no_et, do_et_ddapc], &
    1550              :                           enum_desc=s2a("NONE", "DDAPC Constraint"), &
    1551         1462 :                           default_i_val=do_no_et)
    1552         1462 :       CALL section_add_keyword(section, keyword)
    1553         1462 :       CALL keyword_release(keyword)
    1554              : 
    1555         1462 :       NULLIFY (print_key)
    1556              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
    1557              :                                        description="Controls the printing basic info about the method", &
    1558         1462 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
    1559         1462 :       CALL section_add_subsection(section, print_key)
    1560         1462 :       CALL section_release(print_key)
    1561              : 
    1562         1462 :    END SUBROUTINE create_et_coupling_section
    1563              : 
    1564              : ! **************************************************************************************************
    1565              : !> \brief defines input sections for specification of Hilbert space partitioning
    1566              : !>        in projection-operator approach of electronic coupling calulation
    1567              : !> \param section pointer to the section data structure
    1568              : !> \param section_name name of the projection section
    1569              : !> \author Z. Futera (02.2017)
    1570              : ! **************************************************************************************************
    1571         1462 :    SUBROUTINE create_projection(section, section_name)
    1572              : 
    1573              :       ! Routine arguments
    1574              :       TYPE(section_type), POINTER                        :: section
    1575              :       CHARACTER(len=*), INTENT(in)                       :: section_name
    1576              : 
    1577              :       TYPE(keyword_type), POINTER                        :: keyword
    1578              :       TYPE(section_type), POINTER                        :: print_key, section_block, section_print
    1579              : 
    1580              : ! Routine name for dubug purposes
    1581              : 
    1582              :       ! Sanity check
    1583            0 :       CPASSERT(.NOT. ASSOCIATED(section))
    1584              : 
    1585              :       ! Initialization
    1586         1462 :       NULLIFY (keyword)
    1587         1462 :       NULLIFY (print_key)
    1588         1462 :       NULLIFY (section_block)
    1589         1462 :       NULLIFY (section_print)
    1590              : 
    1591              :       ! Input-file section definition
    1592              :       CALL section_create(section, __LOCATION__, name=TRIM(ADJUSTL(section_name)), &
    1593              :                           description="Projection-operator approach fo ET coupling calculation", &
    1594         1462 :                           n_keywords=0, n_subsections=2, repeats=.FALSE.)
    1595              : 
    1596              :       ! Subsection #0: Log printing
    1597              :       CALL cp_print_key_section_create(print_key, __LOCATION__, 'PROGRAM_RUN_INFO', &
    1598              :                                        description="Controls printing of data and informations to log file", &
    1599         1462 :                                        print_level=low_print_level, filename="__STD_OUT__")
    1600         1462 :       CALL section_add_subsection(section, print_key)
    1601         1462 :       CALL section_release(print_key)
    1602              : 
    1603              :       ! Subsection #1: Atomic blocks
    1604              :       CALL section_create(section_block, __LOCATION__, name='BLOCK', &
    1605              :                           description="Part of the system (donor, acceptor, bridge,...)", &
    1606         1462 :                           n_keywords=2, n_subsections=1, repeats=.TRUE.)
    1607         1462 :       CALL section_add_subsection(section, section_block)
    1608              : 
    1609              :       ! S#1 - Keyword #1: Atom IDs defining a Hilbert space block
    1610              :       CALL keyword_create(keyword, __LOCATION__, name='ATOMS', &
    1611              :                           description="Array of atom IDs in the system part", &
    1612              :                           usage="ATOMS {integer} {integer} .. {integer}", &
    1613         1462 :                           n_var=-1, type_of_var=integer_t, repeats=.FALSE.)
    1614         1462 :       CALL section_add_keyword(section_block, keyword)
    1615         1462 :       CALL keyword_release(keyword)
    1616              : 
    1617              :       ! S#1 - Keyword #1: Atom IDs defining a Hilbert space block
    1618              :       CALL keyword_create(keyword, __LOCATION__, name='NELECTRON', &
    1619              :                           description="Number of electrons expected in the system part", &
    1620         1462 :                           usage="NELECTRON {integer}", default_i_val=0)
    1621         1462 :       CALL section_add_keyword(section_block, keyword)
    1622         1462 :       CALL keyword_release(keyword)
    1623              : 
    1624              :       ! S#1 - Subsection #1: Printing setting
    1625              :       CALL section_create(section_print, __LOCATION__, name='PRINT', &
    1626              :                           description="Possible printing options in ET system part", &
    1627         1462 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
    1628         1462 :       CALL section_add_subsection(section_block, section_print)
    1629              : 
    1630              :       ! S#1 - S#1 - Keyword #1: MO coefficient on specific atom
    1631              :       CALL keyword_create(keyword, __LOCATION__, name='MO_COEFF_ATOM', &
    1632              :                           description="Print out MO coeffiecients on given atom", &
    1633              :                           usage="MO_COEFF_ATOM {integer} {integer} .. {integer}", &
    1634         1462 :                           type_of_var=integer_t, n_var=-1, repeats=.TRUE.)
    1635         1462 :       CALL section_add_keyword(section_print, keyword)
    1636         1462 :       CALL keyword_release(keyword)
    1637              : 
    1638              :       ! S#1 - S#1 - Keyword #1: MO coefficient of specific state
    1639              :       CALL keyword_create(keyword, __LOCATION__, name='MO_COEFF_ATOM_STATE', &
    1640              :                           description="Print out MO coeffiecients of specific state", &
    1641              :                           usage="MO_COEFF_ATOM_STATE {integer} {integer} .. {integer}", &
    1642         1462 :                           type_of_var=integer_t, n_var=-1, repeats=.TRUE.)
    1643         1462 :       CALL section_add_keyword(section_print, keyword)
    1644         1462 :       CALL keyword_release(keyword)
    1645              : 
    1646              :       ! S#1 - S#1 - Subsection #1: Saving MOs to CUBE files
    1647              :       CALL cp_print_key_section_create(print_key, __LOCATION__, 'MO_CUBES', &
    1648              :                                        description="Controls saving of MO cube files", &
    1649         1462 :                                        print_level=high_print_level, filename="")
    1650              : 
    1651              :       ! S#1 - S#1 - S#1 - Keyword #1: Stride
    1652              :       CALL keyword_create(keyword, __LOCATION__, name='STRIDE', &
    1653              :                           description="The stride (X,Y,Z) used to write the cube file", &
    1654              :                           usage="STRIDE {integer} {integer} {integer}", n_var=-1, &
    1655         1462 :                           default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1656         1462 :       CALL section_add_keyword(print_key, keyword)
    1657         1462 :       CALL keyword_release(keyword)
    1658              : 
    1659              :       ! S#1 - S#1 - S#1 - Keyword #2: List of MO IDs
    1660              :       CALL keyword_create(keyword, __LOCATION__, name='MO_LIST', &
    1661              :                           description="Indices of molecular orbitals to save", &
    1662              :                           usage="MO_LIST {integer} {integer} .. {integer}", &
    1663         1462 :                           type_of_var=integer_t, n_var=-1, repeats=.TRUE.)
    1664         1462 :       CALL section_add_keyword(print_key, keyword)
    1665         1462 :       CALL keyword_release(keyword)
    1666              : 
    1667              :       ! S#1 - S#1 - S#1 - Keyword #2: Number of unoccupied states
    1668              :       CALL keyword_create(keyword, __LOCATION__, name='NLUMO', &
    1669              :                           description="Number of unoccupied molecular orbitals to save", &
    1670         1462 :                           usage="NLUMO {integer}", default_i_val=1)
    1671         1462 :       CALL section_add_keyword(print_key, keyword)
    1672         1462 :       CALL keyword_release(keyword)
    1673              : 
    1674              :       ! S#1 - S#1 - S#1 - Keyword #3: Number of occupied states
    1675              :       CALL keyword_create(keyword, __LOCATION__, name='NHOMO', &
    1676              :                           description="Number of occupied molecular orbitals to save", &
    1677         1462 :                           usage="NHOMO {integer}", default_i_val=1)
    1678         1462 :       CALL section_add_keyword(print_key, keyword)
    1679         1462 :       CALL keyword_release(keyword)
    1680              : 
    1681         1462 :       CALL section_add_subsection(section_print, print_key)
    1682         1462 :       CALL section_release(print_key)
    1683              : 
    1684              :       ! S#1 - S#1 - Clean
    1685         1462 :       CALL section_release(section_print)
    1686              : 
    1687              :       ! S#1 - Clean
    1688         1462 :       CALL section_release(section_block)
    1689              : 
    1690              :       ! S#1 - Subsection #1: Printing setting
    1691              :       CALL section_create(section_print, __LOCATION__, name='PRINT', &
    1692              :                           description="Possible printing options in ET", &
    1693         1462 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
    1694         1462 :       CALL section_add_subsection(section, section_print)
    1695              : 
    1696              :       ! Print couplings
    1697              :       CALL cp_print_key_section_create(print_key, __LOCATION__, 'COUPLINGS', &
    1698              :                                        description="Controls printing couplings onto file", &
    1699         1462 :                                        print_level=low_print_level, filename="")
    1700              : 
    1701              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    1702              :                           description="append the files when they already exist", &
    1703         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1704         1462 :       CALL section_add_keyword(print_key, keyword)
    1705         1462 :       CALL keyword_release(keyword)
    1706              : 
    1707         1462 :       CALL section_add_subsection(section_print, print_key)
    1708         1462 :       CALL section_release(print_key)
    1709              : 
    1710         1462 :       CALL section_release(section_print)
    1711              : 
    1712         1462 :    END SUBROUTINE create_projection
    1713              : 
    1714              : ! **************************************************************************************************
    1715              : !> \brief creates an input section for tddfpt calculation
    1716              : !> \param section section to create
    1717              : !> \par History
    1718              : !>    * 05.2016 forked from create_tddfpt_section [Sergey Chulkov]
    1719              : !>    * 08.2016 moved from module input_cp2k_dft [Sergey Chulkov]
    1720              : ! **************************************************************************************************
    1721         2924 :    SUBROUTINE create_tddfpt2_section(section)
    1722              :       TYPE(section_type), POINTER                        :: section
    1723              : 
    1724              :       TYPE(keyword_type), POINTER                        :: keyword
    1725              :       TYPE(section_type), POINTER                        :: print_key, subsection
    1726              : 
    1727         2924 :       CPASSERT(.NOT. ASSOCIATED(section))
    1728              :       CALL section_create(section, __LOCATION__, name="TDDFPT", &
    1729              :                           description="Controls time-dependent density functional perturbation theory "// &
    1730              :                           "(TDDFPT) calculations for electronic excitations and related properties.", &
    1731              :                           n_keywords=14, n_subsections=4, repeats=.FALSE., &
    1732        11696 :                           citations=[Iannuzzi2005, Hanasaki2025, Hernandez2025])
    1733              : 
    1734         2924 :       NULLIFY (keyword, print_key, subsection)
    1735              : 
    1736              :       CALL keyword_create(keyword, __LOCATION__, &
    1737              :                           name="_SECTION_PARAMETERS_", &
    1738              :                           description="Activates the TDDFPT procedure.", &
    1739              :                           default_l_val=.FALSE., &
    1740         2924 :                           lone_keyword_l_val=.TRUE.)
    1741         2924 :       CALL section_add_keyword(section, keyword)
    1742         2924 :       CALL keyword_release(keyword)
    1743              : 
    1744              :       ! Integer
    1745              :       CALL keyword_create(keyword, __LOCATION__, name="NSTATES", &
    1746              :                           description="Number of excited states to converge.", &
    1747              :                           n_var=1, type_of_var=integer_t, &
    1748         2924 :                           default_i_val=1)
    1749         2924 :       CALL section_add_keyword(section, keyword)
    1750         2924 :       CALL keyword_release(keyword)
    1751              : 
    1752              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
    1753              :                           description="Maximal number of iterations to be performed.", &
    1754              :                           n_var=1, type_of_var=integer_t, &
    1755         2924 :                           default_i_val=50)
    1756         2924 :       CALL section_add_keyword(section, keyword)
    1757         2924 :       CALL keyword_release(keyword)
    1758              : 
    1759              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_KV", &
    1760              :                           description="Maximal number of Krylov space vectors. "// &
    1761              :                           "Davidson iterations will be restarted upon reaching this limit.", &
    1762              :                           n_var=1, type_of_var=integer_t, &
    1763         2924 :                           default_i_val=5000)
    1764         2924 :       CALL section_add_keyword(section, keyword)
    1765         2924 :       CALL keyword_release(keyword)
    1766              : 
    1767              :       CALL keyword_create(keyword, __LOCATION__, name="NLUMO", &
    1768              :                           description="Number of unoccupied orbitals to consider. "// &
    1769              :                           "Default is to use all unoccupied orbitals (-1).", &
    1770              :                           n_var=1, type_of_var=integer_t, &
    1771         2924 :                           default_i_val=-1)
    1772         2924 :       CALL section_add_keyword(section, keyword)
    1773         2924 :       CALL keyword_release(keyword)
    1774              : 
    1775              :       CALL keyword_create(keyword, __LOCATION__, name="NPROC_STATE", &
    1776              :                           description="Number of MPI processes to be used per excited state. "// &
    1777              :                           "Default is to use all MPI processes (0).", &
    1778              :                           n_var=1, type_of_var=integer_t, &
    1779         2924 :                           default_i_val=0)
    1780         2924 :       CALL section_add_keyword(section, keyword)
    1781         2924 :       CALL keyword_release(keyword)
    1782              : 
    1783              :       ! kernel type
    1784              :       CALL keyword_create(keyword, __LOCATION__, name="KERNEL", &
    1785              :                           description="Options to compute the kernel", &
    1786              :                           usage="KERNEL FULL", &
    1787              :                           enum_c_vals=s2a("FULL", "sTDA", "NONE"), &
    1788              :                           enum_i_vals=[tddfpt_kernel_full, tddfpt_kernel_stda, tddfpt_kernel_none], &
    1789         2924 :                           default_i_val=tddfpt_kernel_full)
    1790         2924 :       CALL section_add_keyword(section, keyword)
    1791         2924 :       CALL keyword_release(keyword)
    1792              : 
    1793              :       ! spin-flip TDDFPT options
    1794              :       CALL keyword_create(keyword, __LOCATION__, name="SPINFLIP", &
    1795              :                           description="Selects the type of spin-flip TDDFPT kernel", &
    1796              :                           usage="SPINFLIP NONCOLLINEAR", &
    1797              :                           enum_c_vals=s2a("NONE", "COLLINEAR", "NONCOLLINEAR"), &
    1798              :                           enum_i_vals=[no_sf_tddfpt, tddfpt_sf_col, tddfpt_sf_noncol], &
    1799              :                           enum_desc=s2a("Only molecular orbital energy differences are considered", &
    1800              :                                         "MO energy diferences and Fock exchange contributions are "// &
    1801              :                                         "considered", &
    1802              :                                         "MO energy differences, Fock exchange and "// &
    1803              :                                         "Noncollinear local exchange-correlation "// &
    1804              :                                         "kernel are considered"), &
    1805         5848 :                           default_i_val=no_sf_tddfpt, citations=[Hernandez2025])
    1806         2924 :       CALL section_add_keyword(section, keyword)
    1807         2924 :       CALL keyword_release(keyword)
    1808              : 
    1809              :       CALL keyword_create(keyword, __LOCATION__, name="OE_CORR", &
    1810              :                           description="Orbital energy correction potential.", &
    1811              :                           enum_c_vals=s2a("NONE", "LB94", "GLLB", "SAOP", "SHIFT"), &
    1812              :                           enum_i_vals=[oe_none, oe_lb, oe_gllb, oe_saop, oe_shift], &
    1813              :                           enum_desc=s2a("No orbital correction scheme is used", &
    1814              :                                         "van Leeuwen and Baerends. PRA, 49:2421, 1994", &
    1815              :                                         "Gritsenko, van Leeuwen, van Lenthe, Baerends. PRA, 51:1944, 1995", &
    1816              :                                         "Gritsenko, Schipper, Baerends. Chem. Phys. Lett., 302:199, 1999", &
    1817              :                                         "Constant shift of virtual and/or open-shell orbitals"), &
    1818         2924 :                           default_i_val=oe_none)
    1819         2924 :       CALL section_add_keyword(section, keyword)
    1820         2924 :       CALL keyword_release(keyword)
    1821              : 
    1822              :       ! SHIFTS
    1823              :       CALL keyword_create(keyword, __LOCATION__, name="EV_SHIFT", &
    1824              :                           variants=s2a("VIRTUAL_SHIFT"), &
    1825              :                           description="Constant shift of virtual state eigenvalues.", &
    1826              :                           usage="EV_SHIFT 0.500", &
    1827              :                           n_var=1, type_of_var=real_t, &
    1828              :                           unit_str="eV", &
    1829         2924 :                           default_r_val=0.0_dp)
    1830         2924 :       CALL section_add_keyword(section, keyword)
    1831         2924 :       CALL keyword_release(keyword)
    1832              :       !
    1833              :       CALL keyword_create(keyword, __LOCATION__, name="EOS_SHIFT", &
    1834              :                           variants=s2a("OPEN_SHELL_SHIFT"), &
    1835              :                           description="Constant shift of open shell eigenvalues.", &
    1836              :                           usage="EOS_SHIFT 0.200", &
    1837              :                           n_var=1, type_of_var=real_t, &
    1838              :                           unit_str="eV", &
    1839         2924 :                           default_r_val=0.0_dp)
    1840         2924 :       CALL section_add_keyword(section, keyword)
    1841         2924 :       CALL keyword_release(keyword)
    1842              : 
    1843              :       ! Real
    1844              :       CALL keyword_create(keyword, __LOCATION__, name="CONVERGENCE", &
    1845              :                           description="Target accuracy for excited state energies.", &
    1846              :                           n_var=1, type_of_var=real_t, unit_str="hartree", &
    1847         2924 :                           default_r_val=1.0e-5_dp)
    1848         2924 :       CALL section_add_keyword(section, keyword)
    1849         2924 :       CALL keyword_release(keyword)
    1850              : 
    1851              :       CALL keyword_create(keyword, __LOCATION__, name="MIN_AMPLITUDE", &
    1852              :                           description="The smallest excitation amplitude to print.", &
    1853              :                           n_var=1, type_of_var=real_t, &
    1854         2924 :                           default_r_val=5.0e-2_dp)
    1855         2924 :       CALL section_add_keyword(section, keyword)
    1856         2924 :       CALL keyword_release(keyword)
    1857              : 
    1858              :       CALL keyword_create(keyword, __LOCATION__, name="ORTHOGONAL_EPS", &
    1859              :                           description="The largest possible overlap between the ground state and "// &
    1860              :                           "orthogonalised excited state wave-functions. Davidson iterations "// &
    1861              :                           "will be restarted when the overlap goes beyond this threshold in "// &
    1862              :                           "order to prevent numerical instability.", &
    1863              :                           n_var=1, type_of_var=real_t, &
    1864         2924 :                           default_r_val=1.0e-4_dp)
    1865         2924 :       CALL section_add_keyword(section, keyword)
    1866         2924 :       CALL keyword_release(keyword)
    1867              : 
    1868              :       ! Logical
    1869              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART", &
    1870              :                           description="Restart the TDDFPT calculation if a restart file exists", &
    1871              :                           n_var=1, type_of_var=logical_t, &
    1872         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1873         2924 :       CALL section_add_keyword(section, keyword)
    1874         2924 :       CALL keyword_release(keyword)
    1875              : 
    1876              :       CALL keyword_create(keyword, __LOCATION__, name="RKS_TRIPLETS", &
    1877              :                           description="Compute triplet excited states using spin-unpolarised molecular orbitals.", &
    1878              :                           n_var=1, type_of_var=logical_t, &
    1879         2924 :                           default_l_val=.FALSE.)
    1880         2924 :       CALL section_add_keyword(section, keyword)
    1881         2924 :       CALL keyword_release(keyword)
    1882              : 
    1883              :       CALL keyword_create(keyword, __LOCATION__, name="ADMM_KERNEL_XC_CORRECTION", &
    1884              :                           description="Use/Ignore ADMM correction xc functional for TD kernel. "// &
    1885              :                           "XC correction functional is defined in ground state XC section.", &
    1886              :                           n_var=1, type_of_var=logical_t, &
    1887         2924 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1888         2924 :       CALL section_add_keyword(section, keyword)
    1889         2924 :       CALL keyword_release(keyword)
    1890              : 
    1891              :       CALL keyword_create(keyword, __LOCATION__, name="ADMM_KERNEL_CORRECTION_SYMMETRIC", &
    1892              :                           description="ADMM correction functional in kernel is applied symmetrically. "// &
    1893              :                           "Original implementation is using a non-symmetric formula.", &
    1894              :                           n_var=1, type_of_var=logical_t, &
    1895         2924 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    1896         2924 :       CALL section_add_keyword(section, keyword)
    1897         2924 :       CALL keyword_release(keyword)
    1898              : 
    1899              :       CALL keyword_create(keyword, __LOCATION__, name="DO_LRIGPW", &
    1900              :                           description="Local resolution of identity for Coulomb contribution.", &
    1901              :                           n_var=1, type_of_var=logical_t, &
    1902         2924 :                           default_l_val=.FALSE.)
    1903         2924 :       CALL section_add_keyword(section, keyword)
    1904         2924 :       CALL keyword_release(keyword)
    1905              : 
    1906              :       CALL keyword_create(keyword, __LOCATION__, name="AUTO_BASIS", &
    1907              :                           description="Specify type and size of automatically generated auxiliary "// &
    1908              :                           "(RI) basis sets. Exactly two arguments are required for this option. "// &
    1909              :                           "The first argument of basis type should be one of the following: "// &
    1910              :                           "`P_LRI_AUX`. The second argument of basis size should be one of the "// &
    1911              :                           "following: `SMALL`, `MEDIUM`, `LARGE`, or `HUGE`. The default is not "// &
    1912              :                           "using any of these basis sets, requested by `AUTO_BASIS X X` (exactly "// &
    1913              :                           "as written here).", &
    1914              :                           usage="AUTO_BASIS {basis_type} {basis_size}", &
    1915         8772 :                           type_of_var=char_t, repeats=.TRUE., n_var=-1, default_c_vals=["X", "X"])
    1916         2924 :       CALL section_add_keyword(section, keyword)
    1917         2924 :       CALL keyword_release(keyword)
    1918              : 
    1919              :       CALL keyword_create(keyword, __LOCATION__, name="DO_SMEARING", &
    1920              :                           description="Implying smeared occupation. ", &
    1921              :                           n_var=1, type_of_var=logical_t, &
    1922         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    1923         2924 :       CALL section_add_keyword(section, keyword)
    1924         2924 :       CALL keyword_release(keyword)
    1925              : 
    1926              :       CALL keyword_create(keyword, __LOCATION__, name="EXCITON_DESCRIPTORS", &
    1927              :                           description="Compute exciton descriptors. "// &
    1928              :                           "Details given in Manual section about Bethe Salpeter equation.", &
    1929              :                           n_var=1, type_of_var=logical_t, &
    1930         2924 :                           default_l_val=.FALSE.)
    1931         2924 :       CALL section_add_keyword(section, keyword)
    1932         2924 :       CALL keyword_release(keyword)
    1933              : 
    1934              :       CALL keyword_create(keyword, __LOCATION__, name="DIRECTIONAL_EXCITON_DESCRIPTORS", &
    1935              :                           description="Print cartesian components of exciton descriptors.", &
    1936              :                           n_var=1, type_of_var=logical_t, &
    1937         2924 :                           default_l_val=.FALSE.)
    1938         2924 :       CALL section_add_keyword(section, keyword)
    1939         2924 :       CALL keyword_release(keyword)
    1940              : 
    1941              :       CALL keyword_create(keyword, __LOCATION__, name="DIRECTIONAL_EXCITON_CROSSCORRELATION", &
    1942              :                           description="Print the electron-hole crosscorrelation matrix as part of the "// &
    1943              :                           "cartesian components of exciton descriptors. Only active together with "// &
    1944              :                           "DIRECTIONAL_EXCITON_DESCRIPTORS.", &
    1945              :                           n_var=1, type_of_var=logical_t, &
    1946         2924 :                           default_l_val=.TRUE.)
    1947         2924 :       CALL section_add_keyword(section, keyword)
    1948         2924 :       CALL keyword_release(keyword)
    1949              : 
    1950              :       ! Strings
    1951              :       CALL keyword_create(keyword, __LOCATION__, name="WFN_RESTART_FILE_NAME", &
    1952              :                           variants=["RESTART_FILE_NAME"], &
    1953              :                           description="Name of the wave function restart file, may include a path."// &
    1954              :                           " If no file is specified, the default is to open the file as generated by"// &
    1955              :                           " the wave function restart print key.", &
    1956              :                           usage="WFN_RESTART_FILE_NAME <FILENAME>", &
    1957         5848 :                           type_of_var=lchar_t)
    1958         2924 :       CALL section_add_keyword(section, keyword)
    1959         2924 :       CALL keyword_release(keyword)
    1960              : 
    1961              :       ! DIPOLE subsection
    1962              :       CALL section_create(subsection, __LOCATION__, name="DIPOLE_MOMENTS", &
    1963              :                           description="Parameters to compute oscillator strengths in the dipole approximation.", &
    1964         2924 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
    1965              : 
    1966              :       CALL keyword_create(keyword, __LOCATION__, name="DIPOLE_FORM", &
    1967              :                           description="Form of dipole transition integrals.", &
    1968              :                           enum_c_vals=s2a("BERRY", "LENGTH", "VELOCITY", "VELOCITY_OLD", &
    1969              :                                           "SCF_MOMENT"), &
    1970              :                           enum_desc=s2a("Based on Berry phase formula (valid for fully periodic molecular systems only)", &
    1971              :                                         "Length form &lang; i | r | j &rang; (valid for non-periodic molecular systems only)", &
    1972              :                                         "Velocity form &lang; i | d/dr | j &rang;", &
    1973              :                                         "Old velocity form &lang; i | d/dr | j &rang;", &
    1974              :                                         "SCF molecular-orbital moment form for k-point TDDFPT"), &
    1975              :                           enum_i_vals=[tddfpt_dipole_berry, tddfpt_dipole_length, &
    1976              :                                        tddfpt_dipole_velocity, tddfpt_dipole_velocity_old, &
    1977              :                                        tddfpt_dipole_scf_moment], &
    1978         2924 :                           default_i_val=tddfpt_dipole_velocity)
    1979         2924 :       CALL section_add_keyword(subsection, keyword)
    1980         2924 :       CALL keyword_release(keyword)
    1981              : 
    1982              :       CALL keyword_create(keyword, __LOCATION__, name="REFERENCE", &
    1983              :                           description="Reference point to calculate electric "// &
    1984              :                           "dipole moments using the dipole integrals in the length form.", &
    1985              :                           enum_c_vals=s2a("COM", "COAC", "USER_DEFINED", "ZERO"), &
    1986              :                           enum_desc=s2a("Use Center of Mass", &
    1987              :                                         "Use Center of Atomic Charges", &
    1988              :                                         "Use User-defined Point", &
    1989              :                                         "Use Origin of Coordinate System"), &
    1990              :                           enum_i_vals=[use_mom_ref_com, &
    1991              :                                        use_mom_ref_coac, &
    1992              :                                        use_mom_ref_user, &
    1993              :                                        use_mom_ref_zero], &
    1994         2924 :                           default_i_val=use_mom_ref_com)
    1995         2924 :       CALL section_add_keyword(subsection, keyword)
    1996         2924 :       CALL keyword_release(keyword)
    1997              : 
    1998              :       CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_POINT", &
    1999              :                           description="User-defined reference point.", &
    2000              :                           usage="REFERENCE_POINT x y z", &
    2001         2924 :                           repeats=.FALSE., n_var=3, type_of_var=real_t, unit_str='bohr')
    2002         2924 :       CALL section_add_keyword(subsection, keyword)
    2003         2924 :       CALL keyword_release(keyword)
    2004              : 
    2005         2924 :       CALL section_add_subsection(section, subsection)
    2006         2924 :       CALL section_release(subsection)
    2007              : 
    2008              :       ! SOC functional
    2009              : 
    2010              :       CALL section_create(subsection, __LOCATION__, name="SOC", &
    2011              :                           description="Is jet to be implemented", &
    2012         2924 :                           n_keywords=2, n_subsections=0, repeats=.FALSE.)
    2013              : 
    2014              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
    2015              :                           variants=s2a("EPS_FILTER_MATRIX"), &
    2016              :                           description="The threshold used for sparse matrix operations", &
    2017              :                           usage="EPS_FILTER {real}", &
    2018              :                           type_of_var=real_t, &
    2019         2924 :                           default_r_val=1.0E-10_dp)
    2020         2924 :       CALL section_add_keyword(subsection, keyword)
    2021         2924 :       CALL keyword_release(keyword)
    2022              : 
    2023              :       CALL keyword_create(keyword, __LOCATION__, name="GRID", &
    2024              :                           variants=["ATOMIC_GRID"], &
    2025              :                           description="Specification of the atomic angular and radial grids for "// &
    2026              :                           "a atomic kind. This keyword must be repeated for all kinds!  "// &
    2027              :                           "Usage: GRID < LEBEDEV_GRID > < RADIAL_GRID >", &
    2028              :                           usage="GRID {string} {integer} {integer}", &
    2029         5848 :                           n_var=3, type_of_var=char_t, repeats=.TRUE.)
    2030         2924 :       CALL section_add_keyword(subsection, keyword)
    2031         2924 :       CALL keyword_release(keyword)
    2032              : 
    2033         2924 :       CALL section_add_subsection(section, subsection)
    2034         2924 :       CALL section_release(subsection)
    2035              : 
    2036              :       ! kernel XC functional
    2037         2924 :       CALL create_xc_section(subsection)
    2038         2924 :       CALL section_add_subsection(section, subsection)
    2039         2924 :       CALL section_release(subsection)
    2040              : 
    2041              :       ! MGRID subsection
    2042         2924 :       CALL create_mgrid_section(subsection, create_subsections=.FALSE.)
    2043         2924 :       CALL section_add_subsection(section, subsection)
    2044         2924 :       CALL section_release(subsection)
    2045              : 
    2046              :       ! sTDA subsection
    2047         2924 :       CALL create_stda_section(subsection)
    2048         2924 :       CALL section_add_subsection(section, subsection)
    2049         2924 :       CALL section_release(subsection)
    2050              : 
    2051              :       ! RSE subsection
    2052         2924 :       CALL create_res_section(subsection)
    2053         2924 :       CALL section_add_subsection(section, subsection)
    2054         2924 :       CALL section_release(subsection)
    2055              : 
    2056              :       CALL keyword_create(keyword, __LOCATION__, name="DO_BSE", &
    2057              :                           description="Choosing BSE kernel.", &
    2058         2924 :                           usage="DO_BSE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2059         2924 :       CALL section_add_keyword(section, keyword)
    2060         2924 :       CALL keyword_release(keyword)
    2061              : 
    2062              :       CALL keyword_create(keyword, __LOCATION__, name="DO_BSE_W_ONLY", &
    2063              :                           description="Debug option for BSE kernel.", &
    2064         2924 :                           usage="DO_BSE_W_ONLY", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2065         2924 :       CALL section_add_keyword(section, keyword)
    2066         2924 :       CALL keyword_release(keyword)
    2067              : 
    2068              :       CALL keyword_create(keyword, __LOCATION__, name="DO_BSE_GW_ONLY", &
    2069              :                           description="Debug option for BSE kernel.", &
    2070         2924 :                           usage="DO_BSE_GW_ONLY", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2071         2924 :       CALL section_add_keyword(section, keyword)
    2072         2924 :       CALL keyword_release(keyword)
    2073              : 
    2074              :       ! LRI subsection
    2075         2924 :       CALL create_lrigpw_section(subsection)
    2076         2924 :       CALL section_add_subsection(section, subsection)
    2077         2924 :       CALL section_release(subsection)
    2078              : 
    2079              :       ! LINRES section
    2080         2924 :       CALL create_linres_section(subsection, create_subsections=.FALSE., default_set_tdlr=.TRUE.)
    2081         2924 :       CALL section_add_subsection(section, subsection)
    2082         2924 :       CALL section_release(subsection)
    2083              : 
    2084              :       ! PRINT subsection
    2085              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    2086         2924 :                           description="Printing of information during the TDDFT run.", repeats=.FALSE.)
    2087              : 
    2088              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="PROGRAM_BANNER", &
    2089              :                                        description="Controls the printing of the banner for TDDFPT program", &
    2090         2924 :                                        print_level=silent_print_level, filename="__STD_OUT__")
    2091         2924 :       CALL section_add_subsection(subsection, print_key)
    2092         2924 :       CALL section_release(print_key)
    2093              : 
    2094              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="GUESS_VECTORS", &
    2095              :                                        description="Controls the printing of initial guess vectors.", &
    2096         2924 :                                        print_level=low_print_level, filename="__STD_OUT__")
    2097         2924 :       CALL section_add_subsection(subsection, print_key)
    2098         2924 :       CALL section_release(print_key)
    2099              : 
    2100              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="ITERATION_INFO", &
    2101              :                                        description="Controls the printing of basic iteration information "// &
    2102              :                                        "during the TDDFT run.", &
    2103         2924 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
    2104         2924 :       CALL section_add_subsection(subsection, print_key)
    2105         2924 :       CALL section_release(print_key)
    2106              : 
    2107              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="DETAILED_ENERGY", &
    2108              :                                        description="Controls the printing of detailed energy information "// &
    2109              :                                        "during the TDDFT run.", &
    2110         2924 :                                        print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
    2111         2924 :       CALL section_add_subsection(subsection, print_key)
    2112         2924 :       CALL section_release(print_key)
    2113              : 
    2114              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="BASIS_SET_FILE", &
    2115              :                                        description="Controls the printing of a file with all basis sets used.", &
    2116         2924 :                                        print_level=debug_print_level, filename="BASIS_SETS")
    2117         2924 :       CALL section_add_subsection(subsection, print_key)
    2118         2924 :       CALL section_release(print_key)
    2119              : 
    2120              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="RESTART", &
    2121              :                                        description="Controls the dumping of the latest wavefunction "// &
    2122              :                                        "restart file during TDDFPT.", &
    2123              :                                        print_level=low_print_level, common_iter_levels=3, &
    2124              :                                        each_iter_names=s2a("TDDFT_SCF"), each_iter_values=[10], &
    2125         2924 :                                        add_last=add_last_numeric, filename="RESTART", do_backup=.TRUE.)
    2126         2924 :       CALL section_add_subsection(subsection, print_key)
    2127         2924 :       CALL section_release(print_key)
    2128              : 
    2129              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="NTO_ANALYSIS", &
    2130              :                                        description="Perform a natural transition orbital analysis.", &
    2131         2924 :                                        print_level=medium_print_level)
    2132              :       CALL keyword_create(keyword, __LOCATION__, name="THRESHOLD", &
    2133              :                           description="Threshold for sum of NTO eigenvalues considered", &
    2134              :                           usage="Threshold 0.95", &
    2135              :                           n_var=1, &
    2136              :                           type_of_var=real_t, &
    2137         2924 :                           default_r_val=0.975_dp)
    2138         2924 :       CALL section_add_keyword(print_key, keyword)
    2139         2924 :       CALL keyword_release(keyword)
    2140              :       CALL keyword_create(keyword, __LOCATION__, name="INTENSITY_THRESHOLD", &
    2141              :                           description="Threshold for oscillator strength to screen states.", &
    2142              :                           usage="Intensity_threshold 0.01", &
    2143              :                           n_var=1, &
    2144              :                           type_of_var=real_t, &
    2145         2924 :                           default_r_val=0.0_dp)
    2146         2924 :       CALL section_add_keyword(print_key, keyword)
    2147         2924 :       CALL keyword_release(keyword)
    2148              :       CALL keyword_create(keyword, __LOCATION__, name="STATE_LIST", &
    2149              :                           description="Specifies a list of states for the NTO calculations.", &
    2150              :                           usage="STATE_LIST {integer} {integer} .. {integer}", &
    2151         2924 :                           n_var=-1, type_of_var=integer_t)
    2152         2924 :       CALL section_add_keyword(print_key, keyword)
    2153         2924 :       CALL keyword_release(keyword)
    2154              :       CALL keyword_create(keyword, __LOCATION__, name="CUBE_FILES", &
    2155              :                           description="Print NTOs on Cube Files", &
    2156              :                           usage="CUBE_FILES {logical}", repeats=.FALSE., n_var=1, &
    2157         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE., type_of_var=logical_t)
    2158         2924 :       CALL section_add_keyword(print_key, keyword)
    2159         2924 :       CALL keyword_release(keyword)
    2160              :       CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
    2161              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    2162              :                           "(larger values result in smaller cube files). Provide 3 numbers (for X,Y,Z) or"// &
    2163              :                           " 1 number valid for all components.", &
    2164         2924 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    2165         2924 :       CALL section_add_keyword(print_key, keyword)
    2166         2924 :       CALL keyword_release(keyword)
    2167              :       CALL keyword_create(keyword, __LOCATION__, name="APPEND", &
    2168              :                           description="append the cube files when they already exist", &
    2169         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2170         2924 :       CALL section_add_keyword(print_key, keyword)
    2171         2924 :       CALL keyword_release(keyword)
    2172         2924 :       CALL section_add_subsection(subsection, print_key)
    2173         2924 :       CALL section_release(print_key)
    2174              : 
    2175              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "MOS_MOLDEN", &
    2176              :                                        description="Write the NTO in Molden file format, for visualisation.", &
    2177         2924 :                                        print_level=debug_print_level + 1, add_last=add_last_numeric, filename="MOS")
    2178              :       CALL keyword_create(keyword, __LOCATION__, name="UNIT", &
    2179              :                           description="Unit for coordinates and cell in the MOLDEN file.", &
    2180              :                           usage="UNIT ANGSTROM", &
    2181              :                           enum_c_vals=s2a("BOHR", "ANGSTROM"), &
    2182              :                           enum_desc=s2a("Write in Bohr (AU)", "Write in Angstrom"), &
    2183              :                           enum_i_vals=[1, 2], &
    2184         2924 :                           default_i_val=1)
    2185         2924 :       CALL section_add_keyword(print_key, keyword)
    2186         2924 :       CALL keyword_release(keyword)
    2187              :       CALL keyword_create(keyword, __LOCATION__, name="WRITE_CELL", &
    2188              :                           description="Controls whether the [Cell] block is written to the MOLDEN file.", &
    2189              :                           usage="WRITE_CELL TRUE", &
    2190         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2191         2924 :       CALL section_add_keyword(print_key, keyword)
    2192         2924 :       CALL keyword_release(keyword)
    2193              :       CALL keyword_create(keyword, __LOCATION__, name="WRITE_PSEUDO", &
    2194              :                           description="Controls whether the [Pseudo] block is written to the MOLDEN file.", &
    2195              :                           usage="WRITE_PSEUDO TRUE", &
    2196         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2197         2924 :       CALL section_add_keyword(print_key, keyword)
    2198         2924 :       CALL keyword_release(keyword)
    2199              :       CALL keyword_create(keyword, __LOCATION__, name="MARK_GHOST", &
    2200              :                           description="Controls whether ghost atoms are marked in the [Atoms] block by "// &
    2201              :                           "setting their atomic number to zero.", &
    2202              :                           usage="MARK_GHOST T", &
    2203         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2204         2924 :       CALL section_add_keyword(print_key, keyword)
    2205         2924 :       CALL keyword_release(keyword)
    2206              :       CALL keyword_create(keyword, __LOCATION__, name="NDIGITS", &
    2207              :                           description="Specifies the number of significant digits retained. 3 is OK for visualization.", &
    2208              :                           usage="NDIGITS {int}", &
    2209         2924 :                           default_i_val=3)
    2210         2924 :       CALL section_add_keyword(print_key, keyword)
    2211         2924 :       CALL keyword_release(keyword)
    2212              :       CALL keyword_create(keyword, __LOCATION__, name="GTO_KIND", &
    2213              :                           description="Representation of Gaussian-type orbitals", &
    2214              :                           default_i_val=gto_spherical, &
    2215              :                           enum_c_vals=s2a("CARTESIAN", "SPHERICAL"), &
    2216              :                           enum_desc=s2a( &
    2217              :                           "Cartesian Gaussian orbitals. Use with caution", &
    2218              :                           "Spherical Gaussian orbitals. Incompatible with VMD"), &
    2219         2924 :                           enum_i_vals=[gto_cartesian, gto_spherical])
    2220         2924 :       CALL section_add_keyword(print_key, keyword)
    2221         2924 :       CALL keyword_release(keyword)
    2222         2924 :       CALL section_add_subsection(subsection, print_key)
    2223         2924 :       CALL section_release(print_key)
    2224              : 
    2225              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="NAMD_PRINT", &
    2226              :                                        description="Controls the printout required for NAMD with NEWTONX.", &
    2227         2924 :                                        print_level=debug_print_level + 1, filename="CP2K_NEWTONX")
    2228              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_VIRTUALS", &
    2229              :                           description="Print occupied AND virtual molecular orbital coefficients", &
    2230         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2231         2924 :       CALL section_add_keyword(print_key, keyword)
    2232         2924 :       CALL keyword_release(keyword)
    2233              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_PHASES", &
    2234              :                           description="Print phases of occupied and virtuals MOs.", &
    2235         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2236         2924 :       CALL section_add_keyword(print_key, keyword)
    2237         2924 :       CALL keyword_release(keyword)
    2238              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_WITH_PHASES", &
    2239              :                           description="Scale ES eigenvectors with phases of occupied and virtuals MOs.", &
    2240         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2241         2924 :       CALL section_add_keyword(print_key, keyword)
    2242         2924 :       CALL keyword_release(keyword)
    2243         2924 :       CALL section_add_subsection(subsection, print_key)
    2244         2924 :       CALL section_release(print_key)
    2245              : 
    2246              :       !! SOC PRINT SECTION
    2247              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="SOC_PRINT", &
    2248              :                                        description="Controls the printout of the tddfpt2_soc modul", &
    2249         2924 :                                        print_level=debug_print_level + 1, filename="SOC")
    2250              :       CALL keyword_create(keyword, __LOCATION__, name="UNIT_eV", &
    2251              :                           description="Will detrement if output in eVolt will be printef.", &
    2252         2924 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    2253         2924 :       CALL section_add_keyword(print_key, keyword)
    2254         2924 :       CALL keyword_release(keyword)
    2255              :       CALL keyword_create(keyword, __LOCATION__, name="UNIT_wn", &
    2256              :                           description="Will detrement if output in wavenumbers will be printed.", &
    2257         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2258         2924 :       CALL section_add_keyword(print_key, keyword)
    2259         2924 :       CALL keyword_release(keyword)
    2260              :       CALL keyword_create(keyword, __LOCATION__, name="SPLITTING", &
    2261              :                           description="Will add the SOC-Splitting as additional output", &
    2262         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2263         2924 :       CALL section_add_keyword(print_key, keyword)
    2264         2924 :       CALL keyword_release(keyword)
    2265              :       CALL keyword_create(keyword, __LOCATION__, name="SOME", &
    2266              :                           description="Will add the SOC-Matrix as additional output in a different file", &
    2267         2924 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2268         2924 :       CALL section_add_keyword(print_key, keyword)
    2269         2924 :       CALL keyword_release(keyword)
    2270         2924 :       CALL section_add_subsection(subsection, print_key)
    2271         2924 :       CALL section_release(print_key)
    2272              : 
    2273              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="FORCES", &
    2274              :                                        description="Controls the calculation and printing of excited state forces. "// &
    2275              :                                        "This needs a RUN_TYPE that includes force evaluation, e.g. ENERGY_FORCE", &
    2276         2924 :                                        print_level=debug_print_level, filename="TDFORCE")
    2277              :       CALL keyword_create(keyword, __LOCATION__, name="LIST", &
    2278              :                           description="Specifies a list of states for the force calculations.", &
    2279              :                           usage="LIST {integer} {integer} .. {integer}", repeats=.TRUE., &
    2280         2924 :                           n_var=-1, type_of_var=integer_t)
    2281         2924 :       CALL section_add_keyword(print_key, keyword)
    2282         2924 :       CALL keyword_release(keyword)
    2283              :       CALL keyword_create(keyword, __LOCATION__, name="THRESHOLD", &
    2284              :                           description="Threshold for oszillator strength to screen states.", &
    2285              :                           usage="Threshold 0.01", &
    2286              :                           n_var=1, &
    2287              :                           type_of_var=real_t, &
    2288         2924 :                           default_r_val=0.0_dp)
    2289         2924 :       CALL section_add_keyword(print_key, keyword)
    2290         2924 :       CALL keyword_release(keyword)
    2291         2924 :       CALL section_add_subsection(subsection, print_key)
    2292         2924 :       CALL section_release(print_key)
    2293              : 
    2294         2924 :       CALL section_add_subsection(section, subsection)
    2295         2924 :       CALL section_release(subsection)
    2296              : 
    2297         2924 :    END SUBROUTINE create_tddfpt2_section
    2298              : 
    2299              : ! **************************************************************************************************
    2300              : !> \brief creates the stda input section (simplified Tamm Dancoff Approximation)
    2301              : !> \param section the section to create
    2302              : ! **************************************************************************************************
    2303         2924 :    SUBROUTINE create_stda_section(section)
    2304              :       TYPE(section_type), POINTER                        :: section
    2305              : 
    2306              :       TYPE(keyword_type), POINTER                        :: keyword
    2307              : 
    2308         2924 :       CPASSERT(.NOT. ASSOCIATED(section))
    2309              :       CALL section_create(section, __LOCATION__, name="sTDA", &
    2310              :                           description="parameters needed and setup for sTDA calculations", &
    2311         2924 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
    2312         2924 :       NULLIFY (keyword)
    2313              : 
    2314              :       CALL keyword_create(keyword, __LOCATION__, name="FRACTION", &
    2315              :                           variants=["HFX_FRACTION"], &
    2316              :                           description="The fraction of TB Hartree-Fock exchange to use in the Kernel. "// &
    2317              :                           "0.0 implies no HFX part is used in the kernel. ", &
    2318         5848 :                           usage="FRACTION 0.0", default_r_val=0.0_dp)
    2319         2924 :       CALL section_add_keyword(section, keyword)
    2320         2924 :       CALL keyword_release(keyword)
    2321              : 
    2322              :       ! even if scaling parameter for exchange FRACTION (see above) is zero, the semi-empirical electron repulsion
    2323              :       ! operator for exchange is not, so that a keyword is required to switch off sTDA exchange (if wanted)
    2324              :       CALL keyword_create(keyword, __LOCATION__, name="DO_EXCHANGE", &
    2325              :                           description="Explicitly including or switching off sTDA exchange", &
    2326         2924 :                           usage="DO_EXCHANGE", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
    2327         2924 :       CALL section_add_keyword(section, keyword)
    2328         2924 :       CALL keyword_release(keyword)
    2329              : 
    2330              :       CALL keyword_create(keyword, __LOCATION__, name="DO_EWALD", &
    2331              :                           description="Use Ewald type method for Coulomb interaction", &
    2332         2924 :                           usage="DO_EWALD", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2333         2924 :       CALL section_add_keyword(section, keyword)
    2334         2924 :       CALL keyword_release(keyword)
    2335              : 
    2336              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_TD_FILTER", &
    2337              :                           description="Threshold for filtering the transition density matrix", &
    2338         2924 :                           usage="EPS_TD_FILTER epsf", default_r_val=1.e-10_dp)
    2339         2924 :       CALL section_add_keyword(section, keyword)
    2340         2924 :       CALL keyword_release(keyword)
    2341              : 
    2342              :       CALL keyword_create(keyword, __LOCATION__, name="MATAGA_NISHIMOTO_CEXP", &
    2343              :                           description="Exponent used in Mataga-Nishimoto formula for Coulomb (alpha). "// &
    2344              :                           "Default value is method dependent!", &
    2345         2924 :                           usage="MATAGA_NISHIMOTO_CEXP cexp", default_r_val=-99.0_dp)
    2346         2924 :       CALL section_add_keyword(section, keyword)
    2347         2924 :       CALL keyword_release(keyword)
    2348              : 
    2349              :       CALL keyword_create(keyword, __LOCATION__, name="MATAGA_NISHIMOTO_XEXP", &
    2350              :                           description="Exponent used in Mataga-Nishimoto formula for Exchange (beta). "// &
    2351              :                           "Default value is method dependent!", &
    2352         2924 :                           usage="MATAGA_NISHIMOTO_XEXP xexp", default_r_val=-99.0_dp)
    2353         2924 :       CALL section_add_keyword(section, keyword)
    2354         2924 :       CALL keyword_release(keyword)
    2355              : 
    2356              :       CALL keyword_create(keyword, __LOCATION__, name="COULOMB_SR_CUT", &
    2357              :                           description="Maximum range of short range part of Coulomb interaction.", &
    2358         2924 :                           usage="COULOMB_SR_CUT rcut", default_r_val=20.0_dp)
    2359         2924 :       CALL section_add_keyword(section, keyword)
    2360         2924 :       CALL keyword_release(keyword)
    2361              : 
    2362              :       CALL keyword_create(keyword, __LOCATION__, name="COULOMB_SR_EPS", &
    2363              :                           description="Threshold for short range part of Coulomb interaction.", &
    2364         2924 :                           usage="COULOMB_SR_EPS sreps", default_r_val=1.e-03_dp)
    2365         2924 :       CALL section_add_keyword(section, keyword)
    2366         2924 :       CALL keyword_release(keyword)
    2367              : 
    2368         2924 :    END SUBROUTINE create_stda_section
    2369              : 
    2370              : ! **************************************************************************************************
    2371              : !> \brief creates the RES input section (Reduced Excitation Space)
    2372              : !> \param section the section to create
    2373              : ! **************************************************************************************************
    2374         2924 :    SUBROUTINE create_res_section(section)
    2375              :       TYPE(section_type), POINTER                        :: section
    2376              : 
    2377              :       TYPE(keyword_type), POINTER                        :: keyword
    2378              : 
    2379         2924 :       CPASSERT(.NOT. ASSOCIATED(section))
    2380              :       CALL section_create(section, __LOCATION__, name="REDUCED_EXCITATION_SPACE", &
    2381              :                           description="Sets up a restricted (reduced) excitation space for TDDFT", &
    2382         2924 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
    2383              : 
    2384         2924 :       NULLIFY (keyword)
    2385              :       CALL keyword_create(keyword, __LOCATION__, &
    2386              :                           name="_SECTION_PARAMETERS_", &
    2387              :                           description="Controls the activation of RES calculation.", &
    2388              :                           default_l_val=.FALSE., &
    2389         2924 :                           lone_keyword_l_val=.TRUE.)
    2390         2924 :       CALL section_add_keyword(section, keyword)
    2391         2924 :       CALL keyword_release(keyword)
    2392              : 
    2393              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_WINDOW", &
    2394              :                           description="Upper and lower cutoffs [eV] for orbitals to be included for excitations. ", &
    2395              :                           usage="ENERGY_WINDOW -5.0 0.0", default_r_vals=[-1.0E10_dp, 1.0E10_dp], &
    2396         2924 :                           type_of_var=real_t, unit_str="eV")
    2397         2924 :       CALL section_add_keyword(section, keyword)
    2398         2924 :       CALL keyword_release(keyword)
    2399              : 
    2400              :       CALL keyword_create(keyword, __LOCATION__, name="UPPER_ENERGY_CUTOFF", &
    2401              :                           description="Upper energy cutoff [eV] for orbitals to be included in excitations.", &
    2402              :                           usage="UPPER_ENERGY_CUTOFF -5.0", default_r_val=1.0E10_dp, &
    2403         2924 :                           type_of_var=real_t, unit_str="eV")
    2404         2924 :       CALL section_add_keyword(section, keyword)
    2405         2924 :       CALL keyword_release(keyword)
    2406              : 
    2407              :       CALL keyword_create(keyword, __LOCATION__, name="LOWER_ENERGY_CUTOFF", &
    2408              :                           description="Lower energy cutoff [eV] for orbitals to be included in excitations.", &
    2409              :                           usage="LOWER_ENERGY_CUTOFF -5.0", default_r_val=-1.0E10_dp, &
    2410         2924 :                           type_of_var=real_t, unit_str="eV")
    2411         2924 :       CALL section_add_keyword(section, keyword)
    2412         2924 :       CALL keyword_release(keyword)
    2413              : 
    2414              :       CALL keyword_create(keyword, __LOCATION__, name="MOLECULE_LIST", &
    2415              :                           description="Indices of molecules to be excited. "// &
    2416              :                           "This implies the calculation of molecular states through orbital location "// &
    2417              :                           "and subspace diagonalization.", &
    2418              :                           usage="MOLECULE_LIST {integer}  {integer} ..  {integer} ", &
    2419         2924 :                           n_var=-1, type_of_var=integer_t, repeats=.FALSE.)
    2420         2924 :       CALL section_add_keyword(section, keyword)
    2421         2924 :       CALL keyword_release(keyword)
    2422              : 
    2423         2924 :    END SUBROUTINE create_res_section
    2424              : 
    2425              : ! **************************************************************************************************
    2426              : !> \brief creates an input section for electronic band structure calculations
    2427              : !> \param section section to create
    2428              : !> \par History
    2429              : !>    * 07.2023 created [Jan Wilhelm]
    2430              : ! **************************************************************************************************
    2431         1462 :    SUBROUTINE create_bandstructure_section(section)
    2432              :       TYPE(section_type), POINTER                        :: section
    2433              : 
    2434              :       TYPE(keyword_type), POINTER                        :: keyword
    2435              :       TYPE(section_type), POINTER                        :: subsection
    2436              : 
    2437         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    2438              :       CALL section_create(section, __LOCATION__, name="BANDSTRUCTURE", &
    2439              :                           description="Parameters needed to set up a calculation for "// &
    2440              :                           "electronic level energies of molecules and the electronic band "// &
    2441              :                           "structure of materials from post-SCF schemes (GW, perturbative "// &
    2442              :                           "spin-orbit coupling from GTH pseudopotentials), and Floquet "// &
    2443              :                           "band structures as response to continuous driving with light.", &
    2444         1462 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
    2445              : 
    2446         1462 :       NULLIFY (keyword, subsection)
    2447              :       CALL keyword_create(keyword, __LOCATION__, &
    2448              :                           name="_SECTION_PARAMETERS_", &
    2449              :                           description="Controls the activation of the band structure calculation.", &
    2450              :                           default_l_val=.FALSE., &
    2451         1462 :                           lone_keyword_l_val=.TRUE.)
    2452         1462 :       CALL section_add_keyword(section, keyword)
    2453         1462 :       CALL keyword_release(keyword)
    2454              : 
    2455              :       ! here we generate a subsection for getting a k-point path for the bandstructure
    2456         1462 :       CALL create_kpoint_set_section(subsection, "BANDSTRUCTURE_PATH")
    2457         1462 :       CALL section_add_subsection(section, subsection)
    2458         1462 :       CALL section_release(subsection)
    2459              : 
    2460         1462 :       CALL create_gw_section(subsection)
    2461         1462 :       CALL section_add_subsection(section, subsection)
    2462         1462 :       CALL section_release(subsection)
    2463              : 
    2464         1462 :       CALL create_soc_section(subsection)
    2465         1462 :       CALL section_add_subsection(section, subsection)
    2466         1462 :       CALL section_release(subsection)
    2467              : 
    2468         1462 :       CALL create_dos_section(subsection)
    2469         1462 :       CALL section_add_subsection(section, subsection)
    2470         1462 :       CALL section_release(subsection)
    2471              : 
    2472         1462 :       CALL create_floquet_section(subsection)
    2473         1462 :       CALL section_add_subsection(section, subsection)
    2474         1462 :       CALL section_release(subsection)
    2475              : 
    2476         1462 :    END SUBROUTINE create_bandstructure_section
    2477              : 
    2478              : ! **************************************************************************************************
    2479              : !> \brief creates an input section for a GW calculation for the electronic band structure
    2480              : !> \param section section to create
    2481              : !> \par History
    2482              : !>    * 07.2023 created [Jan Wilhelm]
    2483              : ! **************************************************************************************************
    2484         1462 :    SUBROUTINE create_gw_section(section)
    2485              :       TYPE(section_type), POINTER                        :: section
    2486              : 
    2487              :       TYPE(keyword_type), POINTER                        :: keyword
    2488              :       TYPE(section_type), POINTER                        :: print_key, subsection
    2489              : 
    2490         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    2491              :       CALL section_create(section, __LOCATION__, name="GW", &
    2492              :                           description="Parameters needed to set up a GW calculation for "// &
    2493              :                           "electronic level energies $\varepsilon_{n\mathbf{k}}^{G_0W_0}$ "// &
    2494              :                           "of molecules and the band structure of materials: "// &
    2495              :                           "$\varepsilon_{n\mathbf{k}}^{G_0W_0}=  "// &
    2496              :                           "\varepsilon_{n\mathbf{k}}^\text{DFT}+\Sigma_{n\mathbf{k}} "// &
    2497              :                           "-v^\text{xc}_{n\mathbf{k}}$. "// &
    2498              :                           "For the GW algorithm for molecules, see \[Wilhelm2021\]. "// &
    2499              :                           "For 2D materials, see \[Graml2024\].", &
    2500              :                           citations=[Wilhelm2021, Graml2024], &
    2501         4386 :                           n_keywords=1, n_subsections=5, repeats=.FALSE.)
    2502              : 
    2503         1462 :       NULLIFY (keyword)
    2504              :       CALL keyword_create(keyword, __LOCATION__, &
    2505              :                           name="_SECTION_PARAMETERS_", &
    2506              :                           description="Controls the activation of the GW calculation.", &
    2507              :                           default_l_val=.FALSE., &
    2508         1462 :                           lone_keyword_l_val=.TRUE.)
    2509         1462 :       CALL section_add_keyword(section, keyword)
    2510         1462 :       CALL keyword_release(keyword)
    2511              : 
    2512              :       CALL keyword_create(keyword, __LOCATION__, name="NUM_TIME_FREQ_POINTS", &
    2513              :                           description="Number of discrete points for the imaginary-time "// &
    2514              :                           "grid and the imaginary-frequency grid. The more points, the more "// &
    2515              :                           "precise is the calculation. Typically, 10 points are good "// &
    2516              :                           "for 0.1 eV precision of band structures and molecular energy "// &
    2517              :                           "levels, 20 points for 0.03 eV precision, "// &
    2518              :                           "and 30 points for 0.01 eV precision, see Table I in "// &
    2519              :                           "\[Wilhelm2021\]. GW computation time "// &
    2520              :                           "increases linearly with `NUM_TIME_FREQ_POINTS`.", &
    2521              :                           usage="NUM_TIME_FREQ_POINTS 30", &
    2522         1462 :                           default_i_val=30)
    2523         1462 :       CALL section_add_keyword(section, keyword)
    2524         1462 :       CALL keyword_release(keyword)
    2525              : 
    2526              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
    2527              :                           description="Determines a threshold for the DBCSR based sparse "// &
    2528              :                           "multiplications. Normally, `EPS_FILTER` determines accuracy "// &
    2529              :                           "and timing of low-scaling GW calculations. (Lower filter means "// &
    2530              :                           "higher numerical precision, but higher computational cost.)", &
    2531              :                           usage="EPS_FILTER 1.0E-6", &
    2532         1462 :                           default_r_val=1.0E-8_dp)
    2533         1462 :       CALL section_add_keyword(section, keyword)
    2534         1462 :       CALL keyword_release(keyword)
    2535              : 
    2536              :       CALL keyword_create(keyword, __LOCATION__, name="REGULARIZATION_MINIMAX", &
    2537              :                           description="Parameter to regularize the Fourier transformation with minimax grids. "// &
    2538              :                           "In case the parameter 0.0 is chosen, no regularization is performed.", &
    2539              :                           usage="REGULARIZATION_MINIMAX 1.0E-4", &
    2540         1462 :                           default_r_val=-1.0_dp)
    2541         1462 :       CALL section_add_keyword(section, keyword)
    2542         1462 :       CALL keyword_release(keyword)
    2543              : 
    2544              :       CALL keyword_create(keyword, __LOCATION__, name="REGULARIZATION_RI", &
    2545              :                           description="Regularization applied to the GW RI fitting matrix "// &
    2546              :                           "$M_{PQ}$. A negative value selects the context-dependent default: "// &
    2547              :                           "zero for molecules and 1.0E-2 for periodic systems.", &
    2548              :                           usage="REGULARIZATION_RI 1.0E-4", &
    2549         1462 :                           default_r_val=-1.0_dp)
    2550         1462 :       CALL section_add_keyword(section, keyword)
    2551         1462 :       CALL keyword_release(keyword)
    2552              : 
    2553              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS_RI", &
    2554              :                           description="The cutoff radius (in Angstrom) for the truncated  "// &
    2555              :                           "Coulomb operator. The larger the cutoff radius, the faster "// &
    2556              :                           "converges the resolution of the identity (RI) with respect to the "// &
    2557              :                           "RI basis set size. Larger cutoff radius means higher computational "// &
    2558              :                           "cost.", &
    2559              :                           usage="CUTOFF_RADIUS_RI 3.0", &
    2560              :                           default_r_val=cp_unit_to_cp2k(value=3.0_dp, unit_str="angstrom"), &
    2561         1462 :                           type_of_var=real_t, unit_str="angstrom")
    2562         1462 :       CALL section_add_keyword(section, keyword)
    2563         1462 :       CALL keyword_release(keyword)
    2564              : 
    2565              :       CALL keyword_create(keyword, __LOCATION__, name="MEMORY_PER_PROC", &
    2566              :                           description="Specify the available memory per MPI process (in GB). The "// &
    2567              :                           "default value -1 means that the available memory per MPI process is detected "// &
    2568              :                           "automatically from the free memory of the node divided by the number "// &
    2569              :                           "of MPI processes running on that node; this is the recommended setting. "// &
    2570              :                           "Note: This keyword is not used for GW calculations with RI-RS, "// &
    2571              :                           "where the available memory is always detected automatically.", &
    2572              :                           usage="MEMORY_PER_PROC 16", &
    2573         1462 :                           default_r_val=-1.0_dp)
    2574         1462 :       CALL section_add_keyword(section, keyword)
    2575         1462 :       CALL keyword_release(keyword)
    2576              : 
    2577              :       CALL keyword_create(keyword, __LOCATION__, name="APPROX_KP_EXTRAPOL", &
    2578              :                           description="If true, use only a 4x4 kpoint mesh for frequency "// &
    2579              :                           "points $\omega_j, j \ge 2$ (instead of a 4x4 and 6x6 k-point mesh). "// &
    2580              :                           "The k-point extrapolation of $W_{PQ}(i\omega_j,\mathbf{q})$ "// &
    2581              :                           "is done approximately from $W_{PQ}(i\omega_1,\mathbf{q})$.", &
    2582              :                           usage="APPROX_KP_EXTRAPOL", &
    2583         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    2584         1462 :       CALL section_add_keyword(section, keyword)
    2585         1462 :       CALL keyword_release(keyword)
    2586              : 
    2587              :       CALL keyword_create(keyword, __LOCATION__, name="SIZE_LATTICE_SUM", &
    2588              :                           description="Parameter determines how many neighbor cells $\mathbf{R}$ "// &
    2589              :                           "are used for computing "// &
    2590              :                           "$V_{PQ}(\mathbf{k}) = "// &
    2591              :                           "\sum_{\mathbf{R}} e^{i\mathbf{k}\cdot\mathbf{R}}\,\langle P, "// &
    2592              :                           "\text{cell}{=}\mathbf{0}|1/r|Q,\text{cell}{=}\mathbf{R}\rangle$. "// &
    2593              :                           "Normally, parameter does not need to be touched.", &
    2594              :                           usage="SIZE_LATTICE_SUM 4", &
    2595         1462 :                           default_i_val=3)
    2596         1462 :       CALL section_add_keyword(section, keyword)
    2597         1462 :       CALL keyword_release(keyword)
    2598              : 
    2599              :       CALL keyword_create( &
    2600              :          keyword, __LOCATION__, name="KPOINTS_W", &
    2601              :          description="Monkhorst-Pack k-point mesh of size N_x, N_y, N_z for calculating "// &
    2602              :          "$W_{PQ}^\mathbf{R}=\int_\text{BZ}\frac{d\mathbf{k}}{\Omega_\text{BZ}}\, "// &
    2603              :          "e^{-i\mathbf{k}\cdot\mathbf{R}}\,W_{PQ}(\mathbf{k})$. "// &
    2604              :          "For non-periodic directions α, choose N_α = 1. "// &
    2605              :          "Automatic choice of the k-point mesh for negative "// &
    2606              :          "values, i.e. KPOINTS_W -1 -1 -1. "// &
    2607              :          "K-point extrapolation of W is automatically switched on.", &
    2608              :          usage="KPOINTS_W N_x  N_y  N_z", &
    2609         1462 :          n_var=3, type_of_var=integer_t, default_i_vals=[-1, -1, -1])
    2610         1462 :       CALL section_add_keyword(section, keyword)
    2611         1462 :       CALL keyword_release(keyword)
    2612              : 
    2613              :       CALL keyword_create(keyword, __LOCATION__, name="HEDIN_SHIFT", &
    2614              :                           description="If true, use Hedin's shift in G0W0, evGW and evGW0. "// &
    2615              :                           "Details see in Li et al. JCTC 18, 7570 "// &
    2616              :                           "(2022), Figure 1. G0W0 with Hedin's shift should give "// &
    2617              :                           "similar GW eigenvalues as evGW0; at a lower "// &
    2618              :                           "computational cost.", &
    2619              :                           usage="HEDIN_SHIFT", &
    2620              :                           default_l_val=.FALSE., &
    2621         1462 :                           lone_keyword_l_val=.TRUE.)
    2622         1462 :       CALL section_add_keyword(section, keyword)
    2623         1462 :       CALL keyword_release(keyword)
    2624              : 
    2625              :       CALL keyword_create(keyword, __LOCATION__, name="FREQ_MAX_FIT", &
    2626              :                           description="For analytic continuation, a fit on Σ(iω) is performed. "// &
    2627              :                           "This fit is then evaluated at a real frequency, Σ(ω), which is used "// &
    2628              :                           "in the quasiparticle equation "// &
    2629              :                           "$\varepsilon_{n\mathbf{k}}^{G_0W_0}=  "// &
    2630              :                           "\varepsilon_{n\mathbf{k}}^\text{DFT}+\Sigma_{n\mathbf{k}} "// &
    2631              :                           "-v^\text{xc}_{n\mathbf{k}}$. The keyword FREQ_MAX_FIT "// &
    2632              :                           "determines fitting range for the self-energy Σ(iω) on "// &
    2633              :                           "imaginary axis: i*[0, ω_max] for empty orbitals/bands, i*[-ω_max,0] "// &
    2634              :                           "for occ orbitals. A smaller ω_max might lead to better numerical "// &
    2635              :                           "stability (i.e., if you observe clearly wrong GW eigenvalues/bands "// &
    2636              :                           "around HOMO/LUMO, decreasing ω_max might fix this issue). "// &
    2637              :                           "A small benchmark of ω_max is contained in Fig. 5 of "// &
    2638              :                           "J. Wilhelm et al., JCTC 12, 3623-3635 (2016). "// &
    2639              :                           "Note that we used ω_max = 1 Ha = 27.211 eV in the benchmark "// &
    2640              :                           "M. Azizi et al., PRB 109, 245101 (2024).", &
    2641              :                           unit_str="eV", &
    2642              :                           usage="FREQ_MAX_FIT 20.0", &
    2643         1462 :                           default_r_val=cp_unit_to_cp2k(value=10.0_dp, unit_str="eV"))
    2644         1462 :       CALL section_add_keyword(section, keyword)
    2645         1462 :       CALL keyword_release(keyword)
    2646              : 
    2647         1462 :       NULLIFY (subsection)
    2648              :       CALL section_create(subsection, __LOCATION__, name="COHSEX", &
    2649              :                           description="Static Coulomb-hole screened-exchange (COHSEX) approximation "// &
    2650              :                           "and scaling of its correlation self-energy.", &
    2651         1462 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
    2652              : 
    2653         1462 :       NULLIFY (keyword)
    2654              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    2655              :                           description="Static Coulomb-hole screened-exchange (COHSEX) approximation to "// &
    2656              :                           "$G_0W_0$. Only the static screened Coulomb interaction $W(\omega=0)$ is computed; "// &
    2657              :                           "its correlation part $W^\text{c}(0) = W(0) - v$ gives the static correlation "// &
    2658              :                           "self-energy $\Sigma^\text{c}_{mn} = \frac{1}{2}\sum_p \text{sgn}(\varepsilon_p - "// &
    2659              :                           "\varepsilon_\text{F})\, W^\text{c}_{mp,pn}(\omega=0)$. The quasiparticle Hamiltonian "// &
    2660              :                           "$H^\text{QP}_{mn} = \varepsilon_n^\text{DFT}\delta_{mn} + \Sigma^\text{x}_{mn} - "// &
    2661              :                           "v^\text{xc}_{mn} + \Sigma^\text{c}_{mn}$ is built in the Kohn-Sham MO basis; its "// &
    2662              :                           "occupied-virtual blocks are set to zero. The quasiparticle energies are written to "// &
    2663              :                           "the file Quasiparticle_energies_singlepole.", &
    2664              :                           usage="&COHSEX QP_UPDATE", &
    2665              :                           enum_c_vals=s2a("OFF", "DIAGONAL", "QP_UPDATE"), &
    2666              :                           enum_i_vals=[cohsex_off, cohsex_diagonal, cohsex_qp_update], &
    2667              :                           enum_desc=s2a("No static COHSEX (default without the section).", &
    2668              :                                         "Diagonal static COHSEX (Hedin 1965; Hybertsen and Louie 1986): the "// &
    2669              :                                         "quasiparticle energies are the diagonal elements "// &
    2670              :                                         "$\varepsilon_n^\text{DG} = H^\text{QP}_{nn}$. "// &
    2671              :                                         "Default of the section without a parameter.", &
    2672              :                                         "Static COHSEX with quasiparticle update (Tyagi and Voora 2024): "// &
    2673              :                                         "$H^\text{QP}$ is diagonalized, giving the canonical static COHSEX "// &
    2674              :                                         "energies $\varepsilon_n^\text{CN}$ and MOs. Both "// &
    2675              :                                         "$\varepsilon_n^\text{DG}$ and $\varepsilon_n^\text{CN}$ are printed, "// &
    2676              :                                         "the MOs at the $\Gamma$ point with DFT%PRINT%MO and DFT%PRINT%MO_CUBES."), &
    2677              :                           citations=[Hedin1965, Hybertsen1986, Tyagi2024], &
    2678         5848 :                           default_i_val=cohsex_off, lone_keyword_i_val=cohsex_diagonal)
    2679         1462 :       CALL section_add_keyword(subsection, keyword)
    2680         1462 :       CALL keyword_release(keyword)
    2681              : 
    2682              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_OCC", &
    2683              :                           description="Scaling factor of the static COHSEX correlation self-energy in the "// &
    2684              :                           "occupied-occupied block of $H^\text{QP}$.", &
    2685              :                           usage="SCALE_OCC 0.6", &
    2686              :                           citations=[Tyagi2026], &
    2687         2924 :                           default_r_val=1.0_dp)
    2688         1462 :       CALL section_add_keyword(subsection, keyword)
    2689         1462 :       CALL keyword_release(keyword)
    2690              : 
    2691              :       CALL keyword_create(keyword, __LOCATION__, name="SCALE_VIRT", &
    2692              :                           description="Scaling factor of the static COHSEX correlation self-energy in the "// &
    2693              :                           "virtual-virtual block of $H^\text{QP}$.", &
    2694              :                           usage="SCALE_VIRT 0.6", &
    2695              :                           citations=[Tyagi2026], &
    2696         2924 :                           default_r_val=1.0_dp)
    2697         1462 :       CALL section_add_keyword(subsection, keyword)
    2698         1462 :       CALL keyword_release(keyword)
    2699              : 
    2700         1462 :       CALL section_add_subsection(section, subsection)
    2701         1462 :       CALL section_release(subsection)
    2702              : 
    2703         1462 :       NULLIFY (subsection, print_key)
    2704              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
    2705              :                           description="Printing of GW restarts.", &
    2706         1462 :                           n_keywords=2, n_subsections=1, repeats=.FALSE.)
    2707              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
    2708              :                                        description="Controls the printing of restart files "// &
    2709              :                                        "for χ, W, Σ.", &
    2710              :                                        filename="", print_level=low_print_level, &
    2711         1462 :                                        common_iter_levels=3)
    2712         1462 :       CALL section_add_subsection(subsection, print_key)
    2713         1462 :       CALL section_release(print_key)
    2714              : 
    2715         1462 :       CALL section_add_subsection(section, subsection)
    2716         1462 :       CALL section_release(subsection)
    2717              : 
    2718         1462 :       NULLIFY (subsection)
    2719         1462 :       CALL create_ri_rs_section(subsection)
    2720         1462 :       CALL section_add_subsection(section, subsection)
    2721         1462 :       CALL section_release(subsection)
    2722              : 
    2723         1462 :       NULLIFY (subsection)
    2724         1462 :       CALL create_auto_ri_section(subsection)
    2725         1462 :       CALL section_add_subsection(section, subsection)
    2726         1462 :       CALL section_release(subsection)
    2727              : 
    2728         1462 :       NULLIFY (subsection)
    2729         1462 :       CALL create_evgw0_section(subsection)
    2730         1462 :       CALL section_add_subsection(section, subsection)
    2731         1462 :       CALL section_release(subsection)
    2732              : 
    2733         1462 :    END SUBROUTINE create_gw_section
    2734              : 
    2735              : ! **************************************************************************************************
    2736              : !> \brief Creates the automatic RI basis set optimization section.
    2737              : !> \param section AUTO_RI input section
    2738              : ! **************************************************************************************************
    2739         1462 :    SUBROUTINE create_auto_ri_section(section)
    2740              :       TYPE(section_type), POINTER                        :: section
    2741              : 
    2742              :       TYPE(keyword_type), POINTER                        :: keyword
    2743              : 
    2744         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    2745              :       CALL section_create(section, __LOCATION__, name="AUTO_RI", &
    2746              :                           description="Optimizes the RI basis for non-periodic RI-RS GW "// &
    2747              :                           "calculations. The fitting target combines occupied-empty "// &
    2748              :                           "transitions and exchange products. Atom-local (AA) functions are "// &
    2749              :                           "selected first. Neighbor-pair (AB) functions are also used to fit "// &
    2750              :                           "occupied-empty transitions and exchange products. Currently only "// &
    2751              :                           "non-periodic molecules are supported.", &
    2752         1462 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
    2753         1462 :       NULLIFY (keyword)
    2754              :       CALL keyword_create(keyword, __LOCATION__, name="RI_AO_RATIO", &
    2755              :                           description="Ratio between the numbers of optimized RI and AO basis "// &
    2756              :                           "functions. For example, RI_AO_RATIO 3 requires an RI basis with "// &
    2757              :                           "three times as many functions as the AO basis. Compare values such "// &
    2758              :                           "as 1, 1.5, 2, 3 and 4 until the GW energies are converged. "// &
    2759              :                           "Larger values increase time and memory, but also increase the "// &
    2760              :                           "numerical accuracy.", &
    2761         1462 :                           default_r_val=2.0_dp, usage="RI_AO_RATIO 2")
    2762         1462 :       CALL section_add_keyword(section, keyword)
    2763         1462 :       CALL keyword_release(keyword)
    2764              : 
    2765              :       CALL keyword_create(keyword, __LOCATION__, name="OCC_EMPTY_FRONTIER_ORBITAL_WINDOW", &
    2766              :                           description="The exchange contribution to the RI optimization "// &
    2767              :                           "objective includes GW levels within the energy window "// &
    2768              :                           "$[\epsilon_{\mathrm{HOMO}}-w,\epsilon_{\mathrm{LUMO}}+w]$. "// &
    2769              :                           "The default of 5 eV is usually sufficient, for example for "// &
    2770              :                           "GW-BSE excitations up to 10 eV.", &
    2771              :                           default_r_val=cp_unit_to_cp2k(value=5.0_dp, unit_str="eV"), &
    2772         1462 :                           unit_str="eV", usage="OCC_EMPTY_FRONTIER_ORBITAL_WINDOW [eV] 5.0")
    2773         1462 :       CALL section_add_keyword(section, keyword)
    2774         1462 :       CALL keyword_release(keyword)
    2775              : 
    2776              :       CALL keyword_create(keyword, __LOCATION__, name="NEIGHBOR_RADIUS", &
    2777              :                           description="The RI basis also contains contractions of Gaussian "// &
    2778              :                           "functions centered on different atoms. An atom pair A-B is "// &
    2779              :                           "included for these contractions when its distance is smaller than "// &
    2780              :                           "NEIGHBOR_RADIUS. Larger radii increase the computational cost. "// &
    2781              :                           "Three angstrom is a reasonable value and usually does not need to "// &
    2782              :                           "be changed.", &
    2783              :                           default_r_val=cp_unit_to_cp2k(value=3.0_dp, unit_str="angstrom"), &
    2784         1462 :                           unit_str="angstrom", usage="NEIGHBOR_RADIUS [angstrom] 3.0")
    2785         1462 :       CALL section_add_keyword(section, keyword)
    2786         1462 :       CALL keyword_release(keyword)
    2787              : 
    2788         1462 :    END SUBROUTINE create_auto_ri_section
    2789              : 
    2790              : ! **************************************************************************************************
    2791              : !> \brief creates the input section collecting all parameters of the real-space resolution of
    2792              : !>        the identity (RI-RS) used in GW
    2793              : !> \param section section to create
    2794              : ! **************************************************************************************************
    2795         1462 :    SUBROUTINE create_ri_rs_section(section)
    2796              :       TYPE(section_type), POINTER                        :: section
    2797              : 
    2798              :       TYPE(keyword_type), POINTER                        :: keyword
    2799              :       TYPE(section_type), POINTER                        :: subsection
    2800              : 
    2801         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    2802              :       CALL section_create(section, __LOCATION__, name="RI_RS", &
    2803              :                           description="Real-Space Resolution of Identity (RI-RS) method. This "// &
    2804              :                           "approximation replaces the conventional 3-center RI integrals "// &
    2805              :                           "$(\mu\nu|P)$ by a factorized representation on an atom-centered "// &
    2806              :                           "real-space grid with points $\mathbf{r}_\ell$: "// &
    2807              :                           "$(\mu\nu|P) \approx \sum_\ell \varphi_\mu(\mathbf{r}_\ell) "// &
    2808              :                           "\varphi_\nu(\mathbf{r}_\ell) Z_{\ell P}$. "// &
    2809              :                           "The coefficients $Z_{\ell P}$ combine the numerical integration "// &
    2810              :                           "weights and the Coulomb potential of the auxiliary basis function "// &
    2811              :                           "$P$ evaluated at grid point $\mathbf{r}_\ell$. To reduce the "// &
    2812              :                           "computational cost, only grid points within the sphere $B^P$ around "// &
    2813              :                           "atom $P$ are included, i.e. the points with "// &
    2814              :                           "$|\mathbf{r}_\ell - \mathbf{R}_P| < R_c + r_P$. "// &
    2815              :                           "Here, $r_P$ is the effective radius of the most diffuse RI "// &
    2816              :                           "auxiliary Gaussian on atom $P$, at which the basis function "// &
    2817              :                           "magnitude falls below a threshold $\delta$ "// &
    2818              :                           "(currently controlled through EPS_FILTER). "// &
    2819              :                           "This locality approximation yields a sparse representation of the "// &
    2820              :                           "3-center integrals and enables reduced computational cost. "// &
    2821              :                           "See details in \[Duchemin2019\].", &
    2822              :                           citations=[Duchemin2019, Duchemin2021], &
    2823         4386 :                           n_keywords=11, n_subsections=1, repeats=.FALSE.)
    2824              : 
    2825         1462 :       NULLIFY (keyword)
    2826              :       CALL keyword_create(keyword, __LOCATION__, &
    2827              :                           name="_SECTION_PARAMETERS_", &
    2828              :                           description="Controls the activation of RI-RS in the GW calculation. "// &
    2829              :                           "An empty section, &RI_RS ... &END RI_RS, switches RI-RS on with "// &
    2830              :                           "default parameters.", &
    2831              :                           usage="&RI_RS .TRUE.", &
    2832              :                           default_l_val=.FALSE., &
    2833         1462 :                           lone_keyword_l_val=.TRUE.)
    2834         1462 :       CALL section_add_keyword(section, keyword)
    2835         1462 :       CALL keyword_release(keyword)
    2836              : 
    2837              :       CALL keyword_create(keyword, __LOCATION__, name="TIKHONOV", &
    2838              :                           description="Regularization parameter $\alpha$ used to stabilize "// &
    2839              :                           "the inversion of the grid-overlap matrix "// &
    2840              :                           "$D$ in the RI-RS method. "// &
    2841              :                           "See Equation (9) in \[Duchemin2019\].", &
    2842              :                           usage="TIKHONOV 1.0E-8", &
    2843         1462 :                           default_r_val=1.0E-08_dp)
    2844         1462 :       CALL section_add_keyword(section, keyword)
    2845         1462 :       CALL keyword_release(keyword)
    2846              : 
    2847              :       CALL keyword_create(keyword, __LOCATION__, name="GRID_SELECT", &
    2848              :                           description="Selection of the atom-centered grid type used "// &
    2849              :                           "in RI-RS optimized by Duchemin and Blase. "// &
    2850              :                           "(1) def2-TZVPP: Available for elements up to the fourth row "// &
    2851              :                           "of the periodic table (see \[Duchemin2021\]). "// &
    2852              :                           "(2) cc-pVTZ: Available for H, C, N, and O atoms "// &
    2853              :                           "(see \[Duchemin2019\]). "// &
    2854              :                           "(3) User-provided grids: per-element grid files supplied by the "// &
    2855              :                           "user, read as ri_rs_grid/<Element><suffix> in the same format as "// &
    2856              :                           "the built-in sets, with the suffix _rirs.ion.", &
    2857              :                           usage="GRID_SELECT 1", &
    2858         1462 :                           default_i_val=1)
    2859         1462 :       CALL section_add_keyword(section, keyword)
    2860         1462 :       CALL keyword_release(keyword)
    2861              : 
    2862              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS_RL_AO", &
    2863              :                           description="Real-space cutoff radius (in Angstrom) for evaluating "// &
    2864              :                           "the AO basis functions on the RI-RS grid. Override the default radius "// &
    2865              :                           "derived automatically from the most diffuse AO Gaussian on each atom. ", &
    2866              :                           usage="CUTOFF_RADIUS_RL_AO 8.0", &
    2867              :                           default_r_val=cp_unit_to_cp2k(value=-1.0_dp, unit_str="angstrom"), &
    2868         1462 :                           type_of_var=real_t, unit_str="angstrom")
    2869         1462 :       CALL section_add_keyword(section, keyword)
    2870         1462 :       CALL keyword_release(keyword)
    2871              : 
    2872              :       CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS_RL_W", &
    2873              :                           description="Real-space truncation radius (Angstrom) for the grid-basis "// &
    2874              :                           "G operators in the RI-RS GW self-energy. "// &
    2875              :                           "Default -1.0 disables the truncation (exact grid-basis operators).", &
    2876              :                           usage="CUTOFF_RADIUS_RL_W 20.0", &
    2877              :                           default_r_val=cp_unit_to_cp2k(value=-1.0_dp, unit_str="angstrom"), &
    2878         1462 :                           type_of_var=real_t, unit_str="angstrom")
    2879         1462 :       CALL section_add_keyword(section, keyword)
    2880         1462 :       CALL keyword_release(keyword)
    2881              : 
    2882         1462 :       NULLIFY (subsection)
    2883         1462 :       CALL create_ri_rs_grid_optimization_section(subsection)
    2884         1462 :       CALL section_add_subsection(section, subsection)
    2885         1462 :       CALL section_release(subsection)
    2886              : 
    2887         1462 :    END SUBROUTINE create_ri_rs_section
    2888              : 
    2889              : ! **************************************************************************************************
    2890              : !> \brief Creates the GW RI-RS in-memory grid optimizer section.
    2891              : !> \param section ...
    2892              : ! **************************************************************************************************
    2893         1462 :    SUBROUTINE create_ri_rs_grid_optimization_section(section)
    2894              :       TYPE(section_type), POINTER                        :: section
    2895              : 
    2896              :       TYPE(keyword_type), POINTER                        :: keyword
    2897         1462 :       NULLIFY (keyword)
    2898         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    2899              :       CALL section_create( &
    2900              :          section, __LOCATION__, name="GRID_OPTIMIZATION", repeats=.FALSE., &
    2901              :          description="Optimizes RI-RS grid using small local atomic environments. For every atom "// &
    2902              :          "in the structure, a cluster is formed from all atoms whose distance from the centre atom "// &
    2903              :          "is smaller than CUTOFF_ATOMIC_CLUSTER. The grid points are optimized such that the "// &
    2904              :          "corresponding RI-RS three-centre integrals reproduce the analytic integrals: "// &
    2905              :          "For a cluster $C_I$, the normalized squared RI-RS error is "// &
    2906              :          "$E_I = \frac{1}{N_I} \sum_{P\mu\nu \in C_I} \left|(\mu\nu|P) - "// &
    2907              :          "\sum_{\mathbf{r}_{A\ell} \in C_I} \phi_\mu(\mathbf{r}_{A\ell}) "// &
    2908              :          "\phi_\nu(\mathbf{r}_{A\ell}) Z_{A\ell P}\right|^2$. The total objective is "// &
    2909              :          "the average over all local clusters, $E_\mathrm{loc} = \frac{1}{N_\mathrm{at}} "// &
    2910              :          "\sum_{I=1}^{N_\mathrm{at}} E_I$. Starting points are generated on radial-Lebedev grids "// &
    2911              :          "and selected by diagonal Cholesky decomposition in independent atomic clusters. "// &
    2912              :          "If the selection reaches numerical rank before the requested grid size, unused points "// &
    2913              :          "in the central atom's Voronoi cell are added by geometric maximin distance. "// &
    2914              :          "Before Voronoi filtering, the candidate grid contains at least "// &
    2915              :          "max(30, 2 RS_AO_RATIO) times the number of AO functions. RS_AO_RATIO is the sole "// &
    2916              :          "control of the retained points per atom. "// &
    2917              :          "The optimization adapts the grid to the chemical environment and composition of the "// &
    2918              :          "structure and can permit substantially smaller grids. Compact grids often work well for "// &
    2919              :          "small basis sets, but RS_AO_RATIO "// &
    2920         1462 :          "should be tuned and converged for the chosen basis sets and chemical system.")
    2921              : 
    2922              :       CALL keyword_create( &
    2923              :          keyword, __LOCATION__, name="RS_AO_RATIO", &
    2924              :          description="Number of retained real-space points per atomic-orbital (AO) basis function. "// &
    2925              :          "For every atom A, the count is $N_R^A=\lceil\alpha N_{\mathrm{AO}}^A\rceil$, where "// &
    2926              :          "$\alpha$ is RS_AO_RATIO and $N_{\mathrm{AO}}^A$ is that atom's number of AO functions. ", &
    2927         1462 :          usage="RS_AO_RATIO 7", default_r_val=7.0_dp)
    2928         1462 :       CALL section_add_keyword(section, keyword)
    2929         1462 :       CALL keyword_release(keyword)
    2930              : 
    2931              :       CALL keyword_create( &
    2932              :          keyword, __LOCATION__, name="CUTOFF_ATOMIC_CLUSTER", &
    2933              :          description="Radius of the atom-centred cluster used to optimize the grid points. "// &
    2934              :          "All atoms within this distance of the centre atom are included.", &
    2935              :          usage="CUTOFF_ATOMIC_CLUSTER [angstrom] 3.0", type_of_var=real_t, &
    2936              :          default_r_val=cp_unit_to_cp2k(value=3.0_dp, unit_str="angstrom"), &
    2937         1462 :          unit_str="angstrom")
    2938         1462 :       CALL section_add_keyword(section, keyword)
    2939         1462 :       CALL keyword_release(keyword)
    2940              : 
    2941              :       CALL keyword_create( &
    2942              :          keyword, __LOCATION__, name="MAX_ITER", &
    2943              :          description="Maximum number of objective-and-gradient evaluations in the single "// &
    2944              :          "cooperative Cartesian grid optimization.", &
    2945         1462 :          usage="MAX_ITER 300", default_i_val=300)
    2946         1462 :       CALL section_add_keyword(section, keyword)
    2947         1462 :       CALL keyword_release(keyword)
    2948              : 
    2949         1462 :    END SUBROUTINE create_ri_rs_grid_optimization_section
    2950              : 
    2951              : ! **************************************************************************************************
    2952              : !> \brief creates the input section for eigenvalue self-consistent GW0 (evGW0)
    2953              : !> \param section section to create
    2954              : ! **************************************************************************************************
    2955         1462 :    SUBROUTINE create_evgw0_section(section)
    2956              :       TYPE(section_type), POINTER                        :: section
    2957              : 
    2958              :       TYPE(keyword_type), POINTER                        :: keyword
    2959              : 
    2960         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    2961              :       CALL section_create(section, __LOCATION__, name="EVGW0", &
    2962              :                           description="Eigenvalue self-consistent GW0. The quasiparticle "// &
    2963              :                           "energies replace the Kohn-Sham eigenvalues in the Green's function "// &
    2964              :                           "and the cycle is repeated, while the screened Coulomb interaction "// &
    2965              :                           "$W$ stays at its RPA@DFT value. Only the correlation self-energy "// &
    2966              :                           "and the quasiparticle equation are recomputed per cycle; $W$, the "// &
    2967              :                           "exchange self-energy and the RI-RS grid quantities are computed "// &
    2968              :                           "once. This implementation requires RI-RS. Without this section a "// &
    2969              :                           "single-shot G0W0 calculation is performed.", &
    2970         1462 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
    2971              : 
    2972         1462 :       NULLIFY (keyword)
    2973              :       CALL keyword_create(keyword, __LOCATION__, &
    2974              :                           name="_SECTION_PARAMETERS_", &
    2975              :                           description="Controls the activation of evGW0. An empty section, "// &
    2976              :                           "&EVGW0 ... &END EVGW0, switches evGW0 on with default parameters.", &
    2977              :                           usage="&EVGW0 .TRUE.", &
    2978              :                           default_l_val=.FALSE., &
    2979         1462 :                           lone_keyword_l_val=.TRUE.)
    2980         1462 :       CALL section_add_keyword(section, keyword)
    2981         1462 :       CALL keyword_release(keyword)
    2982              : 
    2983              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
    2984              :                           description="Maximum number of evGW0 cycles.", &
    2985              :                           usage="MAX_ITER 20", &
    2986         1462 :                           default_i_val=20)
    2987         1462 :       CALL section_add_keyword(section, keyword)
    2988         1462 :       CALL keyword_release(keyword)
    2989              : 
    2990              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
    2991              :                           description="Target accuracy of the eigenvalue self-consistency. "// &
    2992              :                           "The cycle stops once the quasiparticle HOMO, the quasiparticle "// &
    2993              :                           "LUMO and the HOMO-LUMO gap all change by less than this value "// &
    2994              :                           "between two successive cycles. Unit: Hartree.", &
    2995              :                           usage="EPS_ITER 0.00005", &
    2996         1462 :                           default_r_val=5.0E-5_dp)
    2997         1462 :       CALL section_add_keyword(section, keyword)
    2998         1462 :       CALL keyword_release(keyword)
    2999              : 
    3000         1462 :    END SUBROUTINE create_evgw0_section
    3001              : 
    3002              : ! **************************************************************************************************
    3003              : !> \brief creates an input section for calculation SOC for the electronic band structure
    3004              : !> \param section section to create
    3005              : !> \par History
    3006              : !>    * 09.2023 created [Jan Wilhelm]
    3007              : ! **************************************************************************************************
    3008         1462 :    SUBROUTINE create_soc_section(section)
    3009              :       TYPE(section_type), POINTER                        :: section
    3010              : 
    3011              :       TYPE(keyword_type), POINTER                        :: keyword
    3012              : 
    3013         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    3014              :       CALL section_create(section, __LOCATION__, name="SOC", &
    3015              :                           description="Switch on or off spin-orbit coupling. Use SOC "// &
    3016              :                           "parameters from non-local pseudopotentials as given in "// &
    3017              :                           "Hartwigsen, Goedecker, Hutter, Eq.(18), (19), "// &
    3018              :                           "\[Hartwigsen1998\], with "// &
    3019              :                           "$V_{\mu\nu}^{\mathrm{SOC}, (\alpha)} = "// &
    3020              :                           "(\hbar/2) \langle \phi_\mu | \sum_l \Delta "// &
    3021              :                           "V_l^\mathrm{SO}(\mathbf{r},\mathbf{r}') "// &
    3022              :                           "L^{(\alpha)} | \phi_\nu \rangle, "// &
    3023              :                           "\alpha = x, y, z$.", citations=[Hartwigsen1998], &
    3024         2924 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
    3025              : 
    3026         1462 :       NULLIFY (keyword)
    3027              :       CALL keyword_create(keyword, __LOCATION__, &
    3028              :                           name="_SECTION_PARAMETERS_", &
    3029              :                           description="Controls the activation of the SOC calculation.", &
    3030              :                           default_l_val=.FALSE., &
    3031         1462 :                           lone_keyword_l_val=.TRUE.)
    3032         1462 :       CALL section_add_keyword(section, keyword)
    3033         1462 :       CALL keyword_release(keyword)
    3034              : 
    3035              :       CALL keyword_create(keyword, __LOCATION__, name="SOC_WINDOW_OCC", &
    3036              :                           description="Apply SOC only for states with eigenvalues below VBM "// &
    3037              :                           "in the interval $[\varepsilon_\mathrm{VBM}-E_\mathrm{window\_occ}, \ "// &
    3038              :                           "\varepsilon_\mathrm{VBM}]$. "// &
    3039              :                           "to use for large systems to prevent numerical instabilities.", &
    3040              :                           usage="SOC_WINDOW_OCC 5.0", &
    3041              :                           default_r_val=-1.0_dp, &
    3042         1462 :                           unit_str="eV")
    3043         1462 :       CALL section_add_keyword(section, keyword)
    3044         1462 :       CALL keyword_release(keyword)
    3045              : 
    3046              :       CALL keyword_create(keyword, __LOCATION__, name="SOC_WINDOW_VIRT", &
    3047              :                           description="Apply SOC only for states with eigenvalues above CBM "// &
    3048              :                           "in the interval $[\varepsilon_\mathrm{CBM},\ "// &
    3049              :                           "\varepsilon_\mathrm{CBM}+E_\mathrm{window\_virt}]$, "// &
    3050              :                           "to use for large systems to prevent numerical instabilities.", &
    3051              :                           usage="SOC_WINDOW_VIRT 5.0", &
    3052              :                           default_r_val=-1.0_dp, &
    3053         1462 :                           unit_str="eV")
    3054         1462 :       CALL section_add_keyword(section, keyword)
    3055         1462 :       CALL keyword_release(keyword)
    3056              : 
    3057              :       CALL keyword_create(keyword, __LOCATION__, name="SOC_WINDOW_SMEARING", &
    3058              :                           description="Width of the Fermi-like smoothing at the SOC energy-window edge. "// &
    3059              :                           "Default reproduces the value of 1 eV. "// &
    3060              :                           "only effective when at least one SOC window is active.", &
    3061              :                           usage="SOC_WINDOW_SMEARING 1.0", &
    3062              :                           default_r_val=cp_unit_to_cp2k(value=1.0_dp, unit_str="eV"), &
    3063         1462 :                           unit_str="eV")
    3064         1462 :       CALL section_add_keyword(section, keyword)
    3065         1462 :       CALL keyword_release(keyword)
    3066              : 
    3067              :       CALL keyword_create(keyword, __LOCATION__, name="SOC_NBANDS_OCC", &
    3068              :                           description="Truncate the second-variational SOC diagonalization to this "// &
    3069              :                           "many occupied bands below the Fermi level (per spin). Must be used "// &
    3070              :                           "together with SOC_NBANDS_VIRT. Default -1 = off. ", &
    3071              :                           usage="SOC_NBANDS_OCC 2000", &
    3072         1462 :                           default_i_val=-1)
    3073         1462 :       CALL section_add_keyword(section, keyword)
    3074         1462 :       CALL keyword_release(keyword)
    3075              : 
    3076              :       CALL keyword_create(keyword, __LOCATION__, name="SOC_NBANDS_VIRT", &
    3077              :                           description="Truncate the second-variational SOC diagonalization to this "// &
    3078              :                           "many virtual bands above the Fermi level (per spin). See SOC_NBANDS_OCC. "// &
    3079              :                           "Default -1 = off.", &
    3080              :                           usage="SOC_NBANDS_VIRT 2000", &
    3081         1462 :                           default_i_val=-1)
    3082         1462 :       CALL section_add_keyword(section, keyword)
    3083         1462 :       CALL keyword_release(keyword)
    3084              : 
    3085         1462 :    END SUBROUTINE create_soc_section
    3086              : 
    3087              : ! **************************************************************************************************
    3088              : !> \brief input section for computing the density of states and the projected density of states
    3089              : !> \param section section to create
    3090              : !> \par History
    3091              : !>    * 09.2023 created [Jan Wilhelm]
    3092              : ! **************************************************************************************************
    3093         1462 :    SUBROUTINE create_dos_section(section)
    3094              :       TYPE(section_type), POINTER                        :: section
    3095              : 
    3096              :       TYPE(keyword_type), POINTER                        :: keyword
    3097              :       TYPE(section_type), POINTER                        :: subsection
    3098              : 
    3099         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    3100              :       CALL section_create(section, __LOCATION__, name="DOS", &
    3101              :                           description="Parameters needed to calculate the density of states "// &
    3102              :                           "(DOS) and the projected density of states (PDOS).", &
    3103         1462 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
    3104              : 
    3105         1462 :       NULLIFY (keyword)
    3106              :       CALL keyword_create(keyword, __LOCATION__, &
    3107              :                           name="_SECTION_PARAMETERS_", &
    3108              :                           description="Controls the activation of the DOS calculation.", &
    3109              :                           default_l_val=.FALSE., &
    3110         1462 :                           lone_keyword_l_val=.TRUE.)
    3111         1462 :       CALL section_add_keyword(section, keyword)
    3112         1462 :       CALL keyword_release(keyword)
    3113              : 
    3114              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_WINDOW", &
    3115              :                           description="Print DOS and PDOS in the energy window "// &
    3116              :                           "$[\varepsilon_\mathrm{VBM}-E_\mathrm{window}/2,  "// &
    3117              :                           "\varepsilon_\mathrm{CBM}+E_\mathrm{window}/2]$,"// &
    3118              :                           " where VBM is the valence "// &
    3119              :                           "band maximum (or highest occupied molecular orbital, HOMO, for "// &
    3120              :                           "molecules) and CBM the conduction band minimum (or lowest "// &
    3121              :                           "unoccupied molecular orbital, LUMO, for molecules).", &
    3122              :                           usage="ENERGY_WINDOW 5.0", &
    3123              :                           default_r_val=cp_unit_to_cp2k(value=10.0_dp, unit_str="eV"), &
    3124         1462 :                           unit_str="eV")
    3125         1462 :       CALL section_add_keyword(section, keyword)
    3126         1462 :       CALL keyword_release(keyword)
    3127              : 
    3128              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_STEP", &
    3129              :                           description="Resolution of the energy E when computing the $\rho(E)$.", &
    3130              :                           usage="ENERGY_STEP 0.01", &
    3131              :                           default_r_val=cp_unit_to_cp2k(value=0.01_dp, unit_str="eV"), &
    3132         1462 :                           unit_str="eV")
    3133         1462 :       CALL section_add_keyword(section, keyword)
    3134         1462 :       CALL keyword_release(keyword)
    3135              : 
    3136              :       CALL keyword_create(keyword, __LOCATION__, name="BROADENING", &
    3137              :                           description="Broadening α in Gaussians used in the DOS; "// &
    3138              :                           "$\rho(E) = \sum_n \exp(((E-\varepsilon_n)/\alpha)^2)/("// &
    3139              :                           " \sqrt{2\pi} \alpha)$.", &
    3140              :                           usage="BROADENING 0.01", &
    3141              :                           default_r_val=cp_unit_to_cp2k(value=0.01_dp, unit_str="eV"), &
    3142         1462 :                           unit_str="eV")
    3143         1462 :       CALL section_add_keyword(section, keyword)
    3144         1462 :       CALL keyword_release(keyword)
    3145              : 
    3146              :       CALL keyword_create( &
    3147              :          keyword, __LOCATION__, name="KPOINTS", &
    3148              :          description="Monkhorst-Pack k-point mesh of size N_x, N_y, N_z for calculating "// &
    3149              :          "the density of states (DOS). In GW, the KPOINT_DOS mesh is thus used as k-point "// &
    3150              :          "mesh for the self-energy. For non-periodic directions α, choose N_α = 1. "// &
    3151              :          "Automatic choice of the k-point mesh for negative "// &
    3152              :          "values, i.e. KPOINTS_DOS -1 -1 -1 (automatic choice: N_α = 1 in non-periodic "// &
    3153              :          "direction, 8 k-points in periodic direction). If you like to compute a "// &
    3154              :          "band structure along a k-path, you can specify the k-path in "// &
    3155              :          "&KPOINT_SET.", &
    3156              :          usage="KPOINTS N_x  N_y  N_z", &
    3157         1462 :          n_var=3, type_of_var=integer_t, default_i_vals=[-1, -1, -1])
    3158         1462 :       CALL section_add_keyword(section, keyword)
    3159         1462 :       CALL keyword_release(keyword)
    3160              : 
    3161         1462 :       NULLIFY (subsection)
    3162         1462 :       CALL create_ldos_section(subsection)
    3163         1462 :       CALL section_add_subsection(section, subsection)
    3164         1462 :       CALL section_release(subsection)
    3165              : 
    3166         1462 :    END SUBROUTINE create_dos_section
    3167              : 
    3168              : ! **************************************************************************************************
    3169              : !> \brief ...
    3170              : !> \param section ...
    3171              : ! **************************************************************************************************
    3172         1462 :    SUBROUTINE create_ldos_section(section)
    3173              :       TYPE(section_type), POINTER                        :: section
    3174              : 
    3175              :       TYPE(keyword_type), POINTER                        :: keyword
    3176              : 
    3177         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    3178              :       CALL section_create(section, __LOCATION__, name="LDOS", &
    3179              :                           description="Parameters needed to calculate the local density "// &
    3180              :                           "of states (LDOS).  "// &
    3181              :                           "The LDOS is computed as $\rho(\mathbf{r},E) = "// &
    3182              :                           "\sum\limits_{n,\mathbf{k}}"// &
    3183              :                           " |\psi_{n\mathbf{k}}(r)|^2\, w_\mathbf{k}\, g(E-\varepsilon_{n\mathbf{k}})$ "// &
    3184              :                           "using the Gaussian weight function "// &
    3185              :                           "$g(x) = \exp(x^2/\alpha^2)/(\sqrt{2\pi}\alpha)$, $\alpha$ is the broadening "// &
    3186              :                           "from the &DOS section, and the k-point weight "// &
    3187              :                           "$w_\mathbf{k}$. The k-mesh is taken from the &DOS section.", &
    3188         1462 :                           n_keywords=2, repeats=.FALSE.)
    3189              : 
    3190         1462 :       NULLIFY (keyword)
    3191              :       CALL keyword_create(keyword, __LOCATION__, &
    3192              :                           name="_SECTION_PARAMETERS_", &
    3193              :                           description="Activates the local VBM CBM gap calculation.", &
    3194              :                           default_l_val=.FALSE., &
    3195         1462 :                           lone_keyword_l_val=.TRUE.)
    3196         1462 :       CALL section_add_keyword(section, keyword)
    3197         1462 :       CALL keyword_release(keyword)
    3198              : 
    3199              :       CALL keyword_create(keyword, __LOCATION__, name="INTEGRATION", &
    3200              :                           description="Defines whether the LDOS is integrated along a "// &
    3201              :                           "coordinate. As an example, for INTEGRATION Z, the LDOS "// &
    3202              :                           "$\rho(x,y,E) = \int dz\, \rho(x,y,z,E)$ is computed.", &
    3203              :                           usage="INTEGRATION Z", &
    3204              :                           enum_c_vals=s2a("X", "Y", "Z", "NONE"), &
    3205              :                           enum_i_vals=[int_ldos_x, int_ldos_y, int_ldos_z, int_ldos_none], &
    3206              :                           enum_desc=s2a("Integrate over x coordinate (not yet implemented).", &
    3207              :                                         "Integrate over y coordinate (not yet implemented).", &
    3208              :                                         "Integrate over z coordinate.", &
    3209              :                                         "No integration, print cube file as function "// &
    3210              :                                         "of x,y,z (not yet implemented)."), &
    3211         1462 :                           default_i_val=int_ldos_z)
    3212         1462 :       CALL section_add_keyword(section, keyword)
    3213         1462 :       CALL keyword_release(keyword)
    3214              : 
    3215              :       CALL keyword_create( &
    3216              :          keyword, __LOCATION__, name="BIN_MESH", &
    3217              :          description="Mesh of size n x m for binning the space coordinates x and y of "// &
    3218              :          "the LDOS $\rho(x,y,E)$. If -1, no binning is performed and the "// &
    3219              :          "fine x, y resolution of the electron density from SCF is used.", &
    3220              :          usage="BIN_MESH  n m", &
    3221         1462 :          n_var=2, type_of_var=integer_t, default_i_vals=[10, 10])
    3222         1462 :       CALL section_add_keyword(section, keyword)
    3223         1462 :       CALL keyword_release(keyword)
    3224              : 
    3225         1462 :    END SUBROUTINE create_ldos_section
    3226              : 
    3227              : ! **************************************************************************************************
    3228              : !> \brief creates an input section for a tip scan calculation
    3229              : !> \param section section to create
    3230              : !> \par History
    3231              : !>    * 04.2021 created [JGH]
    3232              : ! **************************************************************************************************
    3233         1462 :    SUBROUTINE create_tipscan_section(section)
    3234              :       TYPE(section_type), POINTER                        :: section
    3235              : 
    3236              :       TYPE(keyword_type), POINTER                        :: keyword
    3237              : 
    3238         1462 :       CPASSERT(.NOT. ASSOCIATED(section))
    3239              :       CALL section_create(section, __LOCATION__, name="TIP_SCAN", &
    3240              :                           description="Parameters needed to set up a Tip Scan. "// &
    3241              :                           "Needs external definition of tip induced field.", &
    3242         1462 :                           n_keywords=1, n_subsections=1, repeats=.FALSE.)
    3243              : 
    3244         1462 :       NULLIFY (keyword)
    3245              : 
    3246              :       CALL keyword_create(keyword, __LOCATION__, &
    3247              :                           name="_SECTION_PARAMETERS_", &
    3248              :                           description="Controls the activation of the Tip Scan procedure", &
    3249              :                           default_l_val=.FALSE., &
    3250         1462 :                           lone_keyword_l_val=.TRUE.)
    3251         1462 :       CALL section_add_keyword(section, keyword)
    3252         1462 :       CALL keyword_release(keyword)
    3253              : 
    3254              :       CALL keyword_create(keyword, __LOCATION__, name="SCAN_DIRECTION", &
    3255              :                           description="Defines scan direction and scan type(line, plane).", &
    3256              :                           usage="SCAN_DIRECTION XY", &
    3257              :                           enum_c_vals=s2a("X", "Y", "Z", "XY", "XZ", "YZ", "XYZ"), &
    3258              :                           enum_i_vals=[scan_x, scan_y, scan_z, scan_xy, scan_xz, scan_yz, scan_xyz], &
    3259         1462 :                           default_i_val=scan_xy)
    3260         1462 :       CALL section_add_keyword(section, keyword)
    3261         1462 :       CALL keyword_release(keyword)
    3262              : 
    3263              :       CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_POINT", &
    3264              :                           description="The reference point to define the absolute position of the scan. ", &
    3265              :                           usage="REFERENCE_POINT 0.0 0.0 1.0", &
    3266              :                           n_var=3, default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp], type_of_var=real_t, &
    3267         1462 :                           unit_str="angstrom")
    3268         1462 :       CALL section_add_keyword(section, keyword)
    3269         1462 :       CALL keyword_release(keyword)
    3270              : 
    3271              :       CALL keyword_create(keyword, __LOCATION__, name="SCAN_POINTS", &
    3272              :                           description="Number of points calculated for each scan direction.", &
    3273              :                           usage="SCAN_POINTS 20 20", &
    3274         1462 :                           n_var=-1, type_of_var=integer_t)
    3275         1462 :       CALL section_add_keyword(section, keyword)
    3276         1462 :       CALL keyword_release(keyword)
    3277              : 
    3278              :       CALL keyword_create(keyword, __LOCATION__, name="SCAN_STEP", &
    3279              :                           description="Step size for each scan direction.", &
    3280              :                           usage="SCAN_STEP 0.01 0.01", &
    3281         1462 :                           n_var=-1, type_of_var=real_t, unit_str="angstrom")
    3282         1462 :       CALL section_add_keyword(section, keyword)
    3283         1462 :       CALL keyword_release(keyword)
    3284              : 
    3285              :       CALL keyword_create(keyword, __LOCATION__, name="TIP_FILENAME", &
    3286              :                           description="Filename of tip potential defined in cube file format.", &
    3287              :                           usage="TIP_FILENAME <filename>", &
    3288         1462 :                           type_of_var=lchar_t)
    3289         1462 :       CALL section_add_keyword(section, keyword)
    3290         1462 :       CALL keyword_release(keyword)
    3291              : 
    3292         1462 :    END SUBROUTINE create_tipscan_section
    3293              : 
    3294              : ! **************************************************************************************************
    3295              : !> \brief ...
    3296              : !> \param section ...
    3297              : !> \param section_name ...
    3298              : !> \author Shridhar Shanbhag
    3299              : ! **************************************************************************************************
    3300         1462 :    SUBROUTINE create_floquet_section(section)
    3301              :       TYPE(section_type), POINTER                        :: section
    3302              : 
    3303              :       TYPE(keyword_type), POINTER                        :: keyword
    3304              : 
    3305              :       CALL section_create(section, __LOCATION__, name="FLOQUET", &
    3306              :                           description="Parameters controlling the calculation of the "// &
    3307              :                           "Floquet band structure and Quasi-energies of a system driven "// &
    3308              :                           "by a periodic monochromatic electric field with any arbitrary "// &
    3309              :                           "polarisation state.", &
    3310         1462 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
    3311         1462 :       NULLIFY (keyword)
    3312              : 
    3313              :       CALL keyword_create(keyword, __LOCATION__, name="AMPLITUDE", &
    3314              :                           description="Electric field amplitude of the monochromatic light.", &
    3315              :                           usage="AMPLITUDE [Vm-1] 1.0E9", n_var=1, type_of_var=real_t, &
    3316         1462 :                           unit_str="Vm-1", default_r_val=0.0_dp)
    3317         1462 :       CALL section_add_keyword(section, keyword)
    3318         1462 :       CALL keyword_release(keyword)
    3319              : 
    3320              :       CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY", &
    3321              :                           description="Frequency of the electric field for Floquet calculations "// &
    3322              :                           "expressed in terms of the energy of a photon in eV.", &
    3323              :                           usage="FREQUENCY 1.5", unit_str="eV", n_var=1, type_of_var=real_t, &
    3324         1462 :                           default_r_val=cp_unit_to_cp2k(value=1.0_dp, unit_str="eV"))
    3325         1462 :       CALL section_add_keyword(section, keyword)
    3326         1462 :       CALL keyword_release(keyword)
    3327              : 
    3328              :       CALL keyword_create(keyword, __LOCATION__, name="POLARISATION", &
    3329              :                           description="Polarisation vector of the input light. The "// &
    3330              :                           "amplitude in each direction is the product of the AMPLITUDE "// &
    3331              :                           "and the POLARISATION vector component. Eg. for light polarized "// &
    3332              :                           "in the x direction, use 1 0 0. For left-circularly polarized "// &
    3333              :                           "light travelling in the +z direction use 1 1 0 and set "// &
    3334              :                           "PHASE_OFFSET 0 0.5 0 for a +Ï€/2 offset", &
    3335              :                           usage="POLARISATION  0.0 0.0 1.0", &
    3336         1462 :                           default_r_vals=[0.0_dp, 0.0_dp, 1.0_dp])
    3337         1462 :       CALL section_add_keyword(section, keyword)
    3338         1462 :       CALL keyword_release(keyword)
    3339              : 
    3340              :       CALL keyword_create(keyword, __LOCATION__, name="PHASE_OFFSETS", &
    3341              :                           description="Phase offset of the electric field in the "// &
    3342              :                           "x, y, and z directions given in multiples of π. For "// &
    3343              :                           "linearly polarized light, use 0 0 0 and for left-circularly "// &
    3344              :                           "polarized light travelling in the +z direction use "// &
    3345              :                           "PHASE_OFFSET 0.0 0.5 0 ", &
    3346              :                           usage="PHASE_OFFSETS  0.5 0 0", &
    3347         1462 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp])
    3348         1462 :       CALL section_add_keyword(section, keyword)
    3349         1462 :       CALL keyword_release(keyword)
    3350              : 
    3351              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_FLOQUET_INDEX", &
    3352              :                           description="Largest absolute Floquet index up to which "// &
    3353              :                           "Floquet Hamiltonian is truncated. Use a larger value to "// &
    3354              :                           "ensure convergence at higher computational cost and a "// &
    3355              :                           "smaller value for faster computation. EPS_FLOQUET checks "// &
    3356              :                           "to ensure that the error due to truncation is small.", &
    3357              :                           usage="MAX_FLOQUET_INDEX 50", &
    3358         1462 :                           default_i_val=50)
    3359         1462 :       CALL section_add_keyword(section, keyword)
    3360         1462 :       CALL keyword_release(keyword)
    3361              : 
    3362              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_NMO", &
    3363              :                           description="Maximum number of Kohn-Sham eigenstates closest "// &
    3364              :                           "to the valence band maximum used in the Floquet calculation. "// &
    3365              :                           "The Floquet Hamiltonian is built only from this band window, "// &
    3366              :                           "greatly reducing its size and the diagonalisation cost for "// &
    3367              :                           "large (e.g. moire) cells. 0 means use all bands. The window "// &
    3368              :                           "must be wide enough that the bands of interest do not couple "// &
    3369              :                           "significantly to the excluded bands; converge results by "// &
    3370              :                           "increasing MAX_NMO.", &
    3371              :                           usage="MAX_NMO 20", &
    3372         1462 :                           default_i_val=0)
    3373         1462 :       CALL section_add_keyword(section, keyword)
    3374         1462 :       CALL keyword_release(keyword)
    3375              : 
    3376              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FLOQUET", &
    3377              :                           description="Threshold on the error due to truncation of "// &
    3378              :                           "the Floquet Hamiltonian. Used to verify that MAX_FLOQUET_INDEX "// &
    3379              :                           "is large enough that truncation errors are small. "// &
    3380              :                           "If negative, the check is removed (not recommended).", &
    3381         1462 :                           usage="EPS_FLOQUET 1.e-10", default_r_val=1.0e-10_dp)
    3382         1462 :       CALL section_add_keyword(section, keyword)
    3383         1462 :       CALL keyword_release(keyword)
    3384              : 
    3385              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_WINDOW", &
    3386              :                           description="Half-width of the energy range, in eV, centred "// &
    3387              :                           "on the Fermi level, over which the Floquet spectral "// &
    3388              :                           "function is evaluated.", &
    3389              :                           usage="ENERGY_WINDOW 5.0", &
    3390              :                           default_r_val=cp_unit_to_cp2k(value=10.0_dp, unit_str="eV"), &
    3391         1462 :                           unit_str="eV")
    3392         1462 :       CALL section_add_keyword(section, keyword)
    3393         1462 :       CALL keyword_release(keyword)
    3394              : 
    3395              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY_STEP", &
    3396              :                           description="Resolution of the energy E used to compute the "// &
    3397              :                           "spectral function within the energy window.", &
    3398              :                           usage="ENERGY_STEP 0.01", &
    3399              :                           default_r_val=cp_unit_to_cp2k(value=0.01_dp, unit_str="eV"), &
    3400         1462 :                           unit_str="eV")
    3401         1462 :       CALL section_add_keyword(section, keyword)
    3402         1462 :       CALL keyword_release(keyword)
    3403              : 
    3404              :       CALL keyword_create(keyword, __LOCATION__, name="BROADENING", &
    3405              :                           description="Lorentzian broadening applied to the peaks of the "// &
    3406              :                           "Floquet spectral function.", &
    3407              :                           usage="BROADENING 0.02", &
    3408              :                           default_r_val=cp_unit_to_cp2k(value=0.02_dp, unit_str="eV"), &
    3409         1462 :                           unit_str="eV")
    3410         1462 :       CALL section_add_keyword(section, keyword)
    3411         1462 :       CALL keyword_release(keyword)
    3412              : 
    3413              :       CALL keyword_create(keyword, __LOCATION__, name="TEMPERATURE", &
    3414              :                           description="Electronic temperature (in K) of the wide-band fermion "// &
    3415              :                           "bath used to weight the Floquet DOS by Fermi-Dirac occupations, adding "// &
    3416              :                           "an occupied spectral-weight column f(E)*A(E) to the DOS file. If "// &
    3417              :                           "negative (default), that column is not written.", &
    3418         1462 :                           usage="TEMPERATURE 300.0", default_r_val=-1.0_dp)
    3419         1462 :       CALL section_add_keyword(section, keyword)
    3420         1462 :       CALL keyword_release(keyword)
    3421              : 
    3422              :       CALL keyword_create(keyword, __LOCATION__, name="FLOQUET_DOS_FILE_NAME", &
    3423              :                           description="File name used for the Floquet spectral function.", &
    3424              :                           usage="FLOQUET_DOS_FILE_NAME FLOQUET_DOS", &
    3425         1462 :                           default_lc_val="FLOQUET_DOS")
    3426         1462 :       CALL section_add_keyword(section, keyword)
    3427         1462 :       CALL keyword_release(keyword)
    3428              : 
    3429              :       CALL keyword_create(keyword, __LOCATION__, name="QUASI_ENERGIES_FILE_NAME", &
    3430              :                           description="File name used for the Floquet quasi-energies.", &
    3431              :                           usage="QUASI_ENERGIES_FILE_NAME QUASI_ENERGIES", &
    3432         1462 :                           default_lc_val="QUASI_ENERGIES")
    3433         1462 :       CALL section_add_keyword(section, keyword)
    3434         1462 :       CALL keyword_release(keyword)
    3435              : 
    3436              :       CALL keyword_create(keyword, __LOCATION__, name="FLOQUET_BS_FILE_NAME", &
    3437              :                           description="File name used for the Floquet m=0 (central-sector) "// &
    3438              :                           "band structure.", &
    3439              :                           usage="FLOQUET_BS_FILE_NAME FLOQUET_BANDSTRUCTURE", &
    3440         1462 :                           default_lc_val="FLOQUET_BANDSTRUCTURE")
    3441         1462 :       CALL section_add_keyword(section, keyword)
    3442         1462 :       CALL keyword_release(keyword)
    3443              : 
    3444              :       CALL keyword_create(keyword, __LOCATION__, name="MEM_FILL_FRACTION", &
    3445              :                           description="Fraction of the computation memory that may be filled "// &
    3446              :                           "by Floquet Hamiltonian matrices. Reduce if process gets OOMP killed.", &
    3447         1462 :                           usage="MEM_FILL_FRACTION 0.5", default_r_val=0.8_dp)
    3448         1462 :       CALL section_add_keyword(section, keyword)
    3449         1462 :       CALL keyword_release(keyword)
    3450              : 
    3451         1462 :    END SUBROUTINE create_floquet_section
    3452              : 
    3453              : ! **************************************************************************************************
    3454              : !> \brief Create the post-SCF analysis input.
    3455              : !> \param section New properties section
    3456              : ! **************************************************************************************************
    3457         1462 :    SUBROUTINE create_spectral_localizer_section(section)
    3458              :       TYPE(section_type), POINTER :: section
    3459              :       TYPE(keyword_type), POINTER :: keyword
    3460              : 
    3461         1462 :       NULLIFY (keyword)
    3462              :       CALL section_create(section, __LOCATION__, name="SPECTRAL_LOCALIZER", &
    3463              :                        description="Spectral localizer for isolated or two- and three-dimensionally periodic GPW/GAPW systems. "// &
    3464              :                           "Uses the full converged AO Hamiltonian, overlap, and analytic position or Berry integrals. "// &
    3465              :                           "Independent of KUBO_TRANSPORT and WANNIER90 Wilson/Z2/Chern or inversion-TQC analysis. "// &
    3466              :                           "Reports a finite-basis local index and protection gap, not a bulk-gap certificate. "// &
    3467              :                           "Requires convergence with basis, system size, and position/energy scale.", &
    3468         7310 :                           repeats=.FALSE., citations=[Dixon2023, Wong2026, Doll2025, Loring2015])
    3469              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    3470              :                           description="Activate post-SCF spectral localizer analysis.", &
    3471         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    3472         1462 :       CALL section_add_keyword(section, keyword)
    3473         1462 :       CALL keyword_release(keyword)
    3474              :       CALL keyword_create(keyword, __LOCATION__, name="FORMULATION", type_of_var=enum_t, &
    3475              :                           description="FINITE uses Cartesian first moments for PERIODIC NONE. PERIODIC uses "// &
    3476              :                           "analytic cos(G.r)/sin(G.r) integrals on a two- or three-dimensional Born-von-Karman torus. "// &
    3477              :                           "MP_GRID controls its size; this is not an independent localizer at each k.", &
    3478         1462 :                           enum_c_vals=s2a("FINITE", "PERIODIC"), enum_i_vals=[0, 1], default_i_val=0)
    3479         1462 :       CALL section_add_keyword(section, keyword)
    3480         1462 :       CALL keyword_release(keyword)
    3481              :       CALL keyword_create(keyword, __LOCATION__, name="MP_GRID", &
    3482              :                           description="Full Gamma-centered analysis mesh for FORMULATION PERIODIC. "// &
    3483              :                           "Equivalent to a Gamma supercell with these replication factors, at the frozen SCF potential. "// &
    3484              :                           "Independent of the SCF KPOINTS scheme or symmetry reduction. Nonperiodic directions "// &
    3485              :                           "must have size one. MAX_AO applies to the entire torus, not the primitive cell.", &
    3486         1462 :                           type_of_var=integer_t, n_var=3, default_i_vals=[1, 1, 1])
    3487         1462 :       CALL section_add_keyword(section, keyword)
    3488         1462 :       CALL keyword_release(keyword)
    3489              :       CALL keyword_create(keyword, __LOCATION__, name="ETA", &
    3490              :                           description="Positive energy scales for FORMULATION PERIODIC, multiplying the "// &
    3491              :                           "dimensionless trigonometric coordinates. Choose on the scale of H-ENERGY and "// &
    3492              :                           "check size/basis/ETA convergence. Replaces KAPPA for this formulation. "// &
    3493              :                           "The localizer and reported gaps retain energy units.", &
    3494         1462 :                           type_of_var=real_t, n_var=-1, unit_str="hartree", default_r_vals=[1.0_dp])
    3495         1462 :       CALL section_add_keyword(section, keyword)
    3496         1462 :       CALL keyword_release(keyword)
    3497              :       CALL keyword_create(keyword, __LOCATION__, name="SOLVER", type_of_var=enum_t, &
    3498              :                           description="Dense LAPACK reference calculation in the AO overlap metric.", &
    3499         1462 :                           enum_c_vals=s2a("DENSE"), enum_i_vals=[0], default_i_val=0)
    3500         1462 :       CALL section_add_keyword(section, keyword)
    3501         1462 :       CALL keyword_release(keyword)
    3502              :       CALL keyword_create(keyword, __LOCATION__, name="INVARIANT", type_of_var=enum_t, &
    3503              :                           description="CHERN evaluates the 2D class A half-signature. Z2 evaluates the "// &
    3504              :                           "class AII Pfaffian sign (2D) or chiral-block determinant sign (3D); "// &
    3505              :                           "requires SOC and TIME_REVERSAL.", &
    3506         1462 :                           enum_c_vals=s2a("CHERN", "Z2"), enum_i_vals=[0, 1], default_i_val=0)
    3507         1462 :       CALL section_add_keyword(section, keyword)
    3508         1462 :       CALL keyword_release(keyword)
    3509              :       CALL keyword_create(keyword, __LOCATION__, name="DIMENSION", &
    3510              :                           description="Number of localizer position directions, 2 or 3. DIMENSION 3 uses "// &
    3511              :                           "all Cartesian moments (FINITE) or all three torus directions (PERIODIC). "// &
    3512              :                           "It requires Z2 and SOLVER DENSE; PERIODIC also requires CELL and POISSON PERIODIC XYZ. "// &
    3513         1462 :                           "Its strong local Z2 index is not a tuple of weak indices or a 2D slice index.", default_i_val=2)
    3514         1462 :       CALL section_add_keyword(section, keyword)
    3515         1462 :       CALL keyword_release(keyword)
    3516              :       CALL keyword_create(keyword, __LOCATION__, name="PLANE", type_of_var=enum_t, &
    3517              :                           description="Ordered Cartesian directions for FINITE; ordered lattice-vector "// &
    3518              :                           "directions for PERIODIC, which must match the two periodic CELL directions. "// &
    3519              :                           "Only valid for DIMENSION 2.", &
    3520         1462 :                           enum_c_vals=s2a("XY", "XZ", "YZ"), enum_i_vals=[1, 2, 3], default_i_val=1)
    3521         1462 :       CALL section_add_keyword(section, keyword)
    3522         1462 :       CALL keyword_release(keyword)
    3523              :       CALL keyword_create(keyword, __LOCATION__, name="POSITION", &
    3524              :                           description="Cartesian query position in the coordinate frame of SUBSYS/COORD. "// &
    3525              :                           "For FINITE with DIMENSION 2 the component perpendicular to PLANE is ignored. For PERIODIC "// &
    3526              :                           "the reciprocal-cell phase G.r0 is used, including for oblique cells. Repeat for scans.", &
    3527              :                           type_of_var=real_t, n_var=3, repeats=.TRUE., unit_str="bohr", &
    3528         1462 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp])
    3529         1462 :       CALL section_add_keyword(section, keyword)
    3530         1462 :       CALL keyword_release(keyword)
    3531              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY", &
    3532              :                           description="Absolute query energies, without a Fermi-level shift. All combinations "// &
    3533              :                           "of POSITION, ENERGY and KAPPA (FINITE) or ETA (PERIODIC) are evaluated.", &
    3534         1462 :                           type_of_var=real_t, n_var=-1, unit_str="hartree", default_r_vals=[0.0_dp])
    3535         1462 :       CALL section_add_keyword(section, keyword)
    3536         1462 :       CALL keyword_release(keyword)
    3537              :       CALL keyword_create(keyword, __LOCATION__, name="KAPPA", &
    3538              :                           description="Positive energy/length scales. The default is not a converged choice; "// &
    3539              :                           "check a plateau under changes of KAPPA and system size.", &
    3540         1462 :                           type_of_var=real_t, n_var=-1, unit_str="hartree*bohr^-1", default_r_vals=[0.01_dp])
    3541         1462 :       CALL section_add_keyword(section, keyword)
    3542         1462 :       CALL keyword_release(keyword)
    3543              :       CALL keyword_create(keyword, __LOCATION__, name="SPIN_CHANNEL", &
    3544              :                           description="Scalar collinear spin channel, as in WANNIER90. SOC requires restricted channel 1.", &
    3545         1462 :                           default_i_val=1)
    3546         1462 :       CALL section_add_keyword(section, keyword)
    3547         1462 :       CALL keyword_release(keyword)
    3548              :       CALL keyword_create(keyword, __LOCATION__, name="SOC", &
    3549              :                           description="Add the GTH pseudopotential SOC operator to the restricted SCF Hamiltonian "// &
    3550              :                           "in the complete AO spinor space. Requires SOC parameters in the potentials; "// &
    3551         1462 :                           "does not perform a self-consistent noncollinear calculation.", default_l_val=.FALSE.)
    3552         1462 :       CALL section_add_keyword(section, keyword)
    3553         1462 :       CALL keyword_release(keyword)
    3554              :       CALL keyword_create(keyword, __LOCATION__, name="TIME_REVERSAL", &
    3555              :                           description="Assert physical spinful time reversal for Z2, as in WANNIER90. "// &
    3556              :                           "The Hamiltonian, metric and position operators are also checked numerically.", &
    3557         1462 :                           default_l_val=.FALSE.)
    3558         1462 :       CALL section_add_keyword(section, keyword)
    3559         1462 :       CALL keyword_release(keyword)
    3560              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_GAP", &
    3561              :                           description="Absolute localizer-gap threshold below which the index is unresolved. "// &
    3562              :                           "An additional roundoff threshold is always applied.", unit_str="hartree", &
    3563         1462 :                           default_r_val=1.e-8_dp)
    3564         1462 :       CALL section_add_keyword(section, keyword)
    3565         1462 :       CALL keyword_release(keyword)
    3566              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_METRIC", &
    3567              :                           description="Minimum smallest/largest AO-overlap eigenvalue ratio. "// &
    3568         1462 :                           "Ill-conditioned bases are rejected, not silently truncated.", default_r_val=1.e-10_dp)
    3569         1462 :       CALL section_add_keyword(section, keyword)
    3570         1462 :       CALL keyword_release(keyword)
    3571              :       CALL keyword_create(keyword, __LOCATION__, name="SPECTRAL_FLATTENING", &
    3572              :                           description="Replace H-ENERGY*S by FLATTENING_SCALE*S*sign(S^-1*(H-ENERGY*S)). "// &
    3573              :                           "Retains the full occupied and empty AO subspaces and leaves position operators unchanged. "// &
    3574              :                           "Requires a positive metric and a resolved electronic gap, checked before flattening. "// &
    3575              :                           "The resulting finite localizer can have a different index and gap from the unflattened one. "// &
    3576              :                           "No bulk-index or convergence certificate is implied. Computed once per ENERGY, using "// &
    3577              :                           "complete Bloch blocks for periodic tori or DBCSR matrix iterations for finite systems. "// &
    3578         1462 :                           "Both retain the original AO basis and can increase fill-in.", default_l_val=.FALSE.)
    3579         1462 :       CALL section_add_keyword(section, keyword)
    3580         1462 :       CALL keyword_release(keyword)
    3581              :       CALL keyword_create(keyword, __LOCATION__, name="FLATTENING_SCALE", &
    3582              :                           description="Positive energy assigned to the positive bands by SPECTRAL_FLATTENING; "// &
    3583              :                           "negative bands receive its negative. ETA or KAPPA and output gaps retain their normal "// &
    3584              :                           "units but refer to this flattened Hamiltonian, not to the original band dispersion.", &
    3585         1462 :                           unit_str="hartree", default_r_val=1.0_dp)
    3586         1462 :       CALL section_add_keyword(section, keyword)
    3587         1462 :       CALL keyword_release(keyword)
    3588              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_ELECTRONIC_GAP", &
    3589              :                           description="Minimum resolved distance from ENERGY to the original generalized "// &
    3590              :                           "Hamiltonian spectrum before SPECTRAL_FLATTENING. Additional roundoff bounds apply. "// &
    3591              :                           "Separate from EPS_GAP, which applies to the final localizer.", &
    3592         1462 :                           unit_str="hartree", default_r_val=1.e-8_dp)
    3593         1462 :       CALL section_add_keyword(section, keyword)
    3594         1462 :       CALL keyword_release(keyword)
    3595              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FLATTENING", &
    3596              :                           description="Tolerance for the inverse and sign-square Frobenius residuals and "// &
    3597              :                           "relative complex-structure/Hermiticity residuals of the DBCSR matrix iterations. "// &
    3598              :                           "For the periodic Bloch path, checks translation covariance, metric orthonormality, "// &
    3599              :                           "eigenproblem residuals and final Hermiticity instead. "// &
    3600         1462 :                           "An unconverged result is rejected, not used to report an index.", default_r_val=1.e-9_dp)
    3601         1462 :       CALL section_add_keyword(section, keyword)
    3602         1462 :       CALL keyword_release(keyword)
    3603              :       CALL keyword_create(keyword, __LOCATION__, name="MATRIX_TOLERANCE", &
    3604         1462 :                           description="Relative Hermiticity and time-reversal residual tolerance.", default_r_val=1.e-9_dp)
    3605         1462 :       CALL section_add_keyword(section, keyword)
    3606         1462 :       CALL keyword_release(keyword)
    3607              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_AO", &
    3608              :                           description="Safety limit on scalar AO dimension for the dense solver. "// &
    3609              :                           "DENSE uses replicated localizers and source-rank diagonalization, "// &
    3610              :                           "quadratic memory and cubic runtime; the SOC Hermitian localizer has dimension "// &
    3611         1462 :                           "4*NAO (DIMENSION 2) or 8*NAO (DIMENSION 3).", default_i_val=512)
    3612         1462 :       CALL section_add_keyword(section, keyword)
    3613         1462 :       CALL keyword_release(keyword)
    3614         1462 :    END SUBROUTINE create_spectral_localizer_section
    3615              : 
    3616              : ! **************************************************************************************************
    3617              : !> \brief Create the post-SCF analysis input.
    3618              : !> \param section New properties section
    3619              : ! **************************************************************************************************
    3620         1462 :    SUBROUTINE create_quadratic_pseudospectrum_section(section)
    3621              :       TYPE(section_type), POINTER :: section, print_key
    3622              :       TYPE(keyword_type), POINTER :: keyword
    3623         1462 :       NULLIFY (keyword, print_key)
    3624              :       CALL section_create(section, __LOCATION__, name="QUADRATIC_PSEUDOSPECTRUM", &
    3625              :                           description="Joint position/energy localization analysis for GPW/GAPW systems. "// &
    3626              :                           "Uses full AO H, S and analytic first moments or periodic trigonometric coordinates. "// &
    3627              :                           "No occupied-state projection and no topology index. "// &
    3628              :                           "Residuals concern finite-basis projected operators, not exact real-space variances.", &
    3629         2924 :                           repeats=.FALSE., citations=[Cerjan2023])
    3630              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
    3631              :                           description="Activate post-SCF quadratic pseudospectrum analysis.", &
    3632         1462 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
    3633         1462 :       CALL section_add_keyword(section, keyword)
    3634         1462 :       CALL keyword_release(keyword)
    3635              :       CALL keyword_create(keyword, __LOCATION__, name="FORMULATION", type_of_var=enum_t, &
    3636              :                           description="FINITE uses Cartesian first moments for isolated systems. PERIODIC uses "// &
    3637              :                           "cos(G.r)/sin(G.r) on a Born-von-Karman torus in the periodic CELL directions only. "// &
    3638              :                           "Open directions are not localized by PERIODIC. TRANSLATION uses analytic translated "// &
    3639              :                           "Gaussian overlaps, with continuum translation norms and explicit AO leakage. Periodic "// &
    3640              :                           "TRANSLATION uses periodized AOs on the full MP_GRID torus; finite translations need no KPOINTS. "// &
    3641              :                           "ENERGY still refers to the projected AO Hamiltonian; no boundary suppression is applied.", &
    3642         1462 :                           enum_c_vals=s2a("FINITE", "PERIODIC", "TRANSLATION"), enum_i_vals=[0, 1, 2], default_i_val=0)
    3643         1462 :       CALL section_add_keyword(section, keyword)
    3644         1462 :       CALL keyword_release(keyword)
    3645              :       CALL keyword_create(keyword, __LOCATION__, name="TRANSLATION_VECTOR", &
    3646              :                           description="Cartesian vector a in the input coordinate frame, for U(a) psi(r) = psi(r+a). "// &
    3647              :                           "Repeat for each equally weighted translation. Only with FORMULATION TRANSLATION. "// &
    3648              :                           "Choose directions and lengths deliberately; this defines a momentum-resolution metric.", &
    3649         1462 :                           type_of_var=real_t, n_var=3, repeats=.TRUE., unit_str="bohr")
    3650         1462 :       CALL section_add_keyword(section, keyword)
    3651         1462 :       CALL keyword_release(keyword)
    3652              :       CALL keyword_create(keyword, __LOCATION__, name="WAVE_VECTOR", &
    3653              :                           description="Cartesian momentum query k in the input frame; phase is exp(i k.a), "// &
    3654              :                           "without an additional 2*pi. Repeat for scans. Only with FORMULATION TRANSLATION.", &
    3655              :                           type_of_var=real_t, n_var=3, repeats=.TRUE., unit_str="bohr^-1", &
    3656         1462 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp])
    3657         1462 :       CALL section_add_keyword(section, keyword)
    3658         1462 :       CALL keyword_release(keyword)
    3659              :       CALL keyword_create(keyword, __LOCATION__, name="TRANSLATION_SCALE", &
    3660              :                           description="Positive energy scales for dimensionless full translation residuals. "// &
    3661              :                           "Every WAVE_VECTOR/ENERGY/TRANSLATION_SCALE combination is evaluated. "// &
    3662              :                           "Only with FORMULATION TRANSLATION, replacing the energy/length-valued KAPPA.", &
    3663         1462 :                           type_of_var=real_t, n_var=-1, unit_str="hartree", default_r_vals=[1.0_dp])
    3664         1462 :       CALL section_add_keyword(section, keyword)
    3665         1462 :       CALL keyword_release(keyword)
    3666              :       CALL keyword_create(keyword, __LOCATION__, name="MP_GRID", &
    3667              :                           description="Full Gamma-centered mesh for PERIODIC or periodic TRANSLATION, independent "// &
    3668              :                           "of SCF symmetry reduction. Equivalent to a Gamma supercell at the frozen SCF potential. "// &
    3669              :                           "Nonperiodic directions must be one; MAX_AO bounds the entire torus.", &
    3670         1462 :                           type_of_var=integer_t, n_var=3, default_i_vals=[1, 1, 1])
    3671         1462 :       CALL section_add_keyword(section, keyword)
    3672         1462 :       CALL keyword_release(keyword)
    3673              :       CALL keyword_create(keyword, __LOCATION__, name="SOLVER", type_of_var=enum_t, &
    3674              :                           description="Dense LAPACK reference calculation in the AO overlap metric.", &
    3675         1462 :                           enum_c_vals=s2a("DENSE"), enum_i_vals=[0], default_i_val=0)
    3676         1462 :       CALL section_add_keyword(section, keyword)
    3677         1462 :       CALL keyword_release(keyword)
    3678              :       CALL keyword_create(keyword, __LOCATION__, name="POSITION", &
    3679              :                           description="Query position in the SUBSYS/COORD frame. Repeat for spatial scans.", &
    3680              :                           type_of_var=real_t, n_var=3, repeats=.TRUE., unit_str="bohr", &
    3681         1462 :                           default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp])
    3682         1462 :       CALL section_add_keyword(section, keyword)
    3683         1462 :       CALL keyword_release(keyword)
    3684              :       CALL keyword_create(keyword, __LOCATION__, name="ENERGY", &
    3685              :                           description="Absolute query energies; every POSITION/ENERGY/KAPPA combination is evaluated.", &
    3686         1462 :                           type_of_var=real_t, n_var=-1, unit_str="hartree", default_r_vals=[0.0_dp])
    3687         1462 :       CALL section_add_keyword(section, keyword)
    3688         1462 :       CALL keyword_release(keyword)
    3689              :       CALL keyword_create(keyword, __LOCATION__, name="KAPPA", &
    3690              :                           description="Positive energy/length scales for Cartesian residuals (FINITE) or "// &
    3691              :                           "periodic chord residuals divided by reciprocal-vector norms (PERIODIC). "// &
    3692              :                           "Check basis, system-size and KAPPA convergence.", &
    3693         1462 :                           type_of_var=real_t, n_var=-1, unit_str="hartree*bohr^-1", default_r_vals=[0.01_dp])
    3694         1462 :       CALL section_add_keyword(section, keyword)
    3695         1462 :       CALL keyword_release(keyword)
    3696              :       CALL keyword_create(keyword, __LOCATION__, name="NSTATES", default_i_val=1, &
    3697         1462 :                           description="Number of lowest quadratic-operator eigenstates, S-normalized.")
    3698         1462 :       CALL section_add_keyword(section, keyword)
    3699         1462 :       CALL keyword_release(keyword)
    3700              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_EIGEN", default_r_val=1.e-8_dp, &
    3701              :                           description="Convergence criterion: S-inverse residual norm <= EPS_EIGEN times "// &
    3702         1462 :                           "max(1,abs(eigenvalue)), with eigenvalues in atomic units of energy squared.")
    3703         1462 :       CALL section_add_keyword(section, keyword)
    3704         1462 :       CALL keyword_release(keyword)
    3705              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_METRIC", default_r_val=1.e-10_dp, &
    3706              :                           description="Minimum AO metric eigenvalue ratio. "// &
    3707         1462 :                           "Ill-conditioned directions are rejected, not silently discarded.")
    3708         1462 :       CALL section_add_keyword(section, keyword)
    3709         1462 :       CALL keyword_release(keyword)
    3710              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_AO", default_i_val=512, &
    3711              :                           description="Scalar AO safety limit for the dense solver, including all periodic torus cells. "// &
    3712              :                           "Increase deliberately for large systems. "// &
    3713         1462 :                           "SOC doubles the operator dimension; DENSE uses quadratic memory.")
    3714         1462 :       CALL section_add_keyword(section, keyword)
    3715         1462 :       CALL keyword_release(keyword)
    3716              :       CALL keyword_create(keyword, __LOCATION__, name="SPIN_CHANNEL", default_i_val=1, &
    3717         1462 :                           description="Collinear scalar spin channel. SOC requires a restricted SCF and channel 1.")
    3718         1462 :       CALL section_add_keyword(section, keyword)
    3719         1462 :       CALL keyword_release(keyword)
    3720              :       CALL keyword_create(keyword, __LOCATION__, name="SOC", default_l_val=.FALSE., &
    3721              :                           description="Add GTH SOC to the restricted converged AO Hamiltonian. Requires SOC "// &
    3722         1462 :                           "pseudopotentials; not a self-consistent noncollinear calculation.")
    3723         1462 :       CALL section_add_keyword(section, keyword)
    3724         1462 :       CALL keyword_release(keyword)
    3725              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="STATES", &
    3726              :                                        description="S-normalized complex AO coefficients, scalar-AO order with "// &
    3727              :                                        "spin-up followed by spin-down for SOC. These are quadratic-operator states, "// &
    3728              :                                        "with cell-major AO ordering within each spin block for PERIODIC. "// &
    3729              :                                        "not Hamiltonian eigenstates. Degenerate states are gauge dependent.", &
    3730         1462 :                                        print_level=low_print_level, filename="")
    3731         1462 :       CALL section_add_subsection(section, print_key)
    3732         1462 :       CALL section_release(print_key)
    3733         1462 :    END SUBROUTINE create_quadratic_pseudospectrum_section
    3734              : 
    3735              : END MODULE input_cp2k_properties_dft
        

Generated by: LCOV version 2.0-1