Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lhyand opened this issue Jul 31, 2024 · 3 comments · Fixed by #1662
Labels
bug Something isn't working

Comments

@lhyand
Copy link

lhyand commented Jul 31, 2024

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

@lhyand lhyand added the bug Something isn't working label Jul 31, 2024
@njzjz
Copy link
Member

njzjz commented Aug 1, 2024

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

@Yi-FanLi
Copy link
Collaborator

Yi-FanLi commented Aug 3, 2024

@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:

if ensemble == "npt" or ensemble == "npt-i" or ensemble == "npt-iso":
ret += "fix 1 all pimd/langevin fmmode physical ensemble npt integrator obabo thermostat PILE_L ${ibead} temp ${TEMP} tau ${TAU_T} scale 1.0 barostat BZP iso ${PRES} taup ${TAU_P}\n"
elif ensemble == "npt-a" or ensemble == "npt-aniso":
ret += "fix 1 all pimd/langevin fmmode physical ensemble npt integrator obabo thermostat PILE_L ${ibead} temp ${TEMP} tau ${TAU_T} scale 1.0 barostat BZP aniso ${PRES} taup ${TAU_P}\n"
elif ensemble == "nvt":
ret += "fix 1 all pimd/langevin fmmode physical ensemble nvt integrator obabo thermostat PILE_L ${ibead} temp ${TEMP} tau ${TAU_T} scale 1.0\n"
elif ensemble == "nve":
ret += "fix 1 all pimd/langevin fmmode physical ensemble nve integrator obabo temp ${TEMP}\n"

@lhyand
Copy link
Author

lhyand commented Aug 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants