# Creating dense random configuration in for molecular dynamics

I am creating a random configuration of particles for a molecular dynamics simulation, where I would like to guarantee a certain density. The strategy is as follows:

1. choose randomly the positions of the particles in $x$- and $y$-axis in square of the side length equal to $a$.

2. compute the distance between every pair of particles, using the periodic boundaries and minimum image conditions.

3. if the distance is less than $2^{1/6}\sigma$ then we should generate them once again to avoid overlaps.

My problem is that the program for the side length $a=10$, number of particles $n=100$ and the $\sigma=1$ diverges. The maximum $\sigma$ value for which the program gives an output is $0.74$. What is the reason?

Should I change the length side to a higher value? Or there is a other way to make the system more dense?

• Welcome to SciComp.SE! It is difficult to understand what the problem is, because you are skipping a lot of details: What do you mean by "more dense"? What are the "minimum image conditions"? What do you mean precisely by "the program diverges"? If at all possible, please use mathematical formulas in your description (using LaTeX notation). – Christian Clason Oct 8 '15 at 13:20

Now I realise this won't exactly satisfy your greater than $2^{1/6}\sigma$ criterion, but to satisfy that exactly will be unphysical and probably not what you want - and any sensible inter-atomic potential will mean there are few such separations. And if you are not using constant volume there are other problems, but I don't see why you can't use a recipe similar to the above.
The method you outline above is going to get very slow for high density systems, random numbers will just lead to too many atomic overlaps. Unfortunately I can't tell you at what reduced density this will start to cause problems in your set up, but in a related one I did many years ago anything for which ${N \over V}\sigma^3$ was greater than about 0.1 ran into problems if (and this is a big if, it's over 20 years ago) I remember correctly.