Sunday, January 26, 2020

computational chemistry - Extract all structures of Gaussian 09 molecular dynamics calculation using babel?


Is there a way to easily extract all the structures and energies from an ADMP calculation done in Gaussian 09? GaussView can plot them but not export them in a useful way and babel just gives me the last structure in there.


I tried


babel  all -oxyz  

but I get just


==============================
*** Open Babel Error in OpenAndSetFormat

Cannot open all
1 molecule converted
1 errors 16 audit log messages

Or is there a different easy way to do this? Otherwise I guess I have to write my own script or look into cclib, but that one is using babel too if I understand it correct?


Example output file: http://dl.dropboxusercontent.com/u/6111391/Tz_TCO_dyn6.txt


Input:


%nprocshared=16
%mem=56GB
%chk=Tz_TCO_dyn6.chk

# 6-31g(d) scrf=check geom=(connectivity,crowd)admp=(stepsize=2500,maxpoints=400) rm062x IOp(1/44=990210)

[No Title]

0 1
C 1.08049600 -0.58720100 -2.07918800
C -1.08049600 0.58720100 -2.07918800
C -0.58945000 0.34949100 0.13978700
H -0.52250100 1.43457800 0.23933400
C 0.58945000 -0.34949100 0.13978700

H 0.52250100 -1.43457800 0.23933400
N -1.13318600 -0.73433600 -2.39136300
N 0.00078600 -1.35005000 -2.39250200
N -0.00078600 1.35005000 -2.39250200
N 1.13318600 0.73433600 -2.39136300
C 1.84657900 0.28440600 0.66016000
H 2.75382900 -0.14516700 0.22100400
H 1.84124500 1.35503200 0.42328200
C -1.84657900 -0.28440600 0.66016000
H -2.75382900 0.14516700 0.22100400

H -1.84124500 -1.35503200 0.42328200
C 1.87373600 0.08444000 2.19307200
H 2.72499800 0.64701600 2.59375900
H 2.07520100 -0.97273600 2.41061700
C -1.87373600 -0.08444000 2.19307200
H -2.72499800 -0.64701600 2.59375900
H -2.07520100 0.97273600 2.41061700
C -0.58945000 -0.50859700 2.93023900
H -0.86607100 -0.70606500 3.97132400
H -0.24860000 -1.47389400 2.53270700

C 0.58945000 0.50859700 2.93023900
H 0.86607100 0.70606500 3.97132400
H 0.24860000 1.47389400 2.53270700
H 2.02862900 -1.10167200 -1.96939700
H -2.02862900 1.10167200 -1.96939700

1 8 1.5 10 1.5 29 1.0
2 7 1.5 9 1.5 30 1.0
3 4 1.0 5 2.0 14 1.0
4

5 6 1.0 11 1.0
6
7 8 1.5
8
9 10 1.5
10
11 12 1.0 13 1.0 17 1.0
12
13
14 15 1.0 16 1.0 20 1.0

15
16
17 18 1.0 19 1.0 26 1.0
18
19
20 21 1.0 22 1.0 23 1.0
21
22
23 24 1.0 25 1.0 26 1.0
24

25
26 27 1.0 28 1.0
27
28
29
30

Answer



If you have the latest copy of cclib installed, it can extract both the energies and geometries and write the geometries to an XYZ trajectory file that you can open with Avogadro or VMD.


To print the HF or DFT energies to the screen,


$ ccget scfenergies admp.out


but be warned that the energies are in eV, not hartree.


To dump geometries to XYZ files, here's a simplified version of a script I use all the time:


#!/usr/bin/env python

"""cclib_extract_geom.py: Extract geometries from a quantum chemical
output file using cclib.
"""



from __future__ import print_function

import os.path

from cclib.io import ccopen, ccwrite


def getargs():
"""Get command-line arguments."""


import argparse

parser = argparse.ArgumentParser()

parser.add_argument('outputfilename', nargs='+')

parser.add_argument('--trajectory',
action='store_true',
help="""Extract all possible geometries into a trajectory-like file?""")
parser.add_argument('--suffix')


args = parser.parse_args()

return args


if __name__ == '__main__':

args = getargs()


for outputfilename in args.outputfilename:

job = ccopen(outputfilename)
data = job.parse()

stub = os.path.splitext(outputfilename)[0]
if args.suffix:
xyzfilename = ''.join([stub, '.', args.suffix, '.xyz'])
else:
xyzfilename = ''.join([stub, '.xyz'])


ccwrite(data, outputdest=xyzfilename, allgeom=args.trajectory)

To write the energies in to a text file in hartree, you might add something like


        from cclib.parser.utils import convertor # put me at the top of the file
with open(stub + '.energies', 'w') as fh:
for energy in data.scfenergies:
fh.write(str(convertor(energy, 'eV', 'hartree')) + '\n')

No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...