How to build a sphere pack using a expression for the radius

Asked by Amauri Aguiar de Freitas

Hello every one,

I am trying to reproduce the article “A spherical discrete element model: calibration procedure and incremental response”, and in this paper the autors used an expression to Rw, as indicated below, to determine the radius of every sphere in the sphere pack. My question is: How can I construct a sphere pack using an expression like this to determine the radius of every sphere?

Rw=Rmin+(Rmax-Rmin)(-0.15 * ln(1-rand[0;1]))^(1/0.75)

Regards,
Amauri

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
Best Jan Stránský (honzik) said :
#1

Hi Amauri,

please define more "a sphere pack". Do you mean loose packing like SpherePack.makeCloud would generate? I assume so for the rest of the answer

you can use "Python reimplementation" of SpherePack.makeCloud [1]:

###
import random
from yade import pack

def myMakeCloud(mn,mx,rMin,rMax,num,maxTry=1000,seed=0):
   random.seed(seed)
   mn = Vector3(mn)
   mx = Vector3(mx)
   size = mx-mn
   rnd = random.random
   ret = []
   for i in xrange(num):
      r = rMin + (rMax-rMin)*pow(-0.15 * log(1-rnd()), 1./0.75)
      for t in xrange(maxTry):
         c = Vector3([mn[axis] + r + (size[axis]-2*r)*rnd() for axis in (0,1,2)])
         packSize = len(ret)
         overlap = False
         for pc,pr in ret:
            if pow(pr+r,2) >= (pc-c).squaredNorm():
               overlap = True
               break
         if not overlap:
            ret.append((c,r))
            break
      if t == maxTry:
         print "WRNING: Exceeded {} tries to insert non-overlapping sphere to packing. Only {} spheres were added, although you requested {}.".format(maxTry,i,num)
   return pack.SpherePack(ret)

sp = myMakeCloud((0,0,0),(10,10,10),1,2,100)
sp.toSimulation()
O.step()
###

cheers
Jan

[1] https://github.com/yade/trunk/blob/master/pkg/dem/SpherePack.cpp#L86

Revision history for this message
Amauri Aguiar de Freitas (amaurifreitas) said :
#3

Thanks Jan Stránský, that solved my question.