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 builds the input structure for optimize_input
10 : !> \par History
11 : !> 09.2010 created [Joost VandeVondele]
12 : !> \author Joost VandeVondele
13 : ! **************************************************************************************************
14 : MODULE input_optimize_input
15 : USE cp_output_handling, ONLY: cp_print_key_section_create, &
16 : low_print_level
17 : USE input_constants, ONLY: opt_force_matching
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: char_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 = 'input_optimize_input'
36 : PUBLIC :: create_optimize_input_section
37 :
38 : CONTAINS
39 :
40 : ! **************************************************************************************************
41 : !> \brief creates the optimize_input section
42 : !> \param section ...
43 : !> \author Joost VandeVondele
44 : ! **************************************************************************************************
45 8428 : SUBROUTINE create_optimize_input_section(section)
46 : TYPE(section_type), POINTER :: section
47 :
48 : TYPE(keyword_type), POINTER :: keyword
49 : TYPE(section_type), POINTER :: sub_section, subsubsection
50 :
51 8428 : CPASSERT(.NOT. ASSOCIATED(section))
52 : CALL section_create(section, __LOCATION__, name="OPTIMIZE_INPUT", &
53 : description="describes an input optimization job, in which parameters in input files get optimized.", &
54 8428 : repeats=.FALSE.)
55 8428 : NULLIFY (keyword)
56 :
57 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
58 : description="What kind of input optimization to perform.", &
59 : usage="METHOD FORCE_MATCHING", &
60 : enum_c_vals=s2a("FORCE_MATCHING"), &
61 : enum_desc=s2a("Perform a force matching minimization."), &
62 : enum_i_vals=(/opt_force_matching/), &
63 8428 : default_i_val=opt_force_matching)
64 8428 : CALL section_add_keyword(section, keyword)
65 8428 : CALL keyword_release(keyword)
66 :
67 : CALL keyword_create(keyword, __LOCATION__, name="ACCURACY", &
68 : description="Final accuracy requested in optimization (RHOEND)", &
69 : usage="ACCURACY 0.00001", &
70 8428 : default_r_val=1.e-5_dp)
71 8428 : CALL section_add_keyword(section, keyword)
72 8428 : CALL keyword_release(keyword)
73 :
74 : CALL keyword_create(keyword, __LOCATION__, name="STEP_SIZE", &
75 : description="Initial step size for search algorithm (RHOBEG)", &
76 : usage="STEP_SIZE 0.005", &
77 8428 : default_r_val=0.05_dp)
78 8428 : CALL section_add_keyword(section, keyword)
79 8428 : CALL keyword_release(keyword)
80 :
81 : CALL keyword_create(keyword, __LOCATION__, name="MAX_FUN", &
82 : description="Maximum number of function evaluations", &
83 : usage="MAX_FUN 1000", &
84 8428 : default_i_val=5000)
85 8428 : CALL section_add_keyword(section, keyword)
86 8428 : CALL keyword_release(keyword)
87 :
88 : CALL keyword_create(keyword, __LOCATION__, name="ITER_START_VAL", &
89 : description="Used for restarting, starting value of the iteration", &
90 : usage="ITER_START_VAL 0", &
91 8428 : default_i_val=0)
92 8428 : CALL section_add_keyword(section, keyword)
93 8428 : CALL keyword_release(keyword)
94 :
95 : CALL keyword_create(keyword, __LOCATION__, name="RANDOMIZE_VARIABLES", &
96 : description="Percentage randomization of the free variables applied initially", &
97 : usage="RANDOMIZE_VARIABLES 20", &
98 8428 : default_r_val=0.00_dp)
99 8428 : CALL section_add_keyword(section, keyword)
100 8428 : CALL keyword_release(keyword)
101 :
102 : !
103 : ! variables section
104 : !
105 :
106 8428 : NULLIFY (sub_section)
107 : CALL section_create(sub_section, __LOCATION__, name="VARIABLE", &
108 : description="Defines initial values for variables and their labels", &
109 8428 : n_subsections=0, repeats=.TRUE.)
110 :
111 : CALL keyword_create(keyword, __LOCATION__, name="VALUE", &
112 : description="Initial value of the variable", &
113 : usage="VALUE 0.0", &
114 8428 : type_of_var=real_t, unit_str="internal_cp2k")
115 8428 : CALL section_add_keyword(sub_section, keyword)
116 8428 : CALL keyword_release(keyword)
117 :
118 : CALL keyword_create(keyword, __LOCATION__, name="FIXED", &
119 : description="Is this variable fixed or should it be optimized.", &
120 : usage="FIXED", &
121 8428 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
122 8428 : CALL section_add_keyword(sub_section, keyword)
123 8428 : CALL keyword_release(keyword)
124 :
125 : CALL keyword_create(keyword, __LOCATION__, name="LABEL", &
126 : description="The label used in the input file, i.e. ${LABEL} will be replaced by the VALUE specified.", &
127 : usage="LABEL PRM01", &
128 8428 : type_of_var=char_t)
129 8428 : CALL section_add_keyword(sub_section, keyword)
130 8428 : CALL keyword_release(keyword)
131 :
132 8428 : CALL section_add_subsection(section, sub_section)
133 8428 : CALL section_release(sub_section)
134 :
135 : !
136 : ! force matching sub sectiong
137 : !
138 :
139 8428 : NULLIFY (sub_section)
140 : CALL section_create(sub_section, __LOCATION__, name="FORCE_MATCHING", &
141 : description="Specify the force matching input.", &
142 8428 : repeats=.TRUE.)
143 :
144 : CALL keyword_create(keyword, __LOCATION__, name="OPTIMIZE_FILE_NAME", &
145 : description="the filename of the input file which contains the parameters to be optimized", &
146 : usage="OPTIMIZE_FILE_NAME my_input.inp", &
147 8428 : default_lc_val="")
148 8428 : CALL section_add_keyword(sub_section, keyword)
149 8428 : CALL keyword_release(keyword)
150 :
151 : CALL keyword_create(keyword, __LOCATION__, name="REF_TRAJ_FILE_NAME", &
152 : description="the filename of the reference coordinates.", &
153 : usage="REF_TRAJ_FILE_NAME pos.xyz", &
154 8428 : default_lc_val="")
155 8428 : CALL section_add_keyword(sub_section, keyword)
156 8428 : CALL keyword_release(keyword)
157 :
158 : CALL keyword_create(keyword, __LOCATION__, name="REF_FORCE_FILE_NAME", &
159 : description="the filename of the reference forces, should also contain the energy", &
160 : usage="REF_FORCE_FILE_NAME frc.xyz", &
161 8428 : default_lc_val="")
162 8428 : CALL section_add_keyword(sub_section, keyword)
163 8428 : CALL keyword_release(keyword)
164 :
165 : CALL keyword_create(keyword, __LOCATION__, name="REF_CELL_FILE_NAME", &
166 : description="the filename of the reference cell", &
167 : usage="REF_CELL_FILE_NAME project.cell", &
168 8428 : default_lc_val="")
169 8428 : CALL section_add_keyword(sub_section, keyword)
170 8428 : CALL keyword_release(keyword)
171 :
172 : CALL keyword_create(keyword, __LOCATION__, name="GROUP_SIZE", &
173 : description="Gives the preferred size of a working group, "// &
174 : "groups will always be equal or larger than this size. "// &
175 : "Usually this should take the number of cores per socket into account for good performance.", &
176 8428 : usage="group_size 2", default_i_val=6)
177 8428 : CALL section_add_keyword(sub_section, keyword)
178 8428 : CALL keyword_release(keyword)
179 :
180 : CALL keyword_create(keyword, __LOCATION__, name="FRAME_START", &
181 : description="starting frame to be used from the reference trajectory", &
182 8428 : usage="FRAME_START 1", default_i_val=1)
183 8428 : CALL section_add_keyword(sub_section, keyword)
184 8428 : CALL keyword_release(keyword)
185 :
186 : CALL keyword_create(keyword, __LOCATION__, name="FRAME_STOP", &
187 : description="final frame to be used from the reference trajectory (all=-1)", &
188 8428 : usage="FRAME_STOP -1", default_i_val=-1)
189 8428 : CALL section_add_keyword(sub_section, keyword)
190 8428 : CALL keyword_release(keyword)
191 :
192 : CALL keyword_create(keyword, __LOCATION__, name="FRAME_STRIDE", &
193 : description="stride when using the reference trajectory", &
194 8428 : usage="FRAME_STRIDE 1", default_i_val=1)
195 8428 : CALL section_add_keyword(sub_section, keyword)
196 8428 : CALL keyword_release(keyword)
197 :
198 : CALL keyword_create(keyword, __LOCATION__, name="FRAME_COUNT", &
199 : description="Use at most FRAME_COUNT frames from the reference trajectory, "// &
200 : "adjusting the stride to have them as fas apart as possible (all=-1).", &
201 8428 : usage="FRAME_COUNT 100", default_i_val=-1)
202 8428 : CALL section_add_keyword(sub_section, keyword)
203 8428 : CALL keyword_release(keyword)
204 :
205 : CALL keyword_create(keyword, __LOCATION__, name="ENERGY_WEIGHT", &
206 : description="Relative weight of the energy RMSD vs the force RMSD", &
207 8428 : usage="ENERGY_WEIGHT 0.1", default_r_val=0.1_dp)
208 8428 : CALL section_add_keyword(sub_section, keyword)
209 8428 : CALL keyword_release(keyword)
210 :
211 : CALL keyword_create(keyword, __LOCATION__, name="SHIFT_AVERAGE", &
212 : description="Shift averages of the energies before computing energy RMSD.", &
213 8428 : usage="SHIFT_AVERAGE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
214 8428 : CALL section_add_keyword(sub_section, keyword)
215 8428 : CALL keyword_release(keyword)
216 :
217 : CALL keyword_create(keyword, __LOCATION__, name="SHIFT_QM", &
218 : description="Shift of the reference energies applied before computing energy RMSD.", &
219 8428 : usage="SHIFT_QM -17.0", default_r_val=0.0_dp)
220 8428 : CALL section_add_keyword(sub_section, keyword)
221 8428 : CALL keyword_release(keyword)
222 :
223 : CALL keyword_create(keyword, __LOCATION__, name="SHIFT_MM", &
224 : description="Shift of the fit energies applied before computing energy RMSD.", &
225 8428 : usage="SHIFT_MM 0.0", default_r_val=0.0_dp)
226 8428 : CALL section_add_keyword(sub_section, keyword)
227 8428 : CALL keyword_release(keyword)
228 :
229 8428 : NULLIFY (subsubsection)
230 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "COMPARE_ENERGIES", &
231 : description="A comparison of energies between fit and reference", &
232 8428 : print_level=low_print_level, filename="compare_energies", common_iter_levels=1)
233 8428 : CALL section_add_subsection(sub_section, subsubsection)
234 8428 : CALL section_release(subsubsection)
235 :
236 8428 : NULLIFY (subsubsection)
237 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "COMPARE_FORCES", &
238 : description="A comparison of forces between fit and reference", &
239 8428 : print_level=low_print_level, filename="compare_forces", common_iter_levels=1)
240 8428 : CALL section_add_subsection(sub_section, subsubsection)
241 8428 : CALL section_release(subsubsection)
242 :
243 8428 : CALL section_add_subsection(section, sub_section)
244 8428 : CALL section_release(sub_section)
245 :
246 8428 : NULLIFY (subsubsection)
247 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "HISTORY", &
248 : description="writes a history of the function value and parameters", &
249 8428 : print_level=low_print_level, filename="history", common_iter_levels=1)
250 8428 : CALL section_add_subsection(section, subsubsection)
251 8428 : CALL section_release(subsubsection)
252 :
253 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "RESTART", &
254 : description="writes an input file that can be used to restart ", &
255 8428 : print_level=low_print_level, filename="optimize", common_iter_levels=1)
256 : CALL keyword_create(keyword, __LOCATION__, name="BACKUP_COPIES", &
257 : description="Specifies the maximum number of backup copies.", &
258 : usage="BACKUP_COPIES {int}", &
259 8428 : default_i_val=1)
260 8428 : CALL section_add_keyword(subsubsection, keyword)
261 8428 : CALL keyword_release(keyword)
262 8428 : CALL section_add_subsection(section, subsubsection)
263 8428 : CALL section_release(subsubsection)
264 :
265 8428 : END SUBROUTINE create_optimize_input_section
266 :
267 : END MODULE input_optimize_input
268 :
|