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