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