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 Library choices for electronic integral APIs.
10 : ! **************************************************************************************************
11 : MODULE integral_library_types
12 : USE input_constants, ONLY: do_potential_coulomb
13 : USE kinds, ONLY: default_path_length,&
14 : dp
15 :
16 : IMPLICIT NONE
17 :
18 : PRIVATE
19 :
20 : INTEGER, PARAMETER, PUBLIC :: library_native = 0, &
21 : library_libint = 1
22 :
23 : #if defined(__LIBINT)
24 : INTEGER, PARAMETER, PUBLIC :: default_coulomb_library = library_libint
25 : LOGICAL, PARAMETER :: libint_available = .TRUE.
26 : #else
27 : INTEGER, PARAMETER, PUBLIC :: default_coulomb_library = library_native
28 : LOGICAL, PARAMETER :: libint_available = .FALSE.
29 : #endif
30 :
31 : TYPE, PUBLIC :: integral_library_type
32 : INTEGER :: coulomb2_library = default_coulomb_library
33 : INTEGER :: coulomb3_library = default_coulomb_library
34 : END TYPE integral_library_type
35 :
36 : TYPE, PUBLIC :: coulomb_operator_type
37 : INTEGER :: potential_type = do_potential_coulomb
38 : REAL(dp) :: omega = 0.0_dp ! SR: erfc(omega*r)/r
39 : REAL(dp) :: cutoff_radius = 0.0_dp ! TC cutoff/effective SR range
40 : CHARACTER(default_path_length) :: filename = ""
41 : REAL(dp) :: scale_coulomb = 0.0_dp ! Only for WFC methods
42 : REAL(dp) :: scale_longrange = 0.0_dp ! Only for WFC methods
43 : END TYPE coulomb_operator_type
44 :
45 : TYPE(integral_library_type), SAVE, PUBLIC :: active_integral_library = integral_library_type()
46 :
47 : PUBLIC :: integral_library_init
48 :
49 : CONTAINS
50 :
51 : ! **************************************************************************************************
52 : !> \brief Resolves requested Coulomb integral libraries against the compiled-in backends.
53 : !> \param coulomb2_library requested two-center Coulomb integral library
54 : !> \param coulomb3_library requested three-center Coulomb integral library
55 : !> \param fallback_applied whether an unavailable Libint request was replaced by the native backend
56 : ! **************************************************************************************************
57 11585 : SUBROUTINE integral_library_init(coulomb2_library, coulomb3_library, fallback_applied)
58 : INTEGER, INTENT(IN) :: coulomb2_library, coulomb3_library
59 : LOGICAL, INTENT(OUT) :: fallback_applied
60 :
61 11585 : active_integral_library%coulomb2_library = coulomb2_library
62 11585 : active_integral_library%coulomb3_library = coulomb3_library
63 11585 : fallback_applied = .FALSE.
64 :
65 : IF (.NOT. libint_available) THEN
66 : IF (active_integral_library%coulomb2_library == library_libint) THEN
67 : active_integral_library%coulomb2_library = library_native
68 : fallback_applied = .TRUE.
69 : END IF
70 : IF (active_integral_library%coulomb3_library == library_libint) THEN
71 : active_integral_library%coulomb3_library = library_native
72 : fallback_applied = .TRUE.
73 : END IF
74 : END IF
75 :
76 11585 : END SUBROUTINE integral_library_init
77 :
78 0 : END MODULE integral_library_types
|