deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.42k stars 486 forks source link

[BUG] Big difference in results of lattice between dp.predict and lammps.minimize #3183

Closed Saberve closed 4 months ago

Saberve commented 5 months ago

Bug summary

I trained the DP potentials of Mg, Li, and Al metals using DPGEN, but encountered some issues while verifying the lattice constants. I used DP potential+LAMMPS to calculate the lattice constants of three metals separately, and the results are shown in the figure. DP potential + Lammps cannot calculate the lattice constants of Li and Al.

DeePMD-kit Version

v2.0.1

TensorFlow Version

2.5.0

How did you download the software?

Offline packages

Input Files, Running Commands, Error Log, etc.

# input file of lammps
# Al
units           metal
boundary                p p p
atom_style      atomic

variable        i loop 20
variable        x equal 3+0.1*$i
#variable        x equal 3.4+0.01*$i

# build the model
lattice         fcc $x
region          box block 0 5 0 5 0 5
create_box      1 box
create_atoms    1 box

# specify the potential
pair_style      deepmd frozen_model.pb 
pair_coeff      * *
mass            1 26.981539

variable        n equal count(all)
variable                P equal pe/$n
#variable       v equal vol

timestep        0.005
thermo          10

# minimize the total energy

min_style       cg
minimize        1.0e-12 1.0e-12 1000 1000

print           "@ $x $P"

# loop
clear
next            i
jump            in.lat

Mg_Li_Al_lammps_lattice_energy

Partial log files of Al

LAMMPS (29 Oct 2020)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94)
  using 1 OpenMP thread(s) per MPI task

units           metal
boundary                p p p
atom_style      atomic

variable        i loop 20
variable        x equal 3+0.1*$i
variable        x equal 3+0.1*1
#variable        x equal 3.4+0.01*$i

# build the model
lattice         fcc $x
lattice         fcc 3.1
Lattice spacing in x,y,z = 3.1000000 3.1000000 3.1000000
region          box block 0 5 0 5 0 5
create_box      1 box
Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (15.500000 15.500000 15.500000)
  2 by 2 by 3 MPI processor grid
create_atoms    1 box
Created 500 atoms
  create_atoms CPU = 0.009 seconds

# specify the potential
pair_style      deepmd frozen_model.pb
pair_coeff      * *
mass            1 26.981539

variable        n equal count(all)
variable                P equal pe/$n
variable                P equal pe/500
#variable       v equal vol

timestep        0.005
thermo          10

# minimize the total energy

min_style       cg
minimize        1.0e-12 1.0e-12 1000 1000
WARNING: Using 'neigh_modify every 1 delay 0 check yes' setting during minimization (src/min.cpp:187)
Neighbor list info ...
  update every 1 steps, delay 0 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 10
  ghost atom cutoff = 10
  binsize = 5, bins = 4 4 4
  1 neighbor lists, perpetual/occasional/extra = 1 0 0
  (1) pair deepmd, perpetual
      attributes: , newton on
      pair build: full/bin/atomonly
      stencil: full/bin/3d
      bin: standard
Per MPI rank memory allocation (min/avg/max) = 4.154 | 4.160 | 4.163 Mbytes
Step Temp E_pair E_mol TotEng Press 
       0            0    143.79183            0    143.79183            0 
       1            0    143.79183            0    143.79183            0 
Loop time of 0.239301 on 12 procs for 1 steps with 500 atoms

68.7% CPU use with 12 MPI tasks x 1 OpenMP threads

Minimization stats:
  Stopping criterion = search direction is not downhill
  Energy initial, next-to-last, final = 
      143.791833629913   143.791833629913   143.791833629913
  Force two-norm initial, final = 0.0000000 0.0000000
  Force max component initial, final = 0.0000000 0.0000000
  Final line search alpha, max atom move = 0.0000000 0.0000000
  Iterations, force evaluations = 1 0

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.087465   | 0.1472     | 0.21319    |  11.5 | 61.51
Neigh   | 0          | 0          | 0          |   0.0 |  0.00
Comm    | 0.0037971  | 0.069288   | 0.1295     |  16.8 | 28.95
Output  | 0          | 0          | 0          |   0.0 |  0.00
Modify  | 0          | 0          | 0          |   0.0 |  0.00
Other   |            | 0.02282    |            |       |  9.53

Nlocal:        41.6667 ave          50 max          37 min
Histogram: 8 0 0 0 0 0 0 0 0 4
Nghost:        2604.33 ave        2717 max        2542 min
Histogram: 8 0 0 0 0 0 0 0 0 4
Neighs:        0.00000 ave           0 max           0 min
Histogram: 12 0 0 0 0 0 0 0 0 0

Total # of neighbors = 0
Ave neighs/atom = 0.0000000
Neighbor list builds = 0
Dangerous builds = 0

print           "@ $x $P"
@ 3.1 0.287583667259825

log file of Al log_Al.txt

But when I use dp.predict, the results are correct. Mg_Li_Al_dp_lattice_energy This question is similar to #2980 submitted by @PolyuWeldingSpock.

I also tried using lammps for relaxation under npt, and only the trajectory of Mg is correct, while Li and Al diffuse like gas.

I want to know why there is such a big difference in the results between dp. predict and lammps. Is the DP potential trained reliable? Why is only the trajectory of Mg correct. Is there any compatibility issue between DP potential and lammmps?

These files contain DP potential and log files Al.zip Li.zip Mg.zip

Steps to Reproduce

These are param.json files and log files used for training DP potentials. Al_trian_DP.zip Li_train_DP.zip Mg_train_DP.zip

Further Information, Files, and Links

No response

njzjz commented 5 months ago

predict does not do geometry optimization (I think it's clear at a glance). I don't under why you expect the energy is the same before and after the optimization .

Saberve commented 5 months ago

Sorry, i mistakenly thought that predict had the function of minimize. Regarding the second point, I do not expect the energy to remain consistent before and after optimization. Actually, this is exactly the problem that troubles me.

njzjz commented 4 months ago

In your model, Al is the second element. So when you create an Al atom, you should run pair_coeff * * Al (with a newer DeePMD-kit) or change the type of Al from 1 to 2.