Commit 2bdb84bd authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Updated unit tests

parent f1f974c2
...@@ -293,12 +293,14 @@ void testOneAngle( FILE* log ) { ...@@ -293,12 +293,14 @@ void testOneAngle( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaHarmonicAngleForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
FILE* log = fopen( "AmoebaHarmonicAngleForce.log", "w" );; //FILE* log = fopen( "AmoebaHarmonicAngleForce.log", "w" );;
FILE* log = NULL;
testOneAngle( log ); testOneAngle( log );
fclose( log ); if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -203,12 +203,17 @@ void testTwoBond( FILE* log ) { ...@@ -203,12 +203,17 @@ void testTwoBond( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaHarmonicBondForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
FILE* log = stderr; FILE* log = NULL;
//FILE* log = stderr;
testOneBond( log ); //testOneBond( log );
testTwoBond( log ); testTwoBond( log );
if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -370,12 +370,15 @@ void testOneAngle( FILE* log ) { ...@@ -370,12 +370,15 @@ void testOneAngle( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaHarmonicInPlaneAngleForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
FILE* log = fopen( "AmoebaHarmonicInPlaneAngleForce.log", "w" );; FILE* log = NULL;
//FILE* log = fopen( "AmoebaHarmonicInPlaneAngleForce.log", "w" );;
testOneAngle( NULL ); testOneAngle( NULL );
(void) fclose( log ); if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
using namespace OpenMM; using namespace OpenMM;
const double TOL = 1e-5; const double TOL = 1e-3;
#define PI_M 3.141592653589 #define PI_M 3.141592653589
#define RADIAN 57.29577951308 #define RADIAN 57.29577951308
...@@ -492,17 +492,20 @@ void testOneOutOfPlaneBend2( FILE* log, int setId ) { ...@@ -492,17 +492,20 @@ void testOneOutOfPlaneBend2( FILE* log, int setId ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaOutOfPlaneBendForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
//FILE* log = stderr; //FILE* log = stderr;
FILE* log = NULL;
//FILE* log = fopen( "AmoebaOutOfPlaneBendForce.log", "w" );;
FILE* log = fopen( "AmoebaOutOfPlaneBendForce1.log", "w" );; testOneOutOfPlaneBend( log );
//testOneOutOfPlaneBend( log );
//testOneOutOfPlaneBend2( log, atoi( argv[1] ) ); //testOneOutOfPlaneBend2( log, atoi( argv[1] ) );
for( int ii = 1; ii <= 6; ii++ ){ //for( int ii = 1; ii <= 6; ii++ ){
testOneOutOfPlaneBend2( log, ii ); // testOneOutOfPlaneBend2( log, ii );
} //}
(void) fclose( log ); if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -301,13 +301,15 @@ void testOnePiTorsion( FILE* log ) { ...@@ -301,13 +301,15 @@ void testOnePiTorsion( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaPiTorsionForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
FILE* log = NULL;
//FILE* log = stderr; //FILE* log = stderr;
//FILE* log = fopen( "AmoebaPiTorsionForce1.log", "w" );;
FILE* log = fopen( "AmoebaPiTorsionForce1.log", "w" );;
testOnePiTorsion( log ); testOnePiTorsion( log );
(void) fclose( log ); if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -283,13 +283,15 @@ void testOneStretchBend( FILE* log ) { ...@@ -283,13 +283,15 @@ void testOneStretchBend( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaStretchBendForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
//FILE* log = stderr;
FILE* log = fopen( "AmoebaStretchBendForce1.log", "w" );; FILE* log = NULL;
//FILE* log = stderr;
//FILE* log = fopen( "AmoebaStretchBendForce1.log", "w" );;
testOneStretchBend( log ); testOneStretchBend( log );
(void) fclose( log ); if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
using namespace OpenMM; using namespace OpenMM;
const double TOL = 1e-5; const double TOL = 1e-3;
#define PI_M 3.141592653589 #define PI_M 3.141592653589
#define RADIAN 57.29577951308 #define RADIAN 57.29577951308
...@@ -207,21 +207,21 @@ static void computeAmoebaTorsionForce(int bondIndex, std::vector<Vec3>& positio ...@@ -207,21 +207,21 @@ static void computeAmoebaTorsionForce(int bondIndex, std::vector<Vec3>& positio
// accumulate forces and energy // accumulate forces and energy
forces[particle1][0] += tempVector[0][0]; forces[particle1][0] -= tempVector[0][0];
forces[particle1][1] += tempVector[0][1]; forces[particle1][1] -= tempVector[0][1];
forces[particle1][2] += tempVector[0][2]; forces[particle1][2] -= tempVector[0][2];
forces[particle2][0] += tempVector[1][0]; forces[particle2][0] -= tempVector[1][0];
forces[particle2][1] += tempVector[1][1]; forces[particle2][1] -= tempVector[1][1];
forces[particle2][2] += tempVector[1][2]; forces[particle2][2] -= tempVector[1][2];
forces[particle3][0] += tempVector[2][0]; forces[particle3][0] -= tempVector[2][0];
forces[particle3][1] += tempVector[2][1]; forces[particle3][1] -= tempVector[2][1];
forces[particle3][2] += tempVector[2][2]; forces[particle3][2] -= tempVector[2][2];
forces[particle4][0] += tempVector[3][0]; forces[particle4][0] -= tempVector[3][0];
forces[particle4][1] += tempVector[3][1]; forces[particle4][1] -= tempVector[3][1];
forces[particle4][2] += tempVector[3][2]; forces[particle4][2] -= tempVector[3][2];
double energyTerm = 0.0; double energyTerm = 0.0;
for( int ii = 0; ii < 3; ii++ ){ for( int ii = 0; ii < 3; ii++ ){
...@@ -317,10 +317,10 @@ void testOneTorsion( FILE* log ) { ...@@ -317,10 +317,10 @@ void testOneTorsion( FILE* log ) {
std::vector<Vec3> positions(numberOfParticles); std::vector<Vec3> positions(numberOfParticles);
positions[0] = Vec3( 0.278860000E+02, 0.264630000E+02, 0.426300000E+01 ); positions[0] = Vec3( 0.278860000E+01, 0.264630000E+01, 0.426300000E+00 );
positions[1] = Vec3( 0.273400000E+02, 0.244300000E+02, 0.261400000E+01 ); positions[1] = Vec3( 0.273400000E+01, 0.244300000E+01, 0.261400000E+00 );
positions[2] = Vec3( 0.262660000E+02, 0.254130000E+02, 0.284200000E+01 ); positions[2] = Vec3( 0.262660000E+01, 0.254130000E+01, 0.284200000E+00 );
positions[3] = Vec3( 0.269130000E+02, 0.266390000E+02, 0.353100000E+01 ); positions[3] = Vec3( 0.269130000E+01, 0.266390000E+01, 0.353100000E+00 );
context.setPositions(positions); context.setPositions(positions);
compareWithExpectedForceAndEnergy( context, *amoebaTorsionForce, TOL, "testOneTorsion", log ); compareWithExpectedForceAndEnergy( context, *amoebaTorsionForce, TOL, "testOneTorsion", log );
...@@ -330,12 +330,14 @@ void testOneTorsion( FILE* log ) { ...@@ -330,12 +330,14 @@ void testOneTorsion( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaTorsionForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
//FILE* log = stderr; //FILE* log = stderr;
FILE* log = fopen( "AmoebaTorsionForce1.log", "w" );; FILE* log = NULL;
//FILE* log = fopen( "AmoebaTorsionForce.log", "w" );;
testOneTorsion( log ); testOneTorsion( log );
(void) fclose( log ); if( log && log != stderr )
(void) fclose( log );
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -304,13 +304,16 @@ void testOneTorsionTorsion( FILE* log ) { ...@@ -304,13 +304,16 @@ void testOneTorsionTorsion( FILE* log ) {
int main( int numberOfArguments, char* argv[] ) { int main( int numberOfArguments, char* argv[] ) {
try { try {
std::cout << "Running test..." << std::endl; std::cout << "TestCudaAmoebaTorsionTorsionForce running test..." << std::endl;
Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() ); Platform::loadPluginsFromDirectory( Platform::getDefaultPluginsDirectory() );
FILE* log = NULL;
//FILE* log = stderr; //FILE* log = stderr;
//FILE* log = fopen( "AmoebaTorsionTorsionForce1.log", "w" );; //FILE* log = fopen( "AmoebaTorsionTorsionForce1.log", "w" );;
//testOneTorsionTorsion( log ); //testOneTorsionTorsion( log );
//(void) fclose( log ); if( log && log != stderr )
(void) fclose( log );
} catch(const std::exception& e) { } catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
std::cout << "FAIL - ERROR. Test failed." << std::endl; std::cout << "FAIL - ERROR. Test failed." << std::endl;
......
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