diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 26e625ee69..b61aa0607d 100644 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -371,6 +371,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 @@ -380,3 +389,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); +} diff --git a/src/ASPHERE/compute_temp_asphere.h b/src/ASPHERE/compute_temp_asphere.h index b08ffbfd91..1e393568cf 100644 --- a/src/ASPHERE/compute_temp_asphere.h +++ b/src/ASPHERE/compute_temp_asphere.h @@ -34,6 +34,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 fix_dof,mode; diff --git a/src/USER-MISC/compute_temp_rotate.cpp b/src/USER-MISC/compute_temp_rotate.cpp index af5da2ee08..24b3e7531d 100644 --- a/src/USER-MISC/compute_temp_rotate.cpp +++ b/src/USER-MISC/compute_temp_rotate.cpp @@ -217,6 +217,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 ------------------------------------------------------------------------- */ @@ -247,6 +258,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 diff --git a/src/USER-MISC/compute_temp_rotate.h b/src/USER-MISC/compute_temp_rotate.h index 895fe8218f..bebe6e49e6 100644 --- a/src/USER-MISC/compute_temp_rotate.h +++ b/src/USER-MISC/compute_temp_rotate.h @@ -33,9 +33,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: diff --git a/src/USER-OMP/fix_nh_asphere_omp.cpp b/src/USER-OMP/fix_nh_asphere_omp.cpp index 9aa7108b83..67c3a67583 100644 --- a/src/USER-OMP/fix_nh_asphere_omp.cpp +++ b/src/USER-OMP/fix_nh_asphere_omp.cpp @@ -188,12 +188,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; diff --git a/src/USER-OMP/fix_nh_omp.cpp b/src/USER-OMP/fix_nh_omp.cpp index 34de7a4b78..38c3edf2e3 100644 --- a/src/USER-OMP/fix_nh_omp.cpp +++ b/src/USER-OMP/fix_nh_omp.cpp @@ -266,8 +266,9 @@ void FixNHOMP::nh_v_press() #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 *= factor0; v[i].y *= factor1; v[i].z *= factor2; @@ -278,7 +279,7 @@ void FixNHOMP::nh_v_press() v[i].x *= factor0; v[i].y *= factor1; v[i].z *= factor2; - temperature->restore_bias(i,&v[i].x); + temperature->restore_bias_thr(i,&v[i].x,buf); } } } @@ -378,12 +379,13 @@ void FixNHOMP::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); } } } diff --git a/src/USER-OMP/fix_nh_sphere_omp.cpp b/src/USER-OMP/fix_nh_sphere_omp.cpp index 48425b0bcd..f5adf3daeb 100644 --- a/src/USER-OMP/fix_nh_sphere_omp.cpp +++ b/src/USER-OMP/fix_nh_sphere_omp.cpp @@ -141,12 +141,13 @@ void FixNHSphereOMP::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); omega[i].x *= factor_eta; omega[i].y *= factor_eta; omega[i].z *= factor_eta; diff --git a/src/USER-OMP/fix_nvt_sllod_omp.cpp b/src/USER-OMP/fix_nvt_sllod_omp.cpp index 71de7ee7d9..7d9c815b5b 100644 --- a/src/USER-OMP/fix_nvt_sllod_omp.cpp +++ b/src/USER-OMP/fix_nvt_sllod_omp.cpp @@ -126,16 +126,16 @@ void FixNVTSllodOMP::nh_v_temp() #pragma omp parallel for default(none) private(i) shared(h_two) schedule(static) #endif for (i = 0; i < nlocal; i++) { - double vdelu0,vdelu1,vdelu2; + double vdelu0,vdelu1,vdelu2,buf[3]; if (mask[i] & groupbit) { vdelu0 = h_two[0]*v[i].x + h_two[5]*v[i].y + h_two[4]*v[i].z; vdelu1 = h_two[1]*v[i].y + h_two[3]*v[i].z; vdelu2 = h_two[2]*v[i].z; - temperature->remove_bias(i,&v[i].x); + temperature->remove_bias_thr(i,&v[i].x,buf); v[i].x = v[i].x*factor_eta - dthalf*vdelu0; v[i].y = v[i].y*factor_eta - dthalf*vdelu1; v[i].z = v[i].z*factor_eta - dthalf*vdelu2; - temperature->restore_bias(i,&v[i].x); + temperature->restore_bias_thr(i,&v[i].x,buf); } } } diff --git a/src/compute.h b/src/compute.h index c2c90d40bd..ccbc39fae9 100644 --- a/src/compute.h +++ b/src/compute.h @@ -103,8 +103,10 @@ class Compute : protected Pointers { virtual int dof_remove(int) {return 0;} virtual void remove_bias(int, double *) {} + virtual void remove_bias_thr(int, double *, double *) {} virtual void remove_bias_all() {} virtual void restore_bias(int, double *) {} + virtual void restore_bias_thr(int, double *, double *) {} virtual void restore_bias_all() {} virtual void reset_extra_compute_fix(const char *); diff --git a/src/compute_temp_com.cpp b/src/compute_temp_com.cpp index ef51d122d4..fd3fdac3b3 100644 --- a/src/compute_temp_com.cpp +++ b/src/compute_temp_com.cpp @@ -166,6 +166,17 @@ void ComputeTempCOM::remove_bias(int, double *v) v[2] -= vbias[2]; } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempCOM::remove_bias_thr(int, double *v, double *) +{ + v[0] -= vbias[0]; + v[1] -= vbias[1]; + v[2] -= vbias[2]; +} + /* ---------------------------------------------------------------------- remove velocity bias from all atoms to leave thermal velocity ------------------------------------------------------------------------- */ @@ -196,6 +207,18 @@ void ComputeTempCOM::restore_bias(int, double *v) v[2] += vbias[2]; } +/* ---------------------------------------------------------------------- + add back in velocity bias to atom I removed by remove_bias_thr() + assume remove_bias_thr() was previously called +------------------------------------------------------------------------- */ + +void ComputeTempCOM::restore_bias_thr(int, double *v, double *) +{ + v[0] += vbias[0]; + v[1] += vbias[1]; + v[2] += vbias[2]; +} + /* ---------------------------------------------------------------------- add back in velocity bias to all atoms removed by remove_bias_all() assume remove_bias_all() was previously called diff --git a/src/compute_temp_com.h b/src/compute_temp_com.h index f940ba22f5..9f7746ccef 100644 --- a/src/compute_temp_com.h +++ b/src/compute_temp_com.h @@ -33,9 +33,11 @@ class ComputeTempCOM : 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 *); private: int fix_dof; diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index 611cbdd3be..b4befbc12f 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -214,6 +214,26 @@ void ComputeTempDeform::remove_bias(int i, double *v) v[2] -= vbias[2]; } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempDeform::remove_bias_thr(int i, double *v, double *b) +{ + double lamda[3]; + double *h_rate = domain->h_rate; + double *h_ratelo = domain->h_ratelo; + + domain->x2lamda(atom->x[i],lamda); + b[0] = h_rate[0]*lamda[0] + h_rate[5]*lamda[1] + + h_rate[4]*lamda[2] + h_ratelo[0]; + b[1] = h_rate[1]*lamda[1] + h_rate[3]*lamda[2] + h_ratelo[1]; + b[2] = h_rate[2]*lamda[2] + h_ratelo[2]; + v[0] -= b[0]; + v[1] -= b[1]; + v[2] -= b[2]; +} + /* ---------------------------------------------------------------------- remove velocity bias from all atoms to leave thermal velocity ------------------------------------------------------------------------- */ @@ -259,6 +279,18 @@ void ComputeTempDeform::restore_bias(int i, double *v) v[2] += vbias[2]; } +/* ---------------------------------------------------------------------- + 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 ComputeTempDeform::restore_bias_thr(int i, double *v, double *b) +{ + v[0] += b[0]; + v[1] += b[1]; + v[2] += b[2]; +} + /* ---------------------------------------------------------------------- add back in velocity bias to all atoms removed by remove_bias_all() assume remove_bias_all() was previously called diff --git a/src/compute_temp_deform.h b/src/compute_temp_deform.h index 3400ed6db4..dfd1479992 100644 --- a/src/compute_temp_deform.h +++ b/src/compute_temp_deform.h @@ -33,8 +33,10 @@ class ComputeTempDeform : public Compute { virtual 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_thr(int, double *, double *); void restore_bias_all(); double memory_usage(); diff --git a/src/compute_temp_partial.cpp b/src/compute_temp_partial.cpp index dbc81bfe0d..ea55ffc9cd 100644 --- a/src/compute_temp_partial.cpp +++ b/src/compute_temp_partial.cpp @@ -179,6 +179,26 @@ void ComputeTempPartial::remove_bias(int i, double *v) } } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempPartial::remove_bias_thr(int i, double *v, double *b) +{ + if (!xflag) { + b[0] = v[0]; + v[0] = 0.0; + } + if (!yflag) { + b[1] = v[1]; + v[1] = 0.0; + } + if (!zflag) { + b[2] = v[2]; + v[2] = 0.0; + } +} + /* ---------------------------------------------------------------------- remove velocity bias from all atoms to leave thermal velocity ------------------------------------------------------------------------- */ @@ -230,6 +250,18 @@ void ComputeTempPartial::restore_bias(int i, double *v) if (!zflag) v[2] += vbias[2]; } +/* ---------------------------------------------------------------------- + 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 ComputeTempPartial::restore_bias_thr(int i, double *v, double *b) +{ + if (!xflag) v[0] += b[0]; + if (!yflag) v[1] += b[1]; + if (!zflag) v[2] += b[2]; +} + /* ---------------------------------------------------------------------- add back in velocity bias to all atoms removed by remove_bias_all() assume remove_bias_all() was previously called diff --git a/src/compute_temp_partial.h b/src/compute_temp_partial.h index e73ade0352..bbf3c5090f 100644 --- a/src/compute_temp_partial.h +++ b/src/compute_temp_partial.h @@ -34,8 +34,10 @@ class ComputeTempPartial : public Compute { int dof_remove(int); void remove_bias(int, double *); + void remove_bias_thr(int, double *, double *); void remove_bias_all(); void restore_bias(int, double *); + void restore_bias_thr(int, double *, double *); void restore_bias_all(); double memory_usage(); diff --git a/src/compute_temp_profile.cpp b/src/compute_temp_profile.cpp index 6e0470020c..1172b9d89c 100644 --- a/src/compute_temp_profile.cpp +++ b/src/compute_temp_profile.cpp @@ -349,6 +349,15 @@ void ComputeTempProfile::remove_bias(int i, double *v) if (zflag) v[2] -= binave[ibin][ivz]; } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempProfile::remove_bias_thr(int i, double *v, double *) +{ + remove_bias(i,v); +} + /* ---------------------------------------------------------------------- remove velocity bias from all atoms to leave thermal velocity ------------------------------------------------------------------------- */ @@ -382,6 +391,16 @@ void ComputeTempProfile::restore_bias(int i, double *v) if (zflag) v[2] += binave[ibin][ivz]; } +/* ---------------------------------------------------------------------- + add back in velocity bias to atom I removed by remove_bias_thr() + assume remove_bias_thr() was previously called +------------------------------------------------------------------------- */ + +void ComputeTempProfile::restore_bias_thr(int i, double *v, double *) +{ + restore_bias(i,v); +} + /* ---------------------------------------------------------------------- add back in velocity bias to all atoms removed by remove_bias_all() assume remove_bias_all() was previously called diff --git a/src/compute_temp_profile.h b/src/compute_temp_profile.h index e282400a07..76ee7955bf 100644 --- a/src/compute_temp_profile.h +++ b/src/compute_temp_profile.h @@ -34,8 +34,10 @@ class ComputeTempProfile : public Compute { void compute_array(); void remove_bias(int, double *); + void remove_bias_thr(int, double *, double *); void remove_bias_all(); void restore_bias(int, double *); + void restore_bias_thr(int, double *, double *); void restore_bias_all(); double memory_usage(); diff --git a/src/compute_temp_ramp.cpp b/src/compute_temp_ramp.cpp index 4bd073d642..85213ab921 100644 --- a/src/compute_temp_ramp.cpp +++ b/src/compute_temp_ramp.cpp @@ -237,6 +237,19 @@ void ComputeTempRamp::remove_bias(int i, double *v) v[v_dim] -= vbias[v_dim]; } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempRamp::remove_bias_thr(int i, double *v, double *b) +{ + double fraction = (atom->x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo); + fraction = MAX(fraction,0.0); + fraction = MIN(fraction,1.0); + b[v_dim] = v_lo + fraction*(v_hi - v_lo); + v[v_dim] -= b[v_dim]; +} + /* ---------------------------------------------------------------------- remove velocity bias from all atoms to leave thermal velocity ------------------------------------------------------------------------- */ @@ -274,6 +287,16 @@ void ComputeTempRamp::restore_bias(int i, double *v) v[v_dim] += vbias[v_dim]; } +/* ---------------------------------------------------------------------- + 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 ComputeTempRamp::restore_bias_thr(int i, double *v, double *b) +{ + v[v_dim] += b[v_dim]; +} + /* ---------------------------------------------------------------------- add back in velocity bias to all atoms removed by remove_bias_all() assume remove_bias_all() was previously called diff --git a/src/compute_temp_ramp.h b/src/compute_temp_ramp.h index a3d1f47e6e..aa833f47dd 100644 --- a/src/compute_temp_ramp.h +++ b/src/compute_temp_ramp.h @@ -34,7 +34,9 @@ class ComputeTempRamp : public Compute { void remove_bias(int, double *); void remove_bias_all(); + void remove_bias_thr(int, double *, double *); void restore_bias(int, double *); + void restore_bias_thr(int, double *, double *); void restore_bias_all(); double memory_usage(); diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 69f5f3909e..38d06a793c 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -178,6 +178,23 @@ void ComputeTempRegion::remove_bias(int i, double *v) } } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempRegion::remove_bias_thr(int i, double *v, double *b) +{ + double *x = atom->x[i]; + if (domain->regions[iregion]->match(x[0],x[1],x[2])) + b[0] = b[1] = b[2] = 0.0; + else { + b[0] = v[0]; + b[1] = v[1]; + b[2] = v[2]; + v[0] = v[1] = v[2] = 0.0; + } +} + /* ---------------------------------------------------------------------- remove velocity bias from all atoms to leave thermal velocity ------------------------------------------------------------------------- */ @@ -222,6 +239,18 @@ void ComputeTempRegion::restore_bias(int i, double *v) v[2] += vbias[2]; } +/* ---------------------------------------------------------------------- + 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 ComputeTempRegion::restore_bias_thr(int i, double *v, double *b) +{ + v[0] += b[0]; + v[1] += b[1]; + v[2] += b[2]; +} + /* ---------------------------------------------------------------------- add back in velocity bias to all atoms removed by remove_bias_all() assume remove_bias_all() was previously called diff --git a/src/compute_temp_region.h b/src/compute_temp_region.h index c980a04ca1..a95e9c20b6 100644 --- a/src/compute_temp_region.h +++ b/src/compute_temp_region.h @@ -33,10 +33,13 @@ class ComputeTempRegion : public Compute { virtual void compute_vector(); int dof_remove(int); + 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(); protected: diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 2c4b4c420d..f3d9880f1e 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -313,6 +313,15 @@ void ComputeTempSphere::remove_bias(int i, double *v) tbias->remove_bias(i,v); } +/* ---------------------------------------------------------------------- + remove velocity bias from atom I to leave thermal velocity +------------------------------------------------------------------------- */ + +void ComputeTempSphere::remove_bias_thr(int i, double *v, double *b) +{ + 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 @@ -322,3 +331,13 @@ void ComputeTempSphere::restore_bias(int i, double *v) { 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 ComputeTempSphere::restore_bias_thr(int i, double *v, double *b) +{ + tbias->restore_bias_thr(i,v,b); +} diff --git a/src/compute_temp_sphere.h b/src/compute_temp_sphere.h index 6f8f984981..27286cc091 100644 --- a/src/compute_temp_sphere.h +++ b/src/compute_temp_sphere.h @@ -33,7 +33,9 @@ class ComputeTempSphere : public Compute { void compute_vector(); void remove_bias(int, double *); + void remove_bias_thr(int, double *, double *); void restore_bias(int, double *); + void restore_bias_thr(int, double *, double *); private: int fix_dof,mode;