View Javadoc
1   // ******************************************************************************
2   //
3   // Title:       Force Field X.
4   // Description: Force Field X - Software for Molecular Biophysics.
5   // Copyright:   Copyright (c) Michael J. Schnieders 2001-2025.
6   //
7   // This file is part of Force Field X.
8   //
9   // Force Field X is free software; you can redistribute it and/or modify it
10  // under the terms of the GNU General Public License version 3 as published by
11  // the Free Software Foundation.
12  //
13  // Force Field X is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  // details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA 02111-1307 USA
21  //
22  // Linking this library statically or dynamically with other modules is making a
23  // combined work based on this library. Thus, the terms and conditions of the
24  // GNU General Public License cover the whole combination.
25  //
26  // As a special exception, the copyright holders of this library give you
27  // permission to link this library with independent modules to produce an
28  // executable, regardless of the license terms of these independent modules, and
29  // to copy and distribute the resulting executable under terms of your choice,
30  // provided that you also meet, for each linked independent module, the terms
31  // and conditions of the license of that module. An independent module is a
32  // module which is not derived from or based on this library. If you modify this
33  // library, you may extend this exception to your version of the library, but
34  // you are not obligated to do so. If you do not wish to do so, delete this
35  // exception statement from your version.
36  //
37  // ******************************************************************************
38  package ffx.openmm.amoeba;
39  
40  import com.sun.jna.Pointer;
41  import com.sun.jna.ptr.DoubleByReference;
42  import com.sun.jna.ptr.IntByReference;
43  import ffx.openmm.Context;
44  import ffx.openmm.Force;
45  import ffx.openmm.IntArray;
46  
47  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_Lambda;
48  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addParticle;
49  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addParticleType;
50  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addParticle_1;
51  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addTypePair;
52  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_create;
53  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_destroy;
54  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getAlchemicalMethod;
55  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getCutoff;
56  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getCutoffDistance;
57  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getEpsilonCombiningRule;
58  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getNonbondedMethod;
59  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getNumParticleTypes;
60  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getNumParticles;
61  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getNumTypePairs;
62  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getParticleExclusions;
63  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getParticleParameters;
64  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getParticleTypeParameters;
65  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getPotentialFunction;
66  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getSigmaCombiningRule;
67  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getSoftcoreAlpha;
68  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getSoftcorePower;
69  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getTypePairParameters;
70  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getUseDispersionCorrection;
71  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_getUseParticleTypes;
72  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setAlchemicalMethod;
73  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setCutoff;
74  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setCutoffDistance;
75  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setEpsilonCombiningRule;
76  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setLambdaName;
77  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setNonbondedMethod;
78  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setParticleExclusions;
79  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setParticleParameters;
80  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setParticleTypeParameters;
81  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setPotentialFunction;
82  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setSigmaCombiningRule;
83  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setSoftcoreAlpha;
84  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setSoftcorePower;
85  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setTypePairParameters;
86  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setUseDispersionCorrection;
87  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_updateParametersInContext;
88  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_usesPeriodicBoundaryConditions;
89  import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_Boolean.OpenMM_True;
90  
91  /**
92   * This class models van der Waals forces in the AMOEBA force field.  It can use
93   * either buffered 14-7 potential or a Lennard-Jones 12-6 potential.
94   * <p>
95   * This class can operate in two different modes.  In one mode, force field parameters
96   * are defined for each particle.  When two particles interact, a combining rule is
97   * used to calculate the interaction parameters based on the parameters for the two
98   * particles.  To use the class in this mode, call the version of addParticle() that
99   * takes sigma and epsilon values.  It should be called once for each particle in the
100  * System.
101  * <p>
102  * In the other mode, each particle has a type index, and parameters are specified for
103  * each type rather than each individual particle.  By default this mode also uses a
104  * combining rule, but you can override it by defining alternate parameters to use for
105  * specific pairs of particle types.  To use the class in this mode, call the version of
106  * addParticle() that takes a type index.  It should be called once for each particle
107  * in the System.  You also must call addParticleType() once for each type.  If you
108  * wish to override the combining for particular pairs of types, do so by calling
109  * addTypePair().
110  * <p>
111  * A unique feature of this class is that the interaction site for a particle does not need to be
112  * exactly at the particle's location.  Instead, it can be placed a fraction of the distance from that
113  * particle to another one.  This is typically done for hydrogens to place the interaction site slightly
114  * closer to the parent atom.  The fraction is known as the "reduction factor", since it reduces the distance
115  * from the parent atom to the interaction site.
116  * <p>
117  * Support is also available for softcore interactions based on setting a per particle alchemical flag and
118  * setting the AmoebaVdwForce to use an "AlchemicalMethod" -- either Decouple or Annihilate.
119  * For Decouple, two alchemical atoms interact normally. For Annihilate, all interactions involving an
120  * alchemical atom are influenced. The softcore state is specified by setting a single
121  * Context parameter "AmoebaVdwLambda" between 0.0 and 1.0.
122  * <p>
123  * The softcore functional form can be modified by setting the softcore power (default of 5) and the softcore
124  * alpha (default of 0,7). For more information on the softcore functional form see Eq. 2 from:
125  * Jiao, D.;  Golubkov, P. A.;  Darden, T. A.; Ren, P.,
126  * Calculation of protein-ligand binding free energy by using a polarizable potential.
127  * Proc. Natl. Acad. Sci. U.S.A. 2008, 105 (17), 6290-6295.
128  * https://www.pnas.org/content/105/17/6290.
129  */
130 public class VdwForce extends Force {
131 
132   /**
133    * Create an Amoeba VdwForce.
134    */
135   public VdwForce() {
136     super(OpenMM_AmoebaVdwForce_create());
137   }
138 
139   /**
140    * Add the force field parameters for a vdw particle.  This version is used when parameters
141    * are defined for each particle.
142    *
143    * @param parentIndex     the index of the parent particle
144    * @param sigma           vdw sigma
145    * @param epsilon         vdw epsilon
146    * @param reductionFactor the fraction of the distance along the line from the parent particle to this particle
147    *                        at which the interaction site should be placed
148    * @param isAlchemical    if true, this vdW particle is undergoing an alchemical change.
149    * @param scaleFactor     a scale factor to apply to all interactions involving this particle (used for CpHMD).
150    * @return index of added particle
151    */
152   public int addParticle(int parentIndex, double sigma, double epsilon, double reductionFactor, int isAlchemical, double scaleFactor) {
153     return OpenMM_AmoebaVdwForce_addParticle(pointer, parentIndex, sigma, epsilon, reductionFactor, isAlchemical, scaleFactor);
154   }
155 
156   /**
157    * Add the force field parameters for a vdw particle. This version is used when parameters
158    * are defined by particle type.
159    *
160    * @param parentIndex     the index of the parent particle
161    * @param typeIndex       the index of the particle type for this particle
162    * @param reductionFactor the fraction of the distance along the line from the parent particle to this particle
163    *                        at which the interaction site should be placed
164    * @param isAlchemical    if true, this vdW particle is undergoing an alchemical change.
165    * @param scaleFactor     a scale factor to apply to all interactions involving this particle (used for CpHMD).
166    * @return index of added particle
167    */
168   public int addParticle(int parentIndex, int typeIndex, double reductionFactor, int isAlchemical, double scaleFactor) {
169     return OpenMM_AmoebaVdwForce_addParticle_1(pointer, parentIndex, typeIndex, reductionFactor, isAlchemical, scaleFactor);
170   }
171 
172   /**
173    * Add a particle type.
174    *
175    * @param sigma   the sigma value for particles of this type
176    * @param epsilon the epsilon value for particles of this type
177    * @return the index of the particle type that was just added.
178    */
179   public int addParticleType(double sigma, double epsilon) {
180     return OpenMM_AmoebaVdwForce_addParticleType(pointer, sigma, epsilon);
181   }
182 
183   /**
184    * Add a type pair.  This overrides the standard combining rule for interactions
185    * between particles of two particular types.
186    *
187    * @param type1   the index of the first particle type
188    * @param type2   the index of the second particle type
189    * @param sigma   the sigma value for interactions between particles of these two types
190    * @param epsilon the epsilon  value for interactions between particles of these two types
191    * @return the index of the type pair that was just added.
192    */
193   public int addTypePair(int type1, int type2, double sigma, double epsilon) {
194     return OpenMM_AmoebaVdwForce_addTypePair(pointer, type1, type2, sigma, epsilon);
195   }
196 
197   /**
198    * Destroy the force.
199    */
200   @Override
201   public void destroy() {
202     if (pointer != null) {
203       OpenMM_AmoebaVdwForce_destroy(pointer);
204       pointer = null;
205     }
206   }
207 
208   /**
209    * Get the alchemical method.
210    *
211    * @return The alchemical method.
212    */
213   public int getAlchemicalMethod() {
214     return OpenMM_AmoebaVdwForce_getAlchemicalMethod(pointer);
215   }
216 
217   /**
218    * Get the cutoff distance.
219    *
220    * @deprecated This method exists only for backward compatibility.  Use getCutoffDistance() instead.
221    */
222   @Deprecated
223   public double getCutoff() {
224     return OpenMM_AmoebaVdwForce_getCutoff(pointer);
225   }
226 
227   /**
228    * Get the cutoff distance (in nm) being used for nonbonded interactions.  If the NonbondedMethod in use
229    * is NoCutoff, this value will have no effect.
230    *
231    * @return the cutoff distance, measured in nm
232    */
233   public double getCutoffDistance() {
234     return OpenMM_AmoebaVdwForce_getCutoffDistance(pointer);
235   }
236 
237   /**
238    * Get the epsilon combining rule.
239    *
240    * @return The epsilon combining rule.
241    */
242   public String getEpsilonCombiningRule() {
243     Pointer rule = OpenMM_AmoebaVdwForce_getEpsilonCombiningRule(pointer);
244     if (rule == null) {
245       return null;
246     }
247     return rule.getString(0);
248   }
249 
250   /**
251    * Get the lambda parameter.
252    *
253    * @return The lambda parameter.
254    */
255   public Pointer getLambda() {
256     return OpenMM_AmoebaVdwForce_Lambda(pointer);
257   }
258 
259   /**
260    * Get the nonbonded method.
261    *
262    * @return The nonbonded method.
263    */
264   public int getNonbondedMethod() {
265     return OpenMM_AmoebaVdwForce_getNonbondedMethod(pointer);
266   }
267 
268   /**
269    * Get the number of particles.
270    *
271    * @return The number of particles.
272    */
273   public int getNumParticles() {
274     return OpenMM_AmoebaVdwForce_getNumParticles(pointer);
275   }
276 
277   /**
278    * Get the number of particle types.
279    *
280    * @return The number of particle types.
281    */
282   public int getNumParticleTypes() {
283     return OpenMM_AmoebaVdwForce_getNumParticleTypes(pointer);
284   }
285 
286   /**
287    * Get the number of type pairs.
288    *
289    * @return The number of type pairs.
290    */
291   public int getNumTypePairs() {
292     return OpenMM_AmoebaVdwForce_getNumTypePairs(pointer);
293   }
294 
295   /**
296    * Get the particle exclusions.
297    *
298    * @param i The index of the particle.
299    * @return An IntArray containing the exclusions.
300    */
301   public IntArray getParticleExclusions(int i) {
302     IntArray exclusions = new IntArray(0);
303     if (pointer != null) {
304       OpenMM_AmoebaVdwForce_getParticleExclusions(pointer, i, exclusions.getPointer());
305     }
306     return exclusions;
307   }
308 
309   /**
310    * Get the particle parameters.
311    *
312    * @param index           The index of the particle.
313    * @param ired            The index of the particle that this particle is reduced to (output).
314    * @param rad             The radius of the particle (output).
315    * @param eps             The epsilon of the particle (output).
316    * @param reductionFactor The reduction factor (output).
317    * @param isAlchemical    Whether the particle is alchemical (output).
318    * @param type            The type of the particle (output).
319    * @param scaleFactor     The scale factor (output).
320    */
321   public void getParticleParameters(int index, IntByReference ired, DoubleByReference rad,
322                                     DoubleByReference eps, DoubleByReference reductionFactor,
323                                     IntByReference isAlchemical, IntByReference type,
324                                     DoubleByReference scaleFactor) {
325     OpenMM_AmoebaVdwForce_getParticleParameters(pointer, index, ired, rad, eps, reductionFactor,
326         isAlchemical, type, scaleFactor);
327   }
328 
329   /**
330    * Get the particle type parameters.
331    *
332    * @param index The index of the particle type.
333    * @param rad   The radius of the particle type (output).
334    * @param eps   The epsilon of the particle type (output).
335    */
336   public void getParticleTypeParameters(int index, DoubleByReference rad, DoubleByReference eps) {
337     OpenMM_AmoebaVdwForce_getParticleTypeParameters(pointer, index, rad, eps);
338   }
339 
340   /**
341    * Get the potential function.
342    *
343    * @return The potential function.
344    */
345   public int getPotentialFunction() {
346     return OpenMM_AmoebaVdwForce_getPotentialFunction(pointer);
347   }
348 
349   /**
350    * Get the sigma combining rule.
351    *
352    * @return The sigma combining rule.
353    */
354   public String getSigmaCombiningRule() {
355     Pointer rule = OpenMM_AmoebaVdwForce_getSigmaCombiningRule(pointer);
356     if (rule == null) {
357       return null;
358     }
359     return rule.getString(0);
360   }
361 
362   /**
363    * Get the softcore alpha.
364    *
365    * @return The softcore alpha.
366    */
367   public double getSoftcoreAlpha() {
368     return OpenMM_AmoebaVdwForce_getSoftcoreAlpha(pointer);
369   }
370 
371   /**
372    * Get the softcore power.
373    *
374    * @return The softcore power.
375    */
376   public int getSoftcorePower() {
377     return OpenMM_AmoebaVdwForce_getSoftcorePower(pointer);
378   }
379 
380   /**
381    * Get the type pair parameters.
382    *
383    * @param index The index of the type pair.
384    * @param type1 The first type (output).
385    * @param type2 The second type (output).
386    * @param rad   The radius (output).
387    * @param eps   The epsilon (output).
388    */
389   public void getTypePairParameters(int index, IntByReference type1, IntByReference type2,
390                                     DoubleByReference rad, DoubleByReference eps) {
391     OpenMM_AmoebaVdwForce_getTypePairParameters(pointer, index, type1, type2, rad, eps);
392   }
393 
394   /**
395    * Get whether to add a contribution to the energy that approximately represents the effect of VdW
396    * interactions beyond the cutoff distance.  The energy depends on the volume of the periodic box, and is only
397    * applicable when periodic boundary conditions are used.  When running simulations at constant pressure, adding
398    * this contribution can improve the quality of results.
399    */
400   public boolean getUseDispersionCorrection() {
401     return OpenMM_AmoebaVdwForce_getUseDispersionCorrection(pointer) != 0;
402   }
403 
404   /**
405    * Get whether to use particle types.
406    *
407    * @return 1 if particle types are used, 0 otherwise.
408    */
409   public int getUseParticleTypes() {
410     return OpenMM_AmoebaVdwForce_getUseParticleTypes(pointer);
411   }
412 
413   /**
414    * Set the alchemical method.
415    *
416    * @param method The alchemical method.
417    */
418   public void setAlchemicalMethod(int method) {
419     OpenMM_AmoebaVdwForce_setAlchemicalMethod(pointer, method);
420   }
421 
422   /**
423    * Set the cutoff distance.
424    *
425    * @deprecated This method exists only for backward compatibility.  Use setCutoffDistance() instead.
426    */
427   @Deprecated
428   public void setCutoff(double cutoff) {
429     OpenMM_AmoebaVdwForce_setCutoff(pointer, cutoff);
430   }
431 
432   /**
433    * Set the cutoff distance (in nm) being used for nonbonded interactions.  If the NonbondedMethod in use
434    * is NoCutoff, this value will have no effect.
435    *
436    * @param distance the cutoff distance, measured in nm
437    */
438   public void setCutoffDistance(double distance) {
439     OpenMM_AmoebaVdwForce_setCutoffDistance(pointer, distance);
440   }
441 
442   /**
443    * Set the epsilon combining rule.
444    *
445    * @param rule The epsilon combining rule.
446    */
447   public void setEpsilonCombiningRule(String rule) {
448     OpenMM_AmoebaVdwForce_setEpsilonCombiningRule(pointer, rule);
449   }
450 
451   /**
452    * Set the lambda parameter name.
453    *
454    * @param name The name of the lambda parameter.
455    */
456   public void setLambdaName(String name) {
457     OpenMM_AmoebaVdwForce_setLambdaName(pointer, name);
458   }
459 
460   /**
461    * Set the nonbonded method.
462    *
463    * @param method The nonbonded method.
464    */
465   public void setNonbondedMethod(int method) {
466     OpenMM_AmoebaVdwForce_setNonbondedMethod(pointer, method);
467   }
468 
469   /**
470    * Set the particle exclusions.
471    *
472    * @param i          The index of the particle.
473    * @param exclusions The exclusions.
474    */
475   public void setParticleExclusions(int i, IntArray exclusions) {
476     OpenMM_AmoebaVdwForce_setParticleExclusions(pointer, i, exclusions.getPointer());
477   }
478 
479   /**
480    * Set the particle parameters.
481    *
482    * @param index           The index of the particle.
483    * @param ired            The index of the particle that this particle is reduced to.
484    * @param rad             The radius of the particle.
485    * @param eps             The epsilon of the particle.
486    * @param reductionFactor The reduction factor.
487    * @param isAlchemical    Whether the particle is alchemical.
488    * @param type            The type of the particle.
489    * @param scaleFactor     The scale factor.
490    */
491   public void setParticleParameters(int index, int ired, double rad, double eps, double reductionFactor, int isAlchemical, int type, double scaleFactor) {
492     OpenMM_AmoebaVdwForce_setParticleParameters(pointer, index, ired, rad, eps, reductionFactor, isAlchemical, type, scaleFactor);
493   }
494 
495   /**
496    * Set the particle type parameters.
497    *
498    * @param index The index of the particle type.
499    * @param rad   The radius of the particle type.
500    * @param eps   The epsilon of the particle type.
501    */
502   public void setParticleTypeParameters(int index, double rad, double eps) {
503     OpenMM_AmoebaVdwForce_setParticleTypeParameters(pointer, index, rad, eps);
504   }
505 
506   /**
507    * Set the potential function.
508    *
509    * @param function The potential function.
510    */
511   public void setPotentialFunction(int function) {
512     OpenMM_AmoebaVdwForce_setPotentialFunction(pointer, function);
513   }
514 
515   /**
516    * Set the sigma combining rule.
517    *
518    * @param rule The sigma combining rule.
519    */
520   public void setSigmaCombiningRule(String rule) {
521     OpenMM_AmoebaVdwForce_setSigmaCombiningRule(pointer, rule);
522   }
523 
524   /**
525    * Set the softcore alpha.
526    *
527    * @param vdWSoftcoreAlpha The softcore alpha.
528    */
529   public void setSoftcoreAlpha(double vdWSoftcoreAlpha) {
530     OpenMM_AmoebaVdwForce_setSoftcoreAlpha(pointer, vdWSoftcoreAlpha);
531   }
532 
533   /**
534    * Set the softcore power.
535    *
536    * @param vdwSoftcorePower The softcore power.
537    */
538   public void setSoftcorePower(int vdwSoftcorePower) {
539     OpenMM_AmoebaVdwForce_setSoftcorePower(pointer, vdwSoftcorePower);
540   }
541 
542   /**
543    * Set the type pair parameters.
544    *
545    * @param index The index of the type pair.
546    * @param type1 The first type.
547    * @param type2 The second type.
548    * @param rad   The radius.
549    * @param eps   The epsilon.
550    */
551   public void setTypePairParameters(int index, int type1, int type2, double rad, double eps) {
552     OpenMM_AmoebaVdwForce_setTypePairParameters(pointer, index, type1, type2, rad, eps);
553   }
554 
555   /**
556    * Set whether to add a contribution to the energy that approximately represents the effect of VdW
557    * interactions beyond the cutoff distance.  The energy depends on the volume of the periodic box, and is only
558    * applicable when periodic boundary conditions are used.  When running simulations at constant pressure, adding
559    * this contribution can improve the quality of results.
560    */
561   public void setUseDispersionCorrection(boolean useCorrection) {
562     OpenMM_AmoebaVdwForce_setUseDispersionCorrection(pointer, useCorrection ? 1 : 0);
563   }
564 
565   /**
566    * Update the per-particle parameters in a Context to match those stored in this Force object.  This method provides
567    * an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
568    * Simply call setParticleParameters() to modify this object's parameters, then call updateParametersInContext()
569    * to copy them over to the Context.
570    * <p>
571    * The only information this method updates is the values of per-particle parameters.  All other aspects of the Force
572    * (the nonbonded method, the cutoff distance, etc.) are unaffected and can only be changed by reinitializing the Context.
573    */
574   public void updateParametersInContext(Context context) {
575     if (context.hasContextPointer()) {
576       OpenMM_AmoebaVdwForce_updateParametersInContext(pointer, context.getPointer());
577     }
578   }
579 
580   /**
581    * Returns whether or not this force makes use of periodic boundary
582    * conditions.
583    *
584    * @return true if nonbondedMethod uses PBC and false otherwise
585    */
586   @Override
587   public boolean usesPeriodicBoundaryConditions() {
588     int pbc = OpenMM_AmoebaVdwForce_usesPeriodicBoundaryConditions(pointer);
589     return pbc == OpenMM_True;
590   }
591 }