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

            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              : !> \par History
      10              : !>      - taken out of input_cp2k_motion
      11              : !> \author Ole Schuett
      12              : ! **************************************************************************************************
      13              : MODULE input_cp2k_motion_print
      14              :    USE cp_output_handling,              ONLY: add_last_numeric,&
      15              :                                               cp_print_key_section_create,&
      16              :                                               high_print_level,&
      17              :                                               low_print_level,&
      18              :                                               silent_print_level
      19              :    USE input_constants,                 ONLY: dump_atomic,&
      20              :                                               dump_dcd,&
      21              :                                               dump_dcd_aligned_cell,&
      22              :                                               dump_pdb,&
      23              :                                               dump_xmol
      24              :    USE input_cp2k_subsys,               ONLY: create_structure_data_section
      25              :    USE input_keyword_types,             ONLY: keyword_create,&
      26              :                                               keyword_release,&
      27              :                                               keyword_type
      28              :    USE input_section_types,             ONLY: section_add_keyword,&
      29              :                                               section_add_subsection,&
      30              :                                               section_create,&
      31              :                                               section_release,&
      32              :                                               section_type
      33              :    USE string_utilities,                ONLY: s2a
      34              : #include "./base/base_uses.f90"
      35              : 
      36              :    IMPLICIT NONE
      37              :    PRIVATE
      38              : 
      39              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      40              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_motion_print'
      41              : 
      42              :    PUBLIC :: create_motion_print_section, add_format_keyword
      43              : 
      44              : CONTAINS
      45              : 
      46              : ! **************************************************************************************************
      47              : !> \brief creates the motion%print section
      48              : !> \param section the section to be created
      49              : !> \author teo
      50              : ! **************************************************************************************************
      51         9238 :    SUBROUTINE create_motion_print_section(section)
      52              :       TYPE(section_type), POINTER                        :: section
      53              : 
      54              :       TYPE(keyword_type), POINTER                        :: keyword
      55              :       TYPE(section_type), POINTER                        :: print_key
      56              : 
      57         9238 :       NULLIFY (keyword, section, print_key)
      58              : 
      59              :       CALL section_create(section, __LOCATION__, name="print", &
      60              :                           description="Controls the printing properties during an MD/Optimization run", &
      61         9238 :                           n_keywords=1, n_subsections=1, repeats=.TRUE.)
      62              : 
      63              :       CALL keyword_create(keyword, __LOCATION__, name="MEMORY_INFO", &
      64              :                           variants=(/"MEMORY"/), &
      65              :                           description="Whether overall memory usage should be sampled and printed "// &
      66              :                           "at each MD/Optimization step.", &
      67              :                           usage="MEMORY_INFO LOGICAL", &
      68        18476 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
      69         9238 :       CALL section_add_keyword(section, keyword)
      70         9238 :       CALL keyword_release(keyword)
      71              : 
      72              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "TRAJECTORY", &
      73              :                                        description="Controls the output of the trajectory", &
      74              :                                        print_level=low_print_level, common_iter_levels=1, &
      75         9238 :                                        filename="", unit_str="angstrom")
      76              :       CALL add_format_keyword(keyword, print_key, pos=.TRUE., &
      77         9238 :                               description="Specifies the format of the output file for the trajectory.")
      78         9238 :       CALL section_add_subsection(section, print_key)
      79         9238 :       CALL section_release(print_key)
      80              : 
      81              :       CALL cp_print_key_section_create( &
      82              :          print_key, __LOCATION__, "SHELL_TRAJECTORY", &
      83              :          description="Controls the output of the trajectory of shells when the shell-model is used ", &
      84              :          print_level=high_print_level, common_iter_levels=1, &
      85         9238 :          filename="", unit_str="angstrom")
      86              :       CALL add_format_keyword(keyword, print_key, pos=.TRUE., &
      87         9238 :                               description="Specifies the format of the output file for the trajectory of shells.")
      88         9238 :       CALL section_add_subsection(section, print_key)
      89         9238 :       CALL section_release(print_key)
      90              : 
      91              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CORE_TRAJECTORY", &
      92              :                                        description="Controls the output of the trajectory of cores when the shell-model is used ", &
      93              :                                        print_level=high_print_level, common_iter_levels=1, &
      94         9238 :                                        filename="", unit_str="angstrom")
      95              :       CALL add_format_keyword(keyword, print_key, pos=.TRUE., &
      96         9238 :                               description="Specifies the format of the output file for the trajectory of cores.")
      97         9238 :       CALL section_add_subsection(section, print_key)
      98         9238 :       CALL section_release(print_key)
      99              : 
     100              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CELL", &
     101              :                                        description="Controls the output of the simulation cell. "// &
     102              :                                        "For later analysis of the trajectory it is recommendable that the "// &
     103              :                                        "frequency of printing is the same as the one used for the trajectory file.", &
     104              :                                        print_level=high_print_level, common_iter_levels=1, &
     105         9238 :                                        filename="")
     106         9238 :       CALL section_add_subsection(section, print_key)
     107         9238 :       CALL section_release(print_key)
     108              : 
     109              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "VELOCITIES", &
     110              :                                        description="Controls the output of the atomic velocities. "// &
     111              :                                        "The default unit for the atomic velocities $v$ is bohr/au_time. "// &
     112              :                                        "The kinetic energy $K_i$ in [hartree] of an atom $i$ with mass $m_i$ in "// &
     113              :                                        "atomic mass units [amu] (or just [u]) and velocity $v_i$ can be obtained by "// &
     114              :                                        "$K_i = \frac{1}{2}f_u\,m_i\,v_i^2$ with $f_u = 1822.888$ as conversion factor "// &
     115              :                                        "from [u] to [a.u.]. $f_u$ is printed in full precision in the top of the CP2K "// &
     116              :                                        "output for print level MEDIUM or higher.", &
     117              :                                        print_level=high_print_level, common_iter_levels=1, &
     118         9238 :                                        filename="", unit_str="bohr*au_t^-1")
     119              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     120         9238 :                               description="Specifies the format of the output file for the velocities.")
     121         9238 :       CALL section_add_subsection(section, print_key)
     122         9238 :       CALL section_release(print_key)
     123              : 
     124              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "SHELL_VELOCITIES", &
     125              :                                        description="Controls the output of the velocities of shells when the shell model is used", &
     126              :                                        print_level=high_print_level, common_iter_levels=1, &
     127         9238 :                                        filename="", unit_str="bohr*au_t^-1")
     128              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     129         9238 :                               description="Specifies the format of the output file for the velocities of shells.")
     130         9238 :       CALL section_add_subsection(section, print_key)
     131         9238 :       CALL section_release(print_key)
     132              : 
     133              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CORE_VELOCITIES", &
     134              :                                        description="controls the output of the velocities of cores when the shell model is used", &
     135              :                                        print_level=high_print_level, common_iter_levels=1, &
     136         9238 :                                        filename="", unit_str="bohr*au_t^-1")
     137              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     138         9238 :                               description="Specifies the format of the output file for the velocities of cores.")
     139         9238 :       CALL section_add_subsection(section, print_key)
     140         9238 :       CALL section_release(print_key)
     141              : 
     142         9238 :       CALL create_structure_data_section(print_key)
     143         9238 :       CALL section_add_subsection(section, print_key)
     144         9238 :       CALL section_release(print_key)
     145              : 
     146              :       CALL cp_print_key_section_create( &
     147              :          print_key, __LOCATION__, "FORCE_MIXING_LABELS", &
     148              :          description="Controls the output of the force mixing (FORCE_EVAL&QMMM&FORCE_MIXING) labels", &
     149              :          print_level=high_print_level, common_iter_levels=1, &
     150         9238 :          filename="")
     151              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     152         9238 :                               description="Specifies the format of the output file for the force mixing labels.")
     153         9238 :       CALL section_add_subsection(section, print_key)
     154         9238 :       CALL section_release(print_key)
     155              : 
     156              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "FORCES", &
     157              :                                        description="Controls the output of the forces", &
     158              :                                        print_level=high_print_level, common_iter_levels=1, &
     159         9238 :                                        filename="", unit_str="hartree*bohr^-1")
     160              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     161         9238 :                               description="Specifies the format of the output file for the forces.")
     162         9238 :       CALL section_add_subsection(section, print_key)
     163         9238 :       CALL section_release(print_key)
     164              : 
     165              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "SHELL_FORCES", &
     166              :                                        description="Controls the output of the forces on shells when shell-model is used", &
     167              :                                        print_level=high_print_level, common_iter_levels=1, &
     168         9238 :                                        filename="", unit_str="hartree*bohr^-1")
     169              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     170         9238 :                               description="Specifies the format of the output file for the forces on shells.")
     171         9238 :       CALL section_add_subsection(section, print_key)
     172         9238 :       CALL section_release(print_key)
     173              : 
     174              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "CORE_FORCES", &
     175              :                                        description="Controls the output of the forces on cores when shell-model is used", &
     176              :                                        print_level=high_print_level, common_iter_levels=1, &
     177         9238 :                                        filename="", unit_str="hartree*bohr^-1")
     178              :       CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
     179         9238 :                               description="Specifies the format of the output file for the forces on cores.")
     180         9238 :       CALL section_add_subsection(section, print_key)
     181         9238 :       CALL section_release(print_key)
     182              : 
     183              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "MIXED_ENERGIES", &
     184              :                                        description="Controls the output of the energies of the two "// &
     185              :                                        "regular FORCE_EVALS in the MIXED method "// &
     186              :                                        "printed is step,time,Etot,E_F1,E_F2,CONS_QNT", &
     187              :                                        print_level=low_print_level, common_iter_levels=1, &
     188         9238 :                                        filename="")
     189         9238 :       CALL section_add_subsection(section, print_key)
     190         9238 :       CALL section_release(print_key)
     191              : 
     192              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "STRESS", &
     193              :                                        description="Controls the output of the stress tensor", &
     194              :                                        print_level=high_print_level, common_iter_levels=1, &
     195         9238 :                                        filename="")
     196         9238 :       CALL section_add_subsection(section, print_key)
     197         9238 :       CALL section_release(print_key)
     198              : 
     199              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "POLAR_MATRIX", &
     200              :                                        description="Controls the output of the polarisability tensor during an MD run", &
     201              :                                        print_level=low_print_level, common_iter_levels=1, &
     202         9238 :                                        filename="")
     203         9238 :       CALL section_add_subsection(section, print_key)
     204         9238 :       CALL section_release(print_key)
     205              : 
     206              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
     207              :                                        description="Controls the dumping of the restart file during runs. "// &
     208              :                                        "By default keeps a short history of three restarts. See also RESTART_HISTORY", &
     209              :                                        each_iter_names=s2a("MD"), each_iter_values=(/20/), &
     210              :                                        print_level=silent_print_level, common_iter_levels=1, &
     211         9238 :                                        add_last=add_last_numeric, filename="")
     212              : 
     213              :       CALL keyword_create(keyword, __LOCATION__, name="BACKUP_COPIES", &
     214              :                           description="Specifies the maximum number of backup copies.", &
     215              :                           usage="BACKUP_COPIES {int}", &
     216         9238 :                           default_i_val=1)
     217         9238 :       CALL section_add_keyword(print_key, keyword)
     218         9238 :       CALL keyword_release(keyword)
     219              : 
     220              :       CALL keyword_create(keyword, __LOCATION__, name="SPLIT_RESTART_FILE", &
     221              :                           description="If specified selected input sections, which are growing with the "// &
     222              :                           "number of atoms in the system, are written to another restart file "// &
     223              :                           "in binary format instead of the default restart file in human "// &
     224              :                           "readable ASCII format. This split of the restart file may "// &
     225              :                           "provide significant memory savings and an accelerated I/O for "// &
     226              :                           "systems with a very large number of atoms", &
     227              :                           usage="SPLIT_RESTART_FILE yes", &
     228              :                           default_l_val=.FALSE., &
     229         9238 :                           lone_keyword_l_val=.TRUE.)
     230         9238 :       CALL section_add_keyword(print_key, keyword)
     231         9238 :       CALL keyword_release(keyword)
     232              : 
     233         9238 :       CALL section_add_subsection(section, print_key)
     234         9238 :       CALL section_release(print_key)
     235              : 
     236              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART_HISTORY", &
     237              :                                        description="Dumps unique restart files during the run keeping all of them. "// &
     238              :                                        "Most useful if recovery is needed at a later point.", &
     239              :                                        print_level=low_print_level, common_iter_levels=0, &
     240              :                                        each_iter_names=s2a("MD", "GEO_OPT", "ROT_OPT"), each_iter_values=(/500, 500, 500/), &
     241         9238 :                                        filename="")
     242         9238 :       CALL section_add_subsection(section, print_key)
     243         9238 :       CALL section_release(print_key)
     244              : 
     245              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "TRANSLATION_VECTOR", &
     246              :                                        description="Dumps the translation vector applied along an MD (if any). Useful"// &
     247              :                                        " for postprocessing of QMMM trajectories in which the QM fragment is continuously"// &
     248              :                                        " centered in the QM box", &
     249              :                                        print_level=high_print_level, common_iter_levels=1, &
     250         9238 :                                        filename="")
     251         9238 :       CALL section_add_subsection(section, print_key)
     252         9238 :       CALL section_release(print_key)
     253              : 
     254         9238 :    END SUBROUTINE create_motion_print_section
     255              : 
     256              : ! **************************************************************************************************
     257              : !> \brief creates the FORMAT keyword
     258              : !> \param keyword ...
     259              : !> \param section will contain the pint section
     260              : !> \param pos ...
     261              : !> \param description ...
     262              : !> \author Teodoro Laino 10.2008 [tlaino]
     263              : ! **************************************************************************************************
     264       157168 :    SUBROUTINE add_format_keyword(keyword, section, pos, description)
     265              :       TYPE(keyword_type), POINTER                        :: keyword
     266              :       TYPE(section_type), POINTER                        :: section
     267              :       LOGICAL, INTENT(IN)                                :: pos
     268              :       CHARACTER(LEN=*), INTENT(IN)                       :: description
     269              : 
     270       157168 :       CPASSERT(ASSOCIATED(section))
     271       157168 :       CPASSERT(.NOT. ASSOCIATED(keyword))
     272              : 
     273       157168 :       IF (pos) THEN
     274              : 
     275              :          CALL keyword_create( &
     276              :             keyword, __LOCATION__, name="FORMAT", &
     277              :             description=description, usage="FORMAT (ATOMIC|DCD|PDB|XMOL|XYZ)", &
     278              :             default_i_val=dump_xmol, &
     279              :             enum_c_vals=s2a("ATOMIC", "DCD", "DCD_ALIGNED_CELL", "PDB", "XMOL", "XYZ"), &
     280              :             enum_i_vals=(/dump_atomic, dump_dcd, dump_dcd_aligned_cell, dump_pdb, dump_xmol, dump_xmol/), &
     281              :             enum_desc=s2a("Write only the coordinates X,Y,Z without element symbols to a formatted file", &
     282              :                           "Write the coordinates (no element labels) and the cell information to a binary file", &
     283              :                           "Like DCD, but the dumped coordinates refer to an aligned cell following the common convention: "// &
     284              :                           "the cell vector **a** is aligned with the *x* axis and the cell vector **b** lies in "// &
     285              :                           "the *xy* plane. This allows the reconstruction of scaled coordinates from the DCD data only.", &
     286              :                           "Write the atomic information in PDB format to a formatted file", &
     287              :                           "Mostly known as XYZ format, provides in a formatted file: element_symbol X Y Z", &
     288        83264 :                           "Alias name for XMOL"))
     289        83264 :          CALL section_add_keyword(section, keyword)
     290        83264 :          CALL keyword_release(keyword)
     291              : 
     292              :          CALL keyword_create(keyword, __LOCATION__, name="CHARGE_OCCUP", &
     293              :                              variants=(/"CHARGE_O"/), &
     294              :                              description="Write the MM charges to the OCCUP field of the PDB file", &
     295              :                              usage="CHARGE_OCCUP logical", &
     296       166528 :                              default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     297        83264 :          CALL section_add_keyword(section, keyword)
     298        83264 :          CALL keyword_release(keyword)
     299              : 
     300              :          CALL keyword_create(keyword, __LOCATION__, name="CHARGE_BETA", &
     301              :                              variants=(/"CHARGE_B"/), &
     302              :                              description="Write the MM charges to the BETA field of the PDB file", &
     303              :                              usage="CHARGE_BETA logical", &
     304       166528 :                              default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     305        83264 :          CALL section_add_keyword(section, keyword)
     306        83264 :          CALL keyword_release(keyword)
     307              : 
     308              :          CALL keyword_create(keyword, __LOCATION__, name="CHARGE_EXTENDED", &
     309              :                              description="Write the MM charges to the very last field of the PDB file (starting from column 81)", &
     310              :                              usage="CHARGE_EXTENDED logical", &
     311        83264 :                              default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     312        83264 :          CALL section_add_keyword(section, keyword)
     313        83264 :          CALL keyword_release(keyword)
     314              : 
     315              :       ELSE
     316              : 
     317              :          CALL keyword_create(keyword, __LOCATION__, name="FORMAT", &
     318              :                              description=description, usage="FORMAT (ATOMIC|DCD|XMOL|XYZ)", &
     319              :                              default_i_val=dump_xmol, &
     320              :                              enum_c_vals=s2a("ATOMIC", "DCD", "XMOL", "XYZ"), &
     321              :                              enum_i_vals=(/dump_atomic, dump_dcd, dump_xmol, dump_xmol/), &
     322              :                              enum_desc=s2a("Write only the coordinates X,Y,Z without element symbols to a formatted file", &
     323              :                                            "Write the coordinates (no element labels) and the cell information to a binary file", &
     324              :                                            "Mostly known as XYZ format, provides in a formatted file: element_symbol X Y Z", &
     325        73904 :                                            "Alias name for XMOL"))
     326        73904 :          CALL section_add_keyword(section, keyword)
     327        73904 :          CALL keyword_release(keyword)
     328              : 
     329              :       END IF
     330              : 
     331              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_ATOM_KIND", &
     332              :                           description="Write the atom kind given in the subsys section instead of the element symbol. "// &
     333              :                           "Only valid for the XMOL format.", &
     334              :                           usage="PRINT_ATOM_KIND logical", &
     335       157168 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     336       157168 :       CALL section_add_keyword(section, keyword)
     337       157168 :       CALL keyword_release(keyword)
     338              : 
     339       157168 :    END SUBROUTINE add_format_keyword
     340              : 
     341              : END MODULE input_cp2k_motion_print
        

Generated by: LCOV version 2.0-1