Problem reading all atoms and all frames in xyz file

242 views
Skip to first unread message

Otakandza Glenn

unread,
Nov 3, 2021, 11:23:30 AM11/3/21
to MDnalysis discussion
Hello everyone,

I am a new user of MDAnalysis,
I am reading an xyz file containing 6 (Cr,Fr,Ni,Mo,C,H) atom types, of which the first 4 represent my substrate and the other two represent the atoms I deposit on the substrate at each time step.
The problem is that MDAnalysis only reads the atoms of the substrate, the first 4, and does not read the other 2. Also, it only reads the first two frames (0 and 1).
My file has a total of 400 frames and I would like to read it with all the atoms to do my analysis.

Does anyone have any ideas?

I have attached a picture and a link to the xyz file

Thank you very much.



file.PNG

Lily Wang

unread,
Nov 3, 2021, 11:33:40 AM11/3/21
to mdnalysis-...@googlegroups.com
Dear Otakandza,

Which version of MDAnalysis are you using? When I load your file, I get a trajectory of 416 frames with 7840 atoms. I’m using the 2.1.0-dev version of MDAnalysis, but that should be very similar to the released 2.0 version available via pip or conda installation (https://userguide.mdanalysis.org/stable/installation.html#conda)

>>> import MDAnalysis as mda
>>> u = mda.Universe("dump.C2H.xyz")
>>> u
<Universe with 7840 atoms>
>>> len(u.trajectory)
416
>>> mda.__version__
'2.1.0-dev0'


Cheers,
Lily



--
You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/f84a4afb-a9ed-466a-9020-7a5c083ba5ban%40googlegroups.com.
<file.PNG>

Otakandza Glenn

unread,
Nov 3, 2021, 12:05:20 PM11/3/21
to mdnalysis-...@googlegroups.com
Thank you very much, Lily, for your reply,
I have version 2.0 and I just updated it again and it still returns version 2.0. However I was able to find out the size of the trajectories, normally I do not know why it shows 416 trajectories, with VMD I read 400 frames.

However, the program does not always read the C and H atoms. 7840 atoms it reads are those of the substrate and does not read the atoms injected during the simulations.

I do not know if you can see this?

Sincerely,
Glenn

You received this message because you are subscribed to a topic in the Google Groups "MDnalysis discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mdnalysis-discussion/N3vyIigfo3E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/D6A39132-C591-43FB-8A77-619B3B01259F%40minium.com.au.

Otakandza Glenn

unread,
Nov 3, 2021, 12:06:51 PM11/3/21
to mdnalysis-...@googlegroups.com
Thank you very much, Lily, for your reply,
I have version 2.0 and I just updated it again and it still returns version 2.0. However I was able to find out the size of the trajectories, normally I do not know why it shows 416 trajectories, with VMD I read 400 frames.

However, the program does not always read the C and H atoms. 7840 atoms it reads are those of the substrate and does not read the atoms injected during the simulations.

I do not know if you can see this?

Sincerely,
Glenn

file_2.PNG

Lily Wang

unread,
Nov 3, 2021, 12:17:33 PM11/3/21
to mdnalysis-...@googlegroups.com
Dear Glenn,

Apologies for using the wrong name before.

Unfortunately MDAnalysis cannot handle the kind of trajectory you have here, where there are different numbers of atoms:

Frame 0: 7840 atoms (successfully read)
Frame 1: 7843 atoms (successfully reads first 7840 atoms, ignores last 3)
Frame 2: 7843 atoms (breaks here)

In MDAnalysis, trajectories must have the same number of atoms for each frame. The XYZReader is probably breaking upon reading Frame 2 because it is trying to read a new frame, but instead it is reading the last three atoms of Frame 1. That might also be why it’s showing 416 frames when you look at the length of the trajectory (although I can see the same behaviour as you, I can only index u.trajectory[0] and u.trajectory[1]).

If you add the C/C/H atoms to the first frame (maybe with zero coordinates), or drop the first frame, you'll be able to use MDAnalysis.

I hope that helps, please let me know if you have any more questions!

Cheers,
Lily

Reply all
Reply to author
Forward
0 new messages