161 |
|
EAM_FF(""); |
162 |
|
} |
163 |
|
|
164 |
< |
EAM_FF::EAM_FF(char* the_variant){ |
164 |
> |
EAM_FF::EAM_FF(string the_variant){ |
165 |
|
|
166 |
< |
char fileName[200]; |
167 |
< |
char* ffPath_env = "FORCE_PARAM_PATH"; |
168 |
< |
char* ffPath; |
169 |
< |
char temp[200]; |
166 |
> |
string fileName; |
167 |
> |
string tempString; |
168 |
|
|
169 |
|
headAtomType = NULL; |
170 |
|
currentAtomType = NULL; |
203 |
|
|
204 |
|
// generate the force file name |
205 |
|
|
206 |
< |
strcpy( fileName, "EAM" ); |
206 |
> |
fileName = "EAM"; |
207 |
|
|
208 |
< |
if (strlen(the_variant) > 0) { |
208 |
> |
if (!the_variant.empty()) { |
209 |
|
has_variant = 1; |
210 |
< |
strcpy( variant, the_variant); |
211 |
< |
strcat( fileName, "."); |
214 |
< |
strcat( fileName, variant ); |
215 |
< |
|
210 |
> |
fileName += "." + the_variant + ".frc"; |
211 |
> |
|
212 |
|
sprintf( painCave.errMsg, |
213 |
|
"Using %s variant of EAM force field.\n", |
214 |
< |
variant ); |
214 |
> |
the_variant.c_str() ); |
215 |
|
painCave.severity = OOPSE_INFO; |
216 |
|
painCave.isFatal = 0; |
217 |
|
simError(); |
218 |
< |
} |
223 |
< |
strcat( fileName, ".frc"); |
218 |
> |
} |
219 |
|
|
220 |
|
//fprintf( stderr,"Trying to open %s\n", fileName ); |
221 |
|
|
222 |
|
// attempt to open the file in the current directory first. |
223 |
|
|
224 |
< |
frcFile = fopen( fileName, "r" ); |
224 |
> |
frcFile = fopen( fileName.c_str(), "r" ); |
225 |
|
|
226 |
|
if( frcFile == NULL ){ |
227 |
|
|
228 |
|
// 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 |
– |
} |
229 |
|
|
230 |
+ |
tempString = ffPath + "/" + fileName; |
231 |
+ |
fileName = tempString; |
232 |
+ |
|
233 |
+ |
frcFile = fopen( fileName.c_str(), "r" ); |
234 |
|
|
241 |
– |
strcpy( temp, ffPath ); |
242 |
– |
strcat( temp, "/" ); |
243 |
– |
strcat( temp, fileName ); |
244 |
– |
strcpy( fileName, temp ); |
245 |
– |
|
246 |
– |
frcFile = fopen( fileName, "r" ); |
247 |
– |
|
235 |
|
if( frcFile == NULL ){ |
236 |
|
|
237 |
|
sprintf( painCave.errMsg, |
239 |
|
"\t%s\n" |
240 |
|
"\tHave you tried setting the FORCE_PARAM_PATH environment " |
241 |
|
"variable?\n", |
242 |
< |
fileName ); |
242 |
> |
fileName.c_str() ); |
243 |
|
painCave.severity = OOPSE_ERROR; |
244 |
|
painCave.isFatal = 1; |
245 |
|
simError(); |
471 |
|
currentAtomType = currentAtomType->next; |
472 |
|
} |
473 |
|
|
474 |
< |
entry_plug->useLJ = 0; |
474 |
> |
entry_plug->useLennardJones = 0; |
475 |
|
entry_plug->useEAM = 1; |
476 |
|
// Walk down again and send out EAM type |
477 |
|
currentAtomType = headAtomType->next; |
1052 |
|
fclose(eamFile); |
1053 |
|
return 0; |
1054 |
|
} |
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 |
– |
|