Open taidbui opened 1 year ago
Thanks again for the feedback and thorough reporting! I'm not surprised to see this; writing out a medium-to-large system with LAMMPS hits a trifecta of weakpoints of Interchange today
Interchange.to_lammps
is, to my knowledge, nearly un-used by our current user baseAll this being said, these are priorities and I do want to improve the LAMMPS writer and get Interchange working better and quicker with larger systems. It's just that each has been a lower priority than the other functionality that has kept me busy lately. I'd be happy to review a PR that implements these changes - otherwise I'll yoink them and add them myself at some point. The ugly loops-within-loops strategy you're running up against is an early implementation that I just haven't gotten around to changing in each writer (I think the GROMACS writer has these changes).
Description It takes too long to write LAMMPS data file for a medium system size.
I experienced this when I tried to convert a rather big system, with 174200 atoms, 165400 bonds, 296000 angles, 415400 dihedrals, and 14400 impropers. I looked into the lammps.py script within https://github.com/openforcefield/openff-interchange/blob/main/openff/interchange/interop/internal/lammps.py and believe that we can optimise the code.
For example in the _write_propers function, we can eliminate the need of using interchange.topology.propers as all information we need is already included in the interchange["ProperTorsions]. Also, using the nested for loop to look up the indices in both interchange['ProperTorsions'] and interchange.topology.propers objects significantly slows down the conversion.
So, I rewrote this and tested on a system with 17669 dihedrals using the following and found that the time required to write the dihedrals section in the lammps datafile is much shorter (Wall time: 212 ms vs 25.1 s)
I believe we can optimise the rest of the lammps.py code with a similar approach.
Thanks