Unverified Commit 9cc16c4f authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1479 from akohlmey/fixup_pair_quip

Correctly and fully support pair style hybrid and hybrid/overlay for pair style quip
parents cfad0634 d3cbccff
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -92,10 +92,6 @@ pairs from the neighbor list. This needs to be very carefully tested,
because it may remove pairs from the neighbor list that are still
required.

Pair style {quip} cannot be used with pair style {hybrid}, only
with {hybrid/overlay} and only the {quip} sub-style is applied to
all atom types.

[Related commands:]

"pair_coeff"_pair_coeff.html
+59 −39
Original line number Diff line number Diff line
@@ -44,6 +44,11 @@ PairQUIP::PairQUIP(LAMMPS *lmp) : Pair(lmp)
  one_coeff = 1;
  no_virial_fdotr_compute = 1;
  manybody_flag = 1;

  map = NULL;
  quip_potential = NULL;
  quip_file = NULL;
  quip_string = NULL;
}

PairQUIP::~PairQUIP()
@@ -52,8 +57,10 @@ PairQUIP::~PairQUIP()
    memory->destroy(setflag);
    memory->destroy(cutsq);
    delete [] map;
    delete [] quip_potential;
  }
  delete [] quip_potential;
  delete [] quip_file;
  delete [] quip_string;
}

void PairQUIP::compute(int eflag, int vflag)
@@ -107,7 +114,7 @@ void PairQUIP::compute(int eflag, int vflag)

  atomic_numbers = new int[ntotal];
  for (ii = 0; ii < ntotal; ii++)
     atomic_numbers[ii] = map[type[ii]-1];
     atomic_numbers[ii] = map[type[ii]];

  quip_local_e = new double [ntotal];
  quip_force = new double [ntotal*3];
@@ -214,14 +221,17 @@ void PairQUIP::compute(int eflag, int vflag)
void PairQUIP::settings(int narg, char ** /* arg */)
{
  if (narg != 0) error->all(FLERR,"Illegal pair_style command");
  if (strcmp(force->pair_style,"hybrid") == 0)
    error->all(FLERR,"Pair style quip is only compatible with hybrid/overlay");

  // check if linked to the correct QUIP library API version
  // as of 2017-07-19 this is API_VERSION 1
  if (quip_lammps_api_version() != 1)
    error->all(FLERR,"QUIP LAMMPS wrapper API version is not compatible "
        "with this version of LAMMPS");

  // QUIP potentials are parameterized in metal units

  if (strcmp("metal",update->unit_style) != 0)
    error->all(FLERR,"QUIP potentials require 'metal' units");
}

/* ----------------------------------------------------------------------
@@ -234,7 +244,7 @@ void PairQUIP::allocate()

  setflag = memory->create(setflag,n+1,n+1,"pair:setflag");
  cutsq = memory->create(cutsq,n+1,n+1,"pair:cutsq");
  map = new int[n];
  map = new int[n+1];
}

void PairQUIP::coeff(int narg, char **arg)
@@ -242,21 +252,14 @@ void PairQUIP::coeff(int narg, char **arg)
  if (!allocated) allocate();

  int n = atom->ntypes;

  // ensure I,J args are * *

   for (int i = 1; i <= n; i++){
      for (int j = 1; j <= n; j++) {
         setflag[i][j] = 1;
      }
   }

  if (narg != (4+n)) {
    char str[1024];
    sprintf(str,"Number of arguments %d is not correct, it should be %d", narg, 4+n);
    error->all(FLERR,str);
  }

  // ensure I,J args are * *

  if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
    error->all(FLERR,"Incorrect args for pair coefficients");

@@ -269,14 +272,31 @@ void PairQUIP::coeff(int narg, char **arg)
  strcpy(quip_string,arg[3]);

  for (int i = 4; i < narg; i++) {

      if (0 == sscanf(arg[i],"%d",&map[i-4])) {
         char str[1024];
         sprintf(str,"Incorrect atomic number %s at position %d",arg[i],i);
         error->all(FLERR,str);
    if (strcmp(arg[i],"NULL") == 0)
      map[i-3] = -1;
    else
      map[i-3] = force->inumeric(FLERR,arg[i]);
  }

  // clear setflag since coeff() called once with I,J = * *

  n = atom->ntypes;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++)
      setflag[i][j] = 0;

  // set setflag i,j for type pairs where both are mapped to elements

  int count = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++)
      if (map[i] >= 0 && map[j] >= 0) {
        setflag[i][j] = 1;
        count++;
      }

  if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");

  // Initialise potential
  // First call initialises potential via the fortran code in memory, and returns the necessary size
  // of quip_potential. This behaviour is invoked by setting n_potential_quip to 0.
+4 −4

File changed.

Contains only whitespace changes.