Update pair eam cd

This commit is contained in:
Richard Berger 2020-05-28 12:35:02 -04:00
parent 0dc05698f3
commit e8ee1df993
No known key found for this signature in database
GPG Key ID: A9E83994E0BA0CAB
1 changed files with 11 additions and 6 deletions

View File

@ -28,6 +28,7 @@
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "tokenizer.h"
using namespace LAMMPS_NS;
@ -512,16 +513,20 @@ void PairEAMCD::read_h_coeff(char *filename)
while(fgets(nextline, MAXLINE, fptr) != NULL) {
strcpy(line, nextline);
}
char* ptr = strtok(line, " \t\n\r\f");
int degree = atoi(ptr);
ValueTokenizer values(line, " \t\n\r\f");
int degree = values.next_int();
nhcoeff = degree+1;
if (values.count() != nhcoeff + 1 || nhcoeff < 1)
error->one(FLERR, "Failed to read h(x) function coefficients in EAM file.");
hcoeff = new double[nhcoeff];
int i = 0;
while((ptr = strtok(NULL," \t\n\r\f")) != NULL && i < nhcoeff) {
hcoeff[i++] = atof(ptr);
while(values.has_next()) {
hcoeff[i++] = values.next_double();
}
if (i != nhcoeff || nhcoeff < 1)
error->one(FLERR,"Failed to read h(x) function coefficients from EAM file.");
// Close the potential file.