ReferenceGBVI.h 11.8 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

/* Portions copyright (c) 2006 Stanford University and Simbios.
 * Contributors: Pande Group
 *
 * 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.
 */

25
26
#ifndef __ReferenceGBVI_H__
#define __ReferenceGBVI_H__
Mark Friedrichs's avatar
Mark Friedrichs committed
27

Mark Friedrichs's avatar
Mark Friedrichs committed
28
29
#include <vector>

30
#include "RealVec.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
31
32
#include "GBVIParameters.h"

33
namespace OpenMM {
Mark Friedrichs's avatar
Mark Friedrichs committed
34

35
class ReferenceGBVI {
Mark Friedrichs's avatar
Mark Friedrichs committed
36
37
38
39
40
41

   private:

      // GB/VI parameters

      GBVIParameters* _gbviParameters;
42
      std::vector<RealOpenMM> _switchDeriviative;
Mark Friedrichs's avatar
Mark Friedrichs committed
43
44
45
46
47
48
49
50
51
52
53
54
55

   public:

      /**---------------------------------------------------------------------------------------
      
         Constructor
      
         @param implicitSolventParameters    ImplicitSolventParameters reference
      
         @return CpuImplicitSolvent object
      
         --------------------------------------------------------------------------------------- */

56
       ReferenceGBVI(GBVIParameters* gbviParameters);
Mark Friedrichs's avatar
Mark Friedrichs committed
57
58
59
60
61
62
63

      /**---------------------------------------------------------------------------------------
      
         Destructor
      
         --------------------------------------------------------------------------------------- */

64
       ~ReferenceGBVI();
Mark Friedrichs's avatar
Mark Friedrichs committed
65
66
67
68
69
70
71
72
73

      /**---------------------------------------------------------------------------------------
      
         Return GBVIParameters
      
         @return GBVIParameters
      
         --------------------------------------------------------------------------------------- */

74
      GBVIParameters* getGBVIParameters() const;
Mark Friedrichs's avatar
Mark Friedrichs committed
75
76
77
78
79
80
81
82
83

      /**---------------------------------------------------------------------------------------
      
         Set ImplicitSolventParameters
      
         @param ImplicitSolventParameters
      
         --------------------------------------------------------------------------------------- */

84
      void setGBVIParameters(GBVIParameters* gbviParameters);
Mark Friedrichs's avatar
Mark Friedrichs committed
85
86
87
88
89
90
91
92
93
94
95
 
      /**---------------------------------------------------------------------------------------
      
         Get Born radii based on Eq. 3 of Labute paper [JCC 29 p. 1693-1698 2008])

         @param atomCoordinates   atomic coordinates
         @param bornRadii         output array of Born radii
         @param gbviChain         not used
      
         --------------------------------------------------------------------------------------- */
      
96
      void computeBornRadii(const std::vector<OpenMM::RealVec>& atomCoordinates, std::vector<RealOpenMM>& bornRadii);
Mark Friedrichs's avatar
Mark Friedrichs committed
97
98
99
100
101
102
103
104
105
106
107
108
109
      
      /**---------------------------------------------------------------------------------------
      
         Get volume Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return volume
      
         --------------------------------------------------------------------------------------- */
      
110
      static RealOpenMM getVolume(RealOpenMM r, RealOpenMM R, RealOpenMM S);
Mark Friedrichs's avatar
Mark Friedrichs committed
111
112
113
114
115
116
117
118
119
120
121
122
123
      
      /**---------------------------------------------------------------------------------------
      
         Get L (analytical solution for volume integrals) 
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return L value (Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
124
      static RealOpenMM getL(RealOpenMM r, RealOpenMM x, RealOpenMM S);
Mark Friedrichs's avatar
Mark Friedrichs committed
125
126
127
128
129
130
131
132
133
134
135
136
137

      /**---------------------------------------------------------------------------------------
      
         Get partial derivative of L wrt r
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return partial derivative based on Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
138
      static RealOpenMM dL_dr(RealOpenMM r, RealOpenMM x, RealOpenMM S);
Mark Friedrichs's avatar
Mark Friedrichs committed
139
140
141
142
143
144
145
146
147
148
149
150
151

      /**---------------------------------------------------------------------------------------
      
         Get partial derivative of L wrt x
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return partial derivative based on Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
152
      static RealOpenMM dL_dx(RealOpenMM r, RealOpenMM x, RealOpenMM S);
Mark Friedrichs's avatar
Mark Friedrichs committed
153
154
155
156
157
158
159
160
161
162
163

      /**---------------------------------------------------------------------------------------
      
         Sgb function
      
         @param t                   r*r*G_i*G_j
      
         @return Sgb (p. 1694 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
164
      static RealOpenMM Sgb(RealOpenMM t);
Mark Friedrichs's avatar
Mark Friedrichs committed
165
166
167
168
169
170
171
172
173
174
175
176
      
      /**---------------------------------------------------------------------------------------
      
         Get GB/VI energy
      
         @param atomCoordinates     atomic coordinates
         @param partialCharges      partial charges
      
         @return energy
      
         --------------------------------------------------------------------------------------- */
      
177
      RealOpenMM computeBornEnergy(const std::vector<OpenMM::RealVec>& atomCoordinates, const std::vector<RealOpenMM>& partialCharges);
Mark Friedrichs's avatar
Mark Friedrichs committed
178
179
180
181
182
183
184
185
186
187
188
      
      /**---------------------------------------------------------------------------------------
      
         Get GB/VI forces
      
         @param atomCoordinates     atomic coordinates
         @param partialCharges      partial charges
         @param forces              output forces
      
         --------------------------------------------------------------------------------------- */
      
189
      void computeBornForces(std::vector<OpenMM::RealVec>& atomCoordinates,
190
                             const std::vector<RealOpenMM>& partialCharges, std::vector<OpenMM::RealVec>& inputForces);
Mark Friedrichs's avatar
Mark Friedrichs committed
191
192
193
194
195
196
197
198
199
200
201
202
203
      
      /**---------------------------------------------------------------------------------------
      
         Get volume Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return volume
      
         --------------------------------------------------------------------------------------- */
      
204
      static double getVolumeD(double r, double R, double S);
Mark Friedrichs's avatar
Mark Friedrichs committed
205
206
207
208
209
210
211
212
213
214
215
216
217
      
      /**---------------------------------------------------------------------------------------
      
         Get L (analytical solution for volume integrals) 
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return L value (Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
218
      static double getLD(double r, double x, double S);
Mark Friedrichs's avatar
Mark Friedrichs committed
219
220
221
222
223
224
225
226
227
228
229
230
231

      /**---------------------------------------------------------------------------------------
      
         Get partial derivative of L wrt r
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return partial derivative based on Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
232
      static double dL_drD(double r, double x, double S);
Mark Friedrichs's avatar
Mark Friedrichs committed
233
234
235
236
237
238
239
240
241
242
243
244
245

      /**---------------------------------------------------------------------------------------
      
         Get partial derivative of L wrt x
      
         @param r                   distance between atoms i & j
         @param R                   atomic radius
         @param S                   scaled atomic radius
      
         @return partial derivative based on Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
      
         --------------------------------------------------------------------------------------- */
      
246
      static double dL_dxD(double r, double x, double S);
Mark Friedrichs's avatar
Mark Friedrichs committed
247

248
249
250
251
252
253
254
255
256
    /**---------------------------------------------------------------------------------------
    
       Return OBC chain derivative: size = _obcParameters->getNumberOfAtoms()
       On first call, memory for array is allocated if not set
    
       @return array
    
       --------------------------------------------------------------------------------------- */
    
257
      std::vector<RealOpenMM>& getSwitchDeriviative();
258
259
260
261
262
263
264
265
266
267
268
269
270
    
    /**---------------------------------------------------------------------------------------
    
       Compute quintic spline value and associated derviative
    
       @param x                   value to compute spline at
       @param rl                  lower cutoff value
       @param ru                  upper cutoff value
       @param outValue            value of spline at x
       @param outDerivative       value of derivative of spline at x
    
       --------------------------------------------------------------------------------------- */
    
271
272
    void quinticSpline(RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
                       RealOpenMM* outValue, RealOpenMM* outDerivative);
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287

    /**---------------------------------------------------------------------------------------
    
       Compute Born radii based on Eq. 3 of Labute paper [JCC 29 p. 1693-1698 2008])
       and quintic splice switching function
    
       @param atomicRadius3       atomic radius cubed
       @param bornSum             Born sum (volume integral)
       @param gbviParameters      Gbvi parameters (parameters used in spline
                                  QuinticLowerLimitFactor & QuinticUpperBornRadiusLimit)
       @param bornRadius          output Born radius
       @param switchDeriviative   output switching function deriviative
    
       --------------------------------------------------------------------------------------- */
    
288
289
290
    void computeBornRadiiUsingQuinticSpline(RealOpenMM atomicRadius3, RealOpenMM bornSum,
                                            GBVIParameters* gbviParameters,
                                            RealOpenMM* bornRadius, RealOpenMM* switchDeriviative);
Mark Friedrichs's avatar
Mark Friedrichs committed
291

Mark Friedrichs's avatar
Mark Friedrichs committed
292
293
};

294
} // namespace OpenMM
Mark Friedrichs's avatar
Mark Friedrichs committed
295

296
#endif // __ReferenceGBVI_H__