Question #667571 on Yade changed: https://answers.launchpad.net/yade/+question/667571
Status: Open => Answered Jan Stránský proposed the following answer: 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 -- You received this question notification because your team yade-users is an answer contact for Yade. _______________________________________________ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp