New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #1536: implement periodic boundary conditions #1853
Conversation
Used `git apply` to apply relevant code for periodic boundary conditions from an ongoing research project. More cleanup necessary before upstream integration.
Adopt MinimumImageFractional and MinimumImageCartesian notation from Giovanni Garberoglio's implementation to replace the PBCDifference methods.
Avoid cluttering the Open Babel API, now that earlier research code has been refactored.
My previous iteration of periodic boundary conditions in OBMol added an extra copy of OBUnitCell* to the OBMol object, which was undesirable because (1) it clutters the API, and (2) leads to consistency problems. Now, there is only one copy of OBUnitCell* within the molecule's data.
These cases cover periodic boundaries and bond output for CIFs
Overall, this looks good. Obviously having a periodic UFF would be great.
|
Periodic boundary code is based on an old version of Open Babel, so I attempted to manually resolve the merge conflicts identified by Github (and ran diff against the current master and periodic-boundaries branches to verify).
Updated mmcifformat.cpp, mol.cpp, and CMakeLists.txt to resolve remaining merge conflicts.
Thank you for the feedback.
Making sure the UFF code is PBC-compatible sounds like a great feature. I will work on that after porting some more PBC features from my research code (such as different formats than CIF) to another PR. |
Okay, this looks okay if you can fix the new set of conflicts. Thanks for your patience - I think this will be really helpful. (I have some ideas about packing molecules using code like this and distance geometry / fragment placement.) |
Resolved remaining merge conflicts in mol.h and mol.cpp
Restored const to OBBond::GetLength. Avoided changes to existing API by dereferencing the `this` pointer as done by similar methods in the code.
Great! I resolved the merge conflicts and made sure not to change any of the const declarations in the existing API. Thanks for your help--I think this is good to go. |
@ghutchis I'm going to try and get the periodic UFF code ready as a separate PR next week. Do you think you'll have time to review this PR before then? |
The coordinates in the atom and bond fields did not match because wrapping had been applied inconsistently. This discrepancy confused a visualization program when parsing the bond symmetry flags.
I cleaned up the new merge conflicts and patched a bug I had found while using the code in my research. Those are all the changes I had planned for now, unless there are any requests. |
I'm going to commit this to master - hopefully the merge was successful. (We'll find out once it re-runs tests.) |
# Resolved Conflicts: # test/CMakeLists.txt
Looks good - I'm going to merge this. Many thanks! |
Just looking at this now in the context of the 3.0.1 release. I see a couple of TODOs in there based on memory allocation and pointers. Do you need/want feedback on these? |
Hi @baoilleach hope you are doing well. Thanks for your interest and offer to help. Is there any section of code in particular that would be good to clean up? From what I remember, most of the remaining TODOs were either in SetLength (and related methods) or file formatters that still calculated geometry from raw vector3's instead of atom/bond distances. I'd be happy to take another look and do some more cleanup, though making Open Babel fully PBC-aware wouldn't be something I could commit to right now. I'm not currently dogfooding the code for research, and implementing PBC the right way might require some larger architectural discussions to see if there's a way to more generically handle coordinates (perhaps an OBCoord class?). |
Currently tied up with the release. Let's talk later... |
This PR partially implements periodic boundary conditions in Open Babel by applying the minimum image convention and using
OBUnitCell
data. Some formats or existing code may not be expecting this behavior, so it is currently hidden behind anOB_PERIODIC_MOL
flag inOBMol
. See also openbabel/enhancement-proposals#6 for more discussion. Currently this PR is more of a minimum viable product, but over the summer I'm planning to submit additional PR's after combing through more of the codebase.This PR also adds an option to write bonding information to CIF output, including notation for bonds across periodic boundaries.
Before the code can be merged, there's a handful of details to take care of:
const
keyword onOBBond::GetLength()
without making a lot of other changes toOBMol::HasFlag
and some related methods.OBGenericData->Clone(NULL)
? Is it NULL, the OBMol, or something context-dependent?Special thanks to Giovanni Garberoglio for helpful discussion and his code in http://software-lisc.fbk.eu/obgmx/. I tried to combine the best parts of both of our PBC implementations in this PR.