run multiple lammps simulation in a consecutive way

Dear lammps-users,

I want to loop over my lammps input script file to run multiple simulations in a consecutive way, using the last simulation’s restart file as the next simulation’s initial input file. During one computing process, lammps will output the trajectory file-dump file and restart file. And then I will run my script to analyze the dump file to get the result I want, after that the dump file will be overlaped by the next new simulation.

for run in 1 2 3 4; # Run multiple simulations in a consecutive way

lammps simulation… # writes trajectory file and restart file

python_script analyze 0 $run &

python_script analyze 1 $run &

python_script analyze 2 $run &

python_script analyze 3 $run &

python_script analyze 4 $run &

done

Try this:

(1) write an input script that reads a restart file, performs a run,

and appends output to a dump file, and writes a new restart file

which includes the final timestep in the filename

(2) If your read_restart command includes the “*” char
in the filename, it will read the highest numbered restart
file that exists.

Thus you can run this script again and again to continue a simulation.

Note that this has nothing to do with Python. People do this for
batch queue systems, where they want their simulaion to run

multiple times in chunks to enable a very long simulation.

Steve

Dear lammps-users,

I want to loop over my lammps input script file to run multiple simulations
in a consecutive way, using the last simulation's restart file as the next
simulation's initial input file. During one computing process, lammps will
output the trajectory file-dump file and restart file. And then I will run
my script to analyze the dump file to get the result I want, after that the
dump file will be overlaped by the next new simulation.

for run in 1 2 3 4; # Run multiple simulations in a consecutive way

lammps simulation.... # writes trajectory file and restart file

python_script analyze 0 $run &

python_script analyze 1 $run &

python_script analyze 2 $run &

python_script analyze 3 $run &

python_script analyze 4 $run &

done

~

Has anyone done that before? If yes, could you share your script with me? Or
any suggestions will be welcomed. Thanks very much.

this is most easily done with a "real" scripting language, i.e. not
the one inside of LAMMPS.

e.g. using a bourne shell script:

for run in `seq 1 4`
do \
    mpirun lmp_mpi -in in.script -log log.script.\{run\} \-var run {run}
    ./python_script analyze 0 \{run\}     \./python\_script analyze 1 {run}
    ./python_script analyze 2 \{run\}     \./python\_script analyze 3 {run}
    ./python_script analyze 4 ${run}
done

axel.

ps. you most likely do *not* want to background your analysis this way
or your next loop iteration will start before your analysis is
completed. either drop the '&' or add a 'wait' before the 'done' or
you'll have problems with your analysis and/or create a so-called
"fork-bomb".