BrookVelocityCenterOfMassRemoval.cpp 18.3 KB
Newer Older
1
2
3
4
5
6
7
8
/* -------------------------------------------------------------------------- *
 *                                   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.               *
 *                                                                            *
9
10
 * Portions copyright (c) 2009 Stanford University and the Authors.           *
 * Authors: Mark Friedrichs, Mike Houston                                     *
11
12
 * Contributors:                                                              *
 *                                                                            *
13
14
15
16
 * 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.                                        *
17
 *                                                                            *
18
19
20
21
 * 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.                        *
22
 *                                                                            *
23
24
 * 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/>.      *
25
26
27
28
 * -------------------------------------------------------------------------- */

#include "BrookVelocityCenterOfMassRemoval.h"
#include "BrookPlatform.h"
29
#include "openmm/OpenMMException.h"
30
#include "BrookStreamImpl.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
31
#include "kernels/kcom.h"
32

33
34
#include <sstream>

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using namespace OpenMM;
using namespace std;

/** 
 *
 * Constructor
 * 
 */

BrookVelocityCenterOfMassRemoval::BrookVelocityCenterOfMassRemoval( ){

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::BrookVelocityCenterOfMassRemoval";

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
50
   BrookOpenMMFloat zero                    = static_cast<BrookOpenMMFloat>( 0.0 );
51
52
53

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
54
   _numberOfParticles           = -1;
55
56
57

   // mark stream dimension variables as unset

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
58
59
60
   _particleStreamWidth         = -1;
   _particleStreamHeight        = -1;
   _particleStreamSize          = -1;
61

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
62
   _totalInverseMass            = zero;
63
64
65
66
67
68
69
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

   for( int ii = 0; ii < LastStreamIndex; ii++ ){
      _streams[ii]   = NULL;
   }

}   
 
/** 
 * Destructor
 * 
 */

BrookVelocityCenterOfMassRemoval::~BrookVelocityCenterOfMassRemoval( ){

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::~BrookVelocityCenterOfMassRemoval";

// ---------------------------------------------------------------------------------------

   for( int ii = 0; ii < LastStreamIndex; ii++ ){
      delete _streams[ii];
   }

}

/** 
 * Get inverse of total mass
 * 
 * @return  inverse of total mass
 *
 */

BrookOpenMMFloat BrookVelocityCenterOfMassRemoval::getTotalInverseMass( void ) const {
   return _totalInverseMass;
}

/** 
 * Get inverse mass stream 
 *
 * @return  inverse mass stream
 *
 */

BrookFloatStreamInternal* BrookVelocityCenterOfMassRemoval::getMassStream( void ) const {
   return _streams[MassStream];
}

/** 
 * Get work stream 
 *
 * @return  work stream
 *
 */

BrookFloatStreamInternal* BrookVelocityCenterOfMassRemoval::getWorkStream( void ) const {
   return _streams[WorkStream];
}

/** 
 * Get linear momentum stream
 *
 * @return   linear momentum stream
 *
 */

BrookFloatStreamInternal* BrookVelocityCenterOfMassRemoval::getLinearMomentumStream( void ) const {
   return _streams[LinearMomentumStream];
}

133
134
135
136
137
138
139
140
141
142
/**
 * Get velocity-COM
 *
 * @param velocities velocities
 * @param  velocityCom                 output velocity com
 *
 * @return DefaultReturnValue
 *
 */
   
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
143
int BrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass( BrookStreamImpl& vStream, BrookOpenMMFloat velocityCom[3], BrookOpenMMFloat* ke ){
144
145
146

   // ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
147
   // static const std::string methodName  = "\nBrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass";
148

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
149
   BrookOpenMMFloat zero    = static_cast<BrookOpenMMFloat>( 0.0 );
150
151
152
153
154
155

   // ---------------------------------------------------------------------------------------

   // calculate linear momentum via reduction
   // subtract it (/totalMass) from velocities

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
156
   BrookStreamInternal* velocityStream  = dynamic_cast<BrookStreamInternal*> (vStream.getBrookStreamInternal());
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
157
   *ke                                  = zero;
158
159

   void* velV                           = velocityStream->getData( 1 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
160
   const float* vArray                  = static_cast<float*>( velV );
161

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
162
   void* massV                          = getMassStream()->getData( 1 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
163
   const float* mArray                  = static_cast<float*>( massV );
164

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
165
   int numberOfParticles                = getNumberOfParticles();
166
167
168
169
   int index                            = 0;

   velocityCom[0] = velocityCom[1] = velocityCom[2] = zero;

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
170
   for( int ii = 0; ii < numberOfParticles; ii++, index += 3 ){
171
172
173
      velocityCom[0] += mArray[ii]*vArray[index];
      velocityCom[1] += mArray[ii]*vArray[index+1];
      velocityCom[2] += mArray[ii]*vArray[index+2];
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
174
                 *ke += mArray[ii]*( vArray[index]*vArray[index] + vArray[index+1]*vArray[index+1] + vArray[index+2]*vArray[index+2] );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
175
if( 0 && ii < 3 ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
176
fprintf( stderr, "getVelocityCenterOfMass %5d %5d m=%15.6e v[%15.6e %15.6e %15.6e ] %d\n", ii, index, mArray[ii], vArray[index], vArray[index+1], vArray[index+2], numberOfParticles );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
177
}
178
179
   }

180
181
182
183
   return DefaultReturnValue;
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
184
 * Get Particle stream size
185
 *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
186
 * @return  Particle stream size
187
188
189
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
190
191
int BrookVelocityCenterOfMassRemoval::getComParticleStreamSize( void ) const {
   return _particleStreamSize;
192
193
194
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
195
 * Get particle stream width
196
 *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
197
 * @return  particle stream width
198
199
200
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
201
202
int BrookVelocityCenterOfMassRemoval::getComParticleStreamWidth( void ) const {
   return _particleStreamWidth;
203
204
205
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
206
 * Get particle stream height
207
 *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
208
 * @return particle stream height
209
210
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
211
212
int BrookVelocityCenterOfMassRemoval::getComParticleStreamHeight( void ) const {
   return _particleStreamHeight;
213
214
215
216
217
}

/** 
 * Initialize stream dimensions
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
218
 * @param numberOfParticles             number of particles
219
220
221
222
223
224
 * @param platform                  platform
 *      
 * @return ErrorReturnValue if error, else DefaultReturnValue
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
225
int BrookVelocityCenterOfMassRemoval::_initializeStreamSizes( int numberOfParticles, const Platform& platform ){
226
227
228
229
230
231
232

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::_initializeStreamSizes";

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
233
234
235
   _particleStreamSize     = getParticleStreamSize( platform );
   _particleStreamWidth    = getParticleStreamWidth( platform );
   _particleStreamHeight   = getParticleStreamHeight( platform );
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254

   return DefaultReturnValue;
}

/** 
 * Initialize streams
 * 
 * @param platform                  platform
 *
 * @return ErrorReturnValue if error, else DefaultReturnValue
 *
 */

int BrookVelocityCenterOfMassRemoval::_initializeStreams( const Platform& platform ){

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::_initializeStreams";

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
255
   BrookOpenMMFloat dangleValue     = static_cast<BrookOpenMMFloat>( 0.0 );
256
257
258

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
259
260
   int particleStreamSize           = getComParticleStreamSize();
   int particleStreamWidth          = getComParticleStreamWidth();
261
262

    _streams[WorkStream]            = new BrookFloatStreamInternal( BrookCommon::BrookVelocityCenterOfMassRemovalWorkStream,
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
263
                                                                    particleStreamSize, particleStreamWidth,
264
                                                                    BrookStreamInternal::Float3, dangleValue );
265
266
267


    _streams[MassStream]            = new BrookFloatStreamInternal( BrookCommon::BrookVelocityCenterOfMassRemovalMassStream,
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
268
                                                                    particleStreamSize, particleStreamWidth,
269
270
271
272
                                                                    BrookStreamInternal::Float, dangleValue );


    _streams[LinearMomentumStream]  = new BrookFloatStreamInternal( "LinearMomentumStream",
273
                                                                    1, 1, BrookStreamInternal::Float3, dangleValue );
274
275
276
277
278
279


   return DefaultReturnValue;
}

/** 
280
 * Set masses & _totalInverseMass 
281
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
282
 * @param masses             particle masses
283
284
285
286
287
288
289
290
291
 *
 */

int BrookVelocityCenterOfMassRemoval::_setMasses( const std::vector<double>& masses ){

// ---------------------------------------------------------------------------------------

   static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::_setMasses";

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
292
293
   BrookOpenMMFloat zero                    = static_cast<BrookOpenMMFloat>( 0.0 );
   BrookOpenMMFloat one                     = static_cast<BrookOpenMMFloat>( 1.0 );
294
295
296

// ---------------------------------------------------------------------------------------

297
298
   // check that masses vector is not larger than expected

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
299
   if( (int) masses.size() > getComParticleStreamSize() ){
300
      std::stringstream message;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
301
      message << methodName << " mass array size=" << masses.size() << " is larger than stream size=" << getComParticleStreamSize();
302
303
304
      throw OpenMMException( message.str() );
   }

305
   // setup masses
306

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
307
308
   BrookOpenMMFloat* localMasses = new BrookOpenMMFloat[getComParticleStreamSize()];
   memset( localMasses, 0, sizeof( BrookOpenMMFloat )*getComParticleStreamSize() );
309
310

   int index          = 0;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
311
   _totalInverseMass  = zero;
312
313
314
   for( std::vector<double>::const_iterator ii = masses.begin(); ii != masses.end(); ii++, index++ ){
      if( *ii != 0.0 ){
         BrookOpenMMFloat value    = static_cast<BrookOpenMMFloat>(*ii);
315
         localMasses[index]        = value;
316
317
318
         _totalInverseMass        += value;
      }
   }
319
320
321

   // 1/Sum[masses]

322
323
324
325
   if( _totalInverseMass > zero ){
      _totalInverseMass = one/_totalInverseMass;
   }

326
327
328
   // write masses to board

   _streams[MassStream]->loadFromArray( localMasses );
329

330
   delete[] localMasses;
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352

   return DefaultReturnValue;
}   
 
/*  
 * Setup of StochasticDynamics parameters
 *
 * @param masses                masses
 * @param platform              Brook platform
 *
 * @return nonzero value if error
 *
 * */
    
int BrookVelocityCenterOfMassRemoval::setup( const std::vector<double>& masses, const Platform& platform ){
    
// ---------------------------------------------------------------------------------------

   static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::setup";

// ---------------------------------------------------------------------------------------

353
   const BrookPlatform& brookPlatform       = dynamic_cast<const BrookPlatform&> (platform);
354
355
   setLog( brookPlatform.getLog() );

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
356
   int numberOfParticles                    = (int) masses.size();
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
357
   setNumberOfParticles( numberOfParticles );
358
359
360

   // set stream sizes and then create streams

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
361
   _initializeStreamSizes( numberOfParticles, platform );
362
363
364
365
   _initializeStreams( platform );

   _setMasses( masses );

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
366
367
368
   if( 1 && getLog() ){
      FILE* log             = getLog();
      std::string contents  = getContentsString( 0 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
369
370
      (void) fprintf( log, "%s contents:\n%s\n", methodName.c_str(), contents.c_str() );
      (void) fflush( log );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
371
372
   }
   
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
   return DefaultReturnValue;
}

/* 
 * Get contents of object
 *
 * @param level   level of dump
 *
 * @return string containing contents
 *
 * */

std::string BrookVelocityCenterOfMassRemoval::getContentsString( int level ) const {

// ---------------------------------------------------------------------------------------

   static const std::string methodName      = "BrookVelocityCenterOfMassRemoval::getContentsString";

   static const unsigned int MAX_LINE_CHARS = 256;
   char value[MAX_LINE_CHARS];
   static const char* Set                   = "Set";
   static const char* NotSet                = "Not set";

// ---------------------------------------------------------------------------------------

   std::stringstream message;
   std::string tab   = "   ";

401
#ifdef _MSC_VER
402
403
404
405
406
#define LOCAL_SPRINTF(a,b,c) sprintf_s( (a), MAX_LINE_CHARS, (b), (c) );   
#else
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );   
#endif

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
407
408
   (void) LOCAL_SPRINTF( value, "%d", getNumberOfParticles() );
   message << _getLine( tab, "Number of particles:", value ); 
409

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
410
411
   (void) LOCAL_SPRINTF( value, "%d", getComParticleStreamWidth() );
   message << _getLine( tab, "Particle stream width:", value ); 
412

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
413
414
   (void) LOCAL_SPRINTF( value, "%d", getComParticleStreamHeight() );
   message << _getLine( tab, "Particle stream height:", value ); 
415

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
416
417
   (void) LOCAL_SPRINTF( value, "%d", getComParticleStreamSize() );
   message << _getLine( tab, "Particle stream size:", value ); 
418

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
419
   (void) LOCAL_SPRINTF( value, "%.5e", getTotalInverseMass() );
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
   message << _getLine( tab, "TotalInverseMass:", value ); 

   message << _getLine( tab, "Log:",                  (getLog()                  ? Set : NotSet) ); 

   message << _getLine( tab, "Mass:",                 (getMassStream()           ? Set : NotSet) ); 
   message << _getLine( tab, "Work:",                 (getWorkStream()           ? Set : NotSet) ); 
   message << _getLine( tab, "LinearMomentum:",       (getLinearMomentumStream() ? Set : NotSet) ); 
 
   for( int ii = 0; ii < LastStreamIndex; ii++ ){
      message << std::endl;
      if( _streams[ii] ){
         message << _streams[ii]->getContentsString( );
      }
   }

#undef LOCAL_SPRINTF

   return message.str();
}
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
439
440
441
442
443
444
445
446
447
448
449
450
451
452
/**
 * Remove velocity-COM
 *
 * @param velocities velocities
 *
 * @return DefaultReturnValue
 *
 */
   
int BrookVelocityCenterOfMassRemoval::removeVelocityCenterOfMass( BrookStreamImpl& velocityStream ){

   // ---------------------------------------------------------------------------------------

   static const std::string methodName  = "BrookVelocityCenterOfMassRemoval::removeVelocityCenterOfMass";
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
453
   static       int printOn             = 0;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
454
   static const double boltz            = 8.3145112119486e-03;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
455
   FILE* log;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
456
   BrookOpenMMFloat ke;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
457
458
459

   // ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
460
461
462
463
464
465
466
467
468
469
470
//setLog( stderr );
   if( printOn && getLog() ){
      log = getLog();
   } else {
      printOn = 0;
   }

   // diagnostics

   if( printOn ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
471
      BrookOpenMMFloat com[3];
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
472
      getVelocityCenterOfMass( velocityStream, com, &ke );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
473
474
475

      BrookOpenMMFloat denomiator = static_cast<float>( 3*getNumberOfParticles())*static_cast<float>( boltz );
      (void) fprintf( log, "%s Pre removal com: [%12.5e %12.5e %12.5e] ke=%.3f ~T=%.3f\n", 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
476
477
                      methodName.c_str(), com[0], com[1], com[2], ke, ke/denomiator );
      BrookStreamInternal* outputVelocityStream = dynamic_cast<BrookStreamInternal*> (velocityStream.getBrookStreamInternal());
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
478
479

      void* velV                       = outputVelocityStream->getData( 1 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
480
      const float* vArray              = static_cast<float*>( velV );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
481
482

      int index                        = 0;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
483
      if( printOn > 1 ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
484
         for( int ii = 0; ii < getNumberOfParticles(); ii++, index += 3 ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
485
            (void) fprintf( log, "V %d [%12.5e %12.5e %12.5e]\n", ii, vArray[index], vArray[index+1], vArray[index+2] );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
486
487
         }
      }
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
488
      (void) fflush( log );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
489
490
491
492
493
494
495
496
497
498
   }

   // calculate linear momentum via reduction
   // subtract it (/totalMass) from velocities

   kCalculateLinearMomentum( getMassStream()->getBrookStream(), velocityStream.getBrookStream(), getWorkStream()->getBrookStream() );
   kSumLinearMomentum( (float) getComParticleStreamWidth(), (float) getNumberOfParticles(), (float) getTotalInverseMass(),
                        getWorkStream()->getBrookStream(), getLinearMomentumStream()->getBrookStream() );
   kRemoveLinearMomentum( getLinearMomentumStream()->getBrookStream(), velocityStream.getBrookStream(), velocityStream.getBrookStream() );

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
499
500
501
502
   // diagnostics

   if( printOn ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
503
      BrookOpenMMFloat com[3];
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
504

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
505
      getVelocityCenterOfMass( velocityStream, com, &ke );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
506
507
508
      BrookOpenMMFloat denomiator = static_cast<float>( 3*getNumberOfParticles() )*static_cast<float>( boltz );

      (void) fprintf( log, "%s strW=%d iatm=%d invMass=%.4e\n   Post removal com: [%12.5e %12.5e %12.5e]  ke=%.3f ~T=%.3f\n",
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
509
510
511
                      methodName.c_str(),
                      getComParticleStreamWidth(), getNumberOfParticles(), getTotalInverseMass(),  com[0], com[1], com[2],
                      ke, ke/denomiator );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
512
513

      void* linMoV = getLinearMomentumStream()->getData( 1 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
514
515
      float* linMo = static_cast<float*>( linMoV );
      (void) fprintf( log, "   LM [%12.5e %12.5e %12.5e]\n", linMo[0], linMo[1], linMo[2] );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
516

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
517
      BrookStreamInternal* outputVelocityStream = dynamic_cast<BrookStreamInternal*> (velocityStream.getBrookStreamInternal());
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
518

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
519
520
      void* velV                      = outputVelocityStream->getData( 1 );
      const float* vArray             = static_cast<float*>( velV );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
521
522

      void* w1                        = getWorkStream()->getData( 1 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
523
      const float* w2                 = static_cast<float*>( w1 );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
524

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
525
      if( printOn > 1 ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
526
527
         int index                        = 0;
         for( int ii = 0; ii < getNumberOfParticles(); ii++, index += 3 ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
528
            (void) fprintf( log, "V %d [%12.5e %12.5e %12.5e] [%12.5e %12.5e %12.5e]\n", ii,
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
529
530
531
532
                            vArray[index], vArray[index+1], vArray[index+2], w2[index], w2[index+1], w2[index+2] );
   
         }
      }
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
533
      (void) fflush( log );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
534
535
536
537
538
539
540

//exit(0);
   }

   return DefaultReturnValue;
}