1 |
chuckv |
499 |
#include <cstdlib> |
2 |
|
|
#include <cstdio> |
3 |
|
|
#include <cstring> |
4 |
|
|
|
5 |
|
|
#include <iostream> |
6 |
|
|
using namespace std; |
7 |
|
|
|
8 |
|
|
#ifdef IS_MPI |
9 |
|
|
#include <mpi.h> |
10 |
|
|
#endif //is_mpi |
11 |
|
|
|
12 |
|
|
#include "ForceFields.hpp" |
13 |
|
|
#include "SRI.hpp" |
14 |
|
|
#include "simError.h" |
15 |
|
|
|
16 |
|
|
#include "fortranWrappers.hpp" |
17 |
|
|
|
18 |
|
|
#ifdef IS_MPI |
19 |
|
|
#include "mpiForceField.h" |
20 |
|
|
#endif // is_mpi |
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
namespace EAM_NS{ |
25 |
|
|
|
26 |
|
|
// Declare the structures that will be passed by the parser and MPI |
27 |
|
|
|
28 |
|
|
typedef struct{ |
29 |
|
|
char name[15]; |
30 |
|
|
double mass; |
31 |
chuckv |
627 |
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 |
chuckv |
631 |
double eam_rcut; // The cutoff radius for eam. |
37 |
chuckv |
627 |
int eam_ident; // Atomic number |
38 |
chuckv |
499 |
int ident; |
39 |
|
|
int last; // 0 -> default |
40 |
|
|
// 1 -> in MPI: tells nodes to stop listening |
41 |
|
|
} atomStruct; |
42 |
|
|
|
43 |
chuckv |
627 |
int parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile ); |
44 |
chuckv |
631 |
int parseEAM( atomStruct &info, char *eamPotFile, double **eam_rvals, |
45 |
|
|
double **eam_rhovals, double **eam_Frhovals); |
46 |
chuckv |
499 |
#ifdef IS_MPI |
47 |
|
|
|
48 |
|
|
MPI_Datatype mpiAtomStructType; |
49 |
|
|
|
50 |
|
|
#endif |
51 |
|
|
|
52 |
|
|
class LinkedAtomType { |
53 |
|
|
public: |
54 |
|
|
LinkedAtomType(){ |
55 |
|
|
next = NULL; |
56 |
|
|
name[0] = '\0'; |
57 |
chuckv |
627 |
eam_rvals = NULL; |
58 |
|
|
eam_rhovals = NULL; |
59 |
|
|
eam_Frhovals = NULL; |
60 |
chuckv |
499 |
} |
61 |
|
|
|
62 |
chuckv |
627 |
~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 |
chuckv |
499 |
LinkedAtomType* find(char* key){ |
70 |
|
|
if( !strcmp(name, key) ) return this; |
71 |
|
|
if( next != NULL ) return next->find(key); |
72 |
|
|
return NULL; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
|
76 |
chuckv |
627 |
void add( atomStruct &info, double *the_eam_rvals, |
77 |
|
|
double *the_eam_rhovals,double *the_eam_Frhovals ){ |
78 |
|
|
|
79 |
|
|
int i; |
80 |
|
|
|
81 |
chuckv |
499 |
// check for duplicates |
82 |
|
|
|
83 |
|
|
if( !strcmp( info.name, name ) ){ |
84 |
|
|
sprintf( painCave.errMsg, |
85 |
|
|
"Duplicate LJ atom type \"%s\" found in " |
86 |
|
|
"the LJ_FF param file./n", |
87 |
|
|
name ); |
88 |
|
|
painCave.isFatal = 1; |
89 |
|
|
simError(); |
90 |
|
|
} |
91 |
|
|
|
92 |
chuckv |
627 |
if( next != NULL ) next->add(info, the_eam_rvals, the_eam_rhovals, the_eam_Frhovals); |
93 |
chuckv |
499 |
else{ |
94 |
|
|
next = new LinkedAtomType(); |
95 |
|
|
strcpy(next->name, info.name); |
96 |
chuckv |
627 |
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 |
chuckv |
499 |
} |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
|
113 |
|
|
#ifdef IS_MPI |
114 |
|
|
|
115 |
|
|
void duplicate( atomStruct &info ){ |
116 |
|
|
strcpy(info.name, name); |
117 |
chuckv |
627 |
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 |
chuckv |
499 |
} |
128 |
|
|
|
129 |
|
|
|
130 |
|
|
#endif |
131 |
|
|
|
132 |
|
|
char name[15]; |
133 |
|
|
double mass; |
134 |
chuckv |
627 |
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 |
chuckv |
631 |
double eam_rcut; // The cutoff radius for eam. |
140 |
chuckv |
627 |
|
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 |
chuckv |
499 |
int ident; |
146 |
|
|
LinkedAtomType* next; |
147 |
|
|
}; |
148 |
|
|
|
149 |
|
|
LinkedAtomType* headAtomType; |
150 |
|
|
LinkedAtomType* currentAtomType; |
151 |
|
|
|
152 |
|
|
} |
153 |
|
|
|
154 |
chuckv |
631 |
using namespace EAM_NS; |
155 |
chuckv |
499 |
|
156 |
|
|
//**************************************************************** |
157 |
|
|
// begins the actual forcefield stuff. |
158 |
|
|
//**************************************************************** |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
EAM_FF::EAM_FF(){ |
162 |
|
|
|
163 |
|
|
char fileName[200]; |
164 |
|
|
char* ffPath_env = "FORCE_PARAM_PATH"; |
165 |
|
|
char* ffPath; |
166 |
|
|
char temp[200]; |
167 |
|
|
char errMsg[1000]; |
168 |
|
|
|
169 |
|
|
headAtomType = NULL; |
170 |
|
|
currentAtomType = NULL; |
171 |
|
|
|
172 |
|
|
// do the funtion wrapping |
173 |
|
|
wrapMeFF( this ); |
174 |
|
|
|
175 |
|
|
#ifdef IS_MPI |
176 |
|
|
int i; |
177 |
|
|
|
178 |
|
|
// ********************************************************************** |
179 |
|
|
// Init the atomStruct mpi type |
180 |
|
|
|
181 |
|
|
atomStruct atomProto; // mpiPrototype |
182 |
chuckv |
627 |
int atomBC[3] = {15,4,6}; // block counts |
183 |
chuckv |
499 |
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 |
chuckv |
627 |
MPI_Address(&atomProto.eam_nrho, &atomDspls[2]); |
189 |
chuckv |
499 |
|
190 |
|
|
atomMbrTypes[0] = MPI_CHAR; |
191 |
|
|
atomMbrTypes[1] = MPI_DOUBLE; |
192 |
|
|
atomMbrTypes[2] = MPI_INT; |
193 |
|
|
|
194 |
|
|
for (i=2; i >= 0; i--) atomDspls[i] -= atomDspls[0]; |
195 |
|
|
|
196 |
|
|
MPI_Type_struct(3, atomBC, atomDspls, atomMbrTypes, &mpiAtomStructType); |
197 |
|
|
MPI_Type_commit(&mpiAtomStructType); |
198 |
|
|
|
199 |
|
|
// *********************************************************************** |
200 |
|
|
|
201 |
|
|
if( worldRank == 0 ){ |
202 |
|
|
#endif |
203 |
|
|
|
204 |
|
|
// generate the force file name |
205 |
|
|
|
206 |
|
|
strcpy( fileName, "EAM_FF.frc" ); |
207 |
|
|
// fprintf( stderr,"Trying to open %s\n", fileName ); |
208 |
|
|
|
209 |
|
|
// attempt to open the file in the current directory first. |
210 |
|
|
|
211 |
|
|
frcFile = fopen( fileName, "r" ); |
212 |
|
|
|
213 |
|
|
if( frcFile == NULL ){ |
214 |
|
|
|
215 |
|
|
// next see if the force path enviorment variable is set |
216 |
|
|
|
217 |
|
|
ffPath = getenv( ffPath_env ); |
218 |
|
|
if( ffPath == NULL ) { |
219 |
|
|
STR_DEFINE(ffPath, FRC_PATH ); |
220 |
|
|
} |
221 |
|
|
|
222 |
|
|
|
223 |
|
|
strcpy( temp, ffPath ); |
224 |
|
|
strcat( temp, "/" ); |
225 |
|
|
strcat( temp, fileName ); |
226 |
|
|
strcpy( fileName, temp ); |
227 |
|
|
|
228 |
|
|
frcFile = fopen( fileName, "r" ); |
229 |
|
|
|
230 |
|
|
if( frcFile == NULL ){ |
231 |
|
|
|
232 |
|
|
sprintf( painCave.errMsg, |
233 |
|
|
"Error opening the force field parameter file: %s\n" |
234 |
|
|
"Have you tried setting the FORCE_PARAM_PATH environment " |
235 |
|
|
"vairable?\n", |
236 |
|
|
fileName ); |
237 |
|
|
painCave.isFatal = 1; |
238 |
|
|
simError(); |
239 |
|
|
} |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
#ifdef IS_MPI |
243 |
|
|
} |
244 |
|
|
|
245 |
chuckv |
627 |
sprintf( checkPointMsg, "EAM_FF file opened sucessfully." ); |
246 |
chuckv |
499 |
MPIcheckPoint(); |
247 |
|
|
|
248 |
|
|
#endif // is_mpi |
249 |
|
|
} |
250 |
|
|
|
251 |
|
|
|
252 |
|
|
EAM_FF::~EAM_FF(){ |
253 |
|
|
|
254 |
|
|
if( headAtomType != NULL ) delete headAtomType; |
255 |
|
|
|
256 |
|
|
#ifdef IS_MPI |
257 |
|
|
if( worldRank == 0 ){ |
258 |
|
|
#endif // is_mpi |
259 |
|
|
|
260 |
|
|
fclose( frcFile ); |
261 |
|
|
|
262 |
|
|
#ifdef IS_MPI |
263 |
|
|
} |
264 |
|
|
#endif // is_mpi |
265 |
|
|
} |
266 |
|
|
|
267 |
|
|
void EAM_FF::initForceField( int ljMixRule ){ |
268 |
|
|
|
269 |
|
|
initFortran( ljMixRule, 0 ); |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
void EAM_FF::cleanMe( void ){ |
273 |
|
|
|
274 |
|
|
#ifdef IS_MPI |
275 |
|
|
|
276 |
|
|
// keep the linked list in the mpi version |
277 |
|
|
|
278 |
|
|
#else // is_mpi |
279 |
|
|
|
280 |
|
|
// delete the linked list in the single processor version |
281 |
|
|
|
282 |
|
|
if( headAtomType != NULL ) delete headAtomType; |
283 |
|
|
|
284 |
|
|
#endif // is_mpi |
285 |
|
|
} |
286 |
|
|
|
287 |
|
|
void EAM_FF::readParams( void ){ |
288 |
|
|
|
289 |
|
|
atomStruct info; |
290 |
|
|
info.last = 1; // initialize last to have the last set. |
291 |
|
|
// if things go well, last will be set to 0 |
292 |
|
|
|
293 |
|
|
int i; |
294 |
|
|
int identNum; |
295 |
chuckv |
627 |
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 |
chuckv |
499 |
|
300 |
|
|
|
301 |
|
|
bigSigma = 0.0; |
302 |
|
|
#ifdef IS_MPI |
303 |
|
|
if( worldRank == 0 ){ |
304 |
|
|
#endif |
305 |
|
|
|
306 |
|
|
// read in the atom types. |
307 |
|
|
|
308 |
|
|
headAtomType = new LinkedAtomType; |
309 |
|
|
|
310 |
chuckv |
627 |
fastForward( "AtomTypes", "eam atom readParams" ); |
311 |
chuckv |
499 |
|
312 |
|
|
// we are now at the AtomTypes section. |
313 |
|
|
|
314 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
315 |
|
|
lineNum++; |
316 |
|
|
|
317 |
|
|
|
318 |
|
|
// read a line, and start parseing out the atom types |
319 |
|
|
|
320 |
|
|
if( eof_test == NULL ){ |
321 |
|
|
sprintf( painCave.errMsg, |
322 |
|
|
"Error in reading Atoms from force file at line %d.\n", |
323 |
|
|
lineNum ); |
324 |
|
|
painCave.isFatal = 1; |
325 |
|
|
simError(); |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
identNum = 1; |
329 |
|
|
// stop reading at end of file, or at next section |
330 |
chuckv |
627 |
|
331 |
chuckv |
499 |
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 |
chuckv |
627 |
if( parseAtom( readLine, lineNum, info, eamPotFile ) ){ |
338 |
|
|
parseEAM(info,eamPotFile, &eam_rvals, |
339 |
chuckv |
631 |
&eam_rhovals, &eam_Frhovals); |
340 |
chuckv |
499 |
info.ident = identNum; |
341 |
chuckv |
627 |
headAtomType->add( info, eam_rvals, |
342 |
|
|
eam_rhovals,eam_Frhovals ); |
343 |
chuckv |
499 |
identNum++; |
344 |
|
|
} |
345 |
|
|
} |
346 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
347 |
|
|
lineNum++; |
348 |
|
|
} |
349 |
chuckv |
627 |
|
350 |
|
|
|
351 |
chuckv |
499 |
|
352 |
|
|
#ifdef IS_MPI |
353 |
chuckv |
627 |
|
354 |
chuckv |
499 |
|
355 |
|
|
// send out the linked list to all the other processes |
356 |
|
|
|
357 |
|
|
sprintf( checkPointMsg, |
358 |
chuckv |
627 |
"EAM_FF atom structures read successfully." ); |
359 |
chuckv |
499 |
MPIcheckPoint(); |
360 |
|
|
|
361 |
|
|
currentAtomType = headAtomType->next; //skip the first element who is a place holder. |
362 |
|
|
while( currentAtomType != NULL ){ |
363 |
|
|
currentAtomType->duplicate( info ); |
364 |
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
sendFrcStruct( &info, mpiAtomStructType ); |
368 |
|
|
|
369 |
chuckv |
627 |
// 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 |
chuckv |
499 |
sprintf( checkPointMsg, |
381 |
chuckv |
627 |
"successfully sent EAM force type: \"%s\"\n", |
382 |
chuckv |
499 |
info.name ); |
383 |
|
|
MPIcheckPoint(); |
384 |
|
|
|
385 |
|
|
currentAtomType = currentAtomType->next; |
386 |
|
|
} |
387 |
|
|
info.last = 1; |
388 |
|
|
sendFrcStruct( &info, mpiAtomStructType ); |
389 |
|
|
|
390 |
|
|
} |
391 |
|
|
|
392 |
|
|
else{ |
393 |
|
|
|
394 |
|
|
// listen for node 0 to send out the force params |
395 |
|
|
|
396 |
|
|
MPIcheckPoint(); |
397 |
|
|
|
398 |
|
|
headAtomType = new LinkedAtomType; |
399 |
|
|
recieveFrcStruct( &info, mpiAtomStructType ); |
400 |
chuckv |
627 |
|
401 |
chuckv |
499 |
while( !info.last ){ |
402 |
chuckv |
627 |
|
403 |
|
|
// allocate the arrays |
404 |
chuckv |
499 |
|
405 |
chuckv |
627 |
eam_rvals = new double[info.eam_nr]; |
406 |
|
|
eam_rhovals = new double[info.eam_nr]; |
407 |
|
|
eam_Frhovals = new double[info.eam_nrho]; |
408 |
chuckv |
499 |
|
409 |
chuckv |
627 |
// 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 |
chuckv |
499 |
|
421 |
chuckv |
627 |
headAtomType->add( info, eam_rvals, eam_rhovals, eam_Frhovals ); |
422 |
chuckv |
499 |
|
423 |
|
|
MPIcheckPoint(); |
424 |
|
|
|
425 |
|
|
recieveFrcStruct( &info, mpiAtomStructType ); |
426 |
chuckv |
627 |
|
427 |
|
|
|
428 |
chuckv |
499 |
} |
429 |
|
|
} |
430 |
|
|
#endif // is_mpi |
431 |
|
|
|
432 |
|
|
// call new A_types in fortran |
433 |
|
|
|
434 |
|
|
int isError; |
435 |
|
|
|
436 |
|
|
// dummy variables |
437 |
chuckv |
627 |
int isLJ = 0; |
438 |
chuckv |
499 |
int isDipole = 0; |
439 |
|
|
int isSSD = 0; |
440 |
|
|
int isGB = 0; |
441 |
chuckv |
631 |
int isEAM= 1; |
442 |
chuckv |
499 |
double dipole = 0.0; |
443 |
chuckv |
631 |
double eamSigma = 0.0; |
444 |
|
|
double eamEpslon = 0.0; |
445 |
chuckv |
499 |
|
446 |
chuckv |
627 |
currentAtomType = headAtomType->next; |
447 |
chuckv |
499 |
while( currentAtomType != NULL ){ |
448 |
|
|
|
449 |
|
|
if( currentAtomType->name[0] != '\0' ){ |
450 |
|
|
isError = 0; |
451 |
|
|
makeAtype( &(currentAtomType->ident), |
452 |
|
|
&isLJ, |
453 |
|
|
&isSSD, |
454 |
|
|
&isDipole, |
455 |
|
|
&isGB, |
456 |
chuckv |
627 |
&isEAM, |
457 |
chuckv |
631 |
&eamEpslon, |
458 |
|
|
&eamSigma, |
459 |
chuckv |
499 |
&dipole, |
460 |
|
|
&isError ); |
461 |
|
|
if( isError ){ |
462 |
|
|
sprintf( painCave.errMsg, |
463 |
|
|
"Error initializing the \"%s\" atom type in fortran\n", |
464 |
|
|
currentAtomType->name ); |
465 |
|
|
painCave.isFatal = 1; |
466 |
|
|
simError(); |
467 |
|
|
} |
468 |
|
|
} |
469 |
|
|
currentAtomType = currentAtomType->next; |
470 |
|
|
} |
471 |
|
|
|
472 |
chuckv |
627 |
entry_plug->useLJ = 0; |
473 |
chuckv |
499 |
|
474 |
chuckv |
627 |
// 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 |
chuckv |
631 |
&(currentAtomType->eam_rcut), |
486 |
chuckv |
627 |
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 |
chuckv |
499 |
#ifdef IS_MPI |
505 |
|
|
sprintf( checkPointMsg, |
506 |
chuckv |
627 |
"EAM_FF atom structures successfully sent to fortran\n" ); |
507 |
chuckv |
499 |
MPIcheckPoint(); |
508 |
|
|
#endif // is_mpi |
509 |
|
|
|
510 |
|
|
} |
511 |
|
|
|
512 |
|
|
|
513 |
|
|
void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
514 |
|
|
|
515 |
|
|
int i; |
516 |
|
|
|
517 |
|
|
// initialize the atoms |
518 |
|
|
|
519 |
|
|
|
520 |
|
|
Atom* thisAtom; |
521 |
|
|
|
522 |
|
|
for( i=0; i<nAtoms; i++ ){ |
523 |
|
|
|
524 |
|
|
currentAtomType = headAtomType->find( the_atoms[i]->getType() ); |
525 |
|
|
if( currentAtomType == NULL ){ |
526 |
|
|
sprintf( painCave.errMsg, |
527 |
|
|
"AtomType error, %s not found in force file.\n", |
528 |
|
|
the_atoms[i]->getType() ); |
529 |
|
|
painCave.isFatal = 1; |
530 |
|
|
simError(); |
531 |
|
|
} |
532 |
|
|
|
533 |
|
|
the_atoms[i]->setMass( currentAtomType->mass ); |
534 |
|
|
the_atoms[i]->setIdent( currentAtomType->ident ); |
535 |
chuckv |
627 |
the_atoms[i]->setEAM(); |
536 |
chuckv |
499 |
|
537 |
|
|
} |
538 |
|
|
} |
539 |
|
|
|
540 |
chuckv |
631 |
void EAM_FF::initializeBonds( int nBonds, Bond** BondArray, |
541 |
chuckv |
499 |
bond_pair* the_bonds ){ |
542 |
|
|
|
543 |
|
|
if( nBonds ){ |
544 |
|
|
sprintf( painCave.errMsg, |
545 |
|
|
"LJ_FF does not support bonds.\n" ); |
546 |
|
|
painCave.isFatal = 1; |
547 |
|
|
simError(); |
548 |
|
|
} |
549 |
|
|
} |
550 |
|
|
|
551 |
|
|
void EAM_FF::initializeBends( int nBends, Bend** bendArray, |
552 |
|
|
bend_set* the_bends ){ |
553 |
|
|
|
554 |
|
|
if( nBends ){ |
555 |
|
|
sprintf( painCave.errMsg, |
556 |
|
|
"LJ_FF does not support bends.\n" ); |
557 |
|
|
painCave.isFatal = 1; |
558 |
|
|
simError(); |
559 |
|
|
} |
560 |
|
|
} |
561 |
|
|
|
562 |
|
|
void EAM_FF::initializeTorsions( int nTorsions, Torsion** torsionArray, |
563 |
|
|
torsion_set* the_torsions ){ |
564 |
|
|
|
565 |
|
|
if( nTorsions ){ |
566 |
|
|
sprintf( painCave.errMsg, |
567 |
|
|
"LJ_FF does not support torsions.\n" ); |
568 |
|
|
painCave.isFatal = 1; |
569 |
|
|
simError(); |
570 |
|
|
} |
571 |
|
|
} |
572 |
|
|
|
573 |
|
|
void EAM_FF::fastForward( char* stopText, char* searchOwner ){ |
574 |
|
|
|
575 |
|
|
int foundText = 0; |
576 |
|
|
char* the_token; |
577 |
|
|
|
578 |
|
|
rewind( frcFile ); |
579 |
|
|
lineNum = 0; |
580 |
|
|
|
581 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
582 |
|
|
lineNum++; |
583 |
|
|
if( eof_test == NULL ){ |
584 |
|
|
sprintf( painCave.errMsg, "Error fast forwarding force file for %s: " |
585 |
|
|
" file is empty.\n", |
586 |
|
|
searchOwner ); |
587 |
|
|
painCave.isFatal = 1; |
588 |
|
|
simError(); |
589 |
|
|
} |
590 |
|
|
|
591 |
|
|
|
592 |
|
|
while( !foundText ){ |
593 |
|
|
while( eof_test != NULL && readLine[0] != '#' ){ |
594 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
595 |
|
|
lineNum++; |
596 |
|
|
} |
597 |
|
|
if( eof_test == NULL ){ |
598 |
|
|
sprintf( painCave.errMsg, |
599 |
|
|
"Error fast forwarding force file for %s at " |
600 |
|
|
"line %d: file ended unexpectedly.\n", |
601 |
|
|
searchOwner, |
602 |
|
|
lineNum ); |
603 |
|
|
painCave.isFatal = 1; |
604 |
|
|
simError(); |
605 |
|
|
} |
606 |
|
|
|
607 |
|
|
the_token = strtok( readLine, " ,;\t#\n" ); |
608 |
|
|
foundText = !strcmp( stopText, the_token ); |
609 |
|
|
|
610 |
|
|
if( !foundText ){ |
611 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
612 |
|
|
lineNum++; |
613 |
|
|
|
614 |
|
|
if( eof_test == NULL ){ |
615 |
|
|
sprintf( painCave.errMsg, |
616 |
|
|
"Error fast forwarding force file for %s at " |
617 |
|
|
"line %d: file ended unexpectedly.\n", |
618 |
|
|
searchOwner, |
619 |
|
|
lineNum ); |
620 |
|
|
painCave.isFatal = 1; |
621 |
|
|
simError(); |
622 |
|
|
} |
623 |
|
|
} |
624 |
|
|
} |
625 |
|
|
} |
626 |
|
|
|
627 |
|
|
|
628 |
|
|
|
629 |
chuckv |
627 |
int EAM_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile ){ |
630 |
chuckv |
499 |
|
631 |
|
|
char* the_token; |
632 |
|
|
|
633 |
|
|
the_token = strtok( lineBuffer, " \n\t,;" ); |
634 |
|
|
if( the_token != NULL ){ |
635 |
|
|
|
636 |
|
|
strcpy( info.name, the_token ); |
637 |
|
|
|
638 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
639 |
|
|
sprintf( painCave.errMsg, |
640 |
|
|
"Error parseing AtomTypes: line %d\n", lineNum ); |
641 |
|
|
painCave.isFatal = 1; |
642 |
|
|
simError(); |
643 |
|
|
} |
644 |
|
|
|
645 |
|
|
info.mass = atof( the_token ); |
646 |
|
|
|
647 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
648 |
|
|
sprintf( painCave.errMsg, |
649 |
|
|
"Error parseing AtomTypes: line %d\n", lineNum ); |
650 |
|
|
painCave.isFatal = 1; |
651 |
|
|
simError(); |
652 |
|
|
} |
653 |
|
|
|
654 |
chuckv |
627 |
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 |
chuckv |
631 |
char* eam_eof_test; |
669 |
chuckv |
627 |
FILE *eamFile; |
670 |
chuckv |
631 |
const int BUFFERSIZE = 2000; |
671 |
|
|
|
672 |
chuckv |
627 |
char temp[200]; |
673 |
|
|
int linenumber; |
674 |
|
|
int nReadLines; |
675 |
chuckv |
631 |
char eam_read_buffer[BUFFERSIZE]; |
676 |
chuckv |
627 |
|
677 |
|
|
int i,j; |
678 |
|
|
|
679 |
|
|
linenumber = 0; |
680 |
|
|
|
681 |
|
|
// Open eam file |
682 |
|
|
eamFile = fopen( eamPotFile, "r" ); |
683 |
|
|
|
684 |
|
|
|
685 |
chuckv |
631 |
if( eamFile == NULL ){ |
686 |
chuckv |
627 |
|
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 |
chuckv |
631 |
if( eamFile == NULL ){ |
705 |
chuckv |
627 |
|
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 |
|
|
|
716 |
|
|
// First line is a comment line, read and toss it.... |
717 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
718 |
chuckv |
627 |
linenumber++; |
719 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
720 |
chuckv |
627 |
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 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
730 |
chuckv |
627 |
linenumber++; |
731 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
732 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
742 |
chuckv |
627 |
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 |
|
|
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 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
768 |
|
|
if(eam_eof_test == NULL){ |
769 |
chuckv |
627 |
sprintf( painCave.errMsg, |
770 |
|
|
"error in reading number of points line in %s\n", eamPotFile); |
771 |
|
|
painCave.isFatal = 1; |
772 |
|
|
simError(); |
773 |
|
|
} |
774 |
|
|
|
775 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
776 |
chuckv |
627 |
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 |
chuckv |
631 |
*eam_Frhovals = new double[info.eam_nrho]; |
820 |
|
|
*eam_rvals = new double[info.eam_nr]; |
821 |
|
|
*eam_rhovals = new double[info.eam_nr]; |
822 |
chuckv |
627 |
|
823 |
|
|
// Parse F of rho vals. |
824 |
|
|
|
825 |
|
|
// Assume for now that we have a complete number of lines |
826 |
chuckv |
631 |
nReadLines = int(info.eam_nrho/5); |
827 |
chuckv |
627 |
|
828 |
|
|
for (i=0;i<nReadLines;i++){ |
829 |
|
|
j = i*5; |
830 |
|
|
|
831 |
|
|
// Read next line |
832 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
833 |
chuckv |
627 |
linenumber++; |
834 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
835 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
845 |
chuckv |
499 |
sprintf( painCave.errMsg, |
846 |
chuckv |
627 |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
847 |
chuckv |
499 |
painCave.isFatal = 1; |
848 |
|
|
simError(); |
849 |
|
|
} |
850 |
|
|
|
851 |
chuckv |
627 |
*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 |
chuckv |
499 |
} |
894 |
chuckv |
627 |
// Parse Z of r vals |
895 |
|
|
|
896 |
|
|
// Assume for now that we have a complete number of lines |
897 |
chuckv |
631 |
nReadLines = int(info.eam_nr/5); |
898 |
chuckv |
627 |
|
899 |
|
|
for (i=0;i<nReadLines;i++){ |
900 |
|
|
j = i*5; |
901 |
|
|
|
902 |
|
|
// Read next line |
903 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
904 |
chuckv |
627 |
linenumber++; |
905 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
906 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
916 |
chuckv |
627 |
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 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
974 |
chuckv |
627 |
linenumber++; |
975 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
976 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
986 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
996 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1006 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1016 |
chuckv |
627 |
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 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1026 |
chuckv |
627 |
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 |
chuckv |
499 |
} |