-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdftd_ncoord.h
259 lines (236 loc) · 7.22 KB
/
dftd_ncoord.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/* This file is part of cpp-d4.
*
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cpp-d4 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with cpp-d4. If not, see <https://www.gnu.org/licenses/>.
*/
/*
* Definition of the coordination numbers used in DFT-D4 and the
* electronegativity equilibration (EEQ) model
*/
#pragma once
#include "dftd_geometry.h"
#include "dftd_matrix.h"
namespace dftd4 {
/**
* Calculate all distance pairs and store in matrix.
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix (inout).
* @return Exit status.
*/
extern int calc_distances(
const TMolecule &mol,
const TIVector &realIdx,
TMatrix<double> &dist
);
/**
* Initialize real indices to all atoms in the molecule.
*
* @param nat Number of atoms in the molecule.
* @param realIdx Vector to store the real indices.
* @return void
*/
extern void initializeRealIdx(int nat, TVector<int> &realIdx);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/**
* Wrapper for error function coordination number.
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix.
* @param cn Vector of coordination numbers.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param dcndr Derivative of coordination number.
* @param lgrad Flag for gradient computation.
* @return Exit status.
*/
extern int get_ncoord_erf(
const TMolecule &mol,
const TIVector &realIdx,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad = false
);
/**
* Wrapper for error function coordination number.
*
* @param mol Molecule object.
* @param dist Distance matrix.
* @param cn Vector of coordination numbers.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param dcndr Derivative of coordination number.
* @param lgrad Flag for gradient computation.
* @return Exit status.
*/
extern int get_ncoord_erf(
const TMolecule &mol,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad = false
);
/**
* Calculate error function coordination number.
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param cn Vector of coordination numbers.
* @return Exit status.
*/
extern int ncoord_erf(
const TMolecule &mol,
const TIVector &realIdx,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn
);
/**
* Calculate error function coordination number and derivative
* w.r.t. nuclear coordinates.
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param cn Vector of coordination numbers.
* @param dcndr Derivative of coordination number.
* @return Exit status.
*/
extern int dncoord_erf(
const TMolecule &mol,
const TIVector &realIdx,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr
);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/**
* Wrapper for error function coordination number for DFT-D4.
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param cn Vector of coordination numbers.
* @return Exit status.
*/
extern int get_ncoord_d4(
const TMolecule &mol,
const TIVector &realIdx,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad = false
);
/**
* Wrapper for error function coordination number for DFT-D4.
*
* @param mol Molecule object.
* @param dist Distance matrix.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param cn Vector of coordination numbers.
* @return Exit status.
*/
extern int get_ncoord_d4(
const TMolecule &mol,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad = false
);
/**
* Calculate covalent coordination number for DFT-D4.
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param cn Vector of coordination numbers.
* @return Exit status.
*/
extern int ncoord_d4(
const TMolecule &mol,
const TIVector &realIdx,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn
);
/**
* Calculate covalent coordination number and derivative
* w.r.t. nuclear coordinates
*
* @param mol Molecule object.
* @param realIdx List for real atoms excluding ghost/non atoms.
* @param dist Distance matrix.
* @param cutoff Real-space cutoff (default: @see {dftd_cutoff.h}).
* @param cn Vector of coordination numbers.
* @param dcndr Derivative of coordination number.
* @return Exit status.
*/
extern int dncoord_d4(
const TMolecule &mol,
const TIVector &realIdx,
const TMatrix<double> &dist,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr
);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/**
* Error function counting function for coordination number contributions.
*
* @param k Steepness of the counting function.
* @param rr Current distance over cutoff radius.
* @return Value of the counting function.
*/
extern double erf_count(double k, double rr);
/**
* Derivative of the counting function w.r.t. the distance.
*
* @param k Steepness of the counting function.
* @param rr TCutoff radius.
* @return Derivative of the counting function.
*/
extern double derf_count(double k, double rr);
/**
* TCutoff function for large coordination numbers
*
* @param cn_max Maximum CN (not strictly obeyed).
* @param cn On input coordination number, on output modified CN.
* @param dcndr On input derivative of CN w.r.t. cartesian coordinates,
* on output derivative of modified CN.
* @param lgrad Flag for gradient.
*/
extern int cut_coordination_number(
double cn_max,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad
);
extern inline double log_cn_cut(double cn_max, double cn);
extern inline double dlog_cn_cut(double cn_max, double cn);
} // namespace dftd4