-
Notifications
You must be signed in to change notification settings - Fork 296
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
Enable EMST in all colvars using makeWhole() #1068
base: master
Are you sure you want to change the base?
Conversation
i think is a very useful feature |
I agree! |
const auto & tree_indexes=tree->getTreeIndexes(); | ||
const auto & root_indexes=tree->getRootIndexes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have read the Tree class wrong:
It appears to me that Tree::getTreeIndexes();
and Tree::getRootIndexes();
are getters that return a copy to the respective internal variable in the tree.
It seems to me that that const auto&
creates a reference to the copy that is returned by the getter
I think this example shows better what I am saying.
It may be a good idea to the getters return a const reference
, so you will have a read-only accessor without any copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I've already seen this (the original version was returning by copy as well) and I agree it should be fixed. Thanks!
Regarding this:
maybe it is worth to think about the on-the-fly version. This would require to rewrite the EMST in a more general version that:
Syntax could be something like:
And I think this can be super useful for visualization, so I want to give it a try. In the end, this is order |
Description
This is changing how PBCs are dealt with in a lot of CVs, so please @maxbonomi @carlocamilloni @gtribello @Iximiel have a look if it makes sense
Current state
Currently, most CVs handle PBCs automatically to some extent. In many cases, the CV definition is not depending on periodic boundaries per se, but just requires molecules to be properly reconstructed before the CV is computed. This is achieved by calling the function
makeWhole
. This function makes a local copy of the coordinates whole by computing the distance between consecutive atoms in the list using PBCs.WHOLEMOLECULES is someway special, because in addition to this can use a minimum spanning tree computed on the reference structure provided by MOLINFO (see #681). In practice:
will reconstruct PBCs using the spanning tree. Here we specify the information twice:
Proposed change
I here implemented to possibility to use the spanning tree also in local reconstructions (e.g., in RMSD, GYRATION, etc). The logic is the following: for a given CV, if the last appearing MOLINFO in the input file is marked as WHOLE we use the spanning tree. Otherwise we use the ordered reconstruction. With NOPBC, PBCs are always ignored.
For example:
For consistency, I did the same to
WHOLEMOLECULES
. This means that:EMST
flag inWHOLEMOLECULES
is not needed anymore: if the previousMOLINFO
is WHOLE, the tree will be used anyway.EMST
flag is allowed (for backward compatibility) and triggers an error if it's used when the previousMOLINFO
is notWHOLE
, as a sanity check.Closed issue
This PR addresses points 1 and 4 in #681. Given that point 2 is closed and point 3 was optional (and likely not a good idea, because it would be extremely expensive), I think this closes #681 .
Implementation
This required me to rewrite the Tree class so as to manage a representation of the tree where we store indexes rather than AtomNumbers. In pratice, I construct the indexes list, then I use it to construct the AtomNumbers list. This is only done during initialization.
Notice that a separate tree is build for each CV depending on the used atoms. So, in order to compute the end-to-end distance in a polymer it is necessary to use
WHOLEMOLECULES
!Target release
I would like my code to appear in release v2.10