New question #677994 on Yade:
https://answers.launchpad.net/yade/+question/677994

hi,
i have wrote a program of bouncing ball on the soil and i want to save the 
height of sphere in each time step in a file 'height.txt'
the problem is that the script does not  calculate the heights and the  time 
step .
my code is:

#!/usr/bin/python
# coding: utf-8

from numpy import*
from yade import plot
 
""" add the particule to simulation """
O.bodies.append([utils.sphere((0,0,2),.5)])

""" add a wall to simulation """
O.bodies.append([utils.wall(-1,axis=2)])


O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
   InteractionLoop(
       [Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_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)
 ]

#fixing step time
O.dt=.5e-4*utils.PWaveTimeStep()

# save the simulation
O.saveTmp()

""" open file"""
fil=open('height.txt', 'w') 
fil.write('%e %e\n' % (t/T, height))

""" print the sphere's height """
def height_sphr():
    h = [O.bodies.state.pos[2]]
    fil.write('%d, %.4f\n' % (O.iter,h))

fil.close()


Any ideas why it doesn't work?

Thanks in advance,

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to