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 Declares the input for global optimization
10 : !> \author Ole Schuett
11 : ! **************************************************************************************************
12 : MODULE glbopt_input
13 : USE bibliography, ONLY: Goedecker2004
14 : USE cp_output_handling, ONLY: cp_print_key_section_create,&
15 : low_print_level
16 : USE input_constants, ONLY: glbopt_do_mincrawl,&
17 : glbopt_do_minhop
18 : USE input_keyword_types, ONLY: keyword_create,&
19 : keyword_release,&
20 : keyword_type
21 : USE input_section_types, ONLY: section_add_keyword,&
22 : section_add_subsection,&
23 : section_create,&
24 : section_release,&
25 : section_type
26 : USE input_val_types, ONLY: integer_t,&
27 : real_t
28 : USE kinds, ONLY: dp
29 : USE string_utilities, ONLY: s2a
30 : #include "../base/base_uses.f90"
31 :
32 : IMPLICIT NONE
33 : PRIVATE
34 :
35 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'glbopt_input'
36 :
37 : PUBLIC :: glbopt_declare_input
38 :
39 : CONTAINS
40 :
41 : ! **************************************************************************************************
42 : !> \brief Declares the SWARM%GLOBAL_OPT input section
43 : !> \param swarm_section ...
44 : !> \author Ole Schuett
45 : ! **************************************************************************************************
46 8530 : SUBROUTINE glbopt_declare_input(swarm_section)
47 : TYPE(section_type), POINTER :: swarm_section
48 :
49 : TYPE(keyword_type), POINTER :: keyword
50 : TYPE(section_type), POINTER :: glbopt_section, printkey
51 :
52 8530 : NULLIFY (glbopt_section, keyword, printkey)
53 :
54 : CALL section_create(glbopt_section, __LOCATION__, name="GLOBAL_OPT", &
55 : description="Section to control global geometry optimizations.", &
56 8530 : repeats=.FALSE.)
57 :
58 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
59 : description="Methods to use for optimization.", &
60 : default_i_val=glbopt_do_minhop, &
61 : enum_c_vals=s2a("MINIMA_HOPPING", "MINIMA_CRAWLING"), &
62 : enum_desc=s2a("Runs Minima-Hopping algorithm.", &
63 : "Runs Minima-Crawling algorithm."), &
64 8530 : enum_i_vals=(/glbopt_do_minhop, glbopt_do_mincrawl/))
65 8530 : CALL section_add_keyword(glbopt_section, keyword)
66 8530 : CALL keyword_release(keyword)
67 :
68 : CALL keyword_create(keyword, __LOCATION__, name="E_TARGET", &
69 : description="Target Energy, the optimization will quit once a lower potential energy is reached.", &
70 8530 : default_r_val=-1*HUGE(1.0_dp), type_of_var=real_t, unit_str="hartree")
71 8530 : CALL section_add_keyword(glbopt_section, keyword)
72 8530 : CALL keyword_release(keyword)
73 :
74 : CALL keyword_create(keyword, __LOCATION__, name="MD_BUMPS_MAX", &
75 : description="Number of bumps in potential energy after which MD runs ends.", &
76 8530 : type_of_var=integer_t, default_i_val=3)
77 8530 : CALL section_add_keyword(glbopt_section, keyword)
78 8530 : CALL keyword_release(keyword)
79 :
80 : CALL keyword_create(keyword, __LOCATION__, name="BUMP_STEPS_UPWARDS", &
81 : description="Number of MD steps with potential energy increases required for a bump.", &
82 8530 : type_of_var=integer_t, default_i_val=2)
83 8530 : CALL section_add_keyword(glbopt_section, keyword)
84 8530 : CALL keyword_release(keyword)
85 :
86 : CALL keyword_create(keyword, __LOCATION__, name="BUMP_STEPS_DOWNWARDS", &
87 : description="Number of MD steps with potential energy decreases required for a bump.", &
88 8530 : type_of_var=integer_t, default_i_val=2)
89 8530 : CALL section_add_keyword(glbopt_section, keyword)
90 8530 : CALL keyword_release(keyword)
91 :
92 : CALL keyword_create(keyword, __LOCATION__, name="FRAGMENTATION_THRESHOLD", &
93 : description="Threshold for atom distance used for detecting fragmentation of clusters.", &
94 8530 : default_r_val=2.0_dp, unit_str="angstrom", type_of_var=real_t)
95 8530 : CALL section_add_keyword(glbopt_section, keyword)
96 8530 : CALL keyword_release(keyword)
97 :
98 : !CALL keyword_create(keyword, __LOCATION__, name="MD_ADAPTIVE_TIMESTEP",&
99 : ! description="Make MD timesteps longer for lower temperatures.", &
100 : ! default_r_val=0.0_dp, type_of_var=real_t)
101 : !CALL section_add_keyword(glbopt_section, keyword)
102 : !CALL keyword_release(keyword)
103 :
104 : CALL cp_print_key_section_create( &
105 : printkey, __LOCATION__, "PROGRESS_TRAJECTORY", &
106 : description="Printkey to control the writting of the progress trajectory. "// &
107 : "This trajectory contains the minima, which are lower in energy than the by then lowerest.", &
108 : print_level=low_print_level, common_iter_levels=1, &
109 8530 : filename="", unit_str="angstrom")
110 8530 : CALL section_add_subsection(glbopt_section, printkey)
111 8530 : CALL section_release(printkey)
112 :
113 8530 : CALL history_declare_input(glbopt_section)
114 8530 : CALL minhop_declare_input(glbopt_section)
115 8530 : CALL mincrawl_declare_input(glbopt_section)
116 :
117 8530 : CALL section_add_subsection(swarm_section, glbopt_section)
118 8530 : CALL section_release(glbopt_section)
119 8530 : END SUBROUTINE glbopt_declare_input
120 :
121 : ! **************************************************************************************************
122 : !> \brief Declares the SWARM%GLOBAL_OPT%HISTORY input section
123 : !> \param glbopt_section ...
124 : !> \author Ole Schuett
125 : ! **************************************************************************************************
126 8530 : SUBROUTINE history_declare_input(glbopt_section)
127 : TYPE(section_type), POINTER :: glbopt_section
128 :
129 : TYPE(keyword_type), POINTER :: keyword
130 : TYPE(section_type), POINTER :: history_section
131 :
132 8530 : NULLIFY (history_section, keyword)
133 :
134 : CALL section_create(history_section, __LOCATION__, name="HISTORY", &
135 : description="Section controlling the history of visited minima and "// &
136 : "how minima are recognized at a later point.", &
137 8530 : repeats=.FALSE.)
138 :
139 : CALL keyword_create(keyword, __LOCATION__, name="ENERGY_PRECISION", &
140 : description="If the difference of two energies is below this threshold "// &
141 : "they are considert equal.", &
142 8530 : default_r_val=1.0e-5_dp, type_of_var=real_t)
143 8530 : CALL section_add_keyword(history_section, keyword)
144 8530 : CALL keyword_release(keyword)
145 :
146 : CALL keyword_create(keyword, __LOCATION__, name="FINGERPRINT_PRECISION", &
147 : description="If the euclidean distance of two fingerprints is below "// &
148 : "this threshold, they are considert equal.", &
149 8530 : default_r_val=1.0e-2_dp, type_of_var=real_t)
150 8530 : CALL section_add_keyword(history_section, keyword)
151 8530 : CALL keyword_release(keyword)
152 :
153 8530 : CALL section_add_subsection(glbopt_section, history_section)
154 8530 : CALL section_release(history_section)
155 8530 : END SUBROUTINE history_declare_input
156 :
157 : ! **************************************************************************************************
158 : !> \brief Declares the SWARM%GLOBAL_OPT%MINIMA_HOPPING input section
159 : !> \param glbopt_section ...
160 : !> \author Ole Schuett
161 : ! **************************************************************************************************
162 8530 : SUBROUTINE minhop_declare_input(glbopt_section)
163 : TYPE(section_type), POINTER :: glbopt_section
164 :
165 : TYPE(keyword_type), POINTER :: keyword
166 : TYPE(section_type), POINTER :: minhop_section
167 :
168 8530 : NULLIFY (minhop_section, keyword)
169 :
170 : CALL section_create(minhop_section, __LOCATION__, name="MINIMA_HOPPING", &
171 : description="Section controlling the Minima Hopping method.", &
172 : citations=(/Goedecker2004/), &
173 17060 : repeats=.FALSE.)
174 :
175 : CALL keyword_create(keyword, __LOCATION__, name="BETA_1", &
176 : description="Factor used to increase temperature when escape failed, "// &
177 : "should be larger than 1.", &
178 8530 : default_r_val=1.1_dp, type_of_var=real_t)
179 8530 : CALL section_add_keyword(minhop_section, keyword)
180 8530 : CALL keyword_release(keyword)
181 :
182 : CALL keyword_create(keyword, __LOCATION__, name="BETA_2", &
183 : description="Factor used to increase temperature when escape found "// &
184 : "known minima, should be larger than 1.", &
185 8530 : default_r_val=1.1_dp, type_of_var=real_t)
186 8530 : CALL section_add_keyword(minhop_section, keyword)
187 8530 : CALL keyword_release(keyword)
188 :
189 : CALL keyword_create(keyword, __LOCATION__, name="BETA_3", &
190 : description="Factor used to decrease temperature when escape succeeded, "// &
191 : "should be smaller than 1.", &
192 8530 : default_r_val=1.0/1.1_dp, type_of_var=real_t)
193 8530 : CALL section_add_keyword(minhop_section, keyword)
194 8530 : CALL keyword_release(keyword)
195 :
196 : CALL keyword_create(keyword, __LOCATION__, name="ALPHA_1", &
197 : description="Factor used to decrease acceptance energy, when minima was accepted, "// &
198 : "should be smaller than 1.", &
199 8530 : default_r_val=0.98_dp, type_of_var=real_t)
200 8530 : CALL section_add_keyword(minhop_section, keyword)
201 8530 : CALL keyword_release(keyword)
202 :
203 : CALL keyword_create(keyword, __LOCATION__, name="ALPHA_2", &
204 : description="Factor used to increase acceptance energy, when minima was rejected, "// &
205 : "should be larger than 1.", &
206 8530 : default_r_val=1.0/0.98_dp, type_of_var=real_t)
207 8530 : CALL section_add_keyword(minhop_section, keyword)
208 8530 : CALL keyword_release(keyword)
209 :
210 : CALL keyword_create(keyword, __LOCATION__, name="E_ACCEPT_INIT", &
211 : description="Initial value of acceptance energy", &
212 8530 : default_r_val=0.005_dp, type_of_var=real_t, unit_str="hartree")
213 8530 : CALL section_add_keyword(minhop_section, keyword)
214 8530 : CALL keyword_release(keyword)
215 :
216 : CALL keyword_create(keyword, __LOCATION__, name="TEMPERATURE_INIT", &
217 : description="Initially temperature in Kelvin", &
218 8530 : default_r_val=100.0_dp, type_of_var=real_t)
219 8530 : CALL section_add_keyword(minhop_section, keyword)
220 8530 : CALL keyword_release(keyword)
221 :
222 : CALL keyword_create(keyword, __LOCATION__, name="SHARE_HISTORY", &
223 : description="If set all worker will use a single share history of visited minima.", &
224 8530 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
225 8530 : CALL section_add_keyword(minhop_section, keyword)
226 8530 : CALL keyword_release(keyword)
227 :
228 8530 : CALL section_add_subsection(glbopt_section, minhop_section)
229 8530 : CALL section_release(minhop_section)
230 8530 : END SUBROUTINE minhop_declare_input
231 :
232 : ! **************************************************************************************************
233 : !> \brief Declares the SWARM%GLOBAL_OPT%MINIMA_CRAWLING input section
234 : !> \param glbopt_section ...
235 : !> \author Ole Schuett
236 : ! **************************************************************************************************
237 8530 : SUBROUTINE mincrawl_declare_input(glbopt_section)
238 : TYPE(section_type), POINTER :: glbopt_section
239 :
240 : TYPE(keyword_type), POINTER :: keyword
241 : TYPE(section_type), POINTER :: mincrawl_section, printkey
242 :
243 8530 : NULLIFY (mincrawl_section, keyword, printkey)
244 :
245 : CALL section_create(mincrawl_section, __LOCATION__, name="MINIMA_CRAWLING", &
246 : description="Section controls Minima Crawling run.", &
247 8530 : repeats=.FALSE.)
248 :
249 : CALL keyword_create(keyword, __LOCATION__, name="TEMPSTEP_BASE", &
250 : description="Base used to calculate temperature steps base**n", &
251 8530 : default_r_val=1.1_dp, type_of_var=real_t)
252 8530 : CALL section_add_keyword(mincrawl_section, keyword)
253 8530 : CALL keyword_release(keyword)
254 :
255 : CALL keyword_create(keyword, __LOCATION__, name="TEMPSTEP_MAX", &
256 : description="Maximum number of temperature steps.", &
257 8530 : default_i_val=100, type_of_var=integer_t)
258 8530 : CALL section_add_keyword(mincrawl_section, keyword)
259 8530 : CALL keyword_release(keyword)
260 :
261 : CALL keyword_create(keyword, __LOCATION__, name="TEMPDIST_UPDATE_WIDTH", &
262 : description="Width of gaussian used to update temperature distribution.", &
263 8530 : default_r_val=2.0_dp, type_of_var=real_t)
264 8530 : CALL section_add_keyword(mincrawl_section, keyword)
265 8530 : CALL keyword_release(keyword)
266 :
267 : CALL keyword_create(keyword, __LOCATION__, name="TEMPDIST_UPDATE_HEIGHT", &
268 : description="Height of gaussian used to update temperature distribution.", &
269 8530 : default_r_val=0.1_dp, type_of_var=real_t)
270 8530 : CALL section_add_keyword(mincrawl_section, keyword)
271 8530 : CALL keyword_release(keyword)
272 :
273 : CALL keyword_create(keyword, __LOCATION__, name="TEMPERATURE_INIT", &
274 : description="Initial temperature in Kelvin", &
275 8530 : default_r_val=100.0_dp, type_of_var=real_t)
276 8530 : CALL section_add_keyword(mincrawl_section, keyword)
277 8530 : CALL keyword_release(keyword)
278 :
279 : CALL keyword_create(keyword, __LOCATION__, name="TEMPDIST_INIT_WIDTH", &
280 : description="Initial width of temperature distribution.", &
281 8530 : default_r_val=5.0_dp, type_of_var=real_t)
282 8530 : CALL section_add_keyword(mincrawl_section, keyword)
283 8530 : CALL keyword_release(keyword)
284 :
285 : CALL keyword_create(keyword, __LOCATION__, name="WORKER_PER_MINIMA", &
286 : description="Maximum number of active workers per Minima.", &
287 8530 : default_i_val=3, type_of_var=integer_t)
288 8530 : CALL section_add_keyword(mincrawl_section, keyword)
289 8530 : CALL keyword_release(keyword)
290 :
291 : CALL keyword_create(keyword, __LOCATION__, name="ESCAPE_HISTORY_LENGTH", &
292 : description="Number of escapes averaged for scoring of minima.", &
293 8530 : default_i_val=10, type_of_var=integer_t)
294 8530 : CALL section_add_keyword(mincrawl_section, keyword)
295 8530 : CALL keyword_release(keyword)
296 :
297 : CALL cp_print_key_section_create(printkey, __LOCATION__, "MINIMA_TRAJECTORY", &
298 : description="Printkey to control the writting of the minima trajectory. "// &
299 : "This trajectory contains all encountered local minima.", &
300 : print_level=low_print_level, common_iter_levels=1, &
301 8530 : filename="", unit_str="angstrom")
302 8530 : CALL section_add_subsection(mincrawl_section, printkey)
303 8530 : CALL section_release(printkey)
304 :
305 8530 : CALL section_add_subsection(glbopt_section, mincrawl_section)
306 8530 : CALL section_release(mincrawl_section)
307 8530 : END SUBROUTINE mincrawl_declare_input
308 :
309 : END MODULE glbopt_input
310 :
|