I am trying a pick a random atom from a group using a loop. Here’s the script.
label pick_pka
# generate random atom ID
variable tmr timer
variable SEED equal ceil(${tmr}*10000000)
variable natoms equal count(all)
variable trial equal floor(random(1,${natoms}+1,${SEED}))
print "Selected atom ID = ${trial}"
# make temporary group for this atom ID
group trialAtom id ${trial}
# check if this atom is in shell
group test intersect trialAtom shellAtoms
variable ntest1 equal count(test)
variable ntest equal ${ntest1}
group trialAtom clear
group test clear
if "${ntest} == 0" then "jump SELF pick_pka"
# success → assign PKA ID
variable PKA_id equal ${trial}
group pka id ${PKA_id}
and Here’s the output
15195 atoms in group shellAtoms
Selected atom ID = 200141
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 176726
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 145097
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 197536
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 51308
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 48153
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 82049
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 235794
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 237260
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 240563
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 115407
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 123959
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 94326
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 201682
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 201125
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 38673
1 atoms in group trialAtom
0 atoms in group test
Selected atom ID = 176746
1 atoms in group trialAtom
1 atoms in group test
1 atoms in group pka
Selected PKA atom ID = 33887
My problem is that why the variable’s value changed here at the end? Am I missing something here? I am running this script with this following command line.
mpiexec -np 1 lmp.exe -sf omp -pk omp 1 -in in.lmp
Thank you for your time.