Loop for input file name

Hi all,

I have several hundred lammps data files with slight changes in structure that I would like to perform the same procedure on. The input files have ordered names like data11, data12, data 2*3 etc. I’m using read_data to read all those data files. How could I achieve this? Any help would be appreciated.

Thanks,

Hao

You could use a BASH script to get a list of all of these data files and then create and run a LAMMPS script.

Something like this:
file_array=$(find ./ -name “data*”)

for file in ${file_array[@]}
do

Start writing your input scripts here

cat <${file}.in

Your LAMMPS settings here

read_data ${file}

More LAMMPS commands here

EOM

Run LAMMPS script

mpirun -n 10 ${file}.in
done

you could create a file with all the files and then use a file style variable to read them in and loop over them in a LAMMPS input.
please see the documentation for the variable command.

axel

Thank you all for the advice. They are very helpful!

Hao