How to parse and write

The cclib package provides three scripts to parse and write data i.e. ccget, ccwrite, and cda

  1. ccget is used to parse attribute data from output files.
  2. ccwrite has the ability to list out all valid attribute data that can be parsed from an output format. It has the added feature of writing the output file into four different formats i.e. json, cjson, cml, xyz.
  3. cda is used for the chemical decomposition analysis of output files.

This page describes how to use the ccget and ccwrite scripts to obtain data from output files.

ccget

The data types that can be parsed from the output file depends on the type of computation being conducted. The name of the output file used to show example usage is Benzeneselenol.out.

Data type can be parsed from the output file by following this format

ccget <attribute> [<attribute>] <CompChemLogFile> [<CompChemLogFile>]

where attribute can be any one of the attribute names available here

  1. Atomic Charges
The atomic charges are obtained by using the atomcharges attribute with ccget
$ ccget atomcharges Benzeneselenol.out
Attempting to read Benzeneselenol.out
atomcharges:
{'mulliken': array([-0.49915 ,  0.056965,  0.172161,  0.349794, -0.153072,  0.094583,
    0.016487,  0.050249,  0.002149,  0.01161 ,  0.053777, -0.173671,
    0.018118])}
  1. Electronic Energies
The molecular electronic energies after SCF (DFT) optimization of the input molecule is obtained by using the scfenergies attribute with ccget
$ ccget scfenergies Benzeneselenol.out
Attempting to read Benzeneselenol.out
scfenergies:
[-71671.43702915 -71671.4524142  -71671.4534768  -71671.45447492
-71671.4556548  -71671.45605671 -71671.43194906 -71671.45761021
-71671.45850275 -71671.39630296 -71671.45915119 -71671.45935854
-71671.4594614  -71671.45947338 -71671.45948807 -71671.4594946
-71671.4594946 ]
  1. Geometry Targets
The targets for convergence of geometry optimization can be obtained by using the geotargets attribute with ccget
$ ccget  geotargets Benzeneselenol.out
Attempting to read Benzeneselenol.out
geotargets:
[ 0.00045  0.0003   0.0018   0.0012 ]

Chaining of attributes

ccget provides the user with the option to chain attributes to obtain more than one type of data with a command call. The attributes can be chained in any particular order. A few chained examples are provided below.

  1. Molecular Orbitals and Multiplicity
The number of molecular orbitals and the number of basis functions used to optimize the molecule can be obtained by running the following command
$ ccget nmo nbasis Benzeneselenol.out
Attempting to read Benzeneselenol.out
nmo:
405
nbasis:
407
  1. Enthalpy and Vibrational Frequency
The enthalpy and the vibrational frequencies of the optimized molecule is conducted is obtained below:
$ ccget enthalpy vibfreqs Benzeneselenol.out
Attempting to read Benzeneselenol.out
enthalpy:
-2633.77264
vibfreqs:
[  129.5512   170.6681   231.4278   304.8614   407.8299   472.5026
   629.9087   679.9032   693.2509   746.7694   812.5113   850.2578
   915.8742   987.1252   988.1785  1002.8922  1038.1073  1091.4005
  1102.3417  1183.3857  1209.2727  1311.3497  1355.6441  1471.4447
  1510.1919  1611.9088  1619.0156  2391.2487  3165.1596  3171.3909
  3182.0753  3188.5786  3198.0359]

ccwrite

The same Benzeneselenol.out file used in the previous examples will be used as the input file for ccwrite. When the ccwrite script is used with a valid input, it prints out the valid attributes that can be parsed from the file.

Command line format:

ccwrite <OutputFileFormat>  <CompChemLogFile> [<CompChemLogFile>]

The valid output file formats are json, cjson, cml, xyz

  1. CML
$ ccwrite cml Benzeneselenol.out
Attempting to parse Benzeneselenol.out
cclib can parse the following attributes from Benzeneselenol.out:
  atomcharges
  atomcoords
  atomnos
  charge
  coreelectrons
  enthalpy
  geotargets
  geovalues
  grads
  homos
  moenergies
  mosyms
  mult
  natom
  nbasis
  nmo
  optdone
  optstatus
  scfenergies
  scftargets
  temperature
  vibdisps
  vibfreqs
  vibirs
  vibsyms

A Benzeneselenol.cml output file is generated in the same directory as the Benzeneselenol.out file.

<?xml version='1.0' encoding='utf-8'?>
<molecule id="Benzeneselenol.out" xmlns="http://www.xml-cml.org/schema">
  <atomArray>
    <atom elementType="C" id="a1" x3="-2.8947620000" y3="-0.0136420000" z3="-0.0015280000" />
    <atom elementType="C" id="a2" x3="-2.2062510000" y3="1.1938510000" z3="-0.0025210000" />
    <atom elementType="C" id="a3" x3="-0.8164260000" y3="1.2153020000" z3="-0.0022010000" />
    <atom elementType="C" id="a4" x3="-0.1033520000" y3="0.0183920000" z3="0.0031060000" />
    <atom elementType="C" id="a5" x3="-0.7906630000" y3="-1.1943840000" z3="0.0058500000" />
    <atom elementType="C" id="a6" x3="-2.1799570000" y3="-1.2059710000" z3="0.0017890000" />
    <atom elementType="H" id="a7" x3="-3.9758430000" y3="-0.0253010000" z3="-0.0029040000" />
    <atom elementType="H" id="a8" x3="-2.7502340000" y3="2.1291370000" z3="-0.0052760000" />
    <atom elementType="H" id="a9" x3="-0.2961840000" y3="2.1630180000" z3="-0.0073260000" />
    <atom elementType="H" id="a10" x3="-0.2474670000" y3="-2.1302310000" z3="0.0132260000" />
    <atom elementType="H" id="a11" x3="-2.7028960000" y3="-2.1530750000" z3="0.0036640000" />
    <atom elementType="Se" id="a12" x3="1.8210800000" y3="-0.0433780000" z3="-0.0038760000" />
    <atom elementType="H" id="a13" x3="2.0043580000" y3="1.4100070000" z3="0.1034490000" />
  </atomArray>
  <bondArray>
    <bond atomRefs2="a9 a3" order="1" />
    <bond atomRefs2="a8 a2" order="1" />
    <bond atomRefs2="a12 a4" order="1" />
    <bond atomRefs2="a12 a13" order="1" />
    <bond atomRefs2="a7 a1" order="1" />
    <bond atomRefs2="a2 a3" order="2" />
    <bond atomRefs2="a2 a1" order="1" />
    <bond atomRefs2="a3 a4" order="1" />
    <bond atomRefs2="a1 a6" order="2" />
    <bond atomRefs2="a6 a11" order="1" />
    <bond atomRefs2="a6 a5" order="1" />
    <bond atomRefs2="a4 a5" order="2" />
    <bond atomRefs2="a5 a10" order="1" />
  </bondArray>
</molecule>
  1. xyz

Using xyz as the <OutputFileFormat> with Benzeneselenol.out, we obtain the following Benzeneselenol.xyz file

13
Benzeneselenol.out: Geometry 17
C     -2.8947620000   -0.0136420000   -0.0015280000
C     -2.2062510000    1.1938510000   -0.0025210000
C     -0.8164260000    1.2153020000   -0.0022010000
C     -0.1033520000    0.0183920000    0.0031060000
C     -0.7906630000   -1.1943840000    0.0058500000
C     -2.1799570000   -1.2059710000    0.0017890000
H     -3.9758430000   -0.0253010000   -0.0029040000
H     -2.7502340000    2.1291370000   -0.0052760000
H     -0.2961840000    2.1630180000   -0.0073260000
H     -0.2474670000   -2.1302310000    0.0132260000
H     -2.7028960000   -2.1530750000    0.0036640000
Se     1.8210800000   -0.0433780000   -0.0038760000
H      2.0043580000    1.4100070000    0.1034490000