pymatgen.ext.matproj module

This module provides classes to interface with the Materials Project REST API v2 to enable the creation of data structures and pymatgen objects using Materials Project data.

To make use of the Materials API, you need to be a registered user of the Materials Project, and obtain an API key by going to your dashboard at https://materialsproject.org/dashboard.

exception MPRestError[source]

Bases: Exception

Exception class for legacy MPRestAdaptor. Raised when the query has problems, e.g., bad query format.

class MPRester(*args, **kwargs)[source]

Bases: object

A class to conveniently interface with the new and legacy Materials Project REST interface. The recommended way to use MPRester is with the “with” context manager to ensure that sessions are properly closed after usage:

with MPRester("API_KEY") as m:
    do_something

MPRester uses the “requests” package, which provides for HTTP connection pooling. All connections are made via https for security.

For more advanced uses of the Materials API, please consult the API documentation at https://materialsproject.org/api and https://docs.materialsproject.org.

Note that this barebones class is to handle transition between the old and new API keys in a transparent manner, providing backwards compatibility. Use it as you would with normal MPRester usage. If a new API key is detected, the _MPResterNew will be initialized. Otherwise, the _MPResterLegacy. Consult the Materials Project documentation at https://docs.materialsproject.org for advice on which API to use.

Parameters:
  • *args – Pass through to either legacy or new MPRester.

  • **kwargs – Pass through to either legacy or new MPRester.

class TaskType(value)[source]

Bases: Enum

task types available in legacy MP data

GGAU_DEF = 'GGA+U Deformation'[source]
GGAU_LINE = 'GGA+U NSCF Line'[source]
GGAU_OPT = 'GGA+U Structure Optimization'[source]
GGAU_STATIC = 'GGA+U Static'[source]
GGAU_STATIC_DIEL = 'GGA+U Static Dielectric'[source]
GGAU_UNIFORM = 'GGA+U NSCF Uniform'[source]
GGA_DEF = 'GGA Deformation'[source]
GGA_LINE = 'GGA NSCF Line'[source]
GGA_OPT = 'GGA Structure Optimization'[source]
GGA_STATIC = 'GGA Static'[source]
GGA_STATIC_DIEL = 'GGA Static Dielectric'[source]
GGA_UNIFORM = 'GGA NSCF Uniform'[source]
LDA_STATIC_DIEL = 'LDA Static Dielectric'[source]
SCAN_OPT = 'SCAN Structure Optimization'[source]
get_chunks(sequence: Sequence[Any], size=1)[source]
Parameters:
  • sequence (Sequence[Any]) – Any sequence.

  • size (int) – Chunk length. Defaults to 1.

Returns:

input sequence in chunks of length size.

Return type:

list[Sequence[Any]]