Not getting desired PSD generation

Asked by Harsh Patel

Hello All,
I am trying to generate cylindrical sphere packing according to a given PSD. First, I use the following script to generate sphere packing:
>
psdSizes,psdCumm=[2.36,4.75,6.3,9.5,12.5],[0.347,0.657,0.76,0.973,1]
fill_size=100
pred=pack.inCylinder(centerBottom=(0,0,-(h_cyl/2)+1),centerTop=(0,0,fill_size),radius=r_cyl-3)
sp=pack.SpherePack()
sp.makeCloud((-r_cyl,-r_cyl,-(h_cyl/2)),(r_cyl,r_cyl,h_cyl/2),psdSizes=psdSizes,psdCumm=psdCumm,num=14000,distributeMass=True)
sp2 = pack.filterSpherePack(pred,sp,returnSpherePack=True)
sp2.toSimulation()
>
Then after running the script, I check the % of spheres with radii less than 2.36 as follows:
>
yell=[]
for b in O.bodies:
  if isinstance(b.shape,Sphere):
    yell.append(b.shape.radius)
count=0
for j in range(len(yell)):
  if yell[j]<2.36:
    count=count+1
print (float(count)/len(yell))
>
Using latter method, I get my answer around 0.87 which should actually be around 0.347. Is there a mistake in my code or in the usage of makeCloud command? I am not able to figure out.

Thanks in advance!

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Robert Caulk
Solved:
Last query:
Last reply:
Revision history for this message
Chareyre (bruno-chareyre-9) said :
#1

Hi,
I would suggest not using titles like «faulty something» since in most
cases problems come from faulty users. ;)

You distribute by mass then you check how it is distributed by number. Of
course it is not the same.

Next time please send the script as a whole.

Bruno

Le ven. 24 août. 2018 20:52, j0hnn1e <email address hidden>
a écrit :

> New question #672684 on Yade:
> https://answers.launchpad.net/yade/+question/672684
>
> Hello All,
> I am trying to generate cylindrical sphere packing according to a given
> PSD. First, I use the following script to generate sphere packing:
> >
> psdSizes,psdCumm=[2.36,4.75,6.3,9.5,12.5],[0.347,0.657,0.76,0.973,1]
> fill_size=100
>
> pred=pack.inCylinder(centerBottom=(0,0,-(h_cyl/2)+1),centerTop=(0,0,fill_size),radius=r_cyl-3)
> sp=pack.SpherePack()
>
> sp.makeCloud((-r_cyl,-r_cyl,-(h_cyl/2)),(r_cyl,r_cyl,h_cyl/2),psdSizes=psdSizes,psdCumm=psdCumm,num=14000,distributeMass=True)
> sp2 = pack.filterSpherePack(pred,sp,returnSpherePack=True)
> sp2.toSimulation()
> >
> Then after running the script, I check the % of spheres with radii less
> than 2.36 as follows:
> >
> yell=[]
> for b in O.bodies:
> if isinstance(b.shape,Sphere):
> yell.append(b.shape.radius)
> count=0
> for j in range(len(yell)):
> if yell[j]<2.36:
> count=count+1
> print (float(count)/len(yell))
> >
> Using latter method, I get my answer around 0.87 which should actually be
> around 0.347. Is there a mistake in my code or in the usage of makeCloud
> command? I am not able to figure out.
>
> Thanks in advance!
>
> --
> 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 : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>

Revision history for this message
Harsh Patel (j0hnn1e) said :
#2

Hello Bruno,
>>I would suggest not using titles like «faulty something» since in most
cases problems come from faulty users. ;

I apologize for misleading question header. I have changed it accordingly.

>>You distribute by mass then you check how it is distributed by number. Of
course it is not the same.

Following your suggestion, I ran the program with 'distributemass=False'. This time, I got the (float(count)/len(yell)) ratio as 0.98 which is way off than the previous one and the desired number. I am trying to wrap my head around what is wrong in my code but couldn't find it.

>>Next time please send the script as a whole.

Firstly, the first code is part of my original script which generates the sphere cloud. The second part is just a 'query code' I run in terminal after I run 'yade myprogram.py' just to check the ratio of spheres with radii less than 2.36. This is the complete part of the script that deals with the sphere generation. Rest of my script is just engines and plotting graphs.

Revision history for this message
Chareyre (bruno-chareyre-9) said :
#3

Still, it is impossible to test your claim with a script based on your code
fragments. You need to send a working script.

Le sam. 25 août. 2018 16:57, j0hnn1e <email address hidden>
a écrit :

> Question #672684 on Yade changed:
> https://answers.launchpad.net/yade/+question/672684
>
> Status: Answered => Open
>
> j0hnn1e is still having a problem:
> Hello Bruno,
> >>I would suggest not using titles like «faulty something» since in most
> cases problems come from faulty users. ;
>
> I apologize for misleading question header. I have changed it
> accordingly.
>
> >>You distribute by mass then you check how it is distributed by number. Of
> course it is not the same.
>
> Following your suggestion, I ran the program with
> 'distributemass=False'. This time, I got the (float(count)/len(yell))
> ratio as 0.98 which is way off than the previous one and the desired
> number. I am trying to wrap my head around what is wrong in my code but
> couldn't find it.
>
> >>Next time please send the script as a whole.
>
> Firstly, the first code is part of my original script which generates
> the sphere cloud. The second part is just a 'query code' I run in
> terminal after I run 'yade myprogram.py' just to check the ratio of
> spheres with radii less than 2.36. This is the complete part of the
> script that deals with the sphere generation. Rest of my script is just
> engines and plotting graphs.
>
> --
> 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 : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Harsh Patel (j0hnn1e) said :
#4

Hello Bruno,
Sorry for inconvenience. Please find attached the working script.
https://pastebin.com/nGwiWxAj

Query code in terminal:
yell=[]
for b in O.bodies:
  if isinstance(b.shape,Sphere):
    yell.append(b.shape.radius)
count=0
for j in range(len(yell)):
  if yell[j]<2.36:
    count=count+1
print (float(count)/len(yell))
*******************
Thanks

Revision history for this message
Robert Caulk (rcaulk) said :
#5

Hello John(?),

In an effort to keep the forums organized for future Yade users, please take a moment to review these guidelines [1] (note the external links rules).

Although I have not run your script, it appears to me that you are using option 4/ of the makeCloud Sphere radius distribution methods [2]. As described in the doc, Yade is likely using appliedPsdscaling to reach your desired numSpheres argument. For answer completeness: you should use method 3/ if you are concerned with the radius magnitude in addition to the radius distribution.

Best,

Robert

[1]https://yade-dem.org/wiki/Howtoask
[2]https://yade-dem.org/doc/yade.pack.html#yade._packSpheres.SpherePack.makeCloud

Revision history for this message
Harsh Patel (j0hnn1e) said :
#6

Hello Robert,
>>In an effort to keep the forums organized for future Yade users, please take a moment to review these guidelines [1] (note the external links rules).
I am sorry for using external link. Please find the script below:
from yade import pack, export, plot
from yade import utils, ymport
import math,numpy
#from yade import plot
r_cyl=75
h_cyl=250
#psdSizes,psdCumm=[2.36,4.75,6.3,9.5,12.5,19,25],[.365,.512,.596,.77,.864,.974,1] #Category 4, N100
psdSizes,psdCumm=[2.36,4.75,6.3,9.5,12.5],[0.347,0.657,0.76,0.973,1] #Category 3, N70

cyl1=O.bodies.append(geom.facetCylinder((0,0,0),r_cyl,h_cyl,wallMask=6))
fill_size=100
pred=pack.inCylinder(centerBottom=(0,0,-(h_cyl/2)+1),centerTop=(0,0,fill_size),radius=r_cyl-3)
idAggregate=O.materials.append(FrictMat(density=2600,young=30e9,poisson=.4,frictionAngle=1.0472,label="aggregate")) #frictionangle in rad
sp=pack.SpherePack()
sp.makeCloud((-r_cyl,-r_cyl,-(h_cyl/2)),(r_cyl,r_cyl,h_cyl/2),psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=False)
sp2 = pack.filterSpherePack(pred,sp,returnSpherePack=True)
sp2.toSimulation()
print (len(O.bodies)-1) #no of spheres generated
O.dt=0.005*PWaveTimeStep()
######################
I tried using 3/ method in [1] but I am still getting quite high %age of spheres of radius less than 2.36 (0.347 is input, 0.654 is the output). I have checked by toggling the bool variable 'distributeMass' (True and False) and I still get very high answers in both the cases.

1. https://yade-dem.org/doc/yade.pack.html#yade._packSpheres.SpherePack.makeCloud

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#7

Hello "Harsh" (?)
Comment #3 was a suggestion for future questions. I was not asking any more script in this thread since in my view the question is already answered (by #1, isn't it?).
Bruno

Revision history for this message
Harsh Patel (j0hnn1e) said :
#8

Hello Bruno,
Thank you for your prompt response. As I mentioned in comment #6, I am still getting very high values of sphere proportion w.r.t. radius. I tried using Robert's suggestion too (comment #5) and removed 'num=14000' from my code but that too doesn't work in my case.

P.S. Sorry for the change in account name, I recently recovered it.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#9

Ah, ok.
Well, the script in #6 seems to generate some PSD, that is all. Hence nothing wrong in it.
If you have a way to show the result is wrong it should be in the script as well.

Note that makeCloud gives nearly exact match to the target PSD yet cropping this with a predicate could change the distribution. The biggest particles are not negligibly small compared to the cylinder in your case, there could some biased removal for this reason. I would suggest to first make sure everything is right in sp before checking sp2
Bruno

p.s. actually I am speculating that you checked sp2... but I don't know really... it is not in your script :(

Revision history for this message
Best Robert Caulk (rcaulk) said :
#10

>I tried using 3/ method in [1] but I am still getting quite high %age of spheres of radius less than 2.36 (0.347 is input, >0.654 is the output). I have checked by toggling the bool variable 'distributeMass' (True and False) and I still get very >high answers in both the cases.

Makes sense, makeCloud is distributing particle diameters and you are looking at radii :-)

Revision history for this message
Harsh Patel (j0hnn1e) said :
#11

Thanks Robert Caulk, that solved my question.

Revision history for this message
Harsh Patel (j0hnn1e) said :
#12

Thanks Bruno and Robert for your suggestions.