3

I have several .xyz files (each composed of several molecules) and I'd like to find an automated way to visualize and save them. I'd appreciate any guidance.

Rose
  • 31
  • 3

3 Answers3

3

You can use VMD to do this.

Note that the following is only tested on Linux with VMD version 1.9.2, i don't know how it works out on Windows or Apple OS.

The following is from a script that i used to render a trajectory. The first thing to do is to load your xyz file as trajectory. I.e. in a format so that vmd allows you to "slide" through the structures in its normal view. Then execute the script in the tlc console. The script iterates over the steps in incremenets of 2 and assumes that you have 2000 structures. The iteration variable is i. The actual command that changes the frames is the animate goto $i command. You would need to adjust that to fit your requirement. I used the tachyion renderer and saved the output figures in tga format. You will most likely have to adjust the path to the renderer binary which is the path /software/vmd-1.9.2/lib/vmd/tachyon_LINUXAMD64 in my case. VMD saves first a .dat file that contains the scene and then applies the renderer to this dat file. This is why i am setting two path variables, first fin for the .dat file and then fout for the actual tga file.

for {set i 0} {$i < 2001} {incr i 2} {
animate goto $i
set fin [format "pic_%04d.dat" $i]
set fout [format "pic_%04d.tga" $i]
render Tachyon $fin "/software/vmd-1.9.2/lib/vmd/tachyon_LINUXAMD64" -aasamples 12 $fin -format TARGA -o $fout -res 1920 1080
}

The nice part about this is that you can implement other commands during your loop, like a zoom or a rotation. All you have to do, is find out what the tcl command in vmd is.

Hans Wurst
  • 1,245
  • 7
  • 15
2

I recommend using software called ChemCraft. The software isn't free; however, they offer a 150 day trial period. I typically use this program to open formatted checkpoint files from Gaussian calculations to view orbitals. It has plenty of other functions, including the ability to open multiple .xyz files and save multiple images.

The default colors are a bit yucky, but I recommend using one of the following from the Display menu: CPK, GaussView, or Spartan. Those will color atoms with the typical scheme: Nitrogen (blue), Oxygen (red), etc.

I hope this helps!

  • 7
    There are also programs such as jmol, avogadro, and pymol (which can be obtained for free if you compile it yourself). There just isn't really any good reason to pay for a software if you all you want to do is use it for visualization. – jheindel Sep 19 '20 at 04:25
0

If you want to use Python, you could

  1. Use ase to load the xyz file structure by structure, see here.
  2. Then use existing molecular visualization tools, such as the kind built into ase, see here. Or use other such as pyxtal. These can be saved as images directly using Python scripts.
  3. Write a short script to iterate over all your structures.

Alternatively, Ovito can also do this, but requires a somewhat steeper learning curve.

QGent
  • 76
  • 6