Skip to main content

AiiDA plugin that simplifies working with pseudo potentials

Project description

aiida-pseudo

AiiDA plugin that simplifies working with pseudopotentials.

PyPI version PyPI pyversions Build Status Docs status

Getting started

The easiest way of getting started using aiida-pseudo is to use the command line interface that ships with it. For example, to install a configuration of the SSSP, just run:

aiida-pseudo install sssp

The version, functional, and protocol can be controlled with various options; use aiida-pseudo install sssp --help to see their description. If you are experiencing problems with this automated install method, see the Troubleshooting section below for help. Installed pseudopotential families can be listed using:

aiida-pseudo list

Any pseudopotential family installed can be loaded like any other Group using the load_group utility from aiida-core. Once loaded, it is easy to get the pseudopotentials for a given element or set of elements:

from aiida.orm import load_group
family = load_group('SSSP/1.1/PBE/efficiency')
pseudo = family.get_pseudo(element='Ga')  # Returns a single pseudo
pseudos = family.get_pseudos(elements=('Ga', 'As'))  # Returns a dictionary of pseudos where the keys are the elements

If you have a StructureData node, the get_pseudos method also accepts that as an argument to automatically retrieve all the pseudopotentials required for that structure:

structure = load_node()  # Load the structure from database or create one
pseudos = family.get_pseudos(structure=structure)

If you use aiida-quantumespresso the pseudos dictionary returned by get_pseudos can be directly used as an input for PwCalculations.

Design

The plugin is centered around two concepts: pseudopotentials and pseudopotential families. The two concepts are further explained below, especially focusing on how they are implemented in aiida-pseudo, what assumptions are made, and what the limitations are.

Pseudopotentials

Pseudopotentials are implemented as data plugins, and the base class is PseudoPotentialData. Pseudopotentials are assumed to be defined by a single file on disk and represent a single chemical element. As such, each pseudopotential node, has to have two attributes: the md5 of the file that it represents and the symbol of chemical element that the pseudopotential describes. The latter follows IUPAC naming conventions as used in the module aiida.common.constants.elements of aiida-core.

The PseudoPotentialData functions as a base class and does not represent an actual existing pseudopotential format. It is possible to create a family of PseudoPotentialData nodes, but since the element cannot be parsed from the file content itself, it will have to be done from the filename, so the filename has to have the format CHEMICAL_SYMBOL.EXTENSION, for example Ar.pseudo. Since the PseudoPotentialData class does not have any features tailored to specific formats, as do the classes which inherit from it (e.g. UpfData for UPF-formatted pseudopotentials), this class is mostly useful for development.

The plugin comes with a variety of pseudopotential subtypes that represent various common pseudopotential formats, such as UPF, PSF, PSML and PSP8. The corresponding data plugins implement how the element and other data are parsed from a pseudopotential file with such a format. A new pseudopotential node can be created by instantiating the corresponding plugin class:

from aiida import plugins

UpfData = plugins.DataFactory('pseudo.upf')

with open('path/to/pseudo.upf', 'rb') as stream:
    pseudo = UpfData(stream)

Note, the pseudopotential constructor expects a stream of bytes, so be sure to open the file handle with the 'rb' mode. Alternatively, you can also use the get_or_create classmethod, which will first search the database to check if a pseudopotential of the exact same type and content already exists. If that is the case, that node is returned, otherwise a new instance is created:

from aiida import plugins

UpfData = plugins.DataFactory('pseudo.upf')

with open('path/to/pseudo.upf', 'rb') as stream:
    pseudo = UpfData.get_or_create(stream)

If a new node was created, it will be unstored. Note that if more than one pseudopotential in the database is matched, a random one is selected and returned.

Families

Having loose pseudopotentials floating around is not very practical, so groups of related pseudopotentials can be organized into "families", which are implemented as group plugins with the base class PseudoPotentialFamily. A family class can in principle support many pseudopotential formats, however, a family instance can only contain pseudopotentials of a single format. For example, the PseudoPotentialFamily class supports all of the pseudopotential formats that are supported by this plugin. However, any instance can only contain pseudopotentials of the same format (e.g. all UPF or all PSP8, not a mixture). In contrast, the SsspFamily only supports the UpfData format.

A pseudopotential family can be constructed manually, by first constructing the class instance and then adding pseudopotential data nodes to it:

from aiida import plugins

UpfData = plugins.DataFactory('pseudo.upf')
PseudoPotentialFamily = plugins.GroupFactory('pseudo')

pseudos = []

for filepath in ['Ga.upf', 'As.upf']:
    with open(filepath, 'rb') as stream:
        pseudo = UpfData(stream)
        pseudos.append(pseudo)

family = PseudoPotentialFamily(label='pseudos/upf').store()
family.append(pseudos)

Note that as with any Group, it has to be stored before nodes can be added. If you have a folder on disk that contains various pseudopotentials for different elements, there is an even easier way to create the family automatically:

from aiida import plugins

UpfData = plugins.DataFactory('pseudo.upf')
PseudoPotentialFamily = plugins.GroupFactory('pseudo')

family = PseudoPotentialFamily('path/to/pseudos', 'pseudos/upf', pseudo_type=UpfData)

The plugin is not able to reliably deduce the format of the pseudopotentials contained in the folder, so one should indicate what data type to use with the pseudo_type argument. The exception is when the family class only supports a single pseudo type, such as for the SsspFamily, in which case that type will automatically be selected. Subclasses of supported pseudo types are also accepted. For example, the base class PseudoPotentialFamily supports pseudopotentials of the PseudoPotentialData type. Because all more specific pseudopotential types are subclasses of PseudoPotentialData, the PseudoPotentialFamily class accepts all of them.

Recommended cutoffs

Certain pseudopotential family types, such as the SsspFamily, provide recommended cutoff values for wave functions and charge density in plane-wave codes. These cutoffs are always in units of electronvolt. The recommended cutoffs for a set of elements or a StructureData can be retrieved from the family as follows:

family = load_group('SSSP/1.1/PBE/efficiency')
cutoffs = family.get_recommended_cutoffs(elements=('Ga', 'As'))  # From a tuple or list of element symbols
cutoffs = family.get_recommended_cutoffs(structure=load_node(<IDENTIFIER>))  # From a `StructureData` node

Troubleshooting

The automated install commands fail

These failures are often due to unstable internet connections causing the download of the pseudopotential archive from the web to fail. In this case, it is possible to install the family manually from an archive that is already available on the local file system. To install a pseudopotential family manually, run the following command:

aiida-pseudo install family <ARCHIVE> <LABEL>

where <ARCHIVE> should be replaced with the pseudopotential archive and <LABEL> with the label to give to the family. The command will attempt to automatically detect the compression format of the archive. If this fails, you can specify the format manually with the --archive-format/-f option, for example, for a .tar.gz archive:

aiida-pseudo install family <ARCHIVE> <LABEL> -f gztar

By default, the command will create a family of the base pseudopotential family type. If you want to create a more specific family, for example an CutoffsPseudoPotentialFamily, you can provide the corresponding entry point to the --family-type/-F option:

aiida-pseudo install family <ARCHIVE> <LABEL> -F pseudo.family.cutoffs

Note that the pseudo.family.sssp and pseudo.family.pseudo_dojo family types are blacklisted since they have their own dedicated install commands in aiida-pseudo install sssp and aiida-pseudo install pseudo-dojo, respectively.

The available pseudopotential family classes can be listed with the command:

verdi plugin list aiida.groups

Any entry point that starts with `pseudo.family.` can potentially be used, depending on the type of pseudopotential archive.


| :exclamation: Warning      |
|:---------------------------|
| The functionality of some plugins, such as the workflow protocols of `aiida-quantumespresso`, may rely on recommended cutoffs to be defined for the pseudopotential family. Unlike the automated install methods for those family types, this manual method will not define recommended cutoffs and as a result it may not be usable for these specific functionalities. Recommended cutoffs can be manually defined for existing pseudopotential families using the `aiida-pseudo family cutoffs set` command. |


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiida-pseudo-0.6.1.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

aiida_pseudo-0.6.1-py3-none-any.whl (68.7 kB view details)

Uploaded Python 3

File details

Details for the file aiida-pseudo-0.6.1.tar.gz.

File metadata

  • Download URL: aiida-pseudo-0.6.1.tar.gz
  • Upload date:
  • Size: 52.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.5

File hashes

Hashes for aiida-pseudo-0.6.1.tar.gz
Algorithm Hash digest
SHA256 727523fcd828709a190f592ec3e72e7ae07993e2184f83c2e34bc5cab5cfa90b
MD5 d7dfabd57f9a805e3f9f00784f45b623
BLAKE2b-256 1d7aed80939b25244d1ef00e08527501ebcb6433f2d8f05b0f6d9bf5364ee1d7

See more details on using hashes here.

File details

Details for the file aiida_pseudo-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: aiida_pseudo-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 68.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.5

File hashes

Hashes for aiida_pseudo-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c38d93ed3494aed2603b415736125854b52838fc7d90f2d6a07224793e942cd9
MD5 8246231a45a56049192d6fc57031b96d
BLAKE2b-256 130b5791da560b95f9f76e35b1a45ad68a9378fc3c233b0670b1748c84694e06

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page