Hello,
I am doing a set of MC moves within a loop. I need to store the image
flags, make a displacement move, check it and then reset if I don't accept
the move.
I've discovered that the image flags are available to be used as atom
style variables within fix store/state but not through the set command
(like x,y,z).
So I've gotten it to work with
fix image0 all store/state 0 ix iy iz
variable ixa equal f_image0[v_a][1]
variable iya equal f_image0[v_a][2]
variable iza equal f_image0[v_a][3]
Then later I have to use a loop over all atoms to reset each atom
separately if I need to.
label loop
variable a loop \{atoms\}
if "{reset1} == 1" then "set atom a image {ixa} \{iya\} {iza}
next a
jump SELF loopa
However, it seems that looping over all atoms is much slower than
resetting an atom style variable via (set atom *) ..such as x,y,z, etc.
Is there another way to store and reset image flags faster than a loop
over all atoms within a LAMMPS script?
the following change to the set command source will enable support for
atom style variables for set image
diff --git a/src/set.cpp b/src/set.cpp
index 4ed07d4..b97a961 100644
--- a/src/set.cpp
+++ b/src/set.cpp
@@ -327,15 +327,18 @@ void Set::command(int narg, char **arg)
ximageflag = yimageflag = zimageflag = 0;
if (strcmp(arg[iarg+1],"NULL") != 0) {
ximageflag = 1;
- ximage = force->inumeric(FLERR,arg[iarg+1]);
+ if (strstr(arg[iarg+1],"v_") == arg[iarg+1])
varparse(arg[iarg+1],1);
+ else ximage = force->inumeric(FLERR,arg[iarg+1]);
}
if (strcmp(arg[iarg+2],"NULL") != 0) {
yimageflag = 1;
- yimage = force->inumeric(FLERR,arg[iarg+2]);
+ if (strstr(arg[iarg+2],"v_") == arg[iarg+2])
varparse(arg[iarg+2],2);
+ else yimage = force->inumeric(FLERR,arg[iarg+2]);
}
if (strcmp(arg[iarg+3],"NULL") != 0) {
zimageflag = 1;
- zimage = force->inumeric(FLERR,arg[iarg+3]);
+ if (strstr(arg[iarg+3],"v_") == arg[iarg+3])
varparse(arg[iarg+3],3);
+ else zimage = force->inumeric(FLERR,arg[iarg+3]);
}
if (ximageflag && ximage && !domain->xperiodic)
error->all(FLERR,
@@ -789,6 +792,9 @@ void Set::set(int keyword)
int xbox = (atom->image[i] & IMGMASK) - IMGMAX;
int ybox = (atom->image[i] >> IMGBITS & IMGMASK) - IMGMAX;
int zbox = (atom->image[i] >> IMG2BITS) - IMGMAX;
+ if (varflag1) ximage = static_cast<int>(xvalue);
+ if (varflag2) yimage = static_cast<int>(yvalue);
+ if (varflag3) zimage = static_cast<int>(zvalue);
if (ximageflag) xbox = ximage;
if (yimageflag) ybox = yimage;
if (zimageflag) zbox = zimage;
...and here is a small demo input:
region box block 0 1 0 1 0 1
atom_modify map array
create_box 1 box
pair_style zero 1.0
pair_coeff * *
mass * 1.0
create_atoms 1 single 0.25 0.25 0.5
create_atoms 1 single 0.75 0.25 0.5
create_atoms 1 single 0.25 0.5 0.5
create_atoms 1 single 0.5 0.5 0.5
variable cx equal xcm(all,x)
variable cy equal xcm(all,y)
variable cz equal xcm(all,z)
print "\{cx\} {cy} ${cz}"
fix 1 all store/state 0 ix iy iz
run 0 post no
set atom 1:2 image 1 1 -1
print "\{cx\} {cy} ${cz}"
variable imgx atom f_1[1]
variable imgy atom f_1[2]
variable imgz atom f_1[3]
set atom * image v_imgx v_imgy v_imgz
print "\{cx\} {cy} ${cz}"
axel.
Also is there a way to turn off all the "Setting atom values for ..."
output in the LAMMPS output from the set command?