how to specifically find interraction number of spheres to a body

Asked by JOHN

Good morning,
I have a list that contains the id's of all the particles in my simulation.
What i wanted to do was return a list of id's whose corresponding particle comes in contact with more than 4(5,6,7,.....) particles
Up until now i ve been using this
def findconnectivity(x):

 return len(O.interactions.withBody(x))

def connectivityIndex(connectivity):

 global conIndex

 conIndex[:]=[]

 for x in loc2glob[:]:

  if len(O.interactions.withBody(x))>connectivity:

   conIndex.append(x)

 return conIndex

def connectivity():

 getHighCon=[]

 for x in conIndex[:]:

  getHighCon.append([O.bodies[x].state.pos[0],O.bodies[x].state.pos[1],O.bodies[x].state.pos[2]])

 return getHighCon

where loc2glob is the index containing the spheres.
However this propably counts interractions with facets as well.
Is there a way to exclude those in the count?
Any help is much appreciated
Thanks
Best regards
John

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
Jérôme Duriez (jduriez) said :
#1

Hi,

To test whether a body is of spherical shape, you may use the general Python function isinstance (that checks whether a particular Python object is an instance of a particular class)

Example:

id = O.bodies.append(sphere(Vector3(0,0,0),1))
isinstance(O.bodies[id].shape,Sphere) # will return True

id = O.bodies.append(facet([Vector3(0,0,0),Vector3(0,1,0),Vector3(1,1,1)]))
isinstance(O.bodies[id].shape,Sphere) # will return False

Can you help with this problem?

Provide an answer of your own, or ask JOHN for more information if necessary.

To post a message you must log in.