28 |
|
typedef struct{ |
29 |
|
char name[15]; |
30 |
|
double mass; |
31 |
< |
double epslon; |
32 |
< |
double sigma; |
31 |
> |
double lattice_constant; |
32 |
> |
double eam_drho; // The distance between each of the points indexed by rho. |
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 |
> |
double eam_rcut; // The cutoff radius for eam. |
37 |
> |
int eam_ident; // Atomic number |
38 |
|
int ident; |
39 |
|
int last; // 0 -> default |
40 |
|
// 1 -> in MPI: tells nodes to stop listening |
41 |
|
} atomStruct; |
42 |
|
|
43 |
< |
int parseAtom( char *lineBuffer, int lineNum, atomStruct &info ); |
44 |
< |
|
43 |
> |
int parseAtom( char *lineBuffer, int lineNum, 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; |
54 |
|
LinkedAtomType(){ |
55 |
|
next = NULL; |
56 |
|
name[0] = '\0'; |
57 |
+ |
eam_rvals = NULL; |
58 |
+ |
eam_rhovals = NULL; |
59 |
+ |
eam_Frhovals = NULL; |
60 |
|
} |
52 |
– |
~LinkedAtomType(){ if( next != NULL ) delete next; } |
61 |
|
|
62 |
+ |
~LinkedAtomType(){ |
63 |
+ |
if( next != NULL ) delete next; |
64 |
+ |
if( eam_rvals != NULL ) delete[] eam_rvals; |
65 |
+ |
if( eam_rhovals != NULL ) delete[] eam_rhovals; |
66 |
+ |
if( eam_Frhovals != NULL ) delete[] eam_Frhovals; |
67 |
+ |
} |
68 |
+ |
|
69 |
|
LinkedAtomType* find(char* key){ |
70 |
|
if( !strcmp(name, key) ) return this; |
71 |
|
if( next != NULL ) return next->find(key); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
< |
void add( atomStruct &info ){ |
77 |
< |
|
76 |
> |
void add( atomStruct &info, double *the_eam_rvals, |
77 |
> |
double *the_eam_rhovals,double *the_eam_Frhovals ){ |
78 |
> |
|
79 |
> |
int i; |
80 |
> |
|
81 |
|
// check for duplicates |
82 |
|
|
83 |
|
if( !strcmp( info.name, name ) ){ |
89 |
|
simError(); |
90 |
|
} |
91 |
|
|
92 |
< |
if( next != NULL ) next->add(info); |
92 |
> |
if( next != NULL ) next->add(info, the_eam_rvals, the_eam_rhovals, the_eam_Frhovals); |
93 |
|
else{ |
94 |
|
next = new LinkedAtomType(); |
95 |
|
strcpy(next->name, info.name); |
96 |
< |
next->mass = info.mass; |
97 |
< |
next->epslon = info.epslon; |
98 |
< |
next->sigma = info.sigma; |
99 |
< |
next->ident = info.ident; |
96 |
> |
next->mass = info.mass; |
97 |
> |
next->lattice_constant = info.lattice_constant; |
98 |
> |
next->eam_nrho = info.eam_nrho; |
99 |
> |
next->eam_drho = info.eam_drho; |
100 |
> |
next->eam_nr = info.eam_nr; |
101 |
> |
next->eam_dr = info.eam_dr; |
102 |
> |
next->eam_rcut = info.eam_rcut; |
103 |
> |
next->eam_ident = info.eam_ident; |
104 |
> |
next->ident = info.ident; |
105 |
> |
|
106 |
> |
next->eam_rvals = the_eam_rvals; |
107 |
> |
next->eam_rhovals = the_eam_rhovals; |
108 |
> |
next->eam_Frhovals = the_eam_Frhovals; |
109 |
|
} |
110 |
|
} |
111 |
|
|
114 |
|
|
115 |
|
void duplicate( atomStruct &info ){ |
116 |
|
strcpy(info.name, name); |
117 |
< |
info.mass = mass; |
118 |
< |
info.epslon = epslon; |
119 |
< |
info.sigma = sigma; |
120 |
< |
info.ident = ident; |
121 |
< |
info.last = 0; |
117 |
> |
info.mass = mass; |
118 |
> |
info.lattice_constant = lattice_constant; |
119 |
> |
info.eam_nrho = eam_nrho; |
120 |
> |
info.eam_drho = eam_drho; |
121 |
> |
info.eam_nr = eam_nr; |
122 |
> |
info.eam_dr = eam_dr; |
123 |
> |
info.eam_rcut = eam_rcut; |
124 |
> |
info.eam_ident = eam_ident; |
125 |
> |
info.ident = ident; |
126 |
> |
info.last = 0; |
127 |
|
} |
128 |
|
|
129 |
|
|
131 |
|
|
132 |
|
char name[15]; |
133 |
|
double mass; |
134 |
< |
double epslon; |
135 |
< |
double sigma; |
134 |
> |
double lattice_constant; |
135 |
> |
int eam_nrho; // Number of points indexed by rho |
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 |
> |
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 |
143 |
> |
double *eam_Frhovals; // F of rho values |
144 |
> |
int eam_ident; // eam identity (atomic number) |
145 |
|
int ident; |
146 |
|
LinkedAtomType* next; |
147 |
|
}; |
151 |
|
|
152 |
|
} |
153 |
|
|
154 |
< |
using namespace LJ_NS; |
154 |
> |
using namespace EAM_NS; |
155 |
|
|
156 |
|
//**************************************************************** |
157 |
|
// begins the actual forcefield stuff. |
179 |
|
// Init the atomStruct mpi type |
180 |
|
|
181 |
|
atomStruct atomProto; // mpiPrototype |
182 |
< |
int atomBC[3] = {15,3,2}; // block counts |
182 |
> |
int atomBC[3] = {15,4,6}; // block counts |
183 |
|
MPI_Aint atomDspls[3]; // displacements |
184 |
|
MPI_Datatype atomMbrTypes[3]; // member mpi types |
185 |
|
|
186 |
|
MPI_Address(&atomProto.name, &atomDspls[0]); |
187 |
|
MPI_Address(&atomProto.mass, &atomDspls[1]); |
188 |
< |
MPI_Address(&atomProto.ident, &atomDspls[2]); |
188 |
> |
MPI_Address(&atomProto.eam_nrho, &atomDspls[2]); |
189 |
|
|
190 |
|
atomMbrTypes[0] = MPI_CHAR; |
191 |
|
atomMbrTypes[1] = MPI_DOUBLE; |
242 |
|
#ifdef IS_MPI |
243 |
|
} |
244 |
|
|
245 |
< |
sprintf( checkPointMsg, "LJ_FF file opened sucessfully." ); |
245 |
> |
sprintf( checkPointMsg, "EAM_FF file opened sucessfully." ); |
246 |
|
MPIcheckPoint(); |
247 |
|
|
248 |
|
#endif // is_mpi |
292 |
|
|
293 |
|
int i; |
294 |
|
int identNum; |
295 |
+ |
double *eam_rvals; // Z of r values |
296 |
+ |
double *eam_rhovals; // rho of r values |
297 |
+ |
double *eam_Frhovals; // F of rho values |
298 |
+ |
char eamPotFile[1000]; |
299 |
|
|
300 |
|
|
301 |
|
bigSigma = 0.0; |
307 |
|
|
308 |
|
headAtomType = new LinkedAtomType; |
309 |
|
|
310 |
< |
fastForward( "AtomTypes", "initializeAtoms" ); |
310 |
> |
fastForward( "AtomTypes", "eam atom readParams" ); |
311 |
|
|
312 |
|
// we are now at the AtomTypes section. |
313 |
|
|
327 |
|
|
328 |
|
identNum = 1; |
329 |
|
// stop reading at end of file, or at next section |
330 |
+ |
|
331 |
|
while( readLine[0] != '#' && eof_test != NULL ){ |
332 |
|
|
333 |
|
// toss comment lines |
334 |
|
if( readLine[0] != '!' ){ |
335 |
|
|
336 |
|
// the parser returns 0 if the line was blank |
337 |
< |
if( parseAtom( readLine, lineNum, info ) ){ |
337 |
> |
if( parseAtom( readLine, lineNum, info, eamPotFile ) ){ |
338 |
> |
parseEAM(info,eamPotFile, &eam_rvals, |
339 |
> |
&eam_rhovals, &eam_Frhovals); |
340 |
|
info.ident = identNum; |
341 |
< |
headAtomType->add( info );; |
341 |
> |
headAtomType->add( info, eam_rvals, |
342 |
> |
eam_rhovals,eam_Frhovals ); |
343 |
|
identNum++; |
344 |
|
} |
345 |
|
} |
346 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
347 |
|
lineNum++; |
348 |
|
} |
349 |
+ |
|
350 |
+ |
|
351 |
|
|
352 |
|
#ifdef IS_MPI |
353 |
+ |
|
354 |
|
|
355 |
|
// send out the linked list to all the other processes |
356 |
|
|
357 |
|
sprintf( checkPointMsg, |
358 |
< |
"LJ_FF atom structures read successfully." ); |
358 |
> |
"EAM_FF atom structures read successfully." ); |
359 |
|
MPIcheckPoint(); |
360 |
|
|
361 |
|
currentAtomType = headAtomType->next; //skip the first element who is a place holder. |
365 |
|
|
366 |
|
|
367 |
|
sendFrcStruct( &info, mpiAtomStructType ); |
368 |
+ |
|
369 |
+ |
// We have to now broadcast the Arrays |
370 |
+ |
MPI_Bcast(currentAtomType->eam_rvals, |
371 |
+ |
currentAtomType->eam_nr, |
372 |
+ |
MPI_DOUBLE,0,MPI_COMM_WORLD); |
373 |
+ |
MPI_Bcast(currentAtomType->eam_rhovals, |
374 |
+ |
currentAtomType->eam_nr, |
375 |
+ |
MPI_DOUBLE,0,MPI_COMM_WORLD); |
376 |
+ |
MPI_Bcast(currentAtomType->eam_Frhovals, |
377 |
+ |
currentAtomType->eam_nrho, |
378 |
+ |
MPI_DOUBLE,0,MPI_COMM_WORLD); |
379 |
|
|
380 |
|
sprintf( checkPointMsg, |
381 |
< |
"successfully sent lJ force type: \"%s\"\n", |
381 |
> |
"successfully sent EAM force type: \"%s\"\n", |
382 |
|
info.name ); |
383 |
|
MPIcheckPoint(); |
384 |
|
|
397 |
|
|
398 |
|
headAtomType = new LinkedAtomType; |
399 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
400 |
< |
|
400 |
> |
|
401 |
|
while( !info.last ){ |
402 |
+ |
|
403 |
+ |
// allocate the arrays |
404 |
|
|
405 |
+ |
eam_rvals = new double[info.eam_nr]; |
406 |
+ |
eam_rhovals = new double[info.eam_nr]; |
407 |
+ |
eam_Frhovals = new double[info.eam_nrho]; |
408 |
|
|
409 |
+ |
// We have to now broadcast the Arrays |
410 |
+ |
MPI_Bcast(eam_rvals, |
411 |
+ |
info.eam_nr, |
412 |
+ |
MPI_DOUBLE,0,MPI_COMM_WORLD); |
413 |
+ |
MPI_Bcast(eam_rhovals, |
414 |
+ |
info.eam_nr, |
415 |
+ |
MPI_DOUBLE,0,MPI_COMM_WORLD); |
416 |
+ |
MPI_Bcast(eam_Frhovals, |
417 |
+ |
info.eam_nrho, |
418 |
+ |
MPI_DOUBLE,0,MPI_COMM_WORLD); |
419 |
+ |
|
420 |
|
|
421 |
< |
headAtomType->add( info ); |
421 |
> |
headAtomType->add( info, eam_rvals, eam_rhovals, eam_Frhovals ); |
422 |
|
|
423 |
|
MPIcheckPoint(); |
424 |
|
|
425 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
426 |
+ |
|
427 |
+ |
|
428 |
|
} |
429 |
|
} |
430 |
|
#endif // is_mpi |
434 |
|
int isError; |
435 |
|
|
436 |
|
// dummy variables |
437 |
< |
int isLJ = 1; |
437 |
> |
int isLJ = 0; |
438 |
|
int isDipole = 0; |
439 |
|
int isSSD = 0; |
440 |
|
int isGB = 0; |
441 |
+ |
int isEAM= 1; |
442 |
|
double dipole = 0.0; |
443 |
+ |
double eamSigma = 0.0; |
444 |
+ |
double eamEpslon = 0.0; |
445 |
|
|
446 |
< |
currentAtomType = headAtomType; |
446 |
> |
currentAtomType = headAtomType->next; |
447 |
|
while( currentAtomType != NULL ){ |
448 |
|
|
449 |
|
if( currentAtomType->name[0] != '\0' ){ |
453 |
|
&isSSD, |
454 |
|
&isDipole, |
455 |
|
&isGB, |
456 |
< |
&(currentAtomType->epslon), |
457 |
< |
&(currentAtomType->sigma), |
456 |
> |
&isEAM, |
457 |
> |
&eamEpslon, |
458 |
> |
&eamSigma, |
459 |
|
&dipole, |
460 |
|
&isError ); |
461 |
|
if( isError ){ |
469 |
|
currentAtomType = currentAtomType->next; |
470 |
|
} |
471 |
|
|
472 |
< |
entry_plug->useLJ = 1; |
472 |
> |
entry_plug->useLJ = 0; |
473 |
|
|
474 |
+ |
// Walk down again and send out EAM type |
475 |
+ |
currentAtomType = headAtomType->next; |
476 |
+ |
while( currentAtomType != NULL ){ |
477 |
+ |
|
478 |
+ |
if( currentAtomType->name[0] != '\0' ){ |
479 |
+ |
isError = 0; |
480 |
+ |
newEAMtype( &(currentAtomType->lattice_constant), |
481 |
+ |
&(currentAtomType->eam_nrho), |
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, |
489 |
+ |
&(currentAtomType->eam_ident), |
490 |
+ |
&isError); |
491 |
+ |
if( isError ){ |
492 |
+ |
sprintf( painCave.errMsg, |
493 |
+ |
"Error initializing the \"%s\" atom type in fortran EAM\n", |
494 |
+ |
currentAtomType->name ); |
495 |
+ |
painCave.isFatal = 1; |
496 |
+ |
simError(); |
497 |
+ |
} |
498 |
+ |
} |
499 |
+ |
currentAtomType = currentAtomType->next; |
500 |
+ |
} |
501 |
+ |
|
502 |
+ |
|
503 |
+ |
|
504 |
|
#ifdef IS_MPI |
505 |
|
sprintf( checkPointMsg, |
506 |
< |
"LJ_FF atom structures successfully sent to fortran\n" ); |
506 |
> |
"EAM_FF atom structures successfully sent to fortran\n" ); |
507 |
|
MPIcheckPoint(); |
508 |
|
#endif // is_mpi |
509 |
|
|
531 |
|
} |
532 |
|
|
533 |
|
the_atoms[i]->setMass( currentAtomType->mass ); |
419 |
– |
the_atoms[i]->setEpslon( currentAtomType->epslon ); |
420 |
– |
the_atoms[i]->setSigma( currentAtomType->sigma ); |
534 |
|
the_atoms[i]->setIdent( currentAtomType->ident ); |
535 |
< |
the_atoms[i]->setLJ(); |
535 |
> |
the_atoms[i]->setEAM(); |
536 |
|
|
424 |
– |
if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma; |
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 ){ |
626 |
|
|
627 |
|
|
628 |
|
|
629 |
< |
int EAM_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){ |
629 |
> |
int EAM_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile ){ |
630 |
|
|
631 |
|
char* the_token; |
632 |
|
|
651 |
|
simError(); |
652 |
|
} |
653 |
|
|
654 |
< |
info.epslon = atof( the_token ); |
655 |
< |
|
656 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
657 |
< |
sprintf( painCave.errMsg, |
658 |
< |
"Error parseing AtomTypes: line %d\n", lineNum ); |
654 |
> |
strcpy( eamPotFile, the_token ); |
655 |
> |
return 1; |
656 |
> |
} |
657 |
> |
else return 0; |
658 |
> |
} |
659 |
> |
|
660 |
> |
int EAM_NS::parseEAM(atomStruct &info, char *eamPotFile, |
661 |
> |
double **eam_rvals, |
662 |
> |
double **eam_rhovals, |
663 |
> |
double **eam_Frhovals){ |
664 |
> |
|
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 |
> |
|
679 |
> |
linenumber = 0; |
680 |
> |
|
681 |
> |
// Open eam file |
682 |
> |
eamFile = fopen( eamPotFile, "r" ); |
683 |
> |
|
684 |
> |
|
685 |
> |
if( eamFile == NULL ){ |
686 |
> |
|
687 |
> |
// next see if the force path enviorment variable is set |
688 |
> |
|
689 |
> |
ffPath = getenv( ffPath_env ); |
690 |
> |
if( ffPath == NULL ) { |
691 |
> |
STR_DEFINE(ffPath, FRC_PATH ); |
692 |
> |
} |
693 |
> |
|
694 |
> |
|
695 |
> |
strcpy( temp, ffPath ); |
696 |
> |
strcat( temp, "/" ); |
697 |
> |
strcat( temp, eamPotFile ); |
698 |
> |
strcpy( eamPotFile, temp ); |
699 |
> |
|
700 |
> |
eamFile = fopen( eamPotFile, "r" ); |
701 |
> |
|
702 |
> |
|
703 |
> |
|
704 |
> |
if( eamFile == NULL ){ |
705 |
> |
|
706 |
> |
sprintf( painCave.errMsg, |
707 |
> |
"Error opening the EAM force parameter file: %s\n" |
708 |
> |
"Have you tried setting the FORCE_PARAM_PATH environment " |
709 |
> |
"vairable?\n", |
710 |
> |
eamPotFile ); |
711 |
|
painCave.isFatal = 1; |
712 |
|
simError(); |
713 |
|
} |
714 |
< |
|
715 |
< |
info.sigma = atof( the_token ); |
714 |
> |
} |
715 |
> |
|
716 |
> |
// First line is a comment line, read and toss it.... |
717 |
> |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
718 |
> |
linenumber++; |
719 |
> |
if(eam_eof_test == NULL){ |
720 |
> |
sprintf( painCave.errMsg, |
721 |
> |
"error in reading commment in %s\n", eamPotFile); |
722 |
> |
painCave.isFatal = 1; |
723 |
> |
simError(); |
724 |
> |
} |
725 |
> |
|
726 |
> |
|
727 |
> |
|
728 |
> |
// The Second line contains atomic number, atomic mass and a lattice constant |
729 |
> |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
730 |
> |
linenumber++; |
731 |
> |
if(eam_eof_test == NULL){ |
732 |
> |
sprintf( painCave.errMsg, |
733 |
> |
"error in reading Identifier line in %s\n", eamPotFile); |
734 |
> |
painCave.isFatal = 1; |
735 |
> |
simError(); |
736 |
> |
} |
737 |
> |
|
738 |
> |
|
739 |
> |
|
740 |
|
|
741 |
< |
return 1; |
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; |
745 |
> |
simError(); |
746 |
> |
} |
747 |
> |
|
748 |
> |
info.eam_ident = atoi( the_token ); |
749 |
> |
|
750 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
751 |
> |
sprintf( painCave.errMsg, |
752 |
> |
"Error parseing EAM mass in %s\n", eamPotFile ); |
753 |
> |
painCave.isFatal = 1; |
754 |
> |
simError(); |
755 |
|
} |
756 |
< |
else return 0; |
756 |
> |
info.mass = atof( the_token); |
757 |
> |
|
758 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
759 |
> |
sprintf( painCave.errMsg, |
760 |
> |
"Error parseing EAM Lattice Constant %s\n", eamPotFile ); |
761 |
> |
painCave.isFatal = 1; |
762 |
> |
simError(); |
763 |
> |
} |
764 |
> |
info.lattice_constant = atof( the_token); |
765 |
> |
|
766 |
> |
// Next line is nrho, drho, nr, dr and rcut |
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( eam_read_buffer, " \n\t,;")) == NULL){ |
776 |
> |
sprintf( painCave.errMsg, |
777 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
778 |
> |
painCave.isFatal = 1; |
779 |
> |
simError(); |
780 |
> |
} |
781 |
> |
|
782 |
> |
info.eam_nrho = atoi( the_token ); |
783 |
> |
|
784 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
785 |
> |
sprintf( painCave.errMsg, |
786 |
> |
"Error parseing EAM drho in %s\n", eamPotFile ); |
787 |
> |
painCave.isFatal = 1; |
788 |
> |
simError(); |
789 |
> |
} |
790 |
> |
info.eam_drho = atof( the_token); |
791 |
> |
|
792 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
793 |
> |
sprintf( painCave.errMsg, |
794 |
> |
"Error parseing EAM # r in %s\n", eamPotFile ); |
795 |
> |
painCave.isFatal = 1; |
796 |
> |
simError(); |
797 |
> |
} |
798 |
> |
info.eam_nr = atoi( the_token); |
799 |
> |
|
800 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
801 |
> |
sprintf( painCave.errMsg, |
802 |
> |
"Error parseing EAM dr in %s\n", eamPotFile ); |
803 |
> |
painCave.isFatal = 1; |
804 |
> |
simError(); |
805 |
> |
} |
806 |
> |
info.eam_dr = atof( the_token); |
807 |
> |
|
808 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
809 |
> |
sprintf( painCave.errMsg, |
810 |
> |
"Error parseing EAM rcut in %s\n", eamPotFile ); |
811 |
> |
painCave.isFatal = 1; |
812 |
> |
simError(); |
813 |
> |
} |
814 |
> |
info.eam_rcut = atof( the_token); |
815 |
> |
|
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.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.eam_nrho/5); |
827 |
> |
|
828 |
> |
for (i=0;i<nReadLines;i++){ |
829 |
> |
j = i*5; |
830 |
> |
|
831 |
> |
// Read next line |
832 |
> |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
833 |
> |
linenumber++; |
834 |
> |
if(eam_eof_test == NULL){ |
835 |
> |
sprintf( painCave.errMsg, |
836 |
> |
"error in reading EAM file %s at line %d\n", |
837 |
> |
eamPotFile,linenumber); |
838 |
> |
painCave.isFatal = 1; |
839 |
> |
simError(); |
840 |
> |
} |
841 |
> |
|
842 |
> |
// Parse 5 values on each line into array |
843 |
> |
// Value 1 |
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; |
848 |
> |
simError(); |
849 |
> |
} |
850 |
> |
|
851 |
> |
*eam_Frhovals[j+0] = atof( the_token ); |
852 |
> |
|
853 |
> |
// Value 2 |
854 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
855 |
> |
sprintf( painCave.errMsg, |
856 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
857 |
> |
painCave.isFatal = 1; |
858 |
> |
simError(); |
859 |
> |
} |
860 |
> |
|
861 |
> |
*eam_Frhovals[j+1] = atof( the_token ); |
862 |
> |
|
863 |
> |
// Value 3 |
864 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
865 |
> |
sprintf( painCave.errMsg, |
866 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
867 |
> |
painCave.isFatal = 1; |
868 |
> |
simError(); |
869 |
> |
} |
870 |
> |
|
871 |
> |
*eam_Frhovals[j+2] = atof( the_token ); |
872 |
> |
|
873 |
> |
// Value 4 |
874 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
875 |
> |
sprintf( painCave.errMsg, |
876 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
877 |
> |
painCave.isFatal = 1; |
878 |
> |
simError(); |
879 |
> |
} |
880 |
> |
|
881 |
> |
*eam_Frhovals[j+3] = atof( the_token ); |
882 |
> |
|
883 |
> |
// Value 5 |
884 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
885 |
> |
sprintf( painCave.errMsg, |
886 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
887 |
> |
painCave.isFatal = 1; |
888 |
> |
simError(); |
889 |
> |
} |
890 |
> |
|
891 |
> |
*eam_Frhovals[j+4] = atof( the_token ); |
892 |
> |
|
893 |
> |
} |
894 |
> |
// Parse Z of r vals |
895 |
> |
|
896 |
> |
// Assume for now that we have a complete number of lines |
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 |
> |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
904 |
> |
linenumber++; |
905 |
> |
if(eam_eof_test == NULL){ |
906 |
> |
sprintf( painCave.errMsg, |
907 |
> |
"error in reading EAM file %s at line %d\n", |
908 |
> |
eamPotFile,linenumber); |
909 |
> |
painCave.isFatal = 1; |
910 |
> |
simError(); |
911 |
> |
} |
912 |
> |
|
913 |
> |
// Parse 5 values on each line into array |
914 |
> |
// Value 1 |
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; |
919 |
> |
simError(); |
920 |
> |
} |
921 |
> |
|
922 |
> |
*eam_rvals[j+0] = atof( the_token ); |
923 |
> |
|
924 |
> |
// Value 2 |
925 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
926 |
> |
sprintf( painCave.errMsg, |
927 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
928 |
> |
painCave.isFatal = 1; |
929 |
> |
simError(); |
930 |
> |
} |
931 |
> |
|
932 |
> |
*eam_rvals[j+1] = atof( the_token ); |
933 |
> |
|
934 |
> |
// Value 3 |
935 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
936 |
> |
sprintf( painCave.errMsg, |
937 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
938 |
> |
painCave.isFatal = 1; |
939 |
> |
simError(); |
940 |
> |
} |
941 |
> |
|
942 |
> |
*eam_rvals[j+2] = atof( the_token ); |
943 |
> |
|
944 |
> |
// Value 4 |
945 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
946 |
> |
sprintf( painCave.errMsg, |
947 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
948 |
> |
painCave.isFatal = 1; |
949 |
> |
simError(); |
950 |
> |
} |
951 |
> |
|
952 |
> |
*eam_rvals[j+3] = atof( the_token ); |
953 |
> |
|
954 |
> |
// Value 5 |
955 |
> |
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
956 |
> |
sprintf( painCave.errMsg, |
957 |
> |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
958 |
> |
painCave.isFatal = 1; |
959 |
> |
simError(); |
960 |
> |
} |
961 |
> |
|
962 |
> |
*eam_rvals[j+4] = atof( the_token ); |
963 |
> |
|
964 |
> |
} |
965 |
> |
// Parse rho of r vals |
966 |
> |
|
967 |
> |
// Assume for now that we have a complete number of lines |
968 |
> |
|
969 |
> |
for (i=0;i<nReadLines;i++){ |
970 |
> |
j = i*5; |
971 |
> |
|
972 |
> |
// Read next line |
973 |
> |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
974 |
> |
linenumber++; |
975 |
> |
if(eam_eof_test == NULL){ |
976 |
> |
sprintf( painCave.errMsg, |
977 |
> |
"error in reading EAM file %s at line %d\n", |
978 |
> |
eamPotFile,linenumber); |
979 |
> |
painCave.isFatal = 1; |
980 |
> |
simError(); |
981 |
> |
} |
982 |
> |
|
983 |
> |
// Parse 5 values on each line into array |
984 |
> |
// Value 1 |
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; |
989 |
> |
simError(); |
990 |
> |
} |
991 |
> |
|
992 |
> |
*eam_rhovals[j+0] = atof( the_token ); |
993 |
> |
|
994 |
> |
// Value 2 |
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; |
999 |
> |
simError(); |
1000 |
> |
} |
1001 |
> |
|
1002 |
> |
*eam_rhovals[j+1] = atof( the_token ); |
1003 |
> |
|
1004 |
> |
// Value 3 |
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; |
1009 |
> |
simError(); |
1010 |
> |
} |
1011 |
> |
|
1012 |
> |
*eam_rhovals[j+2] = atof( the_token ); |
1013 |
> |
|
1014 |
> |
// Value 4 |
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; |
1019 |
> |
simError(); |
1020 |
> |
} |
1021 |
> |
|
1022 |
> |
*eam_rhovals[j+3] = atof( the_token ); |
1023 |
> |
|
1024 |
> |
// Value 5 |
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; |
1029 |
> |
simError(); |
1030 |
> |
} |
1031 |
> |
|
1032 |
> |
*eam_rhovals[j+4] = atof( the_token ); |
1033 |
> |
|
1034 |
> |
} |
1035 |
> |
|
1036 |
> |
fclose(eamFile); |
1037 |
> |
return 0; |
1038 |
|
} |