Suggesting substrate with new pymatgen API

Hello,

I’m trying to suggest suitable substrates for a new material. Previously, I followed this post successfully: How to find the substrate for my own structure

However I can’t seem to make a similar process work with the new pymatgen API nor can I successfully install the legacy version on my new machine. Does anybody know how to solve this issue?

Many thanks in advance

Hi @Lee1, here is a piece of code to retrieve all of the structures that have a substrate entry:

from emmet.core.summary import HasProps
from mp_api.client import MPRester

with MPRester() as mpr:
    docs = mpr.summary.search(has_props=[HasProps.substrates], fields=["structure", "material_id"])
    substrates = [doc.structure for doc in docs]

This is equivalent to:

# Get list of material IDs for common substrates
mids = mpr.get_all_substrates()

substrates = mpr.query({"material_id": {"$in": mids}}, ["structure", "material_id"])

Is this the portion of the code you were looking for?

– Jason

Hello @munrojn, this works thank you. I didn’t know about emmet before now!

Thanks agai