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 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, eri_method_full_gpw, eri_method_gpw_ht, eri_operator_coulomb, &
24 : eri_operator_erf, eri_operator_erfc, eri_operator_gaussian, eri_operator_lr_trunc, &
25 : eri_operator_trunc, eri_operator_yukawa, gaussian, manual_selection, mao_projection, &
26 : no_solver, qiskit_solver, wannier_projection
27 : USE input_cp2k_loc, ONLY: create_localize_section
28 : USE input_cp2k_xc, ONLY: create_xc_section
29 : USE input_keyword_types, ONLY: keyword_create,&
30 : keyword_release,&
31 : keyword_type
32 : USE input_section_types, ONLY: section_add_keyword,&
33 : section_add_subsection,&
34 : section_create,&
35 : section_release,&
36 : section_type
37 : USE input_val_types, ONLY: char_t,&
38 : 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 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_as'
50 :
51 : PUBLIC :: create_active_space_section
52 :
53 : CONTAINS
54 :
55 : ! **************************************************************************************************
56 : !> \brief Create CP2K input section for the calculation of an active space Hamiltonian
57 : !> \param section ...
58 : !> \par History:
59 : !> - Creation 06.04.2016
60 : !> \author JHU
61 : ! **************************************************************************************************
62 9578 : SUBROUTINE create_active_space_section(section)
63 :
64 : TYPE(section_type), POINTER :: section
65 :
66 : TYPE(keyword_type), POINTER :: keyword
67 : TYPE(section_type), POINTER :: print_key, subsection
68 :
69 9578 : CPASSERT(.NOT. ASSOCIATED(section))
70 :
71 : CALL section_create(section, __LOCATION__, name="ACTIVE_SPACE", &
72 : description="Define parameters and method to calculate an electronic active space", &
73 9578 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
74 :
75 9578 : NULLIFY (keyword, subsection, print_key)
76 :
77 : CALL keyword_create(keyword, __LOCATION__, &
78 : name="_SECTION_PARAMETERS_", &
79 : description="Controls the activation of the ACTIVE_SPACE section", &
80 : usage="&ACTIVE_SPACE ON", &
81 : default_l_val=.FALSE., &
82 9578 : lone_keyword_l_val=.TRUE.)
83 9578 : CALL section_add_keyword(section, keyword)
84 9578 : CALL keyword_release(keyword)
85 :
86 : CALL keyword_create(keyword, __LOCATION__, name="ACTIVE_ELECTRONS", &
87 : description="The number of active electrons in the CAS space", &
88 9578 : usage="ACTIVE_ELECTRONS 4", n_var=1, default_i_val=-1, type_of_var=integer_t)
89 9578 : CALL section_add_keyword(section, keyword)
90 9578 : CALL keyword_release(keyword)
91 :
92 : CALL keyword_create(keyword, __LOCATION__, name="ACTIVE_ORBITALS", &
93 : description="The number of active orbitals defining the CAS space.", &
94 9578 : usage="ACTIVE_ORBITALS 2", n_var=1, default_i_val=-1, type_of_var=integer_t)
95 9578 : CALL section_add_keyword(section, keyword)
96 9578 : CALL keyword_release(keyword)
97 :
98 : CALL keyword_create(keyword, __LOCATION__, name="ACTIVE_ORBITAL_INDICES", &
99 : description="The indices of the active orbitals. Requires ORBITAL_SELECTION MANUAL! "// &
100 : "Need to be as many indices as active orbitals times the number of spin "// &
101 : "channels (2 if ROKS or UKS/LSD else 1).", &
102 : usage="ACTIVE_ORBITAL_INDICES 2 3 {...}", n_var=-1, default_i_vals=[-1], &
103 9578 : type_of_var=integer_t)
104 9578 : CALL section_add_keyword(section, keyword)
105 9578 : CALL keyword_release(keyword)
106 :
107 : CALL cp_print_key_section_create(print_key, __LOCATION__, "FCIDUMP", &
108 : description="Controls the writing of a file in FCIDUMP format.", &
109 9578 : print_level=high_print_level, filename="")
110 9578 : CALL section_add_subsection(section, print_key)
111 9578 : CALL section_release(print_key)
112 :
113 : CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_SELECTION", &
114 : description="Method used to select active space orbitals.", &
115 : usage="ORBITAL_SELECTION CANONICAL", &
116 : default_i_val=casci_canonical, &
117 : enum_c_vals=s2a("CANONICAL", "WANNIER_PROJECTION", "MAO", "MANUAL"), &
118 : enum_i_vals=[casci_canonical, wannier_projection, mao_projection, manual_selection], &
119 : enum_desc=s2a("Select orbitals using energy ordering of canoncial orbitals", &
120 : "Select orbitals from projected Wannier functions", &
121 : "Select orbitals from modified atomic orbitals", &
122 9578 : "Select orbitals manually via ACTIVE_ORBITAL_INDICES"))
123 :
124 9578 : CALL section_add_keyword(section, keyword)
125 9578 : CALL keyword_release(keyword)
126 :
127 : CALL keyword_create(keyword, __LOCATION__, name="SUBSPACE_ATOM", &
128 : description="Number of atom that defines the subspace to be projected on.", &
129 : usage="SUBSPACE_ATOM x", default_i_val=-1, &
130 9578 : type_of_var=integer_t)
131 9578 : CALL section_add_keyword(section, keyword)
132 9578 : CALL keyword_release(keyword)
133 :
134 : CALL keyword_create(keyword, __LOCATION__, name="SUBSPACE_SHELL", &
135 : description="Shell definition for subsapce.", &
136 : usage="SUBSPACE_SHELL 3d4s", default_c_val="X", &
137 9578 : type_of_var=char_t)
138 9578 : CALL section_add_keyword(section, keyword)
139 9578 : CALL keyword_release(keyword)
140 :
141 : CALL keyword_create(keyword, __LOCATION__, name="SCF_EMBEDDING", &
142 : description="Whether to turn on the self-consistent embedding scheme", &
143 9578 : default_l_val=.FALSE., lone_keyword_l_val=.FALSE.)
144 9578 : CALL section_add_keyword(section, keyword)
145 9578 : CALL keyword_release(keyword)
146 :
147 : CALL keyword_create(keyword, __LOCATION__, name="QCSCHEMA", &
148 : description="Name of the QCSchema file, may include a path", &
149 : usage="QCSCHEMA <FILENAME>", &
150 : type_of_var=lchar_t, repeats=.FALSE., &
151 9578 : default_lc_val="")
152 9578 : CALL section_add_keyword(section, keyword)
153 9578 : CALL keyword_release(keyword)
154 :
155 : CALL keyword_create(keyword, __LOCATION__, name="AS_SOLVER", &
156 : description="The external active space solver for the embedding approach", &
157 : usage="AS_SOLVER QISKIT", &
158 : default_i_val=no_solver, &
159 : enum_c_vals=s2a("NONE", "QISKIT"), &
160 : enum_i_vals=[no_solver, qiskit_solver], &
161 : enum_desc=s2a("NO solver, used to produce FCIDUMP/QCSchema files", &
162 9578 : "QISKIT active space solver"))
163 9578 : CALL section_add_keyword(section, keyword)
164 9578 : CALL keyword_release(keyword)
165 :
166 : CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
167 : description="Energy convergence threshold of the DFT embedding scheme.", &
168 : usage="EPS_ITER 1.0E-6 ", type_of_var=real_t, &
169 9578 : default_r_val=1.0E-6_dp)
170 9578 : CALL section_add_keyword(section, keyword)
171 9578 : CALL keyword_release(keyword)
172 :
173 : CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
174 : description="Fraction of new density to be mixed with previous one in SCF embedding.", &
175 : usage="ALPHA 0.25", type_of_var=real_t, &
176 9578 : default_r_val=0.8_dp)
177 9578 : CALL section_add_keyword(section, keyword)
178 9578 : CALL keyword_release(keyword)
179 :
180 : CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
181 : description="Max number of iterations for the DFT embedding scheme.", &
182 : usage="MAX_ITER 50", type_of_var=integer_t, &
183 9578 : default_i_val=50)
184 9578 : CALL section_add_keyword(section, keyword)
185 9578 : CALL keyword_release(keyword)
186 :
187 9578 : CALL create_print_orb_section(subsection)
188 9578 : CALL section_add_subsection(section, subsection)
189 9578 : CALL section_release(subsection)
190 :
191 9578 : CALL create_eri_section(subsection)
192 9578 : CALL section_add_subsection(section, subsection)
193 9578 : CALL section_release(subsection)
194 :
195 9578 : CALL create_eri_gpw(subsection)
196 9578 : CALL section_add_subsection(section, subsection)
197 9578 : CALL section_release(subsection)
198 :
199 9578 : CALL create_localize_section(subsection)
200 9578 : CALL section_add_subsection(section, subsection)
201 9578 : CALL section_release(subsection)
202 :
203 9578 : CALL create_socket_section(subsection)
204 9578 : CALL section_add_subsection(section, subsection)
205 9578 : CALL section_release(subsection)
206 :
207 9578 : CALL create_xc_section(subsection)
208 9578 : CALL section_add_subsection(section, subsection)
209 9578 : CALL section_release(subsection)
210 :
211 9578 : END SUBROUTINE create_active_space_section
212 :
213 : ! **************************************************************************************************
214 : !> \brief ...
215 : !> \param section ...
216 : ! **************************************************************************************************
217 9578 : SUBROUTINE create_socket_section(section)
218 : TYPE(section_type), POINTER :: section
219 :
220 : TYPE(keyword_type), POINTER :: keyword
221 :
222 9578 : CPASSERT(.NOT. ASSOCIATED(section))
223 : CALL section_create(section, __LOCATION__, name="SOCKET", &
224 : description="Parameters to set up the socket communicating to the external active space solver.", &
225 9578 : n_keywords=3, n_subsections=0, repeats=.FALSE.)
226 :
227 9578 : NULLIFY (keyword)
228 : CALL keyword_create(keyword, __LOCATION__, name="INET", &
229 : description="Use an INET socket rather than a UNIX socket.", &
230 : usage="INET <LOGICAL>", &
231 9578 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
232 9578 : CALL section_add_keyword(section, keyword)
233 9578 : CALL keyword_release(keyword)
234 :
235 : CALL keyword_create(keyword, __LOCATION__, name="PORT", &
236 : description="Port number for the socket client.", &
237 : usage="port <INTEGER>", &
238 9578 : default_i_val=12345)
239 9578 : CALL section_add_keyword(section, keyword)
240 9578 : CALL keyword_release(keyword)
241 :
242 : CALL keyword_create(keyword, __LOCATION__, name="HOST", &
243 : description="Host name for the socket client.", &
244 : usage="host <HOSTNAME>", &
245 9578 : default_c_val="embedding_socket")
246 9578 : CALL section_add_keyword(section, keyword)
247 9578 : CALL keyword_release(keyword)
248 :
249 9578 : END SUBROUTINE create_socket_section
250 :
251 : ! **************************************************************************************************
252 : !> \brief ...
253 : !> \param section ...
254 : ! **************************************************************************************************
255 9578 : SUBROUTINE create_print_orb_section(section)
256 : TYPE(section_type), POINTER :: section
257 :
258 : TYPE(keyword_type), POINTER :: keyword
259 :
260 9578 : CPASSERT(.NOT. ASSOCIATED(section))
261 : CALL section_create(section, __LOCATION__, name="PRINT_ORBITAL_CUBES", &
262 : description="Controls printing of active orbital cube files.", &
263 9578 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
264 :
265 9578 : NULLIFY (keyword)
266 : CALL keyword_create(keyword, __LOCATION__, name="FILENAME", &
267 : description="Body of Filename for the cube files.", &
268 : usage="FILENAME {name}", default_c_val="ActiveOrbital", &
269 9578 : type_of_var=char_t)
270 9578 : CALL section_add_keyword(section, keyword)
271 9578 : CALL keyword_release(keyword)
272 :
273 : CALL keyword_create(keyword, __LOCATION__, name="ALIST", &
274 : description="List of alpha orbitals to be printed. -1 defaults to all values", &
275 : usage="ALIST {1 2 3 ...}", n_var=-1, default_i_vals=[-1], &
276 9578 : lone_keyword_i_val=-1, type_of_var=integer_t)
277 9578 : CALL section_add_keyword(section, keyword)
278 9578 : CALL keyword_release(keyword)
279 :
280 : CALL keyword_create(keyword, __LOCATION__, name="BLIST", &
281 : description="List of beta orbitals to be printed. -1 defaults to all values", &
282 : usage="BLIST {1 2 3 ...}", n_var=-1, default_i_vals=[-1], &
283 9578 : lone_keyword_i_val=-1, type_of_var=integer_t)
284 9578 : CALL section_add_keyword(section, keyword)
285 9578 : CALL keyword_release(keyword)
286 :
287 : CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
288 : description="The stride (X,Y,Z) used to write the cube file"// &
289 : " (larger values result in smaller cube files)."// &
290 : " You can provide 3 numbers (for X,Y,Z) or 1 number valid for all components", &
291 : usage="STRIDE {2 2 2}", n_var=-1, default_i_vals=[2, 2, 2], &
292 9578 : type_of_var=integer_t)
293 9578 : CALL section_add_keyword(section, keyword)
294 9578 : CALL keyword_release(keyword)
295 :
296 : CALL keyword_create(keyword, __LOCATION__, name="STOP_AFTER_CUBES", &
297 : description="Whether to stop the computation after printing the cubes.", &
298 9578 : default_l_val=.FALSE., lone_keyword_l_val=.FALSE.)
299 9578 : CALL section_add_keyword(section, keyword)
300 9578 : CALL keyword_release(keyword)
301 :
302 9578 : END SUBROUTINE create_print_orb_section
303 :
304 : ! **************************************************************************************************
305 : !> \brief ...
306 : !> \param section ...
307 : ! **************************************************************************************************
308 9578 : SUBROUTINE create_eri_section(section)
309 : TYPE(section_type), POINTER :: section
310 :
311 : TYPE(keyword_type), POINTER :: keyword
312 :
313 9578 : CPASSERT(.NOT. ASSOCIATED(section))
314 : CALL section_create(section, __LOCATION__, name="ERI", &
315 : description="Parameters for the electron repulsion integrals.", &
316 9578 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
317 :
318 9578 : NULLIFY (keyword)
319 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
320 : description="Method used in ERI calculation.", &
321 : usage="METHOD FULL_GPW", &
322 : enum_c_vals=s2a("FULL_GPW", "GPW_HALF_TRANSFORM"), &
323 : enum_i_vals=[eri_method_full_gpw, eri_method_gpw_ht], &
324 : enum_desc=s2a("Use the GPW approach with MOs", &
325 : "Use the GPW approach for half-transformed MO ERIs"), &
326 9578 : default_i_val=eri_method_full_gpw)
327 9578 : CALL section_add_keyword(section, keyword)
328 9578 : CALL keyword_release(keyword)
329 :
330 : CALL keyword_create(keyword, __LOCATION__, name="OPERATOR", &
331 : description="Operator used in ERI calculation.", &
332 : usage="OPERATOR LONGRANGE", &
333 : enum_c_vals=s2a("COULOMB", "YUKAWA", "LONGRANGE", &
334 : "SHORTRANGE", "GAUSSIAN", "TRUNCATED", "LR_TRUNC"), &
335 : enum_i_vals=[eri_operator_coulomb, eri_operator_yukawa, &
336 : eri_operator_erf, eri_operator_erfc, eri_operator_gaussian, &
337 : eri_operator_trunc, eri_operator_lr_trunc], &
338 : enum_desc=s2a("Coulomb operator: 1/r", &
339 : "Yukawa operator: exp(-omega*R)/R", &
340 : "Longrange operator: erf(omega*R)/R", &
341 : "Shortrange operator: erfc(omega*R)/R", &
342 : "Gaussian operator: exp(-omega*R2)/R", &
343 : "Truncated Coulomb operator: if (R < R_c) 1/R else 0)", &
344 : "Truncated longrange operator: if (R < R_c) erf(omega*R)/R else 0"), &
345 9578 : default_i_val=eri_operator_coulomb)
346 9578 : CALL section_add_keyword(section, keyword)
347 9578 : CALL keyword_release(keyword)
348 :
349 : CALL keyword_create(keyword, __LOCATION__, name="PERIODICITY", &
350 : description="Periodicity used for operators in ERI calclulation.", &
351 : usage="PERIODICITY 1 1 1", n_var=-1, default_i_vals=[0, 0, 0], &
352 9578 : type_of_var=integer_t)
353 9578 : CALL section_add_keyword(section, keyword)
354 9578 : CALL keyword_release(keyword)
355 :
356 : CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
357 : description="Range-separation parameter for ERI operator.", &
358 : usage="OMEGA 0.25", type_of_var=real_t, &
359 9578 : default_r_val=0.4_dp)
360 9578 : CALL section_add_keyword(section, keyword)
361 9578 : CALL keyword_release(keyword)
362 :
363 : CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
364 : description="Cutoff radius (in Angstroms) for the truncated 1/r and "// &
365 : "longrange potentials. "// &
366 : "Only valid when doing truncated calculations.", &
367 : usage="CUTOFF_RADIUS 10.0", type_of_var=real_t, &
368 9578 : unit_str="angstrom", default_r_val=0.0_dp)
369 9578 : CALL section_add_keyword(section, keyword)
370 9578 : 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 9578 : default_r_val=1.0E-12_dp)
377 9578 : CALL section_add_keyword(section, keyword)
378 9578 : CALL keyword_release(keyword)
379 :
380 9578 : END SUBROUTINE create_eri_section
381 :
382 : ! **************************************************************************************************
383 : !> \brief ...
384 : !> \param section ...
385 : ! **************************************************************************************************
386 9578 : SUBROUTINE create_eri_gpw(section)
387 : TYPE(section_type), POINTER :: section
388 :
389 : TYPE(keyword_type), POINTER :: keyword
390 :
391 9578 : 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 9578 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
395 :
396 9578 : 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 9578 : default_r_val=1.0E-8_dp)
401 9578 : CALL section_add_keyword(section, keyword)
402 9578 : 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 9578 : default_r_val=1.0E-9_dp)
409 9578 : CALL section_add_keyword(section, keyword)
410 9578 : 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 9578 : default_r_val=300.0_dp)
416 9578 : CALL section_add_keyword(section, keyword)
417 9578 : 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 19156 : default_r_val=50.0_dp)
424 9578 : CALL section_add_keyword(section, keyword)
425 9578 : 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 19156 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
432 9578 : CALL section_add_keyword(section, keyword)
433 9578 : 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 9578 : default_i_val=-1)
443 9578 : CALL section_add_keyword(section, keyword)
444 9578 : 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 19156 : high_print_level, debug_print_level])
457 9578 : CALL section_add_keyword(section, keyword)
458 9578 : CALL keyword_release(keyword)
459 :
460 9578 : END SUBROUTINE create_eri_gpw
461 :
462 : END MODULE input_cp2k_as
|