exporting the file of properties of spheres in simulation

Asked by yashar1876

Hello everyone,
   Thanks a lot about your attention for answering;
I try to find special spheres from simulation, also interested the probe the way for searching properties of spheres. my question is about ideal frame work that is there the way for exporting a file of properties of spheres of simulation (for example x,y,z,r) in originate of coordinate in frame of .txt file or like these?

          regard, Yashar.

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

There are plenty ways to do that, yes.
I suggest to first clarify which data you need, and for instance to write a loop to print it in the terminal:
for b in O.bodies:
    print b.state.pos[0], b.state.pos[1], b.state.pos[2], b.material.friction, etc.

When it has the shape you want you do exactly the same but writing to a file.
I hope it helps.

Bruno

Revision history for this message
Hien N.G. NGUYEN (rin) said :
#2

I would like to add more details to Bruno's answer on how to save to external file.
In Python/YADE you can use the command WRITE(), let's say you create a variable 'a' to store your data's info:

a=open('allinfo','w') #allinfo is the name of the file, w is write permission

Then do the loop as Bruno mentioned:

for b in O.bodies:
  a.write(str(b.state.pos[0]), str(b.state.pos[1]), str(b.state.pos[2])+'\n')

a.close() #close the file

Check in the folder where you launch this script, the file should be 'allinfo' which contains the data you need, line by line. Then load it in to excel or matlab or whatever for post processing.

My other advice is to save anyway the full model (xml.gz) so that you can recall more data later on. You won't know what data you'll need more in the future, better save them all.
Anyway keeping the data as txt/csv is a good idea, since maybe you can work with it in Windows other time. This might be not ideal but that's what I did during my thesis and it's just fine.

Hien.

Revision history for this message
yashar1876 (yashar1876) said :
#4

Thanks Hien N.G. NGUYEN (rin) and Bruno Chareyre, that solved my question. For next step, I want to export a specific series of spheres into the a .txt file, Please you guide me.
Thanks a lot for attention, Yashar.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#5

Thanks for details Hien.

> My other advice is to save anyway the full model (xml.gz)

Sorry but... the "xml.gz" part is a very bad advice ;)
"yade.gz" will reduce time and size big time. There is no reason to use xml.
B

Can you help with this problem?

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

To post a message you must log in.