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 627 by chuckv, Wed Jul 16 21:49:59 2003 UTC vs.
Revision 631 by chuckv, Thu Jul 17 19:25:51 2003 UTC

# Line 33 | Line 33 | namespace EAM_NS{
33      double eam_dr;    // The distance between each of the rho points.    
34      int eam_nrho;  // Number of points indexed by rho
35      int eam_nr;    // The number of points based on r (Both Phi(r) and Rho(r)).
36 <    int eam_rcut;  // The cutoff radius for eam.
36 >    double eam_rcut;  // The cutoff radius for eam.
37      int eam_ident; // Atomic number
38      int ident;
39      int last;      //  0  -> default
# Line 41 | Line 41 | namespace EAM_NS{
41    } atomStruct;
42  
43    int parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile );
44 <  int parseEAM( atomStruct &info, char *eamPotFile );
44 >  int parseEAM( atomStruct &info, char *eamPotFile, double **eam_rvals,
45 >                double **eam_rhovals, double **eam_Frhovals);
46   #ifdef IS_MPI
47    
48    MPI_Datatype mpiAtomStructType;
# Line 135 | Line 136 | namespace EAM_NS{
136      double eam_drho; // The distance between each of the points indexed by rho.
137      int eam_nr;   // The number of points based on r (Both Phi(r) and Rho(r)).
138      double eam_dr;   // The distance between each of the rho points.
139 <    int eam_rcut; // The cutoff radius for eam.
139 >    double eam_rcut; // The cutoff radius for eam.
140  
141      double *eam_rvals;    // Z of r values
142      double *eam_rhovals;  // rho of r values
# Line 150 | Line 151 | using namespace LJ_NS;
151  
152   }
153  
154 < using namespace LJ_NS;
154 > using namespace EAM_NS;
155  
156   //****************************************************************
157   // begins the actual forcefield stuff.  
# Line 335 | Line 336 | void EAM_FF::readParams( void ){
336          // the parser returns 0 if the line was blank
337          if( parseAtom( readLine, lineNum, info, eamPotFile ) ){
338            parseEAM(info,eamPotFile, &eam_rvals,
339 <                   &eam_rhovals, &eam_Frhovals)){
339 >                   &eam_rhovals, &eam_Frhovals);
340            info.ident = identNum;
341            headAtomType->add( info, eam_rvals,
342                               eam_rhovals,eam_Frhovals );
# Line 437 | Line 438 | void EAM_FF::readParams( void ){
438    int isDipole = 0;
439    int isSSD = 0;
440    int isGB = 0;
441 <  int isEam = 1;
441 >  int isEAM= 1;
442    double dipole = 0.0;
443 +  double eamSigma = 0.0;
444 +  double eamEpslon = 0.0;
445    
446    currentAtomType = headAtomType->next;
447    while( currentAtomType != NULL ){
# Line 451 | Line 454 | void EAM_FF::readParams( void ){
454                   &isDipole,
455                   &isGB,
456                   &isEAM,
457 <                 &(currentAtomType->epslon),
458 <                 &(currentAtomType->sigma),
457 >                 &eamEpslon,
458 >                 &eamSigma,
459                   &dipole,
460                   &isError );
461        if( isError ){
# Line 479 | Line 482 | void EAM_FF::readParams( void ){
482                    &(currentAtomType->eam_drho),
483                    &(currentAtomType->eam_nr),
484                    &(currentAtomType->eam_dr),
485 +                  &(currentAtomType->eam_rcut),
486                    currentAtomType->eam_rvals,
487                    currentAtomType->eam_rhovals,
488                    currentAtomType->eam_Frhovals,
# Line 533 | Line 537 | void LJ_FF::initializeBonds( int nBonds, Bond** BondAr
537    }
538   }
539  
540 < void LJ_FF::initializeBonds( int nBonds, Bond** BondArray,
540 > void EAM_FF::initializeBonds( int nBonds, Bond** BondArray,
541                               bond_pair* the_bonds ){
542    
543      if( nBonds ){
# Line 661 | Line 665 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
665    char* ffPath_env = "FORCE_PARAM_PATH";
666    char* ffPath;
667    char* the_token;
668 +  char* eam_eof_test;
669    FILE *eamFile;
670 +  const int BUFFERSIZE = 2000;
671 +
672    char temp[200];
673    int linenumber;
674    int nReadLines;
675 +  char eam_read_buffer[BUFFERSIZE];
676  
677    int i,j;
678  
# Line 674 | Line 682 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
682    eamFile = fopen( eamPotFile, "r" );
683    
684    
685 <  if( frcFile == NULL ){
685 >  if( eamFile == NULL ){
686      
687        // next see if the force path enviorment variable is set
688      
# Line 693 | Line 701 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
701  
702      
703      
704 <    if( frcFile == NULL ){
704 >    if( eamFile == NULL ){
705        
706        sprintf( painCave.errMsg,
707                 "Error opening the EAM force parameter file: %s\n"
# Line 706 | Line 714 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
714    }
715  
716    // First line is a comment line, read and toss it....
717 <  eof_test = fgets(read_buffer, sizeof(read_buffer),eamFile);
717 >  eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
718    linenumber++;
719 <  if(eof_test == NULL){
719 >  if(eam_eof_test == NULL){
720      sprintf( painCave.errMsg,
721               "error in reading commment in %s\n", eamPotFile);
722      painCave.isFatal = 1;
# Line 718 | Line 726 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
726  
727  
728    // The Second line contains atomic number, atomic mass and a lattice constant
729 <  eof_test = fgets(read_buffer, sizeof(read_buffer),eamFile);
729 >  eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
730    linenumber++;
731 <  if(eof_test == NULL){
731 >  if(eam_eof_test == NULL){
732      sprintf( painCave.errMsg,
733               "error in reading Identifier line in %s\n", eamPotFile);
734      painCave.isFatal = 1;
# Line 730 | Line 738 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
738  
739  
740      
741 <  if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
741 >  if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
742      sprintf( painCave.errMsg,
743               "Error parseing EAM ident  line in %s\n", eamPotFile );
744      painCave.isFatal = 1;
# Line 756 | Line 764 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
764    info.lattice_constant = atof( the_token);
765  
766    // Next line is nrho, drho, nr, dr and rcut
767 <  eof_test = fgets(read_buffer, sizeof(read_buffer),eamFile)
768 <  if(eof_test == NULL){
767 >  eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
768 >  if(eam_eof_test == NULL){
769      sprintf( painCave.errMsg,
770               "error in reading number of points line in %s\n", eamPotFile);
771      painCave.isFatal = 1;
772      simError();
773    }
774  
775 <  if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
775 >  if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
776      sprintf( painCave.errMsg,
777               "Error parseing EAM nrho: line in %s\n", eamPotFile );
778      painCave.isFatal = 1;
# Line 808 | Line 816 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
816  
817    // Ok now we have to allocate point arrays and read in number of points
818    // Index the arrays for fortran, starting at 1
819 <  *eam_Frhovals = new double[info.nrho];
820 <  *eam_rvals    = new double[info.nr];
821 <  *eam_rhovals  = new double[info.nr];
819 >  *eam_Frhovals = new double[info.eam_nrho];
820 >  *eam_rvals    = new double[info.eam_nr];
821 >  *eam_rhovals  = new double[info.eam_nr];
822  
823    // Parse F of rho vals.
824  
825    // Assume for now that we have a complete number of lines
826 <  nReadLines = int(info.nrho/5);
826 >  nReadLines = int(info.eam_nrho/5);
827  
828    for (i=0;i<nReadLines;i++){
829      j = i*5;
830      
831      // Read next line
832 <    eof_test = fgets(read_buffer, sizeof(read_buffer),eamFile);
832 >    eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
833      linenumber++;
834 <    if(eof_test == NULL){
834 >    if(eam_eof_test == NULL){
835        sprintf( painCave.errMsg,
836                 "error in reading EAM file %s at line %d\n",
837                 eamPotFile,linenumber);
# Line 833 | Line 841 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
841      
842      // Parse 5 values on each line into array
843      // Value 1
844 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
844 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
845        sprintf( painCave.errMsg,
846                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
847        painCave.isFatal = 1;
# Line 886 | Line 894 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
894    // Parse Z of r vals
895    
896    // Assume for now that we have a complete number of lines
897 <  nReadLines = int(info.nr/5);
897 >  nReadLines = int(info.eam_nr/5);
898  
899    for (i=0;i<nReadLines;i++){
900      j = i*5;
901  
902      // Read next line
903 <    eof_test = fgets(read_buffer, sizeof(read_buffer),eamFile);
903 >    eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
904      linenumber++;
905 <    if(eof_test == NULL){
905 >    if(eam_eof_test == NULL){
906        sprintf( painCave.errMsg,
907                 "error in reading EAM file %s at line %d\n",
908                 eamPotFile,linenumber);
# Line 904 | Line 912 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
912      
913      // Parse 5 values on each line into array
914      // Value 1
915 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
915 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
916        sprintf( painCave.errMsg,
917                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
918        painCave.isFatal = 1;
# Line 962 | Line 970 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
970      j = i*5;
971  
972      // Read next line
973 <    eof_test = fgets(read_buffer, sizeof(read_buffer),eamFile);
973 >    eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
974      linenumber++;
975 <    if(eof_test == NULL){
975 >    if(eam_eof_test == NULL){
976        sprintf( painCave.errMsg,
977                 "error in reading EAM file %s at line %d\n",
978                 eamPotFile,linenumber);
# Line 974 | Line 982 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
982    
983      // Parse 5 values on each line into array
984      // Value 1
985 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
985 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
986        sprintf( painCave.errMsg,
987                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
988        painCave.isFatal = 1;
# Line 984 | Line 992 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
992      *eam_rhovals[j+0] = atof( the_token );
993  
994      // Value 2
995 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
995 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
996        sprintf( painCave.errMsg,
997                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
998        painCave.isFatal = 1;
# Line 994 | Line 1002 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1002      *eam_rhovals[j+1] = atof( the_token );
1003  
1004      // Value 3
1005 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
1005 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1006        sprintf( painCave.errMsg,
1007                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1008        painCave.isFatal = 1;
# Line 1004 | Line 1012 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1012      *eam_rhovals[j+2] = atof( the_token );
1013  
1014      // Value 4
1015 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
1015 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1016        sprintf( painCave.errMsg,
1017                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1018        painCave.isFatal = 1;
# Line 1014 | Line 1022 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1022      *eam_rhovals[j+3] = atof( the_token );
1023  
1024      // Value 5
1025 <    if ( (the_token = strtok( read_buffer, " \n\t,;")) == NULL){
1025 >    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
1026        sprintf( painCave.errMsg,
1027                 "Error parseing EAM nrho: line in %s\n", eamPotFile );
1028        painCave.isFatal = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines