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 631 by chuckv, Thu Jul 17 19:25:51 2003 UTC vs.
Revision 669 by chuckv, Thu Aug 7 00:47:33 2003 UTC

# Line 168 | Line 168 | EAM_FF::EAM_FF(){
168  
169    headAtomType = NULL;
170    currentAtomType = NULL;
171 +
172 +  // Set eamRcut to 0.0
173 +  eamRcut = 0.0;
174  
175    // do the funtion wrapping
176    wrapMeFF( this );
# Line 264 | Line 267 | void EAM_FF::initForceField( int ljMixRule ){
267   #endif // is_mpi
268   }
269  
270 < void EAM_FF::initForceField( int ljMixRule ){
270 >
271 > void EAM_FF::calcRcut( void ){
272    
273 +  #ifdef IS_MPI
274 +  double tempEamRcut = eamRcut;
275 +  MPI_Allreduce( &tempEamRcut, &eamRcut, 1, MPI_DOUBLE, MPI_MAX,
276 +                 MPI_COMM_WORLD);
277 + #endif  //is_mpi
278 +  entry_plug->setRcut(eamRcut);
279 + }
280 +
281 +
282 + void EAM_FF::initForceField( int ljMixRule ){
283    initFortran( ljMixRule, 0 );
284   }
285  
# Line 284 | Line 298 | void EAM_FF::readParams( void ){
298   #endif // is_mpi
299   }
300  
301 +
302   void EAM_FF::readParams( void ){
303  
304    atomStruct info;
# Line 470 | Line 485 | void EAM_FF::readParams( void ){
485    }
486        
487    entry_plug->useLJ = 0;
488 <
488 >  entry_plug->useEAM = 1;
489    // Walk down again and send out EAM type
490    currentAtomType = headAtomType->next;
491    while( currentAtomType != NULL ){
492      
493      if( currentAtomType->name[0] != '\0' ){
494        isError = 0;
495 +
496        newEAMtype( &(currentAtomType->lattice_constant),
497                    &(currentAtomType->eam_nrho),
498                    &(currentAtomType->eam_drho),
# Line 488 | Line 504 | void EAM_FF::readParams( void ){
504                    currentAtomType->eam_Frhovals,
505                    &(currentAtomType->eam_ident),
506                    &isError);
507 +
508        if( isError ){
509          sprintf( painCave.errMsg,
510                   "Error initializing the \"%s\" atom type in fortran EAM\n",
# Line 506 | Line 523 | void EAM_FF::readParams( void ){
523             "EAM_FF atom structures successfully sent to fortran\n" );
524    MPIcheckPoint();
525   #endif // is_mpi
526 +
527 +
528  
529   }
530  
# Line 513 | Line 532 | void EAM_FF::initializeAtoms( int nAtoms, Atom** the_a
532   void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){
533    
534    int i;
535 <
535 >  
536    // initialize the atoms
537    
538  
# Line 533 | Line 552 | void EAM_FF::initializeAtoms( int nAtoms, Atom** the_a
552      the_atoms[i]->setMass( currentAtomType->mass );
553      the_atoms[i]->setIdent( currentAtomType->ident );
554      the_atoms[i]->setEAM();
555 +    the_atoms[i]->setEamRcut( currentAtomType->eam_rcut);
556  
557 +    if (eamRcut < currentAtomType->eam_rcut) eamRcut = currentAtomType->eam_rcut;
558 +
559    }
560   }
561  
# Line 661 | Line 683 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
683                       double **eam_rvals,
684                       double **eam_rhovals,
685                       double **eam_Frhovals){
686 <  
686 >  double* myEam_rvals;
687 >  double* myEam_rhovals;
688 >  double* myEam_Frhovals;
689 >
690    char* ffPath_env = "FORCE_PARAM_PATH";
691    char* ffPath;
692    char* the_token;
693    char* eam_eof_test;
694    FILE *eamFile;
695 <  const int BUFFERSIZE = 2000;
695 >  const int BUFFERSIZE = 3000;
696  
697    char temp[200];
698    int linenumber;
699    int nReadLines;
700    char eam_read_buffer[BUFFERSIZE];
701  
702 +
703    int i,j;
704  
705    linenumber = 0;
# Line 814 | Line 840 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
840    info.eam_rcut = atof( the_token);
841  
842  
843 +
844 +
845 +
846    // Ok now we have to allocate point arrays and read in number of points
847    // Index the arrays for fortran, starting at 1
848 <  *eam_Frhovals = new double[info.eam_nrho];
849 <  *eam_rvals    = new double[info.eam_nr];
850 <  *eam_rhovals  = new double[info.eam_nr];
848 >  myEam_Frhovals = new double[info.eam_nrho];
849 >  myEam_rvals    = new double[info.eam_nr];
850 >  myEam_rhovals  = new double[info.eam_nr];
851  
852    // Parse F of rho vals.
853  
854    // Assume for now that we have a complete number of lines
855    nReadLines = int(info.eam_nrho/5);
856 +  
857 +
858  
859    for (i=0;i<nReadLines;i++){
860      j = i*5;
861 <    
861 >
862      // Read next line
863      eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
864      linenumber++;
# Line 847 | Line 878 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
878        painCave.isFatal = 1;
879        simError();
880      }
881 +
882 +    myEam_Frhovals[j+0] = atof( the_token );
883      
851    *eam_Frhovals[j+0] = atof( the_token );
852    
884      // Value 2
885      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
886        sprintf( painCave.errMsg,
# Line 857 | Line 888 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
888        painCave.isFatal = 1;
889        simError();
890      }
891 <  
892 <    *eam_Frhovals[j+1] = atof( the_token );
891 >
892 >    myEam_Frhovals[j+1] = atof( the_token );
893      
894      // Value 3
895      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
# Line 867 | Line 898 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
898        painCave.isFatal = 1;
899        simError();
900      }
901 +
902 +    myEam_Frhovals[j+2] = atof( the_token );
903      
871    *eam_Frhovals[j+2] = atof( the_token );
872    
904      // Value 4
905      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
906        sprintf( painCave.errMsg,
# Line 877 | Line 908 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
908        painCave.isFatal = 1;
909        simError();
910      }
880    
881    *eam_Frhovals[j+3] = atof( the_token );
911  
912 +    myEam_Frhovals[j+3] = atof( the_token );
913 +
914      // Value 5
915      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
916        sprintf( painCave.errMsg,
# Line 887 | Line 918 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
918        painCave.isFatal = 1;
919        simError();
920      }
921 +
922 +    myEam_Frhovals[j+4] = atof( the_token );
923      
891    *eam_Frhovals[j+4] = atof( the_token );
892    
924    }
925    // Parse Z of r vals
926    
# Line 919 | Line 950 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
950        simError();
951      }
952      
953 <    *eam_rvals[j+0] = atof( the_token );
953 >    myEam_rvals[j+0] = atof( the_token );
954  
955      // Value 2
956      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
# Line 929 | Line 960 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
960        simError();
961      }
962    
963 <    *eam_rvals[j+1] = atof( the_token );
963 >    myEam_rvals[j+1] = atof( the_token );
964  
965      // Value 3
966      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
# Line 939 | Line 970 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
970        simError();
971      }
972    
973 <    *eam_rvals[j+2] = atof( the_token );
973 >    myEam_rvals[j+2] = atof( the_token );
974  
975      // Value 4
976      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
# Line 949 | Line 980 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
980        simError();
981      }
982    
983 <    *eam_rvals[j+3] = atof( the_token );
983 >    myEam_rvals[j+3] = atof( the_token );
984  
985      // Value 5
986      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
# Line 959 | Line 990 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
990        simError();
991      }
992    
993 <    *eam_rvals[j+4] = atof( the_token );
993 >    myEam_rvals[j+4] = atof( the_token );
994  
995    }
996    // Parse rho of r vals
# Line 989 | Line 1020 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1020        simError();
1021      }
1022    
1023 <    *eam_rhovals[j+0] = atof( the_token );
1023 >    myEam_rhovals[j+0] = atof( the_token );
1024  
1025      // Value 2
1026      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
# Line 999 | Line 1030 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1030        simError();
1031      }
1032    
1033 <    *eam_rhovals[j+1] = atof( the_token );
1033 >    myEam_rhovals[j+1] = atof( the_token );
1034  
1035      // Value 3
1036      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
# Line 1009 | Line 1040 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1040        simError();
1041      }
1042    
1043 <    *eam_rhovals[j+2] = atof( the_token );
1043 >    myEam_rhovals[j+2] = atof( the_token );
1044  
1045      // Value 4
1046      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
# Line 1019 | Line 1050 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1050        simError();
1051      }
1052    
1053 <    *eam_rhovals[j+3] = atof( the_token );
1053 >    myEam_rhovals[j+3] = atof( the_token );
1054  
1055      // Value 5
1056      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
# Line 1029 | Line 1060 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1060        simError();
1061      }
1062    
1063 <    *eam_rhovals[j+4] = atof( the_token );
1063 >    myEam_rhovals[j+4] = atof( the_token );
1064  
1065    }
1066 +  *eam_rvals = myEam_rvals;
1067 +  *eam_rhovals = myEam_rhovals;
1068 +  *eam_Frhovals = myEam_Frhovals;
1069  
1070    fclose(eamFile);
1071    return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines