matproj Package

matproj Package

This module implements high-level interfaces to the public Materials Project.

rest Module

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

To make use of the Materials Project REST application programming interface ( Materials API), you need to be a registered user of the MaterialsProject, and obtain an API key by going to your profile at https://www.materialsproject.org/profile.

exception MPRestError[source]

Bases: exceptions.Exception

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

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

Bases: pymatgen.matproj.rest.MPRester

A class to conveniently interface with the 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.

snl Module

Classes and methods related to the Structure Notation Language (SNL)

class Author[source]

Bases: pymatgen.matproj.snl.Author

An Author contains two fields:

name

Name of author (String)

email

Email of author (String)

static from_dict(d)[source]
static parse_author(author)[source]

Parses an Author object from either a String, dict, or tuple

Args:
author:
A String formatted as “NAME <email@domain.com>”, (name, email) tuple, or a dict with name and email keys
Returns:
An Author object.
to_dict[source]
class HistoryNode[source]

Bases: pymatgen.matproj.snl.HistoryNode

A HistoryNode represents a step in the chain of events that lead to a Structure. HistoryNodes leave ‘breadcrumbs’ so that you can trace back how a Structure was created. For example, a HistoryNode might represent pulling a Structure from an external database such as the ICSD or CSD. Or, it might represent the application of a code (e.g. pymatgen) to the Structure, with a custom description of how that code was applied (e.g. a site removal Transformation was applied).

A HistoryNode contains three fields:

name

The name of a code or resource that this Structure encountered in its history (String)

url

The URL of that code/resource (String)

description

A free-form description of how the code/resource is related to the Structure (dict).

static from_dict(h_node)[source]
static parse_history_node(h_node)[source]

Parses a History Node object from either a dict or a tuple.

Args:
h_node:
A dict with name/url/description fields or a 3-element tuple.
Returns:
History node.
to_dict[source]
class StructureNL(struct_or_mol, authors, projects=None, references='', remarks=None, data=None, history=None, created_at=None)[source]

Bases: object

The Structure Notation Language (SNL, pronounced ‘snail’) is container for a pymatgen Structure/Molecule object with some additional fields for enhanced provenance. It is meant to be imported/exported in a JSON file format with the following structure:

  • about
    • created_at
    • authors
    • projects
    • references
    • remarks
    • data
    • history
  • lattice (optional)

  • sites

Args:
struct_or_mol:
A pymatgen.core.structure Structure/Molecule object
authors:
List of {“name”:’‘, “email”:’‘} dicts, list of Strings as ‘John Doe <johndoe@gmail.com>’, or a single String with commas separating authors
projects:
List of Strings [‘Project A’, ‘Project B’]
references:
A String in BibTeX format
remarks:
List of Strings [‘Remark A’, ‘Remark B’]
data:
A free form dict. Namespaced at the root level with an underscore, e.g. {“_materialsproject”: <custom data>}
history:
List of dicts - [{‘name’:’‘, ‘url’:’‘, ‘description’:{}}]
created_at:
A datetime object
classmethod from_dict(d)[source]
to_dict[source]
is_valid_bibtex(reference)[source]

Use pybtex to validate that a reference is in proper BibTeX format

Args:
reference:
A String reference in BibTeX format
Returns:
Boolean indicating if reference is valid bibtex.

Table Of Contents

This Page