aiida_quantumespresso.calculations.helpers

aiida_quantumespresso.calculations.helpers#

Utilities to automatically format, convert and validate data structures from python to fortran.

Package Contents#

Functions#

_check_and_convert(keyword, val, expected_type)

Check and convert the value for the given keyword against an expected type.

pw_input_helper(input_params, structure[, ...])

Validate if the input dictionary for Quantum ESPRESSO is valid.

exception aiida_quantumespresso.calculations.helpers.QEInputValidationError[source]#

Bases: aiida.common.InputValidationError

Raise when the parser encounters an error while creating the input file of Quantum ESPRESSO.

aiida_quantumespresso.calculations.helpers._check_and_convert(keyword, val, expected_type)[source]#

Check and convert the value for the given keyword against an expected type.

Parameters:
  • keyword – the keyword

  • val – value for the given keyword

  • expected_type – type the value should have: [INTEGER, REAL, CHARACTER, LOGICAL]

aiida_quantumespresso.calculations.helpers.pw_input_helper(input_params, structure, stop_at_first_error=False, flat_mode=False, version='6.2')[source]#

Validate if the input dictionary for Quantum ESPRESSO is valid.

Return the dictionary (possibly with small variations: e.g. convert integer to float where necessary, recreate the proper structure if flat_mode is True, …) to use as input parameters (use_parameters) for the pw.x calculation.

Parameters:
  • input_params

    If flat_mode is True, pass a dictionary

    with ‘key’ = value; use the correct type (int, bool, …) for value. If an array is required:

    • if its length is fixed: pass a list of the required length

    • if its length is ‘ntyp’: pass a dictionary, associating each specie to its value.

    • (other lengths are not supported)

    Example:

    {
    'calculation': 'vc-relax',
    'ecutwfc': 30.,
    'hubbard_u': {'O': 1},
    }
    

    If instead flat_mode is False, pass a dictionary in the format expected by AiiDA (keys are namelists, values are in the format specified above, i.e. key/value pairs for all keywords in the given namelist). Example:

    {
        'CONTROL': {
            'calculation': 'vc-relax'
            },
        'SYSTEM': {
            'hubbard_u': {'O': 1.0},
            'ecutwfc': 30.,
            },
    },
    

  • structure – the StructureData object used as input for QE pw.x

  • stop_at_first_error – if True, stops at the first error. Otherwise, when, possible, continue and give a global error for all the issues encountered.

  • flat_mode – if True, instead of passing the dictionary of namelists, and inside the keywords, pass directly the keywords - this function will return the correct dictionary to pass to the PwCalculation, with the keywords arranged in the correct namelist.

  • version – string with version number, used to find the correct XML file descriptor. If not specified, uses the most recent version available in the validator. It reads the definitions from the XML files in the same folder as this python module. If the version is not recognised, the Exception message will also suggest a close-by version.

Raises:

QEInputValidationError – if the input is not considered valid.