Write the data.lammps only of a group ?

Hello Lammps users,

I need a clarification on the following.

Can we write the data of only a particular group of the total system?

usually, write_data command writes for the full system, can we specify the group keyword here? if so, how?

I searched in the lammps documentation, but could not get it from there.

Thanks for your time.

Hello Lammps users,

I need a clarification on the following.
Can we write the data of only a particular group of the total system?

no.

usually, write_data command writes for the full system, can we specify the
group keyword here? if so, how?

you cannot.

I searched in the lammps documentation, but could not get it from there.

that is the rule: if it is not mentioned in the documentation, then a
feature is not available.

axel.

As a work-around, you could write a one-time dump for your subsystem and then use some external script to convert this back into a valid data file.

… Or use the delete_atoms command to remove all unwanted data before writing the new data file.

Axel

Hi, Dr. Stefan Paquay, and Dr. Axel Kohlmayer,
Many thanks for your solutions.
Your ideas have made to think of one more way.
That is, take the full data file, read into VMD. Then select the groups as required, and then writepdb only to those groups.

Later, read those pdb s into VMD, use topotools, to create the data files.

But there is a drawback in this way, it won’t write velocities into data; and also, the atom numbers are reassigned (starts from 1, and goes on sequentially).

one of the best solutions are as you suggested before.

But in case, if we don’t worry about the numbering reassignment and don’t need velocities, then above mentioned method could be easier.

Thanks.

Regards,

Siva

If you have already defined a group (eg “do_want”), then an easier, elegant way to solve your problem would be to follow Axel’s suggestion, using something like:

group dont_want subtract all do_want
delete_atoms group dont_want
write_data new.data

That’s what I would do

-Andrew

P.S. Nevertheless, I can’t seem to pass up an opportunity to promote “moltemplate”…
…so if you have moltemplate installed, you try this:

ltemplify.py -atomtype “1 2 3” script.in file.data > new.lt

or

ltemplify.py -atomid “13 14 15 61*69” script.in file.data > new.lt

(You will have to include your input script, eg “script.in”)
Then run:

moltemplate.sh new.lt

This should generate a file named “new.data” (as well as “new.in.init”, “new.in.settings” containing all of the “pair_coeff”, “bond_coeff”, “angle_coeff”, … commands.) The “new.data” file will have only the atoms you selected, and they will be renumbered (along with the atom type numbers in your “pair_coeff”, “bond_coeff”, etc…). Broken bonds or angle interactions will be removed (without warning you).

Documentation is in appendix B1 of the moltemplate manual, and there’s an example here.

(Note: the version of moltemplate distributed with LAMMPS is now several years old. You can download the latest version here.)

(There may be elegant ways to do this using pizza.py as well.)

Cheers