how to use class yade.wrapper.StepDisplacer((object)arg1)

Asked by Mahdeyeh

Dear all,
At first: I am beginner in YADE.

I have simulated clumps spherical particles.
I have modeled 3000 particles, I mean I have 3000 clumps.

I want to get as output (text or excel): If particles in specified range of my volume are moved, printing their positions continuous.
Because of having too many particles and then positions, I want to have just position of moved particles.
How I can get this aim?
I wrote this code: but I do not know how write code for : if particles moved .....

def positions():
    for b in O.bodies:
        if b.state.pos[0]>(2.9) and b.state.pos[0]<7 and b.state.pos[1]>4 and b.state.pos[1]<19: # flow zone

            iter0=O.iter
            Positions=open("Positions id iter x y.txt","a")
            Positions.write(repr(id)+' '+repr(iter0)+' '+repr(b.state.pos[0])+' '+repr(b.state.pos[1])+' '"\n")
            Positions.close()

O.engines=O.engines+[PyRunner(command='positions()',iterPeriod=300000,label="flow")]

And can I use for this purpose with this code: if yes how to use and write?
class yade.wrapper.StepDisplacer((object)arg1)

Many thanks for your help.
Best regards,

ubuntu : 18.04
yade 2018.02b

Question information

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

Hi,

> I want to get as output (text or excel):

In Python, direct excel output is possible. But text output is much much easier to do and if is is a "table", excel should load such file without problem.

> If particles ... are moved, printing their positions continuous.
> I want to have just position of moved particles.

What does "printing" mean?
What does "(positions) continuous" mean?
What does "moved (particles)" mean? Moved from the beginning of simulation? From last output? ... ? Changed position? Or also orientation? ... ?

Please be more specific what and why you want.

> How I can get this aim?
> but I do not know how write code for : if particles moved .....

depends on definition of "moved" (see above) and actual purpose (which is not clear)

> Because of having too many particles and then positions ...

Why is the amount a problem? 3000 does not sound as too many..

> StepDisplacer

StepDisplacer has different purpose. According to docs [1], it "applies displacement".

Cheers
Jan

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

Revision history for this message
Mahdeyeh (mahdiye.sky) said :
#2

Thanks Jan

> What does "printing" mean?
I mean having their position as output.

> What does "moved (particles)" mean? Moved from the beginning of simulation? From last output? ... ? Changed position? Or also orientation? ... ?
I mean changed position or orientation.

> Why is the amount a problem? 3000 does not sound as too many..
Maybe because of my computer.

> According to docs [1], it "applies displacement".
Any example for this? please..

I want write a code that says: if particles moved from ex-position so give their id and new position of everyone.
Because I want to draw shape`s moving of every particle in plot or diagram. And at the end, achieve to shape`s moving of hole body.

Best regards,

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

TL;TR:
I do not understand what you want to achieve.
I do not understand why outputting position of all particles is a problem. You can filter it afterwards, much easier than polluting the simulation.

>> What does "moved (particles)" mean? Moved from the beginning of simulation? From last output? ... ? Changed position? Or also orientation? ... ?
> I mean changed position or orientation.

Moved from the beginning of simulation? From last output? ... ?

>> Why is the amount a problem? 3000 does not sound as too many..
> Maybe because of my computer.

Why is the amount a problem? What are the symptoms?
What you do with the output that it is problematic?

> I want write a code that says: if particles moved from ex-position so give their id and new position of everyone.

sorry, it is still very unclear.. I really don't know how to read and understand the sentence :-(

> Because I want to draw shape`s moving of every particle in plot or diagram. And at the end, achieve to shape`s moving of hole body.

I don't understand the usecase (maybe that is the problem).
What is "plot or diagram"? How should it look? Picture of deformed shape? Some polar diagram of displacements? ... ?
What is "every particle"? individual particles? only clumps?
What is "whole body"?
Do you have some examples to share?

Are you aware of tools like Paraview?
Is regular exporting of the simulation into paraview and then visualizing it in Paraview what you want? Why not?

>> According to docs [1], it "applies displacement".
> Any example for this? please..

I do not have any experience with it, but a simple example could be:
###
s1 = sphere((0,0,0),1)
s2 = sphere((5,0,0),1)
O.bodies.append((s1,s2))
displacer = StepDisplacer(mov=(1,1,1)) # can also be used inside O.engines
O.step()
print("0",s1.state.pos,s2.state.pos)

displacer.ids = [0] # only apply 1st body
displacer() # run displacer
O.step()
print("1",s1.state.pos,s2.state.pos)

O.step()
print("2",s1.state.pos,s2.state.pos)

displacer.ids = [0,1] # both bodies
displacer() # run displacer
O.step()
print("3",s1.state.pos,s2.state.pos)

O.step()
print("4",s1.state.pos,s2.state.pos)
###

with output:
0 Vector3(0,0,0) Vector3(5,0,0)
1 Vector3(1,1,1) Vector3(5,0,0)
2 Vector3(1,1,1) Vector3(5,0,0)
3 Vector3(2,2,2) Vector3(6,1,1)
4 Vector3(2,2,2) Vector3(6,1,1)

Cheers
Jan

Revision history for this message
Mahdeyeh (mahdiye.sky) said :
#4

Thank you for example .

> Moved from the beginning of simulation? From last output? ... ?
both of them! Moved from the beginning of simulation and also From last output.

> What is "plot or diagram"? How should it look? Picture of deformed shape? Some polar diagram of displacements? ... ?
I want = Some polar diagram of displacements.

> What is "every particle"? individual particles? only clumps?
Only clumps.

> What is "whole body"?
all of clumps. All 3000 clumps in model.

> Do you have some examples to share?
I do not know how to share one image.

> Are you aware of tools like Paraview?
> Is regular exporting of the simulation into paraview and then visualizing it in Paraview what you want? Why not?
yes, I use Paraview but I did n`t check this item ( Some polar diagram of displacements) in it.

Thanks for your time
Best regards,

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

Thanks, now it starts to take some shapes :-)

> I do not know how to share one image.

not ideal, but you can put the image on the internet (dropbox, google drive, ...) and share a link

It definitely is possible to output position / displacement of only clumps that had moved.
You have to store "last" positions in an array / dictionary, compare the current positions, identify which clumps had moved and output only those.
However, it seems to me complicated to do the output (compared to the proposal below), potentially introducing some bug / error.
Moreover, the partial data may be source of further complications in the postprocessing stage and the reconstruction may not be trivial.

I would always output position/displacement of all clumps.
The output is one / a few lines of code.
Once having the data, you can always easily do differences between any times (from beginning, from last output, ...)
Or do I miss something?

Cheers
Jan

Revision history for this message
Mahdeyeh (mahdiye.sky) said :
#6

>I would always output position/displacement of all clumps.
>The output is one / a few lines of code.
>Once having the data, you can always easily do differences between any times (from beginning, from last output, ...)

This seems good idea. I will try. Thanks

And what about Paraview as you said. Can I have polar diagram of displacements?

Revision history for this message
Launchpad Janitor (janitor) said :
#7

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

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

> And what about Paraview as you said. Can I have polar diagram of displacements?

I would be surprised if not, but I would use a different tool, such as gnuplot or python matplotlib.

Cheers
Jan