(git:4cc4584)
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
23 USE input_constants, ONLY: &
46 USE input_val_types, ONLY: integer_t
47 USE kinds, ONLY: dp
48 USE string_utilities, ONLY: s2a
49#include "./base/base_uses.f90"
50
51 IMPLICIT NONE
52 PRIVATE
53
54 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
55 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_force_eval'
56
58
59CONTAINS
60
61! **************************************************************************************************
62!> \brief creates the force_eval section
63!> \param section the section to be created
64!> \author fawzi
65! **************************************************************************************************
66 SUBROUTINE create_force_eval_section(section)
67 TYPE(section_type), POINTER :: section
68
69 TYPE(keyword_type), POINTER :: keyword
70 TYPE(section_type), POINTER :: subsection
71
72 cpassert(.NOT. ASSOCIATED(section))
73 CALL section_create(section, __location__, name="force_eval", &
74 description="parameters needed to calculate energy and forces and"// &
75 " describe the system you want to analyze.", &
76 n_keywords=1, n_subsections=10, repeats=.true.)
77
78 NULLIFY (subsection)
79 NULLIFY (keyword)
80 CALL keyword_create(keyword, __location__, name="METHOD", &
81 description="Selects the method used by this FORCE_EVAL section to compute energies, "// &
82 "forces, and related properties.", &
83 usage="METHOD <STRING>", &
84 enum_c_vals=s2a("QS", &
85 "SIRIUS", &
86 "FIST", &
87 "QMMM", &
88 "EIP", &
89 "QUICKSTEP", &
90 "NNP", &
91 "MIXED", &
92 "EMBED", &
93 "IPI"), &
94 enum_desc=s2a("Alias for QUICKSTEP", &
95 "PW DFT using the SIRIUS library", &
96 "Molecular Mechanics", &
97 "Hybrid quantum classical", &
98 "Empirical Interatomic Potential", &
99 "Electronic structure methods in the Quickstep module, including GPW and GAPW DFT.", &
100 "Neural Network Potentials", &
101 "Use a combination of two of the above", &
102 "Perform an embedded calculation", &
103 "Receive forces from an i-PI client"), &
105 default_i_val=do_qs)
106 CALL section_add_keyword(section, keyword)
107 CALL keyword_release(keyword)
108
109 CALL keyword_create(keyword, __location__, name="STRESS_TENSOR", &
110 description="Controls the calculation of the stress tensor. The combinations defined below"// &
111 " are not implemented for all methods.", &
112 usage="stress_tensor (NONE|ANALYTICAL|NUMERICAL|DIAGONAL_ANA|DIAGONAL_NUM)", &
113 default_i_val=do_stress_none, &
114 enum_c_vals=s2a("NONE", "ANALYTICAL", "NUMERICAL", "DIAGONAL_ANALYTICAL", "DIAGONAL_NUMERICAL"), &
117 enum_desc=s2a("Do not compute stress tensor", &
118 "Compute the stress tensor analytically (if available).", &
119 "Compute the stress tensor numerically.", &
120 "Compute the diagonal part only of the stress tensor analytically (if available).", &
121 "Compute the diagonal part only of the stress tensor numerically"))
122
123 CALL section_add_keyword(section, keyword)
124 CALL keyword_release(keyword)
125
126 ! Create FORCE_EVAL/EXTERNAL_POTENTIAL section, corresponding to add_external_potential in
127 ! external_potential_methods.F and applicable to any force method. A private subroutine
128 ! create_ext_pot_section was previously used for this purpose, which has been dropped to
129 ! avoid confusion with the similarly named one in input_cp2k_external.F for
130 ! FORCE_EVAL/DFT/EXTERNAL_POTENTIAL and applicable to Quickstep DFT only.
131 CALL create_function_section(subsection, "EXTERNAL_POTENTIAL", "FUNCTION", &
132 description="Section controlling the presence of an external "// &
133 "potential dependent on the atomic positions (X,Y,Z). Not to "// &
134 "be confused with the Quickstep DFT-specific settings under "// &
135 "FORCE_EVAL/DFT/EXTERNAL_POTENTIAL.", &
136 repeats=.true., do_deriv=.true., input_variables=["X", "Y", "Z"])
137 CALL keyword_create(keyword, __location__, name="ATOMS_LIST", &
138 description="Specifies the atoms on which the external potential will act", &
139 usage="ATOMS_LIST {INT} {INT} ..", repeats=.true., &
140 n_var=-1, type_of_var=integer_t)
141 CALL section_add_keyword(subsection, keyword)
142 CALL keyword_release(keyword)
143 CALL section_add_subsection(section, subsection)
144 CALL section_release(subsection)
145
146 CALL create_rescale_force_section(subsection)
147 CALL section_add_subsection(section, subsection)
148 CALL section_release(subsection)
149
150 CALL create_mix_section(subsection)
151 CALL section_add_subsection(section, subsection)
152 CALL section_release(subsection)
153
154 CALL create_embed_section(subsection)
155 CALL section_add_subsection(section, subsection)
156 CALL section_release(subsection)
157
158 CALL create_dft_section(subsection)
159 CALL section_add_subsection(section, subsection)
160 CALL section_release(subsection)
161
162 CALL create_pwdft_section(subsection)
163 CALL section_add_subsection(section, subsection)
164 CALL section_release(subsection)
165
166 CALL create_mm_section(subsection)
167 CALL section_add_subsection(section, subsection)
168 CALL section_release(subsection)
169
170 CALL create_nnp_section(subsection)
171 CALL section_add_subsection(section, subsection)
172 CALL section_release(subsection)
173
174 CALL create_qmmm_section(subsection)
175 CALL section_add_subsection(section, subsection)
176 CALL section_release(subsection)
177
178 CALL create_eip_section(subsection)
179 CALL section_add_subsection(section, subsection)
180 CALL section_release(subsection)
181
182 CALL create_bsse_section(subsection)
183 CALL section_add_subsection(section, subsection)
184 CALL section_release(subsection)
185
186 CALL create_subsys_section(subsection)
187 CALL section_add_subsection(section, subsection)
188 CALL section_release(subsection)
189
190 CALL create_properties_section(subsection)
191 CALL section_add_subsection(section, subsection)
192 CALL section_release(subsection)
193
194 CALL create_f_env_print_section(subsection)
195 CALL section_add_subsection(section, subsection)
196 CALL section_release(subsection)
197
198 END SUBROUTINE create_force_eval_section
199
200! **************************************************************************************************
201!> \brief Creates the section controlling the rescaling of forces
202!> \param section the section to create
203!> \author teo
204! **************************************************************************************************
205 SUBROUTINE create_rescale_force_section(section)
206 TYPE(section_type), POINTER :: section
207
208 TYPE(keyword_type), POINTER :: keyword
209
210 cpassert(.NOT. ASSOCIATED(section))
211 CALL section_create(section, __location__, name="RESCALE_FORCES", &
212 description="Section controlling the rescaling of forces. Useful when"// &
213 " starting from quite bad geometries with unphysically large forces.", &
214 n_keywords=1, n_subsections=0, repeats=.false.)
215 NULLIFY (keyword)
216
217 CALL keyword_create(keyword, __location__, name="MAX_FORCE", &
218 description="Specify the Maximum Values of the force. If the force"// &
219 " of one atom exceed this value it's rescaled to the MAX_FORCE"// &
220 " value.", &
221 default_r_val=cp_unit_to_cp2k(value=50.0_dp, &
222 unit_str="kcalmol*angstrom^-1"), &
223 unit_str="hartree*bohr^-1")
224 CALL section_add_keyword(section, keyword)
225 CALL keyword_release(keyword)
226
227 END SUBROUTINE create_rescale_force_section
228
229! **************************************************************************************************
230!> \brief ...
231!> \param section ...
232!> \author fawzi
233! **************************************************************************************************
234 SUBROUTINE create_f_env_print_section(section)
235 TYPE(section_type), POINTER :: section
236
237 TYPE(keyword_type), POINTER :: keyword
238 TYPE(section_type), POINTER :: print_key
239
240 NULLIFY (keyword)
241 NULLIFY (print_key)
242
243 cpassert(.NOT. ASSOCIATED(section))
244
245 CALL section_create(section, __location__, &
246 name="PRINT", &
247 description="Properties that you want to output and that are common to all methods", &
248 n_keywords=0, n_subsections=10, repeats=.false.)
249
250 CALL cp_print_key_section_create(print_key, __location__, &
251 name="PROGRAM_RUN_INFO", &
252 description="Controls the printing of basic information generated by FORCE_EVAL", &
253 print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
254 CALL keyword_create(keyword, __location__, &
255 name="ENERGY_UNIT", &
256 description="Specifies the physical unit used for the printing of the total energy. "// &
257 "Note that the meaningfulness of the unit is not checked.", &
258 usage="ENERGY_UNIT eV", &
259 default_c_val="hartree", &
260 repeats=.false.)
261 CALL section_add_keyword(print_key, keyword)
262 CALL keyword_release(keyword)
263 CALL section_add_subsection(section, print_key)
264 CALL section_release(print_key)
265
266 CALL cp_print_key_section_create(print_key, __location__, &
267 name="FORCES", &
268 description="Controls the printing of the forces after each force evaluation", &
269 print_level=high_print_level, filename="__STD_OUT__")
270 CALL keyword_create(keyword, __location__, &
271 name="NDIGITS", &
272 description="Specifies the number of digits used "// &
273 "for the printing of the forces", &
274 usage="NDIGITS 6", &
275 default_i_val=8, &
276 repeats=.false.)
277 CALL section_add_keyword(print_key, keyword)
278 CALL keyword_release(keyword)
279 CALL keyword_create(keyword, __location__, &
280 name="FORCE_UNIT", &
281 variants=["UNIT"], & ! add old keyword name for backward compatibility
282 description="Specifies the physical unit used for the printing of the forces. "// &
283 "Note that the meaningfulness of the unit is not checked.", &
284 usage="FORCE_UNIT eV/angstrom", &
285 default_c_val="hartree/bohr", &
286 repeats=.false.)
287 CALL section_add_keyword(print_key, keyword)
288 CALL keyword_release(keyword)
289 CALL section_add_subsection(section, print_key)
290 CALL section_release(print_key)
291
292 CALL cp_print_key_section_create(print_key, __location__, &
293 name="GRID_INFORMATION", &
294 description="Controls the printing of information regarding the PW and RS grid structures.", &
295 print_level=medium_print_level, filename="__STD_OUT__")
296 CALL section_add_subsection(section, print_key)
297 CALL section_release(print_key)
298
299 CALL cp_print_key_section_create(print_key, __location__, &
300 name="TOTAL_NUMBERS", &
301 description="Controls the printing of the total number of atoms, kinds, ...", &
302 print_level=low_print_level, filename="__STD_OUT__")
303 CALL section_add_subsection(section, print_key)
304 CALL section_release(print_key)
305
306 CALL cp_print_key_section_create(print_key, __location__, &
307 name="DISTRIBUTION", &
308 description="Controls the printing of the distribution of molecules, atoms, ...", &
309 print_level=high_print_level, filename="__STD_OUT__")
310 CALL section_add_subsection(section, print_key)
311 CALL section_release(print_key)
312
313 CALL cp_print_key_section_create(print_key, __location__, &
314 name="DISTRIBUTION2D", &
315 description="Controls the printing of the distribution of matrix blocks, ...", &
316 print_level=high_print_level, filename="__STD_OUT__")
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="DISTRIBUTION1D", &
322 description="Each node prints out its distribution info ...", &
323 print_level=high_print_level, filename="__STD_OUT__")
324 CALL section_add_subsection(section, print_key)
325 CALL section_release(print_key)
326
327 CALL cp_print_key_section_create(print_key, __location__, &
328 name="STRESS_TENSOR", &
329 description="Controls the printing of the stress tensor", &
330 print_level=high_print_level, filename="__STD_OUT__")
331 CALL keyword_create(keyword, __location__, &
332 name="COMPONENTS", &
333 description="Print all GPW/GAPW components contributing to the stress tensor", &
334 usage="COMPONENTS", &
335 default_l_val=.false., &
336 lone_keyword_l_val=.true.)
337 CALL section_add_keyword(print_key, keyword)
338 CALL keyword_release(keyword)
339 CALL keyword_create(keyword, __location__, &
340 name="STRESS_UNIT", &
341 description="Specifies the physical unit used for the printing of the stress tensor. "// &
342 "Note that the meaningfulness of the unit is not checked.", &
343 usage="STRESS_UNIT kbar", &
344 default_c_val="bar", &
345 repeats=.false.)
346 CALL section_add_keyword(print_key, keyword)
347 CALL keyword_release(keyword)
348 CALL section_add_subsection(section, print_key)
349 CALL section_release(print_key)
350
351 CALL cp_print_key_section_create(print_key, __location__, &
352 name="GRRM", &
353 description="Controls the printing of the GRRM interface file", &
354 print_level=debug_print_level + 1, filename="CP2K_GRRM")
355 CALL section_add_subsection(section, print_key)
356 CALL section_release(print_key)
357
358 CALL cp_print_key_section_create(print_key, __location__, &
359 name="SCINE", &
360 description="Controls the printing of the SCINE interface file", &
361 print_level=debug_print_level + 1, filename="")
362 CALL section_add_subsection(section, print_key)
363 CALL section_release(print_key)
364
365 END SUBROUTINE create_f_env_print_section
366
367END 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...
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, do_backup)
creates a print_key section
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
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:1282
Creates and parses an input section to define a generic function.
subroutine, public create_function_section(gen_section, section_name, func_name, description, repeats, do_deriv, input_variables)
Create the input section for a generic function.
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 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