← Back to team overview

yade-users team mailing list archive

Re: [Question #647318]: How to generate particles in a cylinder given their mass distribution with size?

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
> Should I use pack.SpherePack() or O.bodies.append(loop for particle generation) ?
Yes, both :-)
You can use the approach with TriaxialTest, but with importFilename argument:

##########
from yade import ymport
from yade import pack
txt = 'packing.txt'

# create initial packing
sp = SpherePack()
dim = 1.5e-1
minc,maxc = Vector3(0,0,0), dim*Vector3(1,1,1)
sp.makeCloud(minc,maxc,rMean=4e-3,num=500)
# change num in both cases to get desired mass ratio
sp.makeCloud(minc,maxc,rMean=2e-3,num=1000)
sp.toSimulation()
with open(txt,'w') as f:
   for b in O.bodies:
      x,y,z = b.state.pos
      r = b.shape.radius
      f.write("{} {} {} {}\n".format(x,y,z,r))

# TriaxialTest
O.reset()
test = TriaxialTest(importFilename=txt)
test.load()
O.run(1000,True)
# extract cylinder
mina,maxa = aabbExtrema()
d0 = max(mina)
d1 = min(maxa)
size = d1-d0
c = d0+.5*size
c0 = Vector3(c,c,d0)
c1 = Vector3(c,c,d1)
pred = pack.inCylinder(c0,c1,.4*size)
cyl = [b.id for b in O.bodies if isinstance(b.shape,Sphere) and pred(b.state.pos,b.shape.radius)]
with open(txt,'w') as f:
   f.write("#format_x_y_z_r\n")
   for i in cyl:
      b = O.bodies[i]
      x,y,z = b.state.pos
      r = b.shape.radius
      f.write("{} {} {} {}\n".format(x,y,z,r))

# load
O.reset()
sphs = ymport.text(txt)
O.bodies.append(sphs)
##########

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.TriaxialTest.importFilename
[2] https://yade-dem.org/doc/yade.pack.html#yade._packSpheres.SpherePack.makeCloud

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