diff --git a/src/USER-OMP/thr_data.cpp b/src/USER-OMP/thr_data.cpp index de09dadc58dd5124dbb676438f5df3b69b301ffd..21b3279e215e00d6aa7b577e0be6af2cf93d2fbe 100644 --- a/src/USER-OMP/thr_data.cpp +++ b/src/USER-OMP/thr_data.cpp @@ -116,9 +116,10 @@ void ThrData::init_force(int nall, double **f, double **torque, void ThrData::init_eam(int nall, double *rho) { - _rho = rho + _tid*nall; - if (nall > 0) + if (nall >= 0 && rho) { + _rho = rho + _tid*nall; memset(_rho, 0, nall*sizeof(double)); + } } /* ---------------------------------------------------------------------- */ @@ -127,9 +128,9 @@ void ThrData::init_adp(int nall, double *rho, double **mu, double **lambda) { init_eam(nall, rho); - _mu = mu + _tid*nall; - _lambda = lambda + _tid*nall; - if (nall > 0) { + if (nall >= 0 && mu && lambda) { + _mu = mu + _tid*nall; + _lambda = lambda + _tid*nall; memset(&(_mu[0][0]), 0, nall*3*sizeof(double)); memset(&(_lambda[0][0]), 0, nall*6*sizeof(double)); } @@ -141,9 +142,9 @@ void ThrData::init_cdeam(int nall, double *rho, double *rhoB, double *D_values) { init_eam(nall, rho); - _rhoB = rhoB + _tid*nall; - _D_values = D_values + _tid*nall; - if (nall > 0) { + if (nall >= 0 && rhoB && D_values) { + _rhoB = rhoB + _tid*nall; + _D_values = D_values + _tid*nall; memset(_rhoB, 0, nall*sizeof(double)); memset(_D_values, 0, nall*sizeof(double)); } @@ -155,8 +156,8 @@ void ThrData::init_eim(int nall, double *rho, double *fp) { init_eam(nall, rho); - _fp = fp + _tid*nall; - if (nall > 0) + if (nall >= 0 && fp) + _fp = fp + _tid*nall; memset(_fp,0,nall*sizeof(double)); } diff --git a/src/USER-OMP/thr_omp.cpp b/src/USER-OMP/thr_omp.cpp index 4462f70bf1140cb9b0430230f6c4631847f8e461..ed3e82f5396255146a07cd36ebd0e9dbe821c3e7 100644 --- a/src/USER-OMP/thr_omp.cpp +++ b/src/USER-OMP/thr_omp.cpp @@ -513,6 +513,18 @@ void ThrOMP::ev_tally_thr(Pair * const pair, const int i, const int j, const int v_tally_thr(pair, i, j, nlocal, newton_pair, v, thr); } + + if (pair->num_tally_compute > 0) { + // ev_tally callbacks are not thread safe and thus have to be protected +#if defined(_OPENMP) +#pragma omp critical +#endif + for (int k=0; k < pair->num_tally_compute; ++k) { + Compute *c = pair->list_tally_compute[k]; + c->pair_tally_callback(i, j, nlocal, newton_pair, + evdwl, ecoul, fpair, delx, dely, delz); + } + } } /* ---------------------------------------------------------------------- diff --git a/src/fix_temp_berendsen.cpp b/src/fix_temp_berendsen.cpp index dc91056227a6008dbcc39445b1b7cd32f8f23d3e..e4b245245583c3ab58faba4cd41e4f2d9e8762b0 100644 --- a/src/fix_temp_berendsen.cpp +++ b/src/fix_temp_berendsen.cpp @@ -138,6 +138,10 @@ void FixTempBerendsen::end_of_step() double t_current = temperature->compute_scalar(); double tdof = temperature->dof; + // there is nothing to do, if there are no degrees of freedom + + if (tdof < 1) return; + if (t_current == 0.0) error->all(FLERR, "Computed temperature for fix temp/berendsen cannot be 0.0"); diff --git a/src/fix_temp_csld.cpp b/src/fix_temp_csld.cpp index e394f06e58c3b3718b8ecf3c762dbabc61f00378..28235b00fcb336f9bae999372917dc822d09555a 100644 --- a/src/fix_temp_csld.cpp +++ b/src/fix_temp_csld.cpp @@ -183,6 +183,10 @@ void FixTempCSLD::end_of_step() double t_current = temperature->compute_scalar(); double ekin_old = t_current * 0.5 * temperature->dof * force->boltz; + // there is nothing to do, if there are no degrees of freedom + + if (temperature->dof < 1) return; + double * const * const v = atom->v; const int * const mask = atom->mask; const int * const type = atom->type; diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index deaa8f91ecbf066d47a311ad0928d7d3c164d742..6171e688c042c33471a5fae3e7456bab29a98350 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -244,7 +244,12 @@ void FixTempCSVR::end_of_step() const double ekin_old = t_current * efactor; const double ekin_new = t_target * efactor; + // there is nothing to do, if there are no degrees of freedom + + if (temperature->dof < 1) return; + // compute velocity scaling factor on root node and broadcast + double lamda; if (comm->me == 0) { lamda = resamplekin(ekin_old, ekin_new); diff --git a/src/fix_temp_rescale.cpp b/src/fix_temp_rescale.cpp index 23c26aa02cec57373dbdd8a8f2aba1e4481504f7..b84bab20c7113e9dc5fae83d6378761b2005be00 100644 --- a/src/fix_temp_rescale.cpp +++ b/src/fix_temp_rescale.cpp @@ -133,6 +133,13 @@ void FixTempRescale::init() void FixTempRescale::end_of_step() { double t_current = temperature->compute_scalar(); + + // there is nothing to do, if there are no degrees of freedom + + if (temperature->dof < 1) return; + + // protect against division by zero. + if (t_current == 0.0) error->all(FLERR,"Computed temperature for fix temp/rescale cannot be 0.0"); diff --git a/src/pair.h b/src/pair.h index 3d73fc1a93bf5e95f2ae18b36f9ab5be0eecd82a..d1a41fbee6cd39fdbfcb16c4de3b2a35fb3a6615 100644 --- a/src/pair.h +++ b/src/pair.h @@ -188,7 +188,7 @@ class Pair : protected Pointers { // management of callbacks to be run from ev_tally() - private: + protected: int num_tally_compute; class Compute **list_tally_compute; public: