©️ Copyright 2024 @ Authors
作者:John Yan (AISI电子结构团队实习生) 📨
日期:2024-9-26
共享协议:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
快速开始:点击上方的 开始连接 按钮,选择 deepks-abacus:3.7.5v1 镜像及 c2_m4_cpu 节点配置,并在连接后点击右上方的切换内核,选择Python (ipykernel)内核稍等片刻即可运行。
目录:
0. 写在前边
1. 多元素体系多标签训练数据的准备
2. 进行多元素体系多标签训练需要修改的参数
3. 多元素体系多标签训练过程
4. 多元素体系多标签训练结果
5. DeePKS实战教程小结
0. 写在前边
对于真实的研究体系,其材料的组成往往是复杂多样的,即具有原子数不同、元素组合不同等特点。实现对于这类复杂体系的DeePKS模型的训练具有重要实际应用价值,但同时也带来了训练难度上的大幅度提升。
本节作为DeePKS实战系列的最后一篇教程,将会介绍多元素组合体系多标签训练,希望用户可以基于本教程构建出适合自己研究体系的DeePKS模型。
1. 训练数据的准备
参考附录教程DeePKS实战(附录)|使用DeePKS init功能进行训练数据的生产里的方案,使用ABACUS批量生产hse06标签。
2.相对于单一元素组分训练需要修改的参数
2.1 scf_abacus.yaml
Step1. 需要修改abacus计算input参数,使其能够正常输出力、应力和轨道文件
cal_force: 1 #输出力结果
cal_stress: 1 #输出应力结果
deepks_bandgap: 1 #输出轨道(能带)结果
Step2. 需要修改abacus计算所有的赝势和轨道文件(包含当前研究多元素体系的所有元素)
orb_files: ["Cs_gga_10au_100Ry_4s2p1d.orb","Pb_gga_7au_100Ry_2s2p2d1f.orb","I_gga_7au_100Ry_2s2p2d1f.orb","C_gga_7au_100Ry_2s2p1d.orb","N_gga_7au_100Ry_2s2p1d.orb","H_gga_6au_100Ry_2s1p.orb"]
pp_files: ["Cs_ONCV_PBE-1.0.upf","Pb_ONCV_PBE-1.0.upf","I_ONCV_PBE-1.0.upf","C_ONCV_PBE-1.0.upf","N_ONCV_PBE-1.0.upf","H_ONCV_PBE-1.0.upf"]
Step3. 删除(注释)ntype关键词(ABACUS目前已支持从STRU文件读取元素信息)
完整的参数:
scf_abacus:
#INPUT args
# ntype: 3
ecutwfc: 100
scf_thr: 1e-7
scf_nmax: 50
dft_functional: "pbe"
gamma_only: 0
kspacing: 0.1
cal_force: 1
cal_stress: 1
deepks_bandgap: 1
#STRU args ( Here are default STRU args, you can set for each group in ../systems/group.xx/stru_abacus.yaml )
orb_files: ["Cs_gga_10au_100Ry_4s2p1d.orb","Pb_gga_7au_100Ry_2s2p2d1f.orb","I_gga_7au_100Ry_2s2p2d1f.orb","C_gga_7au_100Ry_2s2p1d.orb","N_gga_7au_100Ry_2s2p1d.orb","H_gga_6au_100Ry_2s1p.orb"]
pp_files: ["Cs_ONCV_PBE-1.0.upf","Pb_ONCV_PBE-1.0.upf","I_ONCV_PBE-1.0.upf","C_ONCV_PBE-1.0.upf","N_ONCV_PBE-1.0.upf","H_ONCV_PBE-1.0.upf"]
proj_file: ["jle.orb"]
lattice_constant: 1.88972613
lattice_vector: [[28, 0, 0], [0, 28, 0], [0, 0, 28]]
coord_type: "Cartesian"
#cmd args
run_cmd : "mpirun"
abacus_path: "abacus"
注意,为了使得模型更容易收敛,第一轮init时不训练力、应力和轨道标签,相应的init_scf_abacus部分为:
init_scf_abacus:
orb_files: ["Cs_gga_10au_100Ry_4s2p1d.orb","Pb_gga_7au_100Ry_2s2p2d1f.orb","I_gga_7au_100Ry_2s2p2d1f.orb","C_gga_7au_100Ry_2s2p1d.orb","N_gga_7au_100Ry_2s2p1d.orb","H_gga_6au_100Ry_2s1p.orb"]
pp_files: ["Cs_ONCV_PBE-1.0.upf","Pb_ONCV_PBE-1.0.upf","I_ONCV_PBE-1.0.upf","C_ONCV_PBE-1.0.upf","N_ONCV_PBE-1.0.upf","H_ONCV_PBE-1.0.upf"]
proj_file: ["jle.orb"]
# ntype: 3
ecutwfc: 100
scf_thr: 1e-7
scf_nmax: 50
dft_functional: "pbe"
gamma_only: 0
kspacing: 0.1
cal_force: 0
cal_stress: 0
deepks_bandgap: 0
lattice_constant: 1.88972613
lattice_vector: [[28, 0, 0], [0, 28, 0], [0, 0, 28]]
coord_type: "Cartesian"
#cmd args
run_cmd : "mpirun"
abacus_path: "abacus"
2.2 params.yaml
需要修改params.yaml
中的参数使得其他标签可以加入到训练中,
extra_label
为true
时打开多标签训练
extra_label: true #set to true if force/stress/energy gap labels are required
force_factor
stress_factor
和orbital_factor
决定其在Loss函数中的占比
force_factor: 1 #for force training; otherwise set to 0.
stress_factor: 0.1 #for stress training; otherwise set to 0.
orbital_factor: 0.1 #set to non-zero value (e.g. 0.001) for orbital training.
2.3 systems.yaml
加入新元素组合的体系:
# this is only part of input settings.
# should be used together with params.yaml and machines.yaml
# training and testing systems
systems_train: # can also be files that containing system paths
- ../systems/group.00 # support glob
- ../systems/group.02 # support glob
- ../systems/group.05 # support glob
- ../systems/group.06 # support glob
systems_test: # if empty, use the last system of training set
- ../systems/group.01 # support glob
- ../systems/group.04 # support glob
3. 训练过程
填写提交bohrium服务器运行的账户信息
取消以下代码的注释并运行可进行计算,大约会产生150元机时费用。
4. 训练结果
多标签训练每一轮的log.data如下:
iter.00
Training:
Convergence:
17 / 93 = 0.18280
Energy:
ME: 0.03678355183812469
MAE: 0.03678355183812469
MARE: 0.022374677561990127
Force:
MAE: 0.0023626622572945626
Stress:
MAE: 0.04656025769972068
Band gap:
ME: 0.035481124783633224
MAE: 0.035481124783633224
Testing:
Convergence:
1 / 16 = 0.06250
Energy:
ME: 0.026203197120615584
MAE: 0.026203197120615584
MARE: 0.01570646217164387
Force:
MAE: 0.00396892100486528
Stress:
MAE: 0.04581480462217594
Band gap:
ME: 0.04220258611926125
MAE: 0.04220258611926125
iter.01
Training:
Convergence:
22 / 93 = 0.23656
Energy:
ME: 0.017447338740107284
MAE: 0.021673921541043202
MARE: 0.01035344799812454
Force:
MAE: 0.002952115029176204
Stress:
MAE: 0.10079806752968964
Band gap:
ME: 0.011913024156628177
MAE: 0.011913024156628177
Testing:
Convergence:
5 / 16 = 0.31250
Energy:
ME: -0.002185551241431938
MAE: 0.009773697663355563
MARE: 0.019632889981539225
Force:
MAE: 0.003489262446198467
Stress:
MAE: 0.051701256326736784
Band gap:
ME: 0.01836722907165925
MAE: 0.01836722907165925
iter.02
Training:
Convergence:
87 / 93 = 0.93548
Energy:
ME: 0.005748775404959639
MAE: 0.006270612955886072
MARE: 0.0054503712170346115
Force:
MAE: 0.0022837451799805042
Stress:
MAE: 0.037030268121047795
Band gap:
ME: 0.005538189169722413
MAE: 0.005538189169722413
Testing:
Convergence:
16 / 16 = 1.00000
Energy:
ME: 0.0029239311544557722
MAE: 0.003459647231053964
MARE: 0.0037046138913416193
Force:
MAE: 0.002672497699164389
Stress:
MAE: 0.02180791530004329
Band gap:
ME: 0.009882601267032512
MAE: 0.009882601267032512
iter.03
Training:
Convergence:
90 / 93 = 0.96774
Energy:
ME: 0.0025007355962228055
MAE: 0.003148663496330623
MARE: 0.0026888235274018907
Force:
MAE: 0.0014150615867891984
Stress:
MAE: 0.027713359144555753
Band gap:
ME: 0.00330616134458794
MAE: 0.00330616134458794
Testing:
Convergence:
16 / 16 = 1.00000
Energy:
ME: 0.002204148128448935
MAE: 0.003543566321418723
MARE: 0.003074614565271361
Force:
MAE: 0.001765359678230145
Stress:
MAE: 0.01685252157592679
Band gap:
ME: 0.006134469434761008
MAE: 0.006134469434761008
iter.04
Training:
Convergence:
92 / 93 = 0.98925
Energy:
ME: 0.0008629536289488466
MAE: 0.0017784968657080205
MARE: 0.0016101344519868532
Force:
MAE: 0.0011471838584834592
Stress:
MAE: 0.02329828587398357
Band gap:
ME: 0.0029852458155659478
MAE: 0.0029852458155659478
Testing:
Convergence:
16 / 16 = 1.00000
Energy:
ME: 0.0006442695368136242
MAE: 0.002888851101623402
MARE: 0.0029009941451872976
Force:
MAE: 0.0013859574540888609
Stress:
MAE: 0.014620123544422806
Band gap:
ME: 0.004848511896749577
MAE: 0.004848511896749577
iter.05
Training:
Convergence:
93 / 93 = 1.00000
Energy:
ME: 0.0003172572458410169
MAE: 0.0015052621365734384
MARE: 0.00146646476885235
Force:
MAE: 0.0010180623545925896
Stress:
MAE: 0.01729372091527994
Band gap:
ME: 0.0028973887975609226
MAE: 0.0028973887975609226
Testing:
Convergence:
16 / 16 = 1.00000
Energy:
ME: 0.00033273453499305106
MAE: 0.002712417126957689
MARE: 0.002741844005845267
Force:
MAE: 0.0012701853078435972
Stress:
MAE: 0.011529820278091817
Band gap:
ME: 0.00433436312018421
MAE: 0.00433436312018421
可以看到,引入不同元素体系后,在初始轮次训练得到的模型引入下一轮scf计算时收敛难度较大,但在不断迭代后,算例的收敛比例迅速提升,达到100%收敛。教程中为了演示iter只设置为6,在真实环境下可能需要更多的循环次数以获得更精确的结果。
5. DeePKS实战教程小结
密度泛函理论(DFT)中常用的泛函如PBE具有效率高但精度不足的问题,而杂化泛函如HSE06有精度高但效率低的问题。DeePKS通过引入深度学习模型来弥补低精度泛函和高精度泛函之间的差异,从而在高效率的同时提高整体计算的精度。本教程从易到难介绍了在真实材料体系中DeePKS模型的训练,通过上手操作,可以看到DeePKS在弥补泛函精度问题上的极大潜力,例如在本篇中,引入DeePKS模型的PBE计算花销只占HSE计算的15%左右,但精度却已经和HSE相当,并且随着iter轮次的增加,误差逐渐降低。这一创新方法为DFT计算带来了新的可能性,值得我们在未来的研究中进一步探索和应用。