Parsing a QChem Output File: Difference between revisions

From Thom Group Wiki
Jump to navigation Jump to search
(Created page with "__TOC__ ==Summary==")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:


==Summary==
==Summary==
To extract all data from a QChem output file, you can use the QChemParser object from <pre>qcmagic.interfaces.parsers.qchem_parser.qchem_parser</pre>
Parsing is not automatic, you first have to create a parser object
<pre>parser = QChemParser('/path/to/file.out')</pre>
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.
<pre>
>> data = parser([])
>> for key in data.keys(): print(key)
prelude
input
molecule
rem
postlude
geometry
</pre>
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 single-point calculation.
<pre>
>> 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
</pre>
Each of the keys corresponds to a dictionary containing the relevant information, for example we can look at the 'scf' information
<pre>
>> print(data['scf'])
{'cycles': {1: {'energy': -0.6434040867, 'diis error': 9.04e-17}, 2: {'energy': -1.0661086494, 'diis error': 9.04e-17}}, 'minima': {0: {}}}
</pre>

==[[RevQCMagic|Return]]==

Latest revision as of 17:12, 1 April 2026

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 single-point calculation.

>> 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