BrookVelocityCenterOfMassRemoval.h 6.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#ifndef OPENMM_BROOK_VELOCITY_CENTER_OF_MASS_REMOVAL_H_
#define OPENMM_BROOK_VELOCITY_CENTER_OF_MASS_REMOVAL_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.               *
 *                                                                            *
12
13
 * Portions copyright (c) 2009 Stanford University and the Authors.           *
 * Authors: Mark Friedrichs, Mike Houston                                     *
14
15
 * Contributors:                                                              *
 *                                                                            *
16
17
18
19
 * This program is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU Lesser General Public License as published   *
 * by the Free Software Foundation, either version 3 of the License, or       *
 * (at your option) any later version.                                        *
20
 *                                                                            *
21
22
23
24
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU Lesser General Public License for more details.                        *
25
 *                                                                            *
26
27
 * You should have received a copy of the GNU Lesser General Public License   *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
28
29
30
31
32
 * -------------------------------------------------------------------------- */

#include <vector>
#include <set>

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
33
34
#include "BrookStreamImpl.h"
//#include "BrookFloatStreamInternal.h"
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "BrookPlatform.h"
#include "BrookCommon.h"

namespace OpenMM {

/**
 *
 * Encapsulates removal of center of mass
 *
 */

class BrookVelocityCenterOfMassRemoval : public BrookCommon {

   public:
  
      /** 
       * Constructor
       * 
       */
      
      BrookVelocityCenterOfMassRemoval( );
  
      /** 
       * Destructor
       * 
       */
      
      ~BrookVelocityCenterOfMassRemoval( );
  
      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
65
       * Get  particle stream width
66
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
67
       * @return particle stream width
68
69
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
70
      int getComParticleStreamWidth( void ) const; 
71
72

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
73
       * Get  particle stream height
74
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
75
       * @return particle stream height
76
77
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
78
      int getComParticleStreamHeight( void ) const;
79
80

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
81
       * Get  particle stream size
82
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
83
       * @return particle stream size
84
85
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
86
      int getComParticleStreamSize( void ) const; 
87
88

      /** 
89
       * Remove velocity center-of-mass
90
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
91
       * @param  velocities                  particle velocities
92
93
94
95
96
       *
       * @return  DefaultReturnValue
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
97
      int removeVelocityCenterOfMass( BrookStreamImpl& velocityStream );
98

99
      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
100
       * Get velocity center-of-mass and kinetic energy (used for diagnostics)
101
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
102
       * @param  velocities                  particle velocities
103
       * @param  velocityCom                 output velocity com
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
104
       * @param  ke                          output kinetic energy
105
106
107
108
109
       *
       * @return  DefaultReturnValue
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
110
      int getVelocityCenterOfMass( BrookStreamImpl& vStream, BrookOpenMMFloat velocityCom[3], BrookOpenMMFloat* ke );
111

112
113
114
      /* 
       * Setup of  parameters
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
115
       * @param masses                particle masses
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
       * @param platform              Brook platform
       *
       * @return ErrorReturnValue value if error, else DefaultReturnValue
       *
       * */
      
      int setup( const std::vector<double>& masses, const Platform& platform  );
      
      /* 
       * Get contents of object
       *
       * @param level of dump
       *
       * @return string containing contents
       *
       * */
      
      std::string getContentsString( int level = 0 ) const;

      /**
       * Get inverse of total mass
       *
       * @return inverse of total mass
       *
       */
         
      BrookOpenMMFloat getTotalInverseMass( void ) const;
      
      /** 
       * Get inverse mass stream 
       *
       * @return  inverse mass stream
       *
       */
      
      BrookFloatStreamInternal* getMassStream( void ) const;
      
      /** 
       * Get work stream 
       *
       * @return  work stream
       *
       */
      
      BrookFloatStreamInternal* getWorkStream( void ) const;
      
      /** 
       * Get linear momentum stream 
       *
       * @return  linear momentum stream
       *
       */
      
      BrookFloatStreamInternal* getLinearMomentumStream( void ) const;
      
   private:
   
      // streams indices

      enum BrookVelocityCenterOfMassRemovalStreams { 
              MassStream,
              WorkStream,
              LinearMomentumStream,
              LastStreamIndex
           };

      BrookOpenMMFloat _totalInverseMass;

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
184
      // Particle stream dimensions
185

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
186
187
188
      int _particleStreamWidth;
      int _particleStreamHeight;
      int _particleStreamSize;
189
190
191
192
193
194
195
196

      // internal streams

      BrookFloatStreamInternal* _streams[LastStreamIndex];

      /* 
       * Setup of stream dimensions
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
197
198
       * @param particleStreamSize        particle stream size
       * @param particleStreamWidth       particle stream width
199
200
201
202
203
       *
       * @return ErrorReturnValue if error, else DefaultReturnValue
       *
       * */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
204
      int _initializeStreamSizes( int particleStreamSize, int particleStreamWidth );
205
206
207
208

      /** 
       * Initialize stream dimensions
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
209
       * @param numberOfParticles         number of particles
210
211
212
213
214
215
       * @param platform                  platform
       *
       * @return ErrorReturnValue if error, else DefaultReturnValue
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
216
      int _initializeStreamSizes( int numberOfParticles, const Platform& platform );
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
      
      /** 
       * Initialize stream dimensions and streams
       * 
       * @param platform                  platform
       *
       * @return nonzero value if error
       *
       */
      
      int _initializeStreams( const Platform& platform );

      /** 
       * Set inverse masses 
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
232
       * @param masses             particle masses
233
234
235
236
237
238
239
240
241
242
243
       *
       */
      
      int _setMasses( const std::vector<double>& masses );
      
      
};

} // namespace OpenMM

#endif /* OPENMM_BROOK_VELOCITY_CENTER_OF_MASS_REMOVAL_H_ */