Retrieving work function from MP using API

#1

I would like to retrieve workfunction that is available at Materials Project.

For example, look at: https://materialsproject.org/materials/mp-72/ ; here I would like to retrieve the ‘Surfaces’ table (Located above the Elasticity data) and place it in a data frame.

Can this be done using API?

Thanks.
Nitin

1 Like
#2

AFAIK there’s no way to fetch the data in a single query, but you can use a combination of the has and the get_surface_data method in the python api to get all of the data, something like:

from pymatgen import MPRester
import pandas as pd
import tqdm

with MPRester() as mpr:
    data = mpr.query({"has": "surfaces"}, 
                     ['material_id', 'pretty_formula'])
    all_sdata = []
    for datum in tqdm.tqdm(data):
        agg_sdata = mpr.get_surface_data(datum['material_id'])
        surfaces = agg_sdata['surfaces']
        for surface in surfaces:
            surface.update(datum)
        all_sdata.extend(surfaces)
df = pd.DataFrame(all_sdata)
1 Like