diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 40b3e6fc28..2e752d7f31 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -316,33 +316,29 @@ void DumpCustom::init_style() // find current ptr for each compute,fix,variable // check that fix frequency is acceptable - int icompute; for (i = 0; i < ncompute; i++) { - icompute = modify->find_compute(id_compute[i]); + int icompute = modify->find_compute(id_compute[i]); if (icompute < 0) error->all(FLERR,"Could not find dump custom compute ID"); compute[i] = modify->compute[icompute]; } - int ifix; for (i = 0; i < nfix; i++) { - ifix = modify->find_fix(id_fix[i]); + int ifix = modify->find_fix(id_fix[i]); if (ifix < 0) error->all(FLERR,"Could not find dump custom fix ID"); fix[i] = modify->fix[ifix]; if (nevery % modify->fix[ifix]->peratom_freq) error->all(FLERR,"Dump custom and fix not computed at compatible times"); } - int ivariable; for (i = 0; i < nvariable; i++) { - ivariable = input->variable->find(id_variable[i]); + int ivariable = input->variable->find(id_variable[i]); if (ivariable < 0) error->all(FLERR,"Could not find dump custom variable name"); variable[i] = ivariable; } - int icustom; for (i = 0; i < ncustom; i++) { - icustom = atom->find_custom(id_custom[i],flag_custom[i]); + int icustom = atom->find_custom(id_custom[i],flag_custom[i]); if (icustom < 0) error->all(FLERR,"Could not find custom per-atom property ID"); } diff --git a/src/velocity.cpp b/src/velocity.cpp index 30d479b0eb..44d1556676 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -186,15 +186,11 @@ void Velocity::create(double t_desired, int seed) Compute *temperature_nobias = nullptr; if (temperature == nullptr || bias_flag) { - char **arg = new char*[3]; - arg[0] = (char *) "velocity_temp"; - arg[1] = group->names[igroup]; - arg[2] = (char *) "temp"; + modify->add_compute(fmt::format("velocity_temp {} temp",group->names[igroup])); if (temperature == nullptr) { - temperature = new ComputeTemp(lmp,3,arg); + temperature = modify->compute[modify->ncompute-1]; tcreate_flag = 1; - } else temperature_nobias = new ComputeTemp(lmp,3,arg); - delete [] arg; + } else temperature_nobias = modify->compute[modify->ncompute-1]; } // initialize temperature computation(s) @@ -401,8 +397,8 @@ void Velocity::create(double t_desired, int seed) // if temperature compute was created, delete it delete random; - if (tcreate_flag) delete temperature; - if (temperature_nobias) delete temperature_nobias; + if (tcreate_flag) modify->delete_compute("velocity_temp"); + if (temperature_nobias) modify->delete_compute("velocity_temp"); } /* ---------------------------------------------------------------------- */ @@ -578,7 +574,7 @@ void Velocity::scale(int /*narg*/, char **arg) int tflag = 0; if (temperature == nullptr) { - modify->add_compute(fmt::format("velocity_temp {} temp")); + modify->add_compute(fmt::format("velocity_temp {} temp",group->names[igroup])); temperature = modify->compute[modify->ncompute-1]; tflag = 1; } @@ -608,7 +604,7 @@ void Velocity::scale(int /*narg*/, char **arg) // if temperature was created, delete it - if (tflag) delete temperature; + if (tflag) modify->delete_compute("velocity_temp"); } /* ----------------------------------------------------------------------