aiida_pseudo.groups.mixins#

Module containing various mixins for Group subclasses.

Submodules#

Package Contents#

Classes#

RecommendedCutoffMixin

Mixin that adds support of recommended cutoffs to a Group subclass, using its extras.

Attributes#

__all__

class aiida_pseudo.groups.mixins.RecommendedCutoffMixin#

Mixin that adds support of recommended cutoffs to a Group subclass, using its extras.

This class assumes that the cutoffs apply to a plane-wave based code and as such the cutoffs pertain to the wave functions and the charge density. The units have to be in electronvolt.

DEFAULT_UNIT = 'eV'#
_key_cutoffs = '_cutoffs'#
_key_cutoffs_unit = '_cutoffs_unit'#
_key_default_stringency = '_default_stringency'#
static validate_cutoffs(elements: set, cutoffs: dict) None#

Validate a cutoff dictionary for a given set of elements.

Parameters:
  • elements – set of elements for which to validate the cutoffs dictionary.

  • cutoffs

    dictionary with recommended cutoffs. Format: set of recommended cutoffs written as a dictionary that maps each element for which the family contains a pseudopotential to a dictionary that specifies the cutoff_wfc and cutoff_rho keys, corresponding a float value with the recommended cutoff to be used for the wave functions and charge density, respectively. For example:

    {
        "Ag": {
            "cutoff_wfc": 50.0,
            "cutoff_rho": 200.0
        },
        ...
    }
    

Raises:

ValueError – if the set of elements and those defined in the cutoffs do not match exactly, or if the cutoffs dictionary has an invalid format.

static validate_cutoffs_unit(unit: str) None#

Validate the cutoffs unit.

The unit should be a name that is recognized by the pint library to be a unit of energy.

Raises:

ValueError – if an invalid unit is specified.

validate_stringency(stringency: str | None) None#

Validate a cutoff stringency.

Check if the stringency is defined for the family. If no stringency input is passed, the method checks if a default stringency has been set.

Parameters:

stringency – the cutoff stringency to validate.

Raises:
  • ValueError – if stringency is equal to None and the family defines no default stringency.

  • ValueError – if the family does not define cutoffs for the specified stringency.

_get_cutoffs_dict() dict#

Return the cutoffs dictionary that maps the stringencies to the recommended cutoffs.

Returns:

the cutoffs extra or an empty dictionary if it has not yet been set.

_get_cutoffs_unit_dict() dict#

Return the cutoffs units for each of the stringencies.

Returns:

the cutoffs units extra or an empty dictionary if it has not yet been set.

get_default_stringency() str#

Return the default stringency if defined.

Returns:

the default stringency.

Raises:

ValueError – if default stringency has not been defined.

set_default_stringency(default_stringency: str) None#

Set the default stringency for the recommended cutoffs.

Parameters:

default_stringency – the default stringency to be used for the recommended cutoffs.

Raises:
  • ValueError – if the provided default stringency is not in the tuple of available cutoff stringencies for the pseudo family.

  • ValueError – if the user tries to unset the stringency by providing None as an input.

get_cutoff_stringencies() tuple#

Return a tuple of the available cutoff stringencies.

Returns:

the tuple of stringencies that are defined for this family.

set_cutoffs(cutoffs: dict, stringency: str, unit: str | None = None) None#

Set the recommended cutoffs for the pseudos in this family and a specified stringency.

Parameters:
  • cutoffs

    dictionary with recommended cutoffs. Format: set of recommended cutoffs written as a dictionary that maps each element for which the family contains a pseudopotential to a dictionary that specifies the cutoff_wfc and cutoff_rho keys, corresponding a float value with the recommended cutoff to be used for the wave functions and charge density, respectively. For example:

    {
        "Ag": {
            "cutoff_wfc": 50.0,
            "cutoff_rho": 200.0
        },
        ...
    }
    

  • stringency – the stringency corresponding to the provided cutoffs.

  • unit – string definition of a unit of energy as recognized by the UnitRegistry of the pint lib. Defaults to electronvolt.

Raises:

ValueError – if the cutoffs have an invalid format or the unit is not a valid energy unit.

get_cutoffs(stringency: str | None = None) dict#

Return a set of cutoffs for the given stringency.

Parameters:

stringency – optional stringency for which to retrieve the cutoffs. If not specified, the default stringency of the family is used.

Raises:
  • ValueError – if no stringency is specified and no default stringency is defined for the family.

  • ValueError – if the requested stringency is not defined for this family.

delete_cutoffs(stringency: str) None#

Delete the recommended cutoffs for a specified stringency.

Parameters:

stringency – stringency for which to delete the cutoffs.

Raises:

ValueError – if the requested stringency is not defined for this family.

get_cutoffs_unit(stringency: str | None = None) str#

Return the cutoffs unit for the specified or family default stringency.

Parameters:

stringency – optional stringency for which to retrieve the unit. If not specified, the default stringency of the family is used.

Returns:

the string representation of the unit of the cutoffs.

Raises:
  • ValueError – if no stringency is specified and no default stringency is defined for the family.

  • ValueError – if the requested stringency is not defined for this family.

Return tuple of recommended wavefunction and density cutoffs for the given elements or StructureData.

Note

at least one and only one of arguments elements or structure should be passed.

Parameters:
  • elements – single or tuple of elements.

  • structure – a StructureData node.

  • stringency – optional stringency if different from the default.

  • unit – string definition of a unit of energy as recognized by the UnitRegistry of the pint lib.

Returns:

tuple of recommended wavefunction and density cutoff.

Raises:
  • ValueError – if the requested stringency is not defined for this family.

  • ValueError – if optional unit specified is invalid.

  • ValueError – if the family does not have a pseudo for one of the elements (of the structure).

aiida_pseudo.groups.mixins.__all__#