yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #21431
Re: [Question #686692]: Create a pack in which the cylindrical particles and spherical particles are randomly distributed.
Question #686692 on Yade changed:
https://answers.launchpad.net/yade/+question/686692
Status: Open => Answered
Jan Stránský proposed the following answer:
a MWE:
#########
def randomOrientation(): # most likely not very well random, but for this example it is ok
from random import random as r
return Quaternion((r(),r(),r()),2*pi*r())
# create loose spherical packing using makeCloud
sp = yade.pack.SpherePack()
mi,ma = (0,0,0),(20,20,20)
nCyls,nSphs = 40,30
sp.makeCloud(mi,ma,rMean=2,rRelFuzz=.5,num=nCyls) # makeCloud for cylinders
sp.makeCloud(mi,ma,rMean=1,rRelFuzz=.5,num=nSphs) # makeCloud for spheres
for i,(pos,radius) in enumerate(sp):
if i < nCyls: # add cylinder
ori = randomOrientation()
extents = (radius,.1*radius,.1*radius)
O.bodies.append(box(pos,extents,ori))
else: # add sphere
O.bodies.append(sphere(pos,radius))
##########
there is no cylinder command in my yade, so I used box instead, but the idea should be clear.
cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.