声子晶体求解能带结构的代码
时间: 2023-07-13 15:07:05 浏览: 55
声子晶体的能带结构可以通过密度泛函理论 (DFT) 和密度泛函微扰理论 (DFPT) 计算得到。以下是一个使用VASP软件包计算声子晶体能带结构的示例代码:
1. 从POSCAR文件中读取晶体结构信息
```python
from pymatgen.io.vasp.inputs import Poscar
poscar = Poscar.from_file("POSCAR")
structure = poscar.structure
```
2. 设置计算参数
```python
from pymatgen.io.vasp.sets import MPStaticSet, MPNonSCFSet
# 静态计算参数
static_set = MPStaticSet(structure)
# 非自洽计算参数
non_scf_set = MPNonSCFSet(structure)
```
3. 运行静态计算
```python
from pymatgen.io.vasp.outputs import Vasprun
# 运行静态计算
static_dir = "static"
static_set.write_input(static_dir)
Vasprun(os.path.join(static_dir, "vasprun.xml"))
```
4. 生成声子模式
```python
from pymatgen.io.vasp.inputs import Incar, Kpoints
from pymatgen.io.vasp.sets import MPStaticSet, MPNonSCFSet
from pymatgen.electronic_structure.bandstructure import BandStructure
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
# 静态计算参数
static_set = MPStaticSet(structure)
# 非自洽计算参数
non_scf_set = MPNonSCFSet(structure)
# 声子模式计算参数
phonon_set = Incar.from_file(os.path.join(static_dir, "INCAR"))
phonon_set.update({
"IBRION": 6,
"NFREE": 2,
"ISYM": 2,
"NSW": 0,
"ICHARG": 2,
"TURBO": 0,
"LREAL": False, # 必须设置为 False
"ISMEAR": 0,
"SIGMA": 0.01,
})
phonon_set.write_file(os.path.join(non_scf_dir, "INCAR"))
# 声子模式 K 点
kpoints = Kpoints.automatic_density_by_vol(structure, 1000)
kpoints.write_file(os.path.join(non_scf_dir, "KPOINTS"))
# 运行非自洽计算
non_scf_dir = "nscf"
non_scf_set.write_input(non_scf_dir)
Vasprun(os.path.join(non_scf_dir, "vasprun.xml"))
# 读取声子模式信息
phonon_eigenvalues = Vasprun(os.path.join(non_scf_dir, "vasprun.xml")).phonon_band_structure
phonon_eigenvalues.write_yaml("phonon.yaml")
```
5. 计算声子晶体能带结构
```python
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.electronic_structure.plotter import PhononBSPlotter
# 读取静态计算结果
static_dir = "static"
vasprun = Vasprun(os.path.join(static_dir, "vasprun.xml"))
energy_range = [-10, 10] # 能量范围
# 读取声子模式计算结果
phonon_eigenvalues = BandStructure.from_file("phonon.yaml")
# 计算声子晶体能带结构
analyzer = SpacegroupAnalyzer(structure)
bandstructure = analyzer.get_band_structure(vasprun, line_mode=True, efermi=vasprun.efermi)
phonon_bandstructure = PhononBandStructureSymmLine(bandstructure, phonon_eigenvalues)
plotter = PhononBSPlotter(phonon_bandstructure)
plotter.get_plot(energy_range=energy_range).show()
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![mph](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)