tracking a particle

Asked by Alireza Sadeghi

Hello All,

I have another question.

How can I track an specific particle during the deformation?
Thank you.

Best Regards

Alireza

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Alireza Sadeghi
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

there are several options. E.g. storing the position by PyRunner.
You can store the values in separate variable or using plot module [1]

A MWE:
###
from yade import plot

O.bodies.append(sphere((0,0,0),1))
O.engines = [
   ForceResetter(),
   NewtonIntegrator(gravity=(0,0,-10)),
   PyRunner(iterPeriod=10,command="trackParticle()"),
]

def trackParticle():
   b = O.bodies[0]
   pos = b.state.pos
   plot.addData(i=O.iter,pos=pos)

O.dt = 1e-2
O.run(100,True)
print plot.data["pos_z"]
###

cheers
Jan

[1] https://yade-dev.gitlab.io/trunk/user.html#tracking-variables

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#2

Hello Jan,

Thank you very much for your response and help.

Best Regards

Alireza

Revision history for this message
Vasileios Angelidakis (vsangelidakis) said :
#3

For visual inspections you could also highlight it, to track its position in real-time, using:

###
O.bodies[id].shape.highlight=True
###

or color it differently from the other particles with:

###
O.bodies[id].shape.color=[0,255,0] # for a green particle
###

All the best,

Vasileios

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#5

Dear Vasileios and Dear Mina,

Thank you very much for your help.

Best Regards

Alireza