Skip to content

Mat Info

Overview

Mat Info is for storing the basic information regarding a material. This is intended as a basic local storage of the material information pulled from a database. The information is not to be changed while the calculations are performed.

from DeWorks.materials import mat_info

Attributes

Field Type Description
material_id str | MPID Unique identifier for the materila(MPID from Materials Project or string)
formula_pretty str Human-readable chemical formula
composition dict | Composition Elemental composition of the material
structure dict | Structure Crystallographic structure
nsites int Number of atomic sites in the structure
energy_above_hull float | None Energy stability metric
name str(computed) Generates a filename-like identifier with the format {material_id}_{formula_pretty}

load_DataDoc(cls, doc: DataDoc)

Constructs a mat_info object from a DataDoc instance. Currently only supports MPdataDoc and dict

mp_doc = {
    "material_id": "mp-149",
    "formula_pretty": "Si",
    "composition": {"Si": 1},
    "structure": Si_Structure,
    "nsites": 2,
    "energy_above_hull": 0.01,
}

matInfo = mat_info.load_DataDoc(mp_doc)

Field Serializers

serialize_composition(self, composition: dict | Composition, info)

Ensures composition is saved in dict format.

serialize_structure(self, structure: dict | Structure, info)

Ensures structure is saved in dict format.

Utility Method

save(self, path: str | None = None)

Saves the model as a JSON file.

info.save() # Using the example above, saves as "mp-149_Si_info.json"

load_json(cls, path: str)

Loads the mat_info object from a JSON file.

loaded_file = mat_info.load_json("mp-149_Si_info.json")

Note

  • Designed for immutable material metadata.
  • Relise on pymatgen objects (Composition, Structure) for rich data modeling.