AmoebaReferenceKernels.h 18.5 KB
Newer Older
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
#ifndef AMOEBA_OPENMM_REFERENCE_KERNELS_H_
#define AMOEBA_OPENMM_REFERENCE_KERNELS_H_

/* -------------------------------------------------------------------------- *
 *                              AmoebaOpenMM                                  *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors:                                                                   *
 * Contributors:                                                              *
 *                                                                            *
 * This program 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.                                        *
 *                                                                            *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.      *
 * -------------------------------------------------------------------------- */

#include "amoebaKernels.h"
#include "openmm/System.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"

namespace OpenMM {

/**
 * This kernel is invoked by AmoebaHarmonicBondForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaHarmonicBondForceKernel : public CalcAmoebaHarmonicBondForceKernel {
public:
    ReferenceCalcAmoebaHarmonicBondForceKernel(std::string name, 
                                               const Platform& platform,
                                               System& system);
    ~ReferenceCalcAmoebaHarmonicBondForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaHarmonicBondForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaHarmonicBondForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numBonds;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<RealOpenMM> length;
    std::vector<RealOpenMM> kQuadratic;
    RealOpenMM globalHarmonicBondCubic;
    RealOpenMM globalHarmonicBondQuartic;
    System& system;
};

/**
 * This kernel is invoked by AmoebaHarmonicAngleForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaHarmonicAngleForceKernel : public CalcAmoebaHarmonicAngleForceKernel {
public:
    ReferenceCalcAmoebaHarmonicAngleForceKernel(std::string name, const Platform& platform, System& system);
    ~ReferenceCalcAmoebaHarmonicAngleForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaHarmonicAngleForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaHarmonicAngleForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numAngles;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<RealOpenMM> angle;
    std::vector<RealOpenMM> kQuadratic;
    RealOpenMM globalHarmonicAngleCubic;
    RealOpenMM globalHarmonicAngleQuartic;
    RealOpenMM globalHarmonicAnglePentic;
    RealOpenMM globalHarmonicAngleSextic;
    System& system;
};

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
/**
 * This kernel is invoked by AmoebaHarmonicInPlaneAngleForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaHarmonicInPlaneAngleForceKernel : public CalcAmoebaHarmonicInPlaneAngleForceKernel {
public:
    ReferenceCalcAmoebaHarmonicInPlaneAngleForceKernel(std::string name, const Platform& platform, System& system);
    ~ReferenceCalcAmoebaHarmonicInPlaneAngleForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaHarmonicInPlaneAngleForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaHarmonicInPlaneAngleForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numAngles;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
    std::vector<RealOpenMM> angle;
    std::vector<RealOpenMM> kQuadratic;
    RealOpenMM globalHarmonicInPlaneAngleCubic;
    RealOpenMM globalHarmonicInPlaneAngleQuartic;
    RealOpenMM globalHarmonicInPlaneAnglePentic;
    RealOpenMM globalHarmonicInPlaneAngleSextic;
    System& system;
};

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
/**
 * This kernel is invoked by AmoebaTorsionForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaTorsionForceKernel : public CalcAmoebaTorsionForceKernel {
public:
    ReferenceCalcAmoebaTorsionForceKernel(std::string name, const Platform& platform, System& system);
    ~ReferenceCalcAmoebaTorsionForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaTorsionForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaTorsionForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numTorsions;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
    std::vector< std::vector<RealOpenMM> > torsionParameters1;
    std::vector< std::vector<RealOpenMM> > torsionParameters2;
    std::vector< std::vector<RealOpenMM> > torsionParameters3;
    System& system;
};

/**
 * This kernel is invoked by AmoebaPiTorsionForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaPiTorsionForceKernel : public CalcAmoebaPiTorsionForceKernel {
public:
    ReferenceCalcAmoebaPiTorsionForceKernel(std::string name, const Platform& platform, System& system);
    ~ReferenceCalcAmoebaPiTorsionForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaPiTorsionForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaPiTorsionForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numPiTorsions;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
    std::vector<int>   particle5;
    std::vector<int>   particle6;
    std::vector<RealOpenMM> kTorsion;
    System& system;
};

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
/**
 * This kernel is invoked by AmoebaStretchBendForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaStretchBendForceKernel : public CalcAmoebaStretchBendForceKernel {
public:
    ReferenceCalcAmoebaStretchBendForceKernel(std::string name, const Platform& platform, System& system);
    ~ReferenceCalcAmoebaStretchBendForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaStretchBendForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaStretchBendForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numStretchBends;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<RealOpenMM> lengthABParameters;
    std::vector<RealOpenMM> lengthCBParameters;
    std::vector<RealOpenMM> angleParameters;
    std::vector<RealOpenMM> kParameters;
    System& system;
};
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

/**
 * This kernel is invoked by AmoebaOutOfPlaneBendForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaOutOfPlaneBendForceKernel : public CalcAmoebaOutOfPlaneBendForceKernel {
public:
    ReferenceCalcAmoebaOutOfPlaneBendForceKernel(std::string name, const Platform& platform, System& system);
    ~ReferenceCalcAmoebaOutOfPlaneBendForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the AmoebaOutOfPlaneBendForce this kernel will be used for
     */
    void initialize(const System& system, const AmoebaOutOfPlaneBendForce& force);
    /**
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
     */
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
    int numOutOfPlaneBends;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
    std::vector<RealOpenMM> kParameters;
    RealOpenMM globalOutOfPlaneBendAngleCubic;
    RealOpenMM globalOutOfPlaneBendAngleQuartic;
    RealOpenMM globalOutOfPlaneBendAnglePentic;
    RealOpenMM globalOutOfPlaneBendAngleSextic;
    System& system;
};

289
290
291
292
293
// /**
//  * This kernel is invoked by AmoebaTorsionTorsionForce to calculate the forces acting on the system and the energy of the system.
//  */
// class ReferenceCalcAmoebaTorsionTorsionForceKernel : public CalcAmoebaTorsionTorsionForceKernel {
// public:
294
//     ReferenceCalcAmoebaTorsionTorsionForceKernel(std::string name, const Platform& platform, System& system);
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//     ~ReferenceCalcAmoebaTorsionTorsionForceKernel();
//     /**
//      * Initialize the kernel.
//      * 
//      * @param system     the System this kernel will be applied to
//      * @param force      the AmoebaTorsionTorsionForce this kernel will be used for
//      */
//     void initialize(const System& system, const AmoebaTorsionTorsionForce& force);
//     /**
//      * Execute the kernel to calculate the forces and/or energy.
//      *
//      * @param context        the context in which to execute this kernel
//      * @param includeForces  true if forces should be calculated
//      * @param includeEnergy  true if the energy should be calculated
//      * @return the potential energy due to the force
//      */
//     double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
// private:
//     int numTorsionTorsions;
//     int numTorsionTorsionGrids;
//     System& system;
// };
// 
// /**
//  * This kernel is invoked by AmoebaMultipoleForce to calculate the forces acting on the system and the energy of the system.
//  */
// class ReferenceCalcAmoebaMultipoleForceKernel : public CalcAmoebaMultipoleForceKernel {
// public:
323
//     ReferenceCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, System& system);
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
//     ~ReferenceCalcAmoebaMultipoleForceKernel();
//     /**
//      * Initialize the kernel.
//      * 
//      * @param system     the System this kernel will be applied to
//      * @param force      the AmoebaMultipoleForce this kernel will be used for
//      */
//     void initialize(const System& system, const AmoebaMultipoleForce& force);
//     /**
//      * Execute the kernel to calculate the forces and/or energy.
//      *
//      * @param context        the context in which to execute this kernel
//      * @param includeForces  true if forces should be calculated
//      * @param includeEnergy  true if the energy should be calculated
//      * @return the potential energy due to the force
//      */
//     double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
// private:
//     int numMultipoles;
//     System& system;
// };
// 
// /**
//  * This kernel is invoked by AmoebaMultipoleForce to calculate the forces acting on the system and the energy of the system.
//  */
// class ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel : public CalcAmoebaGeneralizedKirkwoodForceKernel {
// public:
351
//     ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel(std::string name, const Platform& platform, System& system);
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
//     ~ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel();
//     /**
//      * Initialize the kernel.
//      * 
//      * @param system     the System this kernel will be applied to
//      * @param force      the AmoebaMultipoleForce this kernel will be used for
//      */
//     void initialize(const System& system, const AmoebaGeneralizedKirkwoodForce& force);
//     /**
//      * Execute the kernel to calculate the forces and/or energy.
//      *
//      * @param context        the context in which to execute this kernel
//      * @param includeForces  true if forces should be calculated
//      * @param includeEnergy  true if the energy should be calculated
//      * @return the potential energy due to the force
//      */
//     double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
// private:
//     System& system;
// };
// 
// /**
//  * This kernel is invoked to calculate the vdw forces acting on the system and the energy of the system.
//  */
// class ReferenceCalcAmoebaVdwForceKernel : public CalcAmoebaVdwForceKernel {
// public:
378
//     ReferenceCalcAmoebaVdwForceKernel(std::string name, const Platform& platform, System& system);
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
//     ~ReferenceCalcAmoebaVdwForceKernel();
//     /**
//      * Initialize the kernel.
//      * 
//      * @param system     the System this kernel will be applied to
//      * @param force      the AmoebaMultipoleForce this kernel will be used for
//      */
//     void initialize(const System& system, const AmoebaVdwForce& force);
//     /**
//      * Execute the kernel to calculate the forces and/or energy.
//      *
//      * @param context        the context in which to execute this kernel
//      * @param includeForces  true if forces should be calculated
//      * @param includeEnergy  true if the energy should be calculated
//      * @return the potential energy due to the force
//      */
//     double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
// private:
//     System& system;
// };
// 
// /**
//  * This kernel is invoked to calculate the WCA dispersion forces acting on the system and the energy of the system.
//  */
// class ReferenceCalcAmoebaWcaDispersionForceKernel : public CalcAmoebaWcaDispersionForceKernel {
// public:
405
//     ReferenceCalcAmoebaWcaDispersionForceKernel(std::string name, const Platform& platform, System& system);
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
//     ~ReferenceCalcAmoebaWcaDispersionForceKernel();
//     /**
//      * Initialize the kernel.
//      * 
//      * @param system     the System this kernel will be applied to
//      * @param force      the AmoebaMultipoleForce this kernel will be used for
//      */
//     void initialize(const System& system, const AmoebaWcaDispersionForce& force);
//     /**
//      * Execute the kernel to calculate the forces and/or energy.
//      *
//      * @param context        the context in which to execute this kernel
//      * @param includeForces  true if forces should be calculated
//      * @param includeEnergy  true if the energy should be calculated
//      * @return the potential energy due to the force
//      */
//     double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
// private:
//     System& system;
// };

} // namespace OpenMM

#endif /*AMOEBA_OPENMM_REFERENCE_KERNELS_H*/