[SciPy-User] Distance matrix with periodic boundary conditions
Wed Nov 17 11:17:59 CST 2010
I've run into a similar experience before - I wasn't able to find
another scipy module that did the job so I ended up doing a somewhat
crude implementation of my own for doing post-processing of molecular
dynamics simulation data.
It is a variation on a cell-linked-list decomposition method that is
commonly seen in molecular simulation and relies on the particle
interaction being cutoff at some small or intermediate value relative
to the total size of the domain.
If it might work for you I can post some of the key parts of the code,
or send you a file or two offlist. Let me know.
On Wed, Nov 17, 2010 at 10:12 AM, Ramon Crehuet <firstname.lastname@example.org> wrote:
> Dear all,
> I am trying to analyze some simulation results calculated with periodic
> boundary conditions (PBC). Calculating the distance matrix between
> particles is time consuming with python, and I wanted to use
> scipy.spatial.distance.pdist. However I need to impose PBC, which means
> that the vector between two particles has to be calculated like this:
> r = r2 - r1
> r = r - box*np.round(r/box)
> where r1 and r2 are arrays with x,y,z positions of each pair of
> particles. That needs to be corrected before calculating the distance
> (the module of that vector).
> I implemented the distance matrix calculation with cython and got
> considerable speed-ups, but I wonder if I am reinventing the wheel and
> this is already (better) implemented in some scipy module.
> SciPy-User mailing list
More information about the SciPy-User