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.DoubleArray;
42  import ffx.openmm.Force;
43  import ffx.openmm.IntArray;
44  
45  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_addMultipole;
46  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_create;
47  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_destroy;
48  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setAEwald;
49  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setCovalentMap;
50  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setCutoffDistance;
51  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setEwaldErrorTolerance;
52  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setExtrapolationCoefficients;
53  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setMultipoleParameters;
54  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setMutualInducedMaxIterations;
55  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setMutualInducedTargetEpsilon;
56  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setNonbondedMethod;
57  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setPmeGridDimensions;
58  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_setPolarizationType;
59  import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_AmoebaMultipoleForce_updateParametersInContext;
60  
61  /**
62   * Amoeba Polarizable Multipole Force.
63   */
64  public class MultipoleForce extends Force {
65  
66    public MultipoleForce() {
67      pointer = OpenMM_AmoebaMultipoleForce_create();
68    }
69  
70    /**
71     * Set the polarization method.
72     *
73     * @param method The polarization method.
74     */
75    public void setPolarizationType(int method) {
76      OpenMM_AmoebaMultipoleForce_setPolarizationType(pointer, method);
77    }
78  
79    /**
80     * Set extrapolation coefficients.
81     *
82     * @param exptCoefficients The extrapolation coefficients.
83     */
84    public void setExtrapolationCoefficients(DoubleArray exptCoefficients) {
85      OpenMM_AmoebaMultipoleForce_setExtrapolationCoefficients(pointer, exptCoefficients.getPointer());
86    }
87  
88    /**
89     * Add a multipole.
90     *
91     * @param charge         The charge.
92     * @param dipole         The dipole.
93     * @param quadrupole     The quadrupole.
94     * @param axisType       The axis type.
95     * @param zaxis          The z-axis.
96     * @param xaxis          The x-axis.
97     * @param yaxis          The y-axis.
98     * @param thole          The Thole parameter.
99     * @param pdamp          The damping factor.
100    * @param polarizability The polarizability.
101    */
102   public void addMultipole(double charge, DoubleArray dipole, DoubleArray quadrupole, int axisType,
103                            int zaxis, int xaxis, int yaxis, double thole, double pdamp, double polarizability) {
104     OpenMM_AmoebaMultipoleForce_addMultipole(pointer, charge, dipole.getPointer(), quadrupole.getPointer(),
105         axisType, zaxis, xaxis, yaxis, thole, pdamp, polarizability);
106   }
107 
108   /**
109    * Set the multipole parameters.
110    *
111    * @param index          The atom index.
112    * @param charge         The charge.
113    * @param dipoles        The dipole.
114    * @param quadrupoles    The quadrupole.
115    * @param axisType       The axis type.
116    * @param zaxis          The z-axis.
117    * @param xaxis          The x-axis.
118    * @param yaxis          The y-axis.
119    * @param thole          The Thole parameter.
120    * @param pdamp          The damping factor.
121    * @param polarizability The polarizability.
122    */
123   public void setMultipoleParameters(int index, double charge, DoubleArray dipoles, DoubleArray quadrupoles,
124                                      int axisType, int zaxis, int xaxis, int yaxis,
125                                      double thole, double pdamp, double polarizability) {
126     OpenMM_AmoebaMultipoleForce_setMultipoleParameters(pointer, index, charge,
127         dipoles.getPointer(), quadrupoles.getPointer(), axisType, zaxis, xaxis, yaxis, thole, pdamp, polarizability);
128   }
129 
130   /**
131    * Set the nonbonded method for the multipole force.
132    *
133    * @param method The nonbonded method.
134    */
135   public void setNonbondedMethod(int method) {
136     OpenMM_AmoebaMultipoleForce_setNonbondedMethod(pointer, method);
137   }
138 
139   /**
140    * Set the cutoff distance for the multipole force.
141    *
142    * @param cutoff The cutoff distance.
143    */
144   public void setCutoffDistance(double cutoff) {
145     OpenMM_AmoebaMultipoleForce_setCutoffDistance(pointer, cutoff);
146   }
147 
148   /**
149    * Set the Ewald coefficient for the multipole force.
150    *
151    * @param aewald The Ewald coefficient.
152    */
153   public void setAEwald(double aewald) {
154     OpenMM_AmoebaMultipoleForce_setAEwald(pointer, aewald);
155   }
156 
157   /**
158    * Set the Ewald error tolerance for the multipole force.
159    *
160    * @param ewaldTolerance The Ewald error tolerance.
161    */
162   public void setEwaldErrorTolerance(double ewaldTolerance) {
163     OpenMM_AmoebaMultipoleForce_setEwaldErrorTolerance(pointer, ewaldTolerance);
164   }
165 
166   /**
167    * Set the PME grid dimensions for the multipole force.
168    *
169    * @param gridDimensions The PME grid dimensions.
170    */
171   public void setPmeGridDimensions(IntArray gridDimensions) {
172     OpenMM_AmoebaMultipoleForce_setPmeGridDimensions(pointer, gridDimensions.getPointer());
173   }
174 
175   //    OpenMM_AmoebaMultipoleForce_setMutualInducedTargetEpsilon(amoebaMultipoleForce, pme.getPolarEps());
176 
177   /**
178    * Set the mutual induced target maximum number of iterations.
179    *
180    * @param iterations The mutual induced max iterations.
181    */
182   public void setMutualInducedMaxIterations(int iterations) {
183     OpenMM_AmoebaMultipoleForce_setMutualInducedMaxIterations(pointer, iterations);
184   }
185 
186   /**
187    * Set the mutual induced target epsilon.
188    *
189    * @param epsilon The mutual induced target epsilon.
190    */
191   public void setMutualInducedTargetEpsilon(double epsilon) {
192     OpenMM_AmoebaMultipoleForce_setMutualInducedTargetEpsilon(pointer, epsilon);
193   }
194 
195   /**
196    * Set the covalent map.
197    *
198    * @param i            The atom index.
199    * @param covalentType The covalent type.
200    * @param covalentMap  The covalent map.
201    */
202   public void setCovalentMap(int i, int covalentType, IntArray covalentMap) {
203     OpenMM_AmoebaMultipoleForce_setCovalentMap(pointer, i, covalentType, covalentMap.getPointer());
204   }
205 
206   /**
207    * Update the parameters in the context.
208    *
209    * @param context The OpenMM context.
210    */
211   public void updateParametersInContext(Context context) {
212     if (context.hasContextPointer()) {
213       OpenMM_AmoebaMultipoleForce_updateParametersInContext(pointer, context.getPointer());
214     }
215   }
216 
217   /**
218    * Destroy the force.
219    */
220   public void destroy() {
221     if (pointer != null) {
222       OpenMM_AmoebaMultipoleForce_destroy(pointer);
223       pointer = null;
224     }
225   }
226 
227 }