Output a fix print at specific timesteps defined from a file


I’d like to output some quantities with fix print, at timesteps that will not be defined through an equal-style variable, but through a file. Below, I’ve written as an indication what I’ve tried to do, but for some reason I don’t get the results that I’d expect. I believe that if I want to use a file, I’ll have to loop over each line of the file in the following way, right?

label loop
variable tss file timesteps.txt
if “${tss} == 100” then “jump in.shear_flow break”

fix thermo_print all print {tss} "{varstep} ${vartemp}" append output.thermo title “step temp” screen no
next tss
jump in.shear_flow loop
label break
run 100

You can imagine that the timesteps.txt contains numbers on each row, like 1,7,10,100, which are the desired timesteps at which I want to output.

Thanks a lot,

Please see the post Please Read This First: Guidelines and Suggestions for posting LAMMPS questions for how to properly quote text from input files in this forum software.

Your looping is not quite correct and using fix print is not really meant for that purpose. What should work the way you describe is the following (note how it displays correctly unlike in your post):

variable tss file timesteps.txt
print "step temp" file output.thermo screen no
label loop
run ${tss} upto post no
print "${varstep} ${vartemp}" append output.thermo screen no
next tss
jump SELF loop

Thank you so much Axel!