-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LAMMPS DATA WRITER #3197
Comments
How about the following changes in LAMMPS.py (~ line 340)? I confirmed this works for bonds and angles for a simple water system. Commented lines are the lines included in the original code. def _write_bonds(self, bonds):
self.f.write('\n')
self.f.write('{}\n'.format(btype_sections[bonds.btype]))
self.f.write('\n')
bt = {}; t=0
for bond, i in zip(bonds, range(1, len(bonds)+1)):
if bond.type not in bt.keys():
t += 1
bt[bond.type] = t
self.f.write('{:d} {:d} '.format(i, bt[bond.type])+\
' '.join((bond.atoms.indices + 1).astype(str))+'\n')
# try:
# self.f.write('{:d} {:d} '.format(i, int(bond.type))+\
# ' '.join((bond.atoms.indices + 1).astype(str))+'\n')
# except TypeError:
# raise_from(TypeError('LAMMPS DATAWriter: Trying to write bond, '
# 'but bond type {} is not '
# 'numerical.'.format(bond.type)),
# None) |
The codes you provided have been rewritten in develop branch like this commit. (0d951a2#diff-b36aa1d8c19a92c6f8918f35d8c0ea354fd051e64b40e789452551e7bc0792ba , PR #2759) Also, I think some issues you provided have been solved in develop branch. You may try a development version. The method to build it is here. (https://userguide.mdanalysis.org/stable/contributing_code.html#build-mdanalysis-develop) |
Thanks, closing the issue. |
Hello, I'm trying to write a LAMMPS data file from a coordinate file. Consider a hydrogen gas,
Now let's make a data file with MDAnalysis. In order to make a LAMMPS data file, the atom types should be changed to positive integers.
However, I received the error from the LAMMPS.py (~line 431).
I think try, except should be added like this?
After adding try, except the above example should work. Now let's add a bond between the first hydrogen atom (index: 0) and second hydrogen atom (index: 1)!
I received the following error:
TypeError: LAMMPS DATAWriter: Trying to write bond, but bond type ('1', '1') is not numerical.
Trying to change the bond type like this is not allowed, with the error message saying AttributeError: can't set attribute
Thanks! Anyone can help me how to set a bond properly so that MDAnalysis can understand?
MDAnalysis 1.0.1
The text was updated successfully, but these errors were encountered: