Commit cb3344a3 authored by sjplimp's avatar sjplimp Committed by GitHub
Browse files

Merge pull request #489 from akohlmey/thread-safe-biasing

port thread-safe temperature biasing from LAMMPS-ICMS
parents 5d38cbbc d2810f9f
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -396,6 +396,15 @@ void ComputeTempAsphere::remove_bias(int i, double *v)
  if (tbias) tbias->remove_bias(i,v);
}

/* ----------------------------------------------------------------------
   remove velocity bias from atom I to leave thermal velocity
------------------------------------------------------------------------- */

void ComputeTempAsphere::remove_bias_thr(int i, double *v, double *b)
{
  if (tbias) tbias->remove_bias_thr(i,v,b);
}

/* ----------------------------------------------------------------------
   add back in velocity bias to atom I removed by remove_bias()
   assume remove_bias() was previously called
@@ -405,3 +414,13 @@ void ComputeTempAsphere::restore_bias(int i, double *v)
{
  if (tbias) tbias->restore_bias(i,v);
}

/* ----------------------------------------------------------------------
   add back in velocity bias to atom I removed by remove_bias_thr()
   assume remove_bias_thr() was previously called with the same buffer b
------------------------------------------------------------------------- */

void ComputeTempAsphere::restore_bias_thr(int i, double *v, double *b)
{
  if (tbias) tbias->restore_bias_thr(i,v,b);
}
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ class ComputeTempAsphere : public Compute {

  void remove_bias(int, double *);
  void restore_bias(int, double *);
  void remove_bias_thr(int, double *, double *);
  void restore_bias_thr(int, double *, double *);

 private:
  int mode;
+23 −0
Original line number Diff line number Diff line
@@ -221,6 +221,17 @@ void ComputeTempRotate::remove_bias(int i, double *v)
  v[2] -= vbiasall[i][2];
}

/* ----------------------------------------------------------------------
   remove velocity bias from atom I to leave thermal velocity
------------------------------------------------------------------------- */

void ComputeTempRotate::remove_bias_thr(int i, double *v, double *)
{
  v[0] -= vbiasall[i][0];
  v[1] -= vbiasall[i][1];
  v[2] -= vbiasall[i][2];
}

/* ----------------------------------------------------------------------
   remove velocity bias from all atoms to leave thermal velocity
------------------------------------------------------------------------- */
@@ -251,6 +262,18 @@ void ComputeTempRotate::restore_bias(int i, double *v)
  v[2] += vbiasall[i][2];
}

/* ----------------------------------------------------------------------
   add back in velocity bias to atom I removed by remove_bias_thr()
   assume remove_bias_thr() was previously called
------------------------------------------------------------------------- */

void ComputeTempRotate::restore_bias_thr(int i, double *v, double *)
{
  v[0] += vbiasall[i][0];
  v[1] += vbiasall[i][1];
  v[2] += vbiasall[i][2];
}

/* ----------------------------------------------------------------------
   add back in velocity bias to all atoms removed by remove_bias_all()
   assume remove_bias_all() was previously called
+3 −0
Original line number Diff line number Diff line
@@ -34,9 +34,12 @@ class ComputeTempRotate : public Compute {
  void compute_vector();

  void remove_bias(int, double *);
  void remove_bias_thr(int, double *, double *);
  void remove_bias_all();
  void restore_bias(int, double *);
  void restore_bias_all();
  void restore_bias_thr(int, double *, double *);

  double memory_usage();

 private:
+3 −2
Original line number Diff line number Diff line
@@ -183,12 +183,13 @@ void FixNHAsphereOMP::nh_v_temp()
#pragma omp parallel for default(none) private(i) schedule(static)
#endif
    for (i = 0; i < nlocal; i++) {
      double buf[3];
      if (mask[i] & groupbit) {
        temperature->remove_bias(i,&v[i].x);
        temperature->remove_bias_thr(i,&v[i].x,buf);
        v[i].x *= factor_eta;
        v[i].y *= factor_eta;
        v[i].z *= factor_eta;
        temperature->restore_bias(i,&v[i].x);
        temperature->restore_bias_thr(i,&v[i].x,buf);
        angmom[i].x *= factor_eta;
        angmom[i].y *= factor_eta;
        angmom[i].z *= factor_eta;
Loading