determining contacts with getBodyIdsContacts() ?

Asked by Johannes Welsch on 2019-02-01


I am new to Yade, and I have a question concerning the determination of contacts of particles.
I want to calculate the coordination number of a binary packing. One for the bigger particles and one for the smaller particles. My idea was to use getBodyIdsContacts() of each particle and to use len(getBodyIdsContacts()) as the number of contacts, with which I can calculate the Coordination Number.

As an easy example I am using two spheres to tryout the functions.
I am creating two spheres with a radius of 0.5, so the distance in case of a contact should be 1.0 or less.
I am using getBodyIdsContacts() to print a list of contacting bodies, the simulation stops when there is a contact of the two spheres. I am also printing the force acting between the two spheres.

The problem is, that getBodyIdsContacts() shows a contact of the particles, although there is no force between them and the distance of the particles assumes that there is no contact (d = 1.024). Can you give me some hints how to solve the problem, or which other function I can use to determine the number of contacts of a particles.

kind regards
Johannes Welsch




      [Ig2_Sphere_Sphere_ScGeom()], # collision geometry
      [Ip2_FrictMat_FrictMat_FrictPhys()], # collision "physics"
      [Law2_ScGeom_FrictPhys_CundallStrack()] # contact law -- apply forces



def PrintContacts():

    contacts = utils.getBodyIdsContacts(1)

    if len(contacts) > 0:
        print "Position Partikel 1", O.bodies[1].state.pos
        print "Kontakte Partikel 1", utils.getBodyIdsContacts(1)
        print "Partikel 1",O.forces.f(1)


Question information

English Edit question
Yade Edit question
No assignee Edit question
Solved by:
Robert Caulk
Last query:
Last reply:
Best Robert Caulk (rcaulk) said : #1

See [1]. The VIRTUAL interactions you mention are kept handy (for efficiency purposes?), but they do not participate in the simulation. You are right in wanting to exclude these from your coordination number calculation. As pointed out by [1]:


returns a list of REAL interactions for that particular body.


Thanks Robert Caulk, that solved my question.