# Calculation parsers¶

This section describes the different parsers classes for calculations.

## Quantum ESPRESSO parsers¶

exception aiida_quantumespresso.parsers.QEOutputParsingError[source]

Exception raised when there is a parsing error in the QE parser

aiida_quantumespresso.parsers.convert_qe2aiida_structure(output_dict, input_structure=None)[source]

Receives the dictionary cell parsed from quantum espresso Convert it into an AiiDA structure object

aiida_quantumespresso.parsers.convert_qe_time_to_sec(timestr)[source]

Given the walltime string of Quantum Espresso, converts it in a number of seconds (float).

aiida_quantumespresso.parsers.get_parser_info(parser_info_template=None)[source]

Return a template dictionary with details about the parser such as the version

Parameters: parser_info_template – template string with single placeholder to be replaced by current version number dictionary with parser name, version and empty list for warnings
aiida_quantumespresso.parsers.ldlparse_QE_errors(lines, count, warnings)[source]

Parse QE errors messages (those appearing between some lines with %%%%%%%%)

Parameters: Return messages: lines – list of strings, the output text file as read by readlines() or as obtained by data.split('\\n') when data is the text file read by read() count – the line at which we identified some %%%%%%%% warnings – the warnings already parsed in the file a list of QE error messages
aiida_quantumespresso.parsers.parse_QE_errors(lines, count, warnings)[source]

Parse QE errors messages (those appearing between some lines with %%%%%%%%)

Parameters: Return messages: lines – list of strings, the output text file as read by readlines() or as obtained by data.split('\\n') when data is the text file read by read() count – the line at which we identified some %%%%%%%% warnings – the warnings already parsed in the file a list of QE error messages
aiida_quantumespresso.parsers.parse_raw_out_basic(out_file, calc_name)[source]

A very simple parser for the standard out, usually aiida.out. Currently only parses basic warnings and the walltime. :param out_file: the standard out to be parsed :param calc_name: the name of the calculation, e.g. PROJWFC :return: parsed_data

### Raw Pw Parser¶

A collection of function that are used to parse the output of Quantum Espresso PW. The function that needs to be called from outside is parse_raw_output(). The functions mostly work without aiida specific functionalities. The parsing will try to convert whatever it can in some dictionary, which by operative decision doesn’t have much structure encoded, [the values are simple ]

aiida_quantumespresso.parsers.raw_parser_pw.cell_volume(a1, a2, a3)[source]

returns the volume of the primitive cell: $$|\vec a_1\cdot(\vec a_2\cross \vec a_3)|$$

aiida_quantumespresso.parsers.raw_parser_pw.convert_list_to_matrix(in_matrix, n_rows, n_columns)[source]

converts a list into a list of lists (a matrix like) with n_rows and n_columns

aiida_quantumespresso.parsers.raw_parser_pw.convert_qe_time_to_sec(timestr)[source]

Given the walltime string of Quantum Espresso, converts it in a number of seconds (float).

aiida_quantumespresso.parsers.raw_parser_pw.parse_QE_errors(lines, count, warnings)[source]
Parse QE errors messages (those appearing between some lines with
%%%%%%%%)
Parameters: Return messages: lines – list of strings, the output text file as read by readlines() or as obtained by data.split('\\n') when data is the text file read by read() count – the line at which we identified some %%%%%%%% warnings – the warnings already parsed in the file a list of QE error messages
aiida_quantumespresso.parsers.raw_parser_pw.parse_pw_text_output(data, xml_data={}, structure_data={}, input_dict={}, parser_opts={})[source]

Parses the text output of QE-PWscf.

Parameters: Return parsed_data: data – a string, the file as read by read() xml_data – the dictionary with the keys read from xml. structure_data – dictionary, coming from the xml, with info on the structure input_dict – dictionary with the input parameters parser_opts – the parser options from the settings input parameter node dictionary with key values, referring to quantities at the last scf step key,values referring to intermediate scf steps, as in the case of vc-relax. Empty dictionary if no value is present. a list with critical messages. If any is found in parsed_data[‘warnings’], the calculation is FAILED!
aiida_quantumespresso.parsers.raw_parser_pw.parse_pw_xml_output(data, dir_with_bands=None)[source]

Parse the xml data of QE v5.0.x Input data must be a single string, as returned by file.read() Returns a dictionary with parsed values

aiida_quantumespresso.parsers.raw_parser_pw.parse_raw_output(out_file, input_dict, parser_opts={}, xml_file=None, dir_with_bands=None)[source]

Parses the output of a calculation Receives in input the paths to the output file and the xml file.

3 different keys to check in output: parser_warnings, xml_warnings and warnings. On an upper level, these flags MUST be checked. The first two are expected to be empty unless QE failures or unfinished jobs.

Parameters: Return parsed_data: out_file – path to pw std output input_dict – dictionary with the input parameters dir_with_bands – path to directory with all k-points (Kxxxxx) folders xml_file – path to QE data-file.xml dictionary with key values, referring to quantities at the last scf step a dictionary with parsed parameters a dictionary with arrays (for relax & md calcs.) a dictionary with data for the output structure a dictionary with data for bands (for bands calcs.) a boolean that is False in case of failed calculations QEOutputParsingError – for errors in the parsing AssertionError – if two keys in the parsed dicts are found to be equal

### Basic Raw Pw Parser¶

This is just a minimal parser for basic quantities.

A collection of function that are used to parse the output of Quantum Espresso PW. The function that needs to be called from outside is parse_raw_output(). The functions mostly work without aiida specific functionalities. The parsing will try to convert whatever it can in some dictionary, which by operative decision doesn’t have much structure encoded, [the values are simple ]

aiida_quantumespresso.parsers.basic_raw_parser_pw.cell_volume(a1, a2, a3)[source]

returns the volume of the primitive cell: |a1.(a2xa3)|

aiida_quantumespresso.parsers.basic_raw_parser_pw.convert_list_to_matrix(in_matrix, n_rows, n_columns)[source]

converts a list into a list of lists (a matrix like) with n_rows and n_columns

aiida_quantumespresso.parsers.basic_raw_parser_pw.convert_qe_time_to_sec(timestr)[source]

Given the walltime string of Quantum Espresso, converts it in a number of seconds (float).

aiida_quantumespresso.parsers.basic_raw_parser_pw.parse_QE_errors(lines, count, warnings)[source]

Parse QE errors messages (those appearing between some lines with '%%%%%%%%')

Parameters: Return messages: lines – list of strings, the output text file as read by readlines() or as obtained by data.split(‘n’) when data is the text file read by read() count – the line at which we identified some '%%%%%%%%' warnings – the warnings already parsed in the file a list of QE error messages
aiida_quantumespresso.parsers.basic_raw_parser_pw.parse_pw_text_output(data, xml_data=None, structure_data=None, input_dict=None)[source]

Parses the text output of QE-PWscf.

Parameters: Return parsed_data: data – a string, the file as read by read() xml_data – the dictionary with the keys read from xml. structure_data – dictionary, coming from the xml, with info on the structure dictionary with key values, referring to quantities at the last scf step. key,values referring to intermediate scf steps, as in the case of vc-relax. Empty dictionary if no value is present. a list with critical messages. If any is found in parsed_data[‘warnings’], the calculation is FAILED!
aiida_quantumespresso.parsers.basic_raw_parser_pw.parse_pw_xml_output(data, dir_with_bands=None)[source]

Parse the xml data of QE v5.0.x Input data must be a single string, as returned by file.read() Returns a dictionary with parsed values

aiida_quantumespresso.parsers.basic_raw_parser_pw.parse_raw_output(out_file, input_dict, parser_opts=None, xml_file=None, dir_with_bands=None)[source]

Parses the output of a calculation Receives in input the paths to the output file and the xml file.

Parameters: Returns out_dict: out_file – path to pw std output input_dict – not used parser_opts – not used dir_with_bands – path to directory with all k-points (Kxxxxx) folders xml_file – path to QE data-file.xml a dictionary with parsed data a boolean that is False in case of failed calculations QEOutputParsingError – for errors in the parsing, AssertionError – if two keys in the parsed dicts are found to be qual

3 different keys to check in output: parser_warnings, xml_warnings and warnings. On an upper level, these flags MUST be checked. The first two are expected to be empty unless QE failures or unfinished jobs.

### Raw Cp Parser¶

aiida_quantumespresso.parsers.raw_parser_cp.parse_cp_text_output(data, xml_data)[source]

data must be a list of strings, one for each lines, as returned by readlines(). On output, a dictionary with parsed values

aiida_quantumespresso.parsers.raw_parser_cp.parse_cp_traj_stanzas(num_elements, splitlines, prepend_name, rescale=1.0)[source]

num_elements: Number of lines (with three elements) between lines with two only elements (containing step number and time in ps). num_elements is 3 for cell, and the number of atoms for coordinates and positions.

splitlines: a list of lines of the file, already split in pieces using string.split

prepend_name: a string to be prepended to the name of keys returned in the return dictionary.

rescale: the values in each stanza are multiplied by this factor, for units conversion

aiida_quantumespresso.parsers.raw_parser_cp.parse_cp_xml_counter_output(data)[source]

Parse xml file print_counter.xml data must be a single string, as returned by file.read() (notice the difference with parse_text_output!) On output, a dictionary with parsed values.

aiida_quantumespresso.parsers.raw_parser_cp.parse_cp_xml_output(data)[source]

Parse xml data data must be a single string, as returned by file.read() (notice the difference with parse_text_output!) On output, a dictionary with parsed values. Democratically, we have decided to use picoseconds as units of time, eV for energies, Angstrom for lengths.

### Basic Raw Cp Parser¶

This is just a minimal parser for basic quantities.

aiida_quantumespresso.parsers.basic_raw_parser_cp.parse_cp_text_output(data, xml_data)[source]

data must be a list of strings, one for each lines, as returned by readlines(). On output, a dictionary with parsed values

aiida_quantumespresso.parsers.basic_raw_parser_cp.parse_cp_traj_stanzas(num_elements, splitlines, prepend_name, rescale=1.0)[source]

num_elements: Number of lines (with three elements) between lines with two only elements (containing step number and time in ps). num_elements is 3 for cell, and the number of atoms for coordinates and positions.

splitlines: a list of lines of the file, already split in pieces using string.split

prepend_name: a string to be prepended to the name of keys returned in the return dictionary.

rescale: the values in each stanza are multiplied by this factor, for units conversion

aiida_quantumespresso.parsers.basic_raw_parser_cp.parse_cp_xml_counter_output(data)[source]

Parse xml file print_counter.xml data must be a single string, as returned by file.read() (notice the difference with parse_text_output!) On output, a dictionary with parsed values.

aiida_quantumespresso.parsers.basic_raw_parser_cp.parse_cp_xml_output(data)[source]

Parse xml data data must be a single string, as returned by file.read() (notice the difference with parse_text_output!) On output, a dictionary with parsed values. Democratically, we have decided to use picoseconds as units of time, eV for energies, Angstrom for lengths.

### Constants¶

Physical or mathematical constants. Since every code has its own conversion units, this module defines what QE understands as for an eV or other quantities. Whenever possible, we try to use the constants defined in :py:mod:aiida.common.constants:, but if some constants are slightly different among different codes (e.g., different standard definition), we define the constants in this file.