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 1462 : 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 1462 : 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 1462 : 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 2924 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
70 1462 : CALL section_add_keyword(section, keyword)
71 1462 : 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 1462 : filename="", unit_str="angstrom")
77 : CALL add_format_keyword(keyword, print_key, pos=.TRUE., &
78 1462 : description="Specifies the format of the output file for the trajectory.")
79 1462 : CALL section_add_subsection(section, print_key)
80 1462 : 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 1462 : filename="", unit_str="angstrom")
87 : CALL add_format_keyword(keyword, print_key, pos=.TRUE., &
88 1462 : description="Specifies the format of the output file for the trajectory of shells.")
89 1462 : CALL section_add_subsection(section, print_key)
90 1462 : 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 1462 : filename="", unit_str="angstrom")
96 : CALL add_format_keyword(keyword, print_key, pos=.TRUE., &
97 1462 : description="Specifies the format of the output file for the trajectory of cores.")
98 1462 : CALL section_add_subsection(section, print_key)
99 1462 : 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 1462 : filename="")
107 1462 : CALL section_add_subsection(section, print_key)
108 1462 : 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 1462 : filename="", unit_str="bohr*au_t^-1")
120 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
121 1462 : description="Specifies the format of the output file for the velocities.")
122 1462 : CALL section_add_subsection(section, print_key)
123 1462 : 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 1462 : filename="", unit_str="bohr*au_t^-1")
129 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
130 1462 : description="Specifies the format of the output file for the velocities of shells.")
131 1462 : CALL section_add_subsection(section, print_key)
132 1462 : 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 1462 : filename="", unit_str="bohr*au_t^-1")
138 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
139 1462 : description="Specifies the format of the output file for the velocities of cores.")
140 1462 : CALL section_add_subsection(section, print_key)
141 1462 : CALL section_release(print_key)
142 :
143 1462 : CALL create_structure_data_section(print_key)
144 1462 : CALL section_add_subsection(section, print_key)
145 1462 : 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 geometry "// &
149 : "and cell for optimization tasks. Currently CIF and XYZ "// &
150 : "formats are available, as controlled independently by "// &
151 : "PRINT_CIF and PRINT_XYZ respectively, with the same "// &
152 : "file name except for extension suffix.", &
153 1462 : print_level=low_print_level, filename="FINAL")
154 :
155 : CALL keyword_create(keyword, __LOCATION__, name="PRINT_CIF", &
156 : description="Print the final structure as CIF. Currently "// &
157 : "the structure will always be dumped with the asymmetric "// &
158 : "space group `P 1` as a triclinic system with a single "// &
159 : "symmetry-equivalent position `x, y, z` for all atoms. "// &
160 : "All fractional coordinates are in the range [0,1] and "// &
161 : "all occupancies are unity.", &
162 : usage="PRINT_CIF T", default_l_val=.TRUE., &
163 1462 : lone_keyword_l_val=.TRUE.)
164 1462 : CALL section_add_keyword(print_key, keyword)
165 1462 : CALL keyword_release(keyword)
166 :
167 : CALL keyword_create(keyword, __LOCATION__, name="PRINT_XYZ", &
168 : description="Print the final structure as XYZ. The cell "// &
169 : "information is available in the comment line according "// &
170 : "to the extended XYZ specification as the `Lattice=...` "// &
171 : "field, and the unit is angstrom for both the cell vectors "// &
172 : "and the atomic coordinates.", &
173 : usage="PRINT_XYZ T", default_l_val=.TRUE., &
174 1462 : lone_keyword_l_val=.TRUE.)
175 1462 : CALL section_add_keyword(print_key, keyword)
176 1462 : CALL keyword_release(keyword)
177 :
178 : CALL keyword_create(keyword, __LOCATION__, name="PRINT_ATOM_KIND", &
179 : description="Write the atom kind given in the subsys section instead "// &
180 : "of the element symbol in the extended XYZ file.", &
181 : usage="PRINT_ATOM_KIND {LOGICAL}", &
182 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
183 1462 : CALL section_add_keyword(print_key, keyword)
184 1462 : CALL keyword_release(keyword)
185 :
186 1462 : CALL section_add_subsection(section, print_key)
187 1462 : CALL section_release(print_key)
188 :
189 : CALL cp_print_key_section_create( &
190 : print_key, __LOCATION__, "FORCE_MIXING_LABELS", &
191 : description="Controls the output of the force mixing (FORCE_EVAL&QMMM&FORCE_MIXING) labels", &
192 : print_level=high_print_level, common_iter_levels=1, &
193 1462 : filename="")
194 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
195 1462 : description="Specifies the format of the output file for the force mixing labels.")
196 1462 : CALL section_add_subsection(section, print_key)
197 1462 : CALL section_release(print_key)
198 :
199 : CALL cp_print_key_section_create(print_key, __LOCATION__, "FORCES", &
200 : description="Controls the output of the forces", &
201 : print_level=high_print_level, common_iter_levels=1, &
202 1462 : filename="", unit_str="hartree*bohr^-1")
203 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
204 1462 : description="Specifies the format of the output file for the forces.")
205 1462 : CALL section_add_subsection(section, print_key)
206 1462 : CALL section_release(print_key)
207 :
208 : CALL cp_print_key_section_create(print_key, __LOCATION__, "SHELL_FORCES", &
209 : description="Controls the output of the forces on shells when shell-model is used", &
210 : print_level=high_print_level, common_iter_levels=1, &
211 1462 : filename="", unit_str="hartree*bohr^-1")
212 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
213 1462 : description="Specifies the format of the output file for the forces on shells.")
214 1462 : CALL section_add_subsection(section, print_key)
215 1462 : CALL section_release(print_key)
216 :
217 : CALL cp_print_key_section_create(print_key, __LOCATION__, "CORE_FORCES", &
218 : description="Controls the output of the forces on cores when shell-model is used", &
219 : print_level=high_print_level, common_iter_levels=1, &
220 1462 : filename="", unit_str="hartree*bohr^-1")
221 : CALL add_format_keyword(keyword, print_key, pos=.FALSE., &
222 1462 : description="Specifies the format of the output file for the forces on cores.")
223 1462 : CALL section_add_subsection(section, print_key)
224 1462 : CALL section_release(print_key)
225 :
226 : CALL cp_print_key_section_create(print_key, __LOCATION__, "MIXED_ENERGIES", &
227 : description="Controls the output of the energies of the two "// &
228 : "regular FORCE_EVALS in the MIXED method "// &
229 : "printed is step,time,Etot,E_F1,E_F2,CONS_QNT", &
230 : print_level=low_print_level, common_iter_levels=1, &
231 1462 : filename="")
232 1462 : CALL section_add_subsection(section, print_key)
233 1462 : CALL section_release(print_key)
234 :
235 : CALL cp_print_key_section_create(print_key, __LOCATION__, "STRESS", &
236 : description="Controls the output of the stress tensor", &
237 : print_level=high_print_level, common_iter_levels=1, &
238 1462 : filename="")
239 1462 : CALL section_add_subsection(section, print_key)
240 1462 : CALL section_release(print_key)
241 :
242 : CALL cp_print_key_section_create(print_key, __LOCATION__, "POLAR_MATRIX", &
243 : description="Controls the output of the polarisability tensor during an MD run", &
244 : print_level=low_print_level, common_iter_levels=1, &
245 1462 : filename="")
246 1462 : CALL section_add_subsection(section, print_key)
247 1462 : CALL section_release(print_key)
248 :
249 : CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
250 : description="Controls the dumping of the latest motion restart file "// &
251 : "during runs. The file suffix will be .restart by default, which is "// &
252 : "ASCII plain-text in the same format as an input file, unless the "// &
253 : "SPLIT_RESTART_FILE keyword is specified. A plain-text file can be "// &
254 : "used directly or parsed by the EXT_RESTART section for fine controls "// &
255 : "over the reuse of different information. See also RESTART_HISTORY.", &
256 : each_iter_names=s2a("MD"), each_iter_values=[20], &
257 : print_level=silent_print_level, common_iter_levels=1, &
258 1462 : add_last=add_last_numeric, filename="", do_backup=.TRUE.)
259 :
260 : CALL keyword_create(keyword, __LOCATION__, name="SPLIT_RESTART_FILE", &
261 : description="If specified selected input sections, which are growing with the "// &
262 : "number of atoms in the system, are written to another restart file "// &
263 : "in binary format instead of the default restart file in human "// &
264 : "readable ASCII format. This split of the restart file may "// &
265 : "provide significant memory savings and an accelerated I/O for "// &
266 : "systems with a very large number of atoms", &
267 : usage="SPLIT_RESTART_FILE yes", &
268 : default_l_val=.FALSE., &
269 1462 : lone_keyword_l_val=.TRUE.)
270 1462 : CALL section_add_keyword(print_key, keyword)
271 1462 : CALL keyword_release(keyword)
272 :
273 1462 : CALL section_add_subsection(section, print_key)
274 1462 : CALL section_release(print_key)
275 :
276 : CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART_HISTORY", &
277 : description="Dumps unique motion restart files during the run, "// &
278 : "keeping all of them. Most useful if recovery is needed at a "// &
279 : "later point. For the latest motion restart file, see RESTART.", &
280 : print_level=low_print_level, common_iter_levels=0, &
281 : each_iter_names=s2a("MD", "GEO_OPT", "ROT_OPT"), each_iter_values=[500, 500, 500], &
282 1462 : filename="")
283 1462 : CALL section_add_subsection(section, print_key)
284 1462 : CALL section_release(print_key)
285 :
286 : CALL cp_print_key_section_create(print_key, __LOCATION__, "TRANSLATION_VECTOR", &
287 : description="Dumps the translation vector applied along an MD (if any). Useful"// &
288 : " for postprocessing of QMMM trajectories in which the QM fragment is continuously"// &
289 : " centered in the QM box", &
290 : print_level=high_print_level, common_iter_levels=1, &
291 1462 : filename="")
292 1462 : CALL section_add_subsection(section, print_key)
293 1462 : CALL section_release(print_key)
294 :
295 1462 : END SUBROUTINE create_motion_print_section
296 :
297 : ! **************************************************************************************************
298 : !> \brief creates the FORMAT keyword
299 : !> \param keyword ...
300 : !> \param section will contain the pint section
301 : !> \param pos ...
302 : !> \param description ...
303 : !> \author Teodoro Laino 10.2008 [tlaino]
304 : ! **************************************************************************************************
305 24996 : SUBROUTINE add_format_keyword(keyword, section, pos, description)
306 : TYPE(keyword_type), POINTER :: keyword
307 : TYPE(section_type), POINTER :: section
308 : LOGICAL, INTENT(IN) :: pos
309 : CHARACTER(LEN=*), INTENT(IN) :: description
310 :
311 24996 : CPASSERT(ASSOCIATED(section))
312 24996 : CPASSERT(.NOT. ASSOCIATED(keyword))
313 :
314 24996 : IF (pos) THEN
315 :
316 : CALL keyword_create( &
317 : keyword, __LOCATION__, name="FORMAT", &
318 : description=description, usage="FORMAT (ATOMIC|DCD|PDB|XMOL|XYZ|EXTXYZ)", &
319 : default_i_val=dump_xmol, &
320 : enum_c_vals=s2a("ATOMIC", "DCD", "DCD_ALIGNED_CELL", "PDB", "XMOL", "XYZ", "EXTXYZ"), &
321 : enum_i_vals=[dump_atomic, dump_dcd, dump_dcd_aligned_cell, dump_pdb, dump_xmol, dump_xmol, dump_extxyz], &
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 : "Like DCD, but the dumped coordinates refer to an aligned cell following the common convention: "// &
325 : "the cell vector **a** is aligned with the *x* axis and the cell vector **b** lies in "// &
326 : "the *xy* plane. This allows the reconstruction of scaled coordinates from the DCD data only.", &
327 : "Write the atomic information in PDB format to a formatted file", &
328 : "Mostly known as XYZ format, provides in a formatted file: element_symbol X Y Z", &
329 : "Alias name for XMOL", &
330 : "Extended XYZ format including cell information. "// &
331 : "For details see [ASE](https://ase-lib.org/ase/io/formatoptions.html#extxyz) "// &
332 13300 : "and [OVITO](https://www.ovito.org/manual/reference/file_formats/input/xyz.html)."))
333 13300 : CALL section_add_keyword(section, keyword)
334 13300 : CALL keyword_release(keyword)
335 :
336 : CALL keyword_create(keyword, __LOCATION__, name="CHARGE_OCCUP", &
337 : variants=["CHARGE_O"], &
338 : description="Write the MM charges to the OCCUP field of the PDB file", &
339 : usage="CHARGE_OCCUP logical", &
340 26600 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
341 13300 : CALL section_add_keyword(section, keyword)
342 13300 : CALL keyword_release(keyword)
343 :
344 : CALL keyword_create(keyword, __LOCATION__, name="CHARGE_BETA", &
345 : variants=["CHARGE_B"], &
346 : description="Write the MM charges to the BETA field of the PDB file", &
347 : usage="CHARGE_BETA logical", &
348 26600 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
349 13300 : CALL section_add_keyword(section, keyword)
350 13300 : CALL keyword_release(keyword)
351 :
352 : CALL keyword_create(keyword, __LOCATION__, name="CHARGE_EXTENDED", &
353 : description="Write the MM charges to the very last field of the PDB file (starting from column 81)", &
354 : usage="CHARGE_EXTENDED logical", &
355 13300 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
356 13300 : CALL section_add_keyword(section, keyword)
357 13300 : CALL keyword_release(keyword)
358 :
359 : ELSE
360 :
361 : CALL keyword_create(keyword, __LOCATION__, name="FORMAT", &
362 : description=description, usage="FORMAT (ATOMIC|DCD|XMOL|XYZ|EXTXYZ)", &
363 : default_i_val=dump_xmol, &
364 : enum_c_vals=s2a("ATOMIC", "DCD", "XMOL", "XYZ", "EXTXYZ"), &
365 : enum_i_vals=[dump_atomic, dump_dcd, dump_xmol, dump_xmol, dump_extxyz], &
366 : enum_desc=s2a("Write only the coordinates X,Y,Z without element symbols to a formatted file", &
367 : "Write the coordinates (no element labels) and the cell information to a binary file", &
368 : "Mostly known as XYZ format, provides in a formatted file: element_symbol X Y Z", &
369 : "Alias name for XMOL", &
370 : "Extended XYZ format including cell information. "// &
371 : "For details see [ASE](https://ase-lib.org/ase/io/formatoptions.html#extxyz) "// &
372 11696 : "and [OVITO](https://www.ovito.org/manual/reference/file_formats/input/xyz.html)."))
373 11696 : CALL section_add_keyword(section, keyword)
374 11696 : CALL keyword_release(keyword)
375 :
376 : END IF
377 :
378 : CALL keyword_create(keyword, __LOCATION__, name="PRINT_ATOM_KIND", &
379 : description="Write the atom kind given in the subsys section instead of the element symbol. "// &
380 : "Only valid for the XMOL and EXTXYZ format.", &
381 : usage="PRINT_ATOM_KIND logical", &
382 24996 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
383 24996 : CALL section_add_keyword(section, keyword)
384 24996 : CALL keyword_release(keyword)
385 :
386 24996 : END SUBROUTINE add_format_keyword
387 :
388 : END MODULE input_cp2k_motion_print
|