pymatgen.ext.optimade module

Optimade support.

class OptimadeRester(aliases_or_resource_urls: Optional[Union[str, List[str]]] = None, timeout=5)[source]

Bases: object

Class to call OPTIMADE-compliant APIs, see optimade.org

This class is ready to use but considered in-development and subject to change until the OPTIMADE paper is published.

OPTIMADE is an effort to provide a standardized interface to retrieve information from many different materials science databases.

This is a client to retrieve structures from OPTIMADE v1 compliant endpoints. It does not yet support all features of the OPTIMADE v1 specification but is intended as a way to quickly search an endpoint in a way familiar to users of pymatgen without needing to know the full OPTIMADE specification.

For advanced usage, please see the OPTIMADE documentation at optimade.org and consider calling the APIs directly.

For convenience, known OPTIMADE endpoints have been given aliases in pymatgen to save typing the full URL. The current list of aliases is:

aflow, cod, mcloud.sssp, mcloud.2dstructures, mcloud.2dtopo, mcloud.tc-applicability, mcloud.threedd, mcloud.scdm, mcloud.curated-cofs, mcloud.optimade-sample, mcloud.stoceriaitf, mcloud.pyrene-mofs, mcloud.li-ion-conductors, mp, odbx, omdb.omdb_production, oqmd, tcod

To refresh this list of aliases, generated from the current list of OPTIMADE providers at optimade.org, call the refresh_aliases() method.

Parameters
  • aliases_or_resource_urls – the alias or structure resource URL or a list of

  • or resource URLs, if providing the resource URL directly it should not (aliases) –

  • an index, this interface can only currently access the "v1/structures" (be) –

  • from the specified resource URL (information) –

  • timeout – number of seconds before an attempted request is abandoned, a good

  • is useful when querying many providers, some of which may be offline (timeout) –

aliases = {'aflow': 'http://aflow.org/API/optimade/', 'cod': 'https://www.crystallography.net/cod/optimade', 'mcloud.2dstructures': 'https://aiida.materialscloud.org/2dstructures/optimade', 'mcloud.2dtopo': 'https://aiida.materialscloud.org/2dtopo/optimade', 'mcloud.curated-cofs': 'https://aiida.materialscloud.org/curated-cofs/optimade', 'mcloud.li-ion-conductors': 'https://aiida.materialscloud.org/li-ion-conductors/optimade', 'mcloud.optimade-sample': 'https://aiida.materialscloud.org/optimade-sample/optimade', 'mcloud.pyrene-mofs': 'https://aiida.materialscloud.org/pyrene-mofs/optimade', 'mcloud.scdm': 'https://aiida.materialscloud.org/autowannier/optimade', 'mcloud.sssp': 'https://aiida.materialscloud.org/sssplibrary/optimade', 'mcloud.stoceriaitf': 'https://aiida.materialscloud.org/stoceriaitf/optimade', 'mcloud.tc-applicability': 'https://aiida.materialscloud.org/tc-applicability/optimade', 'mcloud.threedd': 'https://aiida.materialscloud.org/3dd/optimade', 'mp': 'https://optimade.materialsproject.org', 'mpds': 'https://api.mpds.io', 'nmd': 'https://nomad-lab.eu/prod/rae/optimade/', 'odbx': 'https://optimade.odbx.science', 'omdb.omdb_production': 'http://optimade.openmaterialsdb.se', 'oqmd': 'http://oqmd.org/optimade/', 'tcod': 'https://www.crystallography.net/tcod/optimade'}[source]
describe()[source]

Provides human-readable information about the resources being searched by the OptimadeRester.

get_snls(elements=None, nelements=None, nsites=None, chemical_formula_anonymous=None, chemical_formula_hill=None) → Dict[str, Dict[str, pymatgen.util.provenance.StructureNL]][source]

Retrieve StructureNL from OPTIMADE providers.

A StructureNL is an object provided by pymatgen which combines Structure with associated metadata, such as the URL is was downloaded from and any additional namespaced data.

Not all functionality of OPTIMADE is currently exposed in this convenience method. To use a custom filter, call get_structures_with_filter().

Parameters
  • elements – List of elements

  • nelements – Number of elements, e.g. 4 or [2, 5] for the range >=2 and <=5

  • nsites – Number of sites, e.g. 4 or [2, 5] for the range >=2 and <=5

  • chemical_formula_anonymous – Anonymous chemical formula

  • chemical_formula_hill – Chemical formula following Hill convention

Returns: Dict of (Dict of StructureNLs keyed by that database’s id system) keyed by provider

get_snls_with_filter(optimade_filter: str) → Dict[str, Dict[str, pymatgen.util.provenance.StructureNL]][source]

Get structures satisfying a given OPTIMADE filter.

Parameters

filter – An OPTIMADE-compliant filter

Returns: Dict of Structures keyed by that database’s id system

get_structures(elements=None, nelements=None, nsites=None, chemical_formula_anonymous=None, chemical_formula_hill=None) → Dict[str, Dict[str, pymatgen.core.structure.Structure]][source]

Retrieve Structures from OPTIMADE providers.

Not all functionality of OPTIMADE is currently exposed in this convenience method. To use a custom filter, call get_structures_with_filter().

Parameters
  • elements – List of elements

  • nelements – Number of elements, e.g. 4 or [2, 5] for the range >=2 and <=5

  • nsites – Number of sites, e.g. 4 or [2, 5] for the range >=2 and <=5

  • chemical_formula_anonymous – Anonymous chemical formula

  • chemical_formula_hill – Chemical formula following Hill convention

Returns: Dict of (Dict Structures keyed by that database’s id system) keyed by provider

get_structures_with_filter(optimade_filter: str) → Dict[str, Dict[str, pymatgen.core.structure.Structure]][source]

Get structures satisfying a given OPTIMADE filter.

Parameters

filter – An OPTIMADE-compliant filter

Returns: Dict of Structures keyed by that database’s id system

refresh_aliases(providers_url='https://providers.optimade.org/providers.json')[source]

Updates available OPTIMADE structure resources based on the current list of OPTIMADE providers.

class Provider(name, base_url, description, homepage, prefix)[source]

Bases: tuple

Create new instance of Provider(name, base_url, description, homepage, prefix)

base_url[source]

Alias for field number 1

description[source]

Alias for field number 2

homepage[source]

Alias for field number 3

name[source]

Alias for field number 0

prefix[source]

Alias for field number 4