Obtain large numbers of band structures?

I’m attempting to calculate the electron and hole effective masses of several thousand materials from the MP database, using sumo, which requires the bandstructure. I start by using a mongo-like query to find materials which have bandstructures and meet my other criteria, but putting “bandstructure” in the “properties” argument to MPRester.query() returns None, probably because “bandstructure” isn’t a supported property. For a small number of materials I could simply call get_bandstructure_by_material_id() for each, but I don’t want to hit the API thousands of times every time I run this query.
Is there a good way to do this, or is it beyond the current capabilities of the API?


1 Like

Hi Steven,

I think you can try this

from pymatgen.ext.matproj import MPRester
if __name__=="__main__":
    mpr = MPRester("your_MPkey")
    for id_ in range(1,1000):
        mp_id = "mp-" + str(id_)
        has_bs = False
            bs = mpr.get_bandstructure_by_material_id(material_id=mp_id)
            if bs is not None: has_bs = True
        if has_bs:
            do_something with bs (e.g., save it to a json file)

That method works well for a small number of materials, but each call of get_bandstructure_by_material_id takes about 5 seconds for me, so it isn’t practical at large scale. I think it would also degrade the performance of the MP database for other users, as well, due to the large number of API calls.

You’re right. Look at my post here

I need the line mode band structure to calculate effective mass, not the uniform NSCF calculation.

You can set line_mode = True

Pinging @shyamd @mkhorton @tschaume if they may be able to answer this