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 |
chuckv |
657 |
|
268 |
|
|
void EAM_FF::calcRcut( void ){ |
269 |
|
|
double tempEamRcut; |
270 |
|
|
|
271 |
|
|
entry_plug->setRcut(eamRcut); |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
|
275 |
chuckv |
499 |
void EAM_FF::initForceField( int ljMixRule ){ |
276 |
|
|
initFortran( ljMixRule, 0 ); |
277 |
|
|
} |
278 |
|
|
|
279 |
|
|
void EAM_FF::cleanMe( void ){ |
280 |
|
|
|
281 |
|
|
#ifdef IS_MPI |
282 |
|
|
|
283 |
|
|
// keep the linked list in the mpi version |
284 |
|
|
|
285 |
|
|
#else // is_mpi |
286 |
|
|
|
287 |
|
|
// delete the linked list in the single processor version |
288 |
|
|
|
289 |
|
|
if( headAtomType != NULL ) delete headAtomType; |
290 |
|
|
|
291 |
|
|
#endif // is_mpi |
292 |
|
|
} |
293 |
|
|
|
294 |
chuckv |
657 |
|
295 |
chuckv |
499 |
void EAM_FF::readParams( void ){ |
296 |
|
|
|
297 |
|
|
atomStruct info; |
298 |
|
|
info.last = 1; // initialize last to have the last set. |
299 |
|
|
// if things go well, last will be set to 0 |
300 |
|
|
|
301 |
|
|
int i; |
302 |
|
|
int identNum; |
303 |
chuckv |
627 |
double *eam_rvals; // Z of r values |
304 |
|
|
double *eam_rhovals; // rho of r values |
305 |
|
|
double *eam_Frhovals; // F of rho values |
306 |
|
|
char eamPotFile[1000]; |
307 |
chuckv |
499 |
|
308 |
|
|
|
309 |
|
|
bigSigma = 0.0; |
310 |
|
|
#ifdef IS_MPI |
311 |
|
|
if( worldRank == 0 ){ |
312 |
|
|
#endif |
313 |
|
|
|
314 |
|
|
// read in the atom types. |
315 |
|
|
|
316 |
|
|
headAtomType = new LinkedAtomType; |
317 |
|
|
|
318 |
chuckv |
627 |
fastForward( "AtomTypes", "eam atom readParams" ); |
319 |
chuckv |
499 |
|
320 |
|
|
// we are now at the AtomTypes section. |
321 |
|
|
|
322 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
323 |
|
|
lineNum++; |
324 |
|
|
|
325 |
|
|
|
326 |
|
|
// read a line, and start parseing out the atom types |
327 |
|
|
|
328 |
|
|
if( eof_test == NULL ){ |
329 |
|
|
sprintf( painCave.errMsg, |
330 |
|
|
"Error in reading Atoms from force file at line %d.\n", |
331 |
|
|
lineNum ); |
332 |
|
|
painCave.isFatal = 1; |
333 |
|
|
simError(); |
334 |
|
|
} |
335 |
|
|
|
336 |
|
|
identNum = 1; |
337 |
|
|
// stop reading at end of file, or at next section |
338 |
chuckv |
627 |
|
339 |
chuckv |
499 |
while( readLine[0] != '#' && eof_test != NULL ){ |
340 |
|
|
|
341 |
|
|
// toss comment lines |
342 |
|
|
if( readLine[0] != '!' ){ |
343 |
|
|
|
344 |
|
|
// the parser returns 0 if the line was blank |
345 |
chuckv |
627 |
if( parseAtom( readLine, lineNum, info, eamPotFile ) ){ |
346 |
|
|
parseEAM(info,eamPotFile, &eam_rvals, |
347 |
chuckv |
631 |
&eam_rhovals, &eam_Frhovals); |
348 |
chuckv |
499 |
info.ident = identNum; |
349 |
chuckv |
627 |
headAtomType->add( info, eam_rvals, |
350 |
|
|
eam_rhovals,eam_Frhovals ); |
351 |
chuckv |
499 |
identNum++; |
352 |
|
|
} |
353 |
|
|
} |
354 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
355 |
|
|
lineNum++; |
356 |
|
|
} |
357 |
chuckv |
627 |
|
358 |
|
|
|
359 |
chuckv |
499 |
|
360 |
|
|
#ifdef IS_MPI |
361 |
chuckv |
627 |
|
362 |
chuckv |
499 |
|
363 |
|
|
// send out the linked list to all the other processes |
364 |
|
|
|
365 |
|
|
sprintf( checkPointMsg, |
366 |
chuckv |
627 |
"EAM_FF atom structures read successfully." ); |
367 |
chuckv |
499 |
MPIcheckPoint(); |
368 |
|
|
|
369 |
|
|
currentAtomType = headAtomType->next; //skip the first element who is a place holder. |
370 |
|
|
while( currentAtomType != NULL ){ |
371 |
|
|
currentAtomType->duplicate( info ); |
372 |
|
|
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
sendFrcStruct( &info, mpiAtomStructType ); |
376 |
|
|
|
377 |
chuckv |
627 |
// We have to now broadcast the Arrays |
378 |
|
|
MPI_Bcast(currentAtomType->eam_rvals, |
379 |
|
|
currentAtomType->eam_nr, |
380 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
381 |
|
|
MPI_Bcast(currentAtomType->eam_rhovals, |
382 |
|
|
currentAtomType->eam_nr, |
383 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
384 |
|
|
MPI_Bcast(currentAtomType->eam_Frhovals, |
385 |
|
|
currentAtomType->eam_nrho, |
386 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
387 |
|
|
|
388 |
chuckv |
499 |
sprintf( checkPointMsg, |
389 |
chuckv |
627 |
"successfully sent EAM force type: \"%s\"\n", |
390 |
chuckv |
499 |
info.name ); |
391 |
|
|
MPIcheckPoint(); |
392 |
|
|
|
393 |
|
|
currentAtomType = currentAtomType->next; |
394 |
|
|
} |
395 |
|
|
info.last = 1; |
396 |
|
|
sendFrcStruct( &info, mpiAtomStructType ); |
397 |
|
|
|
398 |
|
|
} |
399 |
|
|
|
400 |
|
|
else{ |
401 |
|
|
|
402 |
|
|
// listen for node 0 to send out the force params |
403 |
|
|
|
404 |
|
|
MPIcheckPoint(); |
405 |
|
|
|
406 |
|
|
headAtomType = new LinkedAtomType; |
407 |
|
|
recieveFrcStruct( &info, mpiAtomStructType ); |
408 |
chuckv |
627 |
|
409 |
chuckv |
499 |
while( !info.last ){ |
410 |
chuckv |
627 |
|
411 |
|
|
// allocate the arrays |
412 |
chuckv |
499 |
|
413 |
chuckv |
627 |
eam_rvals = new double[info.eam_nr]; |
414 |
|
|
eam_rhovals = new double[info.eam_nr]; |
415 |
|
|
eam_Frhovals = new double[info.eam_nrho]; |
416 |
chuckv |
499 |
|
417 |
chuckv |
627 |
// We have to now broadcast the Arrays |
418 |
|
|
MPI_Bcast(eam_rvals, |
419 |
|
|
info.eam_nr, |
420 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
421 |
|
|
MPI_Bcast(eam_rhovals, |
422 |
|
|
info.eam_nr, |
423 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
424 |
|
|
MPI_Bcast(eam_Frhovals, |
425 |
|
|
info.eam_nrho, |
426 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
427 |
|
|
|
428 |
chuckv |
499 |
|
429 |
chuckv |
627 |
headAtomType->add( info, eam_rvals, eam_rhovals, eam_Frhovals ); |
430 |
chuckv |
499 |
|
431 |
|
|
MPIcheckPoint(); |
432 |
|
|
|
433 |
|
|
recieveFrcStruct( &info, mpiAtomStructType ); |
434 |
chuckv |
627 |
|
435 |
|
|
|
436 |
chuckv |
499 |
} |
437 |
|
|
} |
438 |
|
|
#endif // is_mpi |
439 |
|
|
|
440 |
|
|
// call new A_types in fortran |
441 |
|
|
|
442 |
|
|
int isError; |
443 |
|
|
|
444 |
|
|
// dummy variables |
445 |
chuckv |
627 |
int isLJ = 0; |
446 |
chuckv |
499 |
int isDipole = 0; |
447 |
|
|
int isSSD = 0; |
448 |
|
|
int isGB = 0; |
449 |
chuckv |
631 |
int isEAM= 1; |
450 |
chuckv |
499 |
double dipole = 0.0; |
451 |
chuckv |
631 |
double eamSigma = 0.0; |
452 |
|
|
double eamEpslon = 0.0; |
453 |
chuckv |
499 |
|
454 |
chuckv |
627 |
currentAtomType = headAtomType->next; |
455 |
chuckv |
499 |
while( currentAtomType != NULL ){ |
456 |
|
|
|
457 |
|
|
if( currentAtomType->name[0] != '\0' ){ |
458 |
|
|
isError = 0; |
459 |
|
|
makeAtype( &(currentAtomType->ident), |
460 |
|
|
&isLJ, |
461 |
|
|
&isSSD, |
462 |
|
|
&isDipole, |
463 |
|
|
&isGB, |
464 |
chuckv |
627 |
&isEAM, |
465 |
chuckv |
631 |
&eamEpslon, |
466 |
|
|
&eamSigma, |
467 |
chuckv |
499 |
&dipole, |
468 |
|
|
&isError ); |
469 |
|
|
if( isError ){ |
470 |
|
|
sprintf( painCave.errMsg, |
471 |
|
|
"Error initializing the \"%s\" atom type in fortran\n", |
472 |
|
|
currentAtomType->name ); |
473 |
|
|
painCave.isFatal = 1; |
474 |
|
|
simError(); |
475 |
|
|
} |
476 |
|
|
} |
477 |
|
|
currentAtomType = currentAtomType->next; |
478 |
|
|
} |
479 |
|
|
|
480 |
chuckv |
627 |
entry_plug->useLJ = 0; |
481 |
chuckv |
499 |
|
482 |
chuckv |
627 |
// Walk down again and send out EAM type |
483 |
|
|
currentAtomType = headAtomType->next; |
484 |
|
|
while( currentAtomType != NULL ){ |
485 |
|
|
|
486 |
|
|
if( currentAtomType->name[0] != '\0' ){ |
487 |
|
|
isError = 0; |
488 |
chuckv |
657 |
cerr << "Calling newEAMtype for type "<<currentAtomType->eam_ident <<"\n"; |
489 |
chuckv |
627 |
newEAMtype( &(currentAtomType->lattice_constant), |
490 |
|
|
&(currentAtomType->eam_nrho), |
491 |
|
|
&(currentAtomType->eam_drho), |
492 |
|
|
&(currentAtomType->eam_nr), |
493 |
|
|
&(currentAtomType->eam_dr), |
494 |
chuckv |
631 |
&(currentAtomType->eam_rcut), |
495 |
chuckv |
627 |
currentAtomType->eam_rvals, |
496 |
|
|
currentAtomType->eam_rhovals, |
497 |
|
|
currentAtomType->eam_Frhovals, |
498 |
|
|
&(currentAtomType->eam_ident), |
499 |
|
|
&isError); |
500 |
chuckv |
657 |
cerr << "Returned from newEAMtype\n"; |
501 |
chuckv |
627 |
if( isError ){ |
502 |
|
|
sprintf( painCave.errMsg, |
503 |
|
|
"Error initializing the \"%s\" atom type in fortran EAM\n", |
504 |
|
|
currentAtomType->name ); |
505 |
|
|
painCave.isFatal = 1; |
506 |
|
|
simError(); |
507 |
|
|
} |
508 |
|
|
} |
509 |
|
|
currentAtomType = currentAtomType->next; |
510 |
|
|
} |
511 |
|
|
|
512 |
|
|
|
513 |
|
|
|
514 |
chuckv |
499 |
#ifdef IS_MPI |
515 |
|
|
sprintf( checkPointMsg, |
516 |
chuckv |
627 |
"EAM_FF atom structures successfully sent to fortran\n" ); |
517 |
chuckv |
499 |
MPIcheckPoint(); |
518 |
|
|
#endif // is_mpi |
519 |
|
|
|
520 |
chuckv |
657 |
cerr << "Done sending eamtypes to fortran\n"; |
521 |
|
|
|
522 |
chuckv |
499 |
} |
523 |
|
|
|
524 |
|
|
|
525 |
|
|
void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
526 |
|
|
|
527 |
|
|
int i; |
528 |
|
|
|
529 |
|
|
// initialize the atoms |
530 |
|
|
|
531 |
|
|
|
532 |
|
|
Atom* thisAtom; |
533 |
|
|
|
534 |
|
|
for( i=0; i<nAtoms; i++ ){ |
535 |
|
|
|
536 |
|
|
currentAtomType = headAtomType->find( the_atoms[i]->getType() ); |
537 |
|
|
if( currentAtomType == NULL ){ |
538 |
|
|
sprintf( painCave.errMsg, |
539 |
|
|
"AtomType error, %s not found in force file.\n", |
540 |
|
|
the_atoms[i]->getType() ); |
541 |
|
|
painCave.isFatal = 1; |
542 |
|
|
simError(); |
543 |
|
|
} |
544 |
|
|
|
545 |
|
|
the_atoms[i]->setMass( currentAtomType->mass ); |
546 |
|
|
the_atoms[i]->setIdent( currentAtomType->ident ); |
547 |
chuckv |
627 |
the_atoms[i]->setEAM(); |
548 |
chuckv |
499 |
|
549 |
|
|
} |
550 |
|
|
} |
551 |
|
|
|
552 |
chuckv |
631 |
void EAM_FF::initializeBonds( int nBonds, Bond** BondArray, |
553 |
chuckv |
499 |
bond_pair* the_bonds ){ |
554 |
|
|
|
555 |
|
|
if( nBonds ){ |
556 |
|
|
sprintf( painCave.errMsg, |
557 |
|
|
"LJ_FF does not support bonds.\n" ); |
558 |
|
|
painCave.isFatal = 1; |
559 |
|
|
simError(); |
560 |
|
|
} |
561 |
|
|
} |
562 |
|
|
|
563 |
|
|
void EAM_FF::initializeBends( int nBends, Bend** bendArray, |
564 |
|
|
bend_set* the_bends ){ |
565 |
|
|
|
566 |
|
|
if( nBends ){ |
567 |
|
|
sprintf( painCave.errMsg, |
568 |
|
|
"LJ_FF does not support bends.\n" ); |
569 |
|
|
painCave.isFatal = 1; |
570 |
|
|
simError(); |
571 |
|
|
} |
572 |
|
|
} |
573 |
|
|
|
574 |
|
|
void EAM_FF::initializeTorsions( int nTorsions, Torsion** torsionArray, |
575 |
|
|
torsion_set* the_torsions ){ |
576 |
|
|
|
577 |
|
|
if( nTorsions ){ |
578 |
|
|
sprintf( painCave.errMsg, |
579 |
|
|
"LJ_FF does not support torsions.\n" ); |
580 |
|
|
painCave.isFatal = 1; |
581 |
|
|
simError(); |
582 |
|
|
} |
583 |
|
|
} |
584 |
|
|
|
585 |
|
|
void EAM_FF::fastForward( char* stopText, char* searchOwner ){ |
586 |
|
|
|
587 |
|
|
int foundText = 0; |
588 |
|
|
char* the_token; |
589 |
|
|
|
590 |
|
|
rewind( frcFile ); |
591 |
|
|
lineNum = 0; |
592 |
|
|
|
593 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
594 |
|
|
lineNum++; |
595 |
|
|
if( eof_test == NULL ){ |
596 |
|
|
sprintf( painCave.errMsg, "Error fast forwarding force file for %s: " |
597 |
|
|
" file is empty.\n", |
598 |
|
|
searchOwner ); |
599 |
|
|
painCave.isFatal = 1; |
600 |
|
|
simError(); |
601 |
|
|
} |
602 |
|
|
|
603 |
|
|
|
604 |
|
|
while( !foundText ){ |
605 |
|
|
while( eof_test != NULL && readLine[0] != '#' ){ |
606 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
607 |
|
|
lineNum++; |
608 |
|
|
} |
609 |
|
|
if( eof_test == NULL ){ |
610 |
|
|
sprintf( painCave.errMsg, |
611 |
|
|
"Error fast forwarding force file for %s at " |
612 |
|
|
"line %d: file ended unexpectedly.\n", |
613 |
|
|
searchOwner, |
614 |
|
|
lineNum ); |
615 |
|
|
painCave.isFatal = 1; |
616 |
|
|
simError(); |
617 |
|
|
} |
618 |
|
|
|
619 |
|
|
the_token = strtok( readLine, " ,;\t#\n" ); |
620 |
|
|
foundText = !strcmp( stopText, the_token ); |
621 |
|
|
|
622 |
|
|
if( !foundText ){ |
623 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
624 |
|
|
lineNum++; |
625 |
|
|
|
626 |
|
|
if( eof_test == NULL ){ |
627 |
|
|
sprintf( painCave.errMsg, |
628 |
|
|
"Error fast forwarding force file for %s at " |
629 |
|
|
"line %d: file ended unexpectedly.\n", |
630 |
|
|
searchOwner, |
631 |
|
|
lineNum ); |
632 |
|
|
painCave.isFatal = 1; |
633 |
|
|
simError(); |
634 |
|
|
} |
635 |
|
|
} |
636 |
|
|
} |
637 |
|
|
} |
638 |
|
|
|
639 |
|
|
|
640 |
|
|
|
641 |
chuckv |
627 |
int EAM_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile ){ |
642 |
chuckv |
499 |
|
643 |
|
|
char* the_token; |
644 |
|
|
|
645 |
|
|
the_token = strtok( lineBuffer, " \n\t,;" ); |
646 |
|
|
if( the_token != NULL ){ |
647 |
|
|
|
648 |
|
|
strcpy( info.name, the_token ); |
649 |
|
|
|
650 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
651 |
|
|
sprintf( painCave.errMsg, |
652 |
|
|
"Error parseing AtomTypes: line %d\n", lineNum ); |
653 |
|
|
painCave.isFatal = 1; |
654 |
|
|
simError(); |
655 |
|
|
} |
656 |
|
|
|
657 |
|
|
info.mass = atof( the_token ); |
658 |
|
|
|
659 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
660 |
|
|
sprintf( painCave.errMsg, |
661 |
|
|
"Error parseing AtomTypes: line %d\n", lineNum ); |
662 |
|
|
painCave.isFatal = 1; |
663 |
|
|
simError(); |
664 |
|
|
} |
665 |
|
|
|
666 |
chuckv |
627 |
strcpy( eamPotFile, the_token ); |
667 |
|
|
return 1; |
668 |
|
|
} |
669 |
|
|
else return 0; |
670 |
|
|
} |
671 |
|
|
|
672 |
|
|
int EAM_NS::parseEAM(atomStruct &info, char *eamPotFile, |
673 |
|
|
double **eam_rvals, |
674 |
|
|
double **eam_rhovals, |
675 |
|
|
double **eam_Frhovals){ |
676 |
chuckv |
657 |
double* myEam_rvals; |
677 |
|
|
double* myEam_rhovals; |
678 |
|
|
double* myEam_Frhovals; |
679 |
|
|
|
680 |
chuckv |
627 |
char* ffPath_env = "FORCE_PARAM_PATH"; |
681 |
|
|
char* ffPath; |
682 |
|
|
char* the_token; |
683 |
chuckv |
631 |
char* eam_eof_test; |
684 |
chuckv |
627 |
FILE *eamFile; |
685 |
chuckv |
657 |
const int BUFFERSIZE = 3000; |
686 |
chuckv |
631 |
|
687 |
chuckv |
627 |
char temp[200]; |
688 |
|
|
int linenumber; |
689 |
|
|
int nReadLines; |
690 |
chuckv |
631 |
char eam_read_buffer[BUFFERSIZE]; |
691 |
chuckv |
627 |
|
692 |
chuckv |
657 |
|
693 |
chuckv |
627 |
int i,j; |
694 |
|
|
|
695 |
|
|
linenumber = 0; |
696 |
|
|
|
697 |
|
|
// Open eam file |
698 |
|
|
eamFile = fopen( eamPotFile, "r" ); |
699 |
|
|
|
700 |
|
|
|
701 |
chuckv |
631 |
if( eamFile == NULL ){ |
702 |
chuckv |
627 |
|
703 |
|
|
// next see if the force path enviorment variable is set |
704 |
|
|
|
705 |
|
|
ffPath = getenv( ffPath_env ); |
706 |
|
|
if( ffPath == NULL ) { |
707 |
|
|
STR_DEFINE(ffPath, FRC_PATH ); |
708 |
|
|
} |
709 |
|
|
|
710 |
|
|
|
711 |
|
|
strcpy( temp, ffPath ); |
712 |
|
|
strcat( temp, "/" ); |
713 |
|
|
strcat( temp, eamPotFile ); |
714 |
|
|
strcpy( eamPotFile, temp ); |
715 |
|
|
|
716 |
|
|
eamFile = fopen( eamPotFile, "r" ); |
717 |
|
|
|
718 |
|
|
|
719 |
|
|
|
720 |
chuckv |
631 |
if( eamFile == NULL ){ |
721 |
chuckv |
627 |
|
722 |
|
|
sprintf( painCave.errMsg, |
723 |
|
|
"Error opening the EAM force parameter file: %s\n" |
724 |
|
|
"Have you tried setting the FORCE_PARAM_PATH environment " |
725 |
|
|
"vairable?\n", |
726 |
|
|
eamPotFile ); |
727 |
|
|
painCave.isFatal = 1; |
728 |
|
|
simError(); |
729 |
|
|
} |
730 |
|
|
} |
731 |
|
|
|
732 |
|
|
// First line is a comment line, read and toss it.... |
733 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
734 |
chuckv |
627 |
linenumber++; |
735 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
736 |
chuckv |
627 |
sprintf( painCave.errMsg, |
737 |
|
|
"error in reading commment in %s\n", eamPotFile); |
738 |
|
|
painCave.isFatal = 1; |
739 |
|
|
simError(); |
740 |
|
|
} |
741 |
|
|
|
742 |
|
|
|
743 |
|
|
|
744 |
|
|
// The Second line contains atomic number, atomic mass and a lattice constant |
745 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
746 |
chuckv |
627 |
linenumber++; |
747 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
748 |
chuckv |
627 |
sprintf( painCave.errMsg, |
749 |
|
|
"error in reading Identifier line in %s\n", eamPotFile); |
750 |
|
|
painCave.isFatal = 1; |
751 |
|
|
simError(); |
752 |
|
|
} |
753 |
|
|
|
754 |
|
|
|
755 |
|
|
|
756 |
|
|
|
757 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
758 |
chuckv |
627 |
sprintf( painCave.errMsg, |
759 |
|
|
"Error parseing EAM ident line in %s\n", eamPotFile ); |
760 |
|
|
painCave.isFatal = 1; |
761 |
|
|
simError(); |
762 |
|
|
} |
763 |
|
|
|
764 |
|
|
info.eam_ident = atoi( the_token ); |
765 |
|
|
|
766 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
767 |
|
|
sprintf( painCave.errMsg, |
768 |
|
|
"Error parseing EAM mass in %s\n", eamPotFile ); |
769 |
|
|
painCave.isFatal = 1; |
770 |
|
|
simError(); |
771 |
|
|
} |
772 |
|
|
info.mass = atof( the_token); |
773 |
|
|
|
774 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
775 |
|
|
sprintf( painCave.errMsg, |
776 |
|
|
"Error parseing EAM Lattice Constant %s\n", eamPotFile ); |
777 |
|
|
painCave.isFatal = 1; |
778 |
|
|
simError(); |
779 |
|
|
} |
780 |
|
|
info.lattice_constant = atof( the_token); |
781 |
|
|
|
782 |
|
|
// Next line is nrho, drho, nr, dr and rcut |
783 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
784 |
|
|
if(eam_eof_test == NULL){ |
785 |
chuckv |
627 |
sprintf( painCave.errMsg, |
786 |
|
|
"error in reading number of points line in %s\n", eamPotFile); |
787 |
|
|
painCave.isFatal = 1; |
788 |
|
|
simError(); |
789 |
|
|
} |
790 |
|
|
|
791 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
792 |
chuckv |
627 |
sprintf( painCave.errMsg, |
793 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
794 |
|
|
painCave.isFatal = 1; |
795 |
|
|
simError(); |
796 |
|
|
} |
797 |
|
|
|
798 |
|
|
info.eam_nrho = atoi( the_token ); |
799 |
|
|
|
800 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
801 |
|
|
sprintf( painCave.errMsg, |
802 |
|
|
"Error parseing EAM drho in %s\n", eamPotFile ); |
803 |
|
|
painCave.isFatal = 1; |
804 |
|
|
simError(); |
805 |
|
|
} |
806 |
|
|
info.eam_drho = atof( the_token); |
807 |
|
|
|
808 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
809 |
|
|
sprintf( painCave.errMsg, |
810 |
|
|
"Error parseing EAM # r in %s\n", eamPotFile ); |
811 |
|
|
painCave.isFatal = 1; |
812 |
|
|
simError(); |
813 |
|
|
} |
814 |
|
|
info.eam_nr = atoi( the_token); |
815 |
|
|
|
816 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
817 |
|
|
sprintf( painCave.errMsg, |
818 |
|
|
"Error parseing EAM dr in %s\n", eamPotFile ); |
819 |
|
|
painCave.isFatal = 1; |
820 |
|
|
simError(); |
821 |
|
|
} |
822 |
|
|
info.eam_dr = atof( the_token); |
823 |
|
|
|
824 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
825 |
|
|
sprintf( painCave.errMsg, |
826 |
|
|
"Error parseing EAM rcut in %s\n", eamPotFile ); |
827 |
|
|
painCave.isFatal = 1; |
828 |
|
|
simError(); |
829 |
|
|
} |
830 |
|
|
info.eam_rcut = atof( the_token); |
831 |
|
|
|
832 |
|
|
|
833 |
chuckv |
657 |
|
834 |
|
|
|
835 |
|
|
|
836 |
chuckv |
627 |
// Ok now we have to allocate point arrays and read in number of points |
837 |
|
|
// Index the arrays for fortran, starting at 1 |
838 |
chuckv |
657 |
myEam_Frhovals = new double[info.eam_nrho]; |
839 |
|
|
myEam_rvals = new double[info.eam_nr]; |
840 |
|
|
myEam_rhovals = new double[info.eam_nr]; |
841 |
chuckv |
627 |
|
842 |
|
|
// Parse F of rho vals. |
843 |
|
|
|
844 |
|
|
// Assume for now that we have a complete number of lines |
845 |
chuckv |
631 |
nReadLines = int(info.eam_nrho/5); |
846 |
chuckv |
657 |
|
847 |
chuckv |
627 |
|
848 |
chuckv |
657 |
|
849 |
chuckv |
627 |
for (i=0;i<nReadLines;i++){ |
850 |
|
|
j = i*5; |
851 |
chuckv |
657 |
|
852 |
chuckv |
627 |
// Read next line |
853 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
854 |
chuckv |
627 |
linenumber++; |
855 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
856 |
chuckv |
627 |
sprintf( painCave.errMsg, |
857 |
|
|
"error in reading EAM file %s at line %d\n", |
858 |
|
|
eamPotFile,linenumber); |
859 |
|
|
painCave.isFatal = 1; |
860 |
|
|
simError(); |
861 |
|
|
} |
862 |
|
|
|
863 |
|
|
// Parse 5 values on each line into array |
864 |
|
|
// Value 1 |
865 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
866 |
chuckv |
499 |
sprintf( painCave.errMsg, |
867 |
chuckv |
627 |
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
868 |
chuckv |
499 |
painCave.isFatal = 1; |
869 |
|
|
simError(); |
870 |
|
|
} |
871 |
chuckv |
657 |
|
872 |
|
|
myEam_Frhovals[j+0] = atof( the_token ); |
873 |
chuckv |
499 |
|
874 |
chuckv |
627 |
// Value 2 |
875 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
876 |
|
|
sprintf( painCave.errMsg, |
877 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
878 |
|
|
painCave.isFatal = 1; |
879 |
|
|
simError(); |
880 |
|
|
} |
881 |
chuckv |
657 |
|
882 |
|
|
myEam_Frhovals[j+1] = atof( the_token ); |
883 |
chuckv |
627 |
|
884 |
|
|
// Value 3 |
885 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
886 |
|
|
sprintf( painCave.errMsg, |
887 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
888 |
|
|
painCave.isFatal = 1; |
889 |
|
|
simError(); |
890 |
|
|
} |
891 |
chuckv |
657 |
|
892 |
|
|
myEam_Frhovals[j+2] = atof( the_token ); |
893 |
chuckv |
627 |
|
894 |
|
|
// Value 4 |
895 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
896 |
|
|
sprintf( painCave.errMsg, |
897 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
898 |
|
|
painCave.isFatal = 1; |
899 |
|
|
simError(); |
900 |
|
|
} |
901 |
|
|
|
902 |
chuckv |
657 |
myEam_Frhovals[j+3] = atof( the_token ); |
903 |
|
|
|
904 |
chuckv |
627 |
// Value 5 |
905 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
906 |
|
|
sprintf( painCave.errMsg, |
907 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
908 |
|
|
painCave.isFatal = 1; |
909 |
|
|
simError(); |
910 |
|
|
} |
911 |
chuckv |
657 |
|
912 |
|
|
myEam_Frhovals[j+4] = atof( the_token ); |
913 |
chuckv |
627 |
|
914 |
chuckv |
499 |
} |
915 |
chuckv |
627 |
// Parse Z of r vals |
916 |
|
|
|
917 |
|
|
// Assume for now that we have a complete number of lines |
918 |
chuckv |
631 |
nReadLines = int(info.eam_nr/5); |
919 |
chuckv |
627 |
|
920 |
|
|
for (i=0;i<nReadLines;i++){ |
921 |
|
|
j = i*5; |
922 |
|
|
|
923 |
|
|
// Read next line |
924 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
925 |
chuckv |
627 |
linenumber++; |
926 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
927 |
chuckv |
627 |
sprintf( painCave.errMsg, |
928 |
|
|
"error in reading EAM file %s at line %d\n", |
929 |
|
|
eamPotFile,linenumber); |
930 |
|
|
painCave.isFatal = 1; |
931 |
|
|
simError(); |
932 |
|
|
} |
933 |
|
|
|
934 |
|
|
// Parse 5 values on each line into array |
935 |
|
|
// Value 1 |
936 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
937 |
chuckv |
627 |
sprintf( painCave.errMsg, |
938 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
939 |
|
|
painCave.isFatal = 1; |
940 |
|
|
simError(); |
941 |
|
|
} |
942 |
|
|
|
943 |
chuckv |
657 |
myEam_rvals[j+0] = atof( the_token ); |
944 |
chuckv |
627 |
|
945 |
|
|
// Value 2 |
946 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
947 |
|
|
sprintf( painCave.errMsg, |
948 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
949 |
|
|
painCave.isFatal = 1; |
950 |
|
|
simError(); |
951 |
|
|
} |
952 |
|
|
|
953 |
chuckv |
657 |
myEam_rvals[j+1] = atof( the_token ); |
954 |
chuckv |
627 |
|
955 |
|
|
// Value 3 |
956 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
957 |
|
|
sprintf( painCave.errMsg, |
958 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
959 |
|
|
painCave.isFatal = 1; |
960 |
|
|
simError(); |
961 |
|
|
} |
962 |
|
|
|
963 |
chuckv |
657 |
myEam_rvals[j+2] = atof( the_token ); |
964 |
chuckv |
627 |
|
965 |
|
|
// Value 4 |
966 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
967 |
|
|
sprintf( painCave.errMsg, |
968 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
969 |
|
|
painCave.isFatal = 1; |
970 |
|
|
simError(); |
971 |
|
|
} |
972 |
|
|
|
973 |
chuckv |
657 |
myEam_rvals[j+3] = atof( the_token ); |
974 |
chuckv |
627 |
|
975 |
|
|
// Value 5 |
976 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
977 |
|
|
sprintf( painCave.errMsg, |
978 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
979 |
|
|
painCave.isFatal = 1; |
980 |
|
|
simError(); |
981 |
|
|
} |
982 |
|
|
|
983 |
chuckv |
657 |
myEam_rvals[j+4] = atof( the_token ); |
984 |
chuckv |
627 |
|
985 |
|
|
} |
986 |
|
|
// Parse rho of r vals |
987 |
|
|
|
988 |
|
|
// Assume for now that we have a complete number of lines |
989 |
|
|
|
990 |
|
|
for (i=0;i<nReadLines;i++){ |
991 |
|
|
j = i*5; |
992 |
|
|
|
993 |
|
|
// Read next line |
994 |
chuckv |
631 |
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
995 |
chuckv |
627 |
linenumber++; |
996 |
chuckv |
631 |
if(eam_eof_test == NULL){ |
997 |
chuckv |
627 |
sprintf( painCave.errMsg, |
998 |
|
|
"error in reading EAM file %s at line %d\n", |
999 |
|
|
eamPotFile,linenumber); |
1000 |
|
|
painCave.isFatal = 1; |
1001 |
|
|
simError(); |
1002 |
|
|
} |
1003 |
|
|
|
1004 |
|
|
// Parse 5 values on each line into array |
1005 |
|
|
// Value 1 |
1006 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1007 |
chuckv |
627 |
sprintf( painCave.errMsg, |
1008 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
1009 |
|
|
painCave.isFatal = 1; |
1010 |
|
|
simError(); |
1011 |
|
|
} |
1012 |
|
|
|
1013 |
chuckv |
657 |
myEam_rhovals[j+0] = atof( the_token ); |
1014 |
chuckv |
627 |
|
1015 |
|
|
// Value 2 |
1016 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1017 |
chuckv |
627 |
sprintf( painCave.errMsg, |
1018 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
1019 |
|
|
painCave.isFatal = 1; |
1020 |
|
|
simError(); |
1021 |
|
|
} |
1022 |
|
|
|
1023 |
chuckv |
657 |
myEam_rhovals[j+1] = atof( the_token ); |
1024 |
chuckv |
627 |
|
1025 |
|
|
// Value 3 |
1026 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1027 |
chuckv |
627 |
sprintf( painCave.errMsg, |
1028 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
1029 |
|
|
painCave.isFatal = 1; |
1030 |
|
|
simError(); |
1031 |
|
|
} |
1032 |
|
|
|
1033 |
chuckv |
657 |
myEam_rhovals[j+2] = atof( the_token ); |
1034 |
chuckv |
627 |
|
1035 |
|
|
// Value 4 |
1036 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1037 |
chuckv |
627 |
sprintf( painCave.errMsg, |
1038 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
1039 |
|
|
painCave.isFatal = 1; |
1040 |
|
|
simError(); |
1041 |
|
|
} |
1042 |
|
|
|
1043 |
chuckv |
657 |
myEam_rhovals[j+3] = atof( the_token ); |
1044 |
chuckv |
627 |
|
1045 |
|
|
// Value 5 |
1046 |
chuckv |
631 |
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1047 |
chuckv |
627 |
sprintf( painCave.errMsg, |
1048 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
1049 |
|
|
painCave.isFatal = 1; |
1050 |
|
|
simError(); |
1051 |
|
|
} |
1052 |
|
|
|
1053 |
chuckv |
657 |
myEam_rhovals[j+4] = atof( the_token ); |
1054 |
chuckv |
627 |
|
1055 |
|
|
} |
1056 |
chuckv |
657 |
*eam_rvals = myEam_rvals; |
1057 |
|
|
*eam_rhovals = myEam_rhovals; |
1058 |
|
|
*eam_Frhovals = myEam_Frhovals; |
1059 |
chuckv |
627 |
|
1060 |
|
|
fclose(eamFile); |
1061 |
|
|
return 0; |
1062 |
chuckv |
499 |
} |