-
Notifications
You must be signed in to change notification settings - Fork 0
/
ternary_convex_hull.py
41 lines (29 loc) · 1.11 KB
/
ternary_convex_hull.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from typing import List
import pandas as pd
from pymatgen.analysis.phase_diagram import PDEntry, PhaseDiagram
from pymatgen.core.composition import Composition
from spt.plot_params import set_roman_plot_params
def ternary_convex_hull(
element_list: List[str],
max_natom: int = 8,
):
"""子三元系的三元相图 convex hull 绘制"""
system_name = "".join(element_list)
csv_fn = f"{system_name}_1_{max_natom}.csv"
df = pd.read_csv(csv_fn)
comp_df = df["conf_symbol"]
energy_df = df["mixing_energy_pa"]
entries = []
for i in range(df.shape[0]):
comp = Composition(comp_df[i])
energy = energy_df[i]
entry = PDEntry(composition=comp, energy=energy)
entries.append(entry)
phasediagram = PhaseDiagram(entries)
set_roman_plot_params()
ax = phasediagram.get_plot(backend="matplotlib", show_unstable=False)
ax.figure.savefig(f"{system_name}_convex_hull.png")
print(f"\n{system_name} convex hull figure is generated!")
if __name__ == "__main__":
element_list = ["Al", "Mo", "Zr"]
ternary_convex_hull(element_list=element_list)