fix missing argument bug in velocity code and simplify a second case

This commit is contained in:
Axel Kohlmeyer
2021-04-23 18:07:24 -04:00
parent 917cd1b924
commit 8a49bf3a31
2 changed files with 11 additions and 19 deletions

View File

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