(git:495eafe)
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-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 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="Selects the method used by this FORCE_EVAL section to compute energies, "// &
84 "forces, and related properties.", &
85 usage="METHOD <STRING>", &
86 enum_c_vals=s2a("QS", &
87 "SIRIUS", &
88 "FIST", &
89 "QMMM", &
90 "EIP", &
91 "QUICKSTEP", &
92 "NNP", &
93 "MIXED", &
94 "EMBED", &
95 "IPI"), &
96 enum_desc=s2a("Alias for QUICKSTEP", &
97 "PW DFT using the SIRIUS library", &
98 "Molecular Mechanics", &
99 "Hybrid quantum classical", &
100 "Empirical Interatomic Potential", &
101 "Electronic structure methods in the Quickstep module, including GPW and GAPW DFT.", &
102 "Neural Network Potentials", &
103 "Use a combination of two of the above", &
104 "Perform an embedded calculation", &
105 "Receive forces from an i-PI client"), &
107 default_i_val=do_qs)
108 CALL section_add_keyword(section, keyword)
109 CALL keyword_release(keyword)
110
111 CALL keyword_create(keyword, __location__, name="STRESS_TENSOR", &
112 description="Controls the calculation of the stress tensor. The combinations defined below"// &
113 " are not implemented for all methods.", &
114 usage="stress_tensor (NONE|ANALYTICAL|NUMERICAL|DIAGONAL_ANA|DIAGONAL_NUM)", &
115 default_i_val=do_stress_none, &
116 enum_c_vals=s2a("NONE", "ANALYTICAL", "NUMERICAL", "DIAGONAL_ANALYTICAL", "DIAGONAL_NUMERICAL"), &
119 enum_desc=s2a("Do not compute stress tensor", &
120 "Compute the stress tensor analytically (if available).", &
121 "Compute the stress tensor numerically.", &
122 "Compute the diagonal part only of the stress tensor analytically (if available).", &
123 "Compute the diagonal part only of the stress tensor numerically"))
124
125 CALL section_add_keyword(section, keyword)
126 CALL keyword_release(keyword)
127
128 CALL create_ext_pot_section(subsection)
129 CALL section_add_subsection(section, subsection)
130 CALL section_release(subsection)
131
132 CALL create_rescale_force_section(subsection)
133 CALL section_add_subsection(section, subsection)
134 CALL section_release(subsection)
135
136 CALL create_mix_section(subsection)
137 CALL section_add_subsection(section, subsection)
138 CALL section_release(subsection)
139
140 CALL create_embed_section(subsection)
141 CALL section_add_subsection(section, subsection)
142 CALL section_release(subsection)
143
144 CALL create_dft_section(subsection)
145 CALL section_add_subsection(section, subsection)
146 CALL section_release(subsection)
147
148 CALL create_pwdft_section(subsection)
149 CALL section_add_subsection(section, subsection)
150 CALL section_release(subsection)
151
152 CALL create_mm_section(subsection)
153 CALL section_add_subsection(section, subsection)
154 CALL section_release(subsection)
155
156 CALL create_nnp_section(subsection)
157 CALL section_add_subsection(section, subsection)
158 CALL section_release(subsection)
159
160 CALL create_qmmm_section(subsection)
161 CALL section_add_subsection(section, subsection)
162 CALL section_release(subsection)
163
164 CALL create_eip_section(subsection)
165 CALL section_add_subsection(section, subsection)
166 CALL section_release(subsection)
167
168 CALL create_bsse_section(subsection)
169 CALL section_add_subsection(section, subsection)
170 CALL section_release(subsection)
171
172 CALL create_subsys_section(subsection)
173 CALL section_add_subsection(section, subsection)
174 CALL section_release(subsection)
175
176 CALL create_properties_section(subsection)
177 CALL section_add_subsection(section, subsection)
178 CALL section_release(subsection)
179
180 CALL create_f_env_print_section(subsection)
181 CALL section_add_subsection(section, subsection)
182 CALL section_release(subsection)
183
184 END SUBROUTINE create_force_eval_section
185
186! **************************************************************************************************
187!> \brief Creates the section for applying an external potential
188!> \param section ...
189!> \date 03.2008
190!> \author teo
191! **************************************************************************************************
192 SUBROUTINE create_ext_pot_section(section)
193 TYPE(section_type), POINTER :: section
194
195 TYPE(keyword_type), POINTER :: keyword
196
197 cpassert(.NOT. ASSOCIATED(section))
198 CALL section_create(section, __location__, name="EXTERNAL_POTENTIAL", &
199 description="Section controlling the presence of an external potential dependent "// &
200 "on the atomic positions (X,Y,Z)", &
201 n_keywords=7, n_subsections=0, repeats=.true.)
202 NULLIFY (keyword)
203
204 CALL keyword_create(keyword, __location__, name="ATOMS_LIST", &
205 description="Specifies the atoms on which the external potential will act", &
206 usage="ATOMS_LIST {INT} {INT} ..", repeats=.true., &
207 n_var=-1, type_of_var=integer_t)
208 CALL section_add_keyword(section, keyword)
209 CALL keyword_release(keyword)
210
211 CALL keyword_create(keyword, __location__, name="FUNCTION", &
212 description="Specifies the functional form in mathematical notation. Variables must be the atomic "// &
213 "coordinates (X,Y,Z).", usage="FUNCTION X^2+Y^2+Z^2+LOG(ABS(X+Y))", &
214 type_of_var=lchar_t, n_var=1)
215 CALL section_add_keyword(section, keyword)
216 CALL keyword_release(keyword)
217
218 CALL keyword_create(keyword, __location__, name="PARAMETERS", &
219 description="Defines the parameters of the functional form", &
220 usage="PARAMETERS a b D", type_of_var=char_t, &
221 n_var=-1, repeats=.true.)
222 CALL section_add_keyword(section, keyword)
223 CALL keyword_release(keyword)
224
225 CALL keyword_create(keyword, __location__, name="VALUES", &
226 description="Defines the values of parameter of the functional form", &
227 usage="VALUES ", type_of_var=real_t, &
228 n_var=-1, repeats=.true., unit_str="internal_cp2k")
229 CALL section_add_keyword(section, keyword)
230 CALL keyword_release(keyword)
231
232 CALL keyword_create(keyword, __location__, name="UNITS", &
233 description="Optionally, allows to define valid CP2K unit strings for each parameter value. "// &
234 "It is assumed that the corresponding parameter value is specified in this unit.", &
235 usage="UNITS angstrom eV*angstrom^-1 angstrom^1 K", type_of_var=char_t, &
236 n_var=-1, repeats=.true.)
237 CALL section_add_keyword(section, keyword)
238 CALL keyword_release(keyword)
239
240 CALL keyword_create(keyword, __location__, name="DX", &
241 description="Parameter used for computing the derivative with the Ridders' method.", &
242 usage="DX <REAL>", default_r_val=0.1_dp, unit_str="bohr")
243 CALL section_add_keyword(section, keyword)
244 CALL keyword_release(keyword)
245
246 CALL keyword_create(keyword, __location__, name="ERROR_LIMIT", &
247 description="Checks that the error in computing the derivative is not larger than "// &
248 "the value set; in case error is larger a warning message is printed.", &
249 usage="ERROR_LIMIT <REAL>", default_r_val=1.0e-12_dp)
250 CALL section_add_keyword(section, keyword)
251 CALL keyword_release(keyword)
252
253 END SUBROUTINE create_ext_pot_section
254
255! **************************************************************************************************
256!> \brief Creates the section controlling the rescaling of forces
257!> \param section the section to create
258!> \author teo
259! **************************************************************************************************
260 SUBROUTINE create_rescale_force_section(section)
261 TYPE(section_type), POINTER :: section
262
263 TYPE(keyword_type), POINTER :: keyword
264
265 cpassert(.NOT. ASSOCIATED(section))
266 CALL section_create(section, __location__, name="RESCALE_FORCES", &
267 description="Section controlling the rescaling of forces. Useful when"// &
268 " starting from quite bad geometries with unphysically large forces.", &
269 n_keywords=1, n_subsections=0, repeats=.false.)
270 NULLIFY (keyword)
271
272 CALL keyword_create(keyword, __location__, name="MAX_FORCE", &
273 description="Specify the Maximum Values of the force. If the force"// &
274 " of one atom exceed this value it's rescaled to the MAX_FORCE"// &
275 " value.", &
276 default_r_val=cp_unit_to_cp2k(value=50.0_dp, &
277 unit_str="kcalmol*angstrom^-1"), &
278 unit_str="hartree*bohr^-1")
279 CALL section_add_keyword(section, keyword)
280 CALL keyword_release(keyword)
281
282 END SUBROUTINE create_rescale_force_section
283
284! **************************************************************************************************
285!> \brief ...
286!> \param section ...
287!> \author fawzi
288! **************************************************************************************************
289 SUBROUTINE create_f_env_print_section(section)
290 TYPE(section_type), POINTER :: section
291
292 TYPE(keyword_type), POINTER :: keyword
293 TYPE(section_type), POINTER :: print_key
294
295 NULLIFY (keyword)
296 NULLIFY (print_key)
297
298 cpassert(.NOT. ASSOCIATED(section))
299
300 CALL section_create(section, __location__, &
301 name="PRINT", &
302 description="Properties that you want to output and that are common to all methods", &
303 n_keywords=0, n_subsections=10, repeats=.false.)
304
305 CALL cp_print_key_section_create(print_key, __location__, &
306 name="PROGRAM_RUN_INFO", &
307 description="Controls the printing of basic information generated by FORCE_EVAL", &
308 print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
309 CALL keyword_create(keyword, __location__, &
310 name="ENERGY_UNIT", &
311 description="Specifies the physical unit used for the printing of the total energy. "// &
312 "Note that the meaningfulness of the unit is not checked.", &
313 usage="ENERGY_UNIT eV", &
314 default_c_val="hartree", &
315 repeats=.false.)
316 CALL section_add_keyword(print_key, keyword)
317 CALL keyword_release(keyword)
318 CALL section_add_subsection(section, print_key)
319 CALL section_release(print_key)
320
321 CALL cp_print_key_section_create(print_key, __location__, &
322 name="FORCES", &
323 description="Controls the printing of the forces after each force evaluation", &
324 print_level=high_print_level, filename="__STD_OUT__")
325 CALL keyword_create(keyword, __location__, &
326 name="NDIGITS", &
327 description="Specifies the number of digits used "// &
328 "for the printing of the forces", &
329 usage="NDIGITS 6", &
330 default_i_val=8, &
331 repeats=.false.)
332 CALL section_add_keyword(print_key, keyword)
333 CALL keyword_release(keyword)
334 CALL keyword_create(keyword, __location__, &
335 name="FORCE_UNIT", &
336 variants=["UNIT"], & ! add old keyword name for backward compatibility
337 description="Specifies the physical unit used for the printing of the forces. "// &
338 "Note that the meaningfulness of the unit is not checked.", &
339 usage="FORCE_UNIT eV/angstrom", &
340 default_c_val="hartree/bohr", &
341 repeats=.false.)
342 CALL section_add_keyword(print_key, keyword)
343 CALL keyword_release(keyword)
344 CALL section_add_subsection(section, print_key)
345 CALL section_release(print_key)
346
347 CALL cp_print_key_section_create(print_key, __location__, &
348 name="GRID_INFORMATION", &
349 description="Controls the printing of information regarding the PW and RS grid structures.", &
350 print_level=medium_print_level, filename="__STD_OUT__")
351 CALL section_add_subsection(section, print_key)
352 CALL section_release(print_key)
353
354 CALL cp_print_key_section_create(print_key, __location__, &
355 name="TOTAL_NUMBERS", &
356 description="Controls the printing of the total number of atoms, kinds, ...", &
357 print_level=low_print_level, filename="__STD_OUT__")
358 CALL section_add_subsection(section, print_key)
359 CALL section_release(print_key)
360
361 CALL cp_print_key_section_create(print_key, __location__, &
362 name="DISTRIBUTION", &
363 description="Controls the printing of the distribution of molecules, atoms, ...", &
364 print_level=high_print_level, filename="__STD_OUT__")
365 CALL section_add_subsection(section, print_key)
366 CALL section_release(print_key)
367
368 CALL cp_print_key_section_create(print_key, __location__, &
369 name="DISTRIBUTION2D", &
370 description="Controls the printing of the distribution of matrix blocks, ...", &
371 print_level=high_print_level, filename="__STD_OUT__")
372 CALL section_add_subsection(section, print_key)
373 CALL section_release(print_key)
374
375 CALL cp_print_key_section_create(print_key, __location__, &
376 name="DISTRIBUTION1D", &
377 description="Each node prints out its distribution info ...", &
378 print_level=high_print_level, filename="__STD_OUT__")
379 CALL section_add_subsection(section, print_key)
380 CALL section_release(print_key)
381
382 CALL cp_print_key_section_create(print_key, __location__, &
383 name="STRESS_TENSOR", &
384 description="Controls the printing of the stress tensor", &
385 print_level=high_print_level, filename="__STD_OUT__")
386 CALL keyword_create(keyword, __location__, &
387 name="COMPONENTS", &
388 description="Print all GPW/GAPW components contributing to the stress tensor", &
389 usage="COMPONENTS", &
390 default_l_val=.false., &
391 lone_keyword_l_val=.true.)
392 CALL section_add_keyword(print_key, keyword)
393 CALL keyword_release(keyword)
394 CALL keyword_create(keyword, __location__, &
395 name="STRESS_UNIT", &
396 description="Specifies the physical unit used for the printing of the stress tensor. "// &
397 "Note that the meaningfulness of the unit is not checked.", &
398 usage="STRESS_UNIT kbar", &
399 default_c_val="bar", &
400 repeats=.false.)
401 CALL section_add_keyword(print_key, keyword)
402 CALL keyword_release(keyword)
403 CALL section_add_subsection(section, print_key)
404 CALL section_release(print_key)
405
406 CALL cp_print_key_section_create(print_key, __location__, &
407 name="GRRM", &
408 description="Controls the printing of the GRRM interface file", &
409 print_level=debug_print_level + 1, filename="CP2K_GRRM")
410 CALL section_add_subsection(section, print_key)
411 CALL section_release(print_key)
412
413 CALL cp_print_key_section_create(print_key, __location__, &
414 name="SCINE", &
415 description="Controls the printing of the SCINE interface file", &
416 print_level=debug_print_level + 1, filename="")
417 CALL section_add_subsection(section, print_key)
418 CALL section_release(print_key)
419
420 END SUBROUTINE create_f_env_print_section
421
422END 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:1149
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