mbuild
mbuild copied to clipboard
Better representations of compound hierarchy
Some methods for interrogating other features of the hierarchy would be useful. The hierarchy behaves well, but we only have a few methods (mycompound.children
, .parent
.particles
, maybe others?) for poking around. For example, one may wish to measure a compound's vertical height, i.e. "how many children down do I need to go until I reach particles?"
Sometimes I want to just "look" at my compound. Producing a full visualization is not tractable due to the size of most systems but it would be useful for smaller components, i.e. single molecules or looking at an individual monomer in a polymer. These sorts of methods and attributes would mostly help with debugging but I think they would be valuable additions.
Trevor had worked on a "visualize the compound hierarchy" feature a while back but I can't find it on his fork: https://github.com/Jonestj1/mbuild
In general, it should be very possible to create a to_networkx
for the hierarchy as opposed to the bond graph. Then you have all of the tools to interrogate the graph at your finger tips.
I think I found it. It's old but enough to draw something from.
https://github.com/mosdef-hub/mbuild/blob/e24fe1405fe09fc45cd2e05abb6c6311012c077e/mbuild/compound.py#L194
This is still an important issue that should be addressed. Most work has been focused on the total bond graph, but not the hierarchy. It should be simple enough to iterate through the children of a compound and create a node structure similar to this
Solved by #1096