# Calculation of the number of contact point in the particles

Hi,

I have a question about estimating the contact number of every particle when the particles are stopped.

I am studying the effect of the porosity of the powder layer on the electrical resistance.
First, in this code, the spherical powder is replaced with some crump powder and falls into facetBox by gravitational force.
I'd like to get the number of contact points between particles after the sphere pack falling because it is one of the crucial points for the electroconductivity of the powder layer.
Moreover, I would like to get the number of contact points of the clamp powder and that of spherical powder separately.

The code is as follows:

******************************************************************************************************************
from yade import pack, qt, plot, utils, geom, export, ymport

#Base plates properties
Baseplate=O.materials.append(FrictMat(young=190e9,poisson=.265,density=7970,frictionAngle=0.12,label="Baseplate"))

#Create base plate using facets
O.bodies.append(geom.facetBox((0,0,0), (0.21,0.21,0.21), orientation=Quaternion((1,0,0),0), wallMask=31, color=(1,0,0), material=Baseplate)) #Smkoking hole setting

#powder properties
PB=O.materials.append(FrictMat(young=220e9,poisson=.3,density=8287,frictionAngle=0,label="TiAl powder"))

#create Spherepack
sp=pack.SpherePack()

#Paricle size distribution of ball milled powder
sp.makeCloud((-0.2,-0.2,-0.2),(0.2,0.2,0.2), psdSizes=[0.021,0.023,0.025,0.027,0.03,0.033,0.036,0.040,0.044,0.048,0.053,0.058,0.063,0.070,0.076,0.084,0.092,0.101,0.111], psdCumm=[0.0021,0.0049,0.00588,0.00657,0.00907,0.01467,0.02897,0.05637,0.10027,0.16277,0.24527,0.34827,0.47627,0.61227,0.74827,0.86627,0.94987,0.99047,1], distributeMass=True)

#Make the cloud
sp.toSimulation(material=PB)

#Clump setting (by Circularity)
#0.8:
relPosList1 = [[0,0,0],[0.84,0,0]]

#0.6:
relPosList2 = [[0,0,0],[0.6,0,0]]

#0.4:
relPosList3 = [[1,0,0],[1.72,0,0],[2.32,0,0]]

#0.2:
#relPosList4 = [[1,0,0],[1.6,0,0],[2.2,0,0],[2.8,0,0],[3.4,0,0],[4.0,0,0]]

templates= []

#Clump fraction :
CP=O.bodies.replaceByClumps(templates,[0.20773,0.09662,0.00966],discretization=1)

O.engines=[
ForceResetter(), #reset forces

InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]), #approximate collision detection

InteractionLoop( # handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_MindlinPhys(
frictAngle=MatchMaker(matches=((Baseplate,PB,.451),(PB,PB,.451), )),
en=MatchMaker(matches=((Baseplate,PB,.15), (PB,PB,.45), )),
es=MatchMaker(matches=((Baseplate,PB,.10), (PB,PB,.15))))],
[Law2_ScGeom_MindlinPhys_Mindlin()]
),
NewtonIntegrator(damping=0.75, gravity=[0,0,-9.81]),
]

#PyRunner(iterPeriod=200,command='calm()',label='calmRunner')]

O.dt=.85*PWaveTimeStep()

qt.View()

qt.Controller()

O.saveTmp('yim')

#utils.voxelPorosity(resolution=200,start=(-0.8,-0.8,-0.8),end=(0.8,0.8,-0.4)) #Porocity of powderbed

#Contact number of particles
bodyList = []
for i in O.bodies:
if i.isClump:
bodyList.append(i.id)

len(O.bodies[i.id].intrs())

*********************************************************************************************************************

Thanks,

YIM

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Karol Brzezinski
Solved:
Last query:
 Revision history for this message Karol Brzezinski (kbrzezinski) said on 2021-02-26: #1

Hi,

all the interactions are stored in the O.interactions object, so you can count the interactions in the following way:

i_count = len(O.interactions) # this will include also interaction with walls and facets

You can count the number of spheres in such a way:

sp_count = 0

for bb in O.bodies:
if isinstance(bb.shape, Sphere):
sp_count += 1

and the number of clumps:

clump_count = 0

for bb in O.bodies:
if bb.isClump:
clump_count += 1

This solution is pretty straightforward, but I think that you can just divide the number of interactions by the number of spheres (or clumps).

Cheers,
Karol

 Revision history for this message Jérôme Duriez (jduriez) said on 2021-02-26: #2

Generally speaking, https://yade-dem.org/doc/tutorial-data-mining.html might also beneficial here

 Revision history for this message Jan Stránský (honzik) said on 2021-02-26: #3

Hi,
yet another option is to use [1]
bodyInteractions = b.intrs()
returning list of body interactions. If you are interested merely in the number, then
len(bodyInteractions)
returns you the result, or you can do some more fancy postprocessing (like counting only interactions with spheres, excluding walls:
def isSphereSphere(i):
bs = [O.bodies[id] for id in (i.id1,i.id2)]
return all(isinstance(b.shape,Sphere) for b in bs)
len([i for i in bodyInteractions if isSphereSphere(i)])

The optimal choice really depends on your needs..

cheers
Jan

 Revision history for this message Yimsk (sky-132) said on 2021-02-26: #4

Thanks Karol Brzezinski, that solved my question.

 Revision history for this message Yimsk (sky-132) said on 2021-02-26: #5

Sincerely,

YIM