To delete some angles via topotools

Dear LAMMPS USERS,

I did make a model that consists of a box (SPC/E water molecules inside a two carbon atom walls ) connected to a carbon atom pore. I used the “topotools” to convert my PDB data to LAMMPS and also I have used the “topo guessangles” command to show the angles. Please take a look at the data file obtained by topotools which added in the end of this email. I just want to consider H-O-H angles and neglect the C-C-C angles.

Could anybody tell me how to delete some angles through topotools?

Here is a part of my data file obtained by topotools

LAMMPS data file. CGCMM style. atom_style full generated by VMD/TopoTools v1.2 on Tue Jan 27 11:10:34 KST 2015
3372 atoms
4467 bonds
28243 angles
0 dihedrals
0 impropers
3 atom types
1 bond types
2 angle types
0 dihedral types
0 improper types
0.065500 30.065500 xlo xhi
0.000000 0.000000 ylo yhi
0.000000 0.000000 zlo zhi

Pair Coeffs

this is a VMD question. please post it to the VMD mailing list, where
it belongs. thanks.

LAMMPS data files are simple text files. You an use a text editor to
extract the Angles section. (Or use "extract_lammps_data.py").

Then throw away lines if the angle-type (2nd column) is not the type
you want. (You can do that in many ways, for example using awk or a
spreadsheet program, or your own script. The example below uses awk.)

Finally update the number of angles in the header at the top of the data file.

############# EXAMPLE #############
# You can cut and paste this text into a (bash) terminal.
# Suppose your old data file is named "old_file.data".
# I assume you want to delete angles of type 1.
# (If not change "1" to "2" in the awk command below.)

extract_lammps_data.py Angles < old_file.data > old_angles.txt
awk '{if ($2!=1) print $0}' < old_angles.txt > new_angles.txt

extract_lammps_data.py -n Angles < old_file.data > temp_file.data
echo "" >> temp_file.data
echo "Angles" >> temp_file.data
echo "" >> new_file.data
cat new_angles.txt >> temp_file.data

# Almost done...
# Count the number of remaining angles. (One way is using
# "wc" to count the number of lines in the "new_angles.txt" file):

NUM_ANGLES=`wc -l new_angles.txt`

# ...and replace the line at the beginning with the correct angle count:

awk -v num_angles=$NUM_ANGLES \
  '{if ((NF==2) && ($2=="angles"))
     print num_angles" angles";
   else
     print $0;}' < temp_file.data > new_file.data

docs_extract_lammps_data.txt (2.04 KB)

extract_lammps_data.py (4.25 KB)

LAMMPS data files are simple text files. You an use a text editor to
extract the Angles section. (Or use "extract_lammps_data.py").

[...]

##########################

Awk, grep, sed, cut, paste, wc...
...all useful things to know

even simpler would be to read the topotools documentation and create
the topology right as needed. most topotools commands can be
restricted to a subset of atoms. but as i mentioned before, this is a
topic i am willing to discuss on the VMD mailing list, where it
belongs.

axel.

Minor correction and explanation: to follow

LAMMPS data files are simple text files. You an use a text editor to
extract the Angles section. (Or use "extract_lammps_data.py").

Then throw away lines if the angle-type (2nd column) is not the type
you want. (You can do that in many ways, for example using awk or a
spreadsheet program, or your own script. The example below uses awk.)

Finally update the number of angles in the header at the top of the data file.

############# EXAMPLE #############
# You can cut and paste this text into a (bash) terminal.
# Suppose your old data file is named "old_file.data".
# I assume you want to delete angles of type 1.
# (If not change "1" to "2" in the awk command below.)

extract_lammps_data.py Angles < old_file.data > old_angles.txt
awk '{if ($2!=1) print $0}' < old_angles.txt > new_angles.txt

extract_lammps_data.py -n Angles < old_file.data > temp_file.data

The lines above, extracted the "Angles" section of the data file, and
saved it as a seperate file ("new_angles.txt"). The remaining text is
saved in a temporary file ("temp_file.data").

We need to put the "Angles" section back in the "temp_file.data". It
does not matter where we put it as long as we preceed it with 3 lines:
(blank line)
Angles
(blank line)

echo "" >> temp_file.data
echo "Angles" >> temp_file.data
echo "" >> new_file.data (oops WRONG)

sorry, that should have been

echo "" >> temp_file.data

Then we append new list of angles to the end of "temp_file.data":

cat new_angles.txt >> temp_file.data

# Almost done...
# Count the number of remaining angles. (One way is using
# "wc" to count the number of lines in the "new_angles.txt" file):

NUM_ANGLES=`wc -l new_angles.txt`

# ...and replace the line at the beginning with the correct angle count:

awk -v num_angles=$NUM_ANGLES \
  '{if ((NF==2) && ($2=="angles"))
     print num_angles" angles";
   else
     print $0;}' < temp_file.data > new_file.data

##########################

I did not test all of this, but I think it works.
Hopefully, you get the idea.

Awk, grep, sed, cut, paste, wc...
...all useful things to know

Cheers
Andrew