Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2025 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 9300 : 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 9300 : 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 9300 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
74 :
75 9300 : 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 9300 : lone_keyword_l_val=.TRUE.)
83 9300 : CALL section_add_keyword(section, keyword)
84 9300 : 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 9300 : usage="ACTIVE_ELECTRONS 4", n_var=1, default_i_val=-1, type_of_var=integer_t)
89 9300 : CALL section_add_keyword(section, keyword)
90 9300 : 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 9300 : usage="ACTIVE_ORBITALS 2", n_var=1, default_i_val=-1, type_of_var=integer_t)
95 9300 : CALL section_add_keyword(section, keyword)
96 9300 : 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 : usage="ACTIVE_ORBITAL_INDICES 2 3 {...}", n_var=-1, default_i_vals=[-1], &
101 9300 : type_of_var=integer_t)
102 9300 : CALL section_add_keyword(section, keyword)
103 9300 : CALL keyword_release(keyword)
104 :
105 : CALL cp_print_key_section_create(print_key, __LOCATION__, "FCIDUMP", &
106 : description="Controls the writing of a file in FCIDUMP format.", &
107 9300 : print_level=high_print_level, filename="")
108 9300 : CALL section_add_subsection(section, print_key)
109 9300 : CALL section_release(print_key)
110 :
111 : CALL keyword_create(keyword, __LOCATION__, name="ORBITAL_SELECTION", &
112 : description="Method used to select active space orbitals.", &
113 : usage="ORBITAL_SELECTION CANONICAL", &
114 : default_i_val=casci_canonical, &
115 : enum_c_vals=s2a("CANONICAL", "WANNIER_PROJECTION", "MAO", "MANUAL"), &
116 : enum_i_vals=[casci_canonical, wannier_projection, mao_projection, manual_selection], &
117 : enum_desc=s2a("Select orbitals using energy ordering of canoncial orbitals", &
118 : "Select orbitals from projected Wannier functions", &
119 : "Select orbitals from modified atomic orbitals", &
120 9300 : "Select orbitals manually via ACTIVE_ORBITAL_INDICES"))
121 :
122 9300 : CALL section_add_keyword(section, keyword)
123 9300 : CALL keyword_release(keyword)
124 :
125 : CALL keyword_create(keyword, __LOCATION__, name="SUBSPACE_ATOM", &
126 : description="Number of atom that defines the subspace to be projected on.", &
127 : usage="SUBSPACE_ATOM x", default_i_val=-1, &
128 9300 : type_of_var=integer_t)
129 9300 : CALL section_add_keyword(section, keyword)
130 9300 : CALL keyword_release(keyword)
131 :
132 : CALL keyword_create(keyword, __LOCATION__, name="SUBSPACE_SHELL", &
133 : description="Shell definition for subsapce.", &
134 : usage="SUBSPACE_SHELL 3d4s", default_c_val="X", &
135 9300 : type_of_var=char_t)
136 9300 : CALL section_add_keyword(section, keyword)
137 9300 : CALL keyword_release(keyword)
138 :
139 : CALL keyword_create(keyword, __LOCATION__, name="SCF_EMBEDDING", &
140 : description="Whether to turn on the self-consistent embedding scheme", &
141 9300 : default_l_val=.FALSE., lone_keyword_l_val=.FALSE.)
142 9300 : CALL section_add_keyword(section, keyword)
143 9300 : CALL keyword_release(keyword)
144 :
145 : CALL keyword_create(keyword, __LOCATION__, name="QCSCHEMA", &
146 : description="Name of the QCSchema file, may include a path", &
147 : usage="QCSCHEMA <FILENAME>", &
148 : type_of_var=lchar_t, repeats=.FALSE., &
149 9300 : default_lc_val="")
150 9300 : CALL section_add_keyword(section, keyword)
151 9300 : CALL keyword_release(keyword)
152 :
153 : CALL keyword_create(keyword, __LOCATION__, name="AS_SOLVER", &
154 : description="The external active space solver for the embedding approach", &
155 : usage="AS_SOLVER QISKIT", &
156 : default_i_val=no_solver, &
157 : enum_c_vals=s2a("NONE", "QISKIT"), &
158 : enum_i_vals=[no_solver, qiskit_solver], &
159 : enum_desc=s2a("NO solver, used to produce FCIDUMP/QCSchema files", &
160 9300 : "QISKIT active space solver"))
161 9300 : CALL section_add_keyword(section, keyword)
162 9300 : CALL keyword_release(keyword)
163 :
164 : CALL keyword_create(keyword, __LOCATION__, name="EPS_ITER", &
165 : description="Energy convergence threshold of the DFT embedding scheme.", &
166 : usage="EPS_ITER 1.0E-6 ", type_of_var=real_t, &
167 9300 : default_r_val=1.0E-6_dp)
168 9300 : CALL section_add_keyword(section, keyword)
169 9300 : CALL keyword_release(keyword)
170 :
171 : CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
172 : description="Fraction of new density to be mixed with previous one in SCF embedding.", &
173 : usage="ALPHA 0.25", type_of_var=real_t, &
174 9300 : default_r_val=0.8_dp)
175 9300 : CALL section_add_keyword(section, keyword)
176 9300 : CALL keyword_release(keyword)
177 :
178 : CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
179 : description="Max number of iterations for the DFT embedding scheme.", &
180 : usage="MAX_ITER 50", type_of_var=integer_t, &
181 9300 : default_i_val=50)
182 9300 : CALL section_add_keyword(section, keyword)
183 9300 : CALL keyword_release(keyword)
184 :
185 9300 : CALL create_print_orb_section(subsection)
186 9300 : CALL section_add_subsection(section, subsection)
187 9300 : CALL section_release(subsection)
188 :
189 9300 : CALL create_eri_section(subsection)
190 9300 : CALL section_add_subsection(section, subsection)
191 9300 : CALL section_release(subsection)
192 :
193 9300 : CALL create_eri_gpw(subsection)
194 9300 : CALL section_add_subsection(section, subsection)
195 9300 : CALL section_release(subsection)
196 :
197 9300 : CALL create_localize_section(subsection)
198 9300 : CALL section_add_subsection(section, subsection)
199 9300 : CALL section_release(subsection)
200 :
201 9300 : CALL create_socket_section(subsection)
202 9300 : CALL section_add_subsection(section, subsection)
203 9300 : CALL section_release(subsection)
204 :
205 9300 : CALL create_xc_section(subsection)
206 9300 : CALL section_add_subsection(section, subsection)
207 9300 : CALL section_release(subsection)
208 :
209 9300 : END SUBROUTINE create_active_space_section
210 :
211 : ! **************************************************************************************************
212 : !> \brief ...
213 : !> \param section ...
214 : ! **************************************************************************************************
215 9300 : SUBROUTINE create_socket_section(section)
216 : TYPE(section_type), POINTER :: section
217 :
218 : TYPE(keyword_type), POINTER :: keyword
219 :
220 9300 : CPASSERT(.NOT. ASSOCIATED(section))
221 : CALL section_create(section, __LOCATION__, name="SOCKET", &
222 : description="Parameters to set up the socket communicating to the external active space solver.", &
223 9300 : n_keywords=3, n_subsections=0, repeats=.FALSE.)
224 :
225 9300 : NULLIFY (keyword)
226 : CALL keyword_create(keyword, __LOCATION__, name="INET", &
227 : description="Use an INET socket rather than a UNIX socket.", &
228 : usage="INET <LOGICAL>", &
229 9300 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
230 9300 : CALL section_add_keyword(section, keyword)
231 9300 : CALL keyword_release(keyword)
232 :
233 : CALL keyword_create(keyword, __LOCATION__, name="PORT", &
234 : description="Port number for the socket client.", &
235 : usage="port <INTEGER>", &
236 9300 : default_i_val=12345)
237 9300 : CALL section_add_keyword(section, keyword)
238 9300 : CALL keyword_release(keyword)
239 :
240 : CALL keyword_create(keyword, __LOCATION__, name="HOST", &
241 : description="Host name for the socket client.", &
242 : usage="host <HOSTNAME>", &
243 9300 : default_c_val="embedding_socket")
244 9300 : CALL section_add_keyword(section, keyword)
245 9300 : CALL keyword_release(keyword)
246 :
247 9300 : END SUBROUTINE create_socket_section
248 :
249 : ! **************************************************************************************************
250 : !> \brief ...
251 : !> \param section ...
252 : ! **************************************************************************************************
253 9300 : SUBROUTINE create_print_orb_section(section)
254 : TYPE(section_type), POINTER :: section
255 :
256 : TYPE(keyword_type), POINTER :: keyword
257 :
258 9300 : CPASSERT(.NOT. ASSOCIATED(section))
259 : CALL section_create(section, __LOCATION__, name="PRINT_ORBITAL_CUBES", &
260 : description="Controls printing of active orbital cube files.", &
261 9300 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
262 :
263 9300 : NULLIFY (keyword)
264 : CALL keyword_create(keyword, __LOCATION__, name="FILENAME", &
265 : description="Body of Filename for the cube files.", &
266 : usage="FILENAME {name}", default_c_val="ActiveOrbital", &
267 9300 : type_of_var=char_t)
268 9300 : CALL section_add_keyword(section, keyword)
269 9300 : CALL keyword_release(keyword)
270 :
271 : CALL keyword_create(keyword, __LOCATION__, name="ALIST", &
272 : description="List of alpha orbitals to be printed. -1 defaults to all values", &
273 : usage="ALIST {1 2 3 ...}", n_var=-1, default_i_vals=[-1], &
274 9300 : lone_keyword_i_val=-1, type_of_var=integer_t)
275 9300 : CALL section_add_keyword(section, keyword)
276 9300 : CALL keyword_release(keyword)
277 :
278 : CALL keyword_create(keyword, __LOCATION__, name="BLIST", &
279 : description="List of beta orbitals to be printed. -1 defaults to all values", &
280 : usage="BLIST {1 2 3 ...}", n_var=-1, default_i_vals=[-1], &
281 9300 : lone_keyword_i_val=-1, type_of_var=integer_t)
282 9300 : CALL section_add_keyword(section, keyword)
283 9300 : CALL keyword_release(keyword)
284 :
285 : CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
286 : description="The stride (X,Y,Z) used to write the cube file"// &
287 : " (larger values result in smaller cube files)."// &
288 : " You can provide 3 numbers (for X,Y,Z) or 1 number valid for all components", &
289 : usage="STRIDE {2 2 2}", n_var=-1, default_i_vals=[2, 2, 2], &
290 9300 : type_of_var=integer_t)
291 9300 : CALL section_add_keyword(section, keyword)
292 9300 : CALL keyword_release(keyword)
293 :
294 : CALL keyword_create(keyword, __LOCATION__, name="STOP_AFTER_CUBES", &
295 : description="Whether to stop the computation after printing the cubes.", &
296 9300 : default_l_val=.FALSE., lone_keyword_l_val=.FALSE.)
297 9300 : CALL section_add_keyword(section, keyword)
298 9300 : CALL keyword_release(keyword)
299 :
300 9300 : END SUBROUTINE create_print_orb_section
301 :
302 : ! **************************************************************************************************
303 : !> \brief ...
304 : !> \param section ...
305 : ! **************************************************************************************************
306 9300 : SUBROUTINE create_eri_section(section)
307 : TYPE(section_type), POINTER :: section
308 :
309 : TYPE(keyword_type), POINTER :: keyword
310 :
311 9300 : CPASSERT(.NOT. ASSOCIATED(section))
312 : CALL section_create(section, __LOCATION__, name="ERI", &
313 : description="Parameters for the electron repulsion integrals.", &
314 9300 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
315 :
316 9300 : NULLIFY (keyword)
317 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
318 : description="Method used in ERI calculation.", &
319 : usage="METHOD FULL_GPW", &
320 : enum_c_vals=s2a("FULL_GPW", "GPW_HALF_TRANSFORM"), &
321 : enum_i_vals=[eri_method_full_gpw, eri_method_gpw_ht], &
322 : enum_desc=s2a("Use the GPW approach with MOs", &
323 : "Use the GPW approach for half-transformed MO ERIs"), &
324 9300 : default_i_val=eri_method_full_gpw)
325 9300 : CALL section_add_keyword(section, keyword)
326 9300 : CALL keyword_release(keyword)
327 :
328 : CALL keyword_create(keyword, __LOCATION__, name="OPERATOR", &
329 : description="Operator used in ERI calculation.", &
330 : usage="OPERATOR LONGRANGE", &
331 : enum_c_vals=s2a("COULOMB", "YUKAWA", "LONGRANGE", &
332 : "SHORTRANGE", "GAUSSIAN", "TRUNCATED", "LR_TRUNC"), &
333 : enum_i_vals=[eri_operator_coulomb, eri_operator_yukawa, &
334 : eri_operator_erf, eri_operator_erfc, eri_operator_gaussian, &
335 : eri_operator_trunc, eri_operator_lr_trunc], &
336 : enum_desc=s2a("Coulomb operator: 1/r", &
337 : "Yukawa operator: exp(-omega*R)/R", &
338 : "Longrange operator: erf(omega*R)/R", &
339 : "Shortrange operator: erfc(omega*R)/R", &
340 : "Gaussian operator: exp(-omega*R2)/R", &
341 : "Truncated Coulomb operator: if (R < R_c) 1/R else 0)", &
342 : "Truncated longrange operator: if (R < R_c) erf(omega*R)/R else 0"), &
343 9300 : default_i_val=eri_operator_coulomb)
344 9300 : CALL section_add_keyword(section, keyword)
345 9300 : CALL keyword_release(keyword)
346 :
347 : CALL keyword_create(keyword, __LOCATION__, name="PERIODICITY", &
348 : description="Periodicity used for operators in ERI calclulation.", &
349 : usage="PERIODICITY 1 1 1", n_var=-1, default_i_vals=[0, 0, 0], &
350 9300 : type_of_var=integer_t)
351 9300 : CALL section_add_keyword(section, keyword)
352 9300 : CALL keyword_release(keyword)
353 :
354 : CALL keyword_create(keyword, __LOCATION__, name="OMEGA", &
355 : description="Range-separation parameter for ERI operator.", &
356 : usage="OMEGA 0.25", type_of_var=real_t, &
357 9300 : default_r_val=0.4_dp)
358 9300 : CALL section_add_keyword(section, keyword)
359 9300 : CALL keyword_release(keyword)
360 :
361 : CALL keyword_create(keyword, __LOCATION__, name="CUTOFF_RADIUS", &
362 : description="Cutoff radius (in Angstroms) for the truncated 1/r and "// &
363 : "longrange potentials. "// &
364 : "Only valid when doing truncated calculations.", &
365 : usage="CUTOFF_RADIUS 10.0", type_of_var=real_t, &
366 9300 : unit_str="angstrom", default_r_val=0.0_dp)
367 9300 : CALL section_add_keyword(section, keyword)
368 9300 : CALL keyword_release(keyword)
369 :
370 : CALL keyword_create( &
371 : keyword, __LOCATION__, name="EPS_INTEGRAL", &
372 : description="Accuracy of ERIs that will be stored.", &
373 : usage="EPS_INTEGRAL 1.0E-10 ", type_of_var=real_t, &
374 9300 : default_r_val=1.0E-12_dp)
375 9300 : CALL section_add_keyword(section, keyword)
376 9300 : CALL keyword_release(keyword)
377 :
378 9300 : END SUBROUTINE create_eri_section
379 :
380 : ! **************************************************************************************************
381 : !> \brief ...
382 : !> \param section ...
383 : ! **************************************************************************************************
384 9300 : SUBROUTINE create_eri_gpw(section)
385 : TYPE(section_type), POINTER :: section
386 :
387 : TYPE(keyword_type), POINTER :: keyword
388 :
389 9300 : CPASSERT(.NOT. ASSOCIATED(section))
390 : CALL section_create(section, __LOCATION__, name="ERI_GPW", &
391 : description="Parameters for the GPW approach to electron repulsion integrals.", &
392 9300 : n_keywords=5, n_subsections=0, repeats=.FALSE.)
393 :
394 9300 : NULLIFY (keyword)
395 : CALL keyword_create(keyword, __LOCATION__, name="EPS_GRID", &
396 : description="Determines a threshold for the GPW based integration", &
397 : usage="EPS_GRID 1.0E-9 ", type_of_var=real_t, &
398 9300 : default_r_val=1.0E-8_dp)
399 9300 : CALL section_add_keyword(section, keyword)
400 9300 : CALL keyword_release(keyword)
401 :
402 : CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
403 : description="Determines a threshold for the sparse matrix multiplications if METHOD "// &
404 : "GPW_HALF_TRANSFORM is used", &
405 : usage="EPS_FILTER 1.0E-9 ", type_of_var=real_t, &
406 9300 : default_r_val=1.0E-9_dp)
407 9300 : CALL section_add_keyword(section, keyword)
408 9300 : CALL keyword_release(keyword)
409 :
410 : CALL keyword_create(keyword, __LOCATION__, name="CUTOFF", &
411 : description="The cutoff of the finest grid level in the GPW integration.", &
412 : usage="CUTOFF 300", type_of_var=real_t, &
413 9300 : default_r_val=300.0_dp)
414 9300 : CALL section_add_keyword(section, keyword)
415 9300 : CALL keyword_release(keyword)
416 :
417 : CALL keyword_create(keyword, __LOCATION__, name="REL_CUTOFF", &
418 : variants=["RELATIVE_CUTOFF"], &
419 : description="Determines the grid at which a Gaussian is mapped.", &
420 : usage="REL_CUTOFF 50", type_of_var=real_t, &
421 18600 : default_r_val=50.0_dp)
422 9300 : CALL section_add_keyword(section, keyword)
423 9300 : CALL keyword_release(keyword)
424 :
425 : CALL keyword_create(keyword, __LOCATION__, name="STORE_WFN", &
426 : variants=["STORE_WAVEFUNCTION"], &
427 : description="Store wavefunction in real space representation for integration.", &
428 : usage="STORE_WFN T", type_of_var=logical_t, &
429 18600 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
430 9300 : CALL section_add_keyword(section, keyword)
431 9300 : CALL keyword_release(keyword)
432 :
433 : CALL keyword_create(keyword, __LOCATION__, name="GROUP_SIZE", &
434 : description="Sets the size of a subgroup for ERI calculation, "// &
435 : "each of which with a full set of work grids, arrays or orbitals "// &
436 : "depending on the method of grids (work grids, arrays, orbitals). "// &
437 : "Small numbers reduce communication but increase the memory demands. "// &
438 : "A negative number indicates all processes (default).", &
439 : usage="GROUP_SIZE 2", type_of_var=integer_t, &
440 9300 : default_i_val=-1)
441 9300 : CALL section_add_keyword(section, keyword)
442 9300 : CALL keyword_release(keyword)
443 :
444 : CALL keyword_create(keyword, __LOCATION__, name="PRINT_LEVEL", &
445 : variants=["IOLEVEL"], &
446 : description="How much output is written by the individual groups.", &
447 : usage="PRINT_LEVEL HIGH", &
448 : default_i_val=silent_print_level, enum_c_vals= &
449 : s2a("SILENT", "LOW", "MEDIUM", "HIGH", "DEBUG"), &
450 : enum_desc=s2a("Almost no output", &
451 : "Little output", "Quite some output", "Lots of output", &
452 : "Everything is written out, useful for debugging purposes only"), &
453 : enum_i_vals=[silent_print_level, low_print_level, medium_print_level, &
454 18600 : high_print_level, debug_print_level])
455 9300 : CALL section_add_keyword(section, keyword)
456 9300 : CALL keyword_release(keyword)
457 :
458 9300 : END SUBROUTINE create_eri_gpw
459 :
460 : END MODULE input_cp2k_as
|