6
$\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$ – pranav kumar May 6 at 16:48
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$
1
$\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$ – Nike Dattani May 6 at 19:14
  • $\begingroup$ @NikeDattani apologies, I'll do that from now on $\endgroup$ – geo May 7 at 14:13
  • $\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 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.