--- trunk/OOPSE/libmdtools/DUFF.cpp 2003/06/19 22:02:44 559 +++ trunk/OOPSE/libmdtools/DUFF.cpp 2003/06/24 19:57:54 564 @@ -15,6 +15,13 @@ using namespace std; #include "mpiForceField.h" #endif // is_mpi + +// define some bond Types + +#define FIXED_BOND 0 +#define HARMONIC_BOND 1 + + namespace TPE { // restrict the access of the folowing to this file only. @@ -39,10 +46,11 @@ namespace TPE { // restrict the access of the folowin typedef struct{ char nameA[15]; char nameB[15]; - char type[30]; double d0; + double k0; int last; // 0 -> default // 1 -> tells nodes to stop listening + int type; } bondStruct; @@ -111,8 +119,8 @@ namespace TPE { // restrict the access of the folowin if( !strcmp( info.name, name ) ){ sprintf( painCave.errMsg, - "Duplicate TraPPE_Ex atom type \"%s\" found in " - "the TraPPE_ExFF param file./n", + "Duplicate DUFF atom type \"%s\" found in " + "the DUFF param file./n", name ); painCave.isFatal = 1; simError(); @@ -172,7 +180,6 @@ namespace TPE { // restrict the access of the folowin next = NULL; nameA[0] = '\0'; nameB[0] = '\0'; - type[0] = '\0'; } ~LinkedBondType(){ if( next != NULL ) delete next; } @@ -194,8 +201,8 @@ namespace TPE { // restrict the access of the folowin if(dup){ sprintf( painCave.errMsg, - "Duplicate TraPPE_Ex bond type \"%s - %s\" found in " - "the TraPPE_ExFF param file./n", + "Duplicate DUFF bond type \"%s - %s\" found in " + "the DUFF param file./n", nameA, nameB ); painCave.isFatal = 1; simError(); @@ -207,8 +214,9 @@ namespace TPE { // restrict the access of the folowin next = new LinkedBondType(); strcpy(next->nameA, info.nameA); strcpy(next->nameB, info.nameB); - strcpy(next->type, info.type); + next->type = info.type; next->d0 = info.d0; + next->k0 = info.k0; } } @@ -216,8 +224,9 @@ namespace TPE { // restrict the access of the folowin void duplicate( bondStruct &info ){ strcpy(info.nameA, nameA); strcpy(info.nameB, nameB); - strcpy(info.type, type); + info.type = type; info.d0 = d0; + info.k0 = k0; info.last = 0; } @@ -226,8 +235,9 @@ namespace TPE { // restrict the access of the folowin char nameA[15]; char nameB[15]; - char type[30]; + int type; double d0; + double k0; LinkedBondType* next; }; @@ -264,8 +274,8 @@ namespace TPE { // restrict the access of the folowin if(dup){ sprintf( painCave.errMsg, - "Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in " - "the TraPPE_ExFF param file./n", + "Duplicate DUFF bend type \"%s - %s - %s\" found in " + "the DUFF param file./n", nameA, nameB, nameC ); painCave.isFatal = 1; simError(); @@ -349,8 +359,8 @@ namespace TPE { // restrict the access of the folowin if(dup){ sprintf( painCave.errMsg, - "Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in " - "the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD ); + "Duplicate DUFF torsion type \"%s - %s - %s - %s\" found in " + "the DUFF param file./n", nameA, nameB, nameC, nameD ); painCave.isFatal = 1; simError(); } @@ -418,7 +428,7 @@ using namespace TPE; //**************************************************************** -TraPPE_ExFF::TraPPE_ExFF(){ +DUFF::DUFF(){ char fileName[200]; char* ffPath_env = "FORCE_PARAM_PATH"; @@ -468,7 +478,7 @@ TraPPE_ExFF::TraPPE_ExFF(){ // Init the bondStruct mpi type bondStruct bondProto; // mpiPrototype - int bondBC[3] = {60,1,1}; // block counts + int bondBC[3] = {30,2,2}; // block counts MPI_Aint bondDspls[3]; // displacements MPI_Datatype bondMbrTypes[3]; // member mpi types @@ -537,7 +547,7 @@ TraPPE_ExFF::TraPPE_ExFF(){ // generate the force file name - strcpy( fileName, "TraPPE_Ex.frc" ); + strcpy( fileName, "DUFF.frc" ); // fprintf( stderr,"Trying to open %s\n", fileName ); // attempt to open the file in the current directory first. @@ -576,14 +586,14 @@ TraPPE_ExFF::TraPPE_ExFF(){ #ifdef IS_MPI } - sprintf( checkPointMsg, "TraPPE_ExFF file opened sucessfully." ); + sprintf( checkPointMsg, "DUFF file opened sucessfully." ); MPIcheckPoint(); #endif // is_mpi } -TraPPE_ExFF::~TraPPE_ExFF(){ +DUFF::~DUFF(){ if( headAtomType != NULL ) delete headAtomType; if( headBondType != NULL ) delete headBondType; @@ -601,7 +611,7 @@ TraPPE_ExFF::~TraPPE_ExFF(){ #endif // is_mpi } -void TraPPE_ExFF::cleanMe( void ){ +void DUFF::cleanMe( void ){ #ifdef IS_MPI @@ -620,13 +630,13 @@ void TraPPE_ExFF::cleanMe( void ){ } -void TraPPE_ExFF::initForceField( int ljMixRule ){ +void DUFF::initForceField( int ljMixRule ){ initFortran( ljMixRule, entry_plug->useReactionField ); } -void TraPPE_ExFF::readParams( void ){ +void DUFF::readParams( void ){ int i, a, b, c, d; int identNum; @@ -698,7 +708,7 @@ void TraPPE_ExFF::readParams( void ){ // send out the linked list to all the other processes sprintf( checkPointMsg, - "TraPPE_ExFF atom structures read successfully." ); + "DUFF atom structures read successfully." ); MPIcheckPoint(); currentAtomType = headAtomType->next; //skip the first element who is a place holder. @@ -710,7 +720,7 @@ void TraPPE_ExFF::readParams( void ){ sendFrcStruct( &atomInfo, mpiAtomStructType ); sprintf( checkPointMsg, - "successfully sent TraPPE_Ex force type: \"%s\"\n", + "successfully sent DUFF force type: \"%s\"\n", atomInfo.name ); MPIcheckPoint(); @@ -790,7 +800,7 @@ void TraPPE_ExFF::readParams( void ){ #ifdef IS_MPI sprintf( checkPointMsg, - "TraPPE_ExFF atom structures successfully sent to fortran\n" ); + "DUFF atom structures successfully sent to fortran\n" ); MPIcheckPoint(); #endif // is_mpi @@ -844,7 +854,7 @@ void TraPPE_ExFF::readParams( void ){ // send out the linked list to all the other processes sprintf( checkPointMsg, - "TraPPE_Ex bond structures read successfully." ); + "DUFF bond structures read successfully." ); MPIcheckPoint(); currentBondType = headBondType->next; @@ -874,7 +884,7 @@ void TraPPE_ExFF::readParams( void ){ } sprintf( checkPointMsg, - "TraPPE_ExFF bond structures broadcast successfully." ); + "DUFF bond structures broadcast successfully." ); MPIcheckPoint(); #endif // is_mpi @@ -927,7 +937,7 @@ void TraPPE_ExFF::readParams( void ){ // send out the linked list to all the other processes sprintf( checkPointMsg, - "TraPPE_Ex bend structures read successfully." ); + "DUFF bend structures read successfully." ); MPIcheckPoint(); currentBendType = headBendType->next; @@ -957,7 +967,7 @@ void TraPPE_ExFF::readParams( void ){ } sprintf( checkPointMsg, - "TraPPE_ExFF bend structures broadcast successfully." ); + "DUFF bend structures broadcast successfully." ); MPIcheckPoint(); #endif // is_mpi @@ -1012,7 +1022,7 @@ void TraPPE_ExFF::readParams( void ){ // send out the linked list to all the other processes sprintf( checkPointMsg, - "TraPPE_Ex torsion structures read successfully." ); + "DUFF torsion structures read successfully." ); MPIcheckPoint(); currentTorsionType = headTorsionType->next; @@ -1042,7 +1052,7 @@ void TraPPE_ExFF::readParams( void ){ } sprintf( checkPointMsg, - "TraPPE_ExFF torsion structures broadcast successfully." ); + "DUFF torsion structures broadcast successfully." ); MPIcheckPoint(); #endif // is_mpi @@ -1052,7 +1062,7 @@ void TraPPE_ExFF::readParams( void ){ -void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** the_atoms ){ +void DUFF::initializeAtoms( int nAtoms, Atom** the_atoms ){ ////////////////////////////////////////////////// @@ -1141,7 +1151,7 @@ void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** else{ sprintf( painCave.errMsg, - "TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard" + "DUFF error: Atom \"%s\" is a dipole, yet no standard" " orientation was specifed in the BASS file.\n", currentAtomType->name ); painCave.isFatal = 1; @@ -1151,7 +1161,7 @@ void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** else{ if( the_atoms[i]->isDirectional() ){ sprintf( painCave.errMsg, - "TraPPE_ExFF error: Atom \"%s\" was given a standard" + "DUFF error: Atom \"%s\" was given a standard" "orientation in the BASS file, yet it is not a dipole.\n", currentAtomType->name); painCave.isFatal = 1; @@ -1161,7 +1171,7 @@ void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** } } -void TraPPE_ExFF::initializeBonds( int nBonds, Bond** bondArray, +void DUFF::initializeBonds( int nBonds, Bond** bondArray, bond_pair* the_bonds ){ int i,a,b; char* atomA; @@ -1189,17 +1199,33 @@ void TraPPE_ExFF::initializeBonds( int nBonds, Bond** simError(); } - if( !strcmp( currentBondType->type, "fixed" ) ){ - + switch( currentBondType->type ){ + + case FIXED_BOND: + bondArray[i] = new ConstrainedBond( *the_atoms[a], *the_atoms[b], currentBondType->d0 ); entry_plug->n_constraints++; + break; + + case HARMONIC_BOND: + + bondArray[i] = new HarmonicBond( *the_atoms[a], + *the_atoms[b], + currentBondType->d0, + currentBondType->k0 ); + break; + + default: + + break; + // do nothing } } } -void TraPPE_ExFF::initializeBends( int nBends, Bend** bendArray, +void DUFF::initializeBends( int nBends, Bend** bendArray, bend_set* the_bends ){ QuadraticBend* qBend; @@ -1280,7 +1306,7 @@ void TraPPE_ExFF::initializeBends( int nBends, Bend** } } -void TraPPE_ExFF::initializeTorsions( int nTorsions, Torsion** torsionArray, +void DUFF::initializeTorsions( int nTorsions, Torsion** torsionArray, torsion_set* the_torsions ){ int i, a, b, c, d; @@ -1327,7 +1353,7 @@ void TraPPE_ExFF::initializeTorsions( int nTorsions, T } } -void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){ +void DUFF::fastForward( char* stopText, char* searchOwner ){ int foundText = 0; char* the_token; @@ -1479,6 +1505,7 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon int TPE::parseBond( char *lineBuffer, int lineNum, bondStruct &info ){ char* the_token; + char bondType[30]; the_token = strtok( lineBuffer, " \n\t,;" ); if( the_token != NULL ){ @@ -1501,9 +1528,11 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon simError(); } - strcpy( info.type, the_token ); + strcpy( bondType, the_token ); - if( !strcmp( info.type, "fixed" ) ){ + if( !strcmp( bondType, "fixed" ) ){ + info.type = FIXED_BOND; + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ sprintf( painCave.errMsg, "Error parseing BondTypes: line %d\n", lineNum ); @@ -1513,9 +1542,31 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon info.d0 = atof( the_token ); } + else if( !strcmp( bondType, "harmonic" ) ){ + info.type = HARMONIC_BOND; + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing BondTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.d0 = atof( the_token ); + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing BondTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.k0 = atof( the_token ); + } + else{ sprintf( painCave.errMsg, - "Unknown TraPPE_Ex bond type \"%s\" at line %d\n", + "Unknown DUFF bond type \"%s\" at line %d\n", info.type, lineNum ); painCave.isFatal = 1; @@ -1604,7 +1655,7 @@ int TPE::parseBend( char *lineBuffer, int lineNum, ben else{ sprintf( painCave.errMsg, - "Unknown TraPPE_Ex bend type \"%s\" at line %d\n", + "Unknown DUFF bend type \"%s\" at line %d\n", info.type, lineNum ); painCave.isFatal = 1; @@ -1702,7 +1753,7 @@ int TPE::parseTorsion( char *lineBuffer, int lineNum, else{ sprintf( painCave.errMsg, - "Unknown TraPPE_Ex torsion type \"%s\" at line %d\n", + "Unknown DUFF torsion type \"%s\" at line %d\n", info.type, lineNum ); painCave.isFatal = 1;