QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: ashokgrg19 on January 18, 2018, 22:05

Title: About Tracking the coordinates of each atom
Post by: ashokgrg19 on January 18, 2018, 22:05
Hi There,
I am trying to get each coordinates of the atom for each time interval in molecular dynamics. How can I get these information?
Thanks,
Ashok
Title: Re: About Tracking the coordinates of each atom
Post by: Jess Wellendorff on January 19, 2018, 15:50
The script below reads the images in a saved MD trajectory and prints the coordinates of a particular atom (identified by the index i) in each image. Pretty easy to expand this script to also store the coordinates in a list for plotting purposes.
Code
trajectory = nlread('MD_trajectory.hdf5', MDTrajectory)[-1]
images = trajectory.coordinates()
i = 0
for image in images:
    position = image[i]
    print position
Title: Re: About Tracking the coordinates of each atom
Post by: ashokgrg19 on January 23, 2018, 04:33
Thank you for the information.
What about the mixture of atoms, for example: we have a cluster of atoms like Hydrogen, Helium and Tungsten. if I want to find the coordinates of hydrogen atoms only in the cluster, is it possible to do that? I am asking these questions because I am looking for the trajectory that hydrogen follow throughout simulation.
Thanks,
Ashok
Title: Re: About Tracking the coordinates of each atom
Post by: Petr Khomyakov on January 23, 2018, 11:20
This script print out the position of H atoms along the MD trajectory.

trajectory=nlread('trajectory.hdf5',MDTrajectory)[-1]
images=trajectory.coordinates()

for image in range(len(images)):
  elements=trajectory[image].elements()

  for n in range(len(elements)):
      element=trajectory[image].elements()[n].symbol()
   
      if element=='H':
           position=images[image][n]
           print position

You may have a look at our manual, https://docs.quantumwise.com/manuals/Types/MDTrajectory/MDTrajectory.html, for details on what kind of information can be extracted from the MD trajectory file.  To be able to do scripting, you may also want learning some basic python at https://docs.quantumwise.com/manuals/Python.html, and there is more on the web.
Title: Re: About Tracking the coordinates of each atom
Post by: ashokgrg19 on January 23, 2018, 22:21
Thanks for the help
Title: Re: About Tracking the coordinates of each atom
Post by: ashokgrg19 on January 24, 2018, 17:50
Hi,
I tried to run the code that you provided to me but it keeps saying 
"Traceback (most recent call last):
  File "Test1.py", line 76, in <module>
    elements=trajectory[image].elements()
TypeError: 'MDTrajectory' object does not support indexing.
 
I am wondering it is because of the version of the quantumwise that I used. I am using Quantumwise 2016.4, because I know hdf5 format works for the latest version of quantumwise.
Thanks,
Ashok
Title: Re: About Tracking the coordinates of each atom
Post by: Petr Khomyakov on January 26, 2018, 14:19
That should have worked in the 2017 version. For ATK-2016, you should adjust the script as follows.

Code
trajectory=nlread('trajectory.nc',MDTrajectory)[-1]
images=trajectory.coordinates()

for image in range(len(images)):
  elements=trajectory.image(image).elements()

  for n in range(len(elements)):
      element=elements[n].symbol()

      if element=='H':
           position=images[image][n]
           nlprint(position)
Title: Re: About Tracking the coordinates of each atom
Post by: ashokgrg19 on January 27, 2018, 05:15
Thank you for the help
Ashok