Commit 2243aca0 authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1889 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 31dd4cc6
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ FixSpringSelf::FixSpringSelf(LAMMPS *lmp, int narg, char **arg) :
  if (narg != 4) error->all("Illegal fix spring/self command");

  restart_peratom = 1;
  scalar_flag = 1;
  scalar_vector_freq = 1;
  extscalar = 1;

  k = atof(arg[3]);
  if (k <= 0.0) error->all("Illegal fix spring/self command");
@@ -92,6 +95,7 @@ int FixSpringSelf::setmask()
  int mask = 0;
  mask |= POST_FORCE;
  mask |= POST_FORCE_RESPA;
  mask |= MIN_POST_FORCE;
  return mask;
}

@@ -131,6 +135,7 @@ void FixSpringSelf::post_force(int vflag)
  double zprd = domain->zprd;
  int xbox,ybox,zbox;
  double dx,dy,dz;
  double espring = 0.0;

  for (int i = 0; i < nlocal; i++)
    if (mask[i] & groupbit) {
@@ -143,6 +148,7 @@ void FixSpringSelf::post_force(int vflag)
      f[i][0] -= k*dx;
      f[i][1] -= k*dy;
      f[i][2] -= k*dz;
      espring += k * (dx*dx + dy*dy + dz*dz);
    }
}

@@ -153,6 +159,24 @@ void FixSpringSelf::post_force_respa(int vflag, int ilevel, int iloop)
  if (ilevel == nlevels_respa-1) post_force(vflag);
}

/* ----------------------------------------------------------------------
   energy of stretched springs
------------------------------------------------------------------------- */

double FixSpringSelf::compute_scalar()
{
  double all;
  MPI_Allreduce(&espring,&all,1,MPI_DOUBLE,MPI_SUM,world);
  return all;
}

/* ---------------------------------------------------------------------- */

void FixSpringSelf::min_post_force(int vflag)
{
  post_force(vflag);
}

/* ----------------------------------------------------------------------
   memory usage of local atom-based array
------------------------------------------------------------------------- */
+3 −1
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ class FixSpringSelf : public Fix {
  void setup(int);
  void post_force(int);
  void post_force_respa(int, int, int);
  void min_post_force(int);
  double compute_scalar();

  double memory_usage();
  void grow_arrays(int);
@@ -39,7 +41,7 @@ class FixSpringSelf : public Fix {
  int maxsize_restart();

 private:
  double k;
  double k,espring;
  double **xoriginal;         // original coords of atoms
  int nlevels_respa;
};