LCOV - code coverage report
Current view: top level - src - input_cp2k_motion_print.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:561f475) Lines: 100.0 % 112 112
Test Date: 2026-06-21 06:48:54 Functions: 100.0 % 2 2

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

Generated by: LCOV version 2.0-1