problem while using create_atom with velocity in a looping

Dear all,
I find a problem while using create_atom and velocity command, see the in file below. If we ignore line 39 “velocity …”, the loop goes well. But while I want to velocity those new atoms down, program drop into something an endless loop with nothing dumping out at the second looping.
thanks if you can help.

--------------------here is the in.file-----------------------------------------
units metal
dimension 2
boundary p fs p
atom_style atomic

lattice hex 2.2
region r_all block 0 100 0 100 -0.25 0.25
create_box 1 r_all

mass 1 58.4

pair_style lj/cut 2.5
pair_coeff * * 2.15 1.8
timestep 0.001

region r_pre block 0 100 0 3.0 -0.25 0.25
create_atoms 1 region r_pre

region r_fix block INF INF INF 1.1 INF INF
group g_fix region r_fix

set group all type 1

fix 1 all nve
fix 2 g_fix setforce 0.0 0.0 0.0

thermo 1000
dump 1 all xyz 500 dump.prob

#--------------------------loop begin-------------------------------
label loop
variable i loop 5

print “I = $i”
region r_dop block 0 100 38.0 39.1 -0.25 0.25
delete_atoms region r_dop
create_atoms 1 random 10 $i r_dop
group g_dop region r_dop

velocity g_dop set 0.0 -2.5 0.0

group g_dop delete
run 10000
region r_dop delete
if $i>2 then “jump in.prob break”
next i
jump in.prob loop
label break
variable i delete
print “loop end”
#-------------------loop end---------------------------------

run 5000

I don't see any way a velocity command
can cause a loop to hang. I suggset you put
in print command statements and debug it.


it is not the velocity command that is causing
the trouble, at least not directly, but rather
the create_atom command preceding it that
doesn't return.

the reason that the velocity command can trigger
it lies in the fact, that the region to create atoms
lies outside of the simulation box due to shrinkwrap boundary
conditions that make the box shrink only when a velocity
is assigned. this traps CreateAtoms::add_random() in a
while(1) loop.

the fix to the input is to use "fm" instead of "fs" for the
y-dimension of the box (it won't fix the otherwise equally
problematic choices of parameters, but that is a different

the way to avoid this from the source would be a patch
like the following (or just refuse to add atoms and only
print a warning, when the region is outside the box
and thenreturn immediately?):

diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp
index c73b0d1..3fb0f9b 100644
--- a/src/create_atoms.cpp
+++ b/src/create_atoms.cpp
@@ -310,6 +310,13 @@ void CreateAtoms::add_random()
   // iterate until atom is within region and triclinic simulation box
   // if final atom position is in my subbox, create it

+ if (xlo >= xhi)
+ error->all(FLERR,"no overlap of box and region in x");
+ if (ylo >= yhi)
+ error->all(FLERR,"no overlap of box and region in y");
+ if (zlo >= zhi)
+ error->all(FLERR,"no overlap of box and region in z");