Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2024 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 FORCE_EVAL section of cp2k
10 : !> \par History
11 : !> 06.2004 created [fawzi]
12 : !> \author fawzi
13 : ! **************************************************************************************************
14 : MODULE input_cp2k_force_eval
15 : USE cp_output_handling, ONLY: add_last_numeric,&
16 : cp_print_key_section_create,&
17 : debug_print_level,&
18 : high_print_level,&
19 : low_print_level,&
20 : medium_print_level
21 : USE cp_units, ONLY: cp_unit_to_cp2k
22 : USE input_constants, ONLY: &
23 : do_eip, do_embed, do_fist, do_ipi, do_mixed, do_nnp, do_qmmm, do_qs, do_sirius, &
24 : do_stress_analytical, do_stress_diagonal_anal, do_stress_diagonal_numer, do_stress_none, &
25 : do_stress_numerical, numerical
26 : USE input_cp2k_dft, ONLY: create_bsse_section,&
27 : create_dft_section
28 : USE input_cp2k_eip, ONLY: create_eip_section
29 : USE input_cp2k_embed, ONLY: create_embed_section
30 : USE input_cp2k_mixed, ONLY: create_mix_section
31 : USE input_cp2k_mm, ONLY: create_mm_section
32 : USE input_cp2k_nnp, ONLY: create_nnp_section
33 : USE input_cp2k_properties_dft, ONLY: create_properties_section
34 : USE input_cp2k_pwdft, ONLY: create_pwdft_section
35 : USE input_cp2k_qmmm, ONLY: create_qmmm_section
36 : USE input_cp2k_subsys, ONLY: create_subsys_section
37 : USE input_keyword_types, ONLY: keyword_create,&
38 : keyword_release,&
39 : keyword_type
40 : USE input_section_types, ONLY: section_add_keyword,&
41 : section_add_subsection,&
42 : section_create,&
43 : section_release,&
44 : section_type
45 : USE input_val_types, ONLY: char_t,&
46 : integer_t,&
47 : lchar_t,&
48 : real_t
49 : USE kinds, ONLY: dp
50 : USE string_utilities, ONLY: s2a
51 : #include "./base/base_uses.f90"
52 :
53 : IMPLICIT NONE
54 : PRIVATE
55 :
56 : LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
57 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_force_eval'
58 :
59 : PUBLIC :: create_force_eval_section
60 :
61 : CONTAINS
62 :
63 : ! **************************************************************************************************
64 : !> \brief creates the force_eval section
65 : !> \param section the section to be created
66 : !> \author fawzi
67 : ! **************************************************************************************************
68 8530 : SUBROUTINE create_force_eval_section(section)
69 : TYPE(section_type), POINTER :: section
70 :
71 : TYPE(keyword_type), POINTER :: keyword
72 : TYPE(section_type), POINTER :: subsection
73 :
74 8530 : CPASSERT(.NOT. ASSOCIATED(section))
75 : CALL section_create(section, __LOCATION__, name="force_eval", &
76 : description="parameters needed to calculate energy and forces and"// &
77 : " describe the system you want to analyze.", &
78 8530 : n_keywords=1, n_subsections=10, repeats=.TRUE.)
79 :
80 8530 : NULLIFY (subsection)
81 8530 : NULLIFY (keyword)
82 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
83 : description="Which method should be used to compute forces", &
84 : usage="METHOD <STRING>", &
85 : enum_c_vals=s2a("QS", &
86 : "SIRIUS", &
87 : "FIST", &
88 : "QMMM", &
89 : "EIP", &
90 : "QUICKSTEP", &
91 : "NNP", &
92 : "MIXED", &
93 : "EMBED", &
94 : "IPI"), &
95 : enum_desc=s2a("Alias for QUICKSTEP", &
96 : "PW DFT using the SIRIUS library", &
97 : "Molecular Mechanics", &
98 : "Hybrid quantum classical", &
99 : "Empirical Interatomic Potential", &
100 : "Electronic structure methods (DFT, ...)", &
101 : "Neural Network Potentials", &
102 : "Use a combination of two of the above", &
103 : "Perform an embedded calculation", &
104 : "Recieve forces from i–PI client"), &
105 : enum_i_vals=(/do_qs, do_sirius, do_fist, do_qmmm, do_eip, do_qs, do_nnp, do_mixed, do_embed, do_ipi/), &
106 8530 : default_i_val=do_qs)
107 8530 : CALL section_add_keyword(section, keyword)
108 8530 : CALL keyword_release(keyword)
109 :
110 : CALL keyword_create(keyword, __LOCATION__, name="STRESS_TENSOR", &
111 : description="Controls the calculation of the stress tensor. The combinations defined below"// &
112 : " are not implemented for all methods.", &
113 : usage="stress_tensor (NONE|ANALYTICAL|NUMERICAL|DIAGONAL_ANA|DIAGONAL_NUM)", &
114 : default_i_val=do_stress_none, &
115 : enum_c_vals=s2a("NONE", "ANALYTICAL", "NUMERICAL", "DIAGONAL_ANALYTICAL", "DIAGONAL_NUMERICAL"), &
116 : enum_i_vals=(/do_stress_none, do_stress_analytical, do_stress_numerical, &
117 : do_stress_diagonal_anal, do_stress_diagonal_numer/), &
118 : enum_desc=s2a("Do not compute stress tensor", &
119 : "Compute the stress tensor analytically (if available).", &
120 : "Compute the stress tensor numerically.", &
121 : "Compute the diagonal part only of the stress tensor analytically (if available).", &
122 8530 : "Compute the diagonal part only of the stress tensor numerically"))
123 :
124 8530 : CALL section_add_keyword(section, keyword)
125 8530 : CALL keyword_release(keyword)
126 :
127 8530 : CALL create_ext_pot_section(subsection)
128 8530 : CALL section_add_subsection(section, subsection)
129 8530 : CALL section_release(subsection)
130 :
131 8530 : CALL create_rescale_force_section(subsection)
132 8530 : CALL section_add_subsection(section, subsection)
133 8530 : CALL section_release(subsection)
134 :
135 8530 : CALL create_mix_section(subsection)
136 8530 : CALL section_add_subsection(section, subsection)
137 8530 : CALL section_release(subsection)
138 :
139 8530 : CALL create_embed_section(subsection)
140 8530 : CALL section_add_subsection(section, subsection)
141 8530 : CALL section_release(subsection)
142 :
143 8530 : CALL create_dft_section(subsection)
144 8530 : CALL section_add_subsection(section, subsection)
145 8530 : CALL section_release(subsection)
146 :
147 8530 : CALL create_pwdft_section(subsection)
148 8530 : CALL section_add_subsection(section, subsection)
149 8530 : CALL section_release(subsection)
150 :
151 8530 : CALL create_mm_section(subsection)
152 8530 : CALL section_add_subsection(section, subsection)
153 8530 : CALL section_release(subsection)
154 :
155 8530 : CALL create_nnp_section(subsection)
156 8530 : CALL section_add_subsection(section, subsection)
157 8530 : CALL section_release(subsection)
158 :
159 8530 : CALL create_qmmm_section(subsection)
160 8530 : CALL section_add_subsection(section, subsection)
161 8530 : CALL section_release(subsection)
162 :
163 8530 : CALL create_eip_section(subsection)
164 8530 : CALL section_add_subsection(section, subsection)
165 8530 : CALL section_release(subsection)
166 :
167 8530 : CALL create_bsse_section(subsection)
168 8530 : CALL section_add_subsection(section, subsection)
169 8530 : CALL section_release(subsection)
170 :
171 8530 : CALL create_subsys_section(subsection)
172 8530 : CALL section_add_subsection(section, subsection)
173 8530 : CALL section_release(subsection)
174 :
175 8530 : CALL create_properties_section(subsection)
176 8530 : CALL section_add_subsection(section, subsection)
177 8530 : CALL section_release(subsection)
178 :
179 8530 : CALL create_f_env_print_section(subsection)
180 8530 : CALL section_add_subsection(section, subsection)
181 8530 : CALL section_release(subsection)
182 :
183 8530 : END SUBROUTINE create_force_eval_section
184 :
185 : ! **************************************************************************************************
186 : !> \brief Creates the section for applying an external potential
187 : !> \param section ...
188 : !> \date 03.2008
189 : !> \author teo
190 : ! **************************************************************************************************
191 8530 : SUBROUTINE create_ext_pot_section(section)
192 : TYPE(section_type), POINTER :: section
193 :
194 : TYPE(keyword_type), POINTER :: keyword
195 :
196 8530 : CPASSERT(.NOT. ASSOCIATED(section))
197 : CALL section_create(section, __LOCATION__, name="EXTERNAL_POTENTIAL", &
198 : description="Section controlling the presence of an external potential dependent "// &
199 : "on the atomic positions (X,Y,Z)", &
200 8530 : n_keywords=7, n_subsections=0, repeats=.TRUE.)
201 8530 : NULLIFY (keyword)
202 :
203 : CALL keyword_create(keyword, __LOCATION__, name="ATOMS_LIST", &
204 : description="Specifies the atoms on which the external potential will act", &
205 : usage="ATOMS_LIST {INT} {INT} ..", repeats=.TRUE., &
206 8530 : n_var=-1, type_of_var=integer_t)
207 8530 : CALL section_add_keyword(section, keyword)
208 8530 : CALL keyword_release(keyword)
209 :
210 : CALL keyword_create(keyword, __LOCATION__, name="FUNCTION", &
211 : description="Specifies the functional form in mathematical notation. Variables must be the atomic "// &
212 : "coordinates (X,Y,Z).", usage="FUNCTION X^2+Y^2+Z^2+LOG(ABS(X+Y))", &
213 8530 : type_of_var=lchar_t, n_var=1)
214 8530 : CALL section_add_keyword(section, keyword)
215 8530 : CALL keyword_release(keyword)
216 :
217 : CALL keyword_create(keyword, __LOCATION__, name="PARAMETERS", &
218 : description="Defines the parameters of the functional form", &
219 : usage="PARAMETERS a b D", type_of_var=char_t, &
220 8530 : n_var=-1, repeats=.TRUE.)
221 8530 : CALL section_add_keyword(section, keyword)
222 8530 : CALL keyword_release(keyword)
223 :
224 : CALL keyword_create(keyword, __LOCATION__, name="VALUES", &
225 : description="Defines the values of parameter of the functional form", &
226 : usage="VALUES ", type_of_var=real_t, &
227 8530 : n_var=-1, repeats=.TRUE., unit_str="internal_cp2k")
228 8530 : CALL section_add_keyword(section, keyword)
229 8530 : CALL keyword_release(keyword)
230 :
231 : CALL keyword_create(keyword, __LOCATION__, name="UNITS", &
232 : description="Optionally, allows to define valid CP2K unit strings for each parameter value. "// &
233 : "It is assumed that the corresponding parameter value is specified in this unit.", &
234 : usage="UNITS angstrom eV*angstrom^-1 angstrom^1 K", type_of_var=char_t, &
235 8530 : n_var=-1, repeats=.TRUE.)
236 8530 : CALL section_add_keyword(section, keyword)
237 8530 : CALL keyword_release(keyword)
238 :
239 : CALL keyword_create(keyword, __LOCATION__, name="DX", &
240 : description="Parameter used for computing the derivative with the Ridders' method.", &
241 8530 : usage="DX <REAL>", default_r_val=0.1_dp, unit_str="bohr")
242 8530 : CALL section_add_keyword(section, keyword)
243 8530 : CALL keyword_release(keyword)
244 :
245 : CALL keyword_create(keyword, __LOCATION__, name="ERROR_LIMIT", &
246 : description="Checks that the error in computing the derivative is not larger than "// &
247 : "the value set; in case error is larger a warning message is printed.", &
248 8530 : usage="ERROR_LIMIT <REAL>", default_r_val=1.0E-12_dp)
249 8530 : CALL section_add_keyword(section, keyword)
250 8530 : CALL keyword_release(keyword)
251 :
252 8530 : END SUBROUTINE create_ext_pot_section
253 :
254 : ! **************************************************************************************************
255 : !> \brief Creates the section controlling the rescaling of forces
256 : !> \param section the section to create
257 : !> \author teo
258 : ! **************************************************************************************************
259 8530 : SUBROUTINE create_rescale_force_section(section)
260 : TYPE(section_type), POINTER :: section
261 :
262 : TYPE(keyword_type), POINTER :: keyword
263 :
264 8530 : CPASSERT(.NOT. ASSOCIATED(section))
265 : CALL section_create(section, __LOCATION__, name="RESCALE_FORCES", &
266 : description="Section controlling the rescaling of forces. Useful when"// &
267 : " starting from quite bad geometries with unphysically large forces.", &
268 8530 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
269 8530 : NULLIFY (keyword)
270 :
271 : CALL keyword_create(keyword, __LOCATION__, name="MAX_FORCE", &
272 : description="Specify the Maximum Values of the force. If the force"// &
273 : " of one atom exceed this value it's rescaled to the MAX_FORCE"// &
274 : " value.", &
275 : default_r_val=cp_unit_to_cp2k(value=50.0_dp, &
276 : unit_str="kcalmol*angstrom^-1"), &
277 8530 : unit_str="hartree*bohr^-1")
278 8530 : CALL section_add_keyword(section, keyword)
279 8530 : CALL keyword_release(keyword)
280 :
281 8530 : END SUBROUTINE create_rescale_force_section
282 :
283 : ! **************************************************************************************************
284 : !> \brief ...
285 : !> \param section ...
286 : !> \author fawzi
287 : ! **************************************************************************************************
288 8530 : SUBROUTINE create_f_env_print_section(section)
289 : TYPE(section_type), POINTER :: section
290 :
291 : TYPE(keyword_type), POINTER :: keyword
292 : TYPE(section_type), POINTER :: print_key
293 :
294 8530 : NULLIFY (keyword)
295 8530 : NULLIFY (print_key)
296 :
297 8530 : CPASSERT(.NOT. ASSOCIATED(section))
298 :
299 : CALL section_create(section, __LOCATION__, &
300 : name="PRINT", &
301 : description="Properties that you want to output and that are common to all methods", &
302 8530 : n_keywords=0, n_subsections=10, repeats=.FALSE.)
303 :
304 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
305 : name="PROGRAM_RUN_INFO", &
306 : description="Controls the printing of basic information generated by FORCE_EVAL", &
307 8530 : print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
308 : CALL keyword_create(keyword, __LOCATION__, &
309 : name="ENERGY_UNIT", &
310 : description="Specifies the physical unit used for the printing of the total energy. "// &
311 : "Note that the meaningfulness of the unit is not checked.", &
312 : usage="ENERGY_UNIT eV", &
313 : default_c_val="hartree", &
314 8530 : repeats=.FALSE.)
315 8530 : CALL section_add_keyword(print_key, keyword)
316 8530 : CALL keyword_release(keyword)
317 8530 : CALL section_add_subsection(section, print_key)
318 8530 : CALL section_release(print_key)
319 :
320 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
321 : name="FORCES", &
322 : description="Controls the printing of the forces after each force evaluation", &
323 8530 : print_level=high_print_level, filename="__STD_OUT__")
324 : CALL keyword_create(keyword, __LOCATION__, &
325 : name="NDIGITS", &
326 : description="Specifies the number of digits used "// &
327 : "for the printing of the forces", &
328 : usage="NDIGITS 6", &
329 : default_i_val=8, &
330 8530 : repeats=.FALSE.)
331 8530 : CALL section_add_keyword(print_key, keyword)
332 8530 : CALL keyword_release(keyword)
333 : CALL keyword_create(keyword, __LOCATION__, &
334 : name="FORCE_UNIT", &
335 : variants=(/"UNIT"/), & ! add old keyword name for backward compatibility
336 : description="Specifies the physical unit used for the printing of the forces. "// &
337 : "Note that the meaningfulness of the unit is not checked.", &
338 : usage="FORCE_UNIT eV/angstrom", &
339 : default_c_val="hartree/bohr", &
340 17060 : repeats=.FALSE.)
341 8530 : CALL section_add_keyword(print_key, keyword)
342 8530 : CALL keyword_release(keyword)
343 8530 : CALL section_add_subsection(section, print_key)
344 8530 : CALL section_release(print_key)
345 :
346 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
347 : name="GRID_INFORMATION", &
348 : description="Controls the printing of information regarding the PW and RS grid structures.", &
349 8530 : print_level=medium_print_level, filename="__STD_OUT__")
350 8530 : CALL section_add_subsection(section, print_key)
351 8530 : CALL section_release(print_key)
352 :
353 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
354 : name="TOTAL_NUMBERS", &
355 : description="Controls the printing of the total number of atoms, kinds, ...", &
356 8530 : print_level=low_print_level, filename="__STD_OUT__")
357 8530 : CALL section_add_subsection(section, print_key)
358 8530 : CALL section_release(print_key)
359 :
360 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
361 : name="DISTRIBUTION", &
362 : description="Controls the printing of the distribution of molecules, atoms, ...", &
363 8530 : print_level=high_print_level, filename="__STD_OUT__")
364 8530 : CALL section_add_subsection(section, print_key)
365 8530 : CALL section_release(print_key)
366 :
367 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
368 : name="DISTRIBUTION2D", &
369 : description="Controls the printing of the distribution of matrix blocks, ...", &
370 8530 : print_level=high_print_level, filename="__STD_OUT__")
371 8530 : CALL section_add_subsection(section, print_key)
372 8530 : CALL section_release(print_key)
373 :
374 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
375 : name="DISTRIBUTION1D", &
376 : description="Each node prints out its distribution info ...", &
377 8530 : print_level=high_print_level, filename="__STD_OUT__")
378 8530 : CALL section_add_subsection(section, print_key)
379 8530 : CALL section_release(print_key)
380 :
381 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
382 : name="STRESS_TENSOR", &
383 : description="Controls the printing of the stress tensor", &
384 8530 : print_level=high_print_level, filename="__STD_OUT__")
385 : CALL keyword_create(keyword, __LOCATION__, &
386 : name="COMPONENTS", &
387 : description="Print all GPW/GAPW components contributing to the stress tensor", &
388 : usage="COMPONENTS", &
389 : default_l_val=.FALSE., &
390 8530 : lone_keyword_l_val=.TRUE.)
391 8530 : CALL section_add_keyword(print_key, keyword)
392 8530 : CALL keyword_release(keyword)
393 : CALL keyword_create(keyword, __LOCATION__, &
394 : name="STRESS_UNIT", &
395 : description="Specifies the physical unit used for the printing of the stress tensor. "// &
396 : "Note that the meaningfulness of the unit is not checked.", &
397 : usage="STRESS_UNIT kbar", &
398 : default_c_val="bar", &
399 8530 : repeats=.FALSE.)
400 8530 : CALL section_add_keyword(print_key, keyword)
401 8530 : CALL keyword_release(keyword)
402 8530 : CALL section_add_subsection(section, print_key)
403 8530 : CALL section_release(print_key)
404 :
405 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
406 : name="GRRM", &
407 : description="Controls the printing of the GRRM interface file", &
408 8530 : print_level=debug_print_level + 1, filename="CP2K_GRRM")
409 8530 : CALL section_add_subsection(section, print_key)
410 8530 : CALL section_release(print_key)
411 :
412 : CALL cp_print_key_section_create(print_key, __LOCATION__, &
413 : name="SCINE", &
414 : description="Controls the printing of the SCINE interface file", &
415 8530 : print_level=debug_print_level + 1, filename="")
416 8530 : CALL section_add_subsection(section, print_key)
417 8530 : CALL section_release(print_key)
418 :
419 8530 : END SUBROUTINE create_f_env_print_section
420 :
421 : END MODULE input_cp2k_force_eval
|