AmoebaInPlaneAngleForce.h 8.6 KB
Newer Older
1
2
#ifndef OPENMM_AMOEBA_IN_PLANE_ANGLE_FORCE_H_
#define OPENMM_AMOEBA_IN_PLANE_ANGLE_FORCE_H_
Mark Friedrichs's avatar
Mark Friedrichs committed
3
4

/* -------------------------------------------------------------------------- *
5
 *                              OpenMMAmoeba                                  *
Mark Friedrichs's avatar
Mark Friedrichs committed
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
13
 * Portions copyright (c) 2008-2012 Stanford University and the Authors.      *
 * Authors: Mark Friedrichs, Peter Eastman                                    *
Mark Friedrichs's avatar
Mark Friedrichs committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

#include "openmm/Force.h"
36
#include "internal/windowsExportAmoeba.h"
Mark Friedrichs's avatar
Cleanup  
Mark Friedrichs committed
37
#include <vector>
Mark Friedrichs's avatar
Mark Friedrichs committed
38
39
40
41

namespace OpenMM {

/**
42
 * This class implements an interaction at trigonal centers corresponding to the projected in-plane angle bend energy
43
44
45
46
 * between four particles.  The interaction is defined by a 6th order polynomial in the angle between them.  Only the
 * quadratic term is set per-angle.  The coefficients of the higher order terms each have a single value that
 * is set globally.
 * 
47
 * To use it, create an AmoebaInPlaneAngleForce object then call addAngle() once for each angle.  After
48
 * an angle has been added, you can modify its force field parameters by calling setAngleParameters().
49
 * This will have no effect on Contexts that already exist unless you call updateParametersInContext().
Mark Friedrichs's avatar
Mark Friedrichs committed
50
51
 */

52
class OPENMM_EXPORT_AMOEBA AmoebaInPlaneAngleForce : public Force {
Mark Friedrichs's avatar
Cleanup  
Mark Friedrichs committed
53

Mark Friedrichs's avatar
Mark Friedrichs committed
54
public:
Mark Friedrichs's avatar
Cleanup  
Mark Friedrichs committed
55

Mark Friedrichs's avatar
Mark Friedrichs committed
56
    /**
57
     * Create an AmoebaAngleForce.
Mark Friedrichs's avatar
Mark Friedrichs committed
58
     */
59
    AmoebaInPlaneAngleForce();
Mark Friedrichs's avatar
Mark Friedrichs committed
60
61

    /**
62
     * Get the number of in-plane angle terms in the potential function
Mark Friedrichs's avatar
Mark Friedrichs committed
63
64
65
66
67
68
69
70
     */
    int getNumAngles() const {
        return angles.size();
    }

    /**
     * Set the global cubic term
     * 
71
     * @param cubicK        the cubic force constant for the angle
Mark Friedrichs's avatar
Mark Friedrichs committed
72
     */
73
    void setAmoebaGlobalInPlaneAngleCubic( double cubicK );
Mark Friedrichs's avatar
Mark Friedrichs committed
74
75
76
77
78
79

    /**
     * Get the global cubic term
     * 
     * @return global cubicK term
     */
80
    double getAmoebaGlobalInPlaneAngleCubic( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
81
82

    /**
83
     * Set the global quartic term
Mark Friedrichs's avatar
Mark Friedrichs committed
84
     * 
85
     * @param quarticK the quartic force constant for the angle
Mark Friedrichs's avatar
Mark Friedrichs committed
86
     */
87
    void setAmoebaGlobalInPlaneAngleQuartic( double quarticK );
Mark Friedrichs's avatar
Mark Friedrichs committed
88
89
90
91
92
93

    /**
     * Get the global quartic term
     * 
     * @return global  quartic term
     */
94
    double getAmoebaGlobalInPlaneAngleQuartic( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
95
96
97
98

    /**
     * Set the global pentic term
     * 
99
     * @param penticK the pentic force constant for the angle
Mark Friedrichs's avatar
Mark Friedrichs committed
100
     */
101
    void setAmoebaGlobalInPlaneAnglePentic( double penticK );
Mark Friedrichs's avatar
Mark Friedrichs committed
102
103
104
105
106
107

    /**
     * Get the global pentic term
     * 
     * @return global penticK term
     */
108
    double getAmoebaGlobalInPlaneAnglePentic( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
109
110
111
112

    /**
     * Set the global sextic term
     * 
113
     * @param sexticK       the sextic force constant for the angle
Mark Friedrichs's avatar
Mark Friedrichs committed
114
     */
115
    void setAmoebaGlobalInPlaneAngleSextic( double sexticK );
Mark Friedrichs's avatar
Mark Friedrichs committed
116
117
118
119
120
121

    /**
     * Get the global sextic term
     * 
     * @return global  sextic term
     */
122
    double getAmoebaGlobalInPlaneAngleSextic( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
123
124

    /**
125
     * Add an angle term to the force field.
Mark Friedrichs's avatar
Mark Friedrichs committed
126
127
128
129
130
     *
     * @param particle1     the index of the first particle connected by the angle
     * @param particle2     the index of the second particle connected by the angle
     * @param particle3     the index of the third particle connected by the angle
     * @param particle4     the index of the fourth particle connected by the angle
131
     * @param length        the equilibrium angle, measured in radians
132
     * @param quadratic k   the quadratic force constant for the angle measured in kJ/mol/radian^2
Mark Friedrichs's avatar
Mark Friedrichs committed
133
134
135
136
137
138
     * @return the index of the angle that was added
     */
    int addAngle(int particle1, int particle2, int particle3, int particle4, double length, 
                 double quadraticK );

    /**
139
     * Get the force field parameters for an angle term.
Mark Friedrichs's avatar
Mark Friedrichs committed
140
141
142
143
144
145
     * 
     * @param index         the index of the angle for which to get parameters
     * @param particle1     the index of the first particle connected by the angle
     * @param particle2     the index of the second particle connected by the angle
     * @param particle3     the index of the third particle connected by the angle
     * @param particle4     the index of the fourth particle connected by the angle
146
     * @param length        the equilibrium angle, measured in radians
147
     * @param quadratic k   the quadratic force constant for the angle measured in kJ/mol/radian^2
Mark Friedrichs's avatar
Mark Friedrichs committed
148
149
150
151
152
     */
    void getAngleParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, double& length,
                            double& quadraticK ) const;

    /**
153
     * Set the force field parameters for an angle term.
Mark Friedrichs's avatar
Mark Friedrichs committed
154
155
156
157
158
159
     * 
     * @param index         the index of the angle for which to set parameters
     * @param particle1     the index of the first particle connected by the angle
     * @param particle2     the index of the second particle connected by the angle
     * @param particle3     the index of the third particle connected by the angle
     * @param particle4     the index of the fourth particle connected by the angle
160
     * @param length        the equilibrium angle, measured in radians
161
     * @param quadratic k   the quadratic force constant for the angle, measured in kJ/mol/radian^2
Mark Friedrichs's avatar
Mark Friedrichs committed
162
163
     */
    void setAngleParameters(int index, int particle1, int particle2, int particle3, int particle4, double length, double quadraticK );
164
165
166
167
168
169
170
171
172
173
    /**
     * Update the per-angle parameters in a Context to match those stored in this Force object.  This method provides
     * an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
     * Simply call setAngleParameters() to modify this object's parameters, then call updateParametersInState()
     * to copy them over to the Context.
     * 
     * The only information this method updates is the values of per-angle parameters.  The set of particles involved
     * in an angle cannot be changed, nor can new angles be added.
     */
    void updateParametersInContext(Context& context);
Mark Friedrichs's avatar
Mark Friedrichs committed
174
175

protected:
176
    ForceImpl* createImpl() const;
Mark Friedrichs's avatar
Mark Friedrichs committed
177
178
179
180
181
182
    double _globalCubicK, _globalQuarticK, _globalPenticK, _globalSexticK;
private:
    class AngleInfo;
    std::vector<AngleInfo> angles;
};

183
class AmoebaInPlaneAngleForce::AngleInfo {
Mark Friedrichs's avatar
Mark Friedrichs committed
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
public:
    int particle1, particle2, particle3, particle4;
    double length, quadraticK;
    AngleInfo() {
        particle1 = particle2  = particle3 = particle4 = -1;
        length    = quadraticK = 0.0;
    }
    AngleInfo(int particle1, int particle2, int particle3, int particle4, double length, double  quadraticK ) :
        particle1(particle1), particle2(particle2), particle3(particle3), particle4(particle4),
        length(length), quadraticK(quadraticK) {
    }
};

} // namespace OpenMM

199
#endif /*OPENMM_AMOEBA_IN_PLANE_ANGLE_FORCE_H_*/