LCOV - code coverage report
Current view: top level - src - input_cp2k_projection_rtp.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:42dac4a) Lines: 100.0 % 38 38
Test Date: 2025-07-25 12:55:17 Functions: 100.0 % 1 1

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2025 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief function that builds the projection of MO in RTP section of the input
      10              : !> \author Guillaume Le Breton 04.2023
      11              : ! **************************************************************************************************
      12              : MODULE input_cp2k_projection_rtp
      13              :    USE cp_output_handling,              ONLY: cp_print_key_section_create
      14              :    USE input_constants,                 ONLY: proj_mo_ref_scf,&
      15              :                                               proj_mo_ref_xas_tdp
      16              :    USE input_keyword_types,             ONLY: keyword_create,&
      17              :                                               keyword_release,&
      18              :                                               keyword_type
      19              :    USE input_section_types,             ONLY: section_add_keyword,&
      20              :                                               section_add_subsection,&
      21              :                                               section_create,&
      22              :                                               section_release,&
      23              :                                               section_type
      24              :    USE input_val_types,                 ONLY: integer_t
      25              :    USE string_utilities,                ONLY: s2a
      26              : #include "./base/base_uses.f90"
      27              : 
      28              :    IMPLICIT NONE
      29              :    PRIVATE
      30              : 
      31              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_projection_rtp'
      32              : 
      33              :    PUBLIC :: create_projection_rtp_section
      34              : 
      35              : CONTAINS
      36              : 
      37              : ! **************************************************************************************************
      38              : !> \brief creates the section for time dependent projection of the MOs
      39              : !> \param section ...
      40              : !> \author Guillaume Le Breton
      41              : ! **************************************************************************************************
      42         9254 :    SUBROUTINE create_projection_rtp_section(section)
      43              :       TYPE(section_type), POINTER                        :: section
      44              : 
      45              :       TYPE(keyword_type), POINTER                        :: keyword
      46              :       TYPE(section_type), POINTER                        :: subsection
      47              : 
      48         9254 :       CPASSERT(.NOT. ASSOCIATED(section))
      49              :       CALL section_create(section, __LOCATION__, name="PROJECTION_MO", &
      50              :                           description="Projects the Time Dependent (TD) MO "// &
      51              :                           "coefficients to reference ones. You can define "// &
      52              :                           "several sections like this to project the TD-MOs "// &
      53              :                           "on different reference MOs. Note that each section "// &
      54              :                           "projects from one spin of the TD MOs (TD_MO_INDEX) to "// &
      55              :                           "one spin of the reference MOs (REF_MO_INDEX).", &
      56              :                           n_keywords=7, n_subsections=1, &
      57         9254 :                           repeats=.TRUE.)
      58              : 
      59         9254 :       NULLIFY (keyword, subsection)
      60              :       CALL keyword_create(keyword, __LOCATION__, name="PROPAGATE_REF", &
      61              :                           description="In the case of Ehrenfest dynamics, the atomic basis set is evolving with time. "// &
      62              :                           "The reference MO can either be understood as a spatial-dependent wave-function which is "// &
      63              :                           "time-independent or to be 'attached' with respect to the nuclei position, and "// &
      64              :                           "thus evolve in space as the nuclei move. For the first case, set this variable to TRUE. "// &
      65              :                           "Note that in this case, you shall have enough atomic orbital across the whole space to "// &
      66              :                           "describe this MO as the nuclei will move and may leave the space where the MO is defined. "// &
      67              :                           "For the second case, set to FALSE (default). Note that in this case, if the nuclei undergo "// &
      68              :                           "dramatic changes (dissociation for instance) then this definition may make no longer sense.", &
      69              :                           usage="PROPAGATE_REF .TRUE.", &
      70              :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE., &
      71         9254 :                           repeats=.FALSE.)
      72         9254 :       CALL section_add_keyword(section, keyword)
      73         9254 :       CALL keyword_release(keyword)
      74              : 
      75              :       CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_TYPE", &
      76              :                           description="Type of the reference MO file provided in REF_MO_FILE_NAME.", &
      77              :                           enum_c_vals=s2a("SCF", "XAS_TDP"), &
      78              :                           usage="REFERENCE_TYPE SCF", &
      79              :                           default_i_val=proj_mo_ref_scf, &
      80              :                           enum_desc=s2a("The reference MO is from an SCF calculation.", &
      81              :                                         "The reference MO is from an XAS_TDP analysis."), &
      82         9254 :                           enum_i_vals=(/proj_mo_ref_scf, proj_mo_ref_xas_tdp/))
      83         9254 :       CALL section_add_keyword(section, keyword)
      84         9254 :       CALL keyword_release(keyword)
      85              : 
      86              :       CALL keyword_create(keyword, __LOCATION__, name="REF_MO_FILE_NAME", &
      87              :                           description="Name of the wavefunction file to read the reference MO from. "// &
      88              :                           "For instance, a restart wfn file from SCF calculation or an excited state from XAS_TDP calculation. "// &
      89              :                           "If no file is specified, the default is to use DFT%WFN_RESTART_FILE_NAME. "// &
      90              :                           "Currently, a RTP restart file (.rtpwfn) cannot be used as reference. "// &
      91              :                           "Currently, this file SHALL have the same number of spin as the propagated one "// &
      92              :                           "(eventhough you use only the first spin from this reference).", &
      93              :                           usage="REF_MO_FILE_NAME <FILENAME>", &
      94         9254 :                           default_lc_val="DEFAULT")
      95         9254 :       CALL section_add_keyword(section, keyword)
      96         9254 :       CALL keyword_release(keyword)
      97              : 
      98              :       CALL keyword_create(keyword, __LOCATION__, name="REF_MO_INDEX", &
      99              :                           description="Indexes of the reference MO read from the .wfn reference file (see REF_MO_FILE_NAME). "// &
     100              :                           "Use this keyword if REFERENCE_TYPE=SCF. "// &
     101              :                           "Set to -1 to project on all the MO available. "// &
     102              :                           "One file will be generated per index defined.", &
     103              :                           usage="REF_MO_INDEX 1 2", &
     104              :                           default_i_vals=(/1/), &
     105         9254 :                           n_var=-1, type_of_var=integer_t, repeats=.FALSE.)
     106         9254 :       CALL section_add_keyword(section, keyword)
     107         9254 :       CALL keyword_release(keyword)
     108              : 
     109              :       CALL keyword_create(keyword, __LOCATION__, name="REF_MO_SPIN", &
     110              :                           description="Spin of the reference MOs to consider. "// &
     111              :                           "1 for ALPHA and 2 for BETA spin respectively. "// &
     112              :                           "If the reference MO is spin independent this key is not used.", &
     113              :                           usage="REF_MO_SPIN 1", &
     114              :                           default_i_val=1, &
     115         9254 :                           n_var=1, type_of_var=integer_t, repeats=.FALSE.)
     116              : 
     117         9254 :       CALL section_add_keyword(section, keyword)
     118         9254 :       CALL keyword_release(keyword)
     119              : 
     120              :       CALL keyword_create(keyword, __LOCATION__, name="REF_ADD_LUMO", &
     121              :                           description="If the reference MOs include more empty states that are not propagated, "// &
     122              :                          "using this keyword it is possible to read them as well and thus compute the corresponding projection. ", &
     123              :                           usage="REF_ADD_LUMO 10", &
     124              :                           default_i_val=0, &
     125         9254 :                           n_var=1, type_of_var=integer_t, repeats=.FALSE.)
     126              : 
     127         9254 :       CALL section_add_keyword(section, keyword)
     128         9254 :       CALL keyword_release(keyword)
     129              : 
     130              :       CALL keyword_create(keyword, __LOCATION__, name="SUM_ON_ALL_REF", &
     131              :                           description="Set to .TRUE. in order to sum all the projections done "// &
     132              :                           "over the required MO_REF_INDEX for each TD MOs. "// &
     133              :                           "Only one file will be generated containing the results for every MO_TD_INDEX.", &
     134              :                           usage="SUM_ON_ALL_REF .TRUE.", &
     135              :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE., &
     136         9254 :                           repeats=.FALSE.)
     137         9254 :       CALL section_add_keyword(section, keyword)
     138         9254 :       CALL keyword_release(keyword)
     139              : 
     140              :       CALL keyword_create(keyword, __LOCATION__, name="TD_MO_INDEX", &
     141              :                           description="Indexes of the time dependent MOs to project on the reference MOs. "// &
     142              :                           "Set to -1 to project on all the TD MOs.", &
     143              :                           usage="TD_MO_INDEX 1 2", &
     144              :                           default_i_vals=(/1/), &
     145         9254 :                           n_var=-1, type_of_var=integer_t, repeats=.FALSE.)
     146         9254 :       CALL section_add_keyword(section, keyword)
     147         9254 :       CALL keyword_release(keyword)
     148              : 
     149              :       CALL keyword_create(keyword, __LOCATION__, name="TD_MO_SPIN", &
     150              :                           description="Spin of the TD MOs to consider. 1 for ALPHA spin, 2 for BETA spin. "// &
     151              :                           "If the TD calculation is spin independent this key is not used.", &
     152              :                           usage="TD_MO_SPIN 1", &
     153              :                           default_i_val=1, &
     154         9254 :                           n_var=1, type_of_var=integer_t)
     155         9254 :       CALL section_add_keyword(section, keyword)
     156         9254 :       CALL keyword_release(keyword)
     157              : 
     158              :       CALL keyword_create(keyword, __LOCATION__, name="SUM_ON_ALL_TD", &
     159              :                description="Set to .TRUE. in order to sum the projection done over all on TD MOs on the required MO_REF_INDEX. "// &
     160              :                           "One file per MO_REF_INDEX will be generated. "// &
     161              :                           "Combining SUM_ON_ALL_TD and SUM_ON_ALL_REF lead to one file one projection: "// &
     162              :                           "the population of all the defined TD_MO_INDEX over the reference MO_REF_INDEX per time step required.", &
     163              :                           usage="SUM_ON_ALL_TD .TRUE.", &
     164              :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE., &
     165         9254 :                           repeats=.FALSE.)
     166         9254 :       CALL section_add_keyword(section, keyword)
     167         9254 :       CALL keyword_release(keyword)
     168              : 
     169              :       ! The results for different time step are stored in the same file by default:
     170              :       CALL cp_print_key_section_create(subsection, __LOCATION__, name="PRINT", &
     171              :                                        description="How to print the MO projection", &
     172              :                                        common_iter_levels=999999999, &
     173         9254 :                                        filename="PROJ_MO")
     174         9254 :       CALL section_add_subsection(section, subsection)
     175         9254 :       CALL section_release(subsection)
     176              : 
     177         9254 :    END SUBROUTINE create_projection_rtp_section
     178              : 
     179              : END MODULE input_cp2k_projection_rtp
        

Generated by: LCOV version 2.0-1