[ PROMPT_NODE_27122 ]
analysis_modules
[ SKILL_DOCUMENTATION ]
# Pymatgen 分析模块参考
本参考文档记录了 pymatgen 在材料表征、性质预测和计算分析方面的广泛分析能力。
## 相图与热力学
### 相图构建
python
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter
from pymatgen.entries.computed_entries import ComputedEntry
# 创建条目(成分和每个原子的能量)
entries = [
ComputedEntry("Fe", -8.4),
ComputedEntry("O2", -4.9),
ComputedEntry("FeO", -6.7),
ComputedEntry("Fe2O3", -8.3),
ComputedEntry("Fe3O4", -9.1),
]
# 构建相图
pd = PhaseDiagram(entries)
# 获取稳定条目
stable_entries = pd.stable_entries
# 获取能量高于凸包的数值(稳定性)
entry_to_test = ComputedEntry("Fe2O3", -8.0)
energy_above_hull = pd.get_e_above_hull(entry_to_test)
# 获取分解产物
decomp = pd.get_decomposition(entry_to_test.composition)
# 返回: {entry1: fraction1, entry2: fraction2, ...}
# 获取平衡反应能量
rxn_energy = pd.get_equilibrium_reaction_energy(entry_to_test)
# 绘制相图
plotter = PDPlotter(pd)
plotter.show()
plotter.write_image("phase_diagram.png")
### 化学势图
python
from pymatgen.analysis.phase_diagram import ChemicalPotentialDiagram
# 创建化学势图
cpd = ChemicalPotentialDiagram(entries, limits={"O": (-10, 0)})
# 获取域(稳定性区域)
domains = cpd.domains
### Pourbaix 图
具有 pH 值和电位轴的电化学相图。
python
from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixPlotter
from pymatgen.entries.computed_entries import ComputedEntry
# 创建包含水溶液物种校正的条目
entries = [...] # 包含固体和离子
# 构建 Pourbaix 图
pb = PourbaixDiagram(entries)
# 获取特定 pH 和电位下的稳定条目
stable_entry = pb.get_stable_entry(pH=7, V=0)
# 绘图
plotter = PourbaixPlotter(pb)
plotter.show()
## 结构分析
### 结构匹配与比较
python
from pymatgen.analysis.structure_matcher import StructureMatcher
matcher = StructureMatcher()
# 检查结构是否匹配
is_match = matcher.fit(struct1, struct2)
# 获取结构间的映射
mapping = matcher.get_mapping(struct1, struct2)
# 对相似结构进行分组
grouped = matcher.group_structures([struct1, struct2, struct3, ...])
### Ewald 求和
计算静电能