OpenMD
3.2
Molecular Dynamics in the Open
Toggle main menu visibility
Loading...
Searching...
No Matches
TimeCorrFunc.hpp
1
/*
2
* Copyright (c) 2004-present, The University of Notre Dame. All rights
3
* reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
*
11
* 2. Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
*
15
* 3. Neither the name of the copyright holder nor the names of its
16
* contributors may be used to endorse or promote products derived from
17
* this software without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
* POSSIBILITY OF SUCH DAMAGE.
30
*
31
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32
* research, please cite the following paper when you publish your work:
33
*
34
* [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35
*
36
* Good starting points for code and simulation methodology are:
37
*
38
* [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39
* [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40
* [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42
* [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43
* [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44
* [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45
* [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46
*/
47
48
#ifndef APPLICATIONS_DYNAMICPROPS_TIMECORRFUNC_HPP
49
#define APPLICATIONS_DYNAMICPROPS_TIMECORRFUNC_HPP
50
51
#include <string>
52
#include <vector>
53
54
#include "applications/dynamicProps/DynamicProperty.hpp"
55
#include "
brains/SimInfo.hpp
"
56
#include "
io/DumpReader.hpp
"
57
#include "
primitives/StuntDouble.hpp
"
58
#include "selection/SelectionEvaluator.hpp"
59
#include "selection/SelectionManager.hpp"
60
#include "utils/ProgressBar.hpp"
61
62
namespace
OpenMD
{
63
64
//! Computes a correlation function by scanning a trajectory once to
65
//! precompute quantities to be correlated
66
67
template
<
typename
T>
68
class
TimeCorrFunc :
public
DynamicProperty {
69
public
:
70
TimeCorrFunc(
SimInfo
* info,
const
std::string& filename,
71
const
std::string& sele1,
const
std::string& sele2);
72
73
virtual
~TimeCorrFunc() {
delete
reader_; }
74
virtual
void
doCorrelate();
75
76
const
std::string& getCorrFuncType()
const
{
return
corrFuncType_; }
77
78
void
setCorrFuncType(
const
std::string& type) { corrFuncType_ = type; }
79
80
void
setParameterString(
const
std::string& params) {
81
paramString_ = params;
82
}
83
84
void
setLabelString(
const
std::string& label) { labelString_ = label; }
85
86
protected
:
87
virtual
void
preCorrelate();
88
virtual
void
correlation();
89
virtual
void
postCorrelate();
90
virtual
void
computeFrame(
int
frame);
91
virtual
void
validateSelection(
SelectionManager
& seleMan);
92
virtual
void
correlateFrames(
int
frame1,
int
frame2,
int
timeBin);
93
virtual
void
writeCorrelate();
94
95
// The pure virtual functions that must be implemented.
96
97
// For System Properties:
98
virtual
void
computeProperty1(
int
frame) = 0;
99
virtual
void
computeProperty2(
int
frame) = 0;
100
virtual
T calcCorrVal(
int
frame1,
int
frame2) = 0;
101
// For Molecular Properties
102
virtual
int
computeProperty1(
int
frame,
Molecule
* mol) = 0;
103
virtual
int
computeProperty2(
int
frame,
Molecule
* mol) = 0;
104
// For Object
105
virtual
int
computeProperty1(
int
frame,
StuntDouble
* sd) = 0;
106
virtual
int
computeProperty2(
int
frame,
StuntDouble
* sd) = 0;
107
// For Bond properties
108
virtual
int
computeProperty1(
int
frame,
Bond
* b) = 0;
109
virtual
int
computeProperty2(
int
frame,
Bond
* b) = 0;
110
// For everything except System properties:
111
virtual
T calcCorrVal(
int
frame1,
int
frame2,
int
id1,
int
id2) = 0;
112
113
RealType deltaTime_;
114
unsigned
int
nTimeBins_;
115
int
nFrames_;
116
std::vector<T> histogram_;
117
std::vector<int> count_;
118
std::vector<RealType> times_;
119
RealType dtMean_ {};
120
RealType dtSigma_ {};
121
122
SimInfo
* info_ {
nullptr
};
123
DumpReader
* reader_;
124
std::string dumpFilename_;
125
SelectionManager
seleMan1_;
126
SelectionManager
seleMan2_;
127
128
Snapshot
* currentSnapshot_;
129
130
std::string selectionScript1_;
131
std::string selectionScript2_;
132
133
SelectionEvaluator
evaluator1_;
134
SelectionEvaluator
evaluator2_;
135
136
bool
uniqueSelections_;
137
bool
autoCorrFunc_;
138
bool
doSystemProperties_;
139
bool
doMolecularProperties_;
140
bool
doObjectProperties_;
141
bool
doAtomicProperties_;
142
bool
doBondProperties_;
143
bool
allowTimeFuzz_;
144
145
std::string corrFuncType_;
146
std::string paramString_;
147
std::string labelString_;
148
149
std::vector<std::vector<int>> sele1ToIndex_;
150
std::vector<std::vector<int>> sele2ToIndex_;
151
152
ProgressBarPtr progressBar_;
153
};
154
155
template
<
typename
T>
156
class
AutoCorrFunc :
public
TimeCorrFunc<T> {
157
public
:
158
AutoCorrFunc(
SimInfo
* info,
const
std::string& filename,
159
const
std::string& sele1,
const
std::string& sele2);
160
161
protected
:
162
virtual
void
computeProperty1(
int
frame) = 0;
163
virtual
int
computeProperty1(
int
frame,
Molecule
* mol) = 0;
164
virtual
int
computeProperty1(
int
frame,
StuntDouble
* sd) = 0;
165
virtual
int
computeProperty1(
int
frame,
Bond
* bond) = 0;
166
167
virtual
void
computeProperty2(
int
) {}
168
virtual
int
computeProperty2(
int
,
Molecule
*) {
return
-1; }
169
virtual
int
computeProperty2(
int
,
StuntDouble
*) {
return
-1; }
170
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
171
};
172
173
template
<
typename
T>
174
class
CrossCorrFunc :
public
TimeCorrFunc<T> {
175
public
:
176
CrossCorrFunc(
SimInfo
* info,
const
std::string& filename,
177
const
std::string& sele1,
const
std::string& sele2);
178
179
protected
:
180
virtual
void
computeProperty1(
int
frame) = 0;
181
virtual
int
computeProperty1(
int
frame,
Molecule
* mol) = 0;
182
virtual
int
computeProperty1(
int
frame,
StuntDouble
* sd) = 0;
183
virtual
int
computeProperty1(
int
frame,
Bond
* bond) = 0;
184
virtual
void
computeProperty2(
int
frame) = 0;
185
virtual
int
computeProperty2(
int
frame,
Molecule
* mol) = 0;
186
virtual
int
computeProperty2(
int
frame,
StuntDouble
* sd) = 0;
187
virtual
int
computeProperty2(
int
frame,
Bond
* bond) = 0;
188
};
189
190
template
<
typename
T>
191
class
SystemACF :
public
AutoCorrFunc<T> {
192
public
:
193
SystemACF(
SimInfo
* info,
const
std::string& filename,
194
const
std::string& sele1,
const
std::string& sele2);
195
196
protected
:
197
virtual
void
computeProperty1(
int
frame) = 0;
198
virtual
T calcCorrVal(
int
frame1,
int
frame2) = 0;
199
200
virtual
int
computeProperty1(
int
,
Molecule
*) {
return
-1; }
201
virtual
int
computeProperty1(
int
,
StuntDouble
*) {
return
-1; }
202
virtual
int
computeProperty1(
int
,
Bond
*) {
return
-1; }
203
204
virtual
void
computeProperty2(
int
) {}
205
virtual
int
computeProperty2(
int
,
Molecule
*) {
return
-1; }
206
virtual
int
computeProperty2(
int
,
StuntDouble
*) {
return
-1; }
207
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
208
209
T calcCorrVal(
int
,
int
,
int
,
int
) {
return
T(0.0); }
210
};
211
212
template
<
typename
T>
213
class
SystemCCF :
public
CrossCorrFunc<T> {
214
public
:
215
SystemCCF(
SimInfo
* info,
const
std::string& filename,
216
const
std::string& sele1,
const
std::string& sele2);
217
218
protected
:
219
virtual
void
computeProperty1(
int
frame) = 0;
220
virtual
void
computeProperty2(
int
frame) = 0;
221
virtual
T calcCorrVal(
int
frame1,
int
frame2) = 0;
222
223
virtual
int
computeProperty1(
int
,
Molecule
*) {
return
-1; }
224
virtual
int
computeProperty1(
int
,
StuntDouble
*) {
return
-1; }
225
virtual
int
computeProperty1(
int
,
Bond
*) {
return
-1; }
226
227
virtual
int
computeProperty2(
int
,
Molecule
*) {
return
-1; }
228
virtual
int
computeProperty2(
int
,
StuntDouble
*) {
return
-1; }
229
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
230
231
T calcCorrVal(
int
,
int
,
int
,
int
) {
return
T(0.0); }
232
};
233
234
template
<
typename
T>
235
class
ObjectACF :
public
AutoCorrFunc<T> {
236
public
:
237
ObjectACF(
SimInfo
* info,
const
std::string& filename,
238
const
std::string& sele1,
const
std::string& sele2);
239
240
protected
:
241
virtual
int
computeProperty1(
int
frame,
StuntDouble
* sd) = 0;
242
virtual
T calcCorrVal(
int
frame1,
int
frame2,
int
id1,
int
id2) = 0;
243
244
virtual
void
computeProperty1(
int
) {
return
; }
245
virtual
int
computeProperty1(
int
,
Molecule
*) {
return
-1; }
246
virtual
int
computeProperty1(
int
,
Bond
*) {
return
-1; }
247
248
virtual
void
computeProperty2(
int
) {
return
; }
249
virtual
int
computeProperty2(
int
,
Molecule
*) {
return
-1; }
250
virtual
int
computeProperty2(
int
,
StuntDouble
*) {
return
-1; }
251
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
252
253
virtual
T calcCorrVal(
int
,
int
) {
return
T(0.0); }
254
};
255
256
template
<
typename
T>
257
class
ObjectCCF :
public
CrossCorrFunc<T> {
258
public
:
259
ObjectCCF(
SimInfo
* info,
const
std::string& filename,
260
const
std::string& sele1,
const
std::string& sele2);
261
262
protected
:
263
virtual
int
computeProperty1(
int
frame,
StuntDouble
* sd) = 0;
264
virtual
int
computeProperty2(
int
frame,
StuntDouble
* sd) = 0;
265
virtual
T calcCorrVal(
int
frame1,
int
frame2,
int
id1,
int
id2) = 0;
266
267
virtual
void
computeProperty1(
int
) {
return
; }
268
virtual
int
computeProperty1(
int
,
Molecule
*) {
return
-1; }
269
virtual
int
computeProperty1(
int
,
Bond
*) {
return
-1; }
270
271
virtual
void
computeProperty2(
int
) {}
272
virtual
int
computeProperty2(
int
,
Molecule
*) {
return
-1; }
273
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
274
275
virtual
T calcCorrVal(
int
,
int
) {
return
T(0.0); }
276
};
277
278
template
<
typename
T>
279
class
MoleculeACF :
public
AutoCorrFunc<T> {
280
public
:
281
MoleculeACF(
SimInfo
* info,
const
std::string& filename,
282
const
std::string& sele1,
const
std::string& sele2);
283
284
protected
:
285
virtual
int
computeProperty1(
int
frame,
Molecule
* mol) = 0;
286
virtual
T calcCorrVal(
int
frame1,
int
frame2,
int
id1,
int
id2) = 0;
287
288
virtual
void
computeProperty1(
int
) {
return
; }
289
virtual
int
computeProperty1(
int
,
StuntDouble
*) {
return
-1; }
290
virtual
int
computeProperty1(
int
,
Bond
*) {
return
-1; }
291
292
virtual
void
computeProperty2(
int
) {
return
; }
293
virtual
int
computeProperty2(
int
,
Molecule
*) {
return
-1; }
294
virtual
int
computeProperty2(
int
,
StuntDouble
*) {
return
-1; }
295
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
296
297
virtual
T calcCorrVal(
int
,
int
) {
return
T(0.0); }
298
};
299
300
template
<
typename
T>
301
class
MoleculeCCF :
public
CrossCorrFunc<T> {
302
public
:
303
MoleculeCCF(
SimInfo
* info,
const
std::string& filename,
304
const
std::string& sele1,
const
std::string& sele2);
305
306
protected
:
307
virtual
int
computeProperty1(
int
frame,
Molecule
* mol) = 0;
308
virtual
int
computeProperty2(
int
frame,
Molecule
* mol) = 0;
309
virtual
T calcCorrVal(
int
frame1,
int
frame2,
int
id1,
int
id2) = 0;
310
311
virtual
void
computeProperty1(
int
) {
return
; }
312
virtual
int
computeProperty1(
int
,
StuntDouble
*) {
return
-1; }
313
virtual
int
computeProperty1(
int
,
Bond
*) {
return
-1; }
314
315
virtual
void
computeProperty2(
int
) {}
316
virtual
int
computeProperty2(
int
,
StuntDouble
*) {
return
-1; }
317
virtual
int
computeProperty2(
int
,
Bond
*) {
return
-1; }
318
319
virtual
T calcCorrVal(
int
,
int
) {
return
T(0.0); }
320
};
321
}
// namespace OpenMD
322
323
#endif
DumpReader.hpp
SimInfo.hpp
StuntDouble.hpp
OpenMD::Bond
Definition
Bond.hpp:64
OpenMD::DumpReader
Definition
DumpReader.hpp:70
OpenMD::Molecule
Definition
Molecule.hpp:81
OpenMD::SelectionEvaluator
"selection/SelectionEvaluator"
Definition
SelectionEvaluator.hpp:76
OpenMD::SelectionManager
Definition
SelectionManager.hpp:62
OpenMD::SimInfo
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition
SimInfo.hpp:96
OpenMD::Snapshot
The Snapshot class is a repository storing dynamic data during a Simulation.
Definition
Snapshot.hpp:166
OpenMD::StuntDouble
"Don't move, or you're dead! Stand up! Captain, we've got them!"
Definition
StuntDouble.hpp:94
OpenMD
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Definition
ActionCorrFunc.cpp:63
applications
dynamicProps
save
TimeCorrFunc.hpp
Generated on
for OpenMD by
1.17.0