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 : !> \brief builds the input structure for the VIBRATIONAL_ANALYSIS module
10 : !> \par History
11 : !> 01.2008 [tlaino] Teodoro Laino - University of Zurich
12 : !> Creating an own module for vibrational analysis
13 : !> \author [tlaino]
14 : ! **************************************************************************************************
15 : MODULE input_cp2k_vib
16 : USE cp_output_handling, ONLY: add_last_numeric,&
17 : cp_print_key_section_create,&
18 : debug_print_level,&
19 : low_print_level,&
20 : medium_print_level,&
21 : silent_print_level
22 : USE cp_units, ONLY: cp_unit_to_cp2k
23 : USE input_constants, ONLY: do_rep_blocked,&
24 : do_rep_interleaved,&
25 : ms_guess_atomic,&
26 : ms_guess_bfgs,&
27 : ms_guess_molden,&
28 : ms_guess_restart,&
29 : ms_guess_restart_vec
30 : USE input_keyword_types, ONLY: keyword_create,&
31 : keyword_release,&
32 : keyword_type
33 : USE input_section_types, ONLY: section_add_keyword,&
34 : section_add_subsection,&
35 : section_create,&
36 : section_release,&
37 : section_type
38 : USE input_val_types, ONLY: integer_t,&
39 : real_t
40 : USE kinds, ONLY: dp
41 : USE string_utilities, ONLY: s2a
42 : #include "../base/base_uses.f90"
43 :
44 : IMPLICIT NONE
45 : PRIVATE
46 :
47 : LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
48 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_vib'
49 :
50 : PUBLIC :: create_vib_section
51 : CONTAINS
52 :
53 : ! **************************************************************************************************
54 : !> \brief Creates the exteranal restart section
55 : !> \param section the section to create
56 : !> \author tlaino
57 : ! **************************************************************************************************
58 1480 : SUBROUTINE create_vib_section(section)
59 : TYPE(section_type), POINTER :: section
60 :
61 : TYPE(keyword_type), POINTER :: keyword
62 : TYPE(section_type), POINTER :: subsection
63 :
64 1480 : CPASSERT(.NOT. ASSOCIATED(section))
65 : CALL section_create( &
66 : section, __LOCATION__, name="VIBRATIONAL_ANALYSIS", &
67 : description="Section to setup parameters to perform a Normal Modes, vibrational, or phonon analysis. "// &
68 : "Vibrations are computed using finite differences, "// &
69 : "which implies a very tight (e.g. 1E-8) threshold is needed for EPS_SCF to get accurate low frequencies. "// &
70 : "The analysis assumes a stationary state (minimum or TS),"// &
71 : " i.e. tight geometry optimization (MAX_FORCE) is needed as well.", &
72 1480 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
73 1480 : NULLIFY (keyword, subsection)
74 :
75 : CALL keyword_create(keyword, __LOCATION__, name="DX", &
76 : description="Specify the increment to be used to construct the HESSIAN with "// &
77 : "finite difference method", &
78 1480 : default_r_val=1.0E-2_dp, unit_str="bohr")
79 1480 : CALL section_add_keyword(section, keyword)
80 1480 : CALL keyword_release(keyword)
81 :
82 : CALL keyword_create(keyword, __LOCATION__, name="NPROC_REP", &
83 : description="Specify the number of processors to be used per replica "// &
84 : "environment (for parallel runs). "// &
85 : "In case of mode selective calculations more than one replica will start"// &
86 : " a block Davidson algorithm to track more than only one frequency", &
87 1480 : default_i_val=1)
88 1480 : CALL section_add_keyword(section, keyword)
89 1480 : CALL keyword_release(keyword)
90 :
91 : CALL keyword_create(keyword, __LOCATION__, name="PROC_DIST_TYPE", &
92 : description="Specify the topology of the mapping of processors into replicas.", &
93 : usage="PROC_DIST_TYPE (INTERLEAVED|BLOCKED)", &
94 : enum_c_vals=s2a("INTERLEAVED", &
95 : "BLOCKED"), &
96 : enum_desc=s2a("Interleaved distribution", &
97 : "Blocked distribution"), &
98 : enum_i_vals=[do_rep_interleaved, do_rep_blocked], &
99 1480 : default_i_val=do_rep_blocked)
100 1480 : CALL section_add_keyword(section, keyword)
101 1480 : CALL keyword_release(keyword)
102 :
103 : CALL keyword_create(keyword, __LOCATION__, name="FULLY_PERIODIC", &
104 : description="Avoids to clean rotations from the Hessian matrix.", &
105 1480 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
106 1480 : CALL section_add_keyword(section, keyword)
107 1480 : CALL keyword_release(keyword)
108 :
109 : CALL keyword_create(keyword, __LOCATION__, name="INTENSITIES", &
110 : description="Calculation of the IR/Raman-Intensities. "// &
111 : "Calculation of dipoles and/or polarizabilities have to be "// &
112 : "specified explicitly in DFT/PRINT/MOMENTS and/or "// &
113 : "PROPERTIES/LINRES/POLAR", &
114 1480 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
115 1480 : CALL section_add_keyword(section, keyword)
116 1480 : CALL keyword_release(keyword)
117 :
118 : CALL keyword_create(keyword, __LOCATION__, name="THERMOCHEMISTRY", &
119 : description="Calculation of the thermochemical data. Valid for molecules in "// &
120 : "the gas phase, not supporting phonon frequencies at general **q**-points "// &
121 : "beyond wave vector **q** at gamma point. Based on the rigid-rotor harmonic "// &
122 : "oscillator (RRHO) model, which is known to break down if very low vibrational "// &
123 : "frequencies are present in a flexible system.", &
124 1480 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
125 1480 : CALL section_add_keyword(section, keyword)
126 1480 : CALL keyword_release(keyword)
127 :
128 : CALL keyword_create(keyword, __LOCATION__, name="TC_TEMPERATURE", &
129 : description="Temperature for the calculation of the thermochemical data ", &
130 : usage="tc_temperature 325.0", default_r_val=cp_unit_to_cp2k(value=273.150_dp, unit_str="K"), &
131 1480 : unit_str="K")
132 1480 : CALL section_add_keyword(section, keyword)
133 1480 : CALL keyword_release(keyword)
134 :
135 : CALL keyword_create(keyword, __LOCATION__, name="TC_PRESSURE", &
136 : description="Pressure for the calculation of the thermochemical data ", &
137 1480 : default_r_val=cp_unit_to_cp2k(value=101325.0_dp, unit_str="Pa"), unit_str="Pa")
138 1480 : CALL section_add_keyword(section, keyword)
139 1480 : CALL keyword_release(keyword)
140 :
141 : CALL keyword_create(keyword, __LOCATION__, name="EPS_SYMMETRY", &
142 : description="Accuracy for detection of rotational symmetry number.", &
143 : usage="EPS_SYMMETRY {REAL}", &
144 1480 : default_r_val=1.0e-4_dp, repeats=.FALSE.)
145 1480 : CALL section_add_keyword(section, keyword)
146 1480 : CALL keyword_release(keyword)
147 :
148 1480 : CALL create_mode_selective_section(subsection)
149 1480 : CALL section_add_subsection(section, subsection)
150 1480 : CALL section_release(subsection)
151 :
152 1480 : CALL create_print_vib_section(subsection)
153 1480 : CALL section_add_subsection(section, subsection)
154 1480 : CALL section_release(subsection)
155 1480 : END SUBROUTINE create_vib_section
156 :
157 : ! **************************************************************************************************
158 : !> \brief Create the print section for VIB
159 : !> \param section the section to create
160 : !> \author Teodoro Laino [tlaino] - 10.2008
161 : ! **************************************************************************************************
162 1480 : SUBROUTINE create_print_vib_section(section)
163 : TYPE(section_type), POINTER :: section
164 :
165 : TYPE(keyword_type), POINTER :: keyword
166 : TYPE(section_type), POINTER :: print_key
167 :
168 1480 : CPASSERT(.NOT. ASSOCIATED(section))
169 : CALL section_create(section, __LOCATION__, name="PRINT", &
170 : description="Section controlling the print information during a vibrational "// &
171 1480 : "analysis.", n_keywords=1, n_subsections=0, repeats=.FALSE.)
172 1480 : NULLIFY (keyword, print_key)
173 :
174 : CALL cp_print_key_section_create(print_key, __LOCATION__, "BANNER", &
175 : description="Controls the printing of the vibrational analysis banner", &
176 : print_level=low_print_level, common_iter_levels=1, &
177 1480 : filename="__STD_OUT__")
178 1480 : CALL section_add_subsection(section, print_key)
179 1480 : CALL section_release(print_key)
180 :
181 : CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
182 : description="Controls the printing basic info about the vibrational method", &
183 1480 : print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
184 1480 : CALL section_add_subsection(section, print_key)
185 1480 : CALL section_release(print_key)
186 :
187 : CALL cp_print_key_section_create(print_key, __LOCATION__, "MOLDEN_VIB", &
188 : description="Controls the printing for visualization in molden format", &
189 1480 : print_level=low_print_level, add_last=add_last_numeric, filename="VIBRATIONS")
190 : CALL keyword_create(keyword, __LOCATION__, name="WRITE_CELL", &
191 : description="Controls whether the CP2K [Cell] extension is written to the MOLDEN file. "// &
192 : "The cell vectors are written in atomic units to match the vibrational coordinates.", &
193 : usage="WRITE_CELL T", &
194 1480 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
195 1480 : CALL section_add_keyword(print_key, keyword)
196 1480 : CALL keyword_release(keyword)
197 1480 : CALL section_add_subsection(section, print_key)
198 1480 : CALL section_release(print_key)
199 :
200 : CALL cp_print_key_section_create(print_key, __LOCATION__, "ROTATIONAL_INFO", &
201 : description="Controls the printing basic info during the cleaning of the "// &
202 : "rotational degrees of freedom.", &
203 1480 : print_level=debug_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
204 : ! Print_key keywords
205 : CALL keyword_create(keyword, __LOCATION__, name="COORDINATES", &
206 : description="Prints atomic coordinates after rotation", &
207 1480 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
208 1480 : CALL section_add_keyword(print_key, keyword)
209 1480 : CALL keyword_release(keyword)
210 1480 : CALL section_add_subsection(section, print_key)
211 1480 : CALL section_release(print_key)
212 :
213 : CALL cp_print_key_section_create(print_key, __LOCATION__, "CARTESIAN_EIGS", &
214 : description="Controls the printing of Cartesian "// &
215 : "frequencies and eigenvectors of the Hessian used "// &
216 : "for initializing ensemble for MD calculations. "// &
217 : "This should always print to a file, and will not "// &
218 : "effect the same frequencies and eigenvectors printed "// &
219 : "in the main vibrational analysis output", &
220 : print_level=low_print_level, &
221 : add_last=add_last_numeric, &
222 1480 : filename="VIBRATIONS", do_backup=.TRUE.)
223 1480 : CALL section_add_subsection(section, print_key)
224 1480 : CALL section_release(print_key)
225 :
226 : CALL cp_print_key_section_create(print_key, __LOCATION__, name="NAMD_PRINT", &
227 : description="Adjust cartesian eigenvalues / vectors to NewtonX format.", &
228 : print_level=debug_print_level + 1, add_last=add_last_numeric, &
229 1480 : filename="FullNormalizedCartesian", do_backup=.TRUE.)
230 1480 : CALL section_add_subsection(section, print_key)
231 1480 : CALL section_release(print_key)
232 :
233 : CALL cp_print_key_section_create(print_key, __LOCATION__, "HESSIAN", &
234 : description="Write the Hessian matrix from a vibrational analysis calculation "// &
235 : "into a binary file.", &
236 1480 : print_level=low_print_level, add_last=add_last_numeric, filename="Hessian")
237 1480 : CALL section_add_subsection(section, print_key)
238 1480 : CALL section_release(print_key)
239 :
240 1480 : END SUBROUTINE create_print_vib_section
241 :
242 : ! **************************************************************************************************
243 : !> \brief Create the input section for MODE selective
244 : !> \param section the section to create
245 : !> \author fschiff
246 : ! **************************************************************************************************
247 1480 : SUBROUTINE create_mode_selective_section(section)
248 : TYPE(section_type), POINTER :: section
249 :
250 : TYPE(keyword_type), POINTER :: keyword
251 : TYPE(section_type), POINTER :: print_key, subsection
252 :
253 1480 : NULLIFY (keyword, subsection, print_key)
254 1480 : CPASSERT(.NOT. ASSOCIATED(section))
255 : CALL section_create(section, __LOCATION__, name="MODE_SELECTIVE", &
256 : description="All parameters needed for to run a mode selective vibrational analysis. "// &
257 : "The keywords FREQUENCY, RANGE, and the subsection INVOLVED_ATOMS are mutually exclusive.", &
258 1480 : n_keywords=8, n_subsections=1, repeats=.FALSE.)
259 :
260 : CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY", &
261 : description="value close to the expected value of the frequency to look for. "// &
262 : "If the block Davidson algorithm is applied, the nrep closest frequencies are tracked. ", &
263 1480 : usage="FREQUENCY {REAL}", default_r_val=-1._dp)
264 1480 : CALL section_add_keyword(section, keyword)
265 1480 : CALL keyword_release(keyword)
266 :
267 : CALL keyword_create(keyword, __LOCATION__, name="RANGE", &
268 : description="Track modes in a given range of frequencies. "// &
269 : "No warranty that the set of frequencies is complete.", &
270 : usage="RANGE {REAL} {REAL}", &
271 1480 : n_var=-1, type_of_var=real_t)
272 1480 : CALL section_add_keyword(section, keyword)
273 1480 : CALL keyword_release(keyword)
274 :
275 : CALL keyword_create(keyword, __LOCATION__, name="LOWEST_FREQUENCY", &
276 : description="Lowest frequency mode to include when writing output. "// &
277 : "Use a negative value to print imaginary frequencies. "// &
278 : "Useful for visualizing the imaginary frequency along a reaction path coordinate "// &
279 : "Depending on accuracy settings, the output might include spurious low frequency "// &
280 : "imaginary modes which should be visually checked (see MOLDEN_VIB).", &
281 1480 : usage="LOWEST_FREQUENCY <REAL>", default_r_val=0.0_dp)
282 1480 : CALL section_add_keyword(section, keyword)
283 1480 : CALL keyword_release(keyword)
284 :
285 : CALL keyword_create(keyword, __LOCATION__, name="ATOMS", &
286 : description="Specifies the list of atoms which should be displaced for the Initial guess", &
287 : usage="ATOMS {integer} {integer} .. {integer}", &
288 1480 : n_var=-1, type_of_var=integer_t)
289 1480 : CALL section_add_keyword(section, keyword)
290 1480 : CALL keyword_release(keyword)
291 :
292 : CALL keyword_create(keyword, __LOCATION__, name="EPS_MAX_VAL", &
293 : description="Convergence criterion for the davidson algorithm. Specifies the maximal value in the "// &
294 : "residuum vectors ", &
295 1480 : usage="EPS_MAX_VAL {REAL}", default_r_val=5.0E-7_dp)
296 1480 : CALL section_add_keyword(section, keyword)
297 1480 : CALL keyword_release(keyword)
298 :
299 : CALL keyword_create( &
300 : keyword, __LOCATION__, name="EPS_NORM", &
301 : description="Convergence criterion for the davidson algorithm. Specifies the maximal value of the norm "// &
302 : "of the residuum vectors ", &
303 1480 : usage="EPS_NORM {REAL}", default_r_val=2.0E-6_dp)
304 1480 : CALL section_add_keyword(section, keyword)
305 1480 : CALL keyword_release(keyword)
306 :
307 : CALL keyword_create( &
308 : keyword, __LOCATION__, name="INITIAL_GUESS", &
309 : description="The type of initial guess for the normal modes", &
310 : usage="INITIAL_GUESS BFGS_HESS", &
311 : default_i_val=ms_guess_atomic, &
312 : enum_c_vals=s2a("BFGS_HESS", "ATOMIC", "RESTART", "RESTART_VEC", "MOLDEN_RESTART"), &
313 : enum_desc=s2a("get the first displacement vector out of the BFGS approximate Hessian", &
314 : "use random displacements for a set of atoms specified", &
315 : "use data from MS_RESTART as initial guess", &
316 : "use a vector from MS_RESTART, useful if you want to increase accurcy by changing functionals or basis", &
317 : "use the .mol file of a former run, to restart a vector"// &
318 : " (similar to Restart_vec, but a different file FORMAT is used)"), &
319 1480 : enum_i_vals=[ms_guess_bfgs, ms_guess_atomic, ms_guess_restart, ms_guess_restart_vec, ms_guess_molden])
320 1480 : CALL section_add_keyword(section, keyword)
321 1480 : CALL keyword_release(keyword)
322 :
323 : CALL keyword_create(keyword, __LOCATION__, name="RESTART_FILE_NAME", &
324 : description="Specifies the name of the file used to create the restarted vectors", &
325 : usage="RESTART_FILE_NAME {filename}", &
326 1480 : default_lc_val="")
327 1480 : CALL section_add_keyword(section, keyword)
328 1480 : CALL keyword_release(keyword)
329 :
330 1480 : CALL create_involved_atoms_section(subsection)
331 1480 : CALL section_add_subsection(section, subsection)
332 1480 : CALL section_release(subsection)
333 :
334 : CALL section_create(subsection, __LOCATION__, name="PRINT", &
335 : description="Controls the printing mode selective vibrational analysis", &
336 1480 : n_keywords=0, n_subsections=1, repeats=.TRUE.)
337 :
338 : CALL cp_print_key_section_create(print_key, __LOCATION__, "MS_RESTART", &
339 : description="Controls the printing of the Mode Selective Restart file.", &
340 : print_level=silent_print_level, common_iter_levels=1, &
341 1480 : add_last=add_last_numeric, filename="")
342 1480 : CALL section_add_subsection(subsection, print_key)
343 1480 : CALL section_release(print_key)
344 :
345 1480 : CALL section_add_subsection(section, subsection)
346 1480 : CALL section_release(subsection)
347 :
348 1480 : END SUBROUTINE create_mode_selective_section
349 :
350 : ! **************************************************************************************************
351 : !> \brief Create the input section for Ivolved_atoms keyword in mode selective
352 : !> \param section the section to create
353 : !> \author fschiff
354 : ! **************************************************************************************************
355 1480 : SUBROUTINE create_involved_atoms_section(section)
356 : TYPE(section_type), POINTER :: section
357 :
358 : TYPE(keyword_type), POINTER :: keyword
359 :
360 1480 : NULLIFY (keyword)
361 1480 : CPASSERT(.NOT. ASSOCIATED(section))
362 : CALL section_create( &
363 : section, __LOCATION__, name="INVOLVED_ATOMS", &
364 : description="All parameters needed for the tracking of modes dominated by the motion of selected atoms. "// &
365 : "Warning, if many atoms are involved, only low frequency modes are detected, "// &
366 : "since they are more delocalized and match the tracked eigenvector.", &
367 1480 : n_keywords=2, n_subsections=0, repeats=.FALSE.)
368 :
369 : CALL keyword_create( &
370 : keyword, __LOCATION__, name="RANGE", &
371 : description=" Specifies the range of wavenumbers in which the modes related to the ATOMS have to be tracked."// &
372 : " If not specified frequencies >400cm-1 will be used to avoid tracking of translational or rotational modes", &
373 : usage="RANGE {REAL} {REAL}", &
374 1480 : n_var=-1, type_of_var=real_t)
375 1480 : CALL section_add_keyword(section, keyword)
376 1480 : CALL keyword_release(keyword)
377 :
378 : CALL keyword_create( &
379 : keyword, __LOCATION__, name="INVOLVED_ATOMS", &
380 : description="Specifies the list of atoms on which the tracked eigenvector should have the highest value "// &
381 : "similar to looking for the vibration of a set of atoms", &
382 : usage="INVOLVED_ATOMS {integer} {integer} .. {integer}", &
383 1480 : n_var=-1, type_of_var=integer_t)
384 1480 : CALL section_add_keyword(section, keyword)
385 1480 : CALL keyword_release(keyword)
386 :
387 1480 : END SUBROUTINE create_involved_atoms_section
388 :
389 : END MODULE input_cp2k_vib
|