title: Writing code to generate lattice in python
body: <p>Let's say I have <code>N</code> particles and I want to place them in a 3D cuboidal lattice. I want to create a numpy array of shape <code>(N,3)</code> with the 3D locations of each point as a row of the array. What is the most efficient way of doing this?</p>
  <p>If I have N particles, I would take the cube root of N, lets call it n. Taking the ceiling of n, I will make a lattice of size ceil(n)*ceil(n)*ceil(n) and start filling up the lattice with particles. Of course, since <code>(ceil(n))**3</code> is greater than <code>N</code>, I will have some empty spots, but that is fine.</p>
  <p>I could make a for loop and add some if statements, but I was wondering if there was a way to make this more efficient using iterative tools or something.</p>
  <p>Thank you in advance for any advice you have!</p>