# Shrinkage of particles

Hello All,

I want to simulate shrinkage of particles during the deformation. the summary of my problem is:
there are some particles in the cylinder and gravity are applied to them. The particles which are in the specific area will be reduced their radii. I did the below simulation but it is not the thing that I want to do.

for i in O.bodies:
if isinstance(i.shape,Sphere) and i.state.pos[2]<-46e-3 and i.state.pos[2]>-48e-3:
i.material=O.materials['Coke']

I want to reduce the size of particles in a specific position. I used the grow.Particle() but it doesn't work. I was wondering if you could give me a solution. the reduction of particles' radius must be a function of time and the position of particles.

Best Regards

Alireza

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Solved:
2019-02-21
Last query:
2019-02-21
2019-02-21
 Jan Stránský (honzik) said on 2019-02-19: #1

Hello,

> but it is not the thing that I want to do.

please be more specific. What it does wrongly and what you expect.

> I used the grow.Particle()

do you mean growParticle(), or really grow.Particle()?

> but it doesn't work.

please again, always be as specific as possible. Did you get an error? If yes, which? The particles did not grow/shrink? ...?

> I was wondering if you could give me a solution. the reduction of particles' radius must be a function of time and the position of particles.

in principle I see no problem to make it work :-)

cheers
Jan

Dear Jan,

Thank you very much for your consideration. Actually , I want to reduce the particles' size in specific area for each iteration (time step), for example:

r1= (1-5e-10) r0

where r0 is initial radius of particle in each iteratition and r1 is the final radius at the end of specific iteratition.

> do you mean growParticle(), or really grow.Particle()?
growParticle() doesn't work. It was a mistake in dictation :)

> please again, always be as specific as possible. Did you get an error? If yes, which? ? The particles did not grow/shrink? ...?

with growParticle() the particles disappeared. I don't know why. In addition, via the code

for i in O.bodies:
if isinstance(i.shape,Sphere) and i.state.pos[2]<-46e-3 and i.state.pos[2]>-48e-3:
i.material=O.materials['Coke']

the radius will be reduced instantly. but I want their reduction in each step.

Thank you very much for your help.

Best Regards

Alireza

 Jan Stránský (honzik) said on 2019-02-20: #3

Hello,

instant replay: please provide a MWE (minimal working example). I.e. a complete script which we can try, reproduce the problem and see all aspects

> the radius will be reduced instantly. but I want their reduction in each step.

put the code in the function and call it with PyRunner

Jan

Hello Jan,

This is a simple case similar to my simulation.

O.reset()

from datetime import datetime

qtr=qt.Renderer()
qtr.bgColor=(1,1,1)

#==============================================================
#================= define the materials =======================
#==============================================================

O.materials.append(CohFrictMat(normalCohesion= 1e20, shearCohesion= 1e20, isCohesive= True, young=6.81e8, density=1377.5, poisson=0.3, frictionAngle= 0.31, fragile=False, label='Coke'))

O.materials.append(CohFrictMat(normalCohesion= 1e20, shearCohesion= 1e20, isCohesive= False, young=6.81e8,
density=1523.6, poisson=0.3, frictionAngle= 0.28, fragile=False, label='mold'))

#===============================================================
#=================== define wall================================
#===============================================================

O.bodies.append(mld)

#===============================================================
#=================== define packing ============================
#===============================================================

nums=['t']

mats=['Coke']

coke=(1e-3,2000)

nums=pack.SpherePack()
nums.makeCloud((-4.5e-3,-4.5e-3,-5e-2),(4.5e-3,4.5e-3,0.08),rMean=coke[0],rRelFuzz=1e-4,num=coke[1])
O.bodies.append([utils.sphere(c,r,material=mats[0]) for c,r in nums])

#===============================================================
#=================== define Engine =============================
#===============================================================

O.engines=[
ForceResetter(),

InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),

]

O.dt=1.00e-6

#=============================================================
#=====================define Shrinkage========================

O.engines=O.engines+[PyRunner(command='Shrinkage()', label='Shrink',iterPeriod=700000)]

def Shrinkage():

for i in O.bodies[Sphere]:

if i.state.pos[2]<-40e-3:

utils.growParticles(0.5,updateMass=True)

#for i in O.bodies:
# if isinstance(i.shape,Sphere) and i.state.pos[2]<-20e-3 and i.state.pos[2]>-30e-3:
# i.material=O.materials['Coke']

Thank you very much for your help.

Best Regards

Alireza

 Bruno Chareyre (bruno-chareyre) said on 2019-02-21: #5

>>>>> I used the grow.Particle() but it doesn't work
>>>> do you mean growParticle(), or really grow.Particle()?
>>> growParticle() doesn't work
> utils.growParticles(0.5,updateMass=True)

You are asking how to change size and you keep claiming that growParticle() does not work, while the good answer to your question is just growParticle().

Bruno

 Bruno Chareyre (bruno-chareyre) said on 2019-02-21: #6

Oh by the way, did you run the MWE before sending?... I guess not.
This is a MWE;

O.bodies.append(sphere((0,0,0),1))
growParticle(0,0.5)

Output:
1
0.5

 Jan Stránský (honzik) said on 2019-02-21: #7

Hello,

thanks for the code (although, as Bruno pointed, it is not very minimal ;-) Why it is not MWE:
- unused or unnecessarry code (import datetime, qtr.bgColor)
- materials are irrelevant to the problem (and you define CohFrictMat and in engines you have just FrictMat)
- facetCylinder is also not needed
- there are quite a lot particles for testing
- but MOST importantly, it is not WORKING example. Your Shrinkage function ends with error and there are several problems:
- for i in O.bodies[Sphere]: # ???
- utils.growParticles(0.5,updateMass=True) # probably you meant just growParticle (without s). growParticles grow all particles. Not what you want and it not very reasonable to use it inside looping over all bodies..

Next time please try to create a MWE specific for the problem.
Quite often you solve the problem yourself this way ;-)

> the radius will be reduced instantly. but I want their reduction in each step.
> PyRunner(command='Shrinkage()', label='Shrink',iterPeriod=700000)

if you want the reduction in each step, use iterPeriod=1

a MWE (demonstration how to shrink particles and an inspiration how true MWE could look like):
###
# you can see particles growing below the wall. For shrinkage, just use multiplier <1

rMean,num = 1e-3, 100

sp=pack.SpherePack()
sp.makeCloud((-5e-3,-5e-3,0),(5e-3,5e-3,20e-3),rMean=rMean,num=num)
O.bodies.append([utils.sphere(c,r) for c,r in sp])
O.bodies.append(wall((0,0,-5e-3),2))

O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
PyRunner(iterPeriod=1,command='shrink()'),
]
O.dt=1e-5

def shrink():
for b in O.bodies:
if not isinstance(b.shape,Sphere):
continue
if b.state.pos[2] < -5e-3:
growParticle(b.id,1+1e-4,updateMass=True)
###

cheers
Jan