Author Topic: About Tracking the coordinates of each atom  (Read 5424 times)

0 Members and 1 Guest are viewing this topic.

Offline ashokgrg19

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Country: us
  • Reputation: 0
    • View Profile
About Tracking the coordinates of each atom
« 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

Offline Jess Wellendorff

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 933
  • Country: dk
  • Reputation: 29
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #1 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

Offline ashokgrg19

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Country: us
  • Reputation: 0
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #2 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

Offline Petr Khomyakov

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 1290
  • Country: dk
  • Reputation: 25
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #3 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.

Offline ashokgrg19

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Country: us
  • Reputation: 0
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #4 on: January 23, 2018, 22:21 »
Thanks for the help

Offline ashokgrg19

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Country: us
  • Reputation: 0
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #5 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

Offline Petr Khomyakov

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 1290
  • Country: dk
  • Reputation: 25
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #6 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)
« Last Edit: January 26, 2018, 14:21 by Petr Khomyakov »

Offline ashokgrg19

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Country: us
  • Reputation: 0
    • View Profile
Re: About Tracking the coordinates of each atom
« Reply #7 on: January 27, 2018, 05:15 »
Thank you for the help
Ashok