Skip to content

[BUG] Multiple output per timestep in model_devi.out when using fix atom/swap in LAMMPS #1756

Open
@MoseyQAQ

Description

@MoseyQAQ

Bug summary

Dear community,

I am using DPGEN to develop a DP model for a solid solution. To achieve the atom swap, I used a customized LAMMPS input template and included fix atom/swap.

When I checked the model_devi.out file:

#       step         max_devi_v         min_devi_v         avg_devi_v         max_devi_f         min_devi_f         avg_devi_f
           0       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
          10       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
          10       2.853282e-03       2.290834e-04       1.438745e-03       1.931051e-02       5.121428e-03       1.125389e-02
          10       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
          20       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
          20       2.384408e-03       1.554695e-04       1.302835e-03       1.741560e-02       5.397162e-03       1.095465e-02
          20       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
          30       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
          30       2.401005e-03       2.546674e-04       1.147003e-03       1.910507e-02       5.154845e-03       1.134784e-02
          30       2.698328e-03       1.933651e-04       1.424635e-03       1.607140e-02       5.474476e-03       1.079843e-02
           ....

As you could see, at each time step, model_devi.out prints three times, and the values are not the same.

After checking the source code of fix atom/swap, which is:
https://github.com/lammps/lammps/blob/2744647c75f065f259845c3636182600c9ce00c9/src/MC/fix_atom_swap.cpp#L351-L362

...
  energy_stored = energy_full();

  // attempt Ncycle atom swaps

  int nsuccess = 0;
  update_swap_atoms_list();
  for (int i = 0; i < ncycles; i++) nsuccess += attempt_swap();
  }
...

The energy_full() and attempt_swap() will call DP to compute the potential energy before and after the atom swap, each compute will trigger DP to update the model_devi.out. That's probably why model_devi.out contains information for the same time step multiple times.

I wonder at such a situation, can DPGEN select the right configuration, since it seems that dpgen reads the output from the model_devi.out.

DP-GEN Version

0.12.1

Platform, Python Version, Remote Platform, etc

Linux
Python 3.12.4

Input Files, Running Commands, Error Log, etc.

All necessary files to reproduce it, including the original input, output, and DP models:
issue.zip

Steps to Reproduce

Download the attached files and run LAMMPS using the given input.

Further Information, Files, and Links

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions