← Back to team overview

yade-users team mailing list archive

Re: [Question #294908]: Remove Spheres Randomicaly from Pack

 

Question #294908 on Yade changed:
https://answers.launchpad.net/yade/+question/294908

    Status: Open => Answered

velimier proposed the following answer:
Hi,
maybe you can randomly append spheres from packing but excluding certain number of spheres. 

from yade import pack
import random

sp = SpherePack()
sp = pack.regularOrtho(pack.inAlignedBox((0,0,0),(1,1,1)),radius=.05,gap=0)

n=350 #number of spheres to exclude

#randomly append spheres from packing
for i in range(0, len(sp)-n):
    b = sp[random.randint(0,len(sp)-1)]
    O.bodies.append(b)
    sp.remove(b)

Hope it suits your need,
Veljko

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.