Load a range of frames from LAMMPS dump

22 views
Skip to first unread message

Ardalan Hayatifar

unread,
Jun 7, 2022, 11:43:24 PMJun 7
to MDnalysis discussion
Hi, 

I have a very large lammps dump file. VMD can't handle it memory-wise, I'm trying to load the last 10 frames of the trajectory file. I'm trying this:

```
$ u = MDAnalysis.Universe("out_test.data",topology_format="LAMMPSDUMP", dt=0.00025, frames=u.trajectory[:5])
$ print(u.trajectory)
<DumpReader out_test.data with 25027 frames of 267 atoms>
```
It seems that it's loading all of the frames.


Thanks in advance for comments/suggestions.



Oliver Beckstein

unread,
Jun 8, 2022, 12:05:52 AMJun 8
to mdnalysis-discussion
Hi Ardalan,

welcome to the MDAnalysis list!

I am not sure what your question is — can you say what you want you expected to happen and what happened instead, or what you’re unclear about?

I’ll just make general comment below:

On Jun 7, 2022, at 6:27 PM, Ardalan Hayatifar <ardalanh...@gmail.com> wrote:

Hi, 

I have a very large lammps dump file. VMD can't handle it memory-wise, I'm trying to load the last 10 frames of the trajectory file. I'm trying this:

```
$ u = MDAnalysis.Universe("out_test.data",topology_format="LAMMPSDUMP", dt=0.00025, frames=u.trajectory[:5])

In principle you don’t need the frames argument. MDAnalysis only loads one frame into memory.

$ print(u.trajectory)
<DumpReader out_test.data with 25027 frames of 267 atoms>
```
It seems that it's loading all of the frames.

That’s fine — it just says that the trajectory contains that many frames. 

You can now use

for ts in u.trajectory[-10:]:
  print(ts.frame, ts.time)
  # do other things…

to look at the last 10 frames.

Oliver



Thanks in advance for comments/suggestions.



--
Oliver Beckstein (he/his/him)

GitHub: @orbeckst

MDAnalysis – a NumFOCUS fiscally sponsored project





Ardalan Hayatifar

unread,
Jun 8, 2022, 2:58:36 PMJun 8
to MDnalysis discussion
Hi Oliver,

Thanks for your reply.

Sorry for the confusion. 
What I intend to do is to load for example the last 10 frames of a lammps trajectory file.
In VMD this can be done, with which I haven't had much luck:
`mol addfile out_test.data type lammpstrj first 1 last 5`

The reason I want to do it this way is that my dump file is huge, and I need to troubleshoot the job by looking at the last few frames. 

Does MDAnalysis load the whole trajectory file into memory? Because it takes forever to make my `MDAnalysis.Universe` from this big trajectory file even with `in_memory=False`

I guess a command like ` u.trajectory[-10:]` works when the whole trajectory file is parsed and the number of frames are known. So I guess my question is mainly for `MDAnalysis.Universe` stage and how make the Universe with a range of frames.

Please let me know if this didn't make sense. 

Thanks.
Reply all
Reply to author
Forward
0 new messages