[lammps-users] write data after bond/react

Dear lammps user,

Writing data after fix bond/react will add teo extra sections in the data file. Is there any way to delete these lines inside lamps? It will cause errors when I wan to open the data file with these extra lines with VMD and OVITO

bond_react_props_internal

1 0 0
2 0 0

bond_react_stabilization_internal

1 1
2 1
3 1

Hi Musa
Perhaps there is a way to do what you want from within LAMMPS. If so, somebody please post a follow-up message. If you have moltemplate installed, you could try using the"exctract_lammps_data.py" script that comes included with it. You can use it to extract only the portions of the data file you want and then stitch them together again using “cat” (see below). Hopefully this will strip out the text you don’t want:

extract_lammps_data.py Header < oldfile > header.txt
extract_lammps_data.py Masses < oldfile > masses.txt

extract_lammps_data.py Atoms < oldfile > atoms.txt
extract_lammps_data.py Bonds < oldfile > bonds.txt
extract_lammps_data.py Angles < oldfile > angles.txt
extract_lammps_data.py Dihedrals < oldfile > dihedrals.txt
extract_lammps_data.py Impropers < oldfile > impropers.txt

cat header.txt > newfile
echo “” >> newfile
echo “Masses” >> newfile
echo “” >> newfile
cat masses.txt >> newfile

echo “” >> newfile
echo “Atoms” >> newfile
echo “” >> newfile
cat atoms.txt >> newfile

echo “” >> newfile
echo “Bonds” >> newfile
echo “” >> newfile
cat bonds.txt >> newfile

echo “” >> newfile
echo “Angles” >> newfile
echo “” >> newfile
cat angles.txt >> newfile

echo “” >> newfile
echo “Dihedrals” >> newfile
echo “” >> newfile
cat dihedrals.txt >> newfile

echo “” >> newfile
echo “Impropers” >> newfile
echo “” >> newfile
cat impropers.txt >> newfile

(If you have “Coeff” sections in your data file, it gets more complicated, because I haven’t tried using “extract_lammps_data.py” on multi-word sections like “Pair Coeffs”. But it probably works if you put quotes around the two words.)

I have never tried running it on a data file created with fix bond/react, so this might not work.

(If this fails, you can always use a text editor, but I guess that is not the solution you want.)

I attempted to type all this on my phone, so I probably made mistakes. I hope this is helpful to somebody.

Cheers

Andrew

You can use the ‘nofix’ option of write_data to not include those sections.

Thanks Jacob,

Thanks nofix works. But what should I do if I wanted to use “run every” command to make movie as you suggested earlier? Nofix does not work with run every.

The ‘nofix’ option to “write_data” should work just the same with “run every.” Are you getting an error message?

Thanks, Jacob, yes it works, I previously did a stupid mistake but with below command it works now:

run 2000 every 1 “write_data crosslinked.data.* nofix”