CsPbI3
Preparation Work
Note
First, we create a working directory called CsPbI3. All subsequent operations are assumed to be in this directory by default.
Here, we take the cubic phase of \(CsPbI_3\) as an example to introduce the use of the entire automated training framework. We download the .cif file from Materials Project. Then we make the supercell of [3,3,2] in VESTA as the initial structure for subsequent training, with the file name CsPbI3.vasp. The supercell structure is as follows:
Cs1 Pb1 I3
1.0
18.8254261017 0.0000000000 0.0000000000
0.0000000000 18.8254261017 0.0000000000
0.0000000000 0.0000000000 12.5502843857
Cs Pb I
18 18 54
Direct
0.166666672 0.166666672 0.250000000
0.166666672 0.166666672 0.750000000
0.166666672 0.500000000 0.250000000
0.166666672 0.500000000 0.750000000
0.166666672 0.833333313 0.250000000
0.166666672 0.833333313 0.750000000
0.500000000 0.166666672 0.250000000
0.500000000 0.166666672 0.750000000
0.500000000 0.500000000 0.250000000
0.500000000 0.500000000 0.750000000
0.500000000 0.833333313 0.250000000
0.500000000 0.833333313 0.750000000
0.833333313 0.166666672 0.250000000
0.833333313 0.166666672 0.750000000
0.833333313 0.500000000 0.250000000
0.833333313 0.500000000 0.750000000
0.833333313 0.833333313 0.250000000
0.833333313 0.833333313 0.750000000
0.000000000 0.000000000 0.000000000
0.000000000 0.000000000 0.500000000
0.000000000 0.333333343 0.000000000
0.000000000 0.333333343 0.500000000
0.000000000 0.666666687 0.000000000
0.000000000 0.666666687 0.500000000
0.333333343 0.000000000 0.000000000
0.333333343 0.000000000 0.500000000
0.333333343 0.333333343 0.000000000
0.333333343 0.333333343 0.500000000
0.333333343 0.666666687 0.000000000
0.333333343 0.666666687 0.500000000
0.666666687 0.000000000 0.000000000
0.666666687 0.000000000 0.500000000
0.666666687 0.333333343 0.000000000
0.666666687 0.333333343 0.500000000
0.666666687 0.666666687 0.000000000
0.666666687 0.666666687 0.500000000
0.000000000 0.000000000 0.250000000
0.000000000 0.000000000 0.750000000
0.000000000 0.333333343 0.250000000
0.000000000 0.333333343 0.750000000
0.000000000 0.666666687 0.250000000
0.000000000 0.666666687 0.750000000
0.333333343 0.000000000 0.250000000
0.333333343 0.000000000 0.750000000
0.333333343 0.333333343 0.250000000
0.333333343 0.333333343 0.750000000
0.333333343 0.666666687 0.250000000
0.333333343 0.666666687 0.750000000
0.666666687 0.000000000 0.250000000
0.666666687 0.000000000 0.750000000
0.666666687 0.333333343 0.250000000
0.666666687 0.333333343 0.750000000
0.666666687 0.666666687 0.250000000
0.666666687 0.666666687 0.750000000
0.000000000 0.166666672 0.000000000
0.000000000 0.166666672 0.500000000
0.000000000 0.500000000 0.000000000
0.000000000 0.500000000 0.500000000
0.000000000 0.833333313 0.000000000
0.000000000 0.833333313 0.500000000
0.333333343 0.166666672 0.000000000
0.333333343 0.166666672 0.500000000
0.333333343 0.500000000 0.000000000
0.333333343 0.500000000 0.500000000
0.333333343 0.833333313 0.000000000
0.333333343 0.833333313 0.500000000
0.666666687 0.166666672 0.000000000
0.666666687 0.166666672 0.500000000
0.666666687 0.500000000 0.000000000
0.666666687 0.500000000 0.500000000
0.666666687 0.833333313 0.000000000
0.666666687 0.833333313 0.500000000
0.166666672 0.000000000 0.000000000
0.166666672 0.000000000 0.500000000
0.166666672 0.333333343 0.000000000
0.166666672 0.333333343 0.500000000
0.166666672 0.666666687 0.000000000
0.166666672 0.666666687 0.500000000
0.500000000 0.000000000 0.000000000
0.500000000 0.000000000 0.500000000
0.500000000 0.333333343 0.000000000
0.500000000 0.333333343 0.500000000
0.500000000 0.666666687 0.000000000
0.500000000 0.666666687 0.500000000
0.833333313 0.000000000 0.000000000
0.833333313 0.000000000 0.500000000
0.833333313 0.333333343 0.000000000
0.833333313 0.333333343 0.500000000
0.833333313 0.666666687 0.000000000
0.833333313 0.666666687 0.500000000
Generate Perturbation Training Set
We first generate 10000 perturbation training sets with 3% cell deformation and 0.2Å atomic perturbation.
Tip
Here, we choose to add -f parameter to avoid generating non-physical structures from perturbations, and it was filterd based on bond length.
NepTrain perturb CsPbI3.vasp -n 10000 -c 0.03 -d 0.2 -f
<!-- Output is as follows: -->
Current structure:Cs18Pb18I54 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
The script will output perturb.xyz. We then use select to extract 100 structures from the 10000 structures as the initial training set.
Note
You may adjust the -d parameter according to the output of selected structure, or directly use -d 0, but the selection may not be optimal
If there is no NEP potential, SOAP descriptors will be used by default. Considering the spacing of SOAP descriptors is relatively large, so you should adjust -d parameter.
NepTrain select perturb.xyz -max 100 -d 1
<!-- Output is as follows: -->
[2024-12-28 18:15:21.436949] -- Reading trajectory perturb.xyz
[2024-12-28 18:15:28.985300] -- The file base does not exist.
[2024-12-28 18:15:28.986175] -- The file ./nep.txt does not exist.
[2024-12-28 18:15:28.986671] -- An invalid path for nep.txt was provided, using SOAP descriptors instead.
[2024-12-28 18:15:29.454689] -- Start generating structure descriptor, please wait
[2024-12-28 18:16:18.169325] -- Starting to select points, please wait...
[2024-12-28 18:16:24.492264] -- Obtained 100 structures.
[2024-12-28 18:16:25.800733] -- The point selection distribution chart is saved to ./selected.png.
[2024-12-28 18:16:25.801237] -- The selected structures are saved to ./selected.xyz.
Then run the following command to finish the preparation!
mv selected.xyz train.xyz
<!-- This deletion is not necessary -->
rm selected_perturb.xyz.xyz perturb.xyz selected.png
Initialize the Task
Tip
All template files can be saved by yourself. And all template files can be saved independently. If a corresponding template file exists in the designated directory (the default being the working directory), the creation of a new template file will be skipped, and the existing template file will be used instead.
First, we use the following command to initialize
NepTrain init slurm
<!-- Output is as follows: -->
[2025-08-07 19:35:53] -- For existing files, we choose to skip; if you need to forcibly generate and overwrite, please use -f or --force.
[2025-08-07 19:35:53] -- Create the directory ./structure, please place the expanded structures that need to run MD into this folder!
[2025-08-07 19:35:53] -- The environment variable vasp is not set. If you have set the environment in the submission script, please ignore this warning.
[2025-08-07 19:35:53] -- The environment variable mpirun is not set. If you have set the environment in the submission script, please ignore this warning.
[2025-08-07 19:35:53] -- The environment variable nep is not set. If you have set the environment in the submission script, please ignore this warning.
[2025-08-07 19:35:53] -- The environment variable gpumd is not set. If you have set the environment in the submission script, please ignore this warning.
[2025-08-07 19:35:53] -- You need to check and modify the vasp_job and vasp.cpu_core in the job.yaml file.
[2025-08-07 19:35:53] -- You also need to check and modify the settings for GPUMD active learning in job.yaml!
[2025-08-07 19:35:53] -- Detected that there is no train.xyz in the current directory; please check the directory structure!
[2025-08-07 19:35:53] -- If there is a training set but the filename is not train.xyz, please unify the job.yaml.
[2025-08-07 19:35:53] -- Create run.in; you can modify the ensemble settings! Temperature and time will be modified by the program!
[2025-08-07 19:35:53] -- Initialization is complete. After checking the files, you can run `NepTrain train job.yaml` to proceed.
Move CsPbI3.vasp to the structure directory created by the program:
mv CsPbI3.vasp structure
Let’s take a look at the current directory:
├── job.yaml
├── run.in
├── structure/
│ └── CsPbI3.vasp
└── train.xyz
Modify MD Template [Optional]
The default run.in is for npt, and generally, only the ensemble needs to be modified, the program will automatically replace the temperature.
We are not making any changes here.
Modify NEP Training Parameters
By default, the program does not require the nep.in file to be provided. It will automatically generate the simplest nep.in based on the training set.
If you need to modify hyperparameters, simply place your own nep.in file in this directory(the default working directory or the directory specified for nep.in in the .yaml file).
Modify Task Details
In job.yaml we have explained each parameter through comments as much as possible. And most parameters do not need to be adjusted.
We will not explain each parameter in detail here, only showing how to modify according to your own system.
VASP Calculation Details
Tip
cpu_core should match the number of CPU(GPU) cores requested for VASP jobs on your cluster.
To accelerate single-point energy calculations, we set the number of tasks through vasp_job, and the program will divide the tasks according to this number.
This depends on your own computational resources.
In addition, all calculation details are specified through INCAR, and you can create your own INCAR and place it in this directory(the default working directory or the directory specified for nep.in in the .yaml file).
We also need to modify the k-points selection. Here we choose the kspacing form. After modification, it is as follows:
dft:
software: vasp #you can switch vasp or abacus
cpu_core: 1
kpoints_use_gamma: true #ASE defaults to using M-point k-mesh, but here we default to using the gamma-centered grid; this can be set to false.
incar_path: auto #A path should be passed in. If it is auto, the corresponding file name will be switched according to the software, such as INCAR or INPUT
use_k_stype: kspacing
#--ka
kpoints:
- 20 #a
- 20 #b
- 20 #c
kspacing: 0.2
Tip
Typically, a kspacing value of 0.2 is sufficient for common calculations. However, for metals, the k-point density needs to be increased. Usually, a kspacing value of 0.1 is much sufficient for metals.
Modify Active Learning Iteration Details
The current program’s number of iterations is determined by the time of active learning. We choose to enable bond length filtering. We set the MD temperature range to 0-300k, with iteration times of 10ps, 100ps, 500ps, and 1000ps.
Tip
step_timesdoes not require a progressive relationship, for example, it can be 10 100 100 500 500 this kind of repetitive detection.
If no structures are extracted in the second 100ps, in addition to the extra time for one md, there will be no repeated training.
After modification, it is as follows:
gpumd:
#Time for iterative progressive learning in units of picoseconds.
#The first active learning is at 10ps, the second at 100ps, with a total of four active learning sessions.
step_times:
- 10
- 100
- 500
- 1000
#Each time active learning is performed, all structures in model_path will undergo molecular dynamics (MD) simulations at the following temperatures, followed by sampling.
temperature_every_step:
- 50
- 100
- 150
- 200
- 250
- 300
model_path: ./structure
run_in_path: ./run.in
An additional note on yaml syntax.
gpumd:
#Time for iterative progressive learning in units of picoseconds.
#The first active learning is at 10ps, the second at 100ps, with a total of four active learning sessions.
step_times:
- 10
- 100
- 500
- 1000
is equivalent to
gpumd:
#Time for iterative progressive learning in units of picoseconds.
#The first active learning is at 10ps, the second at 100ps, with a total of four active learning sessions.
step_times: [10, 100, 500, 1000]
Modify Sampling Details
We set a maximum of 80 structures to be selected each time. The minimum distance is 0.01
select:
#After completing this round of MD, a maximum of max_selected structures will be selected from all trajectories.
max_selected: 80
min_distance: 0.01 #Hyperparameters for farthest point sampling
The complete modified job.yaml is as follows
version: 2.0.0
dft_job: 10 #The number of tasks submitted when calculating single-point energy with DFT.
#所有任务提交的根目录
gpumd_split_job: temperature #Split gpumd tasks by temperature or structure
work_path: ./cache #Root directory for all task submissions.
current_job: nep #If the current_job has three states: nep, gpumd, dft, and if train.xyz has not been calculated, set it to vasp; otherwise, directly set it to use nep to train the potential function, or use gpumd.
generation: 1 #Marking resume tasks.
init_train_xyz: ./train.xyz #Initial training set; if not calculated, set current_job to vasp.
init_nep_txt: ./nep.txt #If current_job is set to gpumd, a potential function must be provided; otherwise, it can be ignored.
nep:
#Does it support restarting? If true, the potential function for the next step will continue from this step for nep_restart_step steps.
#The program will automatically set lambda_1 to 0.
#If false, retrain from scratch every time.
nep_restart: true
nep_restart_step: 20000
#Optional; if you need to modify the number of steps, simply provide a file in the current path.
#If there is no such file, the number of steps will be automatically generated based on the training set.
nep_in_path: ./nep.in
#Optional
test_xyz_path: test.xyz
machine:
#https://docs.deepmodeling.com/projects/dpdispatcher/en/latest/context.html
context_type: LazyLocal
#https://docs.deepmodeling.com/projects/dpdispatcher/en/latest/batch.html
batch_type: Slurm
local_root: ./
remote_root: ~/neptrain/
remote_profile:
hostname: ''
username: ''
key_filename: ''
port: 22
resources:
number_node: 1
gpu_per_node: 1
queue_name: 8V100
group_size: 1
custom_flags:
- '#SBATCH --qos=normal'
- '#SBATCH --job-name=NepTrain-NEP'
prepend_script:
- module load gpumd/4.2.0
dft:
software: vasp #you can switch vasp or abacus
cpu_core: 1
kpoints_use_gamma: true #ASE defaults to using M-point k-mesh, but here we default to using the gamma-centered grid; this can be set to false.
incar_path: auto #A path should be passed in. If it is auto, the corresponding file name will be switched according to the software, such as INCAR or INPUT
use_k_stype: kspacing
#--ka
kpoints:
- 20 #a
- 20 #b
- 20 #c
kspacing: 0.2
machine:
context_type: LazyLocal
batch_type: Slurm
local_root: ./
remote_root: ~/neptrain/
remote_profile:
hostname: ''
username: ''
key_filename: ''
port: 22
resources:
number_node: 1
gpu_per_node: 1
queue_name: 8V100
group_size: 1
custom_flags:
- '#SBATCH --qos=normal'
- '#SBATCH --job-name=NepTrain-NEP'
prepend_script:
- module load vasp/6.4.2-nvhpc24.3-ompi5.0.7
gpumd:
#Time for iterative progressive learning in units of picoseconds.
#The first active learning is at 10ps, the second at 100ps, with a total of four active learning sessions.
step_times:
- 10
- 100
- 500
- 1000
#Each time active learning is performed, all structures in model_path will undergo molecular dynamics (MD) simulations at the following temperatures, followed by sampling.
temperature_every_step:
- 50
- 100
- 150
- 200
- 250
- 300
model_path: ./structure
run_in_path: ./run.in
machine:
context_type: LazyLocal
batch_type: Slurm
local_root: ./
remote_root: ~/neptrain/
remote_profile:
hostname: ''
username: ''
key_filename: ''
port: 22
resources:
number_node: 1
gpu_per_node: 1
queue_name: 8V100
group_size: 1
custom_flags:
- '#SBATCH --qos=normal'
- '#SBATCH --job-name=NepTrain-NEP'
prepend_script:
- module load gpumd/4.2.0
select:
#After completing this round of MD, a maximum of max_selected structures will be selected from all trajectories.
max_selected: 80
min_distance: 0.01 #Hyperparameters for farthest point sampling
filter: 0.6 #Passing a coefficient enables bond length detection, and bonds shorter than the sum of the covalent radii multiplied by the coefficient are considered unphysical structures.
machine:
context_type: LazyLocal
batch_type: Slurm
local_root: ./
remote_root: ~/neptrain/
remote_profile:
hostname: ''
username: ''
key_filename: ''
port: 22
resources:
#Select mainly uses CPU
number_node: 1
gpu_per_node: 1
queue_name: 8V100
group_size: 1
custom_flags:
- '#SBATCH --qos=normal'
- '#SBATCH --job-name=NepTrain-select'
prepend_script:
- source /opt/envs/anaconda3.env
- conda activate neptrain
limit:
force: 20 #Limit the force of the structure to between -force and force
Start Training
Execute the following command in the terminal of the login node
NepTrain train job.yaml
Run in the background
nohup NepTrain train job.yaml &