Skip to main content
Version: 2026.03

NN Tutorial

NN Tutorial

This tutorial uses the MatPL [source root/example/Cu/nn_demo] example to demonstrate training, testing, LAMMPS simulation, and other operations for an NN model. The example directory is organized as follows.

Cu/nn_demo
├── nn_test.json
├── nn_train.json
├── train.job
└── nn_lmps/
├── in.lammps
├── lmp.config
├── forcefield.ff
└── runcpu.job
  • nn_train.json is the input file for training the NN force field.
  • nn_test.json is the input file for testing the NN force field.
  • train.job is an example Slurm job script for training.
  • The nn_lmps directory contains a LAMMPS MD example for the NN force field:
    • Force-field file: forcefield.ff
    • Initial structure: lmp.config
    • Control file: in.lammps
    • Example Slurm script: runcpu.job

train

Run the following command in the nn_demo directory to start training:

MatPL train nn_train.json
# Alternatively, update the environment variables and submit the training job through Slurm: sbatch train.job

Input file description The contents of nn_train.json are shown below. For descriptions of the NN parameters, see the NN Parameter Reference:

{   
"format":"pwmat/movement",
"train_data":["0_300_MOVEMENT", "1_500_MOVEMENT"],
"valid_data":["valid_movement"],
"model_type": "NN",
"atom_type":[29]
}

For details about the force-field directory generated after training, see model_record details.

test

MatPL test nn_test.json

The contents of test.json are shown below. For parameter descriptions, see the Parameter Reference.

{   
"format":"pwmat/movement",
"test_data":["0_300_MOVEMENT", "1_500_MOVEMENT"],
"model_type": "NN",
"model_load_file":"./model_record/nn_model.ckpt"
}

For details about the force-field directory generated after testing, see test_result details.

extract_ff

Extract the nn_model.ckpt file from the model_record directory after training:

# Extract the NN force-field model
MatPL extract_ff nn_model.ckpt

After extraction, a forcefield directory is created with the structure shown below. The other files in this directory contain descriptor-related information.

forcefield
├──fread_dfeat/
├──input/
├──output/
└──forcefield.ff

lammps MD

For installation and usage of the LAMMPS interface for NN models, see lammps-fortran.

Use the trained *.ff force-field file for the LAMMPS simulation. Add the following settings to the LAMMPS input file:

pair_style      matpl
pair_coeff * * 3 1 forcefield.ff 29

Here, 3 selects a force field generated by the NN model, 1 specifies that one force-field file is read, forcefield.ff is the file generated by MatPL, and 29 is the atomic number of copper.