"vscode:/vscode.git/clone" did not exist on "9202aec4edeb1354f455e97db6aef94f1140efa4"
Commit 1da5441e authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Mods

parent 956f3183
...@@ -127,29 +127,33 @@ double BrookCalcKineticEnergyKernel::execute( OpenMMContextImpl& context ){ ...@@ -127,29 +127,33 @@ double BrookCalcKineticEnergyKernel::execute( OpenMMContextImpl& context ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
void* dataV = _openMMBrookInterface.getParticleVelocities()->getData( );
float* velocity = (float*) dataV;
double energy = 0.0;
int index = 0;
if( _masses == NULL ){ if( _masses == NULL ){
std::stringstream message; std::stringstream message;
message << methodName << " masses not set."; message << methodName << " masses not set.";
throw OpenMMException( message.str() ); throw OpenMMException( message.str() );
} }
/* void* dataV = _openMMBrookInterface.getParticleVelocities()->getData( 1 );
printf( " BrookCalcKineticEnergyKernel Masses=%12.5e %12.5e", _masses[0], _masses[1] ); float* velocity = (float*) dataV;
printf( " [%12.5e %12.5e %12.5e]", velocity[index], velocity[index+1], velocity[index+2] ); double energy = 0.0;
index += 3; int index = 0;
printf( " [%12.5e %12.5e %12.5e]\n", velocity[index], velocity[index+1], velocity[index+2] );
printf( "BrookCalcKineticEnergyKernel:\n" );
double com[3] = { 0.0, 0.0, 0.0 };
for ( int ii = 0; ii < _numberOfParticles; ii++, index += 3 ){
com[0] += velocity[index];
com[1] += velocity[index+1];
com[2] += velocity[index+2];
printf( " %d %.3f [%12.5e %12.5e %12.5e]\n", ii, _masses[ii], velocity[index], velocity[index+1], velocity[index+2] );
}
printf( "Com [%12.5e %12.5e %12.5e]\n", com[0], com[1], com[2] );
index = 0; index = 0;
*/
for ( int ii = 0; ii < _numberOfParticles; ii++, index += 3 ){ for ( int ii = 0; ii < _numberOfParticles; ii++, index += 3 ){
energy += _masses[ii]*(velocity[index]*velocity[index] + velocity[index + 1]*velocity[index + 1] + velocity[index + 2]*velocity[index + 2]); energy += _masses[ii]*(velocity[index]*velocity[index] + velocity[index + 1]*velocity[index + 1] + velocity[index + 2]*velocity[index + 2]);
} }
printf( " Ke=%12.5e\n", 0.5*energy );
return 0.5*energy; return 0.5*energy;
} }
...@@ -271,6 +271,17 @@ void* BrookStreamImpl::getData( void ){ ...@@ -271,6 +271,17 @@ void* BrookStreamImpl::getData( void ){
return _brookStreamInternal->getData( ); return _brookStreamInternal->getData( );
} }
/**
* Set every element of this stream to the same value.
*
* @param readFromBoard if set, read data from board
*
* @return data array
*/
void* BrookStreamImpl::getData( int readFromBoard ){
return _brookStreamInternal->getData( readFromBoard );
}
/** /**
* Get Brook stream * Get Brook stream
* *
......
...@@ -114,7 +114,8 @@ class BrookStreamImpl : public StreamImpl { ...@@ -114,7 +114,8 @@ class BrookStreamImpl : public StreamImpl {
* @return data array * @return data array
*/ */
void* getData( void ); void* getData( void );
void* getData( int readFromBoard );
/** /**
* Get Brook stream * Get Brook stream
* *
......
...@@ -174,15 +174,16 @@ int BrookVelocityCenterOfMassRemoval::removeVelocityCenterOfMass( BrookStreamImp ...@@ -174,15 +174,16 @@ int BrookVelocityCenterOfMassRemoval::removeVelocityCenterOfMass( BrookStreamImp
// subtract it (/totalMass) from velocities // subtract it (/totalMass) from velocities
kCalculateLinearMomentum( getMassStream()->getBrookStream(), velocityStream.getBrookStream(), getWorkStream()->getBrookStream() ); kCalculateLinearMomentum( getMassStream()->getBrookStream(), velocityStream.getBrookStream(), getWorkStream()->getBrookStream() );
kSumLinearMomentum( (float) getComParticleStreamWidth(), (float) getNumberOfParticles(), getWorkStream()->getBrookStream(), getLinearMomentumStream()->getBrookStream() ); kSumLinearMomentum( (float) getComParticleStreamWidth(), (float) getNumberOfParticles(), (float) getTotalInverseMass(),
kScale( (float) getTotalInverseMass(), getLinearMomentumStream()->getBrookStream(), getLinearMomentumStream()->getBrookStream() ); getWorkStream()->getBrookStream(), getLinearMomentumStream()->getBrookStream() );
// kScale( (float) getTotalInverseMass(), getLinearMomentumStream()->getBrookStream(), getLinearMomentumStream()->getBrookStream() );
kRemoveLinearMomentum( getLinearMomentumStream()->getBrookStream(), velocityStream.getBrookStream(), velocityStream.getBrookStream() ); kRemoveLinearMomentum( getLinearMomentumStream()->getBrookStream(), velocityStream.getBrookStream(), velocityStream.getBrookStream() );
if( (0 || debug) && getLog() ){ if( (0 || debug) && getLog() ){
BrookOpenMMFloat com[3]; BrookOpenMMFloat com[3];
getVelocityCenterOfMass( velocityStream, com ); getVelocityCenterOfMass( velocityStream, com );
(void) fprintf( getLog(), "%s strW=%d iatm=%d Post removal com: [%12.5e %12.5e %12.5e]", methodName, (void) fprintf( getLog(), "%s strW=%d iatm=%d invMass=%.4e Post removal com: [%12.5e %12.5e %12.5e]", methodName,
getComParticleStreamWidth(), getNumberOfParticles(), com[0], com[1], com[2] ); getComParticleStreamWidth(), getNumberOfParticles(), getTotalInverseMass(), com[0], com[1], com[2] );
void* linMoV = getLinearMomentumStream()->getData( 1 ); void* linMoV = getLinearMomentumStream()->getData( 1 );
float* linMo = (float*) linMoV; float* linMo = (float*) linMoV;
...@@ -227,7 +228,6 @@ int BrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass( BrookStreamImpl& ...@@ -227,7 +228,6 @@ int BrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass( BrookStreamImpl&
// static const char* methodName = "\nBrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass"; // static const char* methodName = "\nBrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass";
static int debug = 0;
BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0; BrookOpenMMFloat zero = (BrookOpenMMFloat) 0.0;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -240,10 +240,10 @@ int BrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass( BrookStreamImpl& ...@@ -240,10 +240,10 @@ int BrookVelocityCenterOfMassRemoval::getVelocityCenterOfMass( BrookStreamImpl&
void* velV = velocityStream->getData( 1 ); void* velV = velocityStream->getData( 1 );
const float* vArray = (float*) velV; const float* vArray = (float*) velV;
void* massV = getMassStream()->getData( 1); void* massV = getMassStream()->getData( 1 );
const float* mArray = (float*) massV; const float* mArray = (float*) massV;
int numberOfParticles = getNumberOfParticles(); int numberOfParticles = getNumberOfParticles();
int index = 0; int index = 0;
velocityCom[0] = velocityCom[1] = velocityCom[2] = zero; velocityCom[0] = velocityCom[1] = velocityCom[2] = zero;
...@@ -329,12 +329,12 @@ int BrookVelocityCenterOfMassRemoval::_initializeStreams( const Platform& platfo ...@@ -329,12 +329,12 @@ int BrookVelocityCenterOfMassRemoval::_initializeStreams( const Platform& platfo
//static const std::string methodName = "BrookVelocityCenterOfMassRemoval::_initializeStreams"; //static const std::string methodName = "BrookVelocityCenterOfMassRemoval::_initializeStreams";
BrookOpenMMFloat dangleValue = (BrookOpenMMFloat) 0.0; BrookOpenMMFloat dangleValue = (BrookOpenMMFloat) 0.0;
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
int particleStreamSize = getComParticleStreamSize(); int particleStreamSize = getComParticleStreamSize();
int particleStreamWidth = getComParticleStreamWidth(); int particleStreamWidth = getComParticleStreamWidth();
_streams[WorkStream] = new BrookFloatStreamInternal( BrookCommon::BrookVelocityCenterOfMassRemovalWorkStream, _streams[WorkStream] = new BrookFloatStreamInternal( BrookCommon::BrookVelocityCenterOfMassRemovalWorkStream,
particleStreamSize, particleStreamWidth, particleStreamSize, particleStreamWidth,
...@@ -440,6 +440,12 @@ int BrookVelocityCenterOfMassRemoval::setup( const std::vector<double>& masses, ...@@ -440,6 +440,12 @@ int BrookVelocityCenterOfMassRemoval::setup( const std::vector<double>& masses,
_setMasses( masses ); _setMasses( masses );
if( 1 && getLog() ){
std::string contents = getContentsString( 0 );
(void) fprintf( getLog(), "%s contents:\n%s\n", methodName.c_str(), contents.c_str() );
(void) fflush( getLog() );
}
return DefaultReturnValue; return DefaultReturnValue;
} }
......
...@@ -85,7 +85,7 @@ reduce void kReduceLinearMomentum( float3 momentum<>, reduce float3 linearMoment ...@@ -85,7 +85,7 @@ reduce void kReduceLinearMomentum( float3 momentum<>, reduce float3 linearMoment
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
kernel void kSumLinearMomentum( float atomStrWidth, float numberOfAtoms, float3 momentum[][], kernel void kSumLinearMomentum( float atomStrWidth, float numberOfAtoms, float scale, float3 momentum[][],
out float3 linearMomentum<> ){ out float3 linearMomentum<> ){
float atomCount; float atomCount;
...@@ -108,6 +108,7 @@ kernel void kSumLinearMomentum( float atomStrWidth, float numberOfAtoms, float3 ...@@ -108,6 +108,7 @@ kernel void kSumLinearMomentum( float atomStrWidth, float numberOfAtoms, float3
atomCount += 1.0f; atomCount += 1.0f;
} }
linearMomentum *= scale;
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
......
...@@ -42,11 +42,12 @@ void kSum( ::brook::stream array, ::brook::stream sum ); ...@@ -42,11 +42,12 @@ void kSum( ::brook::stream array, ::brook::stream sum );
@param atomStrWidth atom stream width @param atomStrWidth atom stream width
@param numberOfAtoms number of atoms @param numberOfAtoms number of atoms
@param scale sum of inverse masses
@param momentum momentum @param momentum momentum
@param linearMomentum total momentum @param linearMomentum total momentum
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
void kSumLinearMomentum( float atomStrWidth, float numberOfAtoms, ::brook::stream momentum, ::brook::stream linearMomentum ); void kSumLinearMomentum( float atomStrWidth, float numberOfAtoms, float scale, ::brook::stream momentum, ::brook::stream linearMomentum );
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment