ABACUS计算模拟实例 | VIII. 基于HSE06的态密度与能带计算
©️ Copyright 2023 @ Authors
作者:Jinghang Wang (AISI电子结构团队实习生) 📨
日期:2024-5-27
共享协议:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
快速开始:点击上方的 开始连接 按钮,选择 ABACUS:3.6.3-user-guide 镜像及 c16_m64_cpu 节点配置,并在连接后点击右上方的切换内核,选择Bash内核稍等片刻即可运行。
🎯 本教程旨在展示使用ABACUS及LibRI完成杂化泛函能带及态密度计算。
本节教程目录如下:
1. 输入文件介绍
2. 能带及态密度计算
在使用ABACUS进行计算时,所有操作都需要在指定的文件夹目录下进行。我们已经准备好了数据集ABACUS-cases,其中文件夹“8”对应本节教程。
INPUT KPT STRU plot_band.py run_scf.log INPUT-band KPT-band Si_ONCV_PBE-1.0.upf plot_dos.py time.json INPUT-dos KPT-dos Si_gga_7au_100Ry_2s2p1d.orb run_band.log INPUT-scf OUT.ABACUS abacus.json run_dos.log
1. 输入文件介绍
ABACUS的HSE计算需要调用LibRI。有关LibRI的介绍、ABACUS杂化泛函相关输入参数、使用ABACUS+LibRI做杂化泛函做自洽计算的流程以及注意事项这些内容,相关开发者已经给出了详细的bohrium notebook教程,见:ABACUS+LibRI 做杂化泛函计算教程。本教程在此基础上介绍使用ABACUS+LibRI做杂化泛函能带及态密度的计算流程。
使用ABACUS+LibRI做杂化泛函能带及态密度的计算流程与使用一般泛函(例如LDA、GGA下的泛函)的计算流程完全相同,只需要在INPUT文件中设置参数dft_functional
参数便可指定你想使用的泛函。
INPUT_PARAMETERS out_chg 1 calculation scf symmetry 1 ecutwfc 100 scf_thr 1e-07 scf_nmax 100 basis_type lcao smearing_method gauss smearing_sigma 0.002 kspacing 0.08 cal_stress 1 cal_force 1 dft_functional hse
重要参数:
dft_functional
:指定使用的泛函。hse
代表HSE06杂化泛函,可通过exx_hybrid_alpha
和exx_hse_omega
参数来调整混合参数及屏蔽参数。out_chg
:输出电荷文件,用于后续能带及态密度计算。
INPUT_PARAMETERS symmetry 0 init_chg file calculation nscf dft_functional hse ecutwfc 100 scf_thr 1e-7 scf_nmax 300 basis_type lcao out_band 1 out_bandgap 1
重要参数:
calculation
:进行非自洽计算。symmetry
:非自洽计算时必须关闭对称性,确保我们指定的k点不会因为对称性而被折叠。init_chg
:读取自洽计算得到电荷文件,用于能带计算。calculation
:进行非自洽计算,电荷密度不再更新。out_band
:在OUT.ABACUS目录下输出能带信息。out_bandgap
:在OUT.ABACUS目录下的running_nscf.log中输出带隙信息。
INPUT_PARAMETERS symmetry 0 init_chg file calculation nscf dft_functional hse ecutwfc 100 scf_thr 1e-7 scf_nmax 300 basis_type lcao out_dos 1
重要参数:
out_dos
:在OUT.ABACUS目录下输出态密度信息。
K_POINTS 8 Line 0.000 0.000 0.000 300 # G 0.500 0.000 0.500 200 # X 0.625 0.250 0.625 200 # U 0.375 0.375 0.750 500 # K 0.000 0.000 0.000 500 # G 0.500 0.500 0.500 200 # L 0.500 0.250 0.750 200 # W 0.500 0.000 0.500 1 # X
K_POINTS 0 Gamma 15 15 15 0 0 0
ATOMIC_SPECIES Si 1 Si_ONCV_PBE-1.0.upf NUMERICAL_ORBITAL Si_gga_7au_100Ry_2s2p1d.orb LATTICE_CONSTANT 1.889766 LATTICE_VECTORS 0.0 2.708337 2.708337 2.708337 0.0 2.708337 2.708337 2.708337 0.0 ATOMIC_POSITIONS Direct Si 0.0 2 0.125 0.125 0.125 1 1 1 0.875 0.875 0.875 1 1 1
2. 能带及态密度计算
准备好了输入文件后,我们就可以开始进行计算。使用 ABACUS+LibRI 做杂化泛函计算时,因为内存消耗比较大,推荐给定计算资源的前提下,先尽量使用 OpenMP 多线程并行,再考虑使用 MPI 多进程并行。我们设置OMP_NUM_THREADS
为16,表示使用16个线程并行计算。
ABACUS v3.6.3 Atomic-orbital Based Ab-initio Computation at UStc Website: http://abacus.ustc.edu.cn/ Documentation: https://abacus.deepmodeling.com/ Repository: https://github.com/abacusmodeling/abacus-develop https://github.com/deepmodeling/abacus-develop Commit: 615828b (Tue May 21 10:48:51 2024 +0800) Thu May 23 23:20:18 2024 MAKE THE DIR : OUT.ABACUS/ RUNNING WITH DEVICE : CPU / Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz dft_functional readin is: hse dft_functional in pseudopot file is: PBE Please make sure this is what you need UNIFORM GRID DIM : 48 * 48 * 48 UNIFORM GRID DIM(BIG) : 12 * 12 * 12 DONE(0.0538626 SEC) : SETUP UNITCELL DONE(0.079452 SEC) : INIT K-POINTS --------------------------------------------------------- Self-consistent calculations for electrons --------------------------------------------------------- SPIN KPOINTS PROCESSORS NBASE 1 1376 1 26 --------------------------------------------------------- Use Systematically Improvable Atomic bases --------------------------------------------------------- ELEMENT ORBITALS NBASE NATOM XC Si 2s2p1d-7au 13 2 --------------------------------------------------------- Initial plane wave basis and FFT box --------------------------------------------------------- DONE(0.590667 SEC) : INIT PLANEWAVE ------------------------------------------- SELF-CONSISTENT : ------------------------------------------- START CHARGE : atomic DONE(23.8502 SEC) : INIT SCF ITER ETOT(eV) EDIFF(eV) DRHO TIME(s) GE1 -2.141027e+02 0.000000e+00 1.479e-01 2.689e+00 GE2 -2.141211e+02 -1.841148e-02 3.174e-02 2.532e+00 GE3 -2.141221e+02 -9.786757e-04 2.431e-03 2.556e+00 GE4 -2.141221e+02 -8.817232e-06 2.298e-04 2.537e+00 GE5 -2.141221e+02 -9.692720e-08 1.223e-05 2.543e+00 GE6 -2.141221e+02 -4.652934e-10 3.798e-06 2.532e+00 GE7 -2.141221e+02 -5.459681e-11 5.164e-08 2.539e+00 Updating EXX and rerun SCF 8.021e+01 (s) GE1 -2.140409e+02 0.000000e+00 3.640e-02 9.163e+00 GE2 -2.141562e+02 -1.152929e-01 2.710e-02 9.195e+00 GE3 -2.141530e+02 3.205288e-03 1.333e-02 9.177e+00 GE4 -2.141537e+02 -7.017391e-04 6.908e-04 9.194e+00 GE5 -2.141537e+02 -1.963940e-06 4.199e-05 9.159e+00 GE6 -2.141537e+02 -4.819963e-09 6.540e-06 9.094e+00 GE7 -2.141537e+02 -1.547030e-10 9.388e-07 9.104e+00 GE8 -2.141537e+02 -6.114649e-12 1.180e-07 9.110e+00 GE9 -2.141537e+02 -1.015080e-12 6.945e-09 9.115e+00 Updating EXX and rerun SCF 8.018e+01 (s) GE1 -2.141555e+02 0.000000e+00 1.239e-03 9.290e+00 GE2 -2.141555e+02 -2.728554e-06 2.031e-04 8.925e+00 GE3 -2.141555e+02 -8.282384e-08 1.736e-05 9.112e+00 GE4 -2.141555e+02 -9.819692e-11 5.980e-07 9.111e+00 GE5 -2.141555e+02 1.377609e-12 1.590e-08 9.114e+00 Updating EXX and rerun SCF 7.993e+01 (s) GE1 -2.141555e+02 0.000000e+00 1.911e-04 1.091e+01 GE2 -2.141555e+02 -7.694189e-08 2.914e-05 9.101e+00 GE3 -2.141555e+02 -2.242675e-09 2.570e-06 9.117e+00 GE4 -2.141555e+02 3.625286e-13 9.001e-08 9.166e+00 Updating EXX and rerun SCF 7.996e+01 (s) GE1 -2.141555e+02 0.000000e+00 2.808e-05 9.204e+00 GE2 -2.141555e+02 -1.656925e-09 4.198e-06 9.183e+00 GE3 -2.141555e+02 -3.816218e-11 3.750e-07 9.185e+00 GE4 -2.141555e+02 2.900229e-13 1.347e-08 9.189e+00 Updating EXX and rerun SCF 7.992e+01 (s) GE1 -2.141555e+02 0.000000e+00 4.082e-06 1.439e+01 GE2 -2.141555e+02 -2.561869e-11 6.011e-07 9.225e+00 GE3 -2.141555e+02 2.102666e-12 5.345e-08 9.197e+00 Updating EXX and rerun SCF 8.004e+01 (s) GE1 -2.141555e+02 0.000000e+00 5.866e-07 9.441e+00 GE2 -2.141555e+02 1.546789e-12 8.552e-08 9.376e+00 Updating EXX and rerun SCF 7.988e+01 (s) GE1 -2.141555e+02 0.000000e+00 6.616e-08 9.206e+00 ---------------------------------------------------------------- TOTAL-STRESS (KBAR) ---------------------------------------------------------------- 28.5296021558 -0.0000002139 -0.0000000222 -0.0000000820 28.5296022593 0.0000000526 -0.0000000499 0.0000000661 28.5293464313 ---------------------------------------------------------------- TOTAL-PRESSURE: 28.529517 KBAR TIME STATISTICS ------------------------------------------------------------------------------------- CLASS_NAME NAME TIME(Sec) CALLS AVG(Sec) PER(%) ------------------------------------------------------------------------------------- total 1103.00 9 122.56 100.00 Driver reading 0.02 1 0.02 0.00 Input Init 0.01 1 0.01 0.00 Input_Conv Convert 0.00 1 0.00 0.00 Driver driver_line 1102.99 1 1102.99 100.00 UnitCell check_tau 0.00 1 0.00 0.00 ESolver_KS_LCAO before_all_runners 18.63 1 18.63 1.69 PW_Basis_Sup setuptransform 0.02 1 0.02 0.00 PW_Basis_Sup distributeg 0.00 1 0.00 0.00 mymath heapsort 0.00 4 0.00 0.00 PW_Basis_K setuptransform 0.31 1 0.31 0.03 PW_Basis_K distributeg 0.00 1 0.00 0.00 PW_Basis setup_struc_factor 0.01 1 0.01 0.00 NOrbital_Lm extra_uniform 9.68 1875 0.01 0.88 Mathzone_Add1 SplineD2 0.02 1875 0.00 0.00 Mathzone_Add1 Cubic_Spline_Interpolation 0.09 1875 0.00 0.01 Mathzone_Add1 Uni_Deriv_Phi 9.48 1875 0.01 0.86 Exx_LRI init 17.89 1 17.89 1.62 Matrix_Orbs21 init 2.58 2 1.29 0.23 ORB_gaunt_table init_Gaunt_CH 0.15 3 0.05 0.01 ORB_gaunt_table Calc_Gaunt_CH 0.07 82305 0.00 0.01 ORB_gaunt_table init_Gaunt 1.37 3 0.46 0.12 ORB_gaunt_table Get_Gaunt_SH 2.18 3635313 0.00 0.20 Matrix_Orbs21 init_radial 0.00 2 0.00 0.00 Matrix_Orbs21 init_radial_table 12.88 2 6.44 1.17 ORB_table_phi cal_ST_Phi12_R 4.03 3439 0.00 0.37 LRI_CV set_orbitals 8.39 1 8.39 0.76 Matrix_Orbs11 init 0.24 1 0.24 0.02 Matrix_Orbs11 init_radial 0.00 1 0.00 0.00 Matrix_Orbs11 init_radial_table 1.40 1 1.40 0.13 ppcell_vl init_vloc 0.00 1 0.00 0.00 Ions opt_ions 1084.21 1 1084.21 98.30 ESolver_KS_LCAO runner 847.37 1 847.37 76.82 ESolver_KS_LCAO before_scf 5.19 1 5.19 0.47 ESolver_KS_LCAO beforesolver 0.02 1 0.02 0.00 ESolver_KS_LCAO set_matrix_grid 0.01 1 0.01 0.00 atom_arrange search 0.00 1 0.00 0.00 Grid_Technique init 0.01 1 0.01 0.00 Grid_BigCell grid_expansion_index 0.00 2 0.00 0.00 Record_adj for_2d 0.00 1 0.00 0.00 Grid_Driver Find_atom 0.00 88 0.00 0.00 LCAO_domain grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 OverlapNew initialize_SR 0.00 1 0.00 0.00 EkineticNew initialize_HR 0.00 1 0.00 0.00 NonlocalNew initialize_HR 0.00 1 0.00 0.00 Exx_LRI cal_exx_ions 5.14 1 5.14 0.47 LRI_CV cal_datas 1.69 3 0.56 0.15 Charge set_rho_core 0.00 1 0.00 0.00 Charge atomic_rho 0.01 1 0.01 0.00 PW_Basis_Sup recip2real 0.16 212 0.00 0.01 PW_Basis_Sup gathers_scatterp 0.02 212 0.00 0.00 Potential init_pot 0.02 1 0.02 0.00 Potential update_from_charge 6.42 36 0.18 0.58 Potential cal_fixed_v 0.00 1 0.00 0.00 PotLocal cal_fixed_v 0.00 1 0.00 0.00 Potential cal_v_eff 6.42 36 0.18 0.58 H_Hartree_pw v_hartree 0.07 36 0.00 0.01 PW_Basis_Sup real2recip 0.14 221 0.00 0.01 PW_Basis_Sup gatherp_scatters 0.01 221 0.00 0.00 PotXC cal_v_eff 6.34 36 0.18 0.57 XC_Functional v_xc 368.82 22 16.76 33.44 Potential interpolate_vrs 0.01 36 0.00 0.00 H_Ewald_pw compute_ewald 0.00 1 0.00 0.00 Charge_Mixing init_mixing 0.00 8 0.00 0.00 HSolverLCAO solve 275.06 35 7.86 24.94 HamiltLCAO updateHk 218.22 48160 0.00 19.78 OperatorLCAO init 4.60 192640 0.00 0.42 Veff contributeHR 2.03 35 0.06 0.18 Gint_interface cal_gint 3.95 71 0.06 0.36 Gint_interface cal_gint_vlocal 2.02 35 0.06 0.18 Gint_Tools cal_psir_ylm 0.67 7560 0.00 0.06 Gint_k transfer_pvpR 0.01 35 0.00 0.00 OverlapNew calculate_SR 0.02 1 0.02 0.00 OverlapNew contributeHk 11.02 48160 0.00 1.00 EkineticNew contributeHR 0.04 35 0.00 0.00 EkineticNew calculate_HR 0.04 1 0.04 0.00 NonlocalNew contributeHR 0.03 35 0.00 0.00 NonlocalNew calculate_HR 0.03 1 0.03 0.00 OperatorLCAO contributeHk 21.49 48160 0.00 1.95 HSolverLCAO hamiltSolvePsiK 48.17 48160 0.00 4.37 DiagoElpa elpa_solve 35.62 48160 0.00 3.23 ElecStateLCAO psiToRho 8.60 35 0.25 0.78 elecstate cal_dm 1.25 36 0.03 0.11 psiMulPsiMpi pdgemm 0.46 49536 0.00 0.04 DensityMatrix cal_DMR 5.34 36 0.15 0.48 Local_Orbital_wfc wfc_2d_to_grid 0.20 59168 0.00 0.02 Gint transfer_DMR 0.02 35 0.00 0.00 Gint_interface cal_gint_rho 1.71 35 0.05 0.16 Charge_Mixing get_drho 0.00 35 0.00 0.00 Charge mix_rho 0.07 27 0.00 0.01 Charge Broyden_mixing 0.01 27 0.00 0.00 RI_2D_Comm split_m2D_ktoR 387.72 7 55.39 35.15 Exx_LRI cal_exx_elec 171.93 7 24.56 15.59 RI_2D_Comm add_Hexx 180.82 38528 0.00 16.39 XC_Functional v_xc_libxc 6.25 28 0.22 0.57 Exx_LRI write_Hexxs_csr 0.23 1 0.23 0.02 ModuleIO save_sparse 0.20 1 0.20 0.02 ESolver_KS_LCAO out_deepks_labels 0.00 1 0.00 0.00 LCAO_Deepks_Interface out_deepks_labels 0.00 1 0.00 0.00 ESolver_KS_LCAO cal_force 236.84 1 236.84 21.47 Force_Stress_LCAO getForceStress 236.84 1 236.84 21.47 Forces cal_force_loc 0.01 1 0.01 0.00 Forces cal_force_ew 0.00 1 0.00 0.00 Forces cal_force_cc 0.00 1 0.00 0.00 Forces cal_force_scc 0.00 1 0.00 0.00 Stress_Func stress_loc 0.00 1 0.00 0.00 Stress_Func stress_har 0.00 1 0.00 0.00 Stress_Func stress_ewa 0.00 1 0.00 0.00 Stress_Func stress_cc 0.00 1 0.00 0.00 Stress_Func stress_gga 0.04 1 0.04 0.00 Force_LCAO_k ftable_k 0.82 1 0.82 0.07 Force_LCAO_k allocate_k 0.20 1 0.20 0.02 LCAO_gen_fixedH build_ST_new 0.11 2 0.06 0.01 LCAO_gen_fixedH b_NL_mu_new 0.08 1 0.08 0.01 Force_LCAO_k cal_foverlap_k 0.16 1 0.16 0.01 Force_LCAO_k cal_edm_2d 0.16 1 0.16 0.01 Force_LCAO_k cal_ftvnl_dphi_k 0.00 1 0.00 0.00 Force_LCAO_k cal_fvl_dphi_k 0.22 1 0.22 0.02 Gint_interface cal_gint_force 0.22 1 0.22 0.02 Gint_Tools cal_dpsir_ylm 0.13 108 0.00 0.01 Gint_Tools cal_dpsirr_ylm 0.02 108 0.00 0.00 Force_LCAO_k cal_fvnl_dbeta_k_new 0.25 1 0.25 0.02 Exx_LRI cal_exx_force 164.62 1 164.62 14.92 Exx_LRI cal_exx_stress 71.34 1 71.34 6.47 ESolver_KS_LCAO cal_stress 0.00 1 0.00 0.00 ESolver_KS_LCAO after_all_runners 0.07 1 0.07 0.01 ModuleIO write_istate_info 0.07 1 0.07 0.01 ------------------------------------------------------------------------------------- START Time : Thu May 23 23:20:18 2024 FINISH Time : Thu May 23 23:38:41 2024 TOTAL Time : 1103 SEE INFORMATION IN : OUT.ABACUS/
可以看到,使用杂化泛函后自洽计算的时间明显增加。
做完自洽及能带计算后,我们就可以在OUT.ABACUS/running_nscf.log文件中获取带隙。可以看到,相比于使用PBE泛函的计算结果,使用HSE06杂化泛函得到的带隙值更接近实验值。
40229: E_bandgap 1.19808 eV
完成能带和态密度计算后,在OUT.ABACUS目录下会分别生成能带和态密度数据的.dat文件,可以使用origin等软件进行处理。我们还可以使用ABACUS的代码仓库中提供的python包abacus-plot可视化,关于abacus-plot的介绍见:Plotting tool for ABACUS。下面我们提供了两个脚本分别用于完成能带和态密度的可视化。运行命令后会在OUT.ABACUS目录下生成图片并显示(在bash内核的notebook中无法直接显示图像)。
import os import matplotlib.pyplot as plt import shutil from PIL import Image def gen_band_config(efermi, energy_r,jsonf = "config.json"): import json config = { "bandfile": "BANDS_1.dat", "efermi": efermi, "energy_range": energy_r, "bandfig": "band.png", "kptfile": "KPT", "dpi": 300 } json.dump(config,open(jsonf,"w"),indent=4) def get_efermi(logfile): with open(logfile) as f: for line in f.readlines()[::-1]: if " EFERMI = " in line: return float(line.split()[-2]) # cp KPT into OUT current_dir = os.getcwd() target_dir = os.path.join(current_dir, "OUT.ABACUS") source_path = os.path.join(current_dir, "KPT") target_path = os.path.join(target_dir, "KPT") shutil.copy(source_path, target_path) # change to OUT os.chdir("OUT.ABACUS") # plot band efermi = get_efermi("running_scf.log") config = gen_band_config(efermi, [-4,4] ,"config.json") os.system("abacus-plot -b") # plot show if os.path.isfile("band.png"): plt.figure(dpi=300) plt.axis('off') plt.imshow(Image.open('band.png')) plt.show() else: print("找不到band.png文件!")
import os import matplotlib.pyplot as plt import shutil from PIL import Image def gen_tdos_config(efermi, energy_r,dos_r,jsonf = "config.json"): import json config = { "tdosfile": "TDOS", "efermi": efermi, "energy_range": energy_r, "dos_range": dos_r, "tdosfig": "tdos.png", "dpi": 300 } json.dump(config,open(jsonf,"w"),indent=4) def get_efermi(logfile): with open(logfile) as f: for line in f.readlines()[::-1]: if " EFERMI = " in line: return float(line.split()[-2]) # change to OUT os.chdir("OUT.ABACUS") # plot band efermi = get_efermi("running_scf.log") config = gen_tdos_config(efermi, [-4,4], [0,5], "config.json") os.system("abacus-plot -d") # plot show if os.path.isfile("tdos.png"): plt.figure(dpi=300) plt.axis('off') plt.imshow(Image.open('tdos.png')) plt.show() else: print("找不到tdos.png文件!")
恭喜你完成了第八个ABACUS计算模拟实例🎉
如果你还想尝试更多的计算实例,可以点击下方了解ABACUS计算模拟合集链接: ABACUS计算模拟实例 | 概述