1 |
gezelter |
2 |
#include <stdlib.h> |
2 |
|
|
#include <stdio.h> |
3 |
|
|
#include <string.h> |
4 |
|
|
|
5 |
|
|
#include <iostream> |
6 |
|
|
using namespace std; |
7 |
|
|
|
8 |
|
|
#ifdef IS_MPI |
9 |
|
|
#include <mpi.h> |
10 |
|
|
#endif //is_mpi |
11 |
|
|
|
12 |
tim |
3 |
#include "UseTheForce/ForceFields.hpp" |
13 |
|
|
#include "primitives/SRI.hpp" |
14 |
|
|
#include "utils/simError.h" |
15 |
gezelter |
141 |
#include "types/AtomType.hpp" |
16 |
|
|
#include "UseTheForce/DarkSide/eam_interface.h" |
17 |
gezelter |
2 |
|
18 |
chuckv |
124 |
//#include "UseTheForce/fortranWrappers.hpp" |
19 |
gezelter |
2 |
|
20 |
|
|
#ifdef IS_MPI |
21 |
tim |
3 |
#include "UseTheForce/mpiForceField.h" |
22 |
gezelter |
2 |
#endif // is_mpi |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
namespace EAM_NS{ |
27 |
|
|
|
28 |
|
|
// Declare the structures that will be passed by the parser and MPI |
29 |
|
|
|
30 |
|
|
typedef struct{ |
31 |
|
|
char name[15]; |
32 |
|
|
double mass; |
33 |
|
|
double lattice_constant; |
34 |
|
|
double eam_drho; // The distance between each of the points indexed by rho. |
35 |
|
|
double eam_rcut; // The cutoff radius for eam. |
36 |
|
|
double eam_dr; // The distance between each of the rho points. |
37 |
|
|
int eam_nrho; // Number of points indexed by rho |
38 |
|
|
int eam_nr; // The number of points based on r (Both Phi(r) and Rho(r)). |
39 |
|
|
int eam_ident; // Atomic number |
40 |
|
|
int ident; |
41 |
|
|
int last; // 0 -> default |
42 |
|
|
// 1 -> in MPI: tells nodes to stop listening |
43 |
|
|
} atomStruct; |
44 |
|
|
|
45 |
|
|
int parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile ); |
46 |
|
|
int parseEAM( atomStruct &info, char *eamPotFile, double **eam_rvals, |
47 |
|
|
double **eam_rhovals, double **eam_Frhovals); |
48 |
|
|
#ifdef IS_MPI |
49 |
|
|
|
50 |
|
|
MPI_Datatype mpiAtomStructType; |
51 |
|
|
|
52 |
|
|
#endif |
53 |
|
|
|
54 |
|
|
class LinkedAtomType { |
55 |
|
|
public: |
56 |
|
|
LinkedAtomType(){ |
57 |
|
|
next = NULL; |
58 |
|
|
name[0] = '\0'; |
59 |
|
|
eam_rvals = NULL; |
60 |
|
|
eam_rhovals = NULL; |
61 |
|
|
eam_Frhovals = NULL; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
~LinkedAtomType(){ |
65 |
|
|
if( next != NULL ) delete next; |
66 |
|
|
if( eam_rvals != NULL ) delete[] eam_rvals; |
67 |
|
|
if( eam_rhovals != NULL ) delete[] eam_rhovals; |
68 |
|
|
if( eam_Frhovals != NULL ) delete[] eam_Frhovals; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
LinkedAtomType* find(char* key){ |
72 |
|
|
if( !strcmp(name, key) ) return this; |
73 |
|
|
if( next != NULL ) return next->find(key); |
74 |
|
|
return NULL; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
|
78 |
|
|
void add( atomStruct &info, double *the_eam_rvals, |
79 |
|
|
double *the_eam_rhovals,double *the_eam_Frhovals ){ |
80 |
|
|
|
81 |
|
|
// check for duplicates |
82 |
|
|
|
83 |
|
|
if( !strcmp( info.name, name ) ){ |
84 |
|
|
sprintf( painCave.errMsg, |
85 |
|
|
"Duplicate EAM atom type \"%s\" found in " |
86 |
|
|
"the EAM_FF param file./n", |
87 |
|
|
name ); |
88 |
|
|
painCave.isFatal = 1; |
89 |
|
|
simError(); |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
if( next != NULL ) next->add(info, the_eam_rvals, the_eam_rhovals, the_eam_Frhovals); |
93 |
|
|
else{ |
94 |
|
|
next = new LinkedAtomType(); |
95 |
|
|
strcpy(next->name, info.name); |
96 |
|
|
next->mass = info.mass; |
97 |
|
|
next->lattice_constant = info.lattice_constant; |
98 |
|
|
next->eam_nrho = info.eam_nrho; |
99 |
|
|
next->eam_drho = info.eam_drho; |
100 |
|
|
next->eam_nr = info.eam_nr; |
101 |
|
|
next->eam_dr = info.eam_dr; |
102 |
|
|
next->eam_rcut = info.eam_rcut; |
103 |
|
|
next->eam_ident = info.eam_ident; |
104 |
|
|
next->ident = info.ident; |
105 |
|
|
|
106 |
|
|
next->eam_rvals = the_eam_rvals; |
107 |
|
|
next->eam_rhovals = the_eam_rhovals; |
108 |
|
|
next->eam_Frhovals = the_eam_Frhovals; |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
|
113 |
|
|
#ifdef IS_MPI |
114 |
|
|
|
115 |
|
|
void duplicate( atomStruct &info ){ |
116 |
|
|
strcpy(info.name, name); |
117 |
|
|
info.mass = mass; |
118 |
|
|
info.lattice_constant = lattice_constant; |
119 |
|
|
info.eam_nrho = eam_nrho; |
120 |
|
|
info.eam_drho = eam_drho; |
121 |
|
|
info.eam_nr = eam_nr; |
122 |
|
|
info.eam_dr = eam_dr; |
123 |
|
|
info.eam_rcut = eam_rcut; |
124 |
|
|
info.eam_ident = eam_ident; |
125 |
|
|
info.ident = ident; |
126 |
|
|
info.last = 0; |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
|
130 |
|
|
#endif |
131 |
|
|
|
132 |
|
|
char name[15]; |
133 |
|
|
double mass; |
134 |
|
|
double lattice_constant; |
135 |
|
|
int eam_nrho; // Number of points indexed by rho |
136 |
|
|
double eam_drho; // The distance between each of the points indexed by rho. |
137 |
|
|
int eam_nr; // The number of points based on r (Both Phi(r) and Rho(r)). |
138 |
|
|
double eam_dr; // The distance between each of the rho points. |
139 |
|
|
double eam_rcut; // The cutoff radius for eam. |
140 |
|
|
|
141 |
|
|
double *eam_rvals; // Z of r values |
142 |
|
|
double *eam_rhovals; // rho of r values |
143 |
|
|
double *eam_Frhovals; // F of rho values |
144 |
|
|
int eam_ident; // eam identity (atomic number) |
145 |
|
|
int ident; |
146 |
|
|
LinkedAtomType* next; |
147 |
|
|
}; |
148 |
|
|
|
149 |
|
|
LinkedAtomType* headAtomType; |
150 |
|
|
LinkedAtomType* currentAtomType; |
151 |
|
|
|
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
using namespace EAM_NS; |
155 |
|
|
|
156 |
|
|
//**************************************************************** |
157 |
|
|
// begins the actual forcefield stuff. |
158 |
|
|
//**************************************************************** |
159 |
|
|
|
160 |
|
|
EAM_FF::EAM_FF() { |
161 |
|
|
EAM_FF(""); |
162 |
|
|
} |
163 |
|
|
|
164 |
|
|
EAM_FF::EAM_FF(char* the_variant){ |
165 |
|
|
|
166 |
|
|
char fileName[200]; |
167 |
|
|
char* ffPath_env = "FORCE_PARAM_PATH"; |
168 |
|
|
char* ffPath; |
169 |
|
|
char temp[200]; |
170 |
|
|
|
171 |
|
|
headAtomType = NULL; |
172 |
|
|
currentAtomType = NULL; |
173 |
|
|
|
174 |
|
|
// Set eamRcut to 0.0 |
175 |
|
|
eamRcut = 0.0; |
176 |
|
|
|
177 |
|
|
#ifdef IS_MPI |
178 |
|
|
int i; |
179 |
|
|
|
180 |
|
|
// ********************************************************************** |
181 |
|
|
// Init the atomStruct mpi type |
182 |
|
|
|
183 |
|
|
atomStruct atomProto; // mpiPrototype |
184 |
|
|
int atomBC[3] = {15,5,5}; // block counts |
185 |
|
|
MPI_Aint atomDspls[3]; // displacements |
186 |
|
|
MPI_Datatype atomMbrTypes[3]; // member mpi types |
187 |
|
|
|
188 |
|
|
MPI_Address(&atomProto.name, &atomDspls[0]); |
189 |
|
|
MPI_Address(&atomProto.mass, &atomDspls[1]); |
190 |
|
|
MPI_Address(&atomProto.eam_nrho, &atomDspls[2]); |
191 |
|
|
|
192 |
|
|
atomMbrTypes[0] = MPI_CHAR; |
193 |
|
|
atomMbrTypes[1] = MPI_DOUBLE; |
194 |
|
|
atomMbrTypes[2] = MPI_INT; |
195 |
|
|
|
196 |
|
|
for (i=2; i >= 0; i--) atomDspls[i] -= atomDspls[0]; |
197 |
|
|
|
198 |
|
|
MPI_Type_struct(3, atomBC, atomDspls, atomMbrTypes, &mpiAtomStructType); |
199 |
|
|
MPI_Type_commit(&mpiAtomStructType); |
200 |
|
|
|
201 |
|
|
// *********************************************************************** |
202 |
|
|
|
203 |
|
|
if( worldRank == 0 ){ |
204 |
|
|
#endif |
205 |
|
|
|
206 |
|
|
// generate the force file name |
207 |
|
|
|
208 |
|
|
strcpy( fileName, "EAM" ); |
209 |
|
|
|
210 |
|
|
if (strlen(the_variant) > 0) { |
211 |
|
|
has_variant = 1; |
212 |
|
|
strcpy( variant, the_variant); |
213 |
|
|
strcat( fileName, "."); |
214 |
|
|
strcat( fileName, variant ); |
215 |
|
|
|
216 |
|
|
sprintf( painCave.errMsg, |
217 |
|
|
"Using %s variant of EAM force field.\n", |
218 |
|
|
variant ); |
219 |
|
|
painCave.severity = OOPSE_INFO; |
220 |
|
|
painCave.isFatal = 0; |
221 |
|
|
simError(); |
222 |
|
|
} |
223 |
|
|
strcat( fileName, ".frc"); |
224 |
|
|
|
225 |
|
|
//fprintf( stderr,"Trying to open %s\n", fileName ); |
226 |
|
|
|
227 |
|
|
// attempt to open the file in the current directory first. |
228 |
|
|
|
229 |
|
|
frcFile = fopen( fileName, "r" ); |
230 |
|
|
|
231 |
|
|
if( frcFile == NULL ){ |
232 |
|
|
|
233 |
|
|
// next see if the force path enviorment variable is set |
234 |
|
|
|
235 |
|
|
ffPath = getenv( ffPath_env ); |
236 |
|
|
if( ffPath == NULL ) { |
237 |
|
|
STR_DEFINE(ffPath, FRC_PATH ); |
238 |
|
|
} |
239 |
|
|
|
240 |
|
|
|
241 |
|
|
strcpy( temp, ffPath ); |
242 |
|
|
strcat( temp, "/" ); |
243 |
|
|
strcat( temp, fileName ); |
244 |
|
|
strcpy( fileName, temp ); |
245 |
|
|
|
246 |
|
|
frcFile = fopen( fileName, "r" ); |
247 |
|
|
|
248 |
|
|
if( frcFile == NULL ){ |
249 |
|
|
|
250 |
|
|
sprintf( painCave.errMsg, |
251 |
|
|
"Error opening the force field parameter file:\n" |
252 |
|
|
"\t%s\n" |
253 |
|
|
"\tHave you tried setting the FORCE_PARAM_PATH environment " |
254 |
|
|
"variable?\n", |
255 |
|
|
fileName ); |
256 |
|
|
painCave.severity = OOPSE_ERROR; |
257 |
|
|
painCave.isFatal = 1; |
258 |
|
|
simError(); |
259 |
|
|
} |
260 |
|
|
} |
261 |
|
|
|
262 |
|
|
|
263 |
|
|
#ifdef IS_MPI |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
sprintf( checkPointMsg, "EAM_FF file opened sucessfully." ); |
267 |
|
|
MPIcheckPoint(); |
268 |
|
|
|
269 |
|
|
#endif // is_mpi |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
|
273 |
|
|
EAM_FF::~EAM_FF(){ |
274 |
|
|
|
275 |
|
|
if( headAtomType != NULL ) delete headAtomType; |
276 |
|
|
|
277 |
|
|
#ifdef IS_MPI |
278 |
|
|
if( worldRank == 0 ){ |
279 |
|
|
#endif // is_mpi |
280 |
|
|
|
281 |
|
|
fclose( frcFile ); |
282 |
|
|
|
283 |
|
|
#ifdef IS_MPI |
284 |
|
|
} |
285 |
|
|
#endif // is_mpi |
286 |
|
|
} |
287 |
|
|
|
288 |
|
|
|
289 |
|
|
void EAM_FF::calcRcut( void ){ |
290 |
|
|
|
291 |
|
|
#ifdef IS_MPI |
292 |
|
|
double tempEamRcut = eamRcut; |
293 |
|
|
MPI_Allreduce( &tempEamRcut, &eamRcut, 1, MPI_DOUBLE, MPI_MAX, |
294 |
|
|
MPI_COMM_WORLD); |
295 |
|
|
#endif //is_mpi |
296 |
|
|
entry_plug->setDefaultRcut(eamRcut); |
297 |
|
|
} |
298 |
|
|
|
299 |
|
|
|
300 |
gezelter |
135 |
void EAM_FF::initForceField( ){ |
301 |
|
|
initFortran(0); |
302 |
gezelter |
2 |
} |
303 |
|
|
|
304 |
|
|
void EAM_FF::cleanMe( void ){ |
305 |
|
|
|
306 |
|
|
#ifdef IS_MPI |
307 |
|
|
|
308 |
|
|
// keep the linked list in the mpi version |
309 |
|
|
|
310 |
|
|
#else // is_mpi |
311 |
|
|
|
312 |
|
|
// delete the linked list in the single processor version |
313 |
|
|
|
314 |
|
|
if( headAtomType != NULL ) delete headAtomType; |
315 |
|
|
|
316 |
|
|
#endif // is_mpi |
317 |
|
|
} |
318 |
|
|
|
319 |
|
|
|
320 |
|
|
void EAM_FF::readParams( void ){ |
321 |
|
|
|
322 |
|
|
atomStruct info; |
323 |
|
|
info.last = 1; // initialize last to have the last set. |
324 |
|
|
// if things go well, last will be set to 0 |
325 |
|
|
|
326 |
|
|
int identNum; |
327 |
|
|
double *eam_rvals; // Z of r values |
328 |
|
|
double *eam_rhovals; // rho of r values |
329 |
|
|
double *eam_Frhovals; // F of rho values |
330 |
|
|
char eamPotFile[1000]; |
331 |
gezelter |
141 |
|
332 |
gezelter |
2 |
|
333 |
|
|
|
334 |
|
|
bigSigma = 0.0; |
335 |
|
|
#ifdef IS_MPI |
336 |
|
|
if( worldRank == 0 ){ |
337 |
|
|
#endif |
338 |
|
|
|
339 |
|
|
// read in the atom types. |
340 |
|
|
|
341 |
|
|
headAtomType = new LinkedAtomType; |
342 |
|
|
|
343 |
|
|
fastForward( "AtomTypes", "eam atom readParams" ); |
344 |
|
|
|
345 |
|
|
// we are now at the AtomTypes section. |
346 |
|
|
|
347 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
348 |
|
|
lineNum++; |
349 |
|
|
|
350 |
|
|
|
351 |
|
|
// read a line, and start parseing out the atom types |
352 |
|
|
|
353 |
|
|
if( eof_test == NULL ){ |
354 |
|
|
sprintf( painCave.errMsg, |
355 |
|
|
"Error in reading Atoms from force file at line %d.\n", |
356 |
|
|
lineNum ); |
357 |
|
|
painCave.isFatal = 1; |
358 |
|
|
simError(); |
359 |
|
|
} |
360 |
|
|
|
361 |
|
|
identNum = 1; |
362 |
|
|
// stop reading at end of file, or at next section |
363 |
|
|
|
364 |
|
|
while( readLine[0] != '#' && eof_test != NULL ){ |
365 |
|
|
|
366 |
|
|
// toss comment lines |
367 |
|
|
if( readLine[0] != '!' ){ |
368 |
|
|
|
369 |
|
|
// the parser returns 0 if the line was blank |
370 |
|
|
if( parseAtom( readLine, lineNum, info, eamPotFile ) ){ |
371 |
|
|
parseEAM(info,eamPotFile, &eam_rvals, |
372 |
|
|
&eam_rhovals, &eam_Frhovals); |
373 |
|
|
info.ident = identNum; |
374 |
|
|
headAtomType->add( info, eam_rvals, |
375 |
|
|
eam_rhovals,eam_Frhovals ); |
376 |
|
|
identNum++; |
377 |
|
|
} |
378 |
|
|
} |
379 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
380 |
|
|
lineNum++; |
381 |
|
|
} |
382 |
|
|
|
383 |
|
|
|
384 |
|
|
|
385 |
|
|
#ifdef IS_MPI |
386 |
|
|
|
387 |
|
|
|
388 |
|
|
// send out the linked list to all the other processes |
389 |
|
|
|
390 |
|
|
sprintf( checkPointMsg, |
391 |
|
|
"EAM_FF atom structures read successfully." ); |
392 |
|
|
MPIcheckPoint(); |
393 |
|
|
|
394 |
|
|
currentAtomType = headAtomType->next; //skip the first element who is a place holder. |
395 |
|
|
while( currentAtomType != NULL ){ |
396 |
|
|
currentAtomType->duplicate( info ); |
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
sendFrcStruct( &info, mpiAtomStructType ); |
401 |
|
|
|
402 |
|
|
// We have to now broadcast the Arrays |
403 |
|
|
MPI_Bcast(currentAtomType->eam_rvals, |
404 |
|
|
currentAtomType->eam_nr, |
405 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
406 |
|
|
MPI_Bcast(currentAtomType->eam_rhovals, |
407 |
|
|
currentAtomType->eam_nr, |
408 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
409 |
|
|
MPI_Bcast(currentAtomType->eam_Frhovals, |
410 |
|
|
currentAtomType->eam_nrho, |
411 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
412 |
|
|
|
413 |
|
|
sprintf( checkPointMsg, |
414 |
|
|
"successfully sent EAM force type: \"%s\"\n", |
415 |
|
|
info.name ); |
416 |
|
|
MPIcheckPoint(); |
417 |
|
|
|
418 |
|
|
currentAtomType = currentAtomType->next; |
419 |
|
|
} |
420 |
|
|
info.last = 1; |
421 |
|
|
sendFrcStruct( &info, mpiAtomStructType ); |
422 |
|
|
|
423 |
|
|
} |
424 |
|
|
|
425 |
|
|
else{ |
426 |
|
|
|
427 |
|
|
// listen for node 0 to send out the force params |
428 |
|
|
|
429 |
|
|
MPIcheckPoint(); |
430 |
|
|
|
431 |
|
|
headAtomType = new LinkedAtomType; |
432 |
|
|
receiveFrcStruct( &info, mpiAtomStructType ); |
433 |
|
|
|
434 |
|
|
while( !info.last ){ |
435 |
|
|
|
436 |
|
|
// allocate the arrays |
437 |
|
|
|
438 |
|
|
eam_rvals = new double[info.eam_nr]; |
439 |
|
|
eam_rhovals = new double[info.eam_nr]; |
440 |
|
|
eam_Frhovals = new double[info.eam_nrho]; |
441 |
|
|
|
442 |
|
|
// We have to now broadcast the Arrays |
443 |
|
|
MPI_Bcast(eam_rvals, |
444 |
|
|
info.eam_nr, |
445 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
446 |
|
|
MPI_Bcast(eam_rhovals, |
447 |
|
|
info.eam_nr, |
448 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
449 |
|
|
MPI_Bcast(eam_Frhovals, |
450 |
|
|
info.eam_nrho, |
451 |
|
|
MPI_DOUBLE,0,MPI_COMM_WORLD); |
452 |
|
|
|
453 |
|
|
|
454 |
|
|
headAtomType->add( info, eam_rvals, eam_rhovals, eam_Frhovals ); |
455 |
|
|
|
456 |
|
|
MPIcheckPoint(); |
457 |
|
|
|
458 |
|
|
receiveFrcStruct( &info, mpiAtomStructType ); |
459 |
|
|
|
460 |
|
|
|
461 |
|
|
} |
462 |
|
|
} |
463 |
|
|
#endif // is_mpi |
464 |
|
|
|
465 |
|
|
// call new A_types in fortran |
466 |
|
|
|
467 |
|
|
int isError; |
468 |
|
|
|
469 |
|
|
// dummy variables |
470 |
|
|
|
471 |
|
|
currentAtomType = headAtomType->next; |
472 |
|
|
while( currentAtomType != NULL ){ |
473 |
|
|
|
474 |
|
|
if( currentAtomType->name[0] != '\0' ){ |
475 |
gezelter |
141 |
|
476 |
|
|
AtomType* at = new AtomType(); |
477 |
|
|
at->setIdent(currentAtomType->ident); |
478 |
|
|
at->setName(currentAtomType->name); |
479 |
|
|
at->setEAM(); |
480 |
|
|
at->complete(); |
481 |
|
|
|
482 |
|
|
} |
483 |
|
|
|
484 |
gezelter |
2 |
currentAtomType = currentAtomType->next; |
485 |
|
|
} |
486 |
|
|
|
487 |
chrisfen |
143 |
entry_plug->useLennardJones = 0; |
488 |
gezelter |
2 |
entry_plug->useEAM = 1; |
489 |
|
|
// Walk down again and send out EAM type |
490 |
|
|
currentAtomType = headAtomType->next; |
491 |
|
|
while( currentAtomType != NULL ){ |
492 |
|
|
|
493 |
|
|
if( currentAtomType->name[0] != '\0' ){ |
494 |
|
|
isError = 0; |
495 |
|
|
|
496 |
|
|
newEAMtype( &(currentAtomType->lattice_constant), |
497 |
|
|
&(currentAtomType->eam_nrho), |
498 |
|
|
&(currentAtomType->eam_drho), |
499 |
|
|
&(currentAtomType->eam_nr), |
500 |
|
|
&(currentAtomType->eam_dr), |
501 |
|
|
&(currentAtomType->eam_rcut), |
502 |
|
|
currentAtomType->eam_rvals, |
503 |
|
|
currentAtomType->eam_rhovals, |
504 |
|
|
currentAtomType->eam_Frhovals, |
505 |
|
|
&(currentAtomType->eam_ident), |
506 |
|
|
&isError); |
507 |
|
|
|
508 |
|
|
if( isError ){ |
509 |
|
|
sprintf( painCave.errMsg, |
510 |
|
|
"Error initializing the \"%s\" atom type in fortran EAM\n", |
511 |
|
|
currentAtomType->name ); |
512 |
|
|
painCave.isFatal = 1; |
513 |
|
|
simError(); |
514 |
|
|
} |
515 |
|
|
} |
516 |
|
|
currentAtomType = currentAtomType->next; |
517 |
|
|
} |
518 |
|
|
|
519 |
|
|
|
520 |
|
|
|
521 |
|
|
#ifdef IS_MPI |
522 |
|
|
sprintf( checkPointMsg, |
523 |
|
|
"EAM_FF atom structures successfully sent to fortran\n" ); |
524 |
|
|
MPIcheckPoint(); |
525 |
|
|
#endif // is_mpi |
526 |
|
|
|
527 |
|
|
|
528 |
|
|
|
529 |
|
|
} |
530 |
|
|
|
531 |
|
|
|
532 |
|
|
void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
533 |
|
|
|
534 |
|
|
int i; |
535 |
|
|
|
536 |
|
|
// initialize the atoms |
537 |
|
|
|
538 |
|
|
for( i=0; i<nAtoms; i++ ){ |
539 |
|
|
|
540 |
|
|
currentAtomType = headAtomType->find( the_atoms[i]->getType() ); |
541 |
|
|
if( currentAtomType == NULL ){ |
542 |
|
|
sprintf( painCave.errMsg, |
543 |
|
|
"AtomType error, %s not found in force file.\n", |
544 |
|
|
the_atoms[i]->getType() ); |
545 |
|
|
painCave.isFatal = 1; |
546 |
|
|
simError(); |
547 |
|
|
} |
548 |
|
|
|
549 |
|
|
the_atoms[i]->setMass( currentAtomType->mass ); |
550 |
|
|
the_atoms[i]->setIdent( currentAtomType->ident ); |
551 |
|
|
|
552 |
|
|
if (eamRcut < currentAtomType->eam_rcut) eamRcut = currentAtomType->eam_rcut; |
553 |
|
|
|
554 |
|
|
} |
555 |
|
|
} |
556 |
|
|
|
557 |
|
|
void EAM_FF::initializeBonds( int nBonds, Bond** BondArray, |
558 |
|
|
bond_pair* the_bonds ){ |
559 |
|
|
|
560 |
|
|
if( nBonds ){ |
561 |
|
|
sprintf( painCave.errMsg, |
562 |
|
|
"LJ_FF does not support bonds.\n" ); |
563 |
|
|
painCave.isFatal = 1; |
564 |
|
|
simError(); |
565 |
|
|
} |
566 |
|
|
} |
567 |
|
|
|
568 |
|
|
void EAM_FF::initializeBends( int nBends, Bend** bendArray, |
569 |
|
|
bend_set* the_bends ){ |
570 |
|
|
|
571 |
|
|
if( nBends ){ |
572 |
|
|
sprintf( painCave.errMsg, |
573 |
|
|
"LJ_FF does not support bends.\n" ); |
574 |
|
|
painCave.isFatal = 1; |
575 |
|
|
simError(); |
576 |
|
|
} |
577 |
|
|
} |
578 |
|
|
|
579 |
|
|
void EAM_FF::initializeTorsions( int nTorsions, Torsion** torsionArray, |
580 |
|
|
torsion_set* the_torsions ){ |
581 |
|
|
|
582 |
|
|
if( nTorsions ){ |
583 |
|
|
sprintf( painCave.errMsg, |
584 |
|
|
"LJ_FF does not support torsions.\n" ); |
585 |
|
|
painCave.isFatal = 1; |
586 |
|
|
simError(); |
587 |
|
|
} |
588 |
|
|
} |
589 |
|
|
|
590 |
|
|
void EAM_FF::fastForward( char* stopText, char* searchOwner ){ |
591 |
|
|
|
592 |
|
|
int foundText = 0; |
593 |
|
|
char* the_token; |
594 |
|
|
|
595 |
|
|
rewind( frcFile ); |
596 |
|
|
lineNum = 0; |
597 |
|
|
|
598 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
599 |
|
|
lineNum++; |
600 |
|
|
if( eof_test == NULL ){ |
601 |
|
|
sprintf( painCave.errMsg, "Error fast forwarding force file for %s: " |
602 |
|
|
" file is empty.\n", |
603 |
|
|
searchOwner ); |
604 |
|
|
painCave.isFatal = 1; |
605 |
|
|
simError(); |
606 |
|
|
} |
607 |
|
|
|
608 |
|
|
|
609 |
|
|
while( !foundText ){ |
610 |
|
|
while( eof_test != NULL && readLine[0] != '#' ){ |
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 |
|
|
the_token = strtok( readLine, " ,;\t#\n" ); |
625 |
|
|
foundText = !strcmp( stopText, the_token ); |
626 |
|
|
|
627 |
|
|
if( !foundText ){ |
628 |
|
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
629 |
|
|
lineNum++; |
630 |
|
|
|
631 |
|
|
if( eof_test == NULL ){ |
632 |
|
|
sprintf( painCave.errMsg, |
633 |
|
|
"Error fast forwarding force file for %s at " |
634 |
|
|
"line %d: file ended unexpectedly.\n", |
635 |
|
|
searchOwner, |
636 |
|
|
lineNum ); |
637 |
|
|
painCave.isFatal = 1; |
638 |
|
|
simError(); |
639 |
|
|
} |
640 |
|
|
} |
641 |
|
|
} |
642 |
|
|
} |
643 |
|
|
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
int EAM_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile ){ |
647 |
|
|
|
648 |
|
|
char* the_token; |
649 |
|
|
|
650 |
|
|
the_token = strtok( lineBuffer, " \n\t,;" ); |
651 |
|
|
if( the_token != NULL ){ |
652 |
|
|
|
653 |
|
|
strcpy( info.name, the_token ); |
654 |
|
|
|
655 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
656 |
|
|
sprintf( painCave.errMsg, |
657 |
|
|
"Error parseing AtomTypes: line %d\n", lineNum ); |
658 |
|
|
painCave.isFatal = 1; |
659 |
|
|
simError(); |
660 |
|
|
} |
661 |
|
|
|
662 |
|
|
info.mass = atof( the_token ); |
663 |
|
|
|
664 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
665 |
|
|
sprintf( painCave.errMsg, |
666 |
|
|
"Error parseing AtomTypes: line %d\n", lineNum ); |
667 |
|
|
painCave.isFatal = 1; |
668 |
|
|
simError(); |
669 |
|
|
} |
670 |
|
|
|
671 |
|
|
strcpy( eamPotFile, the_token ); |
672 |
|
|
return 1; |
673 |
|
|
} |
674 |
|
|
else return 0; |
675 |
|
|
} |
676 |
|
|
|
677 |
|
|
int EAM_NS::parseEAM(atomStruct &info, char *eamPotFile, |
678 |
|
|
double **eam_rvals, |
679 |
|
|
double **eam_rhovals, |
680 |
|
|
double **eam_Frhovals){ |
681 |
|
|
double* myEam_rvals; |
682 |
|
|
double* myEam_rhovals; |
683 |
|
|
double* myEam_Frhovals; |
684 |
|
|
|
685 |
|
|
char* ffPath_env = "FORCE_PARAM_PATH"; |
686 |
|
|
char* ffPath; |
687 |
|
|
char* the_token; |
688 |
|
|
char* eam_eof_test; |
689 |
|
|
FILE *eamFile; |
690 |
|
|
const int BUFFERSIZE = 3000; |
691 |
|
|
|
692 |
|
|
char temp[200]; |
693 |
|
|
int linenumber; |
694 |
|
|
int nReadLines; |
695 |
|
|
char eam_read_buffer[BUFFERSIZE]; |
696 |
|
|
|
697 |
|
|
|
698 |
|
|
int i,j; |
699 |
|
|
|
700 |
|
|
linenumber = 0; |
701 |
|
|
|
702 |
|
|
// Open eam file |
703 |
|
|
eamFile = fopen( eamPotFile, "r" ); |
704 |
|
|
|
705 |
|
|
|
706 |
|
|
if( eamFile == NULL ){ |
707 |
|
|
|
708 |
|
|
// next see if the force path enviorment variable is set |
709 |
|
|
|
710 |
|
|
ffPath = getenv( ffPath_env ); |
711 |
|
|
if( ffPath == NULL ) { |
712 |
|
|
STR_DEFINE(ffPath, FRC_PATH ); |
713 |
|
|
} |
714 |
|
|
|
715 |
|
|
|
716 |
|
|
strcpy( temp, ffPath ); |
717 |
|
|
strcat( temp, "/" ); |
718 |
|
|
strcat( temp, eamPotFile ); |
719 |
|
|
strcpy( eamPotFile, temp ); |
720 |
|
|
|
721 |
|
|
eamFile = fopen( eamPotFile, "r" ); |
722 |
|
|
|
723 |
|
|
|
724 |
|
|
|
725 |
|
|
if( eamFile == NULL ){ |
726 |
|
|
|
727 |
|
|
sprintf( painCave.errMsg, |
728 |
|
|
"Error opening the EAM force parameter file: %s\n" |
729 |
|
|
"Have you tried setting the FORCE_PARAM_PATH environment " |
730 |
|
|
"variable?\n", |
731 |
|
|
eamPotFile ); |
732 |
|
|
painCave.isFatal = 1; |
733 |
|
|
simError(); |
734 |
|
|
} |
735 |
|
|
} |
736 |
|
|
|
737 |
|
|
// First line is a comment line, read and toss it.... |
738 |
|
|
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
739 |
|
|
linenumber++; |
740 |
|
|
if(eam_eof_test == NULL){ |
741 |
|
|
sprintf( painCave.errMsg, |
742 |
|
|
"error in reading commment in %s\n", eamPotFile); |
743 |
|
|
painCave.isFatal = 1; |
744 |
|
|
simError(); |
745 |
|
|
} |
746 |
|
|
|
747 |
|
|
|
748 |
|
|
|
749 |
|
|
// The Second line contains atomic number, atomic mass and a lattice constant |
750 |
|
|
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
751 |
|
|
linenumber++; |
752 |
|
|
if(eam_eof_test == NULL){ |
753 |
|
|
sprintf( painCave.errMsg, |
754 |
|
|
"error in reading Identifier line in %s\n", eamPotFile); |
755 |
|
|
painCave.isFatal = 1; |
756 |
|
|
simError(); |
757 |
|
|
} |
758 |
|
|
|
759 |
|
|
|
760 |
|
|
|
761 |
|
|
|
762 |
|
|
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
763 |
|
|
sprintf( painCave.errMsg, |
764 |
|
|
"Error parsing EAM ident line in %s\n", eamPotFile ); |
765 |
|
|
painCave.isFatal = 1; |
766 |
|
|
simError(); |
767 |
|
|
} |
768 |
|
|
|
769 |
|
|
info.eam_ident = atoi( the_token ); |
770 |
|
|
|
771 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
772 |
|
|
sprintf( painCave.errMsg, |
773 |
|
|
"Error parsing EAM mass in %s\n", eamPotFile ); |
774 |
|
|
painCave.isFatal = 1; |
775 |
|
|
simError(); |
776 |
|
|
} |
777 |
|
|
info.mass = atof( the_token); |
778 |
|
|
|
779 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
780 |
|
|
sprintf( painCave.errMsg, |
781 |
|
|
"Error parsing EAM Lattice Constant %s\n", eamPotFile ); |
782 |
|
|
painCave.isFatal = 1; |
783 |
|
|
simError(); |
784 |
|
|
} |
785 |
|
|
info.lattice_constant = atof( the_token); |
786 |
|
|
|
787 |
|
|
// Next line is nrho, drho, nr, dr and rcut |
788 |
|
|
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
789 |
|
|
if(eam_eof_test == NULL){ |
790 |
|
|
sprintf( painCave.errMsg, |
791 |
|
|
"error in reading number of points line in %s\n", eamPotFile); |
792 |
|
|
painCave.isFatal = 1; |
793 |
|
|
simError(); |
794 |
|
|
} |
795 |
|
|
|
796 |
|
|
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
797 |
|
|
sprintf( painCave.errMsg, |
798 |
|
|
"Error parseing EAM nrho: line in %s\n", eamPotFile ); |
799 |
|
|
painCave.isFatal = 1; |
800 |
|
|
simError(); |
801 |
|
|
} |
802 |
|
|
|
803 |
|
|
info.eam_nrho = atoi( the_token ); |
804 |
|
|
|
805 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
806 |
|
|
sprintf( painCave.errMsg, |
807 |
|
|
"Error parsing EAM drho in %s\n", eamPotFile ); |
808 |
|
|
painCave.isFatal = 1; |
809 |
|
|
simError(); |
810 |
|
|
} |
811 |
|
|
info.eam_drho = atof( the_token); |
812 |
|
|
|
813 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
814 |
|
|
sprintf( painCave.errMsg, |
815 |
|
|
"Error parsing EAM # r in %s\n", eamPotFile ); |
816 |
|
|
painCave.isFatal = 1; |
817 |
|
|
simError(); |
818 |
|
|
} |
819 |
|
|
info.eam_nr = atoi( the_token); |
820 |
|
|
|
821 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
822 |
|
|
sprintf( painCave.errMsg, |
823 |
|
|
"Error parsing EAM dr in %s\n", eamPotFile ); |
824 |
|
|
painCave.isFatal = 1; |
825 |
|
|
simError(); |
826 |
|
|
} |
827 |
|
|
info.eam_dr = atof( the_token); |
828 |
|
|
|
829 |
|
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
830 |
|
|
sprintf( painCave.errMsg, |
831 |
|
|
"Error parsing EAM rcut in %s\n", eamPotFile ); |
832 |
|
|
painCave.isFatal = 1; |
833 |
|
|
simError(); |
834 |
|
|
} |
835 |
|
|
info.eam_rcut = atof( the_token); |
836 |
|
|
|
837 |
|
|
|
838 |
|
|
|
839 |
|
|
|
840 |
|
|
|
841 |
|
|
// Ok now we have to allocate point arrays and read in number of points |
842 |
|
|
// Index the arrays for fortran, starting at 1 |
843 |
|
|
myEam_Frhovals = new double[info.eam_nrho]; |
844 |
|
|
myEam_rvals = new double[info.eam_nr]; |
845 |
|
|
myEam_rhovals = new double[info.eam_nr]; |
846 |
|
|
|
847 |
|
|
// Parse F of rho vals. |
848 |
|
|
|
849 |
|
|
// Assume for now that we have a complete number of lines |
850 |
|
|
nReadLines = int(info.eam_nrho/5); |
851 |
|
|
|
852 |
|
|
|
853 |
|
|
|
854 |
|
|
for (i=0;i<nReadLines;i++){ |
855 |
|
|
j = i*5; |
856 |
|
|
|
857 |
|
|
// Read next line |
858 |
|
|
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
859 |
|
|
linenumber++; |
860 |
|
|
if(eam_eof_test == NULL){ |
861 |
|
|
sprintf( painCave.errMsg, |
862 |
|
|
"error in reading EAM file %s at line %d\n", |
863 |
|
|
eamPotFile,linenumber); |
864 |
|
|
painCave.isFatal = 1; |
865 |
|
|
simError(); |
866 |
|
|
} |
867 |
|
|
|
868 |
|
|
// Parse 5 values on each line into array |
869 |
|
|
// Value 1 |
870 |
|
|
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
871 |
|
|
sprintf( painCave.errMsg, |
872 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
873 |
|
|
painCave.isFatal = 1; |
874 |
|
|
simError(); |
875 |
|
|
} |
876 |
|
|
|
877 |
|
|
myEam_Frhovals[j+0] = atof( the_token ); |
878 |
|
|
|
879 |
|
|
// Value 2 |
880 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
881 |
|
|
sprintf( painCave.errMsg, |
882 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
883 |
|
|
painCave.isFatal = 1; |
884 |
|
|
simError(); |
885 |
|
|
} |
886 |
|
|
|
887 |
|
|
myEam_Frhovals[j+1] = atof( the_token ); |
888 |
|
|
|
889 |
|
|
// Value 3 |
890 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
891 |
|
|
sprintf( painCave.errMsg, |
892 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
893 |
|
|
painCave.isFatal = 1; |
894 |
|
|
simError(); |
895 |
|
|
} |
896 |
|
|
|
897 |
|
|
myEam_Frhovals[j+2] = atof( the_token ); |
898 |
|
|
|
899 |
|
|
// Value 4 |
900 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
901 |
|
|
sprintf( painCave.errMsg, |
902 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
903 |
|
|
painCave.isFatal = 1; |
904 |
|
|
simError(); |
905 |
|
|
} |
906 |
|
|
|
907 |
|
|
myEam_Frhovals[j+3] = atof( the_token ); |
908 |
|
|
|
909 |
|
|
// Value 5 |
910 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
911 |
|
|
sprintf( painCave.errMsg, |
912 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
913 |
|
|
painCave.isFatal = 1; |
914 |
|
|
simError(); |
915 |
|
|
} |
916 |
|
|
|
917 |
|
|
myEam_Frhovals[j+4] = atof( the_token ); |
918 |
|
|
|
919 |
|
|
} |
920 |
|
|
// Parse Z of r vals |
921 |
|
|
|
922 |
|
|
// Assume for now that we have a complete number of lines |
923 |
|
|
nReadLines = int(info.eam_nr/5); |
924 |
|
|
|
925 |
|
|
for (i=0;i<nReadLines;i++){ |
926 |
|
|
j = i*5; |
927 |
|
|
|
928 |
|
|
// Read next line |
929 |
|
|
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
930 |
|
|
linenumber++; |
931 |
|
|
if(eam_eof_test == NULL){ |
932 |
|
|
sprintf( painCave.errMsg, |
933 |
|
|
"error in reading EAM file %s at line %d\n", |
934 |
|
|
eamPotFile,linenumber); |
935 |
|
|
painCave.isFatal = 1; |
936 |
|
|
simError(); |
937 |
|
|
} |
938 |
|
|
|
939 |
|
|
// Parse 5 values on each line into array |
940 |
|
|
// Value 1 |
941 |
|
|
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
942 |
|
|
sprintf( painCave.errMsg, |
943 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
944 |
|
|
painCave.isFatal = 1; |
945 |
|
|
simError(); |
946 |
|
|
} |
947 |
|
|
|
948 |
|
|
myEam_rvals[j+0] = atof( the_token ); |
949 |
|
|
|
950 |
|
|
// Value 2 |
951 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
952 |
|
|
sprintf( painCave.errMsg, |
953 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
954 |
|
|
painCave.isFatal = 1; |
955 |
|
|
simError(); |
956 |
|
|
} |
957 |
|
|
|
958 |
|
|
myEam_rvals[j+1] = atof( the_token ); |
959 |
|
|
|
960 |
|
|
// Value 3 |
961 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
962 |
|
|
sprintf( painCave.errMsg, |
963 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
964 |
|
|
painCave.isFatal = 1; |
965 |
|
|
simError(); |
966 |
|
|
} |
967 |
|
|
|
968 |
|
|
myEam_rvals[j+2] = atof( the_token ); |
969 |
|
|
|
970 |
|
|
// Value 4 |
971 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
972 |
|
|
sprintf( painCave.errMsg, |
973 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
974 |
|
|
painCave.isFatal = 1; |
975 |
|
|
simError(); |
976 |
|
|
} |
977 |
|
|
|
978 |
|
|
myEam_rvals[j+3] = atof( the_token ); |
979 |
|
|
|
980 |
|
|
// Value 5 |
981 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
982 |
|
|
sprintf( painCave.errMsg, |
983 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
984 |
|
|
painCave.isFatal = 1; |
985 |
|
|
simError(); |
986 |
|
|
} |
987 |
|
|
|
988 |
|
|
myEam_rvals[j+4] = atof( the_token ); |
989 |
|
|
|
990 |
|
|
} |
991 |
|
|
// Parse rho of r vals |
992 |
|
|
|
993 |
|
|
// Assume for now that we have a complete number of lines |
994 |
|
|
|
995 |
|
|
for (i=0;i<nReadLines;i++){ |
996 |
|
|
j = i*5; |
997 |
|
|
|
998 |
|
|
// Read next line |
999 |
|
|
eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile); |
1000 |
|
|
linenumber++; |
1001 |
|
|
if(eam_eof_test == NULL){ |
1002 |
|
|
sprintf( painCave.errMsg, |
1003 |
|
|
"error in reading EAM file %s at line %d\n", |
1004 |
|
|
eamPotFile,linenumber); |
1005 |
|
|
painCave.isFatal = 1; |
1006 |
|
|
simError(); |
1007 |
|
|
} |
1008 |
|
|
|
1009 |
|
|
// Parse 5 values on each line into array |
1010 |
|
|
// Value 1 |
1011 |
|
|
if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ |
1012 |
|
|
sprintf( painCave.errMsg, |
1013 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
1014 |
|
|
painCave.isFatal = 1; |
1015 |
|
|
simError(); |
1016 |
|
|
} |
1017 |
|
|
|
1018 |
|
|
myEam_rhovals[j+0] = atof( the_token ); |
1019 |
|
|
|
1020 |
|
|
// Value 2 |
1021 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
1022 |
|
|
sprintf( painCave.errMsg, |
1023 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
1024 |
|
|
painCave.isFatal = 1; |
1025 |
|
|
simError(); |
1026 |
|
|
} |
1027 |
|
|
|
1028 |
|
|
myEam_rhovals[j+1] = atof( the_token ); |
1029 |
|
|
|
1030 |
|
|
// Value 3 |
1031 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
1032 |
|
|
sprintf( painCave.errMsg, |
1033 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
1034 |
|
|
painCave.isFatal = 1; |
1035 |
|
|
simError(); |
1036 |
|
|
} |
1037 |
|
|
|
1038 |
|
|
myEam_rhovals[j+2] = atof( the_token ); |
1039 |
|
|
|
1040 |
|
|
// Value 4 |
1041 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
1042 |
|
|
sprintf( painCave.errMsg, |
1043 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
1044 |
|
|
painCave.isFatal = 1; |
1045 |
|
|
simError(); |
1046 |
|
|
} |
1047 |
|
|
|
1048 |
|
|
myEam_rhovals[j+3] = atof( the_token ); |
1049 |
|
|
|
1050 |
|
|
// Value 5 |
1051 |
|
|
if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ |
1052 |
|
|
sprintf( painCave.errMsg, |
1053 |
|
|
"Error parsing EAM nrho: line in %s\n", eamPotFile ); |
1054 |
|
|
painCave.isFatal = 1; |
1055 |
|
|
simError(); |
1056 |
|
|
} |
1057 |
|
|
|
1058 |
|
|
myEam_rhovals[j+4] = atof( the_token ); |
1059 |
|
|
|
1060 |
|
|
} |
1061 |
|
|
*eam_rvals = myEam_rvals; |
1062 |
|
|
*eam_rhovals = myEam_rhovals; |
1063 |
|
|
*eam_Frhovals = myEam_Frhovals; |
1064 |
|
|
|
1065 |
|
|
fclose(eamFile); |
1066 |
|
|
return 0; |
1067 |
|
|
} |
1068 |
|
|
|
1069 |
|
|
double EAM_FF::getAtomTypeMass (char* atomType) { |
1070 |
|
|
|
1071 |
|
|
currentAtomType = headAtomType->find( atomType ); |
1072 |
|
|
if( currentAtomType == NULL ){ |
1073 |
|
|
sprintf( painCave.errMsg, |
1074 |
|
|
"AtomType error, %s not found in force file.\n", |
1075 |
|
|
atomType ); |
1076 |
|
|
painCave.isFatal = 1; |
1077 |
|
|
simError(); |
1078 |
|
|
} |
1079 |
|
|
|
1080 |
|
|
return currentAtomType->mass; |
1081 |
|
|
} |
1082 |
|
|
|