Search code examples
pythonphysicsmontecarlo

How to check overlap between to particle in Molecular Dynamics


Suppose I have 10 particles and each particle have three co-ordinates. I want to place them randomly such that distance between two particle will be always greater than some value(say 1). Any idea how to do that.


Solution

  • Since you don't mention that the particles are restricted to be in some volume, i.e. they can be anywhere in R^3, you could just introduce random numbers with

    n = 10
    pos = np.random.random(3*n).reshape(n,3)
    

    then calculate all the pairwise distances, see this question on how to efficiently do that, and then divide the whole array pos with the minimum distance (in case you use the value 1 to be the distance that no two particles should ever have less than).