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 9174 : 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 9174 : 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 9174 : repeats=.FALSE.)
55 9174 : 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 9174 : default_i_val=opt_force_matching)
64 9174 : CALL section_add_keyword(section, keyword)
65 9174 : 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 9174 : default_r_val=1.e-5_dp)
71 9174 : CALL section_add_keyword(section, keyword)
72 9174 : 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 9174 : default_r_val=0.05_dp)
78 9174 : CALL section_add_keyword(section, keyword)
79 9174 : 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 9174 : default_i_val=5000)
85 9174 : CALL section_add_keyword(section, keyword)
86 9174 : 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 9174 : default_i_val=0)
92 9174 : CALL section_add_keyword(section, keyword)
93 9174 : 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 9174 : default_r_val=0.00_dp)
99 9174 : CALL section_add_keyword(section, keyword)
100 9174 : CALL keyword_release(keyword)
101 :
102 : !
103 : ! variables section
104 : !
105 :
106 9174 : NULLIFY (sub_section)
107 : CALL section_create(sub_section, __LOCATION__, name="VARIABLE", &
108 : description="Defines initial values for variables and their labels", &
109 9174 : 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 9174 : type_of_var=real_t, unit_str="internal_cp2k")
115 9174 : CALL section_add_keyword(sub_section, keyword)
116 9174 : 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 9174 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
122 9174 : CALL section_add_keyword(sub_section, keyword)
123 9174 : 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 9174 : type_of_var=char_t)
129 9174 : CALL section_add_keyword(sub_section, keyword)
130 9174 : CALL keyword_release(keyword)
131 :
132 9174 : CALL section_add_subsection(section, sub_section)
133 9174 : CALL section_release(sub_section)
134 :
135 : !
136 : ! force matching sub sectiong
137 : !
138 :
139 9174 : NULLIFY (sub_section)
140 : CALL section_create(sub_section, __LOCATION__, name="FORCE_MATCHING", &
141 : description="Specify the force matching input.", &
142 9174 : 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 9174 : default_lc_val="")
148 9174 : CALL section_add_keyword(sub_section, keyword)
149 9174 : 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 9174 : default_lc_val="")
155 9174 : CALL section_add_keyword(sub_section, keyword)
156 9174 : 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 9174 : default_lc_val="")
162 9174 : CALL section_add_keyword(sub_section, keyword)
163 9174 : 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 9174 : default_lc_val="")
169 9174 : CALL section_add_keyword(sub_section, keyword)
170 9174 : 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 9174 : usage="group_size 2", default_i_val=6)
177 9174 : CALL section_add_keyword(sub_section, keyword)
178 9174 : 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 9174 : usage="FRAME_START 1", default_i_val=1)
183 9174 : CALL section_add_keyword(sub_section, keyword)
184 9174 : 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 9174 : usage="FRAME_STOP -1", default_i_val=-1)
189 9174 : CALL section_add_keyword(sub_section, keyword)
190 9174 : CALL keyword_release(keyword)
191 :
192 : CALL keyword_create(keyword, __LOCATION__, name="FRAME_STRIDE", &
193 : description="stride when using the reference trajectory", &
194 9174 : usage="FRAME_STRIDE 1", default_i_val=1)
195 9174 : CALL section_add_keyword(sub_section, keyword)
196 9174 : 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 9174 : usage="FRAME_COUNT 100", default_i_val=-1)
202 9174 : CALL section_add_keyword(sub_section, keyword)
203 9174 : 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 9174 : usage="ENERGY_WEIGHT 0.1", default_r_val=0.1_dp)
208 9174 : CALL section_add_keyword(sub_section, keyword)
209 9174 : 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 9174 : usage="SHIFT_AVERAGE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
214 9174 : CALL section_add_keyword(sub_section, keyword)
215 9174 : 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 9174 : usage="SHIFT_QM -17.0", default_r_val=0.0_dp)
220 9174 : CALL section_add_keyword(sub_section, keyword)
221 9174 : 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 9174 : usage="SHIFT_MM 0.0", default_r_val=0.0_dp)
226 9174 : CALL section_add_keyword(sub_section, keyword)
227 9174 : CALL keyword_release(keyword)
228 :
229 9174 : NULLIFY (subsubsection)
230 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "COMPARE_ENERGIES", &
231 : description="A comparison of energies between fit and reference", &
232 9174 : print_level=low_print_level, filename="compare_energies", common_iter_levels=1)
233 9174 : CALL section_add_subsection(sub_section, subsubsection)
234 9174 : CALL section_release(subsubsection)
235 :
236 9174 : NULLIFY (subsubsection)
237 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "COMPARE_FORCES", &
238 : description="A comparison of forces between fit and reference", &
239 9174 : print_level=low_print_level, filename="compare_forces", common_iter_levels=1)
240 9174 : CALL section_add_subsection(sub_section, subsubsection)
241 9174 : CALL section_release(subsubsection)
242 :
243 9174 : CALL section_add_subsection(section, sub_section)
244 9174 : CALL section_release(sub_section)
245 :
246 9174 : NULLIFY (subsubsection)
247 : CALL cp_print_key_section_create(subsubsection, __LOCATION__, "HISTORY", &
248 : description="writes a history of the function value and parameters", &
249 9174 : print_level=low_print_level, filename="history", common_iter_levels=1)
250 9174 : CALL section_add_subsection(section, subsubsection)
251 9174 : 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 9174 : 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 9174 : default_i_val=1)
260 9174 : CALL section_add_keyword(subsubsection, keyword)
261 9174 : CALL keyword_release(keyword)
262 9174 : CALL section_add_subsection(section, subsubsection)
263 9174 : CALL section_release(subsubsection)
264 :
265 9174 : END SUBROUTINE create_optimize_input_section
266 :
267 : END MODULE input_optimize_input
268 :
|