mosdef-hub / mbuild

A hierarchical, component based molecule builder
https://mbuild.mosdef.org
Other
171 stars 79 forks source link

Performance loading from `.json` file #1162

Closed daico007 closed 6 months ago

daico007 commented 8 months ago

Bug summary I bumped into a performance issue when trying to load from a json file, which is quite bad for bigger/nested system. This is due to the bond_graph.compose step when adding each particle/children into the main compound. We need to add in some workaround to speed this process up.

Code to reproduce the behavior

Please include a code snippet that can be used to reproduce this bug.

import mbuild as mb#
eth = mb.load("CC", smiles=True)
eth.name = "Ethane"
eth_box = mb.packing.fill_box(
    compound=eth,
    n_compounds=1000,
    box=[5, 5, 5]
)
eth_box.name = "EthaneBox"
eth_box.save("eth_box1000.json", overwrite=True)

comp = mb.load("eth_box1000.json") # This will take a minute.