7
$\begingroup$

I sometimes need to remove atoms from LAMMPS datafiles by hand, removing each row that corresponds to an atomID I want to remove, then decrementing the total atom count. This causes the atom IDs to no longer be contiguous in the file.

This is valid in the LAMMPS datafile specification but it causes issues for certain commands, for instance the velocity command:

velocity all create 0.01 4928459 dist gaussian
ERROR: Atom IDs must be consecutive for velocity create loop all (src/velocity.cpp:270)

Being okay with atomIDs being remapped, is there a quick way to make the atom IDs of a lammps datafile contiguous?

$\endgroup$
1
  • $\begingroup$ I must assume that somehow few atoms are not there, you can apply velocity by creating a group of existing atoms and apply velocity to them instead of applying velocity to keyword all. you can check lammps manual to create group $\endgroup$ May 6, 2021 at 16:48

3 Answers 3

4
$\begingroup$

Resetting the atom IDs with the reset_atom_ids command can help with that. You can read more about it here.

For the older version of LAMMPS, you may try reset_ids instead.

$\endgroup$
1
  • $\begingroup$ +1 and welcome to our new community! Thank you very much for contributing your answer here, and we hope to see much more of you in the future!!! Out of curiosity, how did you find us? $\endgroup$ Aug 24, 2021 at 2:17
3
$\begingroup$

To specifically solve the issue with the velocity command, you can use a different loop style. Now, you're using the style all, which requires consecutive atom ids. Other styles, like local and geom don't but there are reasons why they aren't the default. It is explained in the LAMMPS manual.

Perhaps other aspects of the simulation also require consecutive ids, but you can at least work around that particular error.

$\endgroup$
2
$\begingroup$

If you are not concerned with atomIDs being arbitrarily remapped, then you can use a molecule editor like Ovito to import the LAMMPS data file, and then re-export it as a format that doesn't store atomIDs, like the XYZ format. If you then re-import it, and re-export it as LAMMPS datafile, ovito will have to generate the atomIDs and will ensure that they are contiguous.

$\endgroup$
3
  • $\begingroup$ If you will self-answer in the same minute, please make it a community wiki next time. $\endgroup$ May 6, 2021 at 19:14
  • $\begingroup$ @NikeDattani apologies, I'll do that from now on $\endgroup$
    – geo
    May 7, 2021 at 14:13
  • 1
    $\begingroup$ @geo I'll leave it up to you if want to take Nike's suggestion for this post, but you can convert to community wiki at any time by editing your post. Just be aware that 1. you won't earn any rep from additional upvotes on your answer 2. it requires a mod to convert a question back from community wiki. $\endgroup$
    – Tyberius
    May 7, 2021 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .