megnet.data.crystal module

class CrystalGraph(nn_strategy: Union[str, pymatgen.analysis.local_env.NearNeighbors] = 'MinimumDistanceNNAll', atom_converter: megnet.data.graph.Converter = None, bond_converter: megnet.data.graph.Converter = None, cutoff: float = 4.0)[source]

Bases: megnet.data.graph.StructureGraphFixedRadius

Convert a crystal into a graph with z as atomic feature and distance as bond feature one can optionally include state features

class CrystalGraphWithBondTypes(nn_strategy: Union[str, pymatgen.analysis.local_env.NearNeighbors] = 'VoronoiNN', atom_converter: megnet.data.graph.Converter = None, bond_converter: megnet.data.graph.Converter = None)[source]

Bases: megnet.data.graph.StructureGraph

Overwrite the bond attributes with bond types, defined simply by the metallicity of the atoms forming the bond. Three types of scenario is considered, nonmetal-nonmetal (type 0), metal-nonmetal (type 1), and metal-metal (type 2)

convert(structure: pymatgen.core.structure.Structure, state_attributes: List = None) → Dict[source]

Take a pymatgen structure and convert it to a index-type graph representation The graph will have node, distance, index1, index2, where node is a vector of Z number of atoms in the structure, index1 and index2 mark the atom indices forming the bond and separated by distance. For state attributes, you can set structure.state = [[xx, xx]] beforehand or the algorithm would take default [[0, 0]]

Parameters
  • state_attributes – (list) state attributes

  • structure – (pymatgen structure)

  • (dictionary)

get_elemental_embeddings() → Dict[source]

Provides the pre-trained elemental embeddings using formation energies, which can be used to speed up the training of other models. The embeddings are also extremely useful elemental descriptors that encode chemical similarity that may be used in other ways. See

“Graph Networks as a Universal Machine Learning Framework for Molecules and Crystals”, https://arxiv.org/abs/1812.05055

Returns

Dict of elemental embeddings as {symbol: length 16 string}