AmoebaReferenceKernels.h 26.2 KB
Newer Older
1
2
3
4
#ifndef AMOEBA_OPENMM_REFERENCE_KERNELS_H_
#define AMOEBA_OPENMM_REFERENCE_KERNELS_H_

/* -------------------------------------------------------------------------- *
5
 *                              OpenMMAmoeba                                  *
6
7
8
9
10
11
 * -------------------------------------------------------------------------- *
 * 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.               *
 *                                                                            *
12
 * Portions copyright (c) 2008-2015 Stanford University and the Authors.      *
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 * 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 "openmm/System.h"
31
#include "openmm/amoebaKernels.h"
32
33
#include "openmm/AmoebaMultipoleForce.h"
#include "AmoebaReferenceMultipoleForce.h"
34
35
#include "ReferenceNeighborList.h"
#include "SimTKOpenMMRealType.h"
36
37
38
39

namespace OpenMM {

/**
40
 * This kernel is invoked by AmoebaBondForce to calculate the forces acting on the system and the energy of the system.
41
 */
42
class ReferenceCalcAmoebaBondForceKernel : public CalcAmoebaBondForceKernel {
43
public:
44
    ReferenceCalcAmoebaBondForceKernel(std::string name, 
45
                                               const Platform& platform,
46
                                               const System& system);
47
    ~ReferenceCalcAmoebaBondForceKernel();
48
49
50
51
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
52
     * @param force      the AmoebaBondForce this kernel will be used for
53
     */
54
    void initialize(const System& system, const AmoebaBondForce& force);
55
56
57
58
59
60
61
62
63
    /**
     * 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);
64
65
66
67
68
69
70
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaBondForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaBondForce& force);
71
72
73
74
private:
    int numBonds;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
peastman's avatar
peastman committed
75
76
77
78
    std::vector<double> length;
    std::vector<double> kQuadratic;
    double globalBondCubic;
    double globalBondQuartic;
79
    const System& system;
80
    bool usePeriodic;
81
82
83
};

/**
84
 * This kernel is invoked by AmoebaAngleForce to calculate the forces acting on the system and the energy of the system.
85
 */
86
class ReferenceCalcAmoebaAngleForceKernel : public CalcAmoebaAngleForceKernel {
87
public:
88
    ReferenceCalcAmoebaAngleForceKernel(std::string name, const Platform& platform, const System& system);
89
    ~ReferenceCalcAmoebaAngleForceKernel();
90
91
92
93
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
94
     * @param force      the AmoebaAngleForce this kernel will be used for
95
     */
96
    void initialize(const System& system, const AmoebaAngleForce& force);
97
98
99
100
101
102
103
104
105
    /**
     * 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);
106
107
108
109
110
111
112
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaAngleForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaAngleForce& force);
113
114
115
116
117
private:
    int numAngles;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
peastman's avatar
peastman committed
118
119
120
121
122
123
    std::vector<double> angle;
    std::vector<double> kQuadratic;
    double globalAngleCubic;
    double globalAngleQuartic;
    double globalAnglePentic;
    double globalAngleSextic;
124
    const System& system;
125
    bool usePeriodic;
126
127
};

128
/**
129
 * This kernel is invoked by AmoebaInPlaneAngleForce to calculate the forces acting on the system and the energy of the system.
130
 */
131
class ReferenceCalcAmoebaInPlaneAngleForceKernel : public CalcAmoebaInPlaneAngleForceKernel {
132
public:
133
    ReferenceCalcAmoebaInPlaneAngleForceKernel(std::string name, const Platform& platform, const System& system);
134
    ~ReferenceCalcAmoebaInPlaneAngleForceKernel();
135
136
137
138
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
139
     * @param force      the AmoebaInPlaneAngleForce this kernel will be used for
140
     */
141
    void initialize(const System& system, const AmoebaInPlaneAngleForce& force);
142
143
144
145
146
147
148
149
150
    /**
     * 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);
151
152
153
154
155
156
157
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaInPlaneAngleForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaInPlaneAngleForce& force);
158
159
160
161
162
163
private:
    int numAngles;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
peastman's avatar
peastman committed
164
165
166
167
168
169
    std::vector<double> angle;
    std::vector<double> kQuadratic;
    double globalInPlaneAngleCubic;
    double globalInPlaneAngleQuartic;
    double globalInPlaneAnglePentic;
    double globalInPlaneAngleSextic;
170
    const System& system;
171
    bool usePeriodic;
172
173
};

174
175
176
177
178
/**
 * 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:
179
    ReferenceCalcAmoebaPiTorsionForceKernel(std::string name, const Platform& platform, const System& system);
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    ~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);
197
198
199
200
201
202
203
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaPiTorsionForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaPiTorsionForce& force);
204
205
206
207
208
209
210
211
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;
peastman's avatar
peastman committed
212
    std::vector<double> kTorsion;
213
    const System& system;
214
    bool usePeriodic;
215
216
};

217
218
219
220
221
/**
 * 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:
222
    ReferenceCalcAmoebaStretchBendForceKernel(std::string name, const Platform& platform, const System& system);
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    ~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);
240
241
242
243
244
245
246
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaStretchBendForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaStretchBendForce& force);
247
248
249
250
251
private:
    int numStretchBends;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
peastman's avatar
peastman committed
252
253
254
255
256
    std::vector<double> lengthABParameters;
    std::vector<double> lengthCBParameters;
    std::vector<double> angleParameters;
    std::vector<double> k1Parameters;
    std::vector<double> k2Parameters;
257
    const System& system;
258
    bool usePeriodic;
259
};
260
261
262
263
264
265

/**
 * 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:
266
    ReferenceCalcAmoebaOutOfPlaneBendForceKernel(std::string name, const Platform& platform, const System& system);
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
    ~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);
284
285
286
287
288
289
290
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaOutOfPlaneBendForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaOutOfPlaneBendForce& force);
291
292
293
294
295
296
private:
    int numOutOfPlaneBends;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
peastman's avatar
peastman committed
297
298
299
300
301
    std::vector<double> kParameters;
    double globalOutOfPlaneBendAngleCubic;
    double globalOutOfPlaneBendAngleQuartic;
    double globalOutOfPlaneBendAnglePentic;
    double globalOutOfPlaneBendAngleSextic;
302
    const System& system;
303
    bool usePeriodic;
304
305
};

306
307
308
309
310
/**
 * 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:
311
    ReferenceCalcAmoebaTorsionTorsionForceKernel(std::string name, const Platform& platform, const System& system);
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
    ~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;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
    std::vector<int>   particle5;
    std::vector<int>   chiralCheckAtom;
    std::vector<int>   gridIndices;

    int numTorsionTorsionGrids;
peastman's avatar
peastman committed
340
    std::vector< std::vector< std::vector< std::vector<double> > > > torsionTorsionGrids;
341

342
    const System& system;
343
    bool usePeriodic;
344
345
};

346
347
348
349
350
/**
 * 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:
351
    ReferenceCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, const System& system);
352
353
354
355
356
357
358
359
    ~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);
360
361
362
363
364
365
366
    /**
     * Setup for AmoebaReferenceMultipoleForce instance. 
     *
     * @param context        the current context
     *
     * @return pointer to initialized instance of AmoebaReferenceMultipoleForce
     */
367
    AmoebaReferenceMultipoleForce* setupAmoebaReferenceMultipoleForce(ContextImpl& context);
368
369
370
371
372
373
374
375
376
    /**
     * 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);
377
378
379
380
381
382
383
    /**
     * Get the induced dipole moments of all particles.
     * 
     * @param context    the Context for which to get the induced dipoles
     * @param dipoles    the induced dipole moment of particle i is stored into the i'th element
     */
    void getInducedDipoles(ContextImpl& context, std::vector<Vec3>& dipoles);
384
    /**
385
386
387
388
389
     * Get the fixed dipole moments of all particles in the global reference frame.
     * 
     * @param context    the Context for which to get the fixed dipoles
     * @param dipoles    the fixed dipole moment of particle i is stored into the i'th element
     */
390
    void getLabFramePermanentDipoles(ContextImpl& context, std::vector<Vec3>& dipoles);
391
392
393
394
395
396
397
    /**
     * Get the total dipole moments of all particles in the global reference frame.
     * 
     * @param context    the Context for which to get the fixed dipoles
     * @param dipoles    the fixed dipole moment of particle i is stored into the i'th element
     */
    void getTotalDipoles(ContextImpl& context, std::vector<Vec3>& dipoles);
398
    /** 
399
     * Calculate the electrostatic potential given vector of grid coordinates.
400
     *
401
402
     * @param context                      context
     * @param inputGrid                    input grid coordinates
403
404
405
     * @param outputElectrostaticPotential output potential 
     */
    void getElectrostaticPotential(ContextImpl& context, const std::vector< Vec3 >& inputGrid,
406
                                   std::vector< double >& outputElectrostaticPotential);
407
408

    /**
409
     * Get the system multipole moments.
410
     *
411
     * @param context                context 
412
     * @param outputMultipoleMoments vector of multipole moments:
413
                                     (charge,
414
415
416
                                      dipole_x, dipole_y, dipole_z,
                                      quadrupole_xx, quadrupole_xy, quadrupole_xz,
                                      quadrupole_yx, quadrupole_yy, quadrupole_yz,
417
                                      quadrupole_zx, quadrupole_zy, quadrupole_zz)
418
     */
Lee-Ping Wang's avatar
Lee-Ping Wang committed
419
    void getSystemMultipoleMoments(ContextImpl& context, std::vector< double >& outputMultipoleMoments);
420
421
422
423
424
425
426
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaMultipoleForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaMultipoleForce& force);
427
428
429
430
431
432
433
434
435
    /**
     * Get the parameters being used for PME.
     * 
     * @param alpha   the separation parameter
     * @param nx      the number of grid points along the X axis
     * @param ny      the number of grid points along the Y axis
     * @param nz      the number of grid points along the Z axis
     */
    void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
436

437
private:
438

439
    int numMultipoles;
440
    AmoebaMultipoleForce::NonbondedMethod nonbondedMethod;
441
    AmoebaMultipoleForce::PolarizationType polarizationType;
peastman's avatar
peastman committed
442
443
444
445
446
447
    std::vector<double> charges;
    std::vector<double> dipoles;
    std::vector<double> quadrupoles;
    std::vector<double> tholes;
    std::vector<double> dampingFactors;
    std::vector<double> polarity;
448
    std::vector<int>   axisTypes;
449
450
451
    std::vector<int>   multipoleAtomZs;
    std::vector<int>   multipoleAtomXs;
    std::vector<int>   multipoleAtomYs;
452
453
454
    std::vector< std::vector< std::vector<int> > > multipoleAtomCovalentInfo;

    int mutualInducedMaxIterations;
peastman's avatar
peastman committed
455
    double mutualInducedTargetEpsilon;
456
    std::vector<double> extrapolationCoefficients;
457

458
    bool usePme;
peastman's avatar
peastman committed
459
460
    double alphaEwald;
    double cutoffDistance;
461
462
    std::vector<int> pmeGridDimension;

463
    const System& system;
464
465
};

Mark Friedrichs's avatar
Mark Friedrichs committed
466
467
468
469
470
/**
 * This kernel is invoked to calculate the vdw forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaVdwForceKernel : public CalcAmoebaVdwForceKernel {
public:
471
    ReferenceCalcAmoebaVdwForceKernel(std::string name, const Platform& platform, const System& system);
Mark Friedrichs's avatar
Mark Friedrichs committed
472
473
474
475
476
    ~ReferenceCalcAmoebaVdwForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
477
     * @param force      the AmoebaVdwForce this kernel will be used for
Mark Friedrichs's avatar
Mark Friedrichs committed
478
479
480
481
482
483
484
485
486
487
488
     */
    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);
489
490
491
492
493
494
495
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaVdwForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaVdwForce& force);
Mark Friedrichs's avatar
Mark Friedrichs committed
496
497
private:
    int numParticles;
498
    int useCutoff;
499
500
    int usePBC;
    double cutoff;
501
    double dispersionCoefficient;
Mark Friedrichs's avatar
Mark Friedrichs committed
502
    std::vector<int> indexIVs;
503
    std::vector< std::set<int> > allExclusions;
peastman's avatar
peastman committed
504
505
506
    std::vector<double> sigmas;
    std::vector<double> epsilons;
    std::vector<double> reductions;
Mark Friedrichs's avatar
Mark Friedrichs committed
507
508
    std::string sigmaCombiningRule;
    std::string epsilonCombiningRule;
509
    const System& system;
510
    NeighborList* neighborList;
Mark Friedrichs's avatar
Mark Friedrichs committed
511
512
};

Mark Friedrichs's avatar
Mark Friedrichs committed
513
514
515
516
517
/**
 * 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:
518
    ReferenceCalcAmoebaWcaDispersionForceKernel(std::string name, const Platform& platform, const System& system);
Mark Friedrichs's avatar
Mark Friedrichs committed
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
    ~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);
536
537
538
539
540
541
542
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaWcaDispersionForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaWcaDispersionForce& force);
Mark Friedrichs's avatar
Mark Friedrichs committed
543
544
545
private:

    int numParticles;
peastman's avatar
peastman committed
546
547
548
549
550
551
552
553
554
555
556
    std::vector<double> radii;
    std::vector<double> epsilons;
    double epso; 
    double epsh; 
    double rmino; 
    double rminh; 
    double awater; 
    double shctd; 
    double dispoff;
    double slevy;
    double totalMaximumDispersionEnergy;
557
    const System& system;
Mark Friedrichs's avatar
Mark Friedrichs committed
558
};
559

560
561
562
563
564
/**
 * This kernel is invoked to calculate the Gerneralized Kirkwood forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel : public CalcAmoebaGeneralizedKirkwoodForceKernel {
public:
565
    ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel(std::string name, const Platform& platform, const System& system);
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
    ~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);
 
    /**
585
     *  Get the 'include cavity term' flag.
586
587
588
     *
     *  @return includeCavityTerm
     */
589
    int getIncludeCavityTerm() const;
590
591

    /**
592
     *  Get the number of particles.
593
594
595
     *
     *  @return number of particles
     */
596
    int getNumParticles() const;
597
598

    /**
599
     *  Get Direct Polarization flag.
600
601
602
603
     *
     *  @return directPolarization
     *
     */
604
    int getDirectPolarization() const;
605
606

    /**
607
     *  Get the solute dielectric.
608
609
610
611
     *
     *  @return soluteDielectric
     *
     */
peastman's avatar
peastman committed
612
    double getSoluteDielectric() const;
613
614

    /**
615
     *  Get the solvent dielectric.
616
617
618
619
     *
     *  @return solventDielectric
     *
     */
peastman's avatar
peastman committed
620
    double getSolventDielectric() const;
621
622

    /**
623
     *  Get the dielectric offset.
624
625
626
627
     *
     *  @return dielectricOffset
     *
     */
peastman's avatar
peastman committed
628
    double getDielectricOffset() const;
629
630

    /**
631
     *  Get the probe radius.
632
633
634
635
     *
     *  @return probeRadius
     *
     */
peastman's avatar
peastman committed
636
    double getProbeRadius() const;
637
638

    /**
639
     *  Get the surface area factor.
640
641
642
643
     *
     *  @return surfaceAreaFactor
     *
     */
peastman's avatar
peastman committed
644
    double getSurfaceAreaFactor() const;
645
646

    /**
647
     *  Get the vector of particle radii.
648
649
650
651
     *
     *  @param atomicRadii vector of atomic radii
     *
     */
peastman's avatar
peastman committed
652
    void getAtomicRadii(std::vector<double>& atomicRadii) const;
653
654

    /**
655
     *  Get the vector of scale factors.
656
657
658
659
     *
     *  @param scaleFactors vector of scale factors
     *
     */
peastman's avatar
peastman committed
660
    void getScaleFactors(std::vector<double>& scaleFactors) const;
661
662

    /**
663
     *  Get the vector of charges.
664
665
666
667
     *
     *  @param charges vector of charges
     *
     */
peastman's avatar
peastman committed
668
    void getCharges(std::vector<double>& charges) const;
669

670
671
672
673
674
675
676
677
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the AmoebaGeneralizedKirkwoodForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const AmoebaGeneralizedKirkwoodForce& force);

678
679
680
private:

    int numParticles;
peastman's avatar
peastman committed
681
682
683
684
685
686
687
688
    std::vector<double> atomicRadii;
    std::vector<double> scaleFactors;
    std::vector<double> charges;
    double soluteDielectric;
    double solventDielectric;
    double dielectricOffset;
    double probeRadius;
    double surfaceAreaFactor;
689
690
    int includeCavityTerm;
    int directPolarization;
691
    const System& system;
692
693
};

694
695
696
} // namespace OpenMM

#endif /*AMOEBA_OPENMM_REFERENCE_KERNELS_H*/