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 function that build the active space section of the input
10 : !> \par History
11 : !> 10.2005 moved out of input_cp2k [fawzi]
12 : !> 07.2024 moved out of input_cp2k_dft [JGH]
13 : !> \author fawzi
14 : ! **************************************************************************************************
15 : MODULE input_cp2k_as
16 : USE cp_output_handling, ONLY: cp_print_key_section_create,&
17 : debug_print_level,&
18 : high_print_level,&
19 : low_print_level,&
20 : medium_print_level,&
21 : silent_print_level
22 : USE input_constants, ONLY: &
23 : casci_canonical, dmft_model, eri_method_full_gpw, eri_method_gpw_ht, eri_operator_coulomb, &
24 : eri_operator_erf, eri_operator_erfc, eri_operator_gaussian, eri_operator_trunc, &
25 : eri_operator_yukawa, gaussian, hf_model, manual_selection, mao_projection, no_solver, &
26 : qiskit_solver, rsdft_model, wannier_projection
27 : USE input_cp2k_loc, ONLY: create_localize_section
28 : USE input_keyword_types, ONLY: keyword_create,&
29 : keyword_release,&
30 : keyword_type
31 : USE input_section_types, ONLY: section_add_keyword,&
32 : section_add_subsection,&
33 : section_create,&
34 : section_release,&
35 : section_type
36 : USE input_val_types, ONLY: char_t,&
37 : integer_t,&
38 : lchar_t,&
39 : logical_t,&
40 : real_t
41 : USE kinds, ONLY: dp
42 : USE string_utilities, ONLY: s2a
43 : #include "./base/base_uses.f90"
44 :
45 : IMPLICIT NONE
46 : PRIVATE
47 :
48 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_as'
49 :
50 : PUBLIC :: create_active_space_section
51 :
52 : CONTAINS
53 :
54 : ! **************************************************************************************************
55 : !> \brief Create CP2K input section for the calculation of an active space Hamiltonian
56 : !> \param section ...
57 : !> \par History:
58 : !> - Creation 06.04.2016
59 : !> \author JHU
60 : ! **************************************************************************************************
61 8444 : SUBROUTINE create_active_space_section(section)
62 :
63 : TYPE(section_type), POINTER :: section
64 :
65 : TYPE(keyword_type), POINTER :: keyword
66 : TYPE(section_type), POINTER :: print_key, subsection
67 :
68 8444 : CPASSERT(.NOT. ASSOCIATED(section))
69 :
70 : CALL section_create(section, __LOCATION__, name="ACTIVE_SPACE", &
71 : description="Define parameters and method to calculate an electronic active space", &
72 8444 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
73 :
74 8444 : NULLIFY (keyword, subsection, print_key)
75 :
76 : CALL keyword_create(keyword, __LOCATION__, &
77 : name="_SECTION_PARAMETERS_", &
78 : description="Controls the activation of the ACTIVE_SPACE section", &
79 : usage="&ACTIVE_SPACE ON", &
80 : default_l_val=.FALSE., &
81 8444 : lone_keyword_l_val=.TRUE.)
82 8444 : CALL section_add_keyword(section, keyword)
83 8444 : CALL keyword_release(keyword)
84 :
85 : CALL keyword_create(keyword, __LOCATION__, name="MODEL", &
86 : description="Model used to calculate active space interaction Hamiltonian.", &
87 : usage="MODEL HARTREE-FOCK", &
88 : default_i_val=hf_model, &
89 : enum_c_vals=s2a("HARTREE-FOCK", "RSDFT", "DMFT"), &
90 : enum_i_vals=(/hf_model, rsdft_model, dmft_model/), &
91 : enum_desc=s2a("Hartree-Fock model for interaction Hamiltonian", &
92 : "Range-separated DFT model for interaction Hamiltonian", &
93 8444 : "DMFT model Hamiltonian"))
94 8444 : CALL section_add_keyword(section, keyword)
95 8444 : CALL keyword_release(keyword)
96 :
97 : CALL keyword_create(keyword, __LOCATION__, name="ACTIVE_ELECTRONS", &
98 : description="The number of active electrons in the CAS space", &
99 8444 : usage="ACTIVE_ELECTRONS 4", n_var=1, default_i_val=-1, type_of_var=integer_t)
100 8444 : CALL section_add_keyword(section, keyword)
101 8444 : CALL keyword_release(keyword)
102 :
103 : CALL keyword_create(keyword, __LOCATION__, name="ACTIVE_ORBITALS", &
104 : description="The number of active orbitals defining the CAS space.", &
105 8444 : usage="ACTIVE_ORBITALS 2", n_var=1, default_i_val=-1, type_of_var=integer_t)
106 8444 : CALL section_add_keyword(section, keyword)
107 8444 : CALL keyword_release(keyword)
108 :
109 : CALL keyword_create(keyword, __LOCATION__, name="ACTIVE_ORBITAL_INDICES", &
110 : description="The indices of the active orbitals. Requires ORBITAL_SELECTION MANUAL!", &
111 : usage="ACTIVE_ORBITAL_INDICES 2 3 {...}", n_var=-1, default_i_vals=(/-1/), &
112 8444 : type_of_var=integer_t)
113 8444 : CALL section_add_keyword(section, keyword)
114 8444 : CALL keyword_release(keyword)
115 :
116 : CALL keyword_create(keyword, __LOCATION__, name="ISOLATED_SYSTEM", &
117 : description="System is treated without any periodic boundary conditions.", &
118 8444 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
119 8444 : CALL section_add_keyword(section, keyword)
120 8444 : CALL keyword_release(keyword)
121 :
122 : CALL cp_print_key_section_create(print_key, __LOCATION__, "FCIDUMP", &
123 : description="Controls the writing of a file in FCIDUMP format.", &
124 8444 : print_level=high_print_level, filename="")
125 8444 : CALL section_add_subsection(section, print_key)
126 8444 : CALL section_release(print_key)
127 :
128 : CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_SELECTION", &
129 : description="Method used to select active space orbitals.", &
130 : usage="ORBITAL_SELECTION CANONICAL", &
131 : default_i_val=casci_canonical, &
132 : enum_c_vals=s2a("CANONICAL", "WANNIER_PROJECTION", "MAO", "MANUAL"), &
133 : enum_i_vals=(/casci_canonical, wannier_projection, mao_projection, manual_selection/), &
134 : enum_desc=s2a("Select orbitals using energy ordering of canoncial orbitals", &
135 : "Select orbitals from projected Wannier functions", &
136 : "Select orbitals from modified atomic orbitals", &
137 8444 : "Select orbitals manually via ACTIVE_ORBITAL_INDICES"))
138 :
139 8444 : CALL section_add_keyword(section, keyword)
140 8444 : CALL keyword_release(keyword)
141 :
142 : CALL keyword_create(keyword, __LOCATION__, name="SUBSPACE_ATOM", &
143 : description="Number of atom that defines the subspace to be projected on.", &
144 : usage="SUBSPACE_ATOM x", default_i_val=-1, &
145 8444 : type_of_var=integer_t)
146 8444 : CALL section_add_keyword(section, keyword)
147 8444 : CALL keyword_release(keyword)
148 :
149 : CALL keyword_create(keyword, __LOCATION__, name="SUBSPACE_SHELL", &
150 : description="Shell definition for subsapce.", &
151 : usage="SUBSPACE_SHELL 3d4s", default_c_val="X", &
152 8444 : type_of_var=char_t)
153 8444 : CALL section_add_keyword(section, keyword)
154 8444 : CALL keyword_release(keyword)
155 :
156 : CALL keyword_create(keyword, __LOCATION__, name="SCF_EMBEDDING", &
157 : description="Whether to turn on the self-consistent embedding scheme", &
158 8444 : default_l_val=.FALSE., lone_keyword_l_val=.FALSE.)
159 8444 : CALL section_add_keyword(section, keyword)
160 8444 : CALL keyword_release(keyword)
161 :
162 : CALL keyword_create(keyword, __LOCATION__, name="QCSCHEMA", &
163 : description="Name of the QCSchema file, may include a path", &
164 : usage="QCSCHEMA <FILENAME>", &
165 : type_of_var=lchar_t, repeats=.FALSE., &
166 8444 : default_lc_val="")
167 8444 : CALL section_add_keyword(section, keyword)
168 8444 : CALL keyword_release(keyword)
169 :
170 : CALL keyword_create(keyword, __LOCATION__, name="AS_SOLVER", &
171 : description="The external active space solver for the embedding approach", &
172 : usage="AS_SOLVER QISKIT", &
173 : default_i_val=no_solver, &
174 : enum_c_vals=s2a("NONE", "QISKIT"), &
175 : enum_i_vals=(/no_solver, qiskit_solver/), &
176 : enum_desc=s2a("NO solver, used to produce FCIDUMP/QCSchema files", &
177 8444 : "QISKIT active space solver"))
178 8444 : CALL section_add_keyword(section, keyword)
179 8444 : CALL keyword_release(keyword)
180 :
181 : CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
182 : description="Energy convergence threshold of the DFT embedding scheme.", &
183 : usage="EPS_ITER 1.0E-6 ", type_of_var=real_t, &
184 8444 : default_r_val=1.0E-6_dp)
185 8444 : CALL section_add_keyword(section, keyword)
186 8444 : CALL keyword_release(keyword)
187 :
188 : CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
189 : description="Max number of iterations for the DFT embedding scheme.", &
190 : usage="MAX_ITER 50", type_of_var=integer_t, &
191 8444 : default_i_val=50)
192 8444 : CALL section_add_keyword(section, keyword)
193 8444 : CALL keyword_release(keyword)
194 :
195 8444 : CALL create_print_orb_section(subsection)
196 8444 : CALL section_add_subsection(section, subsection)
197 8444 : CALL section_release(subsection)
198 :
199 8444 : CALL create_eri_section(subsection)
200 8444 : CALL section_add_subsection(section, subsection)
201 8444 : CALL section_release(subsection)
202 :
203 8444 : CALL create_eri_gpw(subsection)
204 8444 : CALL section_add_subsection(section, subsection)
205 8444 : CALL section_release(subsection)
206 :
207 8444 : CALL create_localize_section(subsection)
208 8444 : CALL section_add_subsection(section, subsection)
209 8444 : CALL section_release(subsection)
210 :
211 8444 : CALL create_socket_section(subsection)
212 8444 : CALL section_add_subsection(section, subsection)
213 8444 : CALL section_release(subsection)
214 :
215 8444 : END SUBROUTINE create_active_space_section
216 :
217 : ! **************************************************************************************************
218 : !> \brief ...
219 : !> \param section ...
220 : ! **************************************************************************************************
221 8444 : SUBROUTINE create_socket_section(section)
222 : TYPE(section_type), POINTER :: section
223 :
224 : TYPE(keyword_type), POINTER :: keyword
225 :
226 8444 : CPASSERT(.NOT. ASSOCIATED(section))
227 : CALL section_create(section, __LOCATION__, name="SOCKET", &
228 : description="Parameters to set up the socket communicating to the external active space solver.", &
229 8444 : n_keywords=3, n_subsections=0, repeats=.FALSE.)
230 :
231 8444 : NULLIFY (keyword)
232 : CALL keyword_create(keyword, __LOCATION__, name="INET", &
233 : description="Use an INET socket rather than a UNIX socket.", &
234 : usage="INET <LOGICAL>", &
235 8444 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
236 8444 : CALL section_add_keyword(section, keyword)
237 8444 : CALL keyword_release(keyword)
238 :
239 : CALL keyword_create(keyword, __LOCATION__, name="PORT", &
240 : description="Port number for the socket client.", &
241 : usage="port <INTEGER>", &
242 8444 : default_i_val=12345)
243 8444 : CALL section_add_keyword(section, keyword)
244 8444 : CALL keyword_release(keyword)
245 :
246 : CALL keyword_create(keyword, __LOCATION__, name="HOST", &
247 : description="Host name for the socket client.", &
248 : usage="host <HOSTNAME>", &
249 8444 : default_c_val="embedding_socket")
250 8444 : CALL section_add_keyword(section, keyword)
251 8444 : CALL keyword_release(keyword)
252 :
253 8444 : END SUBROUTINE create_socket_section
254 :
255 : ! **************************************************************************************************
256 : !> \brief ...
257 : !> \param section ...
258 : ! **************************************************************************************************
259 8444 : SUBROUTINE create_print_orb_section(section)
260 : TYPE(section_type), POINTER :: section
261 :
262 : TYPE(keyword_type), POINTER :: keyword
263 :
264 8444 : CPASSERT(.NOT. ASSOCIATED(section))
265 : CALL section_create(section, __LOCATION__, name="PRINT_ORBITAL_CUBES", &
266 : description="Controls printing of active orbital cube files.", &
267 8444 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
268 :
269 8444 : NULLIFY (keyword)
270 : CALL keyword_create(keyword, __LOCATION__, name="FILENAME", &
271 : description="Body of Filename for the cube files.", &
272 : usage="FILENAME {name}", default_c_val="ActiveOrbital", &
273 8444 : type_of_var=char_t)
274 8444 : CALL section_add_keyword(section, keyword)
275 8444 : CALL keyword_release(keyword)
276 :
277 : CALL keyword_create(keyword, __LOCATION__, name="ALIST", &
278 : description="List of alpha orbitals to be printed. -1 defaults to all values", &
279 : usage="ALIST {1 2 3 ...}", n_var=-1, default_i_vals=(/-1/), &
280 8444 : lone_keyword_i_val=-1, type_of_var=integer_t)
281 8444 : CALL section_add_keyword(section, keyword)
282 8444 : CALL keyword_release(keyword)
283 :
284 : CALL keyword_create(keyword, __LOCATION__, name="BLIST", &
285 : description="List of beta orbitals to be printed. -1 defaults to all values", &
286 : usage="ALIST {1 2 3 ...}", n_var=-1, default_i_vals=(/-1/), &
287 8444 : lone_keyword_i_val=-1, type_of_var=integer_t)
288 8444 : CALL section_add_keyword(section, keyword)
289 8444 : CALL keyword_release(keyword)
290 :
291 : CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
292 : description="The stride (X,Y,Z) used to write the cube file"// &
293 : " (larger values result in smaller cube files)."// &
294 : " You can provide 3 numbers (for X,Y,Z) or 1 number valid for all components", &
295 : usage="STRIDE {2 2 2}", n_var=-1, default_i_vals=(/2, 2, 2/), &
296 8444 : type_of_var=integer_t)
297 8444 : CALL section_add_keyword(section, keyword)
298 8444 : CALL keyword_release(keyword)
299 :
300 : CALL keyword_create(keyword, __LOCATION__, name="STOP_AFTER_CUBES", &
301 : description="Whether to stop the computation after printing the cubes.", &
302 8444 : default_l_val=.FALSE., lone_keyword_l_val=.FALSE.)
303 8444 : CALL section_add_keyword(section, keyword)
304 8444 : CALL keyword_release(keyword)
305 :
306 8444 : END SUBROUTINE create_print_orb_section
307 :
308 : ! **************************************************************************************************
309 : !> \brief ...
310 : !> \param section ...
311 : ! **************************************************************************************************
312 8444 : SUBROUTINE create_eri_section(section)
313 : TYPE(section_type), POINTER :: section
314 :
315 : TYPE(keyword_type), POINTER :: keyword
316 :
317 8444 : CPASSERT(.NOT. ASSOCIATED(section))
318 : CALL section_create(section, __LOCATION__, name="ERI", &
319 : description="Parameters for the electron repulsion integrals.", &
320 8444 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
321 :
322 8444 : NULLIFY (keyword)
323 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
324 : description="Method used in ERI calculation.", &
325 : usage="METHOD FULL_GPW", &
326 : enum_c_vals=s2a("FULL_GPW", "GPW_HALF_TRANSFORM"), &
327 : enum_i_vals=(/eri_method_full_gpw, eri_method_gpw_ht/), &
328 : enum_desc=s2a("Use the GPW approach with MOs", &
329 : "Use the GPW approach for half-transformed MO ERIs"), &
330 8444 : default_i_val=eri_method_full_gpw)
331 8444 : CALL section_add_keyword(section, keyword)
332 8444 : CALL keyword_release(keyword)
333 :
334 : CALL keyword_create(keyword, __LOCATION__, name="OPERATOR", &
335 : description="Operator used in ERI calculation.", &
336 : usage="OPERATOR <1/R>", &
337 : enum_c_vals=s2a("<1/R>", "<EXP(-A*R)/R>", "<ERF(A*R)/R>", &
338 : "<ERFC(A*R)/R>", "<EXP(-A*R2)/R>", "<H(A-R)/R>"), &
339 : enum_i_vals=(/eri_operator_coulomb, eri_operator_yukawa, &
340 : eri_operator_erf, eri_operator_erfc, eri_operator_gaussian, eri_operator_trunc/), &
341 : enum_desc=s2a("Coulomb operator", &
342 : "Yukawa potential operator", &
343 : "Error function potential operator", &
344 : "Complementary error function potential operator", &
345 : "Gaussian potential operator", &
346 : "Truncated Coulomb potential"), &
347 8444 : default_i_val=eri_operator_coulomb)
348 8444 : CALL section_add_keyword(section, keyword)
349 8444 : CALL keyword_release(keyword)
350 :
351 : CALL keyword_create(keyword, __LOCATION__, name="OPERATOR_PARAMETER", &
352 : description="Range parameter for ERI operator.", &
353 : usage="OPERATOR_PARAMETER 4.0", type_of_var=real_t, &
354 8444 : default_r_val=0.5_dp)
355 8444 : CALL section_add_keyword(section, keyword)
356 8444 : CALL keyword_release(keyword)
357 :
358 : CALL keyword_create(keyword, __LOCATION__, name="PERIODICITY", &
359 : description="Periodicity used for operators in ERI calclulation.", &
360 : usage="PERIODICITY {1 1 1}", n_var=-1, default_i_vals=(/1, 1, 1/), &
361 8444 : type_of_var=integer_t)
362 8444 : CALL section_add_keyword(section, keyword)
363 8444 : CALL keyword_release(keyword)
364 :
365 : CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
366 : description="Radius of operator interactions in non-periodic cases.", &
367 : usage="CUTOFF_RADIUS 20", type_of_var=real_t, &
368 8444 : default_r_val=-1.0_dp)
369 8444 : CALL section_add_keyword(section, keyword)
370 8444 : CALL keyword_release(keyword)
371 :
372 : CALL keyword_create( &
373 : keyword, __LOCATION__, name="EPS_INTEGRAL", &
374 : description="Accuracy of ERIs that will be stored.", &
375 : usage="EPS_INTEGRAL 1.0E-10 ", type_of_var=real_t, &
376 8444 : default_r_val=1.0E-12_dp)
377 8444 : CALL section_add_keyword(section, keyword)
378 8444 : CALL keyword_release(keyword)
379 :
380 8444 : END SUBROUTINE create_eri_section
381 :
382 : ! **************************************************************************************************
383 : !> \brief ...
384 : !> \param section ...
385 : ! **************************************************************************************************
386 8444 : SUBROUTINE create_eri_gpw(section)
387 : TYPE(section_type), POINTER :: section
388 :
389 : TYPE(keyword_type), POINTER :: keyword
390 :
391 8444 : CPASSERT(.NOT. ASSOCIATED(section))
392 : CALL section_create(section, __LOCATION__, name="ERI_GPW", &
393 : description="Parameters for the GPW approach to electron repulsion integrals.", &
394 8444 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
395 :
396 8444 : NULLIFY (keyword)
397 : CALL keyword_create(keyword, __LOCATION__, name="EPS_GRID", &
398 : description="Determines a threshold for the GPW based integration", &
399 : usage="EPS_GRID 1.0E-9 ", type_of_var=real_t, &
400 8444 : default_r_val=1.0E-8_dp)
401 8444 : CALL section_add_keyword(section, keyword)
402 8444 : CALL keyword_release(keyword)
403 :
404 : CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
405 : description="Determines a threshold for the sparse matrix multiplications if METHOD "// &
406 : "GPW_HALF_TRANSFORM is used", &
407 : usage="EPS_FILTER 1.0E-9 ", type_of_var=real_t, &
408 8444 : default_r_val=1.0E-9_dp)
409 8444 : CALL section_add_keyword(section, keyword)
410 8444 : CALL keyword_release(keyword)
411 :
412 : CALL keyword_create(keyword, __LOCATION__, name="CUTOFF", &
413 : description="The cutoff of the finest grid level in the GPW integration.", &
414 : usage="CUTOFF 300", type_of_var=real_t, &
415 8444 : default_r_val=300.0_dp)
416 8444 : CALL section_add_keyword(section, keyword)
417 8444 : CALL keyword_release(keyword)
418 :
419 : CALL keyword_create(keyword, __LOCATION__, name="REL_CUTOFF", &
420 : variants=(/"RELATIVE_CUTOFF"/), &
421 : description="Determines the grid at which a Gaussian is mapped.", &
422 : usage="REL_CUTOFF 50", type_of_var=real_t, &
423 16888 : default_r_val=50.0_dp)
424 8444 : CALL section_add_keyword(section, keyword)
425 8444 : CALL keyword_release(keyword)
426 :
427 : CALL keyword_create(keyword, __LOCATION__, name="STORE_WFN", &
428 : variants=(/"STORE_WAVEFUNCTION"/), &
429 : description="Store wavefunction in real space representation for integration.", &
430 : usage="STORE_WFN T", type_of_var=logical_t, &
431 16888 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
432 8444 : CALL section_add_keyword(section, keyword)
433 8444 : CALL keyword_release(keyword)
434 :
435 : CALL keyword_create(keyword, __LOCATION__, name="GROUP_SIZE", &
436 : description="Sets the size of a subgroup for ERI calculation, "// &
437 : "each of which with a full set of work grids, arrays or orbitals "// &
438 : "depending on the method of grids (work grids, arrays, orbitals). "// &
439 : "Small numbers reduce communication but increase the memory demands. "// &
440 : "A negative number indicates all processes (default).", &
441 : usage="GROUP_SIZE 2", type_of_var=integer_t, &
442 8444 : default_i_val=-1)
443 8444 : CALL section_add_keyword(section, keyword)
444 8444 : CALL keyword_release(keyword)
445 :
446 : CALL keyword_create(keyword, __LOCATION__, name="PRINT_LEVEL", &
447 : variants=(/"IOLEVEL"/), &
448 : description="How much output is written by the individual groups.", &
449 : usage="PRINT_LEVEL HIGH", &
450 : default_i_val=silent_print_level, enum_c_vals= &
451 : s2a("SILENT", "LOW", "MEDIUM", "HIGH", "DEBUG"), &
452 : enum_desc=s2a("Almost no output", &
453 : "Little output", "Quite some output", "Lots of output", &
454 : "Everything is written out, useful for debugging purposes only"), &
455 : enum_i_vals=(/silent_print_level, low_print_level, medium_print_level, &
456 16888 : high_print_level, debug_print_level/))
457 8444 : CALL section_add_keyword(section, keyword)
458 8444 : CALL keyword_release(keyword)
459 :
460 8444 : END SUBROUTINE create_eri_gpw
461 :
462 : END MODULE input_cp2k_as
|