aiida_quantumespresso.calculations

Contents

aiida_quantumespresso.calculations#

Base CalcJob for implementations for pw.x and cp.x of Quantum ESPRESSO.

Subpackages#

Submodules#

Package Contents#

Classes#

HubbardStructureData

Structure data containing code agnostic info on Hubbard parameters.

HubbardUtils

Utility class for handling HubbardStructureData for QuantumESPRESSO.

CalcJob

Custom CalcJob class for aiida-quantumespresso calculations.

BasePwCpInputGenerator

Base CalcJob for implementations for pw.x and cp.x of Quantum ESPRESSO.

Functions#

convert_input_to_namelist_entry(key, val[, mapping])

Convert a key and a value, from an input parameters dictionary for a namelist calculation.

_lowercase_dict(dictionary, dict_name)

_uppercase_dict(dictionary, dict_name)

_case_transform_dict(dictionary, dict_name, func_name, ...)

_pop_parser_options(calc_job_instance, settings_dict)

Delete any parser options from the settings dictionary.

Attributes#

LegacyUpfData

UpfData

class aiida_quantumespresso.calculations.HubbardStructureData(cell: List[List[float]], sites: List[Tuple[str, str, Tuple[float, float, float]]], pbc: Tuple[bool, bool, bool] = (True, True, True), hubbard: aiida_quantumespresso.common.hubbard.Hubbard = None, **kwargs)[source]#

Bases: aiida.orm.StructureData

Structure data containing code agnostic info on Hubbard parameters.

property sites#

Return the sites.

property hubbard: aiida_quantumespresso.common.hubbard.Hubbard#

Get the Hubbard instance.

Returns:

a Hubbard instance.

_hubbard_filename = 'hubbard.json'#
static from_structure(structure: aiida.orm.StructureData, hubbard: aiida_quantumespresso.common.hubbard.Hubbard | None = None)[source]#

Return an instance of HubbardStructureData from a StructureData node.

Parameters:
Returns:

HubbardStructureData instance

append_hubbard_parameter(atom_index: int, atom_manifold: str, neighbour_index: int, neighbour_manifold: str, value: float, translation: Tuple[int, int, int] = None, hubbard_type: str = 'Ueff')[source]#

Append a HubbardParameters.

Parameters:
  • atom_index – atom index in unitcell

  • atom_manifold – atomic manifold (e.g. 3d, 3d-2p)

  • neighbour_index – neighbouring atom index in unitcell

  • neighbour_manifold – neighbour manifold (e.g. 3d, 3d-2p)

  • value – value of the Hubbard parameter, in eV

  • translation – (3,) list of ints, describing the translation vector associated with the neighbour atom, defaults to None

  • hubbard_type – hubbard type (U, V, J, …), defaults to ‘Ueff’ (see Hubbard for full allowed values)

pop_hubbard_parameters(index: int)[source]#

Pop Hubbard parameters in the list.

Parameters:

index – index of the Hubbard parameters to pop

clear_hubbard_parameters()[source]#

Clear all the Hubbard parameters.

initialize_intersites_hubbard(atom_name: str, atom_manifold: str, neighbour_name: str, neighbour_manifold: str, value: float = 1e-08, hubbard_type: str = 'V', use_kinds: bool = True)[source]#

Initialize and append intersite Hubbard values between an atom and its neighbour(s).

Note

this only initialize the value between the first neighbour. In case use_kinds is False, all the possible combination of couples having kind name equal to symbol are initialized.

Parameters:
  • atom_name – atom name in unitcell

  • atom_manifold – atomic manifold (e.g. 3d, 3d-2p)

  • neighbour_index – neighbouring atom name in unitcell

  • neighbour_manifold – neighbour manifold (e.g. 3d, 3d-2p)

  • value – value of the Hubbard parameter, in eV

  • hubbard_type – hubbard type (U, V, J, …), defaults to ‘V’ (see Hubbard for full allowed values)

  • use_kinds – whether to use kinds for initializing the parameters; when False, it initializes all the Kinds matching the atom_name

initialize_onsites_hubbard(atom_name: str, atom_manifold: str, value: float = 1e-08, hubbard_type: str = 'Ueff', use_kinds: bool = True)[source]#

Initialize and append onsite Hubbard values of atoms with specific name.

Parameters:
  • atom_name – atom name in unitcell

  • atom_manifold – atomic manifold (e.g. 3d, 3d-2p)

  • value – value of the Hubbard parameter, in eV

  • hubbard_type – hubbard type (U, J, …), defaults to ‘Ueff’ (see Hubbard for full allowed values)

  • use_kinds – whether to use kinds for initializing the parameters; when False, it initializes all the Kinds matching the atom_name

_get_one_kind_index(kind_name: str) List[int][source]#

Return the first site index matching with kind_name.

_get_symbol_indices(symbol: str) List[int][source]#

Return one site index for each kind name matching symbol.

aiida_quantumespresso.calculations.convert_input_to_namelist_entry(key, val, mapping=None)[source]#

Convert a key and a value, from an input parameters dictionary for a namelist calculation.

Map it to the appropriate string format for the namelist input file. For single values it will return a single string, but for values that are a dictionary, list or tuple, the returned string may be multiline.

Parameters:
  • key – the namelist keyword name

  • val

    the namelist keyword value The value can be either a single value, list/tuple, a double nested list or a dictionary. Depending on the type of the value the resulting string differs vastly

    • single list:

      A list of keywords will be generated, where the index of the value in the list will be used as the index in the keyword and the value itself will be converted using conv_to_fortran. For example:

      'efield': [4, 5, 6]
      

      will result in:

      efield(1) = 4
      efield(1) = 5
      efield(1) = 6
      
    • double nested list:

      This format can be used for keywords that require one or more indices that do not necessarily follow a sequential number, but take specific values that need to be defined by the user. For example:

      'starting_ns_eigenvalue': [
          [1, 1, 3, 3.5],
          [2, 1, 1, 2.8]
      ]
      

      will be formatted as:

      starting_ns_eigenvalue(1,1,3) = 3.5
      starting_ns_eigenvalue(2,1,1) = 2.8
      

      Note that if the mapping argument is provided in the input, any value in sub lists that matches a key in the mapping dictionary (that is to say it is a string that matches one of the kinds), it will be replaced with the index of the corresponding atomic species. For example:

      hubbard_j: [
          [2, 'Ni', 3.5],
          [2, 'Fe', 7.4],
      ]
      

      would be formatted as:

      hubbard_j(2, 1) = 3.5
      hubbard_j(2, 3) = 7.4
      

      Assuming the mapping dictionary contained the kinds ‘Ni’ and ‘Fe’, with the indices 1 and 3, respectively

    • dictionary:

      The keys of this dictionary should correspond to keys in the mapping input argument and will be replaced with the corresponding value. This can be used for keywords that take a single index that needs to conform to the index of the atomic species to which the keyword value should apply. For example:

      hubbard_u: {
          'Co': 3.5,
          'O': 7.4,
      }
      

      will be formatted as:

      hubbard_u(1) = 3.5
      hubbard_u(3) = 7.4
      

      assuming that the kinds ‘Co’ and ‘O’ would have atomic species indices 1 and 3, respectively. This mapping from kind name to atomic species index should be defined by the mapping argument.

  • mapping

    optional parameter, that must be provided if val is a dictionary or a double nested list where the sub lists contain string values. The keys of the mapping dictionary should be the atomic species names that will be encountered in the value, and the corresponding value should be the index of that atomic species. Example:

    mapping = {
        'Fe': 1,
        'O': 2,
    }
    

    This will map every occurrence of ‘Fe’ and ‘O’ in the values to the corresponding integer.

class aiida_quantumespresso.calculations.HubbardUtils(hubbard_structure: aiida_quantumespresso.data.hubbard_structure.HubbardStructureData)[source]#

Utility class for handling HubbardStructureData for QuantumESPRESSO.

property hubbard_structure: aiida_quantumespresso.data.hubbard_structure.HubbardStructureData#

Return the HubbardStructureData.

get_hubbard_card() str[source]#

Return QuantumESPRESSO HUBBARD input card for pw.x.

parse_hubbard_dat(filepath: str | os.PathLike)[source]#

Parse the HUBBARD.dat of QuantumESPRESSO file associated to the current structure.

This function is needed for parsing the HUBBARD.dat file generated in a hp.x calculation.

Note

overrides current Hubbard information.

Parameters:

filepath – the filepath of the HUBBARD.dat to parse

get_hubbard_file() str[source]#

Return QuantumESPRESSO parameters.in data for pw.x`.

reorder_atoms()[source]#

Reorder the atoms with with the kinds in the right order necessary for an hp.x calculation.

An HpCalculation which restarts from a completed PwCalculation, requires that the all Hubbard atoms appear first in the atomic positions card of the PwCalculation input file. This order is based on the order of the kinds in the structure. So a suitable structure has all Hubbard kinds in the begining of kinds list.

Note

overrides current HubbardStructureData

is_to_reorder() bool[source]#

Return whether the atoms should be reordered for an hp.x calculation.

get_hubbard_for_supercell(supercell: aiida.orm.StructureData, thr: float = 0.001) aiida_quantumespresso.data.hubbard_structure.HubbardStructureData[source]#

Return the HubbbardStructureData for a supercell.

Note

the two structure need to be commensurate (no rigid rotations)

Warning

always check that the energy calculation of a pristine supercell structure obtained through this method is the same as the unitcell (within numerical noise)

Returns:

a new HubbbardStructureData with all the mapped Hubbard parameters

class aiida_quantumespresso.calculations.CalcJob(*args, **kwargs)[source]#

Bases: aiida.engine.CalcJob

Custom CalcJob class for aiida-quantumespresso calculations.

_spec_class#
classmethod define(spec)[source]#

Define the process specification.

exception aiida_quantumespresso.calculations.QEInputValidationError[source]#

Bases: aiida.common.InputValidationError

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

aiida_quantumespresso.calculations.LegacyUpfData[source]#
aiida_quantumespresso.calculations.UpfData[source]#
class aiida_quantumespresso.calculations.BasePwCpInputGenerator(*args, **kwargs)[source]#

Bases: base.CalcJob

Base CalcJob for implementations for pw.x and cp.x of Quantum ESPRESSO.

_PSEUDO_SUBFOLDER = './pseudo/'[source]#
_OUTPUT_SUBFOLDER = './out/'[source]#
_PREFIX = 'aiida'[source]#
_DEFAULT_INPUT_FILE = 'aiida.in'[source]#
_DEFAULT_OUTPUT_FILE = 'aiida.out'[source]#
_CRASH_FILE = 'CRASH'[source]#
_DATAFILE_XML_PRE_6_2 = 'data-file.xml'[source]#
_DATAFILE_XML_POST_6_2 = 'data-file-schema.xml'[source]#
_ENVIRON_INPUT_FILE_NAME = 'environ.in'[source]#
_DEFAULT_IBRAV = 0[source]#
_PARALLELIZATION_FLAGS[source]#
_ENABLED_PARALLELIZATION_FLAGS[source]#
_PARALLELIZATION_FLAG_ALIASES[source]#
_internal_retrieve_list = [][source]#
_automatic_namelists[source]#
_blocked_keywords[source]#
_restart_copy_from[source]#
_restart_copy_to[source]#
_default_verbosity = 'high'[source]#
_use_kpoints = False[source]#
xml_filenames()[source]#

Return a list of XML output filenames that can be written by a calculation.

Note that this includes all potential filenames across all known versions of Quantum ESPRESSO

abstract xml_filepaths()[source]#

Return a list of XML output filepaths relative to the remote working directory that should be retrieved.

classmethod define(spec)[source]#

Define the process specification.

classmethod validate_inputs(value, port_namespace)[source]#

Validate the entire inputs namespace.

classmethod validate_parallelization(value, _)[source]#

Validate the parallelization input.

prepare_for_submission(folder)[source]#

Create the input files from the input nodes passed to this instance of the CalcJob.

Parameters:

folder – an aiida.common.folders.Folder to temporarily write files on disk

Returns:

aiida.common.datastructures.CalcInfo instance

_add_parallelization_flags_to_cmdline_params(cmdline_params)[source]#

Get the command line parameters with added parallelization flags.

Adds the parallelization flags to the given cmdline_params and returns the updated list.

Raises an InputValidationError if multiple aliases to the same flag are given in cmdline_params, or the same flag is given both in cmdline_params and the explicit parallelization input.

static _generate_PWCP_input_tail(*args, **kwargs)[source]#

Generate tail of input file.

By default, nothing specific is generated. This method can be implemented again in derived classes, and it will be called by _generate_PWCPinputdata

classmethod _generate_PWCPinputdata(parameters, settings, pseudos, structure, kpoints=None, use_fractional=False)[source]#

Create the input file in string format for a pw.x or cp.x calculation for the given inputs.

aiida_quantumespresso.calculations._lowercase_dict(dictionary, dict_name)[source]#
aiida_quantumespresso.calculations._uppercase_dict(dictionary, dict_name)[source]#
aiida_quantumespresso.calculations._case_transform_dict(dictionary, dict_name, func_name, transform)[source]#
aiida_quantumespresso.calculations._pop_parser_options(calc_job_instance, settings_dict, ignore_errors=True)[source]#

Delete any parser options from the settings dictionary.

The parser options key is found via the get_parser_settings_key() method of the parser class specified as a metadata input.