pymatgen
材料科学工具包。晶体结构(CIF、POSCAR)、相图、能带结构、态密度、材料计划集成、格式转换,专为计算材料科学设计。
分类
开发工具安装
热度:7
下载并解压到你的 skills 目录
复制命令,发送给 OpenClaw 自动安装:
下载并安装这个技能 https://openskills.cc/api/download?slug=k-dense-ai-scientific-skills-pymatgen&locale=zh&source=copy
Pymatgen - Materials Genomics Toolkit
技能概述
Pymatgen 是一个全面的材料科学 Python 工具包,用于创建、分析和操作晶体结构与分子,计算相图与热力学性质,分析电子结构(能带、态密度),并访问 Materials Project 数据库。
适用场景
1. 晶体结构与分子操作
读取和写入 100+ 种结构文件格式(CIF、POSCAR、XYZ 等),分析空间群对称性,计算配位环境,生成超胞和原胞,进行元素替换和结构变换。
2. 电子结构分析与可视化
从 VASP、Gaussian 等计算软件输出中提取能带结构和态密度,计算带隙,识别金属/绝缘体/半导体,生成出版级质量的可视化图表。
3. 相图与热力学计算
构建二元、三元及多元相图,计算能量凸包(energy above hull),分析材料热力学稳定性,预测分解产物,评估亚稳态材料。
4. Materials Project 数据库访问
通过 API 访问 Materials Project 的计算材料数据库,搜索材料属性,获取晶体结构、能带、相变温度等数据,支持高通量材料筛选。
5. 计算工作流自动化
为 VASP、Quantum ESPRESSO、Gaussian 等软件生成标准输入文件,设置弛豫、静态计算、能带计算等常见工作流,追踪结构变换历史。
核心功能
1. 结构文件格式转换
支持 100+ 种晶体结构和分子文件格式的自动检测与转换,包括 CIF、POSCAR、VASP、XYZ、Gaussian、 Quantum ESPRESSO 等主流计算软件格式。
2. 对称性与配位环境分析
使用 spglib 进行空间群识别,获取惯用晶胞和原胞,分析配位环境(CrystalNN、Voronoi 等),计算键长、键角等结构参数。
3. 表面与界面分析
生成表面超胞(slabs),计算表面能,构建 Wulff 形状,寻找吸附位点,分析表面重构,支持表面科学和催化研究。
4. 相图构建器
从 Materials Project 或自定义数据构建相图,计算能量凸包,分析稳定性,预测分解路径,支持热力学研究和相图计算。
5. 能带与态密度分析
读取 VASP vasprun.xml 等输出文件,提取能带结构和态密度,计算带隙(direct/indirect),分析轨道投影,生成可定制图表。
常见问题
What is pymatgen used for?
Pymatgen (Python Materials Genomics) is a comprehensive library for materials analysis used to create, analyze, and manipulate crystal structures and molecules. It supports file format conversion, symmetry analysis, phase diagram construction, electronic structure analysis, surface generation, and provides programmatic access to the Materials Project database.
How do I convert CIF to POSCAR in pymatgen?
Use automatic format detection with
Structure.from_file() and to() methods:from pymatgen.core import Structure
struct = Structure.from_file("structure.cif")
struct.to(filename="POSCAR")Or use the bundled script:
python scripts/structure_converter.py structure.cif POSCARHow to connect to Materials Project API?
export MP_API_KEY="your_key"from mp_api.client import MPRester
with MPRester() as mpr:
struct = mpr.get_structure_by_material_id("mp-149")What file formats does pymatgen support?
Pymatgen supports 100+ file formats including CIF, POSCAR/CONTCAR (VASP), XYZ, CSSR, JSON, pymatgen's JSON serialization, Gaussian input/output, Quantum ESPRESSO PW input, and many more. Use
Structure.from_file() for automatic format detection.How to analyze crystal symmetry with pymatgen?
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
sga = SpacegroupAnalyzer(struct)
print(f"Space group: {sga.get_space_group_symbol()}")
print(f"Number: {sga.get_space_group_number()}")Is pymatgen free to use?
Yes, pymatgen is free and open-source under the MIT license. The Materials Project API is also free for academic use with registration. Commercial use requires separate licensing.
How to calculate band structure from VASP output?
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.plotter import BSPlotter
vasprun = Vasprun("vasprun.xml")
bs = vasprun.get_band_structure()
print(f"Band gap: {bs.get_band_gap()['energy']:.3f} eV")
plotter = BSPlotter(bs)
plotter.save_plot("band_structure.png")How to generate slab surfaces?
from pymatgen.core.surface import SlabGenerator
slabgen = SlabGenerator(struct, miller_index=(1,1,1),
min_slab_size=10.0, min_vacuum_size=10.0)
slabs = slabgen.get_slabs()技术要求
许可证
MIT License - Free for academic and commercial use