# Obtain the contact number of each particles in the primary fabric (only consider large contact force pairs)

Hi all,

In my simulation, I want to calculate the contact number of each particles in the primary fabric (only consider the contact pairs larger than the average contact force).

To obtain the average contact force (avgForce), I use the following and it works OK:
for i in O.interactions:
fn = i.phys.normalForce.norm()
forceInact.append([i,fn])
forceInact=np.array(forceInact)
avgForce=sum(forceInact[:,1]/len(forceInact[:,1])

To get the contact number of each particles , I use:
for b in O.bodies:
len(b.intrs())

However, as my question above, how to give a criteria to obtain the contact number of each particles by considering the contact pairs with large contact forces only?

Thanks,

Zheng

## 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-11-21: #1

Hi Zheng,

I am not sure whether I understand you correctly. From what I understood, you want to know how many contacts of each particle have a normal force (amplitude) bigger than the threshold (mean force that you computed). I propose a modification of your last loop like this:

bodyId_numOfContacts = []
for b in O.bodies:
counter = 0
for ii in b.intrs():
if ii.phys.normalForce.norm() > avgForce:
counter += 1
bodyId_numOfContacts.append([b.id, counter])
bodyId_numOfContacts = np.array(bodyId_numOfContacts)

Cheers,
Karol

 Revision history for this message Zheng (zhengdem) said on 2021-11-22: #2

Thanks Karol Brzezinski, that solved my question.