The issues on retrieval of crystal properties based on Crystal System #4156
-
Hi everyone. I need some guidance on retrieving structural properties of materials, specifically the lattice parameters (a, b, and c lengths) and cell angles, constrained by the crystal system type (such as cubic). Could someone advise on how to perform this query using the new_api? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @brl1999. If I understand correctly, you want to get materials via If that is the case you might want to try the following: To get all matches: from mp_api.client import MPRester
import pandas as pd
# Query MP data (e.g., for cubic crystal systems)
# Reference: https://api.materialsproject.org/docs#/
with MPRester() as mpr:
cubic_materials = mpr.materials.summary.search(
crystal_system="Cubic"
)
# Convert the query results to a list of dictionaries
data = [material.model_dump() for material in cubic_materials]
# Convert to DataFrame
df_cubic = pd.DataFrame(data).set_index("material_id")
# Cache the DataFrame (this is ipynb magic, you would need ipynb instead of py)
%store df_cubic
# Load cache
# %store -r df_cubic To inspect a specific materials with ID: demo_struct = df_cubic.loc["mp-10018"]
print(demo_struct.structure)
# To get the Structure object itself (use under mpr context manager)
# mpr.get_structure_by_material_id("mp-10018") Would give:
|
Beta Was this translation helpful? Give feedback.
Hi @brl1999. If I understand correctly, you want to get materials via
MP_API
of specific crystal system (cubic in your case)? Checkout the official docs.If that is the case you might want to try the following:
To get all matches: