[feature request] Feasibility of reading angle dihedral and improper
I would like to discuss the feasibility of reading angle, dihedral and improper from files(especially LAMMPS) in this issue. Currently, there is no straightforward way to read it. I have found that the Topology of chemfiles already has data structures for angle dihedral and improper, but no implementation and parser in LAMMPSData. However, adding this feature would be extremely beneficial for me when working with OPLS-AA or other all-atom forcefields.
I want to ask if is there a plan to add support for parse angle dihedral and improper. I can do this work in the next month or two.
So currently chemfiles guesses angles/dihedrals/impropers from the list of bonds, and do not have a way to set these to arbitrary values. You can get the guessed list from the Topology.
Do some LAMMPS file have list of angles/dihedrals/impropers that do not match the list of bonds? Could you share an example of such file?
Yes, that info can be inferred from Topology. But sometimes, I want to read the angle/dihedral type from Data file, and write a specific type in the data(e.g. 1 3 1 2 3 means angle_id angle_type i j k). Can I complete these tasks under the existing code?
Right, so you are taking about angle/... type, not the indexes of the atoms inside the angle/....
That's not handled by chemfiles in any way currently; instead when writing LAMMPS file, we guess the angle types from the types of the atoms, so all H-O-H angles will have the same type (for example H-H-H would be 1, H-O-H would be 2, …). LAMMPS also recently added support for type labels, i.e. using strings instead of numbers. This is something that I'd like to support in chemfiles (#462). Would it help you if the output of chemfiles looked like 1 H-O-H 1 2 3 instead of 1 3 1 2 3?
Adding the types inside chemfiles core data structures would require some large scale changes: tracking this information, determining a default when it is not present in the data format, exposing the data back to the user, but if this is the only solution we can think of what would be the best way to do it.
Yes. Mapping the type from its original presentation to a specific format is tedious work. What if we designate some keywords by using PropertyMap. Let's say we define a bond_properties = property_map(), and we can read bond_type as an int or a std::string and store it. When users need the type info, they and check the list_properties and find out what key is. When write the data to file, users must manually use the keyword and set the type. Namely, we do not unify the representation type internally, but let users control it themselves.
Before making large changes, I'd like to understand the exact use case you have. Do you want to read files and map angle types? Write files controlling the angle type? Something else?
I'm sorry to have confused you.
My request is read and write angle/... to LAMMPS Data file directly because I want to read and write their types. Before I start this issue, I don't know that chemfiles can gauss angle/... from the connection so I asked if we can parse angle/... directly from data file.
Now my question is if I can read types of angle/... and write the types to data file. What I already have is the topology connection between atoms and types for angle/... . The types either can be mapped integer, or a something like H-O-H.
So just to be clear: you have somewhere the list of angle types, and you want to give these to chemfiles when writing a LAMMPS file for a new structure, is this right?
Do you also want to extract angle types from an existing LAMMPS file using chemfiles? Or do you only need to write new files with chemfiles?
I need both extract angle/... types from LAMMPS file and write to new files.
Sorry again for my vague words
Ok, so here is a plan to implement this feature:
- Allow to store bonds/angles/... types in a Topology, and add functionality to retrieve it from C/Python/...
- When reading LAMMPS data files, fill in the bond/angle/... type
- When writing LAMMPS data files, if bond/angle/... types are defined, use them
- Look though other file formats, and have them also read/write the bond/angles/... types
I do not have time currently to implement this, but if someone wants to give it a go I should be able to review some PR!
Exactly what I thought! I will do this at the end of June because I'm stuck with some tedious work about graduation.