Calculation parsers

This section describes the different parsers classes for calculations.

Quantum ESPRESSO parsers

exception aiida.parsers.plugins.quantumespresso.QEOutputParsingError[source]

Exception raised by a parser error in a QE code

aiida.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.convert_qe_time_to_sec(timestr)[source]

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

aiida.parsers.plugins.quantumespresso.ldlparse_QE_errors(lines, count, warnings)[source]

Parse QE errors messages, i.e., those appearing between some lines with %%%%%%%%

Parameters:
  • 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
Return messages:
 

a list of QE error messages

aiida.parsers.plugins.quantumespresso.parse_QE_errors(lines, count, warnings)[source]

Parse QE errors messages, i.e., those appearing between some lines with %%%%%%%%

Parameters:
  • 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
Return messages:
 

a list of QE error messages

aiida.parsers.plugins.quantumespresso.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

Pw Parser

class aiida.parsers.plugins.quantumespresso.pw.PwParser(calc)[source]

This class is the implementation of the Parser class for PWscf.

get_extended_symmetries()[source]

Return the extended dictionary of symmetries.

get_linkname_out_kpoints()[source]

Returns the name of the link to the output_kpoints Node exists if cell has changed and no bands are stored.

get_linkname_outarray()[source]

Returns the name of the link to the output_array Node may exist in case of calculation=’scf’

get_linkname_outstructure()[source]

Returns the name of the link to the output_structure Node exists if positions or cell changed.

get_linkname_outtrajectory()[source]

Returns the name of the link to the output_trajectory. Node exists in case of calculation=’md’, ‘vc-md’, ‘relax’, ‘vc-relax’

get_parser_settings_key()[source]

Return the name of the key to be used in the calculation settings, that contains the dictionary with the parser_options

parse_with_retrieved(retrieved)[source]

Receives in input a dictionary of retrieved nodes. Does all the logic here.

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.parsers.plugins.quantumespresso.raw_parser_pw.cell_volume(a1, a2, a3)[source]

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

aiida.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.raw_parser_pw.parse_QE_errors(lines, count, warnings)[source]

Parse QE errors messages (those appearing between some lines with %%%%%%%%) :param 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() :param count: the line at which we identified some %%%%%%%% :param warnings: the warnings already parsed in the file :return messages: a list of QE error messages

aiida.parsers.plugins.quantumespresso.raw_parser_pw.parse_pw_text_output(data, xml_data={}, structure_data={}, input_dict={})[source]

Parses the text output of QE-PWscf.

Parameters:
  • 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
Return parsed_data:
 

dictionary with key values, referring to quantities at the last scf step.

Return trajectory_data:
 

key,values referring to intermediate scf steps, as in the case of vc-relax. Empty dictionary if no value is present.

Return critical_messages:
 

a list with critical messages. If any is found in parsed_data[‘warnings’], the calculation is FAILED!

aiida.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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:
  • out_file – path to pw std output
  • input_dict – dictionary with the input parameters
  • parser_opts – not used
  • dir_with_bands – path to directory with all k-points (Kxxxxx) folders
  • xml_file – path to QE data-file.xml
Return parameter_data:
 

a dictionary with parsed parameters

Return trajectory_data:
 

a dictionary with arrays (for relax & md calcs.)

Return structure_data:
 

a dictionary with data for the output structure

Return bands_data:
 

a dictionary with data for bands (for bands calcs.)

Return job_successful:
 

a boolean that is False in case of failed calculations

Raises:
  • 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.

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.parsers.plugins.quantumespresso.basic_raw_parser_pw.cell_volume(a1, a2, a3)[source]

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

aiida.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.basic_raw_parser_pw.parse_QE_errors(lines, count, warnings)[source]

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

Parameters:
  • 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
Return messages:
 

a list of QE error messages

aiida.parsers.plugins.quantumespresso.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:
  • 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
Return parsed_data:
 

dictionary with key values, referring to quantities at the last scf step.

Return trajectory_data:
 

key,values referring to intermediate scf steps, as in the case of vc-relax. Empty dictionary if no value is present.

Return critical_messages:
 

a list with critical messages. If any is found in parsed_data[‘warnings’], the calculation is FAILED!

aiida.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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:
  • 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
Returns out_dict:
 

a dictionary with parsed data

Return successful:
 

a boolean that is False in case of failed calculations

Raises:

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.

Cp Parser

class aiida.parsers.plugins.quantumespresso.cp.CpParser(calc)[source]

This class is the implementation of the Parser class for Cp.

get_linkname_trajectory()[source]

Returns the name of the link to the output_structure (None if not present)

parse_with_retrieved(retrieved)[source]

Receives in input a dictionary of retrieved nodes. Does all the logic here.

Raw Cp Parser

aiida.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.parsers.plugins.quantumespresso.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.

Dos Parser

class aiida.parsers.plugins.quantumespresso.dos.DosParser(calculation)[source]

This class is the implementation of the Parser class for Dos.

get_linkname_dos()[source]

Returns the name of the link of dos

get_linkname_units()[source]

Returns the name of the link of units

parse_with_retrieved(retrieved)[source]

Parses the datafolder, stores results. Retrieves dos output, and some basic information from the out_file, such as warnings and wall_time

aiida.parsers.plugins.quantumespresso.dos.parse_raw_dos(dos_file, array_names, array_units)[source]

This function takes as input the dos_file as a list of filelines along with information on how to give labels and units to the parsed data

Parameters:
  • dos_file (list) – dos file lines in the form of a list
  • array_names (list) – list of all array names, note that array_names[0] is for the case with non spin-polarized calculations and array_names[1] is for the case with spin-polarized calculation
  • array_units (list) – list of all array units, note that array_units[0] is for the case with non spin-polarized calculations and array_units[1] is for the case with spin-polarized calculation
Return array_data:
 

narray, a dictionary for ArrayData type, which contains all parsed dos output along with labels and units

Return spin:

boolean, indicates whether the parsed results are spin polarized

Projwfc Parser

class aiida.parsers.plugins.quantumespresso.projwfc.ProjwfcParser(calculation)[source]

This class is the implementation of the Parser class for projwfc.x in Quantum Espresso. Parses projection arrays that map the projection onto each point in the bands structure, as well as pdos arrays, which map the projected density of states onto an energy axis.

parse_with_retrieved(retrieved)[source]

Parses the datafolder, stores results. Retrieves projwfc output, and some basic information from the out_file, such as warnings and wall_time

aiida.parsers.plugins.quantumespresso.projwfc.find_orbitals_from_statelines(out_info_dict)[source]

This function reads in all the state_lines, that is, the lines describing which atomic states, taken from the pseudopotential, are used for the projection. Then it converts these state_lines into a set of orbitals

Parameters:out_info_dict – contains various technical internals useful in parsing
Returns:orbitals, a list of orbitals suitable for setting ProjectionData
aiida.parsers.plugins.quantumespresso.projwfc.spin_dependent_pdos_subparcer(out_info_dict)[source]

Finds and labels the pdos arrays associated with the out_info_dict

Parameters:out_info_dict – contains various technical internals useful in parsing
Returns:(pdos_name, pdos_array) tuples for all the specific pdos
aiida.parsers.plugins.quantumespresso.projwfc.spin_dependent_subparcer(out_info_dict)[source]

This find the projection and bands arrays from the out_file and out_info_dict. Used to handle the different possible spin-cases in a convenient manner.

Parameters:out_info_dict – contains various technical internals useful in parsing
Returns:ProjectionData, BandsData parsed from out_file