I need your help on how to derive the results of the phase diagram. I currently export the phase diagram under 0K conditions by the following code:
from mp_api.client import MPRester
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter
from pymatgen.entries.computed_entries import ComputedEntry
初始化 MPRester 并提供 API 密钥
api_key = “api-key”
chemsys = [“Li”, “Fe”, “O”] # 示例化学体系
temperature = 1200 # 示例温度 (K)
初始化 MPRester
with MPRester(api_key) as mpr:
# 获取指定化学体系的相图数据
entries = mpr.get_entries_in_chemsys(chemsys)
# 创建相图对象
pd = PhaseDiagram(entries)
# 创建相图绘图对象
plotter = PDPlotter(pd)
# 显示相图
plotter.show()
But I don’t know how to derive the phase diagram for different temperature parameters. If possible, can you provide the corresponding code?
Hi @hyqwithwjt99800,
A slight modification to your approach should get you close to where you want to be to match the phase diagram app on MP.
from mp_api.client import MPRester
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter
from pymatgen.entries.computed_entries import ComputedEntry
# new import
from pymatgen.entries.computed_entries import GibbsComputedStructureEntry
api_key = “api-key”
chemsys = [“Li”, “Fe”, “O”]
temperature = 1200
with MPRester(api_key) as mpr:
entries = mpr.get_entries_in_chemsys(chemsys)
# new code - choose whether or not you want to shadow the entries
# returned by the api
entries = GibbsComputedStructureEntry.from_entries(
entries, temp=temperature
)
pd = PhaseDiagram(entries)
plotter = PDPlotter(pd)
plotter.show()
1 Like
Thank you very much indeed. I have spent three or four days studying how to derive phase diagrams at different temperatures, but I am not very familiar with this aspect. Thank you very much. Best wishes for you.