Replace by clump

Asked by Fereshteh Salehi

Hello everybody.
I am beginner in yade.
I created a specific aggregate grading with 'psdSizes & psdCumm ' in ' makeCloud '.
Now I want to select two specific ranges of particles and replac them with two different Clumps.
It is a part of my code ####product trash#####
a=[0,.005,.01,.015,.02,.025,.03,.035]
b=[0,.005,.01,.015,.02,.025,.03,.035,.04,.045,.05,.055,.06,.065,.07,.075]
c=[0,.005]
d=[]
for i in a:
 for j in b:
  for k in c:
   d.append((i,j,k))
for i in d:
 O.bodies.appendClumped([sphere((i),.005)])
######clump 1#####
clump=O.bodies.appendClumped([sphere((0,0,0),.002),sphere((.002,0,0),.002)])
#####aggregate#####
from yade import pack
sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),psdSizes=[.001,.002,.078,.08],psdCumm=[0,.07,.71,1])
sp.toSimulation()
######replace######
for b in O.bodies:
 if b.shape.radiuse>.078:
  pass
 else:
  #the particle should be replaced by clump1. ################################## I do not use the 'clumpTemplate' and 'replaceByClumps' commands because these commands select a percentage of the particles randomly and do not take into account the grain size. As a result, they may replace particles of the wrong sizes with the clump we do not intend.
Please guide me in replace part.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Karol Brzezinski
Solved:
Last query:
Last reply:
Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#1

Hi Fereshteh,

you can achieve this by splitting a sphere pack into two separate packs. First, load only the spheres that you want to replace with clumps. After you replace them, load the remaining spheres.

######################## MWE
from yade import pack
sp=pack.SpherePack()
spSpheres = pack.SpherePack()
spClumps = pack.SpherePack()

sp.makeCloud((0,0,0),(1,1,1),psdSizes=[.001,.002,.078,.08],psdCumm=[0,.07,.71,1])

for ss in sp: #split SpherePack into two other packs based on the particle size
 r = ss[1]
 if r > .078/2:# please note that you feed diameters nor radii in psdSizes, that is why I divide it by 2
  spClumps.add(ss[0],ss[1])

 else:
  spSpheres.add(ss[0],ss[1])

# add only the spheres that you want to replace and replace them with clumps
spClumps.toSimulation()
ct = clumpTemplate([1,1],[[0,0,0],[0,0,1]])
O.bodies.replaceByClumps( [ct] , [1], discretization = 20 )
#add the remaining spheres stored in the other sphere pack
spSpheres.toSimulation()
#################### end of MWE

Cheers,
Karol

Revision history for this message
Fereshteh Salehi (salehif) said :
#2

Hi Karol
Thank you very much for your reply.
But I want replace by two different Clumps.
####clump1#####
a=[0,.005,.01,.015,.02,.025,.03,.035]
b=[0,.005,.01,.015,.02,.025,.03,.035,.04,.045,.05,.055,.06,.065,.07,.075]
c=[0,.005]
d=[]
for i in a:
 for j in b:
  for k in c:
   d.append((i,j,k))
for i in d:
 O.bodies.appendClumped([sphere((i),.005)])
######clump2#####
clump=O.bodies.appendClumped([sphere((0,0,0),.002),sphere((.002,0,0),.002)])
#####aggregate#####
from yade import pack
sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),psdSizes=[.001,.002,.078,.08],psdCumm=[0,.07,.71,1])
sp.toSimulation()
######replace######
for b in O.bodies:
 if b.shape.radiuse>.078/2:
  #the particle should be replaced by clump1
 else:
  #the particle should be replaced by clump2

Revision history for this message
Best Karol Brzezinski (kbrzezinski) said :
#3

Hi Fereshteh,

I think that you can just create another clump template and call replaceByClumps() again.
Try whether it is the effect that you wanted to achieve:

############ Code
from yade import pack
sp=pack.SpherePack()
spSmall = pack.SpherePack()
spBig = pack.SpherePack()

sp.makeCloud((0,0,0),(1,1,1),psdSizes=[.001,.002,.078,.08],psdCumm=[0,.07,.71,1])

for ss in sp: #split SpherePack into two other packs based on the particle size
 r = ss[1]
 if r > .078/2:# please note that you feed diameters nor radii in psdSizes, that is why I divide it by 2
  spBig.add(ss[0],ss[1])

 else:
  spSmall.add(ss[0],ss[1])

# add only the spheres that you want to replace and replace them with clump1
spSmall.toSimulation()
ct1 = clumpTemplate([1,1],[[0,0,0],[0,0,1]])

O.bodies.replaceByClumps( [ct1] , [1], discretization = 20 )
#add the remaining spheres stored in the other sphere pack
spBig.toSimulation()
ct2 = clumpTemplate([1,1,1,1,1],[[0,0,0],[0,0,1],[-1,0,0],[0,1,0],[0,-1,0]])
O.bodies.replaceByClumps( [ct2] , [1], discretization = 20 )
########### end of code

Please note, that I didn't use your template, just another clump uncomplicated clump template, to keep the example simple.

Cheers,
Karol

Revision history for this message
Fereshteh Salehi (salehif) said :
#4

Thanks Karol Brzezinski, that solved my question.