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

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

Generated by: LCOV version 2.0-1