Parsing a QChem Output File

From Thom Group Wiki
Revision as of 16:15, 31 March 2026 by Jst55 (talk | contribs) (→‎Summary)
Jump to navigation Jump to search

Summary

To extract all data from a QChem output file, you can use the QChemParser object from

qcmagic.interfaces.parsers.qchem_parser.qchem_parser

Parsing is not automatic, you first have to create a parser object

parser = QChemParser('/path/to/file.out')

The actual parsing occurs when you call the parser object with a list of sections you want it to parse, if you pass an empty list then it only parses the default sections, which are prelude, input, molecule, rem, postlude and geometry.

>> data = parser([])
>> for key in data.keys(): print(key)
prelude
input
molecule
rem
postlude
geometry

However you can use the find_sections method to detect extra sections which may be parsed. In this example the output file is for a simple

>> print(parser.find_sections())
['input', 'sno', 'number_of_electrons', 'scf', 'mos']
>> data = parser(['number_of_electrons', 'scf'])
>> for key in data.keys(): print(key)
prelude
input
molecule
rem
number_of_electrons
scf
postlude
geometry

Each of the keys corresponds to a dictionary containing the relevant information, for example we can look at the 'scf' information

>> print(data['scf'])
{'cycles': {1: {'energy': -0.6434040867, 'diis error': 9.04e-17}, 2: {'energy': -1.0661086494, 'diis error': 9.04e-17}}, 'minima': {0: {}}}

Return