Line data Source code
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 MIXED environment
10 : !> \par History
11 : !> 10.2008 created [tlaino]
12 : !> \author Teodoro Laino [tlaino] - University of Zurich
13 : ! **************************************************************************************************
14 : MODULE input_cp2k_mixed
15 : USE bibliography, ONLY: Holmberg2017,&
16 : Holmberg2018,&
17 : Mavros2015,&
18 : Migliore2009
19 : USE cp_output_handling, ONLY: add_last_numeric,&
20 : cp_print_key_section_create,&
21 : low_print_level,&
22 : medium_print_level
23 : USE generic_function_input, ONLY: create_function_section
24 : USE input_constants, ONLY: mix_cdft,&
25 : mix_coupled,&
26 : mix_generic,&
27 : mix_linear_combination,&
28 : mix_minimum,&
29 : mix_restrained
30 : USE input_keyword_types, ONLY: keyword_create,&
31 : keyword_release,&
32 : keyword_type
33 : USE input_section_types, ONLY: section_add_keyword,&
34 : section_add_subsection,&
35 : section_create,&
36 : section_release,&
37 : section_type
38 : USE input_val_types, ONLY: integer_t,&
39 : lchar_t,&
40 : logical_t,&
41 : real_t
42 : USE kinds, ONLY: dp
43 : USE string_utilities, ONLY: s2a
44 : #include "./base/base_uses.f90"
45 :
46 : IMPLICIT NONE
47 : PRIVATE
48 :
49 : LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
50 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_mixed'
51 :
52 : PUBLIC :: create_mix_section
53 :
54 : CONTAINS
55 :
56 : ! **************************************************************************************************
57 : !> \brief Create the input section for MIXED.
58 : !> \param section the section to create
59 : !> \author fschiff
60 : ! **************************************************************************************************
61 1462 : SUBROUTINE create_mix_section(section)
62 : TYPE(section_type), POINTER :: section
63 :
64 : TYPE(keyword_type), POINTER :: keyword
65 : TYPE(section_type), POINTER :: sub2section, sub3section, subsection
66 :
67 1462 : CPASSERT(.NOT. ASSOCIATED(section))
68 : CALL section_create(section, __LOCATION__, name="MIXED", &
69 : description="This section contains all information to run with a hamiltonian "// &
70 : "defined by a mixing of force_evals. See also the MULTIPLE_FORCE_EVALS section.", &
71 1462 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
72 1462 : NULLIFY (keyword, subsection)
73 :
74 : CALL keyword_create( &
75 : keyword, __LOCATION__, name="MIXING_TYPE", &
76 : description="The type of mixing to be employed", &
77 : usage="MIXING_TYPE LINEAR_COMBINATION", &
78 : default_i_val=mix_linear_combination, &
79 : enum_c_vals=s2a("LINEAR_COMBINATION", &
80 : "MINIMUM", &
81 : "COUPLED", &
82 : "RESTRAINT", &
83 : "GENMIX", &
84 : "MIXED_CDFT"), &
85 : enum_desc=s2a("Linear combination of force envs (support only 2 force_evals)", &
86 : "Use the force env with the minimum energy (support only 2 force_evals)", &
87 : "Consider the force envs as a two state system with a given"// &
88 : " coupling matrix element (support only 2 force_evals)", &
89 : "Use the difference between the energy of the force envs as a"// &
90 : " restraint on the first (support only 2 force_evals)", &
91 : "Defines a user-driven generica coupling (support for an unlimited number of force_eval)", &
92 : "Consider each force env as a CDFT state (supports an unlimited number of force_eval "// &
93 : "for calculation of CDFT properties, but only two states can be mixed for forces)."), &
94 : enum_i_vals=[mix_linear_combination, mix_minimum, mix_coupled, mix_restrained, mix_generic, &
95 1462 : mix_cdft])
96 1462 : CALL section_add_keyword(section, keyword)
97 1462 : CALL keyword_release(keyword)
98 :
99 : CALL keyword_create(keyword, __LOCATION__, name="GROUP_PARTITION", &
100 : description="gives the exact number of processors for each group."// &
101 : " If not specified processors allocated will be equally distributed for"// &
102 : " the specified subforce_eval, trying to build a number of groups equal to the"// &
103 : " number of subforce_eval specified.", &
104 1462 : usage="group_partition 2 2 4 2 4 ", type_of_var=integer_t, n_var=-1)
105 1462 : CALL section_add_keyword(section, keyword)
106 1462 : CALL keyword_release(keyword)
107 :
108 : CALL keyword_create(keyword, __LOCATION__, name="NGROUPS", variants=["NGROUP"], &
109 : description="Gives the wanted number of groups. If not specified the number"// &
110 : " of groups is set to the number of subforce_eval defined.", &
111 2924 : usage="ngroups 4", type_of_var=integer_t)
112 1462 : CALL section_add_keyword(section, keyword)
113 1462 : CALL keyword_release(keyword)
114 :
115 : ! Double force_eval
116 : CALL section_create(subsection, __LOCATION__, name="LINEAR", &
117 : description="Linear combination between two force_eval: F= lambda F1 + (1-lambda) F2", &
118 1462 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
119 :
120 : CALL keyword_create(keyword, __LOCATION__, name="LAMBDA", &
121 : description="Specify the mixing parameter lambda in the formula.", &
122 1462 : usage="lambda <REAL>", type_of_var=real_t)
123 1462 : CALL section_add_keyword(subsection, keyword)
124 1462 : CALL keyword_release(keyword)
125 :
126 1462 : CALL section_add_subsection(section, subsection)
127 1462 : CALL section_release(subsection)
128 : ! Mixed CDFT section
129 : CALL section_create(subsection, __LOCATION__, name="MIXED_CDFT", &
130 : description="Calculate properties involving multiple constrained states. "// &
131 : "Each repetition of the FORCE_EVAL section defines a new CDFT state that is "// &
132 : "included in the simulation. The DFT&QS&CDFT section must be active in each "// &
133 : "FORCE_EVAL and it must be consistently defined. When the keyword "// &
134 : "MIXED&NGROUPS is set to a value 2 or larger, the CDFT states are solved in "// &
135 : "parallel, whereas when it is set to 1, the states are solved in serial. "// &
136 : "During MD, the system can be translated using only two of the CDFT states, "// &
137 : "which are selected with the keyword FORCE_STATES. The forces are determined "// &
138 : "by the linear combination F= lambda F1 + (1-lambda) F2.", &
139 4386 : n_keywords=11, n_subsections=2, repeats=.FALSE., citations=[Holmberg2017, Holmberg2018])
140 :
141 : CALL keyword_create(keyword, __LOCATION__, name="LAMBDA", &
142 : description="Specify the mixing parameter lambda in the formula.", &
143 1462 : usage="lambda <REAL>", type_of_var=real_t)
144 1462 : CALL section_add_keyword(subsection, keyword)
145 1462 : CALL keyword_release(keyword)
146 :
147 : CALL keyword_create(keyword, __LOCATION__, name="FORCE_STATES", &
148 : description="Defines the CDFT states used to translate the system. ", &
149 : usage="FORCE_STATES 1 1", n_var=2, &
150 1462 : default_i_vals=[1, 2], type_of_var=integer_t)
151 1462 : CALL section_add_keyword(subsection, keyword)
152 1462 : CALL keyword_release(keyword)
153 :
154 : CALL keyword_create(keyword, __LOCATION__, name="COUPLING", &
155 : description="Parameter determining how often the CDFT electronic coupling element "// &
156 : "is calculated. Use a negative number to disable and 0 means every step. By default, "// &
157 : "the coupling is calculated by rotating the CDFT states to eigenstates of the weight "// &
158 : "function matrix when a single constraint is active and the constraint definitions are "// &
159 : "identical in both CDFT states. Otherwise uses Lowdin orthogonalization. For more than "// &
160 : "two CDFT states, the couplings are not computed pairwise and the values might "// &
161 : "deviate from values computed separately for each unique CDFT state pair.", &
162 : usage="COUPLING <INT>", &
163 : default_i_val=-1, &
164 1462 : type_of_var=integer_t, n_var=1)
165 1462 : CALL section_add_keyword(subsection, keyword)
166 1462 : CALL keyword_release(keyword)
167 :
168 : CALL keyword_create(keyword, __LOCATION__, name="PARALLEL_BUILD", &
169 : description="Build CDFT weight function and gradients in parallel on all "// &
170 : "N MPI processors before starting the CDFT SCF calculations of the 2 "// &
171 : "involved CDFT states in parallel on N/2 processors. Supports only Becke "// &
172 : "constraints that are identical in both states. Limited to 1 "// &
173 : "charge constraint per state (different target values). "// &
174 : "The keyword MIXED&NGROUPS must be set to 2.", &
175 : usage="PARALLEL_BUILD TRUE", type_of_var=logical_t, &
176 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
177 1462 : CALL section_add_keyword(subsection, keyword)
178 1462 : CALL keyword_release(keyword)
179 :
180 : CALL keyword_create(keyword, __LOCATION__, name="DLB", &
181 : description="Controls the activation of dynamic load balancing during a mixed CDFT calculation."// &
182 : " Requires Gaussian cavity confinement. Works only in conjunction with keyword PARALLEL_BUILD.", &
183 : usage="DLB", type_of_var=logical_t, &
184 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
185 1462 : CALL section_add_keyword(subsection, keyword)
186 1462 : CALL keyword_release(keyword)
187 :
188 : CALL keyword_create(keyword, __LOCATION__, name="METRIC", variants=["COUPLING_METRIC"], &
189 : description="Compute reliability metric for the CDFT electronic coupling element by "// &
190 : "diagonalizing the difference density matrix.", &
191 : usage="METRIC", type_of_var=logical_t, &
192 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE., &
193 4386 : citations=[Mavros2015])
194 1462 : CALL section_add_keyword(subsection, keyword)
195 1462 : CALL keyword_release(keyword)
196 :
197 : CALL keyword_create(keyword, __LOCATION__, name="WFN_OVERLAP", &
198 : description="Compute the CDFT electronic coupling element using the wavefunction overlap "// &
199 : "method in addition to the standard method defined by the keyword COUPLING. "// &
200 : "In this method, the unconstrained KS ground state wavefunction (WFN_RESTART_FILE_NAME) "// &
201 : "is represented as a linear combination of the CDFT states. For more than two CDFT states, "// &
202 : "the coupling is computed pairwise for every state pair (contrary to other coupling methods).", &
203 : usage="WFN_OVERLAP", type_of_var=logical_t, &
204 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE., &
205 2924 : citations=[Migliore2009])
206 1462 : CALL section_add_keyword(subsection, keyword)
207 1462 : CALL keyword_release(keyword)
208 :
209 : CALL keyword_create(keyword, __LOCATION__, name="LOWDIN", &
210 : description="Compute the CDFT electronic coupling element using Lowdin orthogonalization. "// &
211 : "This is the default behavior with multiple constraints and nonidentical constraints. "// &
212 : "By activating this keyword, this method is also used to compute the coupling "// &
213 : "when a single constraint is active in addition to the standard method.", &
214 : usage="LOWDIN", type_of_var=logical_t, &
215 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
216 1462 : CALL section_add_keyword(subsection, keyword)
217 1462 : CALL keyword_release(keyword)
218 :
219 : CALL keyword_create(keyword, __LOCATION__, name="CI", variants=["CONFIGURATION_INTERACTION"], &
220 : description="Perform a CDFT configuration interaction calculation (CDFT-CI). "// &
221 : "The CI vector is expanded in the basis of the CDFT states. Diagonalizes the "// &
222 : "nonorthogonal diabatic CDFT Hamiltonian. The energies and expansion coefficients "// &
223 : "of the CDFT-CI states are outputted. Keyword COUPLING must be active "// &
224 : "to use this feature.", &
225 : usage="CI", type_of_var=logical_t, &
226 2924 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
227 1462 : CALL section_add_keyword(subsection, keyword)
228 1462 : CALL keyword_release(keyword)
229 :
230 : CALL keyword_create(keyword, __LOCATION__, name="NONORTHOGONAL_COUPLING", &
231 : variants=["NONORTHO_COUPLING"], &
232 : description="Print out the nonorthogonal diabatic CDFT coupling between states, "// &
233 : "as it appears in the mixed CDFT Hamiltonian before orthogonalization (coupling "// &
234 : "calculations) and CDFT-CI. Useful for (re)constructing the Hamiltonian for additional "// &
235 : "analysis. This is the CDFT interaction energy between states.", &
236 : usage="NONORTHOGONAL_COUPLING", type_of_var=logical_t, &
237 2924 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
238 1462 : CALL section_add_keyword(subsection, keyword)
239 1462 : CALL keyword_release(keyword)
240 :
241 : CALL keyword_create(keyword, __LOCATION__, name="SCALE_WITH_OCCUPATION_NUMBERS", &
242 : description="Scale molecular orbitals with occupation numbers before calculating "// &
243 : "the electronic coupling. Affects only simulations which employ MO smearing. "// &
244 : "Disabling this keyword in conjunction with a properly selected EPS_OCCUPIED "// &
245 : "threshold might be useful in systems with a large number of fractionally "// &
246 : "occupied orbitals.", &
247 : usage="SCALE_WITH_OCCUPATION_NUMBERS FALSE", type_of_var=logical_t, &
248 1462 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
249 1462 : CALL section_add_keyword(subsection, keyword)
250 1462 : CALL keyword_release(keyword)
251 :
252 : CALL keyword_create(keyword, __LOCATION__, name="WFN_RESTART_FILE_NAME", &
253 : description="Name of the wavefunction restart file that defines the unconstrained"// &
254 : " KS ground state, which is used to compute the electronic coupling with"// &
255 : " the wavefunction overlap method. May include a path.", &
256 : usage="WFN_RESTART_FILE_NAME <FILENAME>", &
257 1462 : type_of_var=lchar_t)
258 1462 : CALL section_add_keyword(subsection, keyword)
259 1462 : CALL keyword_release(keyword)
260 :
261 : CALL keyword_create(keyword, __LOCATION__, name="EPS_SVD", &
262 : description="Determines the matrix inversion solver needed to compute the coupling."// &
263 : " Default value implies LU decomposition, while values between 0.0 and 1.0"// &
264 : " imply SVD decomposition. For SVD, the value acts as a threshold"// &
265 : " for screening singular values so that only values above it are included"// &
266 : " in the matrix pseudoinverse.", &
267 : usage="EPS_SVD <REAL>", type_of_var=real_t, &
268 1462 : default_r_val=0.0_dp, repeats=.FALSE.)
269 1462 : CALL section_add_keyword(subsection, keyword)
270 1462 : CALL keyword_release(keyword)
271 :
272 : CALL keyword_create(keyword, __LOCATION__, name="EPS_OCCUPIED", &
273 : description="Threshold for determining which molecular orbitals are considered occupied"// &
274 : " when fractional and/or empty orbitals are employed. Can and usually should be less than"// &
275 : " the threshold EPS_FERMI_DIRAC defined in section SCF&SMEAR. Note that the number occupied"// &
276 : " MOs should be constant in each CDFT state, since the CDFT coupling is only defined between"// &
277 : " states in the same spin state. Fractionally occupied MOs might exhibit linear dependencies"// &
278 : " and a singular value decomposition (EPS_SVD) can be used for removing these.", &
279 : usage="EPS_OCCUPIED <REAL>", type_of_var=real_t, &
280 1462 : default_r_val=1.0E-6_dp, repeats=.FALSE.)
281 1462 : CALL section_add_keyword(subsection, keyword)
282 1462 : CALL keyword_release(keyword)
283 :
284 : CALL keyword_create(keyword, __LOCATION__, name="LOAD_SCALE", &
285 : description="Control parameter for dynamic load balancing during a mixed CDFT calculation."// &
286 : " See code for details. Works only in conjunction with keyword PARALLEL_BUILD.", &
287 : usage="LOAD_SCALE <REAL>", type_of_var=real_t, &
288 1462 : default_r_val=2.0_dp)
289 1462 : CALL section_add_keyword(subsection, keyword)
290 1462 : CALL keyword_release(keyword)
291 :
292 : CALL keyword_create(keyword, __LOCATION__, name="MORE_WORK", &
293 : description="Control parameter for dynamic load balancing during a mixed CDFT calculation."// &
294 : " See code for details. Works only in conjunction with keyword PARALLEL_BUILD.", &
295 : usage="MORE_WORK <INT>", type_of_var=integer_t, &
296 1462 : default_i_val=0, repeats=.FALSE.)
297 1462 : CALL section_add_keyword(subsection, keyword)
298 1462 : CALL keyword_release(keyword)
299 :
300 : CALL keyword_create(keyword, __LOCATION__, name="VERY_OVERLOADED", &
301 : description="Control parameter for dynamic load balancing during a mixed CDFT calculation."// &
302 : " See code for details. Works only in conjunction with keyword PARALLEL_BUILD.", &
303 : usage="VERY_OVERLOADED <REAL>", type_of_var=real_t, &
304 1462 : default_r_val=0.0_dp, repeats=.FALSE.)
305 1462 : CALL section_add_keyword(subsection, keyword)
306 1462 : CALL keyword_release(keyword)
307 :
308 : CALL keyword_create(keyword, __LOCATION__, name="BLOCK_DIAGONALIZE", &
309 : description="Block diagonalize the CDFT Hamiltonian. Control settings should be given in "// &
310 : "section &BLOCK_DIAGONALIZE. All requested electronic couplings are printed out after "// &
311 : "block diagonalization. When CDFT-CI and block diagonalization are both requested, "// &
312 : "the CI calculation is performed using the block diagonalized Hamiltonian.", &
313 : usage="BLOCK_DIAGONALIZE", type_of_var=logical_t, &
314 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
315 1462 : CALL section_add_keyword(subsection, keyword)
316 1462 : CALL keyword_release(keyword)
317 :
318 1462 : NULLIFY (sub2section)
319 1462 : CALL create_mixed_cdft_block_section(sub2section)
320 1462 : CALL section_add_subsection(subsection, sub2section)
321 1462 : CALL section_release(sub2section)
322 :
323 1462 : CALL create_print_mixed_cdft_section(sub2section)
324 1462 : CALL section_add_subsection(subsection, sub2section)
325 1462 : CALL section_release(sub2section)
326 :
327 1462 : CALL section_add_subsection(section, subsection)
328 1462 : CALL section_release(subsection)
329 : !
330 : CALL section_create(subsection, __LOCATION__, name="COUPLING", &
331 : description="Coupling between two force_eval: E=(E1+E2 - sqrt((E1-E2)**2+4*H12**2))/2", &
332 1462 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
333 : CALL keyword_create(keyword, __LOCATION__, name="COUPLING_PARAMETER", &
334 : description="Coupling parameter H12 used in the coupling", &
335 1462 : usage="COUPLING_PARAMETER <REAL>", type_of_var=real_t)
336 1462 : CALL section_add_keyword(subsection, keyword)
337 1462 : CALL keyword_release(keyword)
338 1462 : CALL section_add_subsection(section, subsection)
339 1462 : CALL section_release(subsection)
340 :
341 : CALL section_create(subsection, __LOCATION__, name="RESTRAINT", &
342 : description="Restraint between two force_eval: E = E1 + k*(E1-E2-t)**2", &
343 1462 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
344 : CALL keyword_create(keyword, __LOCATION__, name="RESTRAINT_TARGET", &
345 : description="Target value of the restraint (t) ", &
346 1462 : usage="RESTRAINT_TARGET <REAL>", type_of_var=real_t)
347 1462 : CALL section_add_keyword(subsection, keyword)
348 1462 : CALL keyword_release(keyword)
349 :
350 : CALL keyword_create(keyword, __LOCATION__, name="RESTRAINT_STRENGTH", &
351 : description="Strength of the restraint (k) in "// &
352 : "k*(E1-E2-t)**2", &
353 1462 : usage="RESTRAINT_STRENGTH <REAL>", type_of_var=real_t)
354 1462 : CALL section_add_keyword(subsection, keyword)
355 1462 : CALL keyword_release(keyword)
356 1462 : CALL section_add_subsection(section, subsection)
357 1462 : CALL section_release(subsection)
358 :
359 : ! Multiple force_eval
360 : CALL create_function_section(subsection, "GENERIC", "MIXING_FUNCTION", &
361 : description="User driven coupling between two or more force_eval. "// &
362 : "This is also required if a free energy calculation with the alchemical "// &
363 : "change method is requested with MOTION/FREE_ENERGY/ALCHEMICAL_CHANGE. "// &
364 : "To allow an efficient mapping the order of the energy variables "// &
365 : "will be considered identical to the order of the force_eval in "// &
366 1462 : "the MULTIPLE_FORCE_EVALS/FORCE_EVAL_ORDER list.", do_deriv=.TRUE.)
367 1462 : CALL section_add_subsection(section, subsection)
368 1462 : CALL section_release(subsection)
369 :
370 : ! Mapping of atoms
371 1462 : NULLIFY (sub2section, sub3section)
372 : CALL section_create(subsection, __LOCATION__, name="MAPPING", &
373 : description="Defines the mapping of atoms for the different force_eval with the mixed force_eval."// &
374 : " The default is to have a mapping 1-1 between atom index (i.e. all force_eval share the same"// &
375 : " geometrical structure). The mapping is based on defining fragments and the mapping the"// &
376 : " fragments between the several force_eval and the mixed force_eval", &
377 1462 : n_keywords=1, n_subsections=0, repeats=.TRUE.)
378 :
379 : ! Mixed force_eval
380 : CALL section_create(sub2section, __LOCATION__, name="FORCE_EVAL_MIXED", &
381 : description="Defines the fragments for the mixed force_eval (reference)", &
382 1462 : n_keywords=1, n_subsections=0, repeats=.TRUE.)
383 :
384 : CALL section_create(sub3section, __LOCATION__, name="FRAGMENT", &
385 : description="Fragment definition", &
386 1462 : n_keywords=1, n_subsections=0, repeats=.TRUE.)
387 :
388 : CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
389 : description="Defines the index of the fragment defined", &
390 1462 : usage="<INTEGER>", type_of_var=integer_t, n_var=1)
391 1462 : CALL section_add_keyword(sub3section, keyword)
392 1462 : CALL keyword_release(keyword)
393 :
394 : CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
395 : description="Starting and ending atomic index defining one fragment must be provided", &
396 1462 : usage="{Integer} {Integer}", type_of_var=integer_t, n_var=2, repeats=.TRUE.)
397 1462 : CALL section_add_keyword(sub3section, keyword)
398 1462 : CALL keyword_release(keyword)
399 :
400 1462 : CALL section_add_subsection(sub2section, sub3section)
401 1462 : CALL section_release(sub3section)
402 1462 : CALL section_add_subsection(subsection, sub2section)
403 1462 : CALL section_release(sub2section)
404 :
405 : ! All other force_eval
406 : CALL section_create(sub2section, __LOCATION__, name="FORCE_EVAL", &
407 : description="Defines the fragments and the mapping for each force_eval (an integer index (ID) "// &
408 : "needs to be provided as parameter)", &
409 1462 : n_keywords=1, n_subsections=0, repeats=.TRUE.)
410 :
411 : CALL keyword_create( &
412 : keyword, __LOCATION__, name="DEFINE_FRAGMENTS", &
413 : description="Specify the fragments definition of the force_eval through the fragments of the"// &
414 : " force_eval_mixed. This avoids the pedantic definition of the fragments for the force_eval,"// &
415 : " assuming the order of the fragments for the specified force_eval is the same as the sequence"// &
416 : " of integers provided. Easier to USE should be preferred to the specification of the single fragments.", &
417 1462 : usage="DEFINE_FRAGMENTS <INTEGER> .. <INTEGER>", type_of_var=integer_t, n_var=-1)
418 1462 : CALL section_add_keyword(sub2section, keyword)
419 1462 : CALL keyword_release(keyword)
420 :
421 : CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
422 : description="Defines the index of the force_eval for which fragments and mappings are provided", &
423 1462 : usage="<INTEGER>", type_of_var=integer_t, n_var=1)
424 1462 : CALL section_add_keyword(sub2section, keyword)
425 1462 : CALL keyword_release(keyword)
426 :
427 : CALL section_create(sub3section, __LOCATION__, name="FRAGMENT", &
428 : description="Fragment definition", &
429 1462 : n_keywords=1, n_subsections=0, repeats=.TRUE.)
430 :
431 : CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
432 : description="Defines the index of the fragment defined", &
433 1462 : usage="<INTEGER>", type_of_var=integer_t, n_var=1)
434 1462 : CALL section_add_keyword(sub3section, keyword)
435 1462 : CALL keyword_release(keyword)
436 :
437 : CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
438 : description="Starting and ending atomic index defining one fragment must be provided", &
439 1462 : usage="{Integer} {Integer}", type_of_var=integer_t, n_var=2, repeats=.FALSE.)
440 1462 : CALL section_add_keyword(sub3section, keyword)
441 1462 : CALL keyword_release(keyword)
442 :
443 : CALL keyword_create(keyword, __LOCATION__, name="MAP", &
444 : description="Provides the index of the fragment of the MIXED force_eval mapped on the"// &
445 : " locally defined fragment.", &
446 1462 : usage="MAP <INTEGER>", type_of_var=integer_t, n_var=1, repeats=.FALSE.)
447 1462 : CALL section_add_keyword(sub3section, keyword)
448 1462 : CALL keyword_release(keyword)
449 :
450 1462 : CALL section_add_subsection(sub2section, sub3section)
451 1462 : CALL section_release(sub3section)
452 1462 : CALL section_add_subsection(subsection, sub2section)
453 1462 : CALL section_release(sub2section)
454 :
455 1462 : CALL section_add_subsection(section, subsection)
456 1462 : CALL section_release(subsection)
457 :
458 1462 : CALL create_print_mix_section(subsection)
459 1462 : CALL section_add_subsection(section, subsection)
460 1462 : CALL section_release(subsection)
461 1462 : END SUBROUTINE create_mix_section
462 :
463 : ! **************************************************************************************************
464 : !> \brief Create the print section for mixed
465 : !> \param section the section to create
466 : !> \author teo
467 : ! **************************************************************************************************
468 1462 : SUBROUTINE create_print_mix_section(section)
469 : TYPE(section_type), POINTER :: section
470 :
471 : TYPE(section_type), POINTER :: print_key
472 :
473 1462 : CPASSERT(.NOT. ASSOCIATED(section))
474 : CALL section_create(section, __LOCATION__, name="print", &
475 : description="Section of possible print options in MIXED env.", &
476 1462 : n_keywords=0, n_subsections=1, repeats=.FALSE.)
477 :
478 1462 : NULLIFY (print_key)
479 :
480 : CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
481 : description="Controls the printing of information during the evaluation of "// &
482 : "the mixed environment. ", &
483 1462 : print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
484 1462 : CALL section_add_subsection(section, print_key)
485 1462 : CALL section_release(print_key)
486 :
487 : CALL cp_print_key_section_create(print_key, __LOCATION__, "DIPOLE", &
488 : description="Controls the printing of dipole information. "// &
489 : "Requires the DIPOLE calculation be active for all subforce_eval.", &
490 1462 : print_level=medium_print_level, filename="__STD_OUT__")
491 1462 : CALL section_add_subsection(section, print_key)
492 1462 : CALL section_release(print_key)
493 1462 : END SUBROUTINE create_print_mix_section
494 :
495 : ! **************************************************************************************************
496 : !> \brief Create the print section specific to mixed CDFT (forked from print_mix_section)
497 : !> \param section the section to create
498 : !> \author Nico Holmberg [06.2017]
499 : ! **************************************************************************************************
500 1462 : SUBROUTINE create_print_mixed_cdft_section(section)
501 : TYPE(section_type), POINTER :: section
502 :
503 : TYPE(keyword_type), POINTER :: keyword
504 : TYPE(section_type), POINTER :: print_key
505 :
506 1462 : CPASSERT(.NOT. ASSOCIATED(section))
507 : CALL section_create(section, __LOCATION__, name="print", &
508 : description="Section of possible print options for the mixed CDFT environment.", &
509 1462 : n_keywords=0, n_subsections=1, repeats=.FALSE.)
510 :
511 1462 : NULLIFY (print_key, keyword)
512 :
513 : CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
514 : description="Controls the printing of information during the evaluation of "// &
515 : "the mixed CDFT environment. ", &
516 1462 : print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
517 :
518 : CALL keyword_create(keyword, __LOCATION__, name="MO_OVERLAP_MATRIX", &
519 : description="Controls the printing of the MO overlap matrices between CDFT states. "// &
520 : "The matrices are printed out in plain text.", &
521 : usage="MO_OVERLAP_MATRIX TRUE", type_of_var=logical_t, &
522 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
523 1462 : CALL section_add_keyword(print_key, keyword)
524 1462 : CALL keyword_release(keyword)
525 :
526 : CALL keyword_create(keyword, __LOCATION__, name="MO_OVERLAP_EIGENVALUES", &
527 : description="Controls the printing of the eigenvalues/singular values of the CDFT MO overlap "// &
528 : "matrices. The product of the eigenvalues/singular values is the CDFT MO overlap. "// &
529 : "Useful mainly for checking which singular values will get screened for a particular EPS_SVD.", &
530 : usage="MO_OVERLAP_EIGENVALUES TRUE", type_of_var=logical_t, &
531 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
532 1462 : CALL section_add_keyword(print_key, keyword)
533 1462 : CALL keyword_release(keyword)
534 :
535 1462 : CALL section_add_subsection(section, print_key)
536 1462 : CALL section_release(print_key)
537 :
538 1462 : END SUBROUTINE create_print_mixed_cdft_section
539 : ! **************************************************************************************************
540 : !> \brief Creates the control section used to setup block diagonalization of the mixed
541 : !> CDFT Hamiltonian matrix
542 : !> \param section the section to create
543 : !> \author Nico Holmberg [11.2017]
544 : ! **************************************************************************************************
545 1462 : SUBROUTINE create_mixed_cdft_block_section(section)
546 : TYPE(section_type), POINTER :: section
547 :
548 : TYPE(keyword_type), POINTER :: keyword
549 :
550 1462 : CPASSERT(.NOT. ASSOCIATED(section))
551 : CALL section_create(section, __LOCATION__, name="BLOCK_DIAGONALIZE", &
552 : description="Control section to setup block diagonalization of the mixed CDFT Hamiltonian. "// &
553 : "Constructs a new Hamiltonian by diagonalizing the initial matrix within each block and "// &
554 : "by rotating the off-diagonal blocks (which represent the interactions between different "// &
555 : "blocks) by the eigenvectors of diagonal blocks.", &
556 1462 : n_keywords=2, n_subsections=0, repeats=.FALSE.)
557 :
558 1462 : NULLIFY (keyword)
559 : CALL keyword_create(keyword, __LOCATION__, name="BLOCK", &
560 : description="Defines which CDFT states are included in a block. Each repetition of this keyword "// &
561 : "defines a new block. The Hamiltonian matrix elements of the requested states are collected "// &
562 : "into a new matrix and subsequently diagonalized. The eigenvectors of this matrix are used to "// &
563 : "rotate the matrix blocks describing the interactions between blocks.", &
564 : usage="BLOCK 1 2", repeats=.TRUE., &
565 1462 : type_of_var=integer_t, n_var=-1)
566 1462 : CALL section_add_keyword(section, keyword)
567 1462 : CALL keyword_release(keyword)
568 :
569 : CALL keyword_create(keyword, __LOCATION__, name="IGNORE_EXCITED", &
570 : description="Ignore excited states related to each block when constructing the new mixed "// &
571 : "CDFT Hamiltonian. This reduces the dimensionality of the Hamiltonian.", &
572 : usage="IGNORE_EXCITED FALSE", type_of_var=logical_t, &
573 1462 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
574 1462 : CALL section_add_keyword(section, keyword)
575 1462 : CALL keyword_release(keyword)
576 :
577 : CALL keyword_create(keyword, __LOCATION__, name="RECURSIVE_DIAGONALIZATION", &
578 : description="Perform block diagonalization recursively until only two blocks remain. "// &
579 : "For example, if the elements of a 8x8 matrix are first collected into 4 blocks "// &
580 : "(using keyword BLOCK), this keyword will transform the matrix to a 2x2 matrix "// &
581 : "(8x8 -> 4x4 -> 2x2). In this example, the blocks of the 2x2 matrix would be "// &
582 : "assembled from the first and last 2 blocks of the 4x4 matrix.", &
583 : usage="RECURSIVE_DIAGONALIZATION TRUE", type_of_var=logical_t, &
584 1462 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
585 1462 : CALL section_add_keyword(section, keyword)
586 1462 : CALL keyword_release(keyword)
587 :
588 1462 : END SUBROUTINE create_mixed_cdft_block_section
589 :
590 : END MODULE input_cp2k_mixed
|