ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/EAM_FF.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/EAM_FF.cpp (file contents):
Revision 657 by chuckv, Wed Jul 30 21:17:01 2003 UTC vs.
Revision 1224 by gezelter, Wed Jun 2 18:27:52 2004 UTC

# Line 1 | Line 1
1 < #include <cstdlib>
2 < #include <cstdio>
3 < #include <cstring>
1 > #include <stdlib.h>
2 > #include <stdio.h>
3 > #include <string.h>
4  
5   #include <iostream>
6   using namespace std;
# Line 30 | Line 30 | namespace EAM_NS{
30      double mass;
31      double lattice_constant;
32      double eam_drho;  // The distance between each of the points indexed by rho.
33 +    double eam_rcut;  // The cutoff radius for eam.
34      double eam_dr;    // The distance between each of the rho points.    
35      int eam_nrho;  // Number of points indexed by rho
36      int eam_nr;    // The number of points based on r (Both Phi(r) and Rho(r)).
36    double eam_rcut;  // The cutoff radius for eam.
37      int eam_ident; // Atomic number
38      int ident;
39      int last;      //  0  -> default
# Line 76 | Line 76 | namespace EAM_NS{
76      void add( atomStruct &info, double *the_eam_rvals,
77                double *the_eam_rhovals,double *the_eam_Frhovals ){
78  
79      int i;
80
79        // check for duplicates
80        
81        if( !strcmp( info.name, name ) ){
# Line 164 | Line 162 | EAM_FF::EAM_FF(){
162    char* ffPath_env = "FORCE_PARAM_PATH";
163    char* ffPath;
164    char temp[200];
167  char errMsg[1000];
165  
166    headAtomType = NULL;
167    currentAtomType = NULL;
168  
169 +  // Set eamRcut to 0.0
170 +  eamRcut = 0.0;
171 +
172    // do the funtion wrapping
173    wrapMeFF( this );
174  
# Line 179 | Line 179 | EAM_FF::EAM_FF(){
179    // Init the atomStruct mpi type
180  
181    atomStruct atomProto; // mpiPrototype
182 <  int atomBC[3] = {15,4,6};  // block counts
182 >  int atomBC[3] = {15,5,5};  // block counts
183    MPI_Aint atomDspls[3];           // displacements
184    MPI_Datatype atomMbrTypes[3];    // member mpi types
185  
# Line 228 | Line 228 | EAM_FF::EAM_FF(){
228        frcFile = fopen( fileName, "r" );
229        
230        if( frcFile == NULL ){
231 <        
232 <        sprintf( painCave.errMsg,
233 <                 "Error opening the force field parameter file: %s\n"
234 <                 "Have you tried setting the FORCE_PARAM_PATH environment "
235 <                 "vairable?\n",
231 >
232 >        sprintf( painCave.errMsg,
233 >                 "Error opening the force field parameter file:\n"
234 >                 "\t%s\n"
235 >                 "\tHave you tried setting the FORCE_PARAM_PATH environment "
236 >                 "variable?\n",
237                   fileName );
238 +        painCave.severity = OOPSE_ERROR;
239          painCave.isFatal = 1;
240          simError();
241        }
# Line 266 | Line 268 | void EAM_FF::calcRcut( void ){
268  
269  
270   void EAM_FF::calcRcut( void ){
271 <  double tempEamRcut;
272 <
273 <  entry_plug->setRcut(eamRcut);
271 >  
272 > #ifdef IS_MPI
273 >  double tempEamRcut = eamRcut;
274 >  MPI_Allreduce( &tempEamRcut, &eamRcut, 1, MPI_DOUBLE, MPI_MAX,
275 >                 MPI_COMM_WORLD);
276 > #endif  //is_mpi
277 >  entry_plug->setDefaultRcut(eamRcut);
278   }
279  
280  
# Line 298 | Line 304 | void EAM_FF::readParams( void ){
304    info.last = 1; // initialize last to have the last set.
305                   // if things go well, last will be set to 0
306  
301  int i;
307    int identNum;
308    double *eam_rvals;    // Z of r values
309    double *eam_rhovals;  // rho of r values
# Line 404 | Line 409 | void EAM_FF::readParams( void ){
409      MPIcheckPoint();
410  
411      headAtomType = new LinkedAtomType;
412 <    recieveFrcStruct( &info, mpiAtomStructType );
412 >    receiveFrcStruct( &info, mpiAtomStructType );
413  
414      while( !info.last ){
415        
# Line 430 | Line 435 | void EAM_FF::readParams( void ){
435        
436        MPIcheckPoint();
437  
438 <      recieveFrcStruct( &info, mpiAtomStructType );
438 >      receiveFrcStruct( &info, mpiAtomStructType );
439  
440  
441      }
# Line 446 | Line 451 | void EAM_FF::readParams( void ){
451    int isDipole = 0;
452    int isSSD = 0;
453    int isGB = 0;
454 <  int isEAM= 1;
454 >  int isEAM = 1;
455 >  int isCharge = 0;
456    double dipole = 0.0;
457 +  double charge = 0.0;
458    double eamSigma = 0.0;
459    double eamEpslon = 0.0;
460    
# Line 462 | Line 469 | void EAM_FF::readParams( void ){
469                   &isDipole,
470                   &isGB,
471                   &isEAM,
472 +                 &isCharge,
473                   &eamEpslon,
474                   &eamSigma,
475 +                 &charge,
476                   &dipole,
477                   &isError );
478        if( isError ){
# Line 478 | Line 487 | void EAM_FF::readParams( void ){
487    }
488        
489    entry_plug->useLJ = 0;
490 <
490 >  entry_plug->useEAM = 1;
491    // Walk down again and send out EAM type
492    currentAtomType = headAtomType->next;
493    while( currentAtomType != NULL ){
494      
495      if( currentAtomType->name[0] != '\0' ){
496        isError = 0;
497 <      cerr << "Calling newEAMtype for type "<<currentAtomType->eam_ident <<"\n";
497 >
498        newEAMtype( &(currentAtomType->lattice_constant),
499                    &(currentAtomType->eam_nrho),
500                    &(currentAtomType->eam_drho),
# Line 497 | Line 506 | void EAM_FF::readParams( void ){
506                    currentAtomType->eam_Frhovals,
507                    &(currentAtomType->eam_ident),
508                    &isError);
509 <      cerr << "Returned from newEAMtype\n";
509 >
510        if( isError ){
511          sprintf( painCave.errMsg,
512                   "Error initializing the \"%s\" atom type in fortran EAM\n",
# Line 517 | Line 526 | void EAM_FF::readParams( void ){
526    MPIcheckPoint();
527   #endif // is_mpi
528  
520  cerr << "Done sending eamtypes to fortran\n";
529  
530 +
531   }
532  
533  
534   void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){
535    
536    int i;
537 <
537 >  
538    // initialize the atoms
539    
531
532  Atom* thisAtom;
533
540    for( i=0; i<nAtoms; i++ ){
541      
542      currentAtomType = headAtomType->find( the_atoms[i]->getType() );
# Line 544 | Line 550 | void EAM_FF::initializeAtoms( int nAtoms, Atom** the_a
550      
551      the_atoms[i]->setMass( currentAtomType->mass );
552      the_atoms[i]->setIdent( currentAtomType->ident );
547    the_atoms[i]->setEAM();
553  
554 +    if (eamRcut < currentAtomType->eam_rcut) eamRcut = currentAtomType->eam_rcut;
555 +    
556    }
557   }
558  
# Line 722 | Line 729 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
729        sprintf( painCave.errMsg,
730                 "Error opening the EAM force parameter file: %s\n"
731                 "Have you tried setting the FORCE_PARAM_PATH environment "
732 <               "vairable?\n",
732 >               "variable?\n",
733                 eamPotFile );
734        painCave.isFatal = 1;
735        simError();
# Line 1013 | Line 1020 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1020      myEam_rhovals[j+0] = atof( the_token );
1021  
1022      // Value 2
1023 <    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1023 >    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1024        sprintf( painCave.errMsg,
1025                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1026        painCave.isFatal = 1;
# Line 1023 | Line 1030 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1030      myEam_rhovals[j+1] = atof( the_token );
1031  
1032      // Value 3
1033 <    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1033 >    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1034        sprintf( painCave.errMsg,
1035                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1036        painCave.isFatal = 1;
# Line 1033 | Line 1040 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1040      myEam_rhovals[j+2] = atof( the_token );
1041  
1042      // Value 4
1043 <    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1043 >    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1044        sprintf( painCave.errMsg,
1045                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1046        painCave.isFatal = 1;
# Line 1043 | Line 1050 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1050      myEam_rhovals[j+3] = atof( the_token );
1051  
1052      // Value 5
1053 <    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1053 >    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1054        sprintf( painCave.errMsg,
1055                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1056        painCave.isFatal = 1;
# Line 1051 | Line 1058 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1058      }
1059    
1060      myEam_rhovals[j+4] = atof( the_token );
1061 <
1061 >
1062    }
1063    *eam_rvals = myEam_rvals;
1064    *eam_rhovals = myEam_rhovals;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines