(git:98357aa)
Loading...
Searching...
No Matches
input_cp2k_nnp.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 Creates the NNP section of the input
10!> \author Christoph Schran (christoph.schran@rub.de)
11!> \author Dhruv Sharma (ds2173@cam.ac.uk)
12!> \date 2020-10-10
13! **************************************************************************************************
15
16 USE bibliography, ONLY: behler2007,&
22 USE cp_units, ONLY: cp_unit_to_cp2k
31 USE input_val_types, ONLY: char_t,&
32 integer_t,&
33 real_t
34 USE kinds, ONLY: dp
35#include "./base/base_uses.f90"
36
37 IMPLICIT NONE
38 PRIVATE
39
40 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .false.
41 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_nnp'
42
43 PUBLIC :: create_nnp_section
44
45CONTAINS
46
47! **************************************************************************************************
48!> \brief Create the input section for NNP
49!> \param section the section to create
50!> \date 2020-10-10
51!> \author Christoph Schran (christoph.schran@rub.de)
52! **************************************************************************************************
53 SUBROUTINE create_nnp_section(section)
54 TYPE(section_type), POINTER :: section
55
56 TYPE(keyword_type), POINTER :: keyword
57 TYPE(section_type), POINTER :: subsection, subsubsection
58
59 cpassert(.NOT. ASSOCIATED(section))
60 CALL section_create(section, __location__, name="NNP", &
61 description="This section contains all information to run a "// &
62 "Neural Network Potential (NNP) calculation.", &
63 n_keywords=5, n_subsections=3, repeats=.false., &
65
66 NULLIFY (subsection, subsubsection, keyword)
67
68 CALL keyword_create(keyword, __location__, name="NNP_INPUT_FILE_NAME", &
69 description="File containing the input information for "// &
70 "the setup of the NNP (n2p2/RuNNer format).", &
71 repeats=.false., default_lc_val="input.nn")
72 CALL section_add_keyword(section, keyword)
73 CALL keyword_release(keyword)
74 CALL keyword_create(keyword, __location__, name="SCALE_FILE_NAME", &
75 description="File containing the scaling information for "// &
76 "the symmetry functions of the NNP.", &
77 repeats=.false., default_lc_val="scaling.data")
78 CALL section_add_keyword(section, keyword)
79 CALL keyword_release(keyword)
80
81 CALL keyword_create(keyword, __location__, name="RAD_SPLINE_N", &
82 description="Number of knots per radial group in "// &
83 "the cubic-Hermite spline tables that tabulate "// &
84 "the radial symmetry-function product "// &
85 "y(r) = exp(-eta*(r-rs)^2) * fcut(r). "// &
86 "The value error scales as O(1/n^4) and the "// &
87 "force (derivative) error as O(1/n^3); the "// &
88 "default keeps both inside the NNP regression "// &
89 "tolerance for a radial cutoff of ~12 bohr "// &
90 "(value ~1e-14, force ~1e-10). Larger cutoffs or "// &
91 "stricter tolerances may need a larger n, with "// &
92 "the force term the binding constraint. Memory "// &
93 "cost scales linearly in n per group.", &
94 repeats=.false., &
95 n_var=1, &
96 type_of_var=integer_t, &
97 default_i_val=8192, &
98 usage="RAD_SPLINE_N 8192")
99 CALL section_add_keyword(section, keyword)
100 CALL keyword_release(keyword)
101
102 CALL keyword_create(keyword, __location__, name="VERLET_SKIN", &
103 description="Verlet skin distance for the NNP descriptor "// &
104 "neighbour cell-list. The neighbour-list cutoff is "// &
105 "(symmetry-function cutoff + skin); the cell-list "// &
106 "chain is rebuilt only when an atom drifts more "// &
107 "than skin/2 from its rebuild-time position, "// &
108 "analogous to the LAMMPS 'neighbor <skin> bin' "// &
109 "command. Larger skin reduces the rebuild rate "// &
110 "but enlarges the per-atom neighbour list. "// &
111 "A negative value (default) selects the "// &
112 "automatic heuristic MIN(0.5 bohr, 0.1*cutoff). "// &
113 "Useful upper bound is half the smallest "// &
114 "perpendicular cell width.", &
115 repeats=.false., &
116 n_var=1, &
117 type_of_var=real_t, &
118 default_r_val=-1.0_dp, &
119 unit_str="bohr", &
120 usage="VERLET_SKIN [bohr] 0.5")
121 CALL section_add_keyword(section, keyword)
122 CALL keyword_release(keyword)
123
124 ! BIAS subsection
125 CALL section_create(subsection, __location__, name="BIAS", &
126 description="Section to bias the committee disagreement (sigma) by "// &
127 "E = 0.5 * K_B * (sigma - SIGMA_0)**2, if sigma > SIGMA_0.", &
128 n_keywords=2, n_subsections=0, repeats=.false., &
129 citations=[schran2020b])
130 CALL keyword_create(keyword, __location__, name="K_B", &
131 description="Harmonic spring constant of the bias potential [1/hartree].", &
132 repeats=.false., &
133 n_var=1, &
134 type_of_var=real_t, &
135 default_r_val=cp_unit_to_cp2k(value=0.1_dp, unit_str="hartree^-1"), &
136 unit_str="hartree^-1", &
137 usage="K_B [hartree^-1] 0.1")
138 CALL section_add_keyword(subsection, keyword)
139 CALL keyword_release(keyword)
140 CALL keyword_create(keyword, __location__, name="SIGMA_0", &
141 description="Shift of the harmonic bias potential.", &
142 repeats=.false., &
143 n_var=1, &
144 type_of_var=real_t, &
145 default_r_val=cp_unit_to_cp2k(value=0.1_dp, unit_str="hartree"), &
146 unit_str="hartree", &
147 usage="SIGMA_0 [hartree] 0.1")
148 CALL section_add_keyword(subsection, keyword)
149 CALL keyword_release(keyword)
150 CALL keyword_create(keyword, __location__, name="ALIGN_NNP_ENERGIES", &
151 description="Remove PES shifts within the committee by "// &
152 "subtracting energy for each committee member. Provide "// &
153 "one number per C-NNP member.", &
154 repeats=.false., &
155 n_var=-1, &
156 type_of_var=real_t, &
157 usage="ALIGN_NNP_ENERGIES <REAL> <REAL> ... <REAL>")
158 CALL section_add_keyword(subsection, keyword)
159 CALL keyword_release(keyword)
160 ! print bias subsubsection:
161 CALL create_nnp_bias_print_section(subsubsection)
162 CALL section_add_subsection(subsection, subsubsection)
163 CALL section_release(subsubsection)
164
165 CALL section_add_subsection(section, subsection)
166 CALL section_release(subsection)
167 ! end BIAS subsection
168
169 CALL section_create(subsection, __location__, name="MODEL", &
170 description="Section for a single NNP model. "// &
171 "If this section is repeated, a committee model (C-NNP) "// &
172 "is used where the NNP members share the same symmetry functions.", &
173 n_keywords=1, n_subsections=0, repeats=.true.)
174 CALL keyword_create(keyword, __location__, name="WEIGHTS", &
175 description="File containing the weights for the "// &
176 "artificial neural networks of the NNP. "// &
177 "The specified name is extended by .XXX.data", &
178 repeats=.false., default_lc_val="weights")
179 CALL section_add_keyword(subsection, keyword)
180 CALL keyword_release(keyword)
181 CALL section_add_subsection(section, subsection)
182 CALL section_release(subsection)
183
184 CALL create_nnp_print_section(subsection)
185 CALL section_add_subsection(section, subsection)
186 CALL section_release(subsection)
187
188 END SUBROUTINE create_nnp_section
189
190! **************************************************************************************************
191!> \brief Creates the print section for the nnp subsection
192!> \param section the section to create
193!> \date 2020-10-10
194!> \author Christoph Schran (christoph.schran@rub.de)
195! **************************************************************************************************
196 SUBROUTINE create_nnp_print_section(section)
197 TYPE(section_type), POINTER :: section
198
199 TYPE(keyword_type), POINTER :: keyword
200 TYPE(section_type), POINTER :: print_key
201
202 cpassert(.NOT. ASSOCIATED(section))
203 CALL section_create(section, __location__, name="PRINT", &
204 description="Section of possible print options in NNP code.", &
205 n_keywords=0, n_subsections=5, repeats=.false.)
206
207 NULLIFY (print_key, keyword)
208
209 CALL cp_print_key_section_create(print_key, __location__, "ENERGIES", &
210 description="Controls the printing of the NNP energies.", &
211 print_level=medium_print_level, common_iter_levels=1)
212 CALL section_add_subsection(section, print_key)
213 CALL section_release(print_key)
214
215 CALL cp_print_key_section_create(print_key, __location__, "FORCES", &
216 description="Controls the printing of the NNP forces.", &
217 print_level=medium_print_level, common_iter_levels=1)
218 CALL section_add_subsection(section, print_key)
219 CALL section_release(print_key)
220
221 CALL cp_print_key_section_create(print_key, __location__, "FORCES_SIGMA", &
222 description="Controls the printing of the STD per atom of the NNP forces.", &
223 print_level=medium_print_level, common_iter_levels=1)
224 CALL section_add_subsection(section, print_key)
225 CALL section_release(print_key)
226
227 CALL cp_print_key_section_create(print_key, __location__, "EXTRAPOLATION", &
228 description="If activated, output structures with extrapolation "// &
229 "warning in xyz-format", &
230 print_level=medium_print_level, common_iter_levels=1)
231 CALL section_add_subsection(section, print_key)
232 CALL section_release(print_key)
233
234 CALL cp_print_key_section_create(print_key, __location__, "SUM_FORCE", &
235 description="If activated, output summed force over specified atoms. "// &
236 "Used in Green-Kubo relation for friction at liquid-solid interfaces.", &
237 print_level=medium_print_level, common_iter_levels=1)
238
239 CALL keyword_create(keyword, __location__, name="ATOM_LIST", &
240 description="List of atoms over which to calculate summed force", &
241 usage="ATOM_LISTS {O} {H} .. {X}", repeats=.false., &
242 n_var=-1, type_of_var=char_t)
243 CALL section_add_keyword(print_key, keyword)
244 CALL keyword_release(keyword)
245
246 CALL section_add_subsection(section, print_key)
247 CALL section_release(print_key)
248
249 END SUBROUTINE create_nnp_print_section
250
251! **************************************************************************************************
252!> \brief Creates the print section for the nnp bias subsubsection
253!> \param section the section to create
254!> \date 2020-10-10
255!> \author Christoph Schran (christoph.schran@rub.de)
256! **************************************************************************************************
257 SUBROUTINE create_nnp_bias_print_section(section)
258 TYPE(section_type), POINTER :: section
259
260 TYPE(section_type), POINTER :: print_key
261
262 cpassert(.NOT. ASSOCIATED(section))
263 CALL section_create(section, __location__, name="PRINT", &
264 description="Section of possible print options in NNP code.", &
265 n_keywords=0, n_subsections=3, repeats=.false.)
266
267 NULLIFY (print_key)
268
269 CALL cp_print_key_section_create(print_key, __location__, "BIAS_ENERGY", &
270 description="Controls the printing of the BIAS energy.", &
271 print_level=medium_print_level, common_iter_levels=1)
272 CALL section_add_subsection(section, print_key)
273 CALL section_release(print_key)
274
275 CALL cp_print_key_section_create(print_key, __location__, "BIAS_FORCES", &
276 description="Controls the printing of the BIAS forces.", &
277 print_level=medium_print_level, common_iter_levels=1)
278 CALL section_add_subsection(section, print_key)
279 CALL section_release(print_key)
280
281 END SUBROUTINE create_nnp_bias_print_section
282
283END MODULE input_cp2k_nnp
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public schran2020b
integer, save, public schran2020a
integer, save, public behler2011
integer, save, public behler2007
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public medium_print_level
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:1222
Creates the NNP section of the input.
subroutine, public create_nnp_section(section)
Create the input section for NNP.
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 char_t
integer, parameter, public integer_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
represent a keyword in the input
represent a section of the input file