some applications of the new function

This commit is contained in:
Axel Kohlmeyer
2021-09-19 19:05:40 -04:00
parent 860a93aa8b
commit f80259dfae
7 changed files with 30 additions and 66 deletions

View File

@ -1217,27 +1217,19 @@ int ReadDump::fields_and_keywords(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"box") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
if (strcmp(arg[iarg+1],"yes") == 0) boxflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) boxflag = 0;
else error->all(FLERR,"Illegal read_dump command");
boxflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"replace") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
if (strcmp(arg[iarg+1],"yes") == 0) replaceflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) replaceflag = 0;
else error->all(FLERR,"Illegal read_dump command");
replaceflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"purge") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
if (strcmp(arg[iarg+1],"yes") == 0) purgeflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) purgeflag = 0;
else error->all(FLERR,"Illegal read_dump command");
purgeflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"trim") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
if (strcmp(arg[iarg+1],"yes") == 0) trimflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) trimflag = 0;
else error->all(FLERR,"Illegal read_dump command");
trimflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"add") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
@ -1257,15 +1249,11 @@ int ReadDump::fields_and_keywords(int narg, char **arg)
iarg += 3;
} else if (strcmp(arg[iarg],"scaled") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
if (strcmp(arg[iarg+1],"yes") == 0) scaleflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) scaleflag = 0;
else error->all(FLERR,"Illegal read_dump command");
scaleflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"wrapped") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");
if (strcmp(arg[iarg+1],"yes") == 0) wrapflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) wrapflag = 0;
else error->all(FLERR,"Illegal read_dump command");
wrapflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"format") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command");

View File

@ -106,11 +106,7 @@ void Rerun::command(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"post") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal rerun command");
if (strcmp(arg[iarg+1],"yes") == 0) {
postflag = 1;
} else if (strcmp(arg[iarg+1],"no") == 0) {
postflag = 0;
} else error->all(FLERR,"Illegal rerun command");
postflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"dump") == 0) {
break;

View File

@ -69,9 +69,7 @@ void ResetIDs::command(int narg, char **arg)
while (iarg < narg) {
if (strcmp(arg[iarg],"sort") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_atom_ids command");
if (strcmp(arg[iarg+1],"yes") == 0) sortflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) sortflag = 0;
else error->all(FLERR,"Illegal reset_atom_ids command");
sortflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else error->all(FLERR,"Illegal reset_atom_ids command");
}

View File

@ -77,15 +77,11 @@ void ResetMolIDs::command(int narg, char **arg)
while (iarg < narg) {
if (strcmp(arg[iarg],"compress") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command");
if (strcmp(arg[iarg+1],"yes") == 0) compressflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) compressflag = 0;
else error->all(FLERR,"Illegal reset_mol_ids command");
compressflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"single") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command");
if (strcmp(arg[iarg+1],"yes") == 0) singleflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) singleflag = 0;
else error->all(FLERR,"Illegal reset_mol_ids command");
singleflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"offset") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command");

View File

@ -77,15 +77,11 @@ void Run::command(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"pre") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal run command");
if (strcmp(arg[iarg+1],"no") == 0) preflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) preflag = 1;
else error->all(FLERR,"Illegal run command");
preflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"post") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal run command");
if (strcmp(arg[iarg+1],"no") == 0) postflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) postflag = 1;
else error->all(FLERR,"Illegal run command");
postflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
// all remaining args are commands

View File

@ -556,16 +556,12 @@ void Thermo::modify_params(int narg, char **arg)
} else if (strcmp(arg[iarg],"norm") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command");
normuserflag = 1;
if (strcmp(arg[iarg+1],"no") == 0) normuser = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) normuser = 1;
else error->all(FLERR,"Illegal thermo_modify command");
normuser = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"flush") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command");
if (strcmp(arg[iarg+1],"no") == 0) flushflag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) flushflag = 1;
else error->all(FLERR,"Illegal thermo_modify command");
flushflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"line") == 0) {

View File

@ -36,6 +36,7 @@ using namespace LAMMPS_NS;
enum{CREATE,SET,SCALE,RAMP,ZERO};
enum{ALL,LOCAL,GEOM};
enum{UNIFORM,GAUSSIAN};
enum{NONE,CONSTANT,EQUAL,ATOM};
#define WARMUP 100
@ -84,7 +85,7 @@ void Velocity::command(int narg, char **arg)
// set defaults
temperature = nullptr;
dist_flag = 0;
dist_flag = UNIFORM;
sum_flag = 0;
momentum_flag = 1;
rotation_flag = 0;
@ -149,11 +150,12 @@ void Velocity::init_external(const char *extgroup)
groupbit = group->bitmask[igroup];
temperature = nullptr;
dist_flag = 0;
dist_flag = UNIFORM;
sum_flag = 0;
momentum_flag = 1;
rotation_flag = 0;
loop_flag = ALL;
rfix = -1;
scale_flag = 1;
bias_flag = 0;
}
@ -275,11 +277,11 @@ void Velocity::create(double t_desired, int seed)
int natoms = static_cast<int> (atom->natoms);
for (i = 1; i <= natoms; i++) {
if (dist_flag == 0) {
if (dist_flag == UNIFORM) {
vx = random->uniform() - 0.5;
vy = random->uniform() - 0.5;
vz = random->uniform() - 0.5;
} else {
} else { // GAUSSIAN
vx = random->gaussian();
vy = random->gaussian();
vz = random->gaussian();
@ -310,11 +312,11 @@ void Velocity::create(double t_desired, int seed)
for (i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
if (dist_flag == 0) {
if (dist_flag == UNIFORM) {
vx = random->uniform() - 0.5;
vy = random->uniform() - 0.5;
vz = random->uniform() - 0.5;
} else {
} else { // GAUSSIAN
vx = random->gaussian();
vy = random->gaussian();
vz = random->gaussian();
@ -335,11 +337,11 @@ void Velocity::create(double t_desired, int seed)
for (i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
random->reset(seed,x[i]);
if (dist_flag == 0) {
if (dist_flag == UNIFORM) {
vx = random->uniform() - 0.5;
vy = random->uniform() - 0.5;
vz = random->uniform() - 0.5;
} else {
} else { // GAUSSIAN
vx = random->gaussian();
vy = random->gaussian();
vz = random->gaussian();
@ -824,27 +826,21 @@ void Velocity::options(int narg, char **arg)
while (iarg < narg) {
if (strcmp(arg[iarg],"dist") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");
if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = 0;
else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = 1;
if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = UNIFORM;
else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = GAUSSIAN;
else error->all(FLERR,"Illegal velocity command");
iarg += 2;
} else if (strcmp(arg[iarg],"sum") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");
if (strcmp(arg[iarg+1],"no") == 0) sum_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) sum_flag = 1;
else error->all(FLERR,"Illegal velocity command");
sum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"mom") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");
if (strcmp(arg[iarg+1],"no") == 0) momentum_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) momentum_flag = 1;
else error->all(FLERR,"Illegal velocity command");
momentum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"rot") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");
if (strcmp(arg[iarg+1],"no") == 0) rotation_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) rotation_flag = 1;
else error->all(FLERR,"Illegal velocity command");
rotation_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"temp") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");
@ -856,9 +852,7 @@ void Velocity::options(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"bias") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");
if (strcmp(arg[iarg+1],"no") == 0) bias_flag = 0;
else if (strcmp(arg[iarg+1],"yes") == 0) bias_flag = 1;
else error->all(FLERR,"Illegal velocity command");
bias_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"loop") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");