--- trunk/OOPSE/libmdtools/TraPPE_ExFF.cpp 2003/03/27 17:32:03 420 +++ trunk/OOPSE/libmdtools/TraPPE_ExFF.cpp 2003/03/27 17:55:20 421 @@ -621,15 +621,20 @@ void TraPPE_ExFF::readParams( void ){ void TraPPE_ExFF::readParams( void ){ - int i; + int i, a, b, c, d; int identNum; + char* atomA; + char* atomB; + char* atomC; + char* atomD; atomStruct atomInfo; bondStruct bondInfo; bendStruct bendInfo; torsionStruct torsionInfo; - + bigSigma = 0.0; + atomInfo.last = 1; bondInfo.last = 1; bendInfo.last = 1; @@ -715,7 +720,7 @@ void TraPPE_ExFF::readParams( void ){ MPIcheckPoint(); - headAtomType = new LinkedType; + headAtomType = new LinkedAtomType; recieveFrcStruct( &atomInfo, mpiAtomStructType ); while( !atomInfo.last ){ @@ -787,25 +792,247 @@ void TraPPE_ExFF::readParams( void ){ // read in the bonds - - - -} +#ifdef IS_MPI + if( worldRank == 0 ){ +#endif + + // read in the bond types. + + headBondType = new LinkedBondType; + + fastForward( "BondTypes", "initializeBonds" ); + // we are now at the bondTypes section + eof_test = fgets( readLine, sizeof(readLine), frcFile ); + lineNum++; + + + // read a line, and start parseing out the atom types -void TraPPE_ExFF::initializeAtoms( void ){ - + if( eof_test == NULL ){ + sprintf( painCave.errMsg, + "Error in reading bonds from force file at line %d.\n", + lineNum ); + painCave.isFatal = 1; + simError(); + } + + // stop reading at end of file, or at next section + while( readLine[0] != '#' && eof_test != NULL ){ + + // toss comment lines + if( readLine[0] != '!' ){ + + // the parser returns 0 if the line was blank + if( parseBond( readLine, lineNum, bondInfo ) ){ + headBondType->add( bondInfo ); + } + } + eof_test = fgets( readLine, sizeof(readLine), frcFile ); + lineNum++; + } + +#ifdef IS_MPI + + // send out the linked list to all the other processes + + sprintf( checkPointMsg, + "TraPPE_Ex bond structures read successfully." ); + MPIcheckPoint(); + + currentBondType = headBondType; + while( currentBondType != NULL ){ + currentBondType->duplicate( bondInfo ); + sendFrcStruct( &bondInfo, mpiBondStructType ); + currentBondType = currentBondType->next; + } + bondInfo.last = 1; + sendFrcStruct( &bondInfo, mpiBondStructType ); + + } + + else{ + + // listen for node 0 to send out the force params + + MPIcheckPoint(); + headBondType = new LinkedBondType; + recieveFrcStruct( &bondInfo, mpiBondStructType ); + while( !bondInfo.last ){ + + headBondType->add( bondInfo ); + recieveFrcStruct( &bondInfo, mpiBondStructType ); + } + } +#endif // is_mpi + + // read in the bends + +#ifdef IS_MPI + if( worldRank == 0 ){ +#endif + + // read in the bend types. + + headBendType = new LinkedBendType; + + fastForward( "BendTypes", "initializeBends" ); + + // we are now at the bendTypes section + + eof_test = fgets( readLine, sizeof(readLine), frcFile ); + lineNum++; + + // read a line, and start parseing out the bend types + + if( eof_test == NULL ){ + sprintf( painCave.errMsg, + "Error in reading bends from force file at line %d.\n", + lineNum ); + painCave.isFatal = 1; + simError(); + } + + // stop reading at end of file, or at next section + while( readLine[0] != '#' && eof_test != NULL ){ + + // toss comment lines + if( readLine[0] != '!' ){ + + // the parser returns 0 if the line was blank + if( parseBend( readLine, lineNum, bendInfo ) ){ + headBendType->add( bendInfo ); + } + } + eof_test = fgets( readLine, sizeof(readLine), frcFile ); + lineNum++; + } + +#ifdef IS_MPI + + // send out the linked list to all the other processes + + sprintf( checkPointMsg, + "TraPPE_Ex bend structures read successfully." ); + MPIcheckPoint(); + + currentBendType = headBendType; + while( currentBendType != NULL ){ + currentBendType->duplicate( bendInfo ); + sendFrcStruct( &bendInfo, mpiBendStructType ); + currentBendType = currentBendType->next; + } + bendInfo.last = 1; + sendFrcStruct( &bendInfo, mpiBendStructType ); + + } + + else{ + + // listen for node 0 to send out the force params + + MPIcheckPoint(); + headBendType = new LinkedBendType; + recieveFrcStruct( &bendInfo, mpiBendStructType ); + while( !bendInfo.last ){ + headBendType->add( bendInfo ); + recieveFrcStruct( &bendInfo, mpiBendStructType ); + } + } +#endif // is_mpi + + + // read in the torsions + +#ifdef IS_MPI + if( worldRank == 0 ){ +#endif + + // read in the torsion types. + + headTorsionType = new LinkedTorsionType; + + fastForward( "TorsionTypes", "initializeTorsions" ); + + // we are now at the torsionTypes section + + eof_test = fgets( readLine, sizeof(readLine), frcFile ); + lineNum++; + + + // read a line, and start parseing out the atom types + + if( eof_test == NULL ){ + sprintf( painCave.errMsg, + "Error in reading torsions from force file at line %d.\n", + lineNum ); + painCave.isFatal = 1; + simError(); + } + + // stop reading at end of file, or at next section + while( readLine[0] != '#' && eof_test != NULL ){ + + // toss comment lines + if( readLine[0] != '!' ){ + + // the parser returns 0 if the line was blank + if( parseTorsion( readLine, lineNum, torsionInfo ) ){ + headTorsionType->add( torsionInfo ); + + } + } + eof_test = fgets( readLine, sizeof(readLine), frcFile ); + lineNum++; + } + +#ifdef IS_MPI + + // send out the linked list to all the other processes + + sprintf( checkPointMsg, + "TraPPE_Ex torsion structures read successfully." ); + MPIcheckPoint(); + + currentTorsionType = headTorsionType; + while( currentTorsionType != NULL ){ + currentTorsionType->duplicate( torsionInfo ); + sendFrcStruct( &torsionInfo, mpiTorsionStructType ); + currentTorsionType = currentTorsionType->next; + } + torsionInfo.last = 1; + sendFrcStruct( &torsionInfo, mpiTorsionStructType ); + + } + + else{ + + // listen for node 0 to send out the force params + + MPIcheckPoint(); + + headTorsionType = new LinkedTorsionType; + recieveFrcStruct( &torsionInfo, mpiTorsionStructType ); + while( !torsionInfo.last ){ + + headTorsionType->add( torsionInfo ); + recieveFrcStruct( &torsionInfo, mpiTorsionStructType ); + } + } +#endif // is_mpi + +} + + + +void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** the_atoms ){ - Atom** the_atoms; - int nAtoms; - the_atoms = entry_plug->atoms; - nAtoms = entry_plug->n_atoms; ////////////////////////////////////////////////// // a quick water fix @@ -837,21 +1064,15 @@ void TraPPE_ExFF::initializeAtoms( void ){ headI[2][1] = 0.0; headI[2][2] = 250; - - ////////////////////////////////////////////////// - - // initialize the atoms - double bigSigma = 0.0; DirectionalAtom* dAtom; for( i=0; ifind( the_atoms[i]->getType() ); if( currentAtomType == NULL ){ sprintf( painCave.errMsg, @@ -918,32 +1139,7 @@ void TraPPE_ExFF::initializeAtoms( void ){ } } -#ifdef IS_MPI - double tempBig = bigSigma; - MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX ); -#endif //is_mpi - //calc rCut and rList - - entry_plug->rCut = 2.5 * bigSigma; - - if(entry_plug->rCut > (entry_plug->box_x / 2.0)) - entry_plug->rCut = entry_plug->box_x / 2.0; - - if(entry_plug->rCut > (entry_plug->box_y / 2.0)) - entry_plug->rCut = entry_plug->box_y / 2.0; - - if(entry_plug->rCut > (entry_plug->box_z / 2.0)) - entry_plug->rCut = entry_plug->box_z / 2.0; - - entry_plug->rList = entry_plug->rCut + 1.0; - - entry_plug->useLJ = 1; // use Lennard Jones is on by default - - // clean up the memory - - delete headAtomType; - #ifdef IS_MPI sprintf( checkPointMsg, "TraPPE_Ex atoms initialized succesfully" ); MPIcheckPoint(); @@ -951,108 +1147,18 @@ void TraPPE_ExFF::initializeBonds( bond_pair* the_bond } -void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){ +void TraPPE_ExFF::initializeBonds( int nBonds, Bond** bondArray, + bond_pair* the_bonds ){ + int i,a,b; + char* atomA; + char* atomB; - - - - - - - info.last = 1; // initialize last to have the last set. - // if things go well, last will be set to 0 - - SRI **the_sris; Atom** the_atoms; - int nBonds; - the_sris = entry_plug->sr_interactions; the_atoms = entry_plug->atoms; - nBonds = entry_plug->n_bonds; - - int i, a, b; - char* atomA; - char* atomB; -#ifdef IS_MPI - if( worldRank == 0 ){ -#endif - - // read in the bond types. - - headBondType = new LinkedType; - - fastForward( "BondTypes", "initializeBonds" ); - // we are now at the bondTypes section - - eof_test = fgets( readLine, sizeof(readLine), frcFile ); - lineNum++; - - - // read a line, and start parseing out the atom types - - if( eof_test == NULL ){ - sprintf( painCave.errMsg, - "Error in reading bonds from force file at line %d.\n", - lineNum ); - painCave.isFatal = 1; - simError(); - } - - // stop reading at end of file, or at next section - while( readLine[0] != '#' && eof_test != NULL ){ - - // toss comment lines - if( readLine[0] != '!' ){ - - // the parser returns 0 if the line was blank - if( parseBond( readLine, lineNum, info ) ){ - headBondType->add( info ); - } - } - eof_test = fgets( readLine, sizeof(readLine), frcFile ); - lineNum++; - } - -#ifdef IS_MPI - - // send out the linked list to all the other processes - - sprintf( checkPointMsg, - "TraPPE_Ex bond structures read successfully." ); - MPIcheckPoint(); - - currentBondType = headBondType; - while( currentBondType != NULL ){ - currentBondType->duplicate( info ); - sendFrcStruct( &info, mpiBondStructType ); - currentBondType = currentBondType->next; - } - info.last = 1; - sendFrcStruct( &info, mpiBondStructType ); - - } - - else{ - - // listen for node 0 to send out the force params - - MPIcheckPoint(); - - headBondType = new LinkedType; - recieveFrcStruct( &info, mpiBondStructType ); - while( !info.last ){ - - headBondType->add( info ); - recieveFrcStruct( &info, mpiBondStructType ); - } - } -#endif // is_mpi - - // initialize the Bonds - for( i=0; itype, "fixed" ) ){ - the_sris[i] = new ConstrainedBond( *the_atoms[a], - *the_atoms[b], - currentBondType->d0 ); + bondArray[i] = new ConstrainedBond( *the_atoms[a], + *the_atoms[b], + currentBondType->d0 ); entry_plug->n_constraints++; } } - - - // clean up the memory - delete headBondType; - #ifdef IS_MPI sprintf( checkPointMsg, "TraPPE_Ex bonds initialized succesfully" ); MPIcheckPoint(); @@ -1090,108 +1191,20 @@ void TraPPE_ExFF::initializeBends( bend_set* the_bends } -void TraPPE_ExFF::initializeBends( bend_set* the_bends ){ +void TraPPE_ExFF::initializeBends( int nBends, Bend** bendArray, + bend_set* the_bends ){ - - - - bendStruct info; - info.last = 1; // initialize last to have the last set. - // if things go well, last will be set to 0 - QuadraticBend* qBend; GhostBend* gBend; - SRI **the_sris; Atom** the_atoms; - int nBends; - the_sris = entry_plug->sr_interactions; the_atoms = entry_plug->atoms; - nBends = entry_plug->n_bends; - + int i, a, b, c; char* atomA; char* atomB; char* atomC; - - -#ifdef IS_MPI - if( worldRank == 0 ){ -#endif - - // read in the bend types. - - headBendType = new LinkedType; - - fastForward( "BendTypes", "initializeBends" ); - - // we are now at the bendTypes section - - eof_test = fgets( readLine, sizeof(readLine), frcFile ); - lineNum++; - - // read a line, and start parseing out the bend types - - if( eof_test == NULL ){ - sprintf( painCave.errMsg, - "Error in reading bends from force file at line %d.\n", - lineNum ); - painCave.isFatal = 1; - simError(); - } - - // stop reading at end of file, or at next section - while( readLine[0] != '#' && eof_test != NULL ){ - - // toss comment lines - if( readLine[0] != '!' ){ - - // the parser returns 0 if the line was blank - if( parseBend( readLine, lineNum, info ) ){ - headBendType->add( info ); - } - } - eof_test = fgets( readLine, sizeof(readLine), frcFile ); - lineNum++; - } - -#ifdef IS_MPI - - // send out the linked list to all the other processes - - sprintf( checkPointMsg, - "TraPPE_Ex bend structures read successfully." ); - MPIcheckPoint(); - - currentBendType = headBendType; - while( currentBendType != NULL ){ - currentBendType->duplicate( info ); - sendFrcStruct( &info, mpiBendStructType ); - currentBendType = currentBendType->next; - } - info.last = 1; - sendFrcStruct( &info, mpiBendStructType ); - - } - - else{ - - // listen for node 0 to send out the force params - - MPIcheckPoint(); - - headBendType = new LinkedType; - recieveFrcStruct( &info, mpiBendStructType ); - while( !info.last ){ - - headBendType->add( info ); - recieveFrcStruct( &info, mpiBendStructType ); - } - } -#endif // is_mpi // initialize the Bends - - int index; for( i=0; itype, "quadratic" ) ){ - index = i + entry_plug->n_bonds; - if( the_bends[i].isGhost){ if( the_bends[i].ghost == b ){ @@ -1245,7 +1256,7 @@ void TraPPE_ExFF::initializeBends( bend_set* the_bends currentBendType->k2, currentBendType->k3, currentBendType->t0 ); - the_sris[index] = gBend; + bendArray[i] = gBend; } else{ qBend = new QuadraticBend( *the_atoms[a], @@ -1255,16 +1266,11 @@ void TraPPE_ExFF::initializeBends( bend_set* the_bends currentBendType->k2, currentBendType->k3, currentBendType->t0 ); - the_sris[index] = qBend; + bendArray[i] = qBend; } } } - - // clean up the memory - - delete headBendType; - #ifdef IS_MPI sprintf( checkPointMsg, "TraPPE_Ex bends initialized succesfully" ); MPIcheckPoint(); @@ -1272,106 +1278,19 @@ void TraPPE_ExFF::initializeTorsions( torsion_set* the } -void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){ +void TraPPE_ExFF::initializeTorsions( int nTorsions, Torsion** torsionArray, + torsion_set* the_torsions ){ - - - - torsionStruct info; - info.last = 1; // initialize last to have the last set. - // if things go well, last will be set to 0 - - int i, a, b, c, d, index; + int i, a, b, c, d; char* atomA; char* atomB; char* atomC; char* atomD; - CubicTorsion* cTors; - SRI **the_sris; + CubicTorsion* cTors; Atom** the_atoms; - int nTorsions; - the_sris = entry_plug->sr_interactions; the_atoms = entry_plug->atoms; - nTorsions = entry_plug->n_torsions; -#ifdef IS_MPI - if( worldRank == 0 ){ -#endif - - // read in the torsion types. - - headTorsionType = new LinkedType; - - fastForward( "TorsionTypes", "initializeTorsions" ); - - // we are now at the torsionTypes section - - eof_test = fgets( readLine, sizeof(readLine), frcFile ); - lineNum++; - - - // read a line, and start parseing out the atom types - - if( eof_test == NULL ){ - sprintf( painCave.errMsg, - "Error in reading torsions from force file at line %d.\n", - lineNum ); - painCave.isFatal = 1; - simError(); - } - - // stop reading at end of file, or at next section - while( readLine[0] != '#' && eof_test != NULL ){ - - // toss comment lines - if( readLine[0] != '!' ){ - - // the parser returns 0 if the line was blank - if( parseTorsion( readLine, lineNum, info ) ){ - headTorsionType->add( info ); - - } - } - eof_test = fgets( readLine, sizeof(readLine), frcFile ); - lineNum++; - } - -#ifdef IS_MPI - - // send out the linked list to all the other processes - - sprintf( checkPointMsg, - "TraPPE_Ex torsion structures read successfully." ); - MPIcheckPoint(); - - currentTorsionType = headTorsionType; - while( currentTorsionType != NULL ){ - currentTorsionType->duplicate( info ); - sendFrcStruct( &info, mpiTorsionStructType ); - currentTorsionType = currentTorsionType->next; - } - info.last = 1; - sendFrcStruct( &info, mpiTorsionStructType ); - - } - - else{ - - // listen for node 0 to send out the force params - - MPIcheckPoint(); - - headTorsionType = new LinkedType; - recieveFrcStruct( &info, mpiTorsionStructType ); - while( !info.last ){ - - headTorsionType->add( info ); - recieveFrcStruct( &info, mpiTorsionStructType ); - } - } -#endif // is_mpi - // initialize the Torsions for( i=0; itype, "cubic" ) ){ - index = i + entry_plug->n_bonds + entry_plug->n_bends; cTors = new CubicTorsion( *the_atoms[a], *the_atoms[b], *the_atoms[c], *the_atoms[d] ); cTors->setConstants( currentTorsionType->k1, currentTorsionType->k2, currentTorsionType->k3, currentTorsionType->k4 ); - the_sris[index] = cTors; + torsionArray[i] = cTors; } } - - - // clean up the memory - - delete headTorsionType; #ifdef IS_MPI sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" );