LCOV - code coverage report
Current view: top level - src/motion - input_cp2k_vib.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:936074a) Lines: 100.0 % 119 119
Test Date: 2025-12-04 06:27:48 Functions: 100.0 % 4 4

            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 builds the input structure for the VIBRATIONAL_ANALYSIS module
      10              : !> \par History
      11              : !>      01.2008 [tlaino] Teodoro Laino - University of Zurich
      12              : !>                       Creating an own module for vibrational analysis
      13              : !> \author [tlaino]
      14              : ! **************************************************************************************************
      15              : MODULE input_cp2k_vib
      16              :    USE cp_output_handling,              ONLY: add_last_numeric,&
      17              :                                               cp_print_key_section_create,&
      18              :                                               debug_print_level,&
      19              :                                               low_print_level,&
      20              :                                               medium_print_level,&
      21              :                                               silent_print_level
      22              :    USE cp_units,                        ONLY: cp_unit_to_cp2k
      23              :    USE input_constants,                 ONLY: do_rep_blocked,&
      24              :                                               do_rep_interleaved,&
      25              :                                               ms_guess_atomic,&
      26              :                                               ms_guess_bfgs,&
      27              :                                               ms_guess_molden,&
      28              :                                               ms_guess_restart,&
      29              :                                               ms_guess_restart_vec
      30              :    USE input_keyword_types,             ONLY: keyword_create,&
      31              :                                               keyword_release,&
      32              :                                               keyword_type
      33              :    USE input_section_types,             ONLY: section_add_keyword,&
      34              :                                               section_add_subsection,&
      35              :                                               section_create,&
      36              :                                               section_release,&
      37              :                                               section_type
      38              :    USE input_val_types,                 ONLY: integer_t,&
      39              :                                               real_t
      40              :    USE kinds,                           ONLY: dp
      41              :    USE string_utilities,                ONLY: s2a
      42              : #include "../base/base_uses.f90"
      43              : 
      44              :    IMPLICIT NONE
      45              :    PRIVATE
      46              : 
      47              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      48              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_vib'
      49              : 
      50              :    PUBLIC :: create_vib_section
      51              : CONTAINS
      52              : 
      53              : ! **************************************************************************************************
      54              : !> \brief Creates the exteranal restart section
      55              : !> \param section the section to create
      56              : !> \author tlaino
      57              : ! **************************************************************************************************
      58         9284 :    SUBROUTINE create_vib_section(section)
      59              :       TYPE(section_type), POINTER                        :: section
      60              : 
      61              :       TYPE(keyword_type), POINTER                        :: keyword
      62              :       TYPE(section_type), POINTER                        :: subsection
      63              : 
      64         9284 :       CPASSERT(.NOT. ASSOCIATED(section))
      65              :       CALL section_create( &
      66              :          section, __LOCATION__, name="VIBRATIONAL_ANALYSIS", &
      67              :          description="Section to setup parameters to perform a Normal Modes, vibrational, or phonon analysis. "// &
      68              :          "Vibrations are computed using finite differences, "// &
      69              :          "which implies a very tight (e.g. 1E-8) threshold is needed for EPS_SCF to get accurate low frequencies. "// &
      70              :          "The analysis assumes a stationary state (minimum or TS),"// &
      71              :          " i.e. tight geometry optimization (MAX_FORCE) is needed as well.", &
      72         9284 :          n_keywords=1, n_subsections=0, repeats=.FALSE.)
      73         9284 :       NULLIFY (keyword, subsection)
      74              : 
      75              :       CALL keyword_create(keyword, __LOCATION__, name="DX", &
      76              :                           description="Specify the increment to be used to construct the HESSIAN with "// &
      77              :                           "finite difference method", &
      78         9284 :                           default_r_val=1.0E-2_dp, unit_str="bohr")
      79         9284 :       CALL section_add_keyword(section, keyword)
      80         9284 :       CALL keyword_release(keyword)
      81              : 
      82              :       CALL keyword_create(keyword, __LOCATION__, name="NPROC_REP", &
      83              :                           description="Specify the number of processors to be used per replica "// &
      84              :                           "environment (for parallel runs). "// &
      85              :                           "In case of mode selective calculations more than one replica will start"// &
      86              :                           " a block Davidson algorithm to track more than only one frequency", &
      87         9284 :                           default_i_val=1)
      88         9284 :       CALL section_add_keyword(section, keyword)
      89         9284 :       CALL keyword_release(keyword)
      90              : 
      91              :       CALL keyword_create(keyword, __LOCATION__, name="PROC_DIST_TYPE", &
      92              :                           description="Specify the topology of the mapping of processors into replicas.", &
      93              :                           usage="PROC_DIST_TYPE (INTERLEAVED|BLOCKED)", &
      94              :                           enum_c_vals=s2a("INTERLEAVED", &
      95              :                                           "BLOCKED"), &
      96              :                           enum_desc=s2a("Interleaved distribution", &
      97              :                                         "Blocked distribution"), &
      98              :                           enum_i_vals=[do_rep_interleaved, do_rep_blocked], &
      99         9284 :                           default_i_val=do_rep_blocked)
     100         9284 :       CALL section_add_keyword(section, keyword)
     101         9284 :       CALL keyword_release(keyword)
     102              : 
     103              :       CALL keyword_create(keyword, __LOCATION__, name="FULLY_PERIODIC", &
     104              :                           description="Avoids to clean rotations from the Hessian matrix.", &
     105         9284 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     106         9284 :       CALL section_add_keyword(section, keyword)
     107         9284 :       CALL keyword_release(keyword)
     108              : 
     109              :       CALL keyword_create(keyword, __LOCATION__, name="INTENSITIES", &
     110              :                           description="Calculation of the IR/Raman-Intensities. "// &
     111              :                           "Calculation of dipoles and/or polarizabilities have to be "// &
     112              :                           "specified explicitly in DFT/PRINT/MOMENTS and/or "// &
     113              :                           "PROPERTIES/LINRES/POLAR", &
     114         9284 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     115         9284 :       CALL section_add_keyword(section, keyword)
     116         9284 :       CALL keyword_release(keyword)
     117              : 
     118              :       CALL keyword_create(keyword, __LOCATION__, name="THERMOCHEMISTRY", &
     119              :                           description="Calculation of the thermochemical data. Valid for molecules in the gas phase. ", &
     120         9284 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     121         9284 :       CALL section_add_keyword(section, keyword)
     122         9284 :       CALL keyword_release(keyword)
     123              : 
     124              :       CALL keyword_create(keyword, __LOCATION__, name="TC_TEMPERATURE", &
     125              :                           description="Temperature for the calculation of the thermochemical data ", &
     126              :                           usage="tc_temperature 325.0", default_r_val=cp_unit_to_cp2k(value=273.150_dp, unit_str="K"), &
     127         9284 :                           unit_str="K")
     128         9284 :       CALL section_add_keyword(section, keyword)
     129         9284 :       CALL keyword_release(keyword)
     130              : 
     131              :       CALL keyword_create(keyword, __LOCATION__, name="TC_PRESSURE", &
     132              :                           description="Pressure for the calculation of the thermochemical data  ", &
     133         9284 :                           default_r_val=cp_unit_to_cp2k(value=101325.0_dp, unit_str="Pa"), unit_str="Pa")
     134         9284 :       CALL section_add_keyword(section, keyword)
     135         9284 :       CALL keyword_release(keyword)
     136              : 
     137         9284 :       CALL create_mode_selective_section(subsection)
     138         9284 :       CALL section_add_subsection(section, subsection)
     139         9284 :       CALL section_release(subsection)
     140              : 
     141         9284 :       CALL create_print_vib_section(subsection)
     142         9284 :       CALL section_add_subsection(section, subsection)
     143         9284 :       CALL section_release(subsection)
     144         9284 :    END SUBROUTINE create_vib_section
     145              : 
     146              : ! **************************************************************************************************
     147              : !> \brief Create the print section for VIB
     148              : !> \param section the section to create
     149              : !> \author Teodoro Laino [tlaino] - 10.2008
     150              : ! **************************************************************************************************
     151         9284 :    SUBROUTINE create_print_vib_section(section)
     152              :       TYPE(section_type), POINTER                        :: section
     153              : 
     154              :       TYPE(keyword_type), POINTER                        :: keyword
     155              :       TYPE(section_type), POINTER                        :: print_key
     156              : 
     157         9284 :       CPASSERT(.NOT. ASSOCIATED(section))
     158              :       CALL section_create(section, __LOCATION__, name="PRINT", &
     159              :                           description="Section controlling the print information during a vibrational "// &
     160         9284 :                           "analysis.", n_keywords=1, n_subsections=0, repeats=.FALSE.)
     161         9284 :       NULLIFY (keyword, print_key)
     162              : 
     163              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "BANNER", &
     164              :                                        description="Controls the printing of the vibrational analysis banner", &
     165              :                                        print_level=low_print_level, common_iter_levels=1, &
     166         9284 :                                        filename="__STD_OUT__")
     167         9284 :       CALL section_add_subsection(section, print_key)
     168         9284 :       CALL section_release(print_key)
     169              : 
     170              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
     171              :                                        description="Controls the printing basic info about the vibrational method", &
     172         9284 :                                        print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     173         9284 :       CALL section_add_subsection(section, print_key)
     174         9284 :       CALL section_release(print_key)
     175              : 
     176              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "MOLDEN_VIB", &
     177              :                                        description="Controls the printing for visualization in molden format", &
     178         9284 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="VIBRATIONS")
     179         9284 :       CALL section_add_subsection(section, print_key)
     180         9284 :       CALL section_release(print_key)
     181              : 
     182              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "ROTATIONAL_INFO", &
     183              :                                        description="Controls the printing basic info during the cleaning of the "// &
     184              :                                        "rotational degrees of freedom.", &
     185         9284 :                                        print_level=debug_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     186              :       ! Print_key keywords
     187              :       CALL keyword_create(keyword, __LOCATION__, name="COORDINATES", &
     188              :                           description="Prints atomic coordinates after rotation", &
     189         9284 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     190         9284 :       CALL section_add_keyword(print_key, keyword)
     191         9284 :       CALL keyword_release(keyword)
     192         9284 :       CALL section_add_subsection(section, print_key)
     193         9284 :       CALL section_release(print_key)
     194              : 
     195              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CARTESIAN_EIGS", &
     196              :                                        description="Controls the printing of Cartesian "// &
     197              :                                        "frequencies and eigenvectors of the Hessian used "// &
     198              :                                        "for initializing ensemble for MD calculations. "// &
     199              :                                        "This should always print to a file, and will not "// &
     200              :                                        "effect the same frequencies and eigenvectors printed "// &
     201              :                                        "in the main vibrational analysis output", &
     202              :                                        print_level=low_print_level, &
     203              :                                        add_last=add_last_numeric, &
     204         9284 :                                        filename="VIBRATIONS")
     205              :       CALL keyword_create(keyword, __LOCATION__, name="BACKUP_COPIES", &
     206              :                           description="Specifies the maximum number of backup copies.", &
     207              :                           usage="BACKUP_COPIES {int}", &
     208         9284 :                           default_i_val=1)
     209         9284 :       CALL section_add_keyword(print_key, keyword)
     210         9284 :       CALL keyword_release(keyword)
     211         9284 :       CALL section_add_subsection(section, print_key)
     212         9284 :       CALL section_release(print_key)
     213              : 
     214              :       CALL cp_print_key_section_create(print_key, __LOCATION__, name="NAMD_PRINT", &
     215              :                                        description="Adjust cartesian eigenvalues / vectors to NewtonX format.", &
     216              :                                        print_level=debug_print_level + 1, add_last=add_last_numeric, &
     217         9284 :                                        filename="FullNormalizedCartesian")
     218              :       CALL keyword_create(keyword, __LOCATION__, name="BACKUP_COPIES", &
     219              :                           description="Specifies the maximum number of backup copies.", &
     220              :                           usage="BACKUP_COPIES {int}", &
     221         9284 :                           default_i_val=1)
     222         9284 :       CALL section_add_keyword(print_key, keyword)
     223         9284 :       CALL keyword_release(keyword)
     224         9284 :       CALL section_add_subsection(section, print_key)
     225         9284 :       CALL section_release(print_key)
     226              : 
     227              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "HESSIAN", &
     228              :                                        description="Write the Hessian matrix from a vibrational analysis calculation "// &
     229              :                                        "into a binary file.", &
     230         9284 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="Hessian")
     231         9284 :       CALL section_add_subsection(section, print_key)
     232         9284 :       CALL section_release(print_key)
     233              : 
     234         9284 :    END SUBROUTINE create_print_vib_section
     235              : 
     236              : ! **************************************************************************************************
     237              : !> \brief Create the input section for MODE selective
     238              : !> \param section the section to create
     239              : !> \author fschiff
     240              : ! **************************************************************************************************
     241         9284 :    SUBROUTINE create_mode_selective_section(section)
     242              :       TYPE(section_type), POINTER                        :: section
     243              : 
     244              :       TYPE(keyword_type), POINTER                        :: keyword
     245              :       TYPE(section_type), POINTER                        :: print_key, subsection
     246              : 
     247         9284 :       NULLIFY (keyword, subsection, print_key)
     248         9284 :       CPASSERT(.NOT. ASSOCIATED(section))
     249              :       CALL section_create(section, __LOCATION__, name="MODE_SELECTIVE", &
     250              :                           description="All parameters needed for to run a mode selective vibrational analysis. "// &
     251              :                           "The keywords FREQUENCY, RANGE, and the subsection INVOLVED_ATOMS are mutually exclusive.", &
     252         9284 :                           n_keywords=8, n_subsections=1, repeats=.FALSE.)
     253              : 
     254              :       CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY", &
     255              :                           description="value close to the expected value of the frequency to look for. "// &
     256              :                           "If the block Davidson algorithm is applied, the nrep closest frequencies are tracked. ", &
     257         9284 :                           usage="FREQUENCY {REAL}", default_r_val=-1._dp)
     258         9284 :       CALL section_add_keyword(section, keyword)
     259         9284 :       CALL keyword_release(keyword)
     260              : 
     261              :       CALL keyword_create(keyword, __LOCATION__, name="RANGE", &
     262              :                           description="Track modes in a given range of frequencies. "// &
     263              :                           "No warranty that the set of frequencies is complete.", &
     264              :                           usage="RANGE {REAL} {REAL}", &
     265         9284 :                           n_var=-1, type_of_var=real_t)
     266         9284 :       CALL section_add_keyword(section, keyword)
     267         9284 :       CALL keyword_release(keyword)
     268              : 
     269              :       CALL keyword_create(keyword, __LOCATION__, name="LOWEST_FREQUENCY", &
     270              :                           description="Lowest frequency mode to include when writing output. "// &
     271              :                           "Use a negative value to print imaginary frequencies. "// &
     272              :                           "Useful for visualizing the imaginary frequency along a reaction path coordinate "// &
     273              :                           "Depending on accuracy settings, the output might include spurious low frequency "// &
     274              :                           "imaginary modes which should be visually checked (see MOLDEN_VIB).", &
     275         9284 :                           usage="LOWEST_FREQUENCY <REAL>", default_r_val=0.0_dp)
     276         9284 :       CALL section_add_keyword(section, keyword)
     277         9284 :       CALL keyword_release(keyword)
     278              : 
     279              :       CALL keyword_create(keyword, __LOCATION__, name="ATOMS", &
     280              :                           description="Specifies the list of atoms which should be displaced for the Initial guess", &
     281              :                           usage="ATOMS {integer} {integer} .. {integer}", &
     282         9284 :                           n_var=-1, type_of_var=integer_t)
     283         9284 :       CALL section_add_keyword(section, keyword)
     284         9284 :       CALL keyword_release(keyword)
     285              : 
     286              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_MAX_VAL", &
     287              :                           description="Convergence criterion for the davidson algorithm. Specifies the maximal value in the "// &
     288              :                           "residuum vectors ", &
     289         9284 :                           usage="EPS_MAX_VAL {REAL}", default_r_val=5.0E-7_dp)
     290         9284 :       CALL section_add_keyword(section, keyword)
     291         9284 :       CALL keyword_release(keyword)
     292              : 
     293              :       CALL keyword_create( &
     294              :          keyword, __LOCATION__, name="EPS_NORM", &
     295              :          description="Convergence criterion for the davidson algorithm. Specifies the maximal value of the norm "// &
     296              :          "of the residuum vectors ", &
     297         9284 :          usage="EPS_NORM {REAL}", default_r_val=2.0E-6_dp)
     298         9284 :       CALL section_add_keyword(section, keyword)
     299         9284 :       CALL keyword_release(keyword)
     300              : 
     301              :       CALL keyword_create( &
     302              :          keyword, __LOCATION__, name="INITIAL_GUESS", &
     303              :          description="The type of initial guess for the normal modes", &
     304              :          usage="INITIAL_GUESS BFGS_HESS", &
     305              :          default_i_val=ms_guess_atomic, &
     306              :          enum_c_vals=s2a("BFGS_HESS", "ATOMIC", "RESTART", "RESTART_VEC", "MOLDEN_RESTART"), &
     307              :          enum_desc=s2a("get the first displacement vector out of the BFGS approximate Hessian", &
     308              :                        "use random displacements for a set of atoms specified", &
     309              :                        "use data from MS_RESTART as initial guess", &
     310              :                        "use a vector from MS_RESTART, useful if you want to increase accurcy by changing functionals or basis", &
     311              :                        "use the .mol file of a former run, to restart a vector"// &
     312              :                        " (similar to Restart_vec, but a different file FORMAT is used)"), &
     313         9284 :          enum_i_vals=[ms_guess_bfgs, ms_guess_atomic, ms_guess_restart, ms_guess_restart_vec, ms_guess_molden])
     314         9284 :       CALL section_add_keyword(section, keyword)
     315         9284 :       CALL keyword_release(keyword)
     316              : 
     317              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_FILE_NAME", &
     318              :                           description="Specifies the name of the file used to create the restarted vectors", &
     319              :                           usage="RESTART_FILE_NAME {filename}", &
     320         9284 :                           default_lc_val="")
     321         9284 :       CALL section_add_keyword(section, keyword)
     322         9284 :       CALL keyword_release(keyword)
     323              : 
     324         9284 :       CALL create_involved_atoms_section(subsection)
     325         9284 :       CALL section_add_subsection(section, subsection)
     326         9284 :       CALL section_release(subsection)
     327              : 
     328              :       CALL section_create(subsection, __LOCATION__, name="PRINT", &
     329              :                           description="Controls the printing mode selective vibrational analysis", &
     330         9284 :                           n_keywords=0, n_subsections=1, repeats=.TRUE.)
     331              : 
     332              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "MS_RESTART", &
     333              :                                        description="Controls the printing of the Mode Selective Restart file.", &
     334              :                                        print_level=silent_print_level, common_iter_levels=1, &
     335         9284 :                                        add_last=add_last_numeric, filename="")
     336         9284 :       CALL section_add_subsection(subsection, print_key)
     337         9284 :       CALL section_release(print_key)
     338              : 
     339         9284 :       CALL section_add_subsection(section, subsection)
     340         9284 :       CALL section_release(subsection)
     341              : 
     342         9284 :    END SUBROUTINE create_mode_selective_section
     343              : 
     344              : ! **************************************************************************************************
     345              : !> \brief Create the input section for Ivolved_atoms keyword in mode selective
     346              : !> \param section the section to create
     347              : !> \author fschiff
     348              : ! **************************************************************************************************
     349         9284 :    SUBROUTINE create_involved_atoms_section(section)
     350              :       TYPE(section_type), POINTER                        :: section
     351              : 
     352              :       TYPE(keyword_type), POINTER                        :: keyword
     353              : 
     354         9284 :       NULLIFY (keyword)
     355         9284 :       CPASSERT(.NOT. ASSOCIATED(section))
     356              :       CALL section_create( &
     357              :          section, __LOCATION__, name="INVOLVED_ATOMS", &
     358              :          description="All parameters needed for the tracking of modes dominated by the motion of selected atoms. "// &
     359              :          "Warning, if many atoms are involved, only low frequency modes are detected, "// &
     360              :          "since they are more delocalized and match the tracked eigenvector.", &
     361         9284 :          n_keywords=2, n_subsections=0, repeats=.FALSE.)
     362              : 
     363              :       CALL keyword_create( &
     364              :          keyword, __LOCATION__, name="RANGE", &
     365              :          description=" Specifies the range of wavenumbers in which the modes related to the ATOMS have to be tracked."// &
     366              :          " If not specified frequencies >400cm-1 will be used to avoid tracking of translational or rotational modes", &
     367              :          usage="RANGE {REAL} {REAL}", &
     368         9284 :          n_var=-1, type_of_var=real_t)
     369         9284 :       CALL section_add_keyword(section, keyword)
     370         9284 :       CALL keyword_release(keyword)
     371              : 
     372              :       CALL keyword_create( &
     373              :          keyword, __LOCATION__, name="INVOLVED_ATOMS", &
     374              :          description="Specifies the list of atoms on which the tracked eigenvector should have the highest value "// &
     375              :          "similar to looking for the vibration of a set of atoms", &
     376              :          usage="INVOLVED_ATOMS {integer} {integer} .. {integer}", &
     377         9284 :          n_var=-1, type_of_var=integer_t)
     378         9284 :       CALL section_add_keyword(section, keyword)
     379         9284 :       CALL keyword_release(keyword)
     380              : 
     381         9284 :    END SUBROUTINE create_involved_atoms_section
     382              : 
     383              : END MODULE input_cp2k_vib
        

Generated by: LCOV version 2.0-1