Running a loop for a specific work

Dear LAMMPS users,

I want to pour powder particles into a box in a fashion like 100 particles at a time then stop the system. Then after some time simply pour another 100 particles and continue in this fashion.

For this, my input is something like this:

region          slab block 140 180 90 95 -0.5 0.5 units box



fix		ins all pour 10000 1 300719 vol 0.2 50 region slab

variable myatom equal atoms 
label loop
variable a loop 1
if "${myatom}==100" then "jump SELF break"
next a 
jump SELF loop
label break
print "ALL DONE"


fix     3 all enforce2d


compute		1 all erotate/sphere       #erotate/sphere comutes the rotational kinetic energy
compute         Tsphere all temp/sphere

thermo_style	custom step atoms ke c_1 vol     #c_1 is coumpted with compute id 
thermo		100

thermo_modify	lost ignore norm no temp Tsphere    #ignore value does not check for lost atoms, norm value normalized the thermodyanmic paprameters
compute_modify	thermo_temp dynamic/dof yes
compute_modify	Tsphere dynamic/dof yes

dump		id all atom 100 dump.pour
dump		1 all custom 100 positions.lammpstrj id x y z vx vy vz diameter

dump		3 all image 20000 image.*.jpg type type &

run		100000

But the system is not working in the way I want. May I know where is the specific problem occurring? Thank you.

Regards,
Yeasir Mohammad Akib
UTRGV

Please look at 5.1. LAMMPS input scripts — LAMMPS documentation and Control flow - Wikipedia
for some general background about how LAMMPS processes input and how loops work, and then at the documentation of the next command — LAMMPS documentation
and the jump command — LAMMPS documentation
for some specific examples and detailed documentation.

What you have done is that you have inserted some looping construct into your input script but it has no “body”, so it is pretty much useless. Also fix pour operates during a “run”, but then the input script is not processed. So what you have to do is to break down your one run into multiple runs, and then have a run command where fix pour inserts a chunk of particles, then unfix fix pour, so it does not insert anything and run some more and then jump back to the previous section of the code where you create fix pour and do another segment with fix pour active and so on.

Bascially, what you have done is to insert bits and pieces of what you want to do somewhere in the input and expect LAMMPS to figure out what your intentions are, but that cannot work. LAMMPS is a computer program and thus you have to spell everything out (do this, then this, then this and then that)
as it is reading and processing the input line by line.

1 Like

I’m currently trying to get the variable/loop/label/ commands to work in a script file as well with no success. Have you found any solutions or insights as to how these commands work and what errors they may throw? For mine I have: #test for variable iteration
units real
boundary p p p
atom_style full

timestep 1
#variable current_file equal ${r}
read_data water.init
#read_restart
#replicate

variable t index 280 290 300
#variable r index 1 a b c

#label loop_temperature
#label loop_read
#variable current_temp equal {t} velocity all create {t} 87287 loop geom

kspace_style pppm 1.0e-5
include WaterESPC.PARM

neighbor 0.3 bin

fix 1 all nvt temp {t} {t} 100 #iso 0 0 1000

dump 1 all atom 10 water${t}.lammpstrj

restart 10 water${t}a.restart water${t}b.restart

thermo_style custom step elapsed temp
thermo 10

run 100

write_data water${t}_.init nocoeff
clear
next t

jump water.in #loop_temperature
The script runs and creates the water280.* files, and then starts to initialize the water290 simulation. It creates the water290 restart files and the lammpsrj file, but then stops. A previous attempt, ran all the simulations, created all restart files, all init files, outputted themo data in the correct file, but will not open and write the water290 and water300 lammpstrj files.

Hi @np20837269,

Please take a look at the posting guidelines. The advices there could help you narrow your problem better and make a more detailed new post if you still have issues so you can get adequate answers.

So I read the posting guidelines again, and aside from including the LAMMPS version and platform, (LAMMPS 15JUN23, Linux). I’m not sure how else to ask the question to get help. Is there anything else I need to do to receive assistance?

Of the top of my head I think the following points are all mentioned and should apply (in addition to giving reference to the version and platform and command line arguments used, if any):

  1. Don’t attach your post to an old discussion, please start a new topic
  2. Your input is not quoted correctly and thus misformatted and not properly readable
  3. Your provided input is incomplete, so people cannot reproduce what you are saying and make experiments to improve your input.
  4. Your input is plastered with commented out code lines that make it very difficult to read and understand. It is usually best to construct a simple demonstration input that just demonstrates your problem
  5. You are asking about the function of the various commands, but those are all discussed in detail in the documentation. So if you have problems understanding any specific details, you need to point out which parts are not clear to you.
  6. You are referring to some previous file without us knowing how exactly it was different
  7. Don’t make any assumptions that people reading this know all about your simulations and what you did, so rather explain too much and with too much detail that too little (like you did). Remember, we cannot look over your shoulder and thus do not see what you see, and neither can we read minds and thus do not know what you know. For responding online that is a serious limitation and the better you make up for it, the better your chances for meaningful feedback instead of people complaining.