(git:ed6f26b)
Loading...
Searching...
No Matches
input_cp2k_force_eval.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 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! **************************************************************************************************
21 USE cp_units, ONLY: cp_unit_to_cp2k
22 USE input_constants, ONLY: &
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
60
61CONTAINS
62
63! **************************************************************************************************
64!> \brief creates the force_eval section
65!> \param section the section to be created
66!> \author fawzi
67! **************************************************************************************************
68 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 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 n_keywords=1, n_subsections=10, repeats=.true.)
79
80 NULLIFY (subsection)
81 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 iPI client"), &
106 default_i_val=do_qs)
107 CALL section_add_keyword(section, keyword)
108 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"), &
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 "Compute the diagonal part only of the stress tensor numerically"))
123
124 CALL section_add_keyword(section, keyword)
125 CALL keyword_release(keyword)
126
127 CALL create_ext_pot_section(subsection)
128 CALL section_add_subsection(section, subsection)
129 CALL section_release(subsection)
130
131 CALL create_rescale_force_section(subsection)
132 CALL section_add_subsection(section, subsection)
133 CALL section_release(subsection)
134
135 CALL create_mix_section(subsection)
136 CALL section_add_subsection(section, subsection)
137 CALL section_release(subsection)
138
139 CALL create_embed_section(subsection)
140 CALL section_add_subsection(section, subsection)
141 CALL section_release(subsection)
142
143 CALL create_dft_section(subsection)
144 CALL section_add_subsection(section, subsection)
145 CALL section_release(subsection)
146
147 CALL create_pwdft_section(subsection)
148 CALL section_add_subsection(section, subsection)
149 CALL section_release(subsection)
150
151 CALL create_mm_section(subsection)
152 CALL section_add_subsection(section, subsection)
153 CALL section_release(subsection)
154
155 CALL create_nnp_section(subsection)
156 CALL section_add_subsection(section, subsection)
157 CALL section_release(subsection)
158
159 CALL create_qmmm_section(subsection)
160 CALL section_add_subsection(section, subsection)
161 CALL section_release(subsection)
162
163 CALL create_eip_section(subsection)
164 CALL section_add_subsection(section, subsection)
165 CALL section_release(subsection)
166
167 CALL create_bsse_section(subsection)
168 CALL section_add_subsection(section, subsection)
169 CALL section_release(subsection)
170
171 CALL create_subsys_section(subsection)
172 CALL section_add_subsection(section, subsection)
173 CALL section_release(subsection)
174
175 CALL create_properties_section(subsection)
176 CALL section_add_subsection(section, subsection)
177 CALL section_release(subsection)
178
179 CALL create_f_env_print_section(subsection)
180 CALL section_add_subsection(section, subsection)
181 CALL section_release(subsection)
182
183 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 SUBROUTINE create_ext_pot_section(section)
192 TYPE(section_type), POINTER :: section
193
194 TYPE(keyword_type), POINTER :: keyword
195
196 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 n_keywords=7, n_subsections=0, repeats=.true.)
201 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 n_var=-1, type_of_var=integer_t)
207 CALL section_add_keyword(section, keyword)
208 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 type_of_var=lchar_t, n_var=1)
214 CALL section_add_keyword(section, keyword)
215 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 n_var=-1, repeats=.true.)
221 CALL section_add_keyword(section, keyword)
222 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 n_var=-1, repeats=.true., unit_str="internal_cp2k")
228 CALL section_add_keyword(section, keyword)
229 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 n_var=-1, repeats=.true.)
236 CALL section_add_keyword(section, keyword)
237 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 usage="DX <REAL>", default_r_val=0.1_dp, unit_str="bohr")
242 CALL section_add_keyword(section, keyword)
243 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 usage="ERROR_LIMIT <REAL>", default_r_val=1.0e-12_dp)
249 CALL section_add_keyword(section, keyword)
250 CALL keyword_release(keyword)
251
252 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 SUBROUTINE create_rescale_force_section(section)
260 TYPE(section_type), POINTER :: section
261
262 TYPE(keyword_type), POINTER :: keyword
263
264 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 n_keywords=1, n_subsections=0, repeats=.false.)
269 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 unit_str="hartree*bohr^-1")
278 CALL section_add_keyword(section, keyword)
279 CALL keyword_release(keyword)
280
281 END SUBROUTINE create_rescale_force_section
282
283! **************************************************************************************************
284!> \brief ...
285!> \param section ...
286!> \author fawzi
287! **************************************************************************************************
288 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 NULLIFY (keyword)
295 NULLIFY (print_key)
296
297 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 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 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 repeats=.false.)
315 CALL section_add_keyword(print_key, keyword)
316 CALL keyword_release(keyword)
317 CALL section_add_subsection(section, print_key)
318 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 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 repeats=.false.)
331 CALL section_add_keyword(print_key, keyword)
332 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 repeats=.false.)
341 CALL section_add_keyword(print_key, keyword)
342 CALL keyword_release(keyword)
343 CALL section_add_subsection(section, print_key)
344 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 print_level=medium_print_level, filename="__STD_OUT__")
350 CALL section_add_subsection(section, print_key)
351 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 print_level=low_print_level, filename="__STD_OUT__")
357 CALL section_add_subsection(section, print_key)
358 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 print_level=high_print_level, filename="__STD_OUT__")
364 CALL section_add_subsection(section, print_key)
365 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 print_level=high_print_level, filename="__STD_OUT__")
371 CALL section_add_subsection(section, print_key)
372 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 print_level=high_print_level, filename="__STD_OUT__")
378 CALL section_add_subsection(section, print_key)
379 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 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 lone_keyword_l_val=.true.)
391 CALL section_add_keyword(print_key, keyword)
392 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 repeats=.false.)
400 CALL section_add_keyword(print_key, keyword)
401 CALL keyword_release(keyword)
402 CALL section_add_subsection(section, print_key)
403 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 print_level=debug_print_level + 1, filename="CP2K_GRRM")
409 CALL section_add_subsection(section, print_key)
410 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 print_level=debug_print_level + 1, filename="")
416 CALL section_add_subsection(section, print_key)
417 CALL section_release(print_key)
418
419 END SUBROUTINE create_f_env_print_section
420
421END MODULE input_cp2k_force_eval
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public debug_print_level
integer, parameter, public low_print_level
integer, parameter, public medium_print_level
integer, parameter, public high_print_level
integer, parameter, public add_last_numeric
subroutine, public cp_print_key_section_create(print_key_section, location, name, description, print_level, each_iter_names, each_iter_values, add_last, filename, common_iter_levels, citations, unit_str)
creates a print_key section
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Definition cp_units.F:1150
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_stress_analytical
integer, parameter, public do_nnp
integer, parameter, public do_stress_diagonal_anal
integer, parameter, public do_eip
integer, parameter, public do_fist
integer, parameter, public do_qmmm
integer, parameter, public do_embed
integer, parameter, public do_sirius
integer, parameter, public do_stress_diagonal_numer
integer, parameter, public do_stress_none
integer, parameter, public do_qs
integer, parameter, public do_mixed
integer, parameter, public do_stress_numerical
integer, parameter, public do_ipi
integer, parameter, public numerical
function that build the dft section of the input
subroutine, public create_bsse_section(section)
Create the BSSE section for counterpoise correction.
subroutine, public create_dft_section(section)
creates the dft section
Creates the EIP section of the input.
subroutine, public create_eip_section(section)
Create the input section for EIP.
builds the input structure for the EMBED environment: clone of MIXED environment
subroutine, public create_embed_section(section)
Create the input section for EMBED: clone of the subroutines for MIXED.
builds the input structure for the FORCE_EVAL section of cp2k
subroutine, public create_force_eval_section(section)
creates the force_eval section
builds the input structure for the MIXED environment
subroutine, public create_mix_section(section)
Create the input section for MIXED.
creates the mm section of the input
subroutine, public create_mm_section(section)
Create the input section for FIST.. Come on.. Let's get woohooo.
Creates the NNP section of the input.
subroutine, public create_nnp_section(section)
Create the input section for NNP.
function that build the dft section of the input
subroutine, public create_properties_section(section)
Create the PROPERTIES section.
subroutine, public create_pwdft_section(section)
...
creates the qmmm section of the input
subroutine, public create_qmmm_section(section)
Creates the QM/MM section.
builds the subsystem section of the input
subroutine, public create_subsys_section(section)
creates the structure of a subsys, i.e. a full set of atoms+mol+bounds+cell
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
subroutine, public keyword_create(keyword, location, name, description, usage, type_of_var, n_var, repeats, variants, default_val, default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, default_l_vals, default_r_vals, default_c_vals, default_i_vals, lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
creates a keyword object
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_create(section, location, name, description, n_keywords, n_subsections, repeats, citations, deprecation_notice)
creates a list of keywords
subroutine, public section_add_keyword(section, keyword)
adds a keyword to the given section
subroutine, public section_add_subsection(section, subsection)
adds a subsection to the given section
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
a wrapper for basic fortran types.
integer, parameter, public real_t
integer, parameter, public lchar_t
integer, parameter, public char_t
integer, parameter, public integer_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Utilities for string manipulations.
represent a keyword in the input
represent a section of the input file