--- trunk/OOPSE/libmdtools/DUFF.cpp 2003/06/20 20:29:36 561 +++ trunk/OOPSE/libmdtools/DUFF.cpp 2004/01/13 23:01:43 941 @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include using namespace std; @@ -15,9 +15,16 @@ using namespace std; #include "mpiForceField.h" #endif // is_mpi -namespace TPE { // restrict the access of the folowing to this file only. +// define some bond Types +#define FIXED_BOND 0 +#define HARMONIC_BOND 1 + + +namespace DUFF_NS { // restrict the access of the folowing to this file only. + + // Declare the structures that will be passed by MPI typedef struct{ @@ -25,10 +32,17 @@ namespace TPE { // restrict the access of the folowin double mass; double epslon; double sigma; + double charge; double dipole; double w0; double v0; + double v0p; + double rl; + double ru; + double rlp; + double rup; int isSSD; + int isCharge; int isDipole; int ident; int last; // 0 -> default @@ -39,10 +53,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; @@ -130,6 +145,11 @@ namespace TPE { // restrict the access of the folowin next->dipole = info.dipole; next->w0 = info.w0; next->v0 = info.v0; + next->v0p = info.v0p; + next->rl = info.rl; + next->ru = info.ru; + next->rlp = info.rlp; + next->rup = info.rup; next->ident = info.ident; } } @@ -146,6 +166,11 @@ namespace TPE { // restrict the access of the folowin info.dipole = dipole; info.w0 = w0; info.v0 = v0; + info.v0p = v0p; + info.rl = rl; + info.ru = ru; + info.rlp = rlp; + info.rup = rup; info.ident = ident; info.last = 0; } @@ -162,6 +187,11 @@ namespace TPE { // restrict the access of the folowin double dipole; double w0; double v0; + double v0p; + double rl; + double ru; + double rlp; + double rup; int ident; LinkedAtomType* next; }; @@ -172,7 +202,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; } @@ -207,8 +236,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 +246,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 +257,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; }; @@ -410,7 +442,7 @@ namespace TPE { // restrict the access of the folowin } // namespace -using namespace TPE; +using namespace DUFF_NS; //**************************************************************** @@ -424,7 +456,6 @@ DUFF::DUFF(){ char* ffPath_env = "FORCE_PARAM_PATH"; char* ffPath; char temp[200]; - char errMsg[1000]; headAtomType = NULL; currentAtomType = NULL; @@ -446,7 +477,7 @@ DUFF::DUFF(){ // Init the atomStruct mpi type atomStruct atomProto; // mpiPrototype - int atomBC[3] = {15,6,4}; // block counts + int atomBC[3] = {15,11,4}; // block counts MPI_Aint atomDspls[3]; // displacements MPI_Datatype atomMbrTypes[3]; // member mpi types @@ -468,7 +499,7 @@ DUFF::DUFF(){ // 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 @@ -628,12 +659,7 @@ void DUFF::readParams( void ){ void DUFF::readParams( void ){ - int i, a, b, c, d; int identNum; - char* atomA; - char* atomB; - char* atomC; - char* atomD; atomStruct atomInfo; bondStruct bondInfo; @@ -754,16 +780,20 @@ void DUFF::readParams( void ){ int isGB = 0; int isLJ = 1; - double GB_dummy = 0.0; - - + int isEAM =0; + int isCharge = 0; + double charge=0.0; + currentAtomType = headAtomType->next;; while( currentAtomType != NULL ){ - if(currentAtomType->isDipole) entry_plug->useDipole = 1; + if(currentAtomType->isDipole) entry_plug->useDipoles = 1; if(currentAtomType->isSSD) { entry_plug->useSticky = 1; - set_sticky_params( &(currentAtomType->w0), &(currentAtomType->v0)); + set_sticky_params( &(currentAtomType->w0), &(currentAtomType->v0), + &(currentAtomType->v0p), + &(currentAtomType->rl), &(currentAtomType->ru), + &(currentAtomType->rlp), &(currentAtomType->rup)); } if( currentAtomType->name[0] != '\0' ){ @@ -773,8 +803,11 @@ void DUFF::readParams( void ){ &(currentAtomType->isSSD), &(currentAtomType->isDipole), &isGB, + &isEAM, + &isCharge, &(currentAtomType->epslon), &(currentAtomType->sigma), + &charge, &(currentAtomType->dipole), &isError ); if( isError ){ @@ -1189,12 +1222,28 @@ void DUFF::initializeBonds( int nBonds, Bond** bondArr 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 } } } @@ -1259,7 +1308,8 @@ void DUFF::initializeBends( int nBends, Bend** bendArr } gBend = new GhostBend( *the_atoms[a], - *the_atoms[b] ); + *the_atoms[b]); + gBend->setConstants( currentBendType->k1, currentBendType->k2, currentBendType->k3, @@ -1275,7 +1325,7 @@ void DUFF::initializeBends( int nBends, Bend** bendArr currentBendType->k3, currentBendType->t0 ); bendArray[i] = qBend; - } + } } } } @@ -1382,7 +1432,7 @@ void DUFF::fastForward( char* stopText, char* searchOw } -int TPE::parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){ +int DUFF_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){ char* the_token; @@ -1468,17 +1518,62 @@ int TPE::parseAtom( char *lineBuffer, int lineNum, ato } info.v0 = atof( the_token ); + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing AtomTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.v0p = atof( the_token ); + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing AtomTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.rl = atof( the_token ); + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing AtomTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.ru = atof( the_token ); + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing AtomTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.rlp = atof( the_token ); + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing AtomTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.rup = atof( the_token ); } - else info.v0 = info.w0 = 0.0; + else info.v0 = info.w0 = info.v0p = info.rl = info.ru = info.rlp = info.rup = 0.0; return 1; } else return 0; } -int TPE::parseBond( char *lineBuffer, int lineNum, bondStruct &info ){ +int DUFF_NS::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 +1596,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 ); @@ -1512,11 +1609,35 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon } info.d0 = atof( the_token ); + + info.k0=0.0; } + 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 DUFF bond type \"%s\" at line %d\n", - info.type, + bondType, lineNum ); painCave.isFatal = 1; simError(); @@ -1528,7 +1649,7 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon } -int TPE::parseBend( char *lineBuffer, int lineNum, bendStruct &info ){ +int DUFF_NS::parseBend( char *lineBuffer, int lineNum, bendStruct &info ){ char* the_token; @@ -1616,7 +1737,7 @@ int TPE::parseBend( char *lineBuffer, int lineNum, ben else return 0; } -int TPE::parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){ +int DUFF_NS::parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){ char* the_token;