Unverified Commit 4e2ebf7f authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1352 from mkanski/reax_var_atoms

A partial fix for ReaxFF failure when the number of atoms increases during a simulation
parents 2077df54 bfa950a7
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -42,16 +42,14 @@ FixReaxC::FixReaxC(LAMMPS *lmp,int narg, char **arg) :
  // perform initial allocation of atom-based arrays
  // register with atom class
  
  oldnmax = 0;
  num_bonds = NULL;
  num_hbonds = NULL;
  grow_arrays(atom->nmax);
  atom->add_callback(0);

  // initialize arrays to MIN so atom migration is OK the 1st time

  int nlocal = atom->nlocal;
  for (int i = 0; i < nlocal; i++)
    num_bonds[i] = num_hbonds[i] = MIN_REAX_BONDS;
  // it is done in grow_arrays() now

  // set comm sizes needed by this fix

@@ -99,6 +97,11 @@ void FixReaxC::grow_arrays(int nmax)
{
  memory->grow(num_bonds,nmax,"reaxc:num_bonds");
  memory->grow(num_hbonds,nmax,"reaxc:num_hbonds");
  for (int i = oldnmax; i < nmax; i++) {
    num_hbonds[i] = MIN_REAX_HBONDS;
    num_bonds[i] = MIN_REAX_BONDS;
  }
  oldnmax = nmax;
}

/* ----------------------------------------------------------------------
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ class FixReaxC : public Fix {
  int maxhbonds;             // max # of Hbonds for any atom
  int *num_bonds;            // # of bonds for each atom
  int *num_hbonds;           // # of Hbonds for each atom
  int oldnmax;               // arrays' size before growing
};

}