Problem regarding fix atom/swap

Dear LAMMPS Community,

I am currently trying to perform a hybrid MD-MC simulation for a polydisperse LJ liquid. To achieve this, I am using the “sphere” atom type, allowing me to input the radius of the particles. The corresponding pair is computed using the pair_modify command, and for MD, I employ the pair_style lj/cut/sphere. Additionally, I use the fix atom/swap command for MC.

While the MD part works as expected, I encounter a segmentation fault when I introduce the fix atom/swap command. Unfortunately, I am not able to figure out the problem.

Your help on this matter would be greatly appreciated.

Below, I have attached a sample input file. I am using lammps August 2023 version.

log logfile

variable i equal 1

variable T equal 1.00
variable rho equal 1.3
variable seed3 equal (82367+$i*10000)

dimension 3
boundary p p p

units lj
atom_style sphere

read_data init_poly.dat

pair_style lj/cut/sphere 2.5

pair_coeff 1 1 1.0 2.5
pair_coeff 2 2 0.5 2.5
pair_modify mix arithmetic
pair_modify shift no

timestep 0.005

neighbor 0.3 bin
neigh_modify every 20 delay 0 check no

velocity all create T {seed3}

fix 2 all nvt temp $T $T 0.1

fix mc all atom/swap 1 1 ${seed3} 1.0 ke no types 1 2

run 10

unfix 2

unfix mc

The algorithm implemented by fix atom/swap requires per-atom-type masses and thus is not compatible with your system. You would have to reprogram parts of the algorithm in the fix source code to rescale the atom velocities by the square root of the ratio of their their individual masses instead of using the pre-computed per-atom-type ratios.

We will add a check so that the fix will print an error message instead of crashing with a segmentation fault.


Thank you for your prompt response. I will try to implement your suggestions in the source code, specifically in the fix_atom_swap.cpp file.

Good luck with that. If you are successful, please consider contributing your changes back to the LAMMPS repository so that others trying the same kind of studies can benefit from it. 3. Modifying & extending LAMMPS — LAMMPS documentation

Thanks a lot. I will give it a shot for my situation. If it works out and can be useful more widely, I will include the modified code.