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-2024.
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 ffx.openmm.Context;
41  import ffx.openmm.Force;
42  import ffx.openmm.IntArray;
43  
44  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addParticleType;
45  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addParticle_1;
46  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_addTypePair;
47  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_create;
48  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_destroy;
49  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setAlchemicalMethod;
50  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setCutoffDistance;
51  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setNonbondedMethod;
52  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setParticleExclusions;
53  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setParticleParameters;
54  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setSoftcoreAlpha;
55  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setSoftcorePower;
56  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_setUseDispersionCorrection;
57  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaVdwForce_updateParametersInContext;
58  
59  /**
60   * Amoeba van der Waals Force.
61   */
62  public class VdwForce extends Force {
63  
64    /**
65     * The Amoeba vdW Force constructor.
66     */
67    public VdwForce() {
68      pointer = OpenMM_AmoebaVdwForce_create();
69    }
70  
71    /**
72     * Add a particle type to the vdW Force.
73     *
74     * @param rad The radius.
75     * @param eps The well depth.
76     * @return The type.
77     */
78    public int addParticleType(double rad, double eps) {
79      return OpenMM_AmoebaVdwForce_addParticleType(pointer, rad, eps);
80    }
81  
82    /**
83     * Add a type pair to the vdW Force.
84     *
85     * @param type1 The first type.
86     * @param type2 The second type.
87     * @param rad   The radius.
88     * @param eps   The well depth.
89     */
90    public void addTypePair(int type1, int type2, double rad, double eps) {
91      OpenMM_AmoebaVdwForce_addTypePair(pointer, type1, type2, rad, eps);
92    }
93  
94    /**
95     * Add a particle to the vdW Force.
96     *
97     * @param ired            The particle ired.
98     * @param type            The particle type.
99     * @param reductionFactor The reduction factor.
100    * @param isAlchemical    The alchemical flag.
101    * @param scaleFactor     The scale factor.
102    */
103   public void addParticle_1(int ired, int type, double reductionFactor, int isAlchemical, double scaleFactor) {
104     OpenMM_AmoebaVdwForce_addParticle_1(pointer, ired, type, reductionFactor, isAlchemical, scaleFactor);
105   }
106 
107   /**
108    * Set the particle parameters.
109    *
110    * @param index           The particle index.
111    * @param ired            The particle reduction index.
112    * @param rad             The radius.
113    * @param eps             The well depth.
114    * @param reductionFactor The reduction factor.
115    * @param isAlchemical    The alchemical flag.
116    * @param type            The type.
117    * @param scaleFactor     The scale factor.
118    */
119   public void setParticleParameters(int index, int ired, double rad, double eps, double reductionFactor,
120                                     int isAlchemical, int type, double scaleFactor) {
121     OpenMM_AmoebaVdwForce_setParticleParameters(pointer, index, ired, rad, eps, reductionFactor, isAlchemical, type, scaleFactor);
122   }
123 
124   /**
125    * Set the cutoff distance.
126    *
127    * @param cutoff The cutoff distance.
128    */
129   public void setCutoffDistance(double cutoff) {
130     OpenMM_AmoebaVdwForce_setCutoffDistance(pointer, cutoff);
131   }
132 
133   /**
134    * Set the vdW force to use a long-range dispersion correction.
135    *
136    * @param value The flag.
137    */
138   public void setUseDispersionCorrection(int value) {
139     OpenMM_AmoebaVdwForce_setUseDispersionCorrection(pointer, value);
140   }
141 
142   /**
143    * Set the non-bonded method.
144    *
145    * @param method The non-bonded method.
146    */
147   public void setNonbondedMethod(int method) {
148     OpenMM_AmoebaVdwForce_setNonbondedMethod(pointer, method);
149   }
150 
151   /**
152    * Set the alchemical method.
153    *
154    * @param method The alchemical method.
155    */
156   public void setAlchemicalMethod(int method) {
157     OpenMM_AmoebaVdwForce_setAlchemicalMethod(pointer, method);
158   }
159 
160   /**
161    * Set the softcore power.
162    *
163    * @param vdWSoftcoreAlpha The softcore power.
164    */
165   public void setSoftcoreAlpha(double vdWSoftcoreAlpha) {
166     OpenMM_AmoebaVdwForce_setSoftcoreAlpha(pointer, vdWSoftcoreAlpha);
167   }
168 
169   /**
170    * Set the softcore power.
171    *
172    * @param vdwSoftcorePower The softcore power.
173    */
174   public void setSoftcorePower(int vdwSoftcorePower) {
175     OpenMM_AmoebaVdwForce_setSoftcorePower(pointer, vdwSoftcorePower);
176   }
177 
178   /**
179    * Set the particle exclusions.
180    *
181    * @param i          The particle index.
182    * @param exclusions The exclusions.
183    */
184   public void setParticleExclusions(int i, IntArray exclusions) {
185     OpenMM_AmoebaVdwForce_setParticleExclusions(pointer, i, exclusions.getPointer());
186   }
187 
188   /**
189    * Update the parameters in the OpenMM Context.
190    *
191    * @param context The OpenMM Context.
192    */
193   public void updateParametersInContext(Context context) {
194     if (context.hasContextPointer()) {
195       OpenMM_AmoebaVdwForce_updateParametersInContext(pointer, context.getPointer());
196     }
197   }
198 
199   /**
200    * Destroy the vdW Force.
201    */
202   public void destroy() {
203     if (pointer != null) {
204       OpenMM_AmoebaVdwForce_destroy(pointer);
205       pointer = null;
206     }
207   }
208 
209 }