AmoebaReferenceKernels.h 29.7 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-2020 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
#include "openmm/AmoebaMultipoleForce.h"
peastman's avatar
peastman committed
33
#include "openmm/HippoNonbondedForce.h"
34
#include "AmoebaReferenceMultipoleForce.h"
peastman's avatar
peastman committed
35
#include "AmoebaReferenceHippoNonbondedForce.h"
36
#include "AmoebaReferenceVdwForce.h"
37
38
#include "ReferenceNeighborList.h"
#include "SimTKOpenMMRealType.h"
39
40
41
42

namespace OpenMM {

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

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

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

177
178
179
180
181
/**
 * 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:
182
    ReferenceCalcAmoebaPiTorsionForceKernel(const std::string& name, const Platform& platform, const System& system);
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
    ~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);
200
201
202
203
204
205
206
    /**
     * 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);
207
208
209
210
211
212
213
214
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
215
    std::vector<double> kTorsion;
216
    const System& system;
217
    bool usePeriodic;
218
219
};

220
221
222
223
224
/**
 * 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:
225
    ReferenceCalcAmoebaStretchBendForceKernel(const std::string& name, const Platform& platform, const System& system);
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
    ~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);
243
244
245
246
247
248
249
    /**
     * 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);
250
251
252
253
254
private:
    int numStretchBends;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
peastman's avatar
peastman committed
255
256
257
258
259
    std::vector<double> lengthABParameters;
    std::vector<double> lengthCBParameters;
    std::vector<double> angleParameters;
    std::vector<double> k1Parameters;
    std::vector<double> k2Parameters;
260
    const System& system;
261
    bool usePeriodic;
262
};
263
264
265
266
267
268

/**
 * 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:
269
    ReferenceCalcAmoebaOutOfPlaneBendForceKernel(const std::string& name, const Platform& platform, const System& system);
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
    ~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);
287
288
289
290
291
292
293
    /**
     * 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);
294
295
296
297
298
299
private:
    int numOutOfPlaneBends;
    std::vector<int>   particle1;
    std::vector<int>   particle2;
    std::vector<int>   particle3;
    std::vector<int>   particle4;
peastman's avatar
peastman committed
300
301
302
303
304
    std::vector<double> kParameters;
    double globalOutOfPlaneBendAngleCubic;
    double globalOutOfPlaneBendAngleQuartic;
    double globalOutOfPlaneBendAnglePentic;
    double globalOutOfPlaneBendAngleSextic;
305
    const System& system;
306
    bool usePeriodic;
307
308
};

309
310
311
312
313
/**
 * 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:
314
    ReferenceCalcAmoebaTorsionTorsionForceKernel(const std::string& name, const Platform& platform, const System& system);
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
340
341
342
    ~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
343
    std::vector< std::vector< std::vector< std::vector<double> > > > torsionTorsionGrids;
344

345
    const System& system;
346
    bool usePeriodic;
347
348
};

349
350
351
352
353
/**
 * 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:
354
    ReferenceCalcAmoebaMultipoleForceKernel(const std::string& name, const Platform& platform, const System& system);
355
356
357
358
359
360
361
362
    ~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);
363
364
365
366
367
368
369
    /**
     * Setup for AmoebaReferenceMultipoleForce instance. 
     *
     * @param context        the current context
     *
     * @return pointer to initialized instance of AmoebaReferenceMultipoleForce
     */
370
    AmoebaReferenceMultipoleForce* setupAmoebaReferenceMultipoleForce(ContextImpl& context);
371
372
373
374
375
376
377
378
379
    /**
     * 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);
380
381
382
383
384
385
386
    /**
     * 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);
387
    /**
388
389
390
391
392
     * 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
     */
393
    void getLabFramePermanentDipoles(ContextImpl& context, std::vector<Vec3>& dipoles);
394
395
396
397
398
399
400
    /**
     * 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);
401
    /** 
402
     * Calculate the electrostatic potential given vector of grid coordinates.
403
     *
404
405
     * @param context                      context
     * @param inputGrid                    input grid coordinates
406
407
408
     * @param outputElectrostaticPotential output potential 
     */
    void getElectrostaticPotential(ContextImpl& context, const std::vector< Vec3 >& inputGrid,
409
                                   std::vector< double >& outputElectrostaticPotential);
410
411

    /**
412
     * Get the system multipole moments.
413
     *
414
     * @param context                context 
415
     * @param outputMultipoleMoments vector of multipole moments:
416
                                     (charge,
417
418
419
                                      dipole_x, dipole_y, dipole_z,
                                      quadrupole_xx, quadrupole_xy, quadrupole_xz,
                                      quadrupole_yx, quadrupole_yy, quadrupole_yz,
420
                                      quadrupole_zx, quadrupole_zy, quadrupole_zz)
421
     */
Lee-Ping Wang's avatar
Lee-Ping Wang committed
422
    void getSystemMultipoleMoments(ContextImpl& context, std::vector< double >& outputMultipoleMoments);
423
424
425
426
427
428
429
    /**
     * 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);
430
431
432
433
434
435
436
437
438
    /**
     * 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;
439

440
private:
441

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

    int mutualInducedMaxIterations;
peastman's avatar
peastman committed
458
    double mutualInducedTargetEpsilon;
459
    std::vector<double> extrapolationCoefficients;
460

461
    bool usePme;
peastman's avatar
peastman committed
462
463
    double alphaEwald;
    double cutoffDistance;
464
465
    std::vector<int> pmeGridDimension;

466
    const System& system;
467
468
};

Mark Friedrichs's avatar
Mark Friedrichs committed
469
470
471
472
473
/**
 * This kernel is invoked to calculate the vdw forces acting on the system and the energy of the system.
 */
class ReferenceCalcAmoebaVdwForceKernel : public CalcAmoebaVdwForceKernel {
public:
474
    ReferenceCalcAmoebaVdwForceKernel(const std::string& name, const Platform& platform, const System& system);
Mark Friedrichs's avatar
Mark Friedrichs committed
475
476
477
478
479
    ~ReferenceCalcAmoebaVdwForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
480
     * @param force      the AmoebaVdwForce this kernel will be used for
Mark Friedrichs's avatar
Mark Friedrichs committed
481
482
483
484
485
486
487
488
489
490
491
     */
    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);
492
493
494
495
496
497
498
    /**
     * 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
499
500
private:
    int numParticles;
501
    int useCutoff;
502
503
    int usePBC;
    double cutoff;
504
    double dispersionCoefficient;
505
    AmoebaReferenceVdwForce vdwForce;
506
    const System& system;
507
    NeighborList* neighborList;
Mark Friedrichs's avatar
Mark Friedrichs committed
508
509
};

Mark Friedrichs's avatar
Mark Friedrichs committed
510
511
512
513
514
/**
 * 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:
515
    ReferenceCalcAmoebaWcaDispersionForceKernel(const std::string& name, const Platform& platform, const System& system);
Mark Friedrichs's avatar
Mark Friedrichs committed
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
    ~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);
533
534
535
536
537
538
539
    /**
     * 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
540
541
542
private:

    int numParticles;
peastman's avatar
peastman committed
543
544
545
546
547
548
549
550
551
552
553
    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;
554
    const System& system;
Mark Friedrichs's avatar
Mark Friedrichs committed
555
};
556

557
558
559
560
561
/**
 * 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:
562
    ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel(const std::string& name, const Platform& platform, const System& system);
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
    ~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);
 
    /**
582
     *  Get the 'include cavity term' flag.
583
584
585
     *
     *  @return includeCavityTerm
     */
586
    int getIncludeCavityTerm() const;
587
588

    /**
589
     *  Get the number of particles.
590
591
592
     *
     *  @return number of particles
     */
593
    int getNumParticles() const;
594
595

    /**
596
     *  Get Direct Polarization flag.
597
598
599
600
     *
     *  @return directPolarization
     *
     */
601
    int getDirectPolarization() const;
602
603

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

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

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

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

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

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

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

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

667
668
669
670
671
672
673
674
    /**
     * 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);

675
676
677
private:

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

peastman's avatar
peastman committed
691
692
693
694
695
/**
 * This kernel is invoked by HippoNonbondedForce to calculate the forces acting on the system and the energy of the system.
 */
class ReferenceCalcHippoNonbondedForceKernel : public CalcHippoNonbondedForceKernel {
public:
696
    ReferenceCalcHippoNonbondedForceKernel(const std::string& name, const Platform& platform, const System& system);
peastman's avatar
peastman committed
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
    ~ReferenceCalcHippoNonbondedForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the HippoNonbondedForce this kernel will be used for
     */
    void initialize(const System& system, const HippoNonbondedForce& force);
    /**
     * Setup for AmoebaReferenceHippoNonbondedForce instance. 
     *
     * @param context        the current context
     *
     * @return pointer to initialized instance of AmoebaReferenceHippoNonbondedForce
     */
    void setupAmoebaReferenceHippoNonbondedForce(ContextImpl& context);
    /**
     * 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);
    /**
     * 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);
    /**
     * 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
     */
    void getLabFramePermanentDipoles(ContextImpl& context, std::vector<Vec3>& dipoles);
    /**
     * 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);
    /**
     * Copy changed parameters over to a context.
     *
     * @param context    the context to copy parameters to
     * @param force      the HippoNonbondedForce to copy the parameters from
     */
    void copyParametersToContext(ContextImpl& context, const HippoNonbondedForce& force);
    /**
     * 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;
    /**
     * Get the parameters being used for dispersion 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 getDPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;

private:

    AmoebaReferenceHippoNonbondedForce* ixn;
    int numParticles;
};

775
776
777
} // namespace OpenMM

#endif /*AMOEBA_OPENMM_REFERENCE_KERNELS_H*/