diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 51f94107f2..fdd800f3a7 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -204,10 +204,6 @@ double ComputeTempChunk::compute_scalar() cchunk->compute_ichunk(); int *ichunk = cchunk->ichunk; - // calculate COM velocity for each chunk - - if (comflag && comstep != update->ntimestep) vcm_compute(); - // remove velocity bias if (biasflag) { @@ -215,6 +211,11 @@ double ComputeTempChunk::compute_scalar() tbias->remove_bias_all(); } + // calculate COM velocity for each chunk + // won't be invoked with bias also removed = 2 biases + + if (comflag && comstep != update->ntimestep) vcm_compute(); + // calculate global temperature, optionally removing COM velocity double **v = atom->v; @@ -311,10 +312,6 @@ void ComputeTempChunk::compute_vector() cchunk->compute_ichunk(); int *ichunk = cchunk->ichunk; - // calculate COM velocity for each chunk - - if (comflag && comstep != update->ntimestep) vcm_compute(); - // remove velocity bias if (biasflag) { @@ -322,6 +319,11 @@ void ComputeTempChunk::compute_vector() tbias->remove_bias_all(); } + // calculate COM velocity for each chunk + // won't be invoked with bias also removed = 2 biases + + if (comflag && comstep != update->ntimestep) vcm_compute(); + // calculate KE tensor, optionally removing COM velocity double **v = atom->v; @@ -397,11 +399,6 @@ void ComputeTempChunk::compute_array() if (nchunk > maxchunk) allocate(); size_array_rows = nchunk; - // calculate COM velocity for each chunk whether comflag set or not - // needed by some values even if comflag not set - - if (comstep != update->ntimestep) vcm_compute(); - // remove velocity bias if (biasflag) { @@ -409,6 +406,13 @@ void ComputeTempChunk::compute_array() tbias->remove_bias_all(); } + // calculate COM velocity for each chunk whether comflag set or not + // needed by some values even if comflag not set + // important to do this after velocity bias is removed + // otherwise per-chunk values that use both v and vcm will be inconsistent + + if (comstep != update->ntimestep) vcm_compute(); + // compute each value for (int i = 0; i < nvalues; i++) {