Skip to content

Commit

Permalink
PwParser: add support for output format of pw.x v6.6 (#552)
Browse files Browse the repository at this point in the history
Quantum ESPRESSO pw.x v6.6 not only comes with a new schema for the XML
output file, which is added here such that it can be parsed, it also has
changes to the standard output format. In a simple SCF calculation for a
silicon structure as a test, one change turned out to be problematic.
The line containing the Harris-Foulkes estimate that used to be printed
directly after the computed total energy has been removed. This line
itself was never parsed anyway, but the estimated SCF accuracy that is
printed afterwards was, and the parser relied on it being two lines
after the total energy. The parser is now adapted to, starting from the
total energy line, scout 5 lines ahead for the line containing the
marker of the estimate SCF accuracy. This once more shows how we should
not rely on parsing textual output.
  • Loading branch information
sphuber authored Sep 14, 2020
1 parent 61fe3b4 commit fe75c80
Show file tree
Hide file tree
Showing 6 changed files with 2,455 additions and 2 deletions.
21 changes: 19 additions & 2 deletions aiida_quantumespresso/parsers/parse_raw/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,21 @@ def parse_stdout(stdout, input_parameters, parser_options=None, parsed_xml=None)
try:

En = float(line.split('=')[1].split('Ry')[0]) * ry_to_ev
E_acc = float(data_step[count + 2].split('<')[1].split('Ry')[0]) * ry_to_ev

# Up till v6.5, the line after total energy would be the Harris-Foulkes estimate, followed by the
# estimated SCF accuracy. However, pw.x v6.6 removed the HF estimate line.
marker = 'estimated scf accuracy'
for i in range(5):
subline = data_step[count + i]
if marker in subline:
try:
E_acc = float(subline.split('<')[1].split('Ry')[0]) * ry_to_ev
except Exception:
pass
else:
break
else:
raise KeyError('could not find and parse the line with `{}`'.format(marker))

for key, value in [['energy', En], ['energy_accuracy', E_acc]]:
trajectory_data.setdefault(key, []).append(value)
Expand Down Expand Up @@ -716,7 +730,10 @@ def parse_stdout(stdout, input_parameters, parser_options=None, parsed_xml=None)
trajectory_data.setdefault('energy_vdw', []).append(value)
break
parsed_data['energy_vdw' + units_suffix] = default_energy_units
except Exception:
except Exception as exception:
import traceback
traceback.print_exc()
print(exception)
logs.warning.append('Error while parsing for energy terms.')

elif 'the Fermi energy is' in line:
Expand Down
Loading

0 comments on commit fe75c80

Please sign in to comment.