44 #include "./base/base_uses.f90"
49 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
50 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_mixed'
62 TYPE(section_type),
POINTER :: section
64 TYPE(keyword_type),
POINTER :: keyword
65 TYPE(section_type),
POINTER :: sub2section, sub3section, subsection
67 cpassert(.NOT.
ASSOCIATED(section))
69 description=
"This section contains all information to run with a hamiltonian "// &
70 "defined by a mixing of force_evals", &
71 n_keywords=1, n_subsections=0, repeats=.false.)
72 NULLIFY (keyword, subsection)
75 keyword, __location__, name=
"MIXING_TYPE", &
76 description=
"The type of mixing to be employed", &
77 usage=
"MIXING_TYPE LINEAR_COMBINATION", &
79 enum_c_vals=s2a(
"LINEAR_COMBINATION", &
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)."), &
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 usage=
"group_partition 2 2 4 2 4 ", type_of_var=
integer_t, n_var=-1)
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 usage=
"ngroups 4", type_of_var=
integer_t)
117 description=
"Linear combination between two force_eval: F= lambda F1 + (1-lambda) F2", &
118 n_keywords=1, n_subsections=0, repeats=.false.)
121 description=
"Specify the mixing parameter lambda in the formula.", &
122 usage=
"lambda <REAL>", type_of_var=
real_t)
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.", &
142 description=
"Specify the mixing parameter lambda in the formula.", &
143 usage=
"lambda <REAL>", type_of_var=
real_t)
148 description=
"Defines the CDFT states used to translate the system. ", &
149 usage=
"FORCE_STATES 1 1", n_var=2, &
150 default_i_vals=(/1, 2/), type_of_var=
integer_t)
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>", &
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 default_l_val=.false., lone_keyword_l_val=.true.)
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.", &
184 default_l_val=.false., lone_keyword_l_val=.true.)
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.", &
192 default_l_val=.false., lone_keyword_l_val=.true., &
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., &
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.", &
215 default_l_val=.false., lone_keyword_l_val=.true.)
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.", &
226 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_l_val=.true., lone_keyword_l_val=.true.)
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>", &
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 default_r_val=0.0_dp, repeats=.false.)
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 default_r_val=1.0e-6_dp, repeats=.false.)
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 default_r_val=2.0_dp)
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 default_i_val=0, repeats=.false.)
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 default_r_val=0.0_dp, repeats=.false.)
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 default_l_val=.false., lone_keyword_l_val=.true.)
318 NULLIFY (sub2section)
319 CALL create_mixed_cdft_block_section(sub2section)
323 CALL create_print_mixed_cdft_section(sub2section)
331 description=
"Coupling between two force_eval: E=(E1+E2 - sqrt((E1-E2)**2+4*H12**2))/2", &
332 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 usage=
"COUPLING_PARAMETER <REAL>", type_of_var=
real_t)
342 description=
"Restraint between two force_eval: E = E1 + k*(E1-E2-t)**2", &
343 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 usage=
"RESTRAINT_TARGET <REAL>", type_of_var=
real_t)
350 CALL keyword_create(keyword, __location__, name=
"RESTRAINT_STRENGTH", &
351 description=
"Strength of the restraint (k) in "// &
353 usage=
"RESTRAINT_STRENGTH <REAL>", type_of_var=
real_t)
361 description=
"User driven coupling between two or more force_eval.", &
362 n_keywords=1, n_subsections=0, repeats=.false.)
363 CALL keyword_create(keyword, __location__, name=
"MIXING_FUNCTION", &
364 description=
"Specifies the mixing functional form in mathematical notation.", &
365 usage=
"MIXING_FUNCTION (E1+E2-LOG(E1/E2))", type_of_var=
lchar_t, &
371 description=
"Defines the variables of the functional form. To allow an efficient"// &
372 " mapping the order of the energy variables will be considered identical to the"// &
373 " order of the force_eval in the force_eval_order list.", &
374 usage=
"VARIABLES x", type_of_var=
char_t, &
380 description=
"Defines the parameters of the functional form", &
381 usage=
"PARAMETERS a b D", type_of_var=
char_t, &
382 n_var=-1, repeats=.true.)
387 description=
"Defines the values of parameter of the functional form", &
388 usage=
"VALUES ", type_of_var=
real_t, &
389 n_var=-1, repeats=.true., unit_str=
"internal_cp2k")
394 description=
"Optionally, allows to define valid CP2K unit strings for each parameter value. "// &
395 "It is assumed that the corresponding parameter value is specified in this unit.", &
396 usage=
"UNITS angstrom eV*angstrom^-1 angstrom^1 K", type_of_var=
char_t, &
397 n_var=-1, repeats=.true.)
402 description=
"Parameter used for computing the derivative with the Ridders' method.", &
403 usage=
"DX <REAL>", default_r_val=0.1_dp, unit_str=
"bohr")
408 description=
"Checks that the error in computing the derivative is not larger than "// &
409 "the value set; in case error is larger a warning message is printed.", &
410 usage=
"ERROR_LIMIT <REAL>", default_r_val=1.0e-12_dp)
417 NULLIFY (sub2section, sub3section)
419 description=
"Defines the mapping of atoms for the different force_eval with the mixed force_eval."// &
420 " The default is to have a mapping 1-1 between atom index (i.e. all force_eval share the same"// &
421 " geometrical structure). The mapping is based on defining fragments and the mapping the"// &
422 " fragments between the several force_eval and the mixed force_eval", &
423 n_keywords=1, n_subsections=0, repeats=.true.)
426 CALL section_create(sub2section, __location__, name=
"FORCE_EVAL_MIXED", &
427 description=
"Defines the fragments for the mixed force_eval (reference)", &
428 n_keywords=1, n_subsections=0, repeats=.true.)
431 description=
"Fragment definition", &
432 n_keywords=1, n_subsections=0, repeats=.true.)
434 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
435 description=
"Defines the index of the fragment defined", &
436 usage=
"<INTEGER>", type_of_var=
integer_t, n_var=1)
440 CALL keyword_create(keyword, __location__, name=
"_DEFAULT_KEYWORD_", &
441 description=
"Starting and ending atomic index defining one fragment must be provided", &
442 usage=
"{Integer} {Integer}", type_of_var=
integer_t, n_var=2, repeats=.true.)
452 CALL section_create(sub2section, __location__, name=
"FORCE_EVAL", &
453 description=
"Defines the fragments and the mapping for each force_eval (an integer index (ID) "// &
454 "needs to be provided as parameter)", &
455 n_keywords=1, n_subsections=0, repeats=.true.)
458 keyword, __location__, name=
"DEFINE_FRAGMENTS", &
459 description=
"Specify the fragments definition of the force_eval through the fragments of the"// &
460 " force_eval_mixed. This avoids the pedantic definition of the fragments for the force_eval,"// &
461 " assuming the order of the fragments for the specified force_eval is the same as the sequence"// &
462 " of integers provided. Easier to USE should be preferred to the specification of the single fragments.", &
463 usage=
"DEFINE_FRAGMENTS <INTEGER> .. <INTEGER>", type_of_var=
integer_t, n_var=-1)
467 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
468 description=
"Defines the index of the force_eval for which fragments and mappings are provided", &
469 usage=
"<INTEGER>", type_of_var=
integer_t, n_var=1)
474 description=
"Fragment definition", &
475 n_keywords=1, n_subsections=0, repeats=.true.)
477 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
478 description=
"Defines the index of the fragment defined", &
479 usage=
"<INTEGER>", type_of_var=
integer_t, n_var=1)
483 CALL keyword_create(keyword, __location__, name=
"_DEFAULT_KEYWORD_", &
484 description=
"Starting and ending atomic index defining one fragment must be provided", &
485 usage=
"{Integer} {Integer}", type_of_var=
integer_t, n_var=2, repeats=.false.)
490 description=
"Provides the index of the fragment of the MIXED force_eval mapped on the"// &
491 " locally defined fragment.", &
492 usage=
"MAP <INTEGER>", type_of_var=
integer_t, n_var=1, repeats=.false.)
504 CALL create_print_mix_section(subsection)
514 SUBROUTINE create_print_mix_section(section)
515 TYPE(section_type),
POINTER :: section
517 TYPE(section_type),
POINTER :: print_key
519 cpassert(.NOT.
ASSOCIATED(section))
521 description=
"Section of possible print options in MIXED env.", &
522 n_keywords=0, n_subsections=1, repeats=.false.)
527 description=
"Controls the printing of information during the evaluation of "// &
528 "the mixed environment. ", &
534 description=
"Controls the printing of dipole information. "// &
535 "Requires the DIPOLE calculation be active for all subforce_eval.", &
539 END SUBROUTINE create_print_mix_section
546 SUBROUTINE create_print_mixed_cdft_section(section)
547 TYPE(section_type),
POINTER :: section
549 TYPE(keyword_type),
POINTER :: keyword
550 TYPE(section_type),
POINTER :: print_key
552 cpassert(.NOT.
ASSOCIATED(section))
554 description=
"Section of possible print options for the mixed CDFT environment.", &
555 n_keywords=0, n_subsections=1, repeats=.false.)
557 NULLIFY (print_key, keyword)
560 description=
"Controls the printing of information during the evaluation of "// &
561 "the mixed CDFT environment. ", &
564 CALL keyword_create(keyword, __location__, name=
"MO_OVERLAP_MATRIX", &
565 description=
"Controls the printing of the MO overlap matrices between CDFT states. "// &
566 "The matrices are printed out in plain text.", &
567 usage=
"MO_OVERLAP_MATRIX TRUE", type_of_var=
logical_t, &
568 default_l_val=.false., lone_keyword_l_val=.true.)
572 CALL keyword_create(keyword, __location__, name=
"MO_OVERLAP_EIGENVALUES", &
573 description=
"Controls the printing of the eigenvalues/singular values of the CDFT MO overlap "// &
574 "matrices. The product of the eigenvalues/singular values is the CDFT MO overlap. "// &
575 "Useful mainly for checking which singular values will get screened for a particular EPS_SVD.", &
576 usage=
"MO_OVERLAP_EIGENVALUES TRUE", type_of_var=
logical_t, &
577 default_l_val=.false., lone_keyword_l_val=.true.)
584 END SUBROUTINE create_print_mixed_cdft_section
591 SUBROUTINE create_mixed_cdft_block_section(section)
592 TYPE(section_type),
POINTER :: section
594 TYPE(keyword_type),
POINTER :: keyword
596 cpassert(.NOT.
ASSOCIATED(section))
597 CALL section_create(section, __location__, name=
"BLOCK_DIAGONALIZE", &
598 description=
"Control section to setup block diagonalization of the mixed CDFT Hamiltonian. "// &
599 "Constructs a new Hamiltonian by diagonalizing the initial matrix within each block and "// &
600 "by rotating the off-diagonal blocks (which represent the interactions between different "// &
601 "blocks) by the eigenvectors of diagonal blocks.", &
602 n_keywords=2, n_subsections=0, repeats=.false.)
606 description=
"Defines which CDFT states are included in a block. Each repetition of this keyword "// &
607 "defines a new block. The Hamiltonian matrix elements of the requested states are collected "// &
608 "into a new matrix and subsequently diagonalized. The eigenvectors of this matrix are used to "// &
609 "rotate the matrix blocks describing the interactions between blocks.", &
610 usage=
"BLOCK 1 2", repeats=.true., &
615 CALL keyword_create(keyword, __location__, name=
"IGNORE_EXCITED", &
616 description=
"Ignore excited states related to each block when constructing the new mixed "// &
617 "CDFT Hamiltonian. This reduces the dimensionality of the Hamiltonian.", &
618 usage=
"IGNORE_EXCITED FALSE", type_of_var=
logical_t, &
619 default_l_val=.true., lone_keyword_l_val=.true.)
623 CALL keyword_create(keyword, __location__, name=
"RECURSIVE_DIAGONALIZATION", &
624 description=
"Perform block diagonalization recursively until only two blocks remain. "// &
625 "For example, if the elements of a 8x8 matrix are first collected into 4 blocks "// &
626 "(using keyword BLOCK), this keyword will transform the matrix to a 2x2 matrix "// &
627 "(8x8 -> 4x4 -> 2x2). In this example, the blocks of the 2x2 matrix would be "// &
628 "assembled from the first and last 2 blocks of the 4x4 matrix.", &
629 usage=
"RECURSIVE_DIAGONALIZATION TRUE", type_of_var=
logical_t, &
630 default_l_val=.false., lone_keyword_l_val=.true.)
634 END SUBROUTINE create_mixed_cdft_block_section
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public holmberg2017
integer, save, public migliore2009
integer, save, public holmberg2018
integer, save, public mavros2015
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public low_print_level
integer, parameter, public medium_print_level
integer, parameter, public add_last_numeric
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
Defines the basic variable types.
integer, parameter, public dp
Utilities for string manipulations.