3
$\begingroup$

Here is the .XYZ format file NP3D.XYZ

Somehow i cannot import this file.It return an error box :- "Cannot Import Data As XYZ Format."

it contains 1000 snapshot of 10 Carbon particles coordinate moving in a box that i have to visualise.

$\endgroup$
6
  • $\begingroup$ Is the pastebin ok? Please contemplate @OleksandrR. comment verry well! $\endgroup$
    – user9660
    Apr 22, 2016 at 17:28
  • 1
    $\begingroup$ from the wikipedia page en.wikipedia.org/wiki/XYZ_file_format "There is no formal standard and several variations exist" $\endgroup$
    – george2079
    Apr 22, 2016 at 17:40
  • $\begingroup$ I'm wondering where do you get the simulation data from? $\endgroup$ Apr 22, 2016 at 18:24
  • 1
    $\begingroup$ Also, what are the units in that file? If angstroms then those atoms are very close together $\endgroup$
    – Jason B.
    Apr 22, 2016 at 18:56
  • $\begingroup$ I really think you need to find out what units these are in, most of the time the units are angstroms, and that is what MMA assumes. Also, it will try to draw bonds between close atoms, which I don't think you want here at all. Figure out he units, and whether you want bonds and then we can help give a better solution. $\endgroup$
    – Jason B.
    Apr 23, 2016 at 7:53

2 Answers 2

7
$\begingroup$

It does not work because of different data elements, compare

Import["ExampleData/caffeine.xyz"]

enter image description here

with data structure

enter image description here

and your data structure:

enter image description here

but change it to:

enter image description here

with

Import["NP3D.xyz"]

you will get:

enter image description here

full data looks like

enter image description here


You can make an animation with these snapshots:

data1 = StringRiffle[#, "\n"] & /@ 
   Split[ReadList["/Users/xslittlegrass/Downloads/NP3D.xyz", 
      "String"], #2 =!= "10" &][[All, 3 ;; -1]];

data = ParallelMap[ImportString[#, "XYZ"] &, data1]; // AbsoluteTiming

Export["~/Downloads/1.gif", data[[46 ;; 146]]]

enter image description here

$\endgroup$
5
  • $\begingroup$ is there a way for me to change whole data structure from start until end? @Louis $\endgroup$
    – Nabil
    Apr 22, 2016 at 16:27
  • $\begingroup$ Is this ok? pastebin.com/CPWBAPnj $\endgroup$
    – user9660
    Apr 22, 2016 at 17:16
  • 1
    $\begingroup$ It's not okay to just remove the intermediate lines. There are 1000 different structures recorded in the file; drawing these all on top of each other is not what OP wants. Rather, some Manipulate (or something like that) to step through each structure is what is desired. But, OP should be able to sort this out for themselves IMO. $\endgroup$ Apr 22, 2016 at 17:24
  • $\begingroup$ @OleksandrR., i guess you are right, feel free to edit or answer on your self $\endgroup$
    – user9660
    Apr 22, 2016 at 17:26
  • $\begingroup$ Thank You @Louis . the new data u give is nice $\endgroup$
    – Nabil
    Apr 23, 2016 at 15:28
2
$\begingroup$

This will split the text into chunks and plot them as molecular plots,

imglist = ImportString[ExportString[#, "Table"], "XYZ"] & /@
   Partition[
    StringSplit[
     Import["http://comsics.usm.my/tlyoon/teaching/ZCE111_1516SEM2/\
data/NP3D.xyz", "Text"], "\n"], 12];

But, those carbon atoms sure are close together....

imglist[[405]]

enter image description here

Maybe the units are not angstroms?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.