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 |
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; |
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 |
151 |
|
|
152 |
|
} |
153 |
|
|
154 |
< |
using namespace LJ_NS; |
154 |
> |
using namespace EAM_NS; |
155 |
|
|
156 |
|
//**************************************************************** |
157 |
|
// begins the actual forcefield stuff. |
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 ); |
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 ){ |
454 |
|
&isDipole, |
455 |
|
&isGB, |
456 |
|
&isEAM, |
457 |
< |
&(currentAtomType->epslon), |
458 |
< |
&(currentAtomType->sigma), |
457 |
> |
&eamEpslon, |
458 |
> |
&eamSigma, |
459 |
|
&dipole, |
460 |
|
&isError ); |
461 |
|
if( isError ){ |
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, |
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 ){ |
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 |
|
|
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 |
|
|
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" |
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; |
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; |
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; |
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; |
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); |
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; |
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); |
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; |
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); |
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; |
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; |
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; |
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; |
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; |