-
Notifications
You must be signed in to change notification settings - Fork 662
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
Single PBC distance calculation #1262
Comments
Hi. I've got a semi-working version of this at the moment. It's nowhere near pretty, but it'll hopefully work. Just one question - my knowledge of MD might be lacking here - when we are using a cubic box, we can just use the format:: if (periodic_x) then But is there any reason why this wouldn't work on the triclinic/orthrhombic box? Thanks. |
Hi Sang! So your version works some of the time, but not always! If the vector is Triclinic boxes are a bit tricky, but they can be expressed as a triangular matrix, so for the first dimension you have to alter all three dimensions to correct the first dimension, then alter 2 dimensions for the second etc. There's a link to the C code which we use for this below Don't worry about pretty code yet, we can fix that in review |
Hi Richard, Thanks for your prompt reply. So, just another query - when you are asking for a single molecule distance, rather than an array, I've identified what atom a (reference) and atom b (target) are using the 'bynum' (index in the gromacs/namd/etc .. file). I figured that a person concerned with this would rather want to identify the specific atom rather than molecule name, but I was just passing this by you and ask whether this would be acceptable? Or in the input of the function, would you need me to extensively give an option for which molecule/residue etc? Thanks Sang |
@Shtkddud123 the signature should be something like this: def distance(a, b):
return ???
a1 = u.atoms[0]
a2 = u.atoms[4]
separation = distance(a1.position, a2.position, u.dimensions) So you input 2 coordinates and a box, and it returns a distance |
Dear Richard, Ok, that seems to be pretty much what I had in mind. Ok, I'll get back to you. Thanks |
Hi, so, I've gotten a premilimary version, which seems to have some issues getting the right values out, which I presume is due to a bug somewhere in the code. The format goes: distance(atom a, atom b, box):
In any case, any feedback and suggestions for corrections would be much appreciated.
|
So, you should be presenting this code as a pull-request, on which it is much easier for everyone to comment. It doesn't matter if it's an initial non-working version. @orbeckst gave you a brief summary on how to accomplish this; we can guide you through it if you need help (but please keep that discussion on the mailing list, not this issue's conversation). On your code: I can already see a problem, in that your choice of passing atom numbers will be somewhat undefined because the function doesn't know on which Universe to look for them (in other words, Afterwards I'd seriously consider looking into using numpy for the fixing of PBC. It can make your code much faster, more compact, and would bring it in line with the rest of the MDAnalysis approach. I don't have time now for more details on how this should be done, but do give it a try. |
Hi, I am not sure whether this is still a open issue or a closed one. I see one code in the issue discussion but didn's see any PR. I wish to take up this issue and resolve it. I would need some direction though. Can anyone help me in this regard? |
Hi everyone, is there a simple way to compute distances taking into account PBC in 1-2 dimensions only? As far as I understand, the current implementation only allows for either no PBC or PBC in all 3 dimensions. Thanks, |
@dpadula85 may I ask you to raise this query in the mailing list please (rather than a closed issue)? Should you wish to raise this as a feature request, then a new issue can be raised a as feature request too (unless such a pre-existing feature request already exists). |
Originally started in #1188 , there's currently not a way to calculate a single pairwise distance, with PBC taken into account. (For many distances there's
lib.distances.distance_array
)We need:
MDAnalysis.lib.distances.distance(a, b, [box])
- which calculates distance betweena
andb
box
can be either an orthogonal or triclinic boxMDAnalysis.lib.distances.minimum_image(vector, box)
which takes a vector and an orthogonal or triclinic box, and returns the vector with periodic boundary conditions appliedMDAnalysis.lib.mdamath.angle
also be able to use theminimum_image
functionFor now, this can just use a Python (numpy) implementation
The text was updated successfully, but these errors were encountered: