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 Definition of disperson types for DFT calculations
10 : !> \author JGH (20.10.2008)
11 : ! **************************************************************************************************
12 : MODULE qs_dispersion_types
13 :
14 : USE input_section_types, ONLY: section_vals_type
15 : USE kinds, ONLY: default_string_length,&
16 : dp
17 : USE qs_neighbor_list_types, ONLY: neighbor_list_set_p_type,&
18 : release_neighbor_list_sets
19 : #include "./base/base_uses.f90"
20 :
21 : IMPLICIT NONE
22 :
23 : PRIVATE
24 :
25 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_dispersion_types'
26 :
27 : ! **************************************************************************************************
28 : INTEGER, PARAMETER :: dftd2_pp = 1
29 : INTEGER, PARAMETER :: dftd3_pp = 2
30 : INTEGER, PARAMETER :: dftd4_pp = 3
31 :
32 : TYPE qs_dispersion_type
33 : INTEGER :: TYPE = -1
34 : INTEGER :: pp_type = -1
35 : INTEGER :: nl_type = -1
36 : CHARACTER(LEN=default_string_length) :: ref_functional = ""
37 : REAL(KIND=dp) :: scaling = -1.0_dp
38 : REAL(KIND=dp) :: rc_disp = -1.0_dp
39 : REAL(KIND=dp) :: rc_d4 = -1.0_dp
40 : REAL(KIND=dp) :: rc_cn = -1.0_dp
41 : REAL(KIND=dp) :: exp_pre = -1.0_dp
42 : TYPE(section_vals_type), POINTER :: dftd_section => NULL()
43 : LOGICAL :: verbose = .FALSE. !extended output
44 : CHARACTER(LEN=default_string_length) :: parameter_file_name = ""
45 : CHARACTER(LEN=default_string_length) :: kernel_file_name = ""
46 : !DFT-D3 global parameters
47 : INTEGER :: max_elem = -1 !elements parametrized
48 : INTEGER :: maxc = -1 !max coordination number references per element
49 : REAL(KIND=dp) :: k1 = -1.0_dp, k2 = -1.0_dp, k3 = -1.0_dp !ad hoc parameters
50 : REAL(KIND=dp) :: alp = -1.0_dp !ad hoc parameters
51 : REAL(KIND=dp) :: s6 = -1.0_dp, s8 = -1.0_dp, sr6 = -1.0_dp !scaling parameters
52 : REAL(KIND=dp) :: a1 = -1.0_dp, a2 = -1.0_dp !BJ scaling parameters
53 : REAL(KIND=dp) :: eps_cn = -1.0_dp
54 : LOGICAL :: doabc = .FALSE. !neglect C9 terms
55 : LOGICAL :: c9cnst = .FALSE. !use constant c9 terms
56 : LOGICAL :: lrc = .FALSE. !calculate a long range correction
57 : LOGICAL :: srb = .FALSE. !calculate a short range bond correction
58 : REAL(KIND=dp), DIMENSION(4) :: srb_params = -1.0_dp ! parameters for SRB (s,g,t1,t2)
59 : REAL(KIND=dp) :: s9 = -1.0_dp !scale the many-body dispersion energy (default=1.0), dftd4
60 : TYPE(neighbor_list_set_p_type), &
61 : DIMENSION(:), POINTER :: sab_vdw => NULL(), sab_cn => NULL() ! neighborlists for pair interactions
62 : REAL(KIND=dp), DIMENSION(:, :, :, :, :), POINTER &
63 : :: c6ab => NULL()
64 : INTEGER, DIMENSION(:), POINTER :: maxci => NULL()
65 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: r0ab => NULL()
66 : REAL(KIND=dp), DIMENSION(:), POINTER :: rcov => NULL() !covalent radii
67 : REAL(KIND=dp), DIMENSION(:), POINTER :: r2r4 => NULL() !atomic <r^2>/<r^4> values
68 : REAL(KIND=dp), DIMENSION(:), POINTER :: cn => NULL() !coordination numbers (defaults)
69 : TYPE(cn_kind_list), DIMENSION(:), POINTER &
70 : :: cnkind => NULL()
71 : TYPE(cn_atom_list), DIMENSION(:), POINTER &
72 : :: cnlist => NULL()
73 : ! KG molecular corrections
74 : LOGICAL :: domol = .FALSE.
75 : REAL(KIND=dp) :: kgc8 = -1.0_dp !s8 scaling parameter
76 : !vdW-DF variables
77 : REAL(KIND=dp) :: pw_cutoff = -1.0_dp
78 : REAL(KIND=dp) :: b_value = -1.0_dp, c_value = -1.0_dp, scale_rvv10 = -1.0_dp !parameters for the rVV10 functional
79 : INTEGER :: nqs = -1, nr_points = -1
80 : !! The number of q points and radial points
81 : !! used in generating the kernel phi(q1*r, q2*r)
82 : !! (see DION 14-16 and SOLER 3)
83 : REAL(KIND=dp) :: r_max = -1.0_dp, q_cut = -1.0_dp, q_min = -1.0_dp, dk = -1.0_dp
84 : !! The maximum value of r, the maximum and minimum
85 : !! values of q and the k-space spacing of grid points.
86 : !! Note that, during a vdW run, values of q0 found
87 : !! larger than q_cut will be saturated (SOLER 6-7) to
88 : !! q_cut
89 : REAL(KIND=dp), DIMENSION(:), POINTER :: q_mesh => NULL() !! The values of all the q points used
90 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER &
91 : :: kernel => NULL() !! A matrix holding the Fourier transformed kernel function
92 : !! for each pair of q values. The ordering is
93 : !! kernel(k_point, q1_value, q2_value)
94 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER &
95 : :: d2phi_dk2 => NULL() !! A matrix holding the second derivatives of the above
96 : !! kernel matrix at each of the q points. Stored as
97 : !! d2phi_dk2(k_point, q1_value, q2_value)
98 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: d2y_dx2 => NULL() !! 2nd derivatives of q_mesh for interpolation
99 : INTEGER, DIMENSION(:, :), POINTER :: d3_exclude_pair => NULL()
100 : INTEGER :: nd3_exclude_pair = -1
101 : END TYPE qs_dispersion_type
102 :
103 : TYPE qs_atom_dispersion_type
104 : INTEGER :: TYPE = -1
105 : LOGICAL :: defined = .FALSE.
106 : REAL(KIND=dp) :: vdw_radii = -1.0_dp !van der Waals radii
107 : REAL(KIND=dp) :: c6 = -1.0_dp !c6 coefficients
108 : END TYPE qs_atom_dispersion_type
109 :
110 : TYPE cn_kind_list
111 : REAL(KIND=dp) :: cnum = -1.0_dp
112 : INTEGER :: kind = -1
113 : END TYPE cn_kind_list
114 : TYPE cn_atom_list
115 : REAL(KIND=dp) :: cnum = -1.0_dp
116 : INTEGER :: natom = -1
117 : INTEGER, DIMENSION(:), POINTER :: atom => NULL()
118 : END TYPE cn_atom_list
119 :
120 : ! **************************************************************************************************
121 :
122 : PUBLIC :: qs_atom_dispersion_type, qs_dispersion_type
123 : PUBLIC :: dftd2_pp, dftd3_pp, dftd4_pp
124 : PUBLIC :: qs_dispersion_release
125 :
126 : ! **************************************************************************************************
127 : CONTAINS
128 : ! **************************************************************************************************
129 : !> \brief ...
130 : !> \param dispersion_env ...
131 : ! **************************************************************************************************
132 6845 : SUBROUTINE qs_dispersion_release(dispersion_env)
133 :
134 : TYPE(qs_dispersion_type), POINTER :: dispersion_env
135 :
136 : INTEGER :: i
137 :
138 6845 : IF (ASSOCIATED(dispersion_env)) THEN
139 6818 : IF (ASSOCIATED(dispersion_env%maxci)) THEN
140 : ! DFT-D3 arrays
141 324 : DEALLOCATE (dispersion_env%maxci)
142 324 : DEALLOCATE (dispersion_env%c6ab)
143 324 : DEALLOCATE (dispersion_env%r0ab)
144 324 : DEALLOCATE (dispersion_env%rcov)
145 324 : DEALLOCATE (dispersion_env%r2r4)
146 324 : DEALLOCATE (dispersion_env%cn)
147 324 : IF (ASSOCIATED(dispersion_env%cnkind)) THEN
148 6 : DEALLOCATE (dispersion_env%cnkind)
149 : END IF
150 324 : IF (ASSOCIATED(dispersion_env%cnlist)) THEN
151 6 : DO i = 1, SIZE(dispersion_env%cnlist)
152 6 : DEALLOCATE (dispersion_env%cnlist(i)%atom)
153 : END DO
154 2 : DEALLOCATE (dispersion_env%cnlist)
155 : END IF
156 : END IF
157 : ! vdD-DF
158 6818 : IF (ASSOCIATED(dispersion_env%q_mesh)) THEN
159 46 : DEALLOCATE (dispersion_env%q_mesh)
160 : END IF
161 6818 : IF (ASSOCIATED(dispersion_env%kernel)) THEN
162 46 : DEALLOCATE (dispersion_env%kernel)
163 : END IF
164 6818 : IF (ASSOCIATED(dispersion_env%d2phi_dk2)) THEN
165 46 : DEALLOCATE (dispersion_env%d2phi_dk2)
166 : END IF
167 6818 : IF (ASSOCIATED(dispersion_env%d2y_dx2)) THEN
168 46 : DEALLOCATE (dispersion_env%d2y_dx2)
169 : END IF
170 6818 : IF (ASSOCIATED(dispersion_env%d3_exclude_pair)) THEN
171 2 : DEALLOCATE (dispersion_env%d3_exclude_pair)
172 : END IF
173 : ! neighborlists
174 6818 : CALL release_neighbor_list_sets(dispersion_env%sab_vdw)
175 6818 : CALL release_neighbor_list_sets(dispersion_env%sab_cn)
176 :
177 6818 : DEALLOCATE (dispersion_env)
178 :
179 : END IF
180 :
181 6845 : END SUBROUTINE qs_dispersion_release
182 :
183 0 : END MODULE qs_dispersion_types
184 :
|