--- trunk/OOPSE/libmdtools/EAM_FF.cpp 2003/07/30 21:17:01 657 +++ trunk/OOPSE/libmdtools/EAM_FF.cpp 2003/11/10 21:50:36 859 @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include using namespace std; @@ -30,10 +30,10 @@ namespace EAM_NS{ double mass; double lattice_constant; double eam_drho; // The distance between each of the points indexed by rho. + double eam_rcut; // The cutoff radius for eam. double eam_dr; // The distance between each of the rho points. int eam_nrho; // Number of points indexed by rho int eam_nr; // The number of points based on r (Both Phi(r) and Rho(r)). - double eam_rcut; // The cutoff radius for eam. int eam_ident; // Atomic number int ident; int last; // 0 -> default @@ -76,8 +76,6 @@ namespace EAM_NS{ void add( atomStruct &info, double *the_eam_rvals, double *the_eam_rhovals,double *the_eam_Frhovals ){ - int i; - // check for duplicates if( !strcmp( info.name, name ) ){ @@ -164,11 +162,13 @@ EAM_FF::EAM_FF(){ char* ffPath_env = "FORCE_PARAM_PATH"; char* ffPath; char temp[200]; - char errMsg[1000]; headAtomType = NULL; currentAtomType = NULL; + // Set eamRcut to 0.0 + eamRcut = 0.0; + // do the funtion wrapping wrapMeFF( this ); @@ -179,7 +179,7 @@ EAM_FF::EAM_FF(){ // Init the atomStruct mpi type atomStruct atomProto; // mpiPrototype - int atomBC[3] = {15,4,6}; // block counts + int atomBC[3] = {15,5,5}; // block counts MPI_Aint atomDspls[3]; // displacements MPI_Datatype atomMbrTypes[3]; // member mpi types @@ -266,9 +266,13 @@ void EAM_FF::calcRcut( void ){ void EAM_FF::calcRcut( void ){ - double tempEamRcut; - - entry_plug->setRcut(eamRcut); + + #ifdef IS_MPI + double tempEamRcut = eamRcut; + MPI_Allreduce( &tempEamRcut, &eamRcut, 1, MPI_DOUBLE, MPI_MAX, + MPI_COMM_WORLD); +#endif //is_mpi + entry_plug->setDefaultRcut(eamRcut); } @@ -298,7 +302,6 @@ void EAM_FF::readParams( void ){ info.last = 1; // initialize last to have the last set. // if things go well, last will be set to 0 - int i; int identNum; double *eam_rvals; // Z of r values double *eam_rhovals; // rho of r values @@ -478,14 +481,14 @@ void EAM_FF::readParams( void ){ } entry_plug->useLJ = 0; - + entry_plug->useEAM = 1; // Walk down again and send out EAM type currentAtomType = headAtomType->next; while( currentAtomType != NULL ){ if( currentAtomType->name[0] != '\0' ){ isError = 0; - cerr << "Calling newEAMtype for type "<eam_ident <<"\n"; + newEAMtype( &(currentAtomType->lattice_constant), &(currentAtomType->eam_nrho), &(currentAtomType->eam_drho), @@ -497,7 +500,7 @@ void EAM_FF::readParams( void ){ currentAtomType->eam_Frhovals, &(currentAtomType->eam_ident), &isError); - cerr << "Returned from newEAMtype\n"; + if( isError ){ sprintf( painCave.errMsg, "Error initializing the \"%s\" atom type in fortran EAM\n", @@ -517,20 +520,17 @@ void EAM_FF::readParams( void ){ MPIcheckPoint(); #endif // is_mpi - cerr << "Done sending eamtypes to fortran\n"; + } void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ int i; - + // initialize the atoms - - Atom* thisAtom; - for( i=0; ifind( the_atoms[i]->getType() ); @@ -545,7 +545,10 @@ void EAM_FF::initializeAtoms( int nAtoms, Atom** the_a the_atoms[i]->setMass( currentAtomType->mass ); the_atoms[i]->setIdent( currentAtomType->ident ); the_atoms[i]->setEAM(); + the_atoms[i]->setEamRcut( currentAtomType->eam_rcut); + if (eamRcut < currentAtomType->eam_rcut) eamRcut = currentAtomType->eam_rcut; + } } @@ -1013,7 +1016,7 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil myEam_rhovals[j+0] = atof( the_token ); // Value 2 - if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ + if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ sprintf( painCave.errMsg, "Error parseing EAM nrho: line in %s\n", eamPotFile ); painCave.isFatal = 1; @@ -1023,7 +1026,7 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil myEam_rhovals[j+1] = atof( the_token ); // Value 3 - if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ + if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ sprintf( painCave.errMsg, "Error parseing EAM nrho: line in %s\n", eamPotFile ); painCave.isFatal = 1; @@ -1033,7 +1036,7 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil myEam_rhovals[j+2] = atof( the_token ); // Value 4 - if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ + if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ sprintf( painCave.errMsg, "Error parseing EAM nrho: line in %s\n", eamPotFile ); painCave.isFatal = 1; @@ -1043,7 +1046,7 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil myEam_rhovals[j+3] = atof( the_token ); // Value 5 - if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ + if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ sprintf( painCave.errMsg, "Error parseing EAM nrho: line in %s\n", eamPotFile ); painCave.isFatal = 1; @@ -1051,7 +1054,7 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil } myEam_rhovals[j+4] = atof( the_token ); - + } *eam_rvals = myEam_rvals; *eam_rhovals = myEam_rhovals;