Dear Lammps Users,

I want to analyze a dump file using,
I wrote a module that does that calculation and a main program that invokes it. The parameters that I use in my main program
to call the module is

t = calc_dev.calc_deviat(d1,d2,filename)

where the d1,d2 are the dumps that I assign in main program, and filename is the output file i want to write the analyzed information in.

I have 5 dumps and I need to analyze everyone with everyone.

that means dump_1 with dump_2, with dump_3 , with dump_4 and etc.
the same for dump_2 …

my programm works for dump_1 , dump_2 but when it calculates the dump_1 and dump_3 it says that index out of range on the line where I do
So that probably means that I have already read this dump file, and I can’t read it more.

Is there any way to reset the current snapshot in dump-command to beginning?

here is my module that calculates what I need:

def calc_deviat(d1,d2,filename):
print "Now I am filling the " + filename + “\n”
natoms = 4050
begin_time = 0
fo = open(filename, “wb”)
v2=np.ones((3,natoms), dtype=float)

while 1:
time = ########## THIS IS THE ERROR LINE
print "timestep = ", time
if time == -1: break

calculate and write in file.

return 1

###########Error Message ##########################
<type ‘exceptions.IndexError’> list index out of range <traceback object at 0xa83cd24>
IndexError’> with value: list index out of range
error on line 34 of file ./
error on line 28 of file
error on line 301 of file /home/vasilis/LAMMPS/lammps-6Dec12/tools/pizza-5Aug12/src/

Thank you,

Unless you know some Python
and are willing to look at the code for the tool
in Pizza,py, the simplest thing to do once you have scanned the dumps
once is to just redefine the dump, e.g. d3 = dump(“file3”)
which will read it in again and let you loop over the snapshots
via next. Or you can reset the loop counter inside,
but you will have to look at the Python code to see how to do it.


Thank you Steve, I managed to make it work doing the redefining of the “dump” command. I thought that maybe there is some “magic command” that will do that redefining instead of me. Perhaps I can write this “magic command” by myself and add it . Vasiliy

I refreshed myself on the interface to the dump tool in

The next() method is actually readying the snapshots from the
dump file one-at-a-time. It returns a -1 if it hit the last snapshot
in the file. So if you are coding a loop that uses it, it’s up to
you to check for that. If you want to read the file again,
you have to re-instantiate the dump, as I indicated before, e.g.

d = dump(“foo.dump”,0)

loop over next() calls
d = dump(“foo.dump”,0)
read again

If you read in the entire file (no 0 as 2nd arg)
then you can use the d.iterator() method to

loop over the snapshots as many times as you like,
w/out re-reading the file.

iterator() returns an index which can be used to access
the dump info in that snapshot directly, e.g.

d.snaps[index].atoms is the 2d array of columns, stored as floats

That’s the way other tools loop over info in the dump.