export final position of spheres from 'Bounching sphere'

Asked by Mamun Al-Siraj on 2019-02-20

Hi there,

I am very new to yade.
I am running the example problem of 'Bounching sphere'.
I want to extract the final positions of the sphere after
they come in rest.
here is my code:

# basic simulation showing sphere falling ball gravity,
# bouncing against another sphere representing the support

# import yade modules that we will use below
from yade import export, plot
# DATA COMPONENTS

# add 2 particles to the simulation
# they the default material (utils.defaultMat)
O.bodies.append([
 # fixed: particle's position in space will not change (support)
 sphere(center=(0,0,0),radius=.5,fixed=True),
 # this particles is free, subject to dynamics
 sphere((0,0,2),.5)
])

url = '/home/al_siraj/yade_STUFF/tutorials'

# FUNCTIONAL COMPONENTS

# simulation loop -- see presentation for the explanation
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom()], # collision geometry
  [Ip2_FrictMat_FrictMat_FrictPhys()], # collision "physics"
  [Law2_ScGeom_FrictPhys_CundallStrack()] # contact law -- apply forces
 ),
 # Apply gravity force to particles. damping: numerical dissipation of energy.
 NewtonIntegrator(gravity=(0,0,-9.81),damping=0.1)
 # printing the data files
 textExt('lets_see.txt',format='x_y_z_r',comment='Final state of the spheres')
 #VTKExporter(fileName=url+'/3d-vtk-',ascii=True,recorders=['spheres'],iterPeriod=100)
]

# set timestep to a fraction of the critical timestep
# the fraction is very small, so that the simulation is not too fast
# and the motion can be observed
O.dt=.5e-4*PWaveTimeStep()
# exporting the final position
# save the simulation, so that it can be reloaded later, for experimentation
O.saveTmp()

-------------------
After exporting, i see always the initial positions of spheres are exported. Is there any way it is
possible to export the final positions of sphere as text file? I have tried other options in export module but was not successful. Any help would be appreciated.

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-02-20
Last query:
2019-02-20
Last reply:
2019-02-20
Best Jan Stránský (honzik) said : #1

Hello,

> I am very new to yade.

welcome :-)

> After exporting, i see always the initial positions of spheres are exported.

Please, provide a working code. I have tried your and got SyntaxError at textExt. If I correct it by adding comma after NewtonIntegrator, I get "NameError: name 'textExt' is not defined".

> I want to extract the final positions of the sphere after they come in rest.
> Is there any way it is possible to export the final positions of sphere as text file?

of course it is possible :-) see below. Personally I see a bigger problem in the definition of "the rest".

> I have tried other options in export module but was not successful.

please always try to be specific enough, i.e.:
- what other options have you tried (other than what? see my first comment)
- what "was not successful" mean? Some error? Again initial position saved? ...?

You can try e.g. (your code without comments and the problematic part in O.engines):
###
from yade import export, plot

O.bodies.append([
 sphere(center=(0,0,0),radius=.5,fixed=True),
 sphere((0,0,2),.5)
])

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 NewtonIntegrator(gravity=(0,0,-9.81),damping=0.1),
]

O.dt=.5*PWaveTimeStep()

# this is new, running and exporting part
O.run(5000,True) # instead of 5000 you can put different value
export.textExt('lets_see.txt',format='x_y_z_r',comment='Final state of the spheres')
###

cheers
Jan

Mamun Al-Siraj (mamoon1834) said : #2

Thanks Jan Stránský, that solved my question.

Mamun Al-Siraj (mamoon1834) said : #3

Hahha, Nice... I figured this comma error after posting it
and also I was exporting data as vtk file but your solution
is nicer.