[ase-users] Extracting data from Trajectory object

Ask Hjorth Larsen asklarsen at gmail.com
Tue Oct 4 10:53:01 CEST 2016


Dear Zeeshan

2016-10-04 1:49 GMT+02:00 Zeeshan Ahmad via ase-users
<ase-users at listserv.fysik.dtu.dk>:
> Hi,
>
> We can read a trajectory file and get info about all the steps using:
>
> atoms = read(’name.traj’,index=‘:’)
>
> I wanted to know if there was a way to extract data for all steps from a
> Trajectory object which was created and attached to some dynamics object.
> For eg:
>
> dyn = NPT(atoms=atoms,timestep=2.0*units.fs,temperature=600*units.kB,pfactor
> = None,mask=(0,0,0),ttime=25.0*units.fs,externalstress=0) #NVT
> traj = Trajectory('Diff.traj','w',atoms)
> dyn.attach(traj.write,interval=1)
> dyn.run(2000)
>
> After running for the required number of steps, one way to post process data
> is to use:
>
> readtraj = read(‘Diff.traj’,index=‘:’)
>
> which gives a list of atoms objects for all 2000 steps. Is there a way to
> extract this info from the Trajectory object called traj without reading the
> .traj file?

At each step of the MD simulation, the geometry is dumped to the file.
After dumping it to the file, it will not be stored in memory as these
trajectories could get very large.  Thus, the only way to regain the
information is to read the file.

If you want to do some work on the configuration /before/ writing to
the file, you can write an observer for that (which eventually calls
write, presumably).

Best regards
Ask

>
> Thanks,
> --
> Zeeshan Ahmad
> PhD student, Mechanical Engineering
> Carnegie Mellon University
> email: azeeshan at andrew.cmu.edu
> http://www.andrew.cmu.edu/user/azeeshan/
>
>
>
>
>
>
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users



More information about the ase-users mailing list