OpenMMBrookInterface.h 10.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef OPENMM_BROOK_INTERFACE_H_
#define OPENMM_BROOK_INTERFACE_H_

/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * 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.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors: Peter Eastman, Mark Friedrichs                                    *
 * 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 "kernels.h"
#include "../../reference/src/SimTKUtilities/SimTKOpenMMRealType.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
37
#include "BrookBondParameters.h"
38
39
#include "BrookBonded.h"
#include "BrookNonBonded.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
40
#include "BrookGbsa.h"
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "NonbondedForce.h"
#include "OpenMMContext.h"
#include "System.h"
#include "ReferencePlatform.h"
#include "VerletIntegrator.h"

namespace OpenMM {

/**
 * OpenMM-Brook interface methods
 */
class OpenMMBrookInterface {

   public:
  
      OpenMMBrookInterface( void );
  
      ~OpenMMBrookInterface();
  
      /**
       * Get reference Context
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
63
       * @param numberOfParticles  number of particles
64
65
66
67
68
       *
       * @return  OpenMMContext
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
69
      OpenMMContext* getReferenceOpenMMContext( int numberOfParticles );
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
      
      /** 
       * Set log file reference
       * 
       * @param  log file reference
       *
       * @return DefaultReturnValue
       *
       */
      
      int setLog( FILE* log );

      /* 
       * Get contents of object
       *
       * @param level of dump
       *
       * @return string containing contents
       *
       * */
      
      std::string getContents( int level ) const;

      /** 
       * Get log file reference
       * 
       * @return  log file reference
       *
       */
      
      FILE* getLog( void ) const;
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
102
103
104
105
106
107
108
109
110
      /** 
       * Zero forces
       *
       * @param context OpenMMContextImpl context 
       *
       */
      
      void zeroForces( OpenMMContextImpl& context );
      
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
      /** 
       * Compute forces
       *
       * @param context OpenMMContextImpl context 
       *
       */
      
      void computeForces( OpenMMContextImpl& context );
      
      /** 
       * Compute energy
       *
       * @param context OpenMMContextImpl context 
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
127
      double computeEnergy( OpenMMContextImpl& context );
128
129
130
131
132
133
134
135
      
      /** 
       * Set trigger Force Kernel
       *
       * @param triggerForceKernel kernel to calculate force
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
136
      void setTriggerForceKernel( void* triggerForceKernel );
137
138
      
      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
139
       * Get trigger Force Kernel
140
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
141
       * @return triggerForceKernel kernel to calculate force
142
143
144
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
145
      void* getTriggerForceKernel( void ) const;
146
147
      
      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
148
       * Set trigger Energy Kernel
149
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
150
       * @param triggerEnergyKernel kernel to calculate force
151
152
153
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
154
      void setTriggerEnergyKernel( void* triggerEnergyKernel );
155
156
157
158
      
      /** 
       * Get trigger Energy Kernel
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
159
       * @return triggerEnergyKernel kernel to calculate force
160
161
162
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
163
      void* getTriggerEnergyKernel( void ) const;
164
165
      
      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
166
       * Get BrookBondParameters for harmonic bond force
167
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
168
169
170
171
172
173
174
175
176
177
       * @return brookBondParameters for BrookBondParameters for harmonic bond force
       *
       */
      
      BrookBondParameters* getHarmonicBondForceParameters( void );
      
      /** 
       * Set BrookBondParameters for harmonic bond force
       * 
       * @param brookBondParameters BrookBondParameters for harmonic bond force
178
179
180
181
182
183
184
       *
       * @return DefaultReturnValue
       *
       */
      
      int setHarmonicBondForceParameters( BrookBondParameters* brookBondParameters );
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
185
186
187
188
189
190
191
192
193
      /** 
       * Get BrookBondParameters for harmonic angle force
       * 
       * @return brookBondParameters for BrookBondParameters for harmonic angle force
       *
       */
      
      BrookBondParameters* getHarmonicAngleForceParameters( void );
      
194
195
196
197
198
199
200
201
202
203
204
205
      /** 
       * Set BrookBondParameters for harmonic angle force
       * 
       * @param brookBondParameters brookBondParameters for BrookBondParameters for harmonic angle force
       *
       * @return DefaultReturnValue
       *
       */
      
      int setHarmonicAngleForceParameters( BrookBondParameters* brookBondParameters );
      
      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
206
207
208
209
210
211
212
213
214
215
       * Get BrookBondParameters for periodic torsion force
       * 
       * @return brookBondParameters for BrookBondParameters for periodic torsion force
       *
       */
      
      BrookBondParameters* getPeriodicTorsionForceParameters( void );

      /** 
       * Set BrookBondParameters for periodic torsion force
216
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
217
       * @param brookBondParameters for periodic torsion force
218
219
220
221
222
223
224
225
       *
       * @return  DefaultReturnValue
       *
       */
      
      int setPeriodicTorsionForceParameters( BrookBondParameters* brookBondParameters );
      
      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
226
       * Get BrookBondParameters for RB torsion force
227
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
228
229
230
231
232
233
234
235
236
237
       * @return brookBondParameters for BrookBondParameters for RB torsion force
       *
       */
      
      BrookBondParameters* getRBTorsionForceParameters( void );

      /** 
       * Set BrookBondParameters for RB torsion force
       * 
       * @param brookBondParameters brookBondParameters for RB torsion force
238
239
240
241
242
243
244
       *
       * @return  DefaultReturnValue
       *
       */
      
      int setRBTorsionForceParameters( BrookBondParameters* brookBondParameters );
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
245
246
247
248
249
250
251
252
253
      /** 
       * Get BrookBondParameters for LJ 14 forces
       * 
       * @return brookBondParameters for BrookBondParameters for LJ 14 forces
       *
       */
      
      BrookBondParameters* getNonBonded14ForceParameters( void );

254
255
256
257
258
259
260
261
262
      /** 
       * Set BrookBondParameters for LJ 14 force
       * 
       * @param brookBondParameters brookBondParameters for LJ 14 force
       *
       * @return  DefaultReturnValue
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
263
264
265
266
267
268
269
270
271
272
      int setNonBonded14ForceParameters( BrookBondParameters* brookBondParameters );
      
      /** 
       * Get positions stream
       * 
       * @return particle positions 
       *
       */
         
      BrookStreamImpl* getParticlePositions( void );
273
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
      /** 
       * Set positions stream
       * 
       * @param positions Brook stream containing particle positions
       *
       * @return  DefaultReturnValue
       *
       */
      
      int setParticlePositions( BrookStreamImpl* positions );
      
      /** 
       * Get velocities stream
       * 
       * @return particle velocities
       *
       */
             
      BrookStreamImpl* getParticleVelocities( void );
       
      /** 
       * Set velocities stream
       * 
       * @param velocities Brook stream containing particle velocities
       *
       * @return  DefaultReturnValue
       *
       */
      
      int setParticleVelocities( BrookStreamImpl* velocities );
      
      /** 
       * Get forces stream
       * 
       * @return ParticleForces
       *
       */
             
      BrookStreamImpl* getParticleForces( void );

      /** 
       * Set forces stream
       * 
       * @param forces Brook stream containing particle forces
       *
       * @return  DefaultReturnValue
       *
       */
      
      int setParticleForces( BrookStreamImpl* forces );

325
326
   private:
   
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
327
328
329
      static const int DefaultReturnValue = 0;
      static const int ErrorReturnValue   = -1;

330
331
332
333
334
335
      enum BondParameterIndices { HarmonicBondIndex, HarmonicAngleIndex, PeriodicTorsionForceIndex, RbTorsionForceIndex, LJ14Index, LastBondForce };

      // log file reference

      FILE* _log;

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
336
       // number of particles
337

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
338
       int _numberOfParticles;
339
   
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
340
       // Brook bonded, nonbonded, Gbsa
341
342
343

       BrookBonded* _brookBonded;
       BrookNonBonded* _brookNonBonded;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
344
       BrookGbsa* _brookGbsa;
345

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
346
347
348
       void* _triggerForceKernel;
       void* _triggerEnergyKernel;

349
350
       BrookBondParameters* _bondParameters[LastBondForce];

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
351
352
353
354
355
356
       // context-related fields

       BrookStreamImpl* _positions;
       BrookStreamImpl* _velocities;
       BrookStreamImpl* _forces;

357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
       // used to calculate energy

       NonbondedForce*       _refForceField;
       System*               _refSystem;
       OpenMMContext*        _refOpenMMContext;
       ReferencePlatform*    _referencePlatform;
       VerletIntegrator*     _refVerletIntegrator;

      /** 
       * Set BrookBondParameters 
       * 
       * @param index
       * @param brookBondParameters brookBondParameters for BrookBondParameters
       *
       * @return DefaultReturnValue
       *
       */
      
      int _setBondParameters( BondParameterIndices index, BrookBondParameters* brookBondParameters );
      
};

} // namespace OpenMM

#endif /* OPENMM_BROOK_INTERFACE_H_ */