deepmodeling / dpgen

The deep potential generator to generate a deep-learning based model of interatomic potential energy and force field
https://docs.deepmodeling.com/projects/dpgen/
GNU Lesser General Public License v3.0
304 stars 174 forks source link

When running dpgen, how can I add fparam after pair_style if I provide the lammps input file myself? #1608

Open lhyand opened 2 months ago

lhyand commented 2 months ago

Bug summary

During the training process, electron temperature is considered. Both numb_fparam and use_ele_temp are set to 1. The lammps input file pair_style automatically generated by dpgen contains the fparam keyword, but I want to provide the lammps input file myself. I added fparam to the pair_style in the input file I provided. I found that the fparam after pair_style in the lammps input file will be deleted during model_devi. The electron temperature is considered during dpkit training. If there is no fparam after pair_style, an error will be reported when running md. So how can I add fparam after pair_style on the premise of providing the lammps input file myself?

DP-GEN Version

0.10.6

Platform, Python Version, Remote Platform, etc

Ubuntu 20.04.5 LTS (in Bohrium) Python 3.10.6

Input Files, Running Commands, Error Log, etc.

This is an input file that I defined myself

units metal boundary p p p atom_style atomic neighbor 1.0 bin box tilt large if "${restart} > 0" then "read_restart dpgen.restart.*" else "read_data conf.lmp" change_box all triclinic mass 1 58.93 mass 2 51.99 mass 3 58.69

pair_style deepmd ../graph.000.pb ../graph.001.pb ../graph.002.pb ../graph.003.pb out_freq ${THERMO_FREQ} out_file model_devi.out fparam ${TEMP}

pair_style deepmd ../graph.000.pb ../graph.001.pb ../graph.002.pb ../graph.003.pb out_freq ${THERMO_FREQ} out_file model_devi.out fparam ${TEMP} pair_coeff thermo_style custom step temp pe ke etotal press vol pxx pyy pzz pxy pxz pyz lx ly lz xy xz yz thermo ${THERMO_FREQ} dump 1 all custom ${DUMP_FREQ} traj/*.lammpstrj id type x y z fx fy fz dump dpgen_dump restart 10000 dpgen.restart if "${restart} == 0" then "velocity all create ${TEMP} 709383" fix 1 all ${ENSEMBLE} temp ${TEMP} ${TEMP} 0.1 fix 2 all atom/swap ${MC_FREQ} 1 9999 ${TEMP} ke yes types 1 2 semi-grand no fix 3 all atom/swap ${MC_FREQ} 1 9999 ${TEMP} ke yes types 1 3 semi-grand no fix 4 all atom/swap ${MC_FREQ} 1 9999 ${TEMP} ke yes types 2 3 semi-grand no timestep 0.001000 run ${NSTEPS} upto

This is the input file used in the model_devi process, and we can see that the fparam keyword has been removed

units metal boundary p p p atom_style atomic neighbor 1.0 bin box tilt large if "${restart} > 0" then "read_restart dpgen.restart.*" else "read_data conf.lmp" change_box all triclinic mass 1 58.93 mass 2 51.99 mass 3 58.69

pair_style deepmd ../graph.000.pb ../graph.001.pb ../graph.002.pb ../graph.003.pb out_freq 10 out_file model_devi.out fparam 200

pair_style deepmd ../graph.000.pb ../graph.001.pb ../graph.002.pb ../graph.003.pb out_freq 10 out_file model_devi.out pair_coeff thermo_style custom step temp pe ke etotal press vol pxx pyy pzz pxy pxz pyz lx ly lz xy xz yz thermo 10 dump 1 all custom 10 traj/.lammpstrj id type x y z fx fy fz dump dpgen_dump all custom 10 traj/.lammpstrj id type x y z restart 10000 dpgen.restart if "${restart} == 0" then "velocity all create 200 709383" fix 1 all nvt temp 200 200 0.1 fix 2 all atom/swap 10 1 9999 200 ke yes types 1 2 semi-grand no fix 3 all atom/swap 10 1 9999 200 ke yes types 1 3 semi-grand no fix 4 all atom/swap 10 1 9999 200 ke yes types 2 3 semi-grand no timestep 0.001000 run 200 upto

The following is the error message

ERROR on proc 0: DeePMD-kit C API Error: the dim of frame parameter provided is not consistent with what the model uses (/home/conda/feedstock_root/build_artifacts/libdeepmd_1698439191117/work/source/lmp/pair_deepmd.cpp:670) Last command: run 200 upto application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0 [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=1 : system msg for write_line failure : Bad file descriptor

Running commands

nohup dpgen run param.json machine.json > log.run 2>&1 &

Steps to Reproduce

nohup dpgen run param.json machine.json > log.run 2>&1 &

Further Information, Files, and Links

No response

njzjz commented 2 months ago

@Yi-FanLi Does PIMD also suffer from the same problem? Or is it never supported for rev_mat?

Yi-FanLi commented 2 months ago

@Yi-FanLi Does PIMD also suffer from the same problem? Or is it never supported for rev_mat?

No, PIMD does not suffer from this problem. PIMD is not involved with rev_mat. The implementation of PIMD support in DP-GEN is based on detecting "nbead" in param.json and replacing "fix npt" with "fix pimd/langevin" when generating the LAMMPS input file: https://github.com/deepmodeling/dpgen/blob/47a23b393c6e071bc588a2171780f09863741d3a/dpgen/generator/lib/lammps.py#L193-L200

lhyand commented 2 months ago

What I do now is to set use_ele_temp and numb_fparam to 1. The input file of lammps is generated by dpgen. The command for running lammps in machine.json is modified to: "command": "sed -i \"33a\ fix 2 all atom/swap 10 1 9999 \${TEMP} ke yes types 1 2 semi-grand no\" input.lammps && sed -i \"34a\ fix 3 all atom/swap 10 1 9999 \${TEMP} ke yes types 1 3 semi-grand no\" input.lammps && sed -i \"35a\fix 4 all atom/swap 10 1 9999 \${TEMP} ke yes types 2 3 semi-grand no\" input.lammps && lmp -in input.lammps".This way I can achieve my goal.