diff --git a/src/ASPHERE/fix_npt_asphere.cpp b/src/ASPHERE/fix_npt_asphere.cpp index 2625bc6391..205630376a 100755 --- a/src/ASPHERE/fix_npt_asphere.cpp +++ b/src/ASPHERE/fix_npt_asphere.cpp @@ -46,7 +46,7 @@ FixNPTAsphere::FixNPTAsphere(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTAsphere::FixNPTAsphere(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/ASPHERE/fix_nvt_asphere.cpp b/src/ASPHERE/fix_nvt_asphere.cpp index 5b8b943ab4..f43e731c23 100755 --- a/src/ASPHERE/fix_nvt_asphere.cpp +++ b/src/ASPHERE/fix_nvt_asphere.cpp @@ -45,5 +45,5 @@ FixNVTAsphere::FixNVTAsphere(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/BODY/fix_nph_body.cpp b/src/BODY/fix_nph_body.cpp index 1808b9ade8..99e33a3d22 100644 --- a/src/BODY/fix_nph_body.cpp +++ b/src/BODY/fix_nph_body.cpp @@ -50,7 +50,7 @@ FixNPHBody::FixNPHBody(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -68,5 +68,5 @@ FixNPHBody::FixNPHBody(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/BODY/fix_npt_body.cpp b/src/BODY/fix_npt_body.cpp index 17014ba17c..077a7babd4 100755 --- a/src/BODY/fix_npt_body.cpp +++ b/src/BODY/fix_npt_body.cpp @@ -50,7 +50,7 @@ FixNPTBody::FixNPTBody(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -68,5 +68,5 @@ FixNPTBody::FixNPTBody(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/BODY/fix_nvt_body.cpp b/src/BODY/fix_nvt_body.cpp index d6601f4966..464f42eae9 100755 --- a/src/BODY/fix_nvt_body.cpp +++ b/src/BODY/fix_nvt_body.cpp @@ -49,5 +49,5 @@ FixNVTBody::FixNVTBody(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/KOKKOS/fix_nph_kokkos.cpp b/src/KOKKOS/fix_nph_kokkos.cpp index 350832a3d7..f3f7c271d6 100755 --- a/src/KOKKOS/fix_nph_kokkos.cpp +++ b/src/KOKKOS/fix_nph_kokkos.cpp @@ -47,7 +47,7 @@ FixNPHKokkos::FixNPHKokkos(LAMMPS *lmp, int narg, char **arg) : this->modify->add_compute(3,newarg); delete [] newarg; - this->tflag = 1; + this->tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -65,7 +65,7 @@ FixNPHKokkos::FixNPHKokkos(LAMMPS *lmp, int narg, char **arg) : newarg[3] = this->id_temp; this->modify->add_compute(4,newarg); delete [] newarg; - this->pflag = 1; + this->pcomputeflag = 1; } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_npt_kokkos.cpp b/src/KOKKOS/fix_npt_kokkos.cpp index 3832fb3e57..bbc26b8e88 100755 --- a/src/KOKKOS/fix_npt_kokkos.cpp +++ b/src/KOKKOS/fix_npt_kokkos.cpp @@ -47,7 +47,7 @@ FixNPTKokkos::FixNPTKokkos(LAMMPS *lmp, int narg, char **arg) : this->modify->add_compute(3,newarg); delete [] newarg; - this->tflag = 1; + this->tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -65,7 +65,7 @@ FixNPTKokkos::FixNPTKokkos(LAMMPS *lmp, int narg, char **arg) : newarg[3] = this->id_temp; this->modify->add_compute(4,newarg); delete [] newarg; - this->pflag = 1; + this->pcomputeflag = 1; } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_nvt_kokkos.cpp b/src/KOKKOS/fix_nvt_kokkos.cpp index bf6ce0de2b..c479251c33 100755 --- a/src/KOKKOS/fix_nvt_kokkos.cpp +++ b/src/KOKKOS/fix_nvt_kokkos.cpp @@ -46,7 +46,7 @@ FixNVTKokkos::FixNVTKokkos(LAMMPS *lmp, int narg, char **arg) : this->modify->add_compute(3,newarg); delete [] newarg; - this->tflag = 1; + this->tcomputeflag = 1; } namespace LAMMPS_NS { diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 7456c08791..aa030540f4 100755 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -488,13 +488,16 @@ void PairVashishta::setup_params() // set cutsq using shortcut to reduce neighbor list for accelerated // calculations. cut must remain unchanged as it is a potential parameter + double tmp_par; for (m = 0; m < nparams; m++) { params[m].cutsq = params[m].cut * params[m].cut; params[m].cutsq2 = params[m].r0 * params[m].r0; - params[m].lam1inv = 1.0/params[m].lambda1; - params[m].lam4inv = 1.0/params[m].lambda4; + tmp_par = params[m].lambda1; + params[m].lam1inv = (tmp_par == 0.0) ? 0.0 : 1.0/tmp_par; + tmp_par = params[m].lambda4; + params[m].lam4inv = (tmp_par == 0.0) ? 0.0 : 1.0/tmp_par; params[m].zizj = params[m].zi*params[m].zj * force->qqr2e; // note that bigd does not have 1/2 factor params[m].mbigd = params[m].bigd; @@ -502,8 +505,9 @@ void PairVashishta::setup_params() params[m].big2b = 2.0*params[m].bigb; params[m].big6w = 6.0*params[m].bigw; - params[m].rcinv = 1.0/params[m].cut; - params[m].rc2inv = 1.0/params[m].cutsq; + tmp_par = params[m].cut; + params[m].rcinv = (tmp_par == 0.0) ? 0.0 : 1.0/tmp_par; + params[m].rc2inv = params[m].rcinv*params[m].rcinv; params[m].rc4inv = params[m].rc2inv*params[m].rc2inv; params[m].rc6inv = params[m].rc2inv*params[m].rc4inv; params[m].rceta = pow(params[m].rcinv,params[m].eta); diff --git a/src/MC/fix_tfmc.cpp b/src/MC/fix_tfmc.cpp index eea0a0bf31..8ce1308694 100755 --- a/src/MC/fix_tfmc.cpp +++ b/src/MC/fix_tfmc.cpp @@ -229,9 +229,12 @@ void FixTFMC::initial_integrate(int vflag) // zero com motion if (comflag == 1 && group->count(igroup) != 0) { MPI_Allreduce(xcm_d,xcm_dall,3,MPI_DOUBLE,MPI_SUM,world); - xcm_dall[0] /= masstotal; - xcm_dall[1] /= masstotal; - xcm_dall[2] /= masstotal; + if (masstotal > 0.0) { + xcm_dall[0] /= masstotal; + xcm_dall[1] /= masstotal; + xcm_dall[2] /= masstotal; + } else xcm_dall[0] = xcm_dall[1] = xcm_dall[2] = 0.0; + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (xflag) x[i][0] -= xcm_dall[0]; diff --git a/src/RIGID/fix_rigid_nh.cpp b/src/RIGID/fix_rigid_nh.cpp index 5db799e9f0..a2c6c338b7 100644 --- a/src/RIGID/fix_rigid_nh.cpp +++ b/src/RIGID/fix_rigid_nh.cpp @@ -148,6 +148,9 @@ FixRigidNH::FixRigidNH(LAMMPS *lmp, int narg, char **arg) : tcomputeflag = 0; pcomputeflag = 0; + + id_temp = NULL; + id_press = NULL; } /* ---------------------------------------------------------------------- */ @@ -162,10 +165,8 @@ FixRigidNH::~FixRigidNH() if (rfix) delete [] rfix; - if (tcomputeflag) { - modify->delete_compute(id_temp); - delete [] id_temp; - } + if (tcomputeflag) modify->delete_compute(id_temp); + delete [] id_temp; // delete pressure if fix created it @@ -1265,7 +1266,6 @@ int FixRigidNH::modify_param(int narg, char **arg) { if (strcmp(arg[0],"temp") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); - if (!pstat_flag) error->all(FLERR,"Illegal fix_modify command"); if (tcomputeflag) { modify->delete_compute(id_temp); tcomputeflag = 0; diff --git a/src/RIGID/fix_rigid_nh.h b/src/RIGID/fix_rigid_nh.h index 684579b8af..08208e5aac 100644 --- a/src/RIGID/fix_rigid_nh.h +++ b/src/RIGID/fix_rigid_nh.h @@ -69,7 +69,7 @@ class FixRigidNH : public FixRigid { char *id_temp,*id_press; class Compute *temperature,*pressure; - int tcomputeflag,pcomputeflag; + int tcomputeflag,pcomputeflag; // 1 = compute was created by fix. 0 = external void couple(); void remap(); diff --git a/src/RIGID/fix_rigid_nh_small.cpp b/src/RIGID/fix_rigid_nh_small.cpp index 5708bb6602..d8ec174f72 100644 --- a/src/RIGID/fix_rigid_nh_small.cpp +++ b/src/RIGID/fix_rigid_nh_small.cpp @@ -163,6 +163,9 @@ FixRigidNHSmall::FixRigidNHSmall(LAMMPS *lmp, int narg, char **arg) : tcomputeflag = 0; pcomputeflag = 0; + + id_temp = NULL; + id_press = NULL; } /* ---------------------------------------------------------------------- */ @@ -176,10 +179,8 @@ FixRigidNHSmall::~FixRigidNHSmall() if (rfix) delete [] rfix; - if (tcomputeflag) { - modify->delete_compute(id_temp); - delete [] id_temp; - } + if (tcomputeflag) modify->delete_compute(id_temp); + delete [] id_temp; // delete pressure if fix created it @@ -1374,7 +1375,6 @@ int FixRigidNHSmall::modify_param(int narg, char **arg) { if (strcmp(arg[0],"temp") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); - if (!pstat_flag) error->all(FLERR,"Illegal fix_modify command"); if (tcomputeflag) { modify->delete_compute(id_temp); tcomputeflag = 0; diff --git a/src/RIGID/fix_rigid_nh_small.h b/src/RIGID/fix_rigid_nh_small.h index f771b8c41b..07510a59e3 100644 --- a/src/RIGID/fix_rigid_nh_small.h +++ b/src/RIGID/fix_rigid_nh_small.h @@ -68,7 +68,7 @@ class FixRigidNHSmall : public FixRigidSmall { char *id_temp,*id_press; class Compute *temperature,*pressure; - int tcomputeflag,pcomputeflag; + int tcomputeflag,pcomputeflag; // 1 = compute was created by fix. 0 = external void couple(); void remap(); diff --git a/src/SHOCK/fix_nphug.cpp b/src/SHOCK/fix_nphug.cpp index 480b667254..7fc0f8a381 100644 --- a/src/SHOCK/fix_nphug.cpp +++ b/src/SHOCK/fix_nphug.cpp @@ -135,7 +135,7 @@ FixNPHug::FixNPHug(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -153,7 +153,7 @@ FixNPHug::FixNPHug(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; // create a new compute potential energy compute diff --git a/src/USER-EFF/fix_nph_eff.cpp b/src/USER-EFF/fix_nph_eff.cpp index dc6bfe20d5..0fe8c8e6db 100644 --- a/src/USER-EFF/fix_nph_eff.cpp +++ b/src/USER-EFF/fix_nph_eff.cpp @@ -46,7 +46,7 @@ FixNPHEff::FixNPHEff(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPHEff::FixNPHEff(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-EFF/fix_npt_eff.cpp b/src/USER-EFF/fix_npt_eff.cpp index 36a6f87cba..02f09839b1 100644 --- a/src/USER-EFF/fix_npt_eff.cpp +++ b/src/USER-EFF/fix_npt_eff.cpp @@ -46,7 +46,7 @@ FixNPTEff::FixNPTEff(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTEff::FixNPTEff(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-EFF/fix_nvt_eff.cpp b/src/USER-EFF/fix_nvt_eff.cpp index 36a9ff3293..ab82f9e0f8 100644 --- a/src/USER-EFF/fix_nvt_eff.cpp +++ b/src/USER-EFF/fix_nvt_eff.cpp @@ -46,5 +46,5 @@ FixNVTEff::FixNVTEff(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/USER-EFF/fix_nvt_sllod_eff.cpp b/src/USER-EFF/fix_nvt_sllod_eff.cpp index 1f6dea658f..1b4ec1f3fb 100644 --- a/src/USER-EFF/fix_nvt_sllod_eff.cpp +++ b/src/USER-EFF/fix_nvt_sllod_eff.cpp @@ -58,7 +58,7 @@ FixNVTSllodEff::FixNVTSllodEff(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-INTEL/fix_npt_intel.cpp b/src/USER-INTEL/fix_npt_intel.cpp index 150464413e..2bfbd5e735 100644 --- a/src/USER-INTEL/fix_npt_intel.cpp +++ b/src/USER-INTEL/fix_npt_intel.cpp @@ -46,7 +46,7 @@ FixNPTIntel::FixNPTIntel(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTIntel::FixNPTIntel(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-INTEL/fix_nvt_intel.cpp b/src/USER-INTEL/fix_nvt_intel.cpp index 65854b07a8..3fe712c9ab 100644 --- a/src/USER-INTEL/fix_nvt_intel.cpp +++ b/src/USER-INTEL/fix_nvt_intel.cpp @@ -45,6 +45,6 @@ FixNVTIntel::FixNVTIntel(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/USER-INTEL/fix_nvt_sllod_intel.cpp b/src/USER-INTEL/fix_nvt_sllod_intel.cpp index 5505abb9ce..bab748ad74 100644 --- a/src/USER-INTEL/fix_nvt_sllod_intel.cpp +++ b/src/USER-INTEL/fix_nvt_sllod_intel.cpp @@ -59,7 +59,7 @@ FixNVTSllodIntel::FixNVTSllodIntel(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-OMP/fix_nph_asphere_omp.cpp b/src/USER-OMP/fix_nph_asphere_omp.cpp index 3e0a6c9df0..dfcbc87e6f 100644 --- a/src/USER-OMP/fix_nph_asphere_omp.cpp +++ b/src/USER-OMP/fix_nph_asphere_omp.cpp @@ -46,7 +46,7 @@ FixNPHAsphereOMP::FixNPHAsphereOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPHAsphereOMP::FixNPHAsphereOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-OMP/fix_nph_omp.cpp b/src/USER-OMP/fix_nph_omp.cpp index be21da2eed..f2a4e66f55 100644 --- a/src/USER-OMP/fix_nph_omp.cpp +++ b/src/USER-OMP/fix_nph_omp.cpp @@ -46,7 +46,7 @@ FixNPHOMP::FixNPHOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPHOMP::FixNPHOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-OMP/fix_nph_sphere_omp.cpp b/src/USER-OMP/fix_nph_sphere_omp.cpp index a5626f9d1c..670009de2f 100644 --- a/src/USER-OMP/fix_nph_sphere_omp.cpp +++ b/src/USER-OMP/fix_nph_sphere_omp.cpp @@ -46,7 +46,7 @@ FixNPHSphereOMP::FixNPHSphereOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPHSphereOMP::FixNPHSphereOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-OMP/fix_nphug_omp.cpp b/src/USER-OMP/fix_nphug_omp.cpp index 7721781769..b652cf563a 100644 --- a/src/USER-OMP/fix_nphug_omp.cpp +++ b/src/USER-OMP/fix_nphug_omp.cpp @@ -135,7 +135,7 @@ FixNPHugOMP::FixNPHugOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -153,7 +153,7 @@ FixNPHugOMP::FixNPHugOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; // create a new compute potential energy compute diff --git a/src/USER-OMP/fix_npt_asphere_omp.cpp b/src/USER-OMP/fix_npt_asphere_omp.cpp index 00bafe661a..1db62d40c0 100644 --- a/src/USER-OMP/fix_npt_asphere_omp.cpp +++ b/src/USER-OMP/fix_npt_asphere_omp.cpp @@ -46,7 +46,7 @@ FixNPTAsphereOMP::FixNPTAsphereOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTAsphereOMP::FixNPTAsphereOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-OMP/fix_npt_omp.cpp b/src/USER-OMP/fix_npt_omp.cpp index c4af48542a..5610f62f36 100644 --- a/src/USER-OMP/fix_npt_omp.cpp +++ b/src/USER-OMP/fix_npt_omp.cpp @@ -46,7 +46,7 @@ FixNPTOMP::FixNPTOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTOMP::FixNPTOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-OMP/fix_npt_sphere_omp.cpp b/src/USER-OMP/fix_npt_sphere_omp.cpp index 6baee93cb4..d71d1380b9 100644 --- a/src/USER-OMP/fix_npt_sphere_omp.cpp +++ b/src/USER-OMP/fix_npt_sphere_omp.cpp @@ -46,7 +46,7 @@ FixNPTSphereOMP::FixNPTSphereOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTSphereOMP::FixNPTSphereOMP(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/USER-OMP/fix_nvt_asphere_omp.cpp b/src/USER-OMP/fix_nvt_asphere_omp.cpp index 23cc2e9581..bb1e784a37 100644 --- a/src/USER-OMP/fix_nvt_asphere_omp.cpp +++ b/src/USER-OMP/fix_nvt_asphere_omp.cpp @@ -45,5 +45,5 @@ FixNVTAsphereOMP::FixNVTAsphereOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/USER-OMP/fix_nvt_omp.cpp b/src/USER-OMP/fix_nvt_omp.cpp index 18d02bff4d..f8f3c15b76 100644 --- a/src/USER-OMP/fix_nvt_omp.cpp +++ b/src/USER-OMP/fix_nvt_omp.cpp @@ -45,5 +45,5 @@ FixNVTOMP::FixNVTOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/USER-OMP/fix_nvt_sllod_omp.cpp b/src/USER-OMP/fix_nvt_sllod_omp.cpp index 8105e831f7..bd704148a5 100644 --- a/src/USER-OMP/fix_nvt_sllod_omp.cpp +++ b/src/USER-OMP/fix_nvt_sllod_omp.cpp @@ -65,7 +65,7 @@ FixNVTSllodOMP::FixNVTSllodOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-OMP/fix_nvt_sphere_omp.cpp b/src/USER-OMP/fix_nvt_sphere_omp.cpp index 6db9ad849a..22eda99883 100644 --- a/src/USER-OMP/fix_nvt_sphere_omp.cpp +++ b/src/USER-OMP/fix_nvt_sphere_omp.cpp @@ -45,5 +45,5 @@ FixNVTSphereOMP::FixNVTSphereOMP(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/USER-REAXC/pair_reax_c.cpp b/src/USER-REAXC/pair_reax_c.cpp index 59b39d4534..b1a14f84e6 100644 --- a/src/USER-REAXC/pair_reax_c.cpp +++ b/src/USER-REAXC/pair_reax_c.cpp @@ -386,7 +386,6 @@ void PairReaxC::init_style( ) delete [] fixarg; fix_reax = (FixReaxC *) modify->fix[modify->nfix-1]; } - } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-TALLY/compute_force_tally.cpp b/src/USER-TALLY/compute_force_tally.cpp index 90464d7949..e9ecedd5ab 100644 --- a/src/USER-TALLY/compute_force_tally.cpp +++ b/src/USER-TALLY/compute_force_tally.cpp @@ -56,6 +56,7 @@ ComputeForceTally::ComputeForceTally(LAMMPS *lmp, int narg, char **arg) : ComputeForceTally::~ComputeForceTally() { if (force && force->pair) force->pair->del_tally_callback(this); + memory->destroy(fatom); delete[] vector; } diff --git a/src/USER-TALLY/compute_pe_tally.cpp b/src/USER-TALLY/compute_pe_tally.cpp index f18a58e44e..68c00b6d2e 100644 --- a/src/USER-TALLY/compute_pe_tally.cpp +++ b/src/USER-TALLY/compute_pe_tally.cpp @@ -55,6 +55,7 @@ ComputePETally::ComputePETally(LAMMPS *lmp, int narg, char **arg) : ComputePETally::~ComputePETally() { if (force && force->pair) force->pair->del_tally_callback(this); + memory->destroy(eatom); delete[] vector; } diff --git a/src/USER-TALLY/compute_stress_tally.cpp b/src/USER-TALLY/compute_stress_tally.cpp index 2a5f522636..2575bd372a 100644 --- a/src/USER-TALLY/compute_stress_tally.cpp +++ b/src/USER-TALLY/compute_stress_tally.cpp @@ -56,6 +56,7 @@ ComputeStressTally::ComputeStressTally(LAMMPS *lmp, int narg, char **arg) : ComputeStressTally::~ComputeStressTally() { if (force && force->pair) force->pair->del_tally_callback(this); + memory->destroy(stress); delete[] vector; } diff --git a/src/comm.cpp b/src/comm.cpp index 825460720d..f29d1bf7df 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -688,6 +688,10 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, int maxbytes; MPI_Allreduce(&nbytes,&maxbytes,1,MPI_INT,MPI_MAX,world); + // no need to communicate without data + + if (maxbytes == 0) return; + char *buf,*bufcopy; memory->create(buf,maxbytes,"comm:buf"); memory->create(bufcopy,maxbytes,"comm:bufcopy"); diff --git a/src/compute_angmom_chunk.cpp b/src/compute_angmom_chunk.cpp index 93a843ac31..5e88f5bc25 100644 --- a/src/compute_angmom_chunk.cpp +++ b/src/compute_angmom_chunk.cpp @@ -136,9 +136,11 @@ void ComputeAngmomChunk::compute_array() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } // compute angmom for each chunk diff --git a/src/compute_dipole_chunk.cpp b/src/compute_dipole_chunk.cpp index 449fb002b6..cb618055f6 100644 --- a/src/compute_dipole_chunk.cpp +++ b/src/compute_dipole_chunk.cpp @@ -159,10 +159,11 @@ void ComputeDipoleChunk::compute_array() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - if (masstotal[i] == 0.0) masstotal[i] = 1.0; - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } // compute dipole for each chunk diff --git a/src/compute_gyration.cpp b/src/compute_gyration.cpp index 0c1c58a4fd..7f06df9103 100644 --- a/src/compute_gyration.cpp +++ b/src/compute_gyration.cpp @@ -109,6 +109,7 @@ void ComputeGyration::compute_vector() } MPI_Allreduce(rg,vector,6,MPI_DOUBLE,MPI_SUM,world); - if (masstotal == 0.0) return; - for (int i = 0; i < 6; i++) vector[i] = vector[i]/masstotal; + if (masstotal > 0.0) + for (int i = 0; i < 6; i++) + vector[i] /= masstotal; } diff --git a/src/compute_gyration_chunk.cpp b/src/compute_gyration_chunk.cpp index e006a82299..58fe33bc3c 100644 --- a/src/compute_gyration_chunk.cpp +++ b/src/compute_gyration_chunk.cpp @@ -143,7 +143,8 @@ void ComputeGyrationChunk::compute_vector() MPI_Allreduce(rg,rgall,nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) - rgall[i] = sqrt(rgall[i]/masstotal[i]); + if (masstotal[i] > 0.0) + rgall[i] = sqrt(rgall[i]/masstotal[i]); } /* ---------------------------------------------------------------------- */ @@ -191,9 +192,12 @@ void ComputeGyrationChunk::compute_array() if (nchunk) MPI_Allreduce(&rgt[0][0],&rgtall[0][0],nchunk*6,MPI_DOUBLE,MPI_SUM,world); - for (i = 0; i < nchunk; i++) - for (j = 0; j < 6; j++) - rgtall[i][j] = rgtall[i][j]/masstotal[i]; + for (i = 0; i < nchunk; i++) { + if (masstotal[i] > 0.0) { + for (j = 0; j < 6; j++) + rgtall[i][j] = rgtall[i][j]/masstotal[i]; + } + } } @@ -253,9 +257,11 @@ void ComputeGyrationChunk::com_chunk() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } } diff --git a/src/compute_inertia_chunk.cpp b/src/compute_inertia_chunk.cpp index 33660b839f..c4e83fa4a1 100644 --- a/src/compute_inertia_chunk.cpp +++ b/src/compute_inertia_chunk.cpp @@ -136,9 +136,11 @@ void ComputeInertiaChunk::compute_array() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } // compute inertia tensor for each chunk diff --git a/src/compute_msd_chunk.cpp b/src/compute_msd_chunk.cpp index 9d9ddcb3bd..30eee1d64a 100644 --- a/src/compute_msd_chunk.cpp +++ b/src/compute_msd_chunk.cpp @@ -201,9 +201,11 @@ void ComputeMSDChunk::compute_array() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } // MSD is difference between current and initial COM diff --git a/src/compute_omega_chunk.cpp b/src/compute_omega_chunk.cpp index c437dd66b3..54e0b8f906 100644 --- a/src/compute_omega_chunk.cpp +++ b/src/compute_omega_chunk.cpp @@ -138,9 +138,11 @@ void ComputeOmegaChunk::compute_array() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } // compute inertia tensor for each chunk diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 5a5853514f..87d6e11864 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -472,9 +472,13 @@ void ComputeTempChunk::vcm_compute() MPI_Allreduce(massproc,masstotal,nchunk,MPI_DOUBLE,MPI_SUM,world); for (i = 0; i < nchunk; i++) { - vcmall[i][0] /= masstotal[i]; - vcmall[i][1] /= masstotal[i]; - vcmall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + vcmall[i][0] /= masstotal[i]; + vcmall[i][1] /= masstotal[i]; + vcmall[i][2] /= masstotal[i]; + } else { + vcmall[i][0] = vcmall[i][1] = vcmall[i][2] = 0.0; + } } } @@ -689,7 +693,7 @@ void ComputeTempChunk::internal(int icol) void ComputeTempChunk::remove_bias(int i, double *v) { - int index = cchunk->ichunk[i]; + int index = cchunk->ichunk[i]-1; if (index < 0) return; v[0] -= vcmall[index][0]; v[1] -= vcmall[index][1]; @@ -711,11 +715,11 @@ void ComputeTempChunk::remove_bias_all() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - index = ichunk[i]; + index = ichunk[i]-1; if (index < 0) continue; - v[i][0] -= vbias[0]; - v[i][1] -= vbias[1]; - v[i][2] -= vbias[2]; + v[i][0] -= vcmall[index][0]; + v[i][1] -= vcmall[index][1]; + v[i][2] -= vcmall[index][2]; } } @@ -726,7 +730,7 @@ void ComputeTempChunk::remove_bias_all() void ComputeTempChunk::restore_bias(int i, double *v) { - int index = cchunk->ichunk[i]; + int index = cchunk->ichunk[i]-1; if (index < 0) return; v[0] += vcmall[index][0]; v[1] += vcmall[index][1]; @@ -749,11 +753,11 @@ void ComputeTempChunk::restore_bias_all() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - index = ichunk[i]; + index = ichunk[i]-1; if (index < 0) continue; - v[i][0] += vbias[0]; - v[i][1] += vbias[1]; - v[i][2] += vbias[2]; + v[i][0] += vcmall[index][0]; + v[i][1] += vcmall[index][1]; + v[i][2] += vcmall[index][2]; } } diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 158c93b2fb..33e07bfb1e 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -209,7 +209,7 @@ void ComputeTempRegion::remove_bias_all() int *mask = atom->mask; int nlocal = atom->nlocal; - if (nlocal > maxbias) { + if (atom->nmax > maxbias) { memory->destroy(vbiasall); maxbias = atom->nmax; memory->create(vbiasall,maxbias,3,"temp/region:vbiasall"); diff --git a/src/compute_torque_chunk.cpp b/src/compute_torque_chunk.cpp index 41ae0c628c..5462debcfc 100644 --- a/src/compute_torque_chunk.cpp +++ b/src/compute_torque_chunk.cpp @@ -136,9 +136,11 @@ void ComputeTorqueChunk::compute_array() MPI_Allreduce(&com[0][0],&comall[0][0],3*nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - comall[i][0] /= masstotal[i]; - comall[i][1] /= masstotal[i]; - comall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + comall[i][0] /= masstotal[i]; + comall[i][1] /= masstotal[i]; + comall[i][2] /= masstotal[i]; + } } // compute torque on each chunk diff --git a/src/compute_vcm_chunk.cpp b/src/compute_vcm_chunk.cpp index a3751fa13a..cd864b2aa8 100644 --- a/src/compute_vcm_chunk.cpp +++ b/src/compute_vcm_chunk.cpp @@ -146,9 +146,11 @@ void ComputeVCMChunk::compute_array() MPI_Allreduce(massproc,masstotal,nchunk,MPI_DOUBLE,MPI_SUM,world); for (int i = 0; i < nchunk; i++) { - vcmall[i][0] /= masstotal[i]; - vcmall[i][1] /= masstotal[i]; - vcmall[i][2] /= masstotal[i]; + if (masstotal[i] > 0.0) { + vcmall[i][0] /= masstotal[i]; + vcmall[i][1] /= masstotal[i]; + vcmall[i][2] /= masstotal[i]; + } else vcmall[i][0] = vcmall[i][1] = vcmall[i][2] = 0.0; } } diff --git a/src/fix_deprecated.cpp b/src/fix_deprecated.cpp index 8139a14d9d..9c0b6686d1 100644 --- a/src/fix_deprecated.cpp +++ b/src/fix_deprecated.cpp @@ -34,8 +34,8 @@ FixDeprecated::FixDeprecated(LAMMPS *lmp, int narg, char **arg) : " dim, origin, delta, region, bound, discard, units\n\n"; if (comm->me == 0) { - if (screen) fprintf(screen,message); - if (logfile) fprintf(logfile,message); + if (screen) fputs(message,screen); + if (logfile) fputs(message,logfile); } } error->all(FLERR,"This fix command has been removed from LAMMPS"); diff --git a/src/fix_heat.cpp b/src/fix_heat.cpp index 0609d45efb..5da405ae3f 100644 --- a/src/fix_heat.cpp +++ b/src/fix_heat.cpp @@ -133,6 +133,8 @@ void FixHeat::init() if (group->count(igroup) == 0) error->all(FLERR,"Fix heat group has no atoms"); masstotal = group->mass(igroup); + if (masstotal <= 0.0) + error->all(FLERR,"Fix heat group has invalid mass"); } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index b300fd2d46..2f1081216b 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -80,6 +80,11 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) flipflag = 1; dipole_flag = 0; + tcomputeflag = 0; + pcomputeflag = 0; + id_temp = NULL; + id_press = NULL; + // turn on tilt factor scaling, whenever applicable dimension = domain->dimension; @@ -558,7 +563,7 @@ FixNH::~FixNH() // delete temperature and pressure if fix created them - if (tflag) modify->delete_compute(id_temp); + if (tcomputeflag) modify->delete_compute(id_temp); delete [] id_temp; if (tstat_flag) { @@ -569,7 +574,7 @@ FixNH::~FixNH() } if (pstat_flag) { - if (pflag) modify->delete_compute(id_press); + if (pcomputeflag) modify->delete_compute(id_press); delete [] id_press; if (mpchain) { delete [] etap; @@ -1347,9 +1352,9 @@ int FixNH::modify_param(int narg, char **arg) { if (strcmp(arg[0],"temp") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); - if (tflag) { + if (tcomputeflag) { modify->delete_compute(id_temp); - tflag = 0; + tcomputeflag = 0; } delete [] id_temp; int n = strlen(arg[1]) + 1; @@ -1381,9 +1386,9 @@ int FixNH::modify_param(int narg, char **arg) } else if (strcmp(arg[0],"press") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); if (!pstat_flag) error->all(FLERR,"Illegal fix_modify command"); - if (pflag) { + if (pcomputeflag) { modify->delete_compute(id_press); - pflag = 0; + pcomputeflag = 0; } delete [] id_press; int n = strlen(arg[1]) + 1; diff --git a/src/fix_nh.h b/src/fix_nh.h index 7227a22968..e468d49817 100644 --- a/src/fix_nh.h +++ b/src/fix_nh.h @@ -76,7 +76,7 @@ class FixNH : public Fix { char *id_temp,*id_press; class Compute *temperature,*pressure; - int tflag,pflag; + int tcomputeflag,pcomputeflag; // 1 = compute was created by fix. 0 = external double *eta,*eta_dot; // chain thermostat for particles double *eta_dotdot; diff --git a/src/fix_nph.cpp b/src/fix_nph.cpp index 6f3678ed3a..a331a07d24 100644 --- a/src/fix_nph.cpp +++ b/src/fix_nph.cpp @@ -46,7 +46,7 @@ FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/fix_nph_sphere.cpp b/src/fix_nph_sphere.cpp index 93d9bf8af2..852234074f 100644 --- a/src/fix_nph_sphere.cpp +++ b/src/fix_nph_sphere.cpp @@ -46,7 +46,7 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/fix_npt.cpp b/src/fix_npt.cpp index 0326c06c77..e14200f6a2 100644 --- a/src/fix_npt.cpp +++ b/src/fix_npt.cpp @@ -46,7 +46,7 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/fix_npt_sphere.cpp b/src/fix_npt_sphere.cpp index 6e7c074d5e..d3773e0d17 100644 --- a/src/fix_npt_sphere.cpp +++ b/src/fix_npt_sphere.cpp @@ -46,7 +46,7 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all @@ -64,5 +64,5 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) : newarg[3] = id_temp; modify->add_compute(4,newarg); delete [] newarg; - pflag = 1; + pcomputeflag = 1; } diff --git a/src/fix_nvt.cpp b/src/fix_nvt.cpp index a86f46c3b5..35ee085da1 100644 --- a/src/fix_nvt.cpp +++ b/src/fix_nvt.cpp @@ -45,5 +45,5 @@ FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/fix_nvt_sllod.cpp b/src/fix_nvt_sllod.cpp index 8257afae05..87e86f2351 100644 --- a/src/fix_nvt_sllod.cpp +++ b/src/fix_nvt_sllod.cpp @@ -63,7 +63,7 @@ FixNVTSllod::FixNVTSllod(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_nvt_sphere.cpp b/src/fix_nvt_sphere.cpp index c886935f12..b65b3adfae 100644 --- a/src/fix_nvt_sphere.cpp +++ b/src/fix_nvt_sphere.cpp @@ -45,5 +45,5 @@ FixNVTSphere::FixNVTSphere(LAMMPS *lmp, int narg, char **arg) : modify->add_compute(3,newarg); delete [] newarg; - tflag = 1; + tcomputeflag = 1; } diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index 7d30c2f865..e10edcb2d9 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -52,6 +52,7 @@ FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) : extscalar = 1; extvector = 1; global_freq = 1; + dynamic_group_allow = 1; /* ---------------------------------------------------------------------- */ @@ -186,6 +187,9 @@ void FixRecenter::initial_integrate(int vflag) // current COM double xcm[3]; + if (group->dynamic[igroup]) + masstotal = group->mass(igroup); + group->xcm(igroup,masstotal,xcm); // shift coords by difference between actual COM and requested COM diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp index ddc161e50d..fb2b21b71d 100644 --- a/src/fix_spring.cpp +++ b/src/fix_spring.cpp @@ -47,6 +47,7 @@ FixSpring::FixSpring(LAMMPS *lmp, int narg, char **arg) : global_freq = 1; extscalar = 1; extvector = 1; + dynamic_group_allow = 1; group2 = NULL; @@ -166,6 +167,10 @@ void FixSpring::post_force(int vflag) void FixSpring::spring_tether() { double xcm[3]; + + if (group->dynamic[igroup]) + masstotal = group->mass(igroup); + group->xcm(igroup,masstotal,xcm); // fx,fy,fz = components of k * (r-r0) / masstotal @@ -192,9 +197,11 @@ void FixSpring::spring_tether() if (dr < 0.0) ftotal[3] = -ftotal[3]; espring = 0.5*k_spring * dr*dr; - fx /= masstotal; - fy /= masstotal; - fz /= masstotal; + if (masstotal > 0.0) { + fx /= masstotal; + fy /= masstotal; + fz /= masstotal; + } // apply restoring force to atoms in group @@ -231,6 +238,13 @@ void FixSpring::spring_tether() void FixSpring::spring_couple() { double xcm[3],xcm2[3]; + + if (group->dynamic[igroup]) + masstotal = group->mass(igroup); + + if (group->dynamic[igroup2]) + masstotal2 = group->mass(igroup2); + group->xcm(igroup,masstotal,xcm); group->xcm(igroup2,masstotal2,xcm2); @@ -259,12 +273,16 @@ void FixSpring::spring_couple() if (dr < 0.0) ftotal[3] = -ftotal[3]; espring = 0.5*k_spring * dr*dr; - fx2 = fx/masstotal2; - fy2 = fy/masstotal2; - fz2 = fz/masstotal2; - fx /= masstotal; - fy /= masstotal; - fz /= masstotal; + if (masstotal2 > 0.0) { + fx2 = fx/masstotal2; + fy2 = fy/masstotal2; + fz2 = fz/masstotal2; + } + if (masstotal > 0.0) { + fx /= masstotal; + fy /= masstotal; + fz /= masstotal; + } // apply restoring force to atoms in group // f = -k*(r-r0)*mass/masstotal diff --git a/src/fix_spring_rg.cpp b/src/fix_spring_rg.cpp index 5e267340c1..4145e01047 100644 --- a/src/fix_spring_rg.cpp +++ b/src/fix_spring_rg.cpp @@ -42,6 +42,8 @@ FixSpringRG::FixSpringRG(LAMMPS *lmp, int narg, char **arg) : rg0_flag = 0; if (strcmp(arg[4],"NULL") == 0) rg0_flag = 1; else rg0 = force->numeric(FLERR,arg[4]); + + dynamic_group_allow = 1; } /* ---------------------------------------------------------------------- */ @@ -94,6 +96,8 @@ void FixSpringRG::post_force(int vflag) // compute current Rg and center-of-mass double xcm[3]; + if (group->dynamic[igroup]) + masstotal = group->mass(igroup); group->xcm(igroup,masstotal,xcm); double rg = group->gyration(igroup,masstotal,xcm); @@ -108,6 +112,7 @@ void FixSpringRG::post_force(int vflag) int *type = atom->type; imageint *image = atom->image; double *mass = atom->mass; + double *rmass = atom->rmass; int nlocal = atom->nlocal; double massfrac; @@ -120,10 +125,14 @@ void FixSpringRG::post_force(int vflag) dy = unwrap[1] - xcm[1]; dz = unwrap[2] - xcm[2]; term1 = 2.0 * k * (1.0 - rg0/rg); - massfrac = mass[type[i]]/masstotal; - f[i][0] -= term1*dx*massfrac; - f[i][1] -= term1*dy*massfrac; - f[i][2] -= term1*dz*massfrac; + if (masstotal > 0.0) { + if (rmass) massfrac = rmass[i]/masstotal; + else massfrac = mass[type[i]]/masstotal; + + f[i][0] -= term1*dx*massfrac; + f[i][1] -= term1*dy*massfrac; + f[i][2] -= term1*dz*massfrac; + } } } diff --git a/src/fix_tmd.cpp b/src/fix_tmd.cpp index 4be97a816e..d326685368 100644 --- a/src/fix_tmd.cpp +++ b/src/fix_tmd.cpp @@ -85,6 +85,8 @@ FixTMD::FixTMD(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) } masstotal = group->mass(igroup); + if (masstotal == 0.0) + error->all(FLERR,"Cannot use fix TMD on massless group"); // rho_start = initial rho // xold = initial x or 0.0 if not in group @@ -155,10 +157,7 @@ void FixTMD::init() int flag = 0; for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"tmd") == 0) flag = 1; - if (flag && strcmp(modify->fix[i]->style,"nve") == 0) flag = 2; - if (flag && strcmp(modify->fix[i]->style,"nvt") == 0) flag = 2; - if (flag && strcmp(modify->fix[i]->style,"npt") == 0) flag = 2; - if (flag && strcmp(modify->fix[i]->style,"nph") == 0) flag = 2; + if (flag && modify->fix[i]->time_integrate) flag = 2; } if (flag == 2) error->all(FLERR,"Fix tmd must come after integration fixes"); diff --git a/src/lattice.cpp b/src/lattice.cpp index e851760792..484ce27972 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -53,7 +53,16 @@ Lattice::Lattice(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (style == NONE) { if (narg != 2) error->all(FLERR,"Illegal lattice command"); - xlattice = ylattice = zlattice = force->numeric(FLERR,arg[1]); + + // Domain defines a default lattice of style "none" with + // spacing 1.0 before the force class is initialized, so + // we have to fall back to using atof() in that case. + + if (force) + xlattice = ylattice = zlattice = force->numeric(FLERR,arg[1]); + else + xlattice = ylattice = zlattice = atof(arg[1]); + if (xlattice <= 0.0) error->all(FLERR,"Illegal lattice command"); return; } diff --git a/src/molecule.cpp b/src/molecule.cpp index 99b5718133..91557b32ba 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -245,9 +245,11 @@ void Molecule::compute_com() com[1] += x[i][1]*onemass; com[2] += x[i][2]*onemass; } - com[0] /= masstotal; - com[1] /= masstotal; - com[2] /= masstotal; + if (masstotal > 0.0) { + com[0] /= masstotal; + com[1] /= masstotal; + com[2] /= masstotal; + } } memory->destroy(dxcom); diff --git a/src/replicate.cpp b/src/replicate.cpp index 941ec32492..e2ed718f65 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -116,9 +116,9 @@ void Replicate::command(int narg, char **arg) // also set atomKK for Kokkos version of Atom class Atom *old = atom; - if (lmp->kokkos) atom = new AtomKokkos(lmp); + atomKK = NULL; + if (lmp->kokkos) atom = atomKK = new AtomKokkos(lmp); else atom = new Atom(lmp); - atomKK = (AtomKokkos*) atom; atom->settings(old); atom->create_avec(old->atom_style,old->avec->nargcopy,old->avec->argcopy,0);