How to set the particle size when generating particles

Asked by 黎犴dada

How to set the particle size when generating particles
I have referred to the particle gradation curves of sand in some literatures and recorded the data.
Can I define the particle gradation I want when the particles are generated?
I really need your help. Thank you

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Robert Caulk (rcaulk) said :
#1

>>Can I define the particle gradation I want when the particles are generated?

Yes, you can [1].

Cheers,

Robert

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

Revision history for this message
黎犴dada (xuzchao) said :
#2

Thank you very much for your reply!
I still haven't solved my problem. I have carefully read the link you provided,
but I still haven't come up with a method that can be incorporated into my existing particle grading

Revision history for this message
Jan Stránský (honzik) said :
#3

> particle gradation curves

is it particle size distribution? On horizontal axis size, on vertical axis % passing?
If yes, then read [1] and focus on psdSizes, psdCumm, "psdSizes and psdCumm, two arrays specifying points of the particle size distribution function" etc.
If no, please be more specific.

Cheers
Jan

Revision history for this message
黎犴dada (xuzchao) said :
#4

Thank you for your answer. This is the code of my three-axis generation. When creating particles, I want to use the grading curve I already have to create particles with specific data, but I am confused about how to modify this code.

# unicode: UTF-8
# For 2D biaxial simulation
# 21/10/2016
# Yade version 2016.06a-24-0557faf~trusty

#########################################
### Defining parameters and variables ###
#########################################

#Material constants
Density = 3000
FrictionAngle = 35
PoissonRatio = 0.5
Young = 300e6
Damp = 0.5
AvgRadius = 0.0027
N_particles = 25000

#Wall constants
WDensity = 0
WFrictionAngle = 0.0
WPoissonRatio = 0.5
WYoung = 50e9

#Packing variables
mn = Vector3(0.,0.,0.)
mx = Vector3(1.5,1.5,1.5)
targetPorosity = 0.2
Porosity = 0.

#Confining variables
ConfPress1 = -90000 #pre-compression
ConfPress = -1.0e5

#Loading control
LoadRate = -0.01

#time calculation
startT = O.time
endT = O.time
timeSpent = endT - startT

########################################
#import necessary packages
from yade import pack,plot,os,timing
import matplotlib; matplotlib.rc('axes',grid=True)
import pylab

########################################
### Sample Preparing ###################
########################################

#Create materials for spheres and plates
SphereMat = O.materials.append(FrictMat(young = Young, poisson = PoissonRatio, frictionAngle = radians(FrictionAngle), density = Density))
WallMat = O.materials.append(FrictMat(young = WYoung, poisson = WPoissonRatio, frictionAngle = radians(WFrictionAngle), density = WDensity))

#Create walls for packing
wallIds = O.bodies.append(aabbWalls([mn,mx],thickness=0.001,material=WallMat))

#Use SpherePack object to generate a random loose particles packing
#O.periodic = True
#O.cell.setBox(8,3,8)

sp = pack.SpherePack()

#psdSizes,psdCumm=[.003,0.0035,0.004,0.0045,0.005,0.0055,0.006,0.0065,0.007,0.0075,0.008,0.0085,0.009],[0.,0.003,0.025,0.081,0.182,0.325,0.493,0.660,0.8,0.890,0.957,0.984,1.]
#pylab.plot(psdSizes,psdCumm,label='precribed PSD')
sp.makeCloud(Vector3(0,0,0.0),Vector3(1.5,1.5,1.5) ,-1,0.33,N_particles,False, 0.75)
#pylab.plot(*sp.psd(bins=30,mass=True),label='PSD of (free) %d random spheres'%len(sp))

#pylab.legend()

#pylab.show()
sp.toSimulation(material = SphereMat)

O.usesTimeStepper=True
O.trackEnerty=True
#################################
#####Defining triaxil engines####
#################################

###first step: compression#######
triax1=TriaxialStressController(
    #define wall ids
    #wall_bottom_id = wallIds[4],
    #wall_top_id = wallIds[5],
    #wall_left_id = wallIds[1],
    #wall_right_id = wallIds[0],
    #wall_back_id = wallIds[2],
    #wall_front_id = wallIds[3],
    #wall_back_activated = False, #for 2d simulation
    #wall_front_activated = False,
    thickness = 0.001,
    maxMultiplier=1.+1.5e5/Young, # spheres growing factor (fast growth)
    finalMaxMultiplier=1.+4e3/Young,
    #maxMultiplier = 1.002,
    internalCompaction = True, # If true the confining pressure is generated by growing particles
    #max_vel = 1.5,
    stressMask = 7,
    computeStressStrainInterval = 10,

    goal1 = ConfPress1,
    goal2 = ConfPress1,
    goal3 = ConfPress1,

)

#O.dt=0.5*PWaveTimeStep()

newton=NewtonIntegrator(damping=Damp)

###engine
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
    InteractionLoop(
     [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
     [Ip2_FrictMat_FrictMat_FrictPhys()],
     [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8, defaultDt=4*utils.PWaveTimeStep()),
    triax1,
    newton,
    PyRunner(realPeriod=10,command='checkUnbalanced()',label='check'),
    PyRunner(command='addPlotData()',iterPeriod=2000,label='record'),
    TriaxialStateRecorder(iterPeriod=2000,file='WallStresses')
]
# Simulation stop conditions defination
def checkUnbalanced():
    unb=unbalancedForce()
    mStress = (triax1.stress(triax1.wall_right_id)[0]+triax1.stress(triax1.wall_top_id)[1]+triax1.stress(triax1.wall_front_id)[2])/3.
    s1 = triax1.stress(triax1.wall_right_id)[0]
    s2 = triax1.stress(triax1.wall_top_id)[1]
    s3 = triax1.stress(triax1.wall_front_id)[2]

    if unb<0.01 and abs(ConfPress1-mStress)/(-ConfPress1)<0.01:
       O.pause()
       O.save('initial.yade.bz2')
       ################################## postprocessing for simulation ######################################################
       f = open("particleinfo.dat",'w')
       f.write('# This is the result data of 2D simulation\n\n')
       f.write('# There are 8 types of varibles in this data as follows:\n\n')
       f.write("varibles='X-cordinate','Y-cordinate','Z-cordinate','Radius','X-displacement','Y-displacement','Z-displacement','Ids'\n\n")
       f.write('%-16s %-16s %-16s %-16s %-16s %-16s %-16s %-16s %-16s\n'% ('X-cordinate','Y-cordinate','Z-cordinate','Radius','X-displacement','Y-displacement','Z-displacement','Ids','dens'))
       for b in O.bodies:
           if isinstance(b.shape,Sphere):
              pos = b.state.pos
              rad = b.shape.radius
              displ = b.state.displ()
              #vel = b.state.vel #vector3
              #O.forces.f(b) for forces
              #O.forces.t(b) for torques
              f.write('%-16g %-16g %-16g %-16g %-16g %-16g %-16g %-16d %-16g\n'%(pos[0],pos[1],pos[2],rad,displ[0],displ[1],displ[2],b.id,b.material.density))
       f.write('################################ ends ##########################################')
       f.close()

# collect history of data
def addPlotData():
    unb = unbalancedForce()
    mStress = -(triax1.stress(triax1.wall_right_id)[0]+triax1.stress(triax1.wall_top_id)[1]+triax1.stress(triax1.wall_front_id)[2])/3.

    plot.addData(e11=-triax1.strain[0], e22=-triax1.strain[1], e33=-triax1.strain[2],
     ev=-triax1.strain[0]-triax1.strain[1]-triax1.strain[2],
   s11=-triax1.stress(triax1.wall_right_id)[0],
   s22=-triax1.stress(triax1.wall_top_id)[1],
   s33=-triax1.stress(triax1.wall_front_id)[2],
                 ub=unbalancedForce(),
                 dstress=(-triax1.stress(triax1.wall_top_id)[1])-(-triax1.stress(triax1.wall_right_id)[0]),
                 disx=triax1.width,
                 disy=triax1.height,
                 disz=triax1.depth,
   i=O.iter,
                 porosity=utils.porosity(),
                 ke=utils.kineticEnergy(),
                 totalEnergy=O.energy.total()
                 )

    print ('unbalanced force: %f, mean stress: %f, s11: %f, s22: %f,s33:%f, coordination number: %f, porosity: %f' %(unb,mStress,-triax1.stress(triax1.wall_right_id)[0],-triax1.stress(triax1.wall_top_id)[1],-triax1.stress(triax1.wall_front_id)[2],avgNumInteractions(),utils.porosity()))

    plot.saveDataTxt('loadinglog.txt.bz2')
    #plot.saveGnuplot('plotScript')

###display
#yade.qt.Controller(),yade.qt.View()

### declare what is to plot. "None" is for separating y and y2 axis
plot.plots={'i':('ub',),'i ':('e11','e22','e33',),' i':('s11','s22','s33',),'e22':'dstress'}
#plot.plots={'i':('ub',),'i ':('s11','s22','s33'),' i':('e11','e22','e33')}

### the traditional triaxial curves would be more like this:
##plot.plots={'e22':('s11','s22','s33',None,'ev')}

## display on the screen (doesn't work on VMware image it seems)

#plot.plot()
O.run()#; O.wait()

Revision history for this message
Jan Stránský (honzik) said :
#5

Please provide a MWE [1], M = minimal. I.e. if it is about initial particle packing, please remove all unnecessary code not related to the problem (materials, triax, checkUnbalanced, even the O.engines?).

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
黎犴dada (xuzchao) said :
#6

Thank you for your answer.This is my particle generation code.

#psdSizes,psdCumm=[.003,0.0035,0.004,0.0045,0.005,0.0055,0.006,0.0065,0.007,0.0075,0.008,0.0085,0.009],[0.,0.003,0.025,0.081,0.182,0.325,0.493,0.660,0.8,0.890,0.957,0.984,1.]
#pylab.plot(psdSizes,psdCumm,label='precribed PSD')
sp.makeCloud(Vector3(0,0,0.0),Vector3(1.5,1.5,1.5) ,-1,0.33,N_particles,False, 0.75)
#pylab.plot(*sp.psd(bins=30,mass=True),label='PSD of (free) %d random spheres'%len(sp))

I want to use my existing particle sizing to generate particles. I don't know how to modify my code.

Revision history for this message
Jan Stránský (honzik) said :
#7

Please provide a MWE [1], W = working, i.e. we can copy-paste it and test it.
Here e.g. N_particles is not defined, 'sp' is not defined etc..
M part is perfect :-)

Have a look at example script [2] and let us know if it helps or if you need further help.

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask
[2] https://gitlab.com/yade-dev/trunk/-/blob/master/examples/test/psd.py

Can you help with this problem?

Provide an answer of your own, or ask 黎犴dada for more information if necessary.

To post a message you must log in.