DeepMD 使用 介绍
DeePMD 使用教程、科研案例、问题收集合集 - Bohrium
使用深度神经网络构建势函数
版本:初始版本(v0)、v1、v2
DP library:DP 模型数据库(类似 Material Project)
exploration、labeling、train 三个过程
learning/notes/DeePMD/DeePMD-kit安装.md at main · wangchr1617/learning · GitHub
learning/notes/DeePMD/DeePMD-kit入门.md at main · wangchr1617/learning · GitHub
DeepMD ASE calculator
1 2 3 4 5 6 7 8 9 from deepmd.calculator import DPcalc = DP(model=...) atoms.calc = calc energy = atoms.get_potential_energy() forces = atoms.get_forces() stress = atoms.get_stress()
描述符
1 2 3 4 5 sel_a se_e2_a se_e3 se_atten
模型压缩
实例
安装 DeePMD-kit 含 CPU 和 GPU 版本
dpgen 1 2 3 4 5 6 7 8 9 10 pip install dpgen conda install -c conda-forge dpgen git clone https://github.com/deepmodeling/dpgen && pip install ./dpgen pip install -U dpdata
使用 工具
机器学习力场训练集可视化 - 知乎
1 2 3 4 5 6 7 8 from deepmd.infer import DeepPotdp = DeepPot(args.model) descriptor = dp.eval_descriptor() dp.eval ()
DeePMD-kit 训练
训练数据中必要的信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 training_data ├── set.000 │ ├── box.npy │ ├── coord.npy │ ├── energy.npy │ ├── force.npy │ └── virial.npy ├── type.raw └── type_map.raw coord.npy type.raw energy.npy force.npy box.npy virial.raw
1 2 3 4 model learning_rate loss training
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 "model" : { "type_map" : [ "H" , "C" ] , "descriptor" : { "type" : "se_e2_a" , "rcut" : 6.00 , "rcut_smth" : 0.50 , "sel" : "auto" , "neuron" : [ 25 , 50 , 100 ] , "resnet_dt" : false , "axis_neuron" : 16 , "seed" : 1 , "_comment" : "that's all" } , "fitting_net" : { "neuron" : [ 240 , 240 , 240 ] , "resnet_dt" : true , "seed" : 1 , "_comment" : "that's all" } , "_comment" : "that's all" ' } ,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 dp train input.json dp train input.json --restart model.ckpt train.log lcurve.out dp freeze -o graph.pb dp compress -i graph.pb -o graph-compress.pb dp test -m graph.pb -s ...
dpgen 构建训练集、训练
同步学习
autoset 功能
使用 DeePMD-kit 同时训练参数初始化不同的 4 个势函数
1 2 3 4 5 6 7 8 9 10 11 12 13 init_bulk init_surf run dpgen sub-command PARAM MACHINE PARAM MACHINE dpgen.log
mdapy 库可生成微扰结构
1 2 3 4 5 import mdapy as mpmp.init() pert = mp.PerturbModel()
DPMD - Deep Potential Molecular Dynamics-Prepare Dataset
机器学习势预测精度用 MAE 评估
Deepmd-kit & DPGEN 使用笔记
离线安装
给离线安装的 conda 环境添加环境名
1 ln -s ~/src/deepmd-kit ~/src/miniconda3/envs/<new_env_name>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 deepmd-kit will now be installed into this location: /home/yangsl/deepmd-kit - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/home/yangsl/deepmd-kit] >>> $HOME /src/deepmd-kit PREFIX=/home/yangsl/src/deepmd-kit Unpacking payload ... Notes: The off-line packages and conda packages require the GNU C Library 2.17 or above[1]. The GPU version requires compatible NVIDIA driver to be installed in advance[2]. It is possible to force conda to override detection when installation[3] (such as CONDA_OVERRIDE_CUDA), but these requirements are still necessary during runtime. [1] The GNU C Library. https://www.gnu.org/software/libc/ [2] Minor Version Compatibility. NVIDIA Data Center GPU Driver Documentation. https://docs.nvidia.com/deploy/cuda-compatibility/index.html#minor-version-compatibility [3] Overriding detected packages. conda documentation. https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html#overriding-detected-packages Installing base environment... Downloading and Extracting Packages Downloading and Extracting Packages Preparing transaction: done Executing transaction: done Please activate the environment before using the packages: source /path/to/deepmd-kit/bin/activate /path/to/deepmd-kitThe following executable files have been installed: 1. DeePMD-kit CLi: dp -h 2. LAMMPS: lmp -h 3. DeePMD-kit i-Pi interface: dp_ipi 4. MPICH: mpirun -h 5. Horovod: horovod -h The following Python libraries have been installed: 1. deepmd 2. dpdata 3. pylammps If you have any questions, seek help from https://github.com/deepmodeling/deepmd-kit/discussions
这两个 raw 文件内容对训练是否会有影响?
通配符获取 outcar deepmd 数据,能量顺序不是按第 1-4 步来的
默认 240
将 ICET 的 data 转换成 deepmd 格式
water se_e2_a 80*3 训练集 80 测试集 type.new 192 行
dpdata
dpdata:将多种构型文件格式转换成 deepmd 格式(转换成其他格式的功能一般)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 import dpdatad_outcar = dpdata.LabeledSystem("OUTCAR" , fmt="vasp/outcar" ) d_outcar["energies" ] d_outcar["forces" ] d_outcar["virials" ] d_outcar.get_nframes() d_outcar.get_natoms() atom_names atom_numbs atoms_types cells coords energies forces virials dpdata.LabeledSystem('OUTCAR' ).to() "deepmd/raw" "deepmd/npy" "vasp/poscar" "vasp/contcar" "vasp/string" "vasp/outcar" "lammps/lmp" "lammps/dump" "pymatgen/structure" "pymatgen/molecule" "pymatgen/computedstructureentry" "ase/structure" training_systems = dpdata.LabeledSystem() predict = training_systems.predict("graph.pb" ) training_systems["energies" ] predict["energies" ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 import dpdatapert_num = 2 perturbed_system = dpdata.System("POSCAR" ).perturb( pert_num=pert_num, cell_pert_fraction=0.03 , atom_pert_distance=0.01 , atom_pert_style="uniform" , atom_pert_prob=1.0 , ) for i in range (pert_num): perturbed_system.to( "vasp/poscar" , f"pert/POSCAR.{i} " , frame_idx=i, ) perturbed_system.sub_system(i).to( "vasp/poscar" , f"pert/POSCAR.{i} " , ) atoms_list = perturbed_system.to("ase/structure" ) write(xyz_fn, atoms_list, format ="extxyz" , append=True ) pert_num cell_pert_fraction atom_pert_distance atom_pert_style atom_pert_prob
势函数使用 1.4. Install LAMMPS — DeePMD-kit documentation
1.2. Install from source code — DeePMD-kit documentation
DeePMD 与 LAMMPS 的接口
先安装 DeePMD-kit 的 C++ 接口
1 2 3 4 5 cd $deepmd_source_dir /sourcemkdir buildcd buildcmake -DUSE_TF_PYTHON_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=$deepmd_root ..
1 2 3 4 5 6 7 8 9 cd $deepmd_source_dir /source/buildmake lammps cp -r $deepmd_source_dir /source/build/USER-DEEPMD path_lammps/srcmake yes-extra-fix make yes-user-deepmd
1 2 pair_style deepmd graph.pb pair_coeff * *