1
+ ! > This module contains the API to access DFT-D3 functionality.
2
+ ! !
1
3
module dftd3_api
2
4
use dftd3_sizes
3
5
use dftd3_common
4
6
use dftd3_core
5
7
implicit none
6
8
private
7
9
8
- public :: dftd3_input, dftd3_state
10
+ public :: dftd3_input, dftd3_calc
9
11
public :: dftd3_init, dftd3_set_params, dftd3_set_functional
10
12
public :: dftd3_dispersion, dftd3_pbc_dispersion
11
13
public :: get_atomic_number
12
14
13
15
16
+ ! > Input for a dftd3 calculator.
17
+ ! !
14
18
type :: dftd3_input
15
- ! Whether three body term should be calculated
19
+ ! > Whether three body term should be calculated
16
20
logical :: threebody = .false.
17
21
18
- ! Numerical gradients instead of analytical ones
22
+ ! > Whether numerical gradients instead of analytical ones
19
23
logical :: numgrad = .false.
20
24
21
- ! C6 min flags (or unallocated if not needed)
25
+ ! > C6 min flags (or unallocated if not needed)
22
26
logical , allocatable :: minc6list(:)
23
27
24
- ! C6 max flags (or unallocated if not needed)
28
+ ! > C6 max flags (or unallocated if not needed)
25
29
logical , allocatable :: maxc6list(:)
26
30
27
- ! Real space cutoff
31
+ ! > Real space cutoff in atomic units.
28
32
real (wp) :: cutoff = sqrt (9000.0_wp )
29
33
30
- ! Real space cutoff for coordination numbers
34
+ ! > Real space cutoff for coordination numbers in atomic units
31
35
real (wp) :: cutoff_cn = sqrt (1600.0_wp )
32
36
end type dftd3_input
33
37
34
38
35
- type :: dftd3_state
39
+ ! > State of a dftd3 calculator.
40
+ ! !
41
+ type :: dftd3_calc
42
+ private
36
43
logical :: noabc, numgrad
37
44
integer :: version
38
45
real (wp) :: s6, rs6, s18, rs18, alp
39
46
real (wp) :: rthr, cn_thr
40
47
integer :: rep_vdw(3 ), rep_cn(3 )
41
48
real (wp), allocatable :: r0ab(:,:), c6ab(:,:,:,:,:)
42
49
integer , allocatable :: mxc(:)
43
- end type dftd3_state
50
+ end type dftd3_calc
44
51
45
52
46
53
contains
47
54
55
+ ! > Initializes a dftd3 calculator.
56
+ ! !
57
+ ! ! \note You also need to call dftd3_set_functional() or dftd3_set_params()
58
+ ! ! before you can make an actual calculation.
59
+ ! !
60
+ ! ! \param input Input parameters for the calculator.
61
+ ! !
48
62
subroutine dftd3_init (this , input )
49
- type (dftd3_state ), intent (out ) :: this
63
+ type (dftd3_calc ), intent (out ) :: this
50
64
type (dftd3_input), intent (in ) :: input
51
65
52
66
logical , allocatable :: minc6list(:), maxc6list(:)
@@ -83,8 +97,14 @@ subroutine dftd3_init(this, input)
83
97
end subroutine dftd3_init
84
98
85
99
100
+ ! > Sets the parameter for the dftd3 calculator by choosing a functional.
101
+ ! !
102
+ ! ! \param func Name of the functional.
103
+ ! ! \param version Version to use.
104
+ ! ! \param tz Whether special TZ-parameters should be used.
105
+ ! !
86
106
subroutine dftd3_set_functional (this , func , version , tz )
87
- type (dftd3_state ), intent (inout ) :: this
107
+ type (dftd3_calc ), intent (inout ) :: this
88
108
character (* ), intent (in ) :: func
89
109
integer , intent (in ) :: version
90
110
logical , intent (in ) :: tz
@@ -96,8 +116,16 @@ subroutine dftd3_set_functional(this, func, version, tz)
96
116
end subroutine dftd3_set_functional
97
117
98
118
119
+ ! > Sets the parameter for the dftd3 calculator directly.
120
+ ! !
121
+ ! ! \param pars Parameter to use. The 5 parameters must follow the same
122
+ ! ! order as when specified in the dftd3.local file for the dftd3 program.
123
+ ! ! (see the documentation of the dftd3 program for details)
124
+ ! ! \param version Version to use. Note, that depending on the version the
125
+ ! ! five parameters may have different (or no) meaning.
126
+ ! !
99
127
subroutine dftd3_set_params (this , pars , version )
100
- type (dftd3_state ), intent (inout ) :: this
128
+ type (dftd3_calc ), intent (inout ) :: this
101
129
real (wp), intent (in ) :: pars(:)
102
130
integer , intent (in ) :: version
103
131
@@ -116,8 +144,16 @@ subroutine dftd3_set_params(this, pars, version)
116
144
end subroutine dftd3_set_params
117
145
118
146
147
+ ! > Calculates the dispersion for a given non-periodic configuration.
148
+ ! !
149
+ ! ! \param coords Coordinates of the atoms in atomic units. Shape: [3, nAtom].
150
+ ! ! \param izp Atomic number of each atom. Shape: [nAtom]. You can determine
151
+ ! ! the atomic number using the get_atomic_number() function.
152
+ ! ! \param disp Calculated dispersion energy in atomic units.
153
+ ! ! \param grads Calculated gradients in atomic units, if present.
154
+ ! !
119
155
subroutine dftd3_dispersion (this , coords , izp , disp , grads )
120
- type (dftd3_state ), intent (in ) :: this
156
+ type (dftd3_calc ), intent (in ) :: this
121
157
real (wp), intent (in ) :: coords(:,:)
122
158
integer , intent (in ) :: izp(:)
123
159
real (wp), intent (out ) :: disp
@@ -158,9 +194,19 @@ subroutine dftd3_dispersion(this, coords, izp, disp, grads)
158
194
end subroutine dftd3_dispersion
159
195
160
196
197
+ ! > Calculates the dispersion for a given periodic configuration.
198
+ ! !
199
+ ! ! \param coords Coordinates of the atoms in atomic units. Shape: [3, nAtom].
200
+ ! ! \param izp Atomic number of each atom. Shape: [nAtom]. You can determine
201
+ ! ! the atomic number using the get_atomic_number() function.
202
+ ! ! \param latvecs Lattice vectors in atomic units. Shape: [3, 3].
203
+ ! ! \param disp Calculated dispersion energy in atomic units.
204
+ ! ! \param grads Calculated gradiens in atomic units, if present.
205
+ ! ! \param stress Calculated stress tensor in atomic units, if present.
206
+ ! !
161
207
subroutine dftd3_pbc_dispersion (this , coords , izp , latvecs , disp , grads , &
162
208
& stress )
163
- type (dftd3_state ), intent (in ) :: this
209
+ type (dftd3_calc ), intent (in ) :: this
164
210
real (wp), intent (in ) :: coords(:,:)
165
211
integer , intent (in ) :: izp(:)
166
212
real (wp), intent (in ) :: latvecs(:,:)
@@ -212,6 +258,11 @@ subroutine dftd3_pbc_dispersion(this, coords, izp, latvecs, disp, grads, &
212
258
end subroutine dftd3_pbc_dispersion
213
259
214
260
261
+ ! > Returns the atomic number for a given species.
262
+ ! !
263
+ ! ! \param species Chemical symbol of the species.
264
+ ! ! \return Atomic number.
265
+ ! !
215
266
elemental function get_atomic_number (species ) result(izp)
216
267
character (* ), intent (in ) :: species
217
268
integer :: izp
0 commit comments