chemfiles icon indicating copy to clipboard operation
chemfiles copied to clipboard

A draft for read and write bond type for lammps data

Open Roy-Kid opened this issue 2 years ago • 2 comments

Dear @Luthaf and other developers,

According to the previous discussion #476 , I write an untested draft that read and write bond type from lammps data file. In this PR, I want to read and write bond/angle/dihedral data from lammps data and trajectory.

Since issue #462 is planning to support symbolic atom type, I choose std::string as the representation for bond type.

In the following code, I completely complied with the storage method of BondOrder. But here I want to initiate a discussion about whether to use bond type or even bond order as a member attribute of Bond, like type in Atom. I think the benefits are as follows: The form is tidier, and the bond information can be obtained directly by iterating topology.bonds

I hope you can review my code in your free time so that I can complete these features in the future~

Thanks a lot!

Roy-Kid avatar Jun 10 '23 04:06 Roy-Kid

@Luthaf Hi, sorry for bothering you. I re-wrote the code according to your suggestion. Now if it not find a custom bond type, it will degrade to integer bond type. However, the custom bond type to integer bond type is one-to-one mapping, but the add_bond API is per-bond type mapping. For example, if 1-2 and 1-3 both bond type 1, after I do add_bond(1, 2, order, "typeA") and add_bond(1, 3, order, "typeB"), the bond type in lammpsdata is both typeB. The later bond_type will override the former one. Should we use the rule: check if user defines a per-bond type, for example, add_bond(1, 2, order, "typeA"). If so, use "typeA" instead of the original type 1, if not, degrade it to type 1;

Roy-Kid avatar Jul 13 '23 07:07 Roy-Kid

However, the custom bond type to integer bond type is one-to-one mapping, but the add_bond API is per-bond type mapping. For example, if 1-2 and 1-3 both bond type 1, after I do add_bond(1, 2, order, "typeA") and add_bond(1, 3, order, "typeB"), the bond type in lammpsdata is both typeB.

I'm not sure I understand here. add_bond is the chemfiles function, right? In this case, why would add_bond(1, 2, order, "typeA") followed by add_bond(1, 3, order, "typeB") result in both bonds having typeB? I would expect that this results in two bonds (1-2 with typeA; and 1-3 with typeB). I'll re-read through the code as well to try to understand.

Luthaf avatar Aug 17 '23 10:08 Luthaf