Unverified Commit e8ee1df9 authored by Richard Berger's avatar Richard Berger
Browse files

Update pair eam cd

parent 0dc05698
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -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.