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
Returns: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:
  • 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_quantumespresso.parsers.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_quantumespresso.parsers.parse_raw_out_basic(out_file, calc_name)[source]

A very simple parser for the standard out, usually aiida.outputs. 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_quantumespresso.parsers.pw.PwParser(node)[source]

Parser implementation for the PwCalculation calculation job class.

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(**kwargs)[source]

Parse the output nodes for a PwCalculations from a dictionary of retrieved nodes. Two nodes that are expected are the default ‘retrieved’ FolderData node which will store the retrieved files permanently in the repository. The second required node is the unstored FolderData node with the temporary retrieved files, which should be passed under the key ‘retrieved_temporary_folder_key’ of the Parser class.

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:
  • 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_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:
  • 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
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_quantumespresso.parsers.raw_parser_pw.parse_pw_xml_pre_6_2(xml_file, dir_with_bands, parser_opts, logger)[source]

Parse the XML output file of Quantum ESPRESSO with the format from before the XSD schema file Returns a dictionary with parsed values

aiida_quantumespresso.parsers.raw_parser_pw.parse_raw_output(out_file, input_dict, parser_opts, logger, 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:
  • out_file – path to pw std output
  • input_dict – dictionary with the input parameters
  • parser_opts – dictionary with parser options
  • logger – aiida logger object
  • xml_file – optional path to the XML output file
  • dir_with_bands – path to directory with all k-points (Kxxxxx) folders
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 equal

Basic Raw Pw Parser

This is just a minimal parser for basic quantities.

Cp Parser

class aiida_quantumespresso.parsers.cp.CpParser(node)[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(**kwargs)[source]

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

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.

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_quantumespresso.parsers.dos.DosParser(node)[source]

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

parse(**kwargs)[source]

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

aiida_quantumespresso.parsers.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_quantumespresso.parsers.projwfc.ProjwfcParser(node)[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(**kwargs)[source]

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

aiida_quantumespresso.parsers.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_quantumespresso.parsers.projwfc.natural_sort_key(sort_key, _nsre=<_sre.SRE_Pattern object>)[source]

Pass to key for str.sort to achieve natural sorting. For example, ["2", "11", "1"] will be sorted to ["1", "2", "11"] instead of ["1", "11", "2"] :param sort_key: Original key to be processed :return: A list of string and integers.

aiida_quantumespresso.parsers.projwfc.spin_dependent_pdos_subparser(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_quantumespresso.parsers.projwfc.spin_dependent_subparser(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