Author Topic: dump trajectory as XYZ file (atk newbie question)  (Read 2725 times)

0 Members and 1 Guest are viewing this topic.

Offline jrussell

  • Regular QuantumATK user
  • **
  • Posts: 10
  • Country: us
  • Reputation: 1
    • View Profile
Hi ATK, I got a parallel job to run which was very exciting, but unfortunately I am not certain how to dump a XYZ file as a trajectory. I saw in the manual that I can save a trajectory file as a .nc file:
Code
OptimizeGeometry(
        bulk_configuration,
        max_forces=0.05*eV/Ang,
        max_steps=200,
        max_step_length=0.5*Ang,
        trajectory_filename='traj.nc')
        disable_stress=True,
        optimizer_method=QuasiNewton(),
        )
Is there a way to extract the XYZ coordinates from the .nc file at the command line? Or is there a way that I can dump the energy, lattice vectors, and cartesian coordinates as part of the input file? I tried the "nlprint" command with the bulk configuration which is great, but I can't use that command inside the optimizer section, only after its done. Thanks for the help, John

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5428
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: dump trajectory as XYZ file (atk newbie question)
« Reply #1 on: May 29, 2012, 09:54 »
Try this:
Code: python
trajectory = nlread('trajectory.nc')[0]

for ix,image in enumerate(trajectory.images()):
    elements = image.elements()
    print len(elements)
    print 'Image %i' % ix
    for elem,coords in zip(elements,image.cartesianCoordinates()):
        print elem.symbol(),
        for i in coords:
            print i.inUnitsOf(Angstrom),
        print
and pipe the output to an XYZ file. There is some confusion, I think, in the world about how to properly separate two configurations in a multi-configuration XYZ file, viz. if there should be an extra blank line between them or not, but the format produced by the above code is acceptable to JMol at least. In principle you can use nlprint for each image, but it also prints the fractional coordinates, so you would have to clean up the file quite a bit afterwards.

Offline jrussell

  • Regular QuantumATK user
  • **
  • Posts: 10
  • Country: us
  • Reputation: 1
    • View Profile
Re: dump trajectory as XYZ file (atk newbie question)
« Reply #2 on: May 29, 2012, 20:05 »
That worked like a charm. Thanks Anders!
Best,
John