--- trunk/OOPSE/libmdtools/EAM_FF.cpp 2003/07/17 19:25:51 631 +++ trunk/OOPSE/libmdtools/EAM_FF.cpp 2004/04/12 20:32:20 1097 @@ -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 @@ -264,8 +264,19 @@ EAM_FF::~EAM_FF(){ #endif // is_mpi } -void EAM_FF::initForceField( int ljMixRule ){ + +void EAM_FF::calcRcut( void ){ +#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); +} + + +void EAM_FF::initForceField( int ljMixRule ){ initFortran( ljMixRule, 0 ); } @@ -284,13 +295,13 @@ void EAM_FF::cleanMe( void ){ #endif // is_mpi } + void EAM_FF::readParams( void ){ atomStruct info; 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 @@ -396,7 +407,7 @@ void EAM_FF::readParams( void ){ MPIcheckPoint(); headAtomType = new LinkedAtomType; - recieveFrcStruct( &info, mpiAtomStructType ); + receiveFrcStruct( &info, mpiAtomStructType ); while( !info.last ){ @@ -422,7 +433,7 @@ void EAM_FF::readParams( void ){ MPIcheckPoint(); - recieveFrcStruct( &info, mpiAtomStructType ); + receiveFrcStruct( &info, mpiAtomStructType ); } @@ -438,8 +449,10 @@ void EAM_FF::readParams( void ){ int isDipole = 0; int isSSD = 0; int isGB = 0; - int isEAM= 1; + int isEAM = 1; + int isCharge = 0; double dipole = 0.0; + double charge = 0.0; double eamSigma = 0.0; double eamEpslon = 0.0; @@ -454,8 +467,10 @@ void EAM_FF::readParams( void ){ &isDipole, &isGB, &isEAM, + &isCharge, &eamEpslon, &eamSigma, + &charge, &dipole, &isError ); if( isError ){ @@ -470,13 +485,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; + newEAMtype( &(currentAtomType->lattice_constant), &(currentAtomType->eam_nrho), &(currentAtomType->eam_drho), @@ -488,6 +504,7 @@ void EAM_FF::readParams( void ){ currentAtomType->eam_Frhovals, &(currentAtomType->eam_ident), &isError); + if( isError ){ sprintf( painCave.errMsg, "Error initializing the \"%s\" atom type in fortran EAM\n", @@ -507,18 +524,17 @@ void EAM_FF::readParams( void ){ MPIcheckPoint(); #endif // is_mpi + + } void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ int i; - + // initialize the atoms - - Atom* thisAtom; - for( i=0; ifind( the_atoms[i]->getType() ); @@ -532,8 +548,9 @@ 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(); + if (eamRcut < currentAtomType->eam_rcut) eamRcut = currentAtomType->eam_rcut; + } } @@ -661,19 +678,23 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil double **eam_rvals, double **eam_rhovals, double **eam_Frhovals){ - + double* myEam_rvals; + double* myEam_rhovals; + double* myEam_Frhovals; + char* ffPath_env = "FORCE_PARAM_PATH"; char* ffPath; char* the_token; char* eam_eof_test; FILE *eamFile; - const int BUFFERSIZE = 2000; + const int BUFFERSIZE = 3000; char temp[200]; int linenumber; int nReadLines; char eam_read_buffer[BUFFERSIZE]; + int i,j; linenumber = 0; @@ -814,20 +835,25 @@ int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil info.eam_rcut = atof( the_token); + + + // Ok now we have to allocate point arrays and read in number of points // Index the arrays for fortran, starting at 1 - *eam_Frhovals = new double[info.eam_nrho]; - *eam_rvals = new double[info.eam_nr]; - *eam_rhovals = new double[info.eam_nr]; + myEam_Frhovals = new double[info.eam_nrho]; + myEam_rvals = new double[info.eam_nr]; + myEam_rhovals = new double[info.eam_nr]; // Parse F of rho vals. // Assume for now that we have a complete number of lines nReadLines = int(info.eam_nrho/5); + + for (i=0;i