change how internal vars are defined by various commands, enable Python class to return a numeric value directly (for speed)

This commit is contained in:
Steve Plimpton
2025-05-15 16:37:41 -06:00
parent 3751fe6be7
commit 06616c5ff3
12 changed files with 278 additions and 82 deletions

View File

@ -392,22 +392,28 @@ void CreateAtoms::command(int narg, char **arg)
if (xstr) {
xvar = input->variable->find(xstr);
if (xvar < 0)
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms does not exist", xstr);
if (xvar < 0) {
input->variable->internal_create(xstr,0.0);
xvar = input->variable->find(xstr);
}
if (!input->variable->internalstyle(xvar))
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", xstr);
}
if (ystr) {
yvar = input->variable->find(ystr);
if (yvar < 0)
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms does not exist", ystr);
if (yvar < 0) {
input->variable->internal_create(ystr,0.0);
yvar = input->variable->find(ystr);
}
if (!input->variable->internalstyle(yvar))
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", ystr);
}
if (zstr) {
zvar = input->variable->find(zstr);
if (zvar < 0)
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms does not exist", zstr);
if (zvar < 0) {
input->variable->internal_create(zstr,0.0);
zvar = input->variable->find(zstr);
}
if (!input->variable->internalstyle(zvar))
error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", zstr);
}