srtee / lammps-USER-CONP2

updated constant potential plugin for LAMMPS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix can crash when atom IDs are non-contiguous

srtee opened this issue · comments

This fix can crash during initialization if atom IDs are non-contiguous.

Specifically, suppose a simulation box originally has N particles, with the electrodes listed as the last particles ID-wise (largest IDs). Now suppose a delete_atoms command removes some particles so that the simulation box now only has M (<N) particles, but some electrode particles still have IDs larger than M.

Then, tag2eleall will often be assigned as a list of ints of length M (fix_conp.cpp: 417), but fix_conp will attempt to write past that bound during initialization (fix_conp.cpp: 507, tag2eleall[eleall2tag[i]] = i).

In the interim, scripts can avoid this bug simply by using reset_atom_ids as necessary. In the long run, clearly the "electrode-tag" should be reimplemented as a per-atom array using LAMMPS's atom class callbacks.