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 ); |
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 |
|
|
298 |
|
#endif // is_mpi |
299 |
|
} |
300 |
|
|
301 |
+ |
|
302 |
|
void EAM_FF::readParams( void ){ |
303 |
|
|
304 |
|
atomStruct info; |
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), |
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", |
523 |
|
"EAM_FF atom structures successfully sent to fortran\n" ); |
524 |
|
MPIcheckPoint(); |
525 |
|
#endif // is_mpi |
526 |
+ |
|
527 |
+ |
|
528 |
|
|
529 |
|
} |
530 |
|
|
532 |
|
void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
533 |
|
|
534 |
|
int i; |
535 |
< |
|
535 |
> |
|
536 |
|
// initialize the atoms |
537 |
|
|
538 |
|
|
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 |
|
|
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; |
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++; |
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, |
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){ |
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, |
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, |
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 |
|
|
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){ |
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){ |
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){ |
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){ |
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 |
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){ |
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){ |
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){ |
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){ |
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; |