GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing cclib.github.io — How to parse and write — cclib 1.8.1 documentation How to parse and writeThis page outlines the various ways cclib can be used to parse and write logfiles, and provides several examples to get you started. From PythonImporting cclib and parsing a file is a few lines of Python code, making it simple to access data from the output file of any supported computational chemistry program. For example: >>> import cclib >>> filename = "water.out" >>> parser = cclib.io.ccopen(filename) >>> data = parser.parse() >>> print("There are %i atoms and %i MOs" % (data.natom, data.nmo)) There are 3 atoms and 7 MOs A newer command, >>> import cclib >>> filename = "logfile.out" >>> data = cclib.io.ccread(filename) >>> print("There are %i atoms and %i MOs" % (data.natom, data.nmo)) There are 3 atoms and 7 MOs The >>> dir(data) [(...), 'atomcoords', 'atommasses', 'atomnos', 'charge', (...), 'mult', 'natom, 'nbasis', ...] You can find a full list of these attribute on the parsed data page. From command lineThe cclib package provides four scripts to parse and write data:
This page describes how to use the ccget, ccwrite and ccframe scripts to obtain data from output files. ccgetThe 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 Data type can be parsed from the output file by following this format: ccget <attribute> [<attribute>] <CompChemLogFile> [<CompChemLogFile>] where
Chaining of attributesccget 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.
ccwriteThe 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
A <?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> Using 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 ccframeThis script creates complete tables of data from output files in some of the formats supported by pandas. Since the pandas library is not a dependency of cclib, it must be installed separately. A complete data table can be parsed from many output files by following this format: ccframe [--force|-f] -O <OutputDest> <CompChemLogFile> [<CompChemLogFile>...] The argument for |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |