git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13951 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2015-08-28 23:36:43 +00:00
parent 0f3d77ed75
commit 4e247c3b8c
7 changed files with 44 additions and 11 deletions

View File

@ -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));
}

View File

@ -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);
}
}
}
/* ----------------------------------------------------------------------

View File

@ -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");

View File

@ -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;

View File

@ -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);

View File

@ -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");

View File

@ -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: