Number of neighbouring sphere particles

Asked by JOHN

Good evening,
I was wondering, is there a way to count the number of immediate neighbours (or neighbours within a distance) of a particle?
What i had come up with was a position comparison, but since there is an inbuilt collision detection which finds particles that are nearby, i thought there might be a better way
Thank you for your time
Cheers
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

Hello,

If your distance threshold matches the one used to define interactions in your YADE simulation you may simply use https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.InteractionContainer.withBody (and ask for the number of elements in the list returned by this function)

Jerome

Revision history for this message
JOHN (washingmachine) said :
#2

hello,
thank you for the answer. Unfortunately i would require a much bigger radius
Cheers
John

Revision history for this message
Jan Stránský (honzik) said :
#3

Hi John,
it pretty much depends on the definition of " immediate neighbours (or neighbours within a distance)". Below there is a simple script counting with distance of centers (regardless particle size)
cheers
Jan

##############################
dist = 3.5 # distance to find "neighbors"

# creates bodies
bodies = (
   sphere(( 0,0,0),1),
   sphere((+5,0,0),1),
   sphere((-3,0,0),1),
)
O.bodies.append(bodies)

# save bodies to SpherePack
sp = SpherePack()
sp.fromSimulation()

# use the data in a separate simulation
O.switchScene()
sp.toSimulation()
for b in O.bodies:
   b.shape.radius = .5*dist
O.dt = 0.
O.engines = [
   InsertionSortCollider([Bo1_Sphere_Aabb()],verletDist=0.),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()],
   )
]
O.step() # create interactions
print len(O.bodies[0].intrs()) # number of interactions (neighbors) [1]

O.switchScene() # return back to original simulation
##############################

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Body.intrs

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.