windows 7
安装最新版即可,网址: https://www.anaconda.com
安装 Visual Studio 2015 或以上
Windows 10 系统建议直接安装官网最新的 Visual Studio 2019+,网址:
https://visualstudio.microsoft.com/zh-hans/downloads/
可能是 Windows 7 的原因,我的电脑无法安装 Visual Studio 2019+ 版本。
Visual Studio 2015 安装:
百度网盘-链接:https://pan.baidu.com/s/14Hk72X2vNObBFspc23Tnqg
提取码:fzpu
备注:文件为压缩包,没有设密码
pip install ase
pip install pymatgen
In [1]: import pymatgen
KPOINTS
POTCAR
vasprun.xml
# KPOINTS Parameters to Generate KPOINTS (Don't Edit This Line): 0.040 0.040 8 59 3 22 12 25
67
Reciprocal lattice
0.00000000000000 0.00000000000000 0.00000000000000 1
0.14285714285714 0.00000000000000 0.00000000000000 6
0.28571428571429 0.00000000000000 0.00000000000000 6
0.42857142857143 0.00000000000000 0.00000000000000 6
0.14285714285714 0.14285714285714 0.00000000000000 6
0.28571428571429 0.14285714285714 0.00000000000000 12
0.42857142857143 0.14285714285714 0.00000000000000 6
0.28571428571429 0.28571428571429 0.00000000000000 6
0.00000000000000 0.00000000000000 0.00000000000000 0 G
0.02380952380952 0.00000000000000 0.00000000000000 0
0.04761904761905 0.00000000000000 0.00000000000000 0
0.07142857142857 0.00000000000000 0.00000000000000 0
0.09523809523810 0.00000000000000 0.00000000000000 0
0.11904761904762 0.00000000000000 0.00000000000000 0
0.14285714285714 0.00000000000000 0.00000000000000 0
0.16666666666667 0.00000000000000 0.00000000000000 0
0.19047619047619 0.00000000000000 0.00000000000000 0
0.21428571428571 0.00000000000000 0.00000000000000 0
0.23809523809524 0.00000000000000 0.00000000000000 0
0.26190476190476 0.00000000000000 0.00000000000000 0
0.28571428571429 0.00000000000000 0.00000000000000 0
0.30952380952381 0.00000000000000 0.00000000000000 0
0.33333333333333 0.00000000000000 0.00000000000000 0
0.35714285714286 0.00000000000000 0.00000000000000 0
0.38095238095238 0.00000000000000 0.00000000000000 0
0.40476190476190 0.00000000000000 0.00000000000000 0
0.42857142857143 0.00000000000000 0.00000000000000 0
0.45238095238095 0.00000000000000 0.00000000000000 0
0.47619047619048 0.00000000000000 0.00000000000000 0
0.50000000000000 0.00000000000000 0.00000000000000 0 M
0.50000000000000 0.00000000000000 0.00000000000000 0 M
0.48484848484545 0.03030303030000 0.00000000000000 0
0.46969696969091 0.06060606060000 0.00000000000000 0
0.45454545453636 0.09090909090000 0.00000000000000 0
0.43939393938182 0.12121212120000 0.00000000000000 0
0.42424242422727 0.15151515150000 0.00000000000000 0
0.40909090907273 0.18181818180000 0.00000000000000 0
0.39393939391818 0.21212121210000 0.00000000000000 0
0.37878787876364 0.24242424240000 0.00000000000000 0
0.36363636360909 0.27272727270000 0.00000000000000 0
0.34848484845455 0.30303030300000 0.00000000000000 0
0.33333333330000 0.33333333330000 0.00000000000000 0 K
0.33333333330000 0.33333333330000 0.00000000000000 0 K
0.31944444441250 0.31944444441250 0.00000000000000 0
0.30555555552500 0.30555555552500 0.00000000000000 0
0.29166666663750 0.29166666663750 0.00000000000000 0
0.27777777775000 0.27777777775000 0.00000000000000 0
0.26388888886250 0.26388888886250 0.00000000000000 0
0.24999999997500 0.24999999997500 0.00000000000000 0
0.23611111108750 0.23611111108750 0.00000000000000 0
0.22222222220000 0.22222222220000 0.00000000000000 0
0.20833333331250 0.20833333331250 0.00000000000000 0
0.19444444442500 0.19444444442500 0.00000000000000 0
0.18055555553750 0.18055555553750 0.00000000000000 0
0.16666666665000 0.16666666665000 0.00000000000000 0
0.15277777776250 0.15277777776250 0.00000000000000 0
0.13888888887500 0.13888888887500 0.00000000000000 0
0.12499999998750 0.12499999998750 0.00000000000000 0
0.11111111110000 0.11111111110000 0.00000000000000 0
0.09722222221250 0.09722222221250 0.00000000000000 0
0.08333333332500 0.08333333332500 0.00000000000000 0
0.06944444443750 0.06944444443750 0.00000000000000 0
0.05555555555000 0.05555555555000 0.00000000000000 0
0.04166666666250 0.04166666666250 0.00000000000000 0
0.02777777777500 0.02777777777500 0.00000000000000 0
0.01388888888750 0.01388888888750 0.00000000000000 0
0.00000000000000 0.00000000000000 0.00000000000000 0 G
$ ipython
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.6.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]:
In [1]: ! ls -l
total 2064
-rw-r--r-- 1 lenovo 197121 4653 六月 27 14:21 KPOINTS
-rw-r--r-- 1 lenovo 197121 437216 六月 27 14:18 POTCAR
-rw-r--r-- 1 lenovo 197121 1664929 六月 27 14:18 vasprun.xml
In [2]: from pymatgen.io.vasp.outputs import Vasprun
In [3]: from pymatgen.electronic_structure.plotter import BSDOSPlotter, DosPlotter
In [4]: bs_vasprun = Vasprun("vasprun.xml", parse_projected_eigen=True)
C:\ProgramData\Anaconda3\lib\site-packages\pymatgen\io\vasp\inputs.py:1857: BadPotcarWarning: POTCAR with symbol Se has metadata that does not match any VASP POTCAR known to pymatgen. The data in this
POTCAR is known to match the following functionals: ['PBE_54', 'PBE_52', 'unvie_PBE_52']
BadPotcarWarning)
C:\ProgramData\Anaconda3\lib\site-packages\pymatgen\io\vasp\inputs.py:1857: BadPotcarWarning: POTCAR with symbol In has metadata that does not match any VASP POTCAR known to pymatgen. The data in this
POTCAR is known to match the following functionals: ['PBE_54', 'PBE_52', 'unvie_PBE_52']
BadPotcarWarning)
# 注意: force_hybrid_mode=True 是打开杂化泛函计算能带的开关,是 pymatgen 2020.05 版本后提供的新功能
In [5]: bs_data = bs_vasprun.get_band_structure(line_mode=True, force_hybrid_mode=True)
In [6]: dos_data = bs_vasprun.complete_dos
In [7]: bands_plot = BSDOSPlotter()
In [8]: plt = bands_plot.get_plot(bs=bs_data)
# 如果需要保存图片
# 支持格式 png, tif, jpg....,只要改后缀名即可
In [9]: plt.savefig("InSe_HSE_bands.tif")
In [10]: plt.savefig("InSe_HSE_bands.png")
In [11]: dos_plot = DosPlotter()
In [12]: dos_plot.add_dos("Total DOS", dos_data)
In [13]: plt = dos_plot.get_plot([-4, 4], [0, 12])
# 保存图片
In [14]: plt.savefig("InSe_HSE_dos.png")
8.例子 3 (能带和态密度放一张图)
In [15]: bs_dos_plot = BSDOSPlotter(bs_projection='elements', dos_projection='elements')
In [16]: plt = bs_dos_plot.get_plot(bs=bs_data, dos=dos_data)
# 保存图片
In [17]: plt.savefig("InSe_HSE_band_dos.png")
# plot_vasp_band_structure.py
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import BSDOSPlotter, DosPlotter
# 变量初始化
bs_vasprun = Vasprun("vasprun.xml", parse_projected_eigen=True)
bs_data = bs_vasprun.get_band_structure(line_mode=True, force_hybrid_mode=True)
dos_data = bs_vasprun.complete_dos
def plot_band():
# 相当于 bands_plot = BSDOSPlotter(bs_projection='elements', dos_projection='elements')
bands_plot = BSDOSPlotter()
plt = bands_plot.get_plot(bs=bs_data)
# 如果需要保存图片
# 支持格式 png, tif, jpg....,只要改后缀名即可
plt.savefig("InSe_HSE_bands.tif")
plt.savefig("InSe_HSE_bands.png")
def plot_dos():
dos_plot = DosPlotter()
dos_plot.add_dos("Total DOS", dos_data)
plt = dos_plot.get_plot([-4, 4], [0, 12])
plt.savefig("InSe_HSE_dos.png")
def plot_bands_dos():
bs_dos_plot = BSDOSPlotter(bs_projection='elements', dos_projection='elements')
plt = bs_dos_plot.get_plot(bs=bs_data, dos=dos_data)
plt.savefig("InSe_HSE_band_dos.png")
if __name__ == "__main__":
plot_band()
plot_dos()
plot_bands_dos()
可能因为是做计算的课题组写的代码缘故(不是专业写代码的课题组),只能实现它的基本功能,没有提取数据的接口,默认画的图太难看等等。要实现其它功能或许只能修改它的源码
修改 C:\ProgramData\Anaconda3\Lib\site-packages\pymatgen\electronic_structure 下的 plotter.py
\
推荐:
0. http://matgenb.materialsvirtuallab.org
1. https://mp.weixin.qq.com/s?__biz=MzI2OTQ4OTExOA==&mid=2247484405&idx=1&sn=d62277344ab874acc237d77188a3829c&chksm=eadec544dda94c52d91e45dda5b4b26293d0763187a9fed0702bad5c099dfde1e617f9ae1f5e&mpshare=1&scene=23&srcid=#rd
2. https://mp.weixin.qq.com/s?__biz=MzI2OTQ4OTExOA==&mid=2247485108&idx=1&sn=286449e79eda774f5753dc7477783383&chksm=eadec005dda94913eab48d136059e47a6146e21e19763f2aa155929bb15de6da3a4ebd7c4511&mpshare=1&scene=23&srcid=&sharer_sharetime=1567245116026&sharer_shareid=7391011dffdb5e46d46643d0c3ee23dc#rd