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