← Back to team overview

yade-users team mailing list archive

[Question #688070]: save the evolution of the average kinetic energy of the grains and their average distance

 

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

hello, i wrote a code python of periodic inclined channel and i want to save the evolution of the average kinetic energy of the grains and their average distance every 500 period. when i open the file i found that kineticenergy=2 ( maximum value )during all simulation. this is my code:
#!/usr/bin/python
#Import libraries
from yade import qt ,plot

# load the initial congiguration
O.load('/home/hafsa/doctorat d1/init_channel_40w.yade.gz')

#Inclination angle of the channel slope
slope=35

#Evolution of the kinetic energies of the flow over the average distance traveled by the grains.
n=7200 # number of spheres 

# interactions
O.engines=O.engines+[NewtonIntegrator(damping=0.2, gravity=Vector3(-1*sin(slope),0.0,-1*cos(slope)), label='newtonIntegr'),
    PyRunner(iterPeriod=500,command='AddData()'),#save every 500 periode of simulation
    PyRunner(iterPeriod=23607,command='Data()'),# end of simulation
 ]

""" open file"""
fil=open('inclined_channel_40w_.dat', 'w')
fil.write('#Ec\t x \n')

def AddData():
    x_g=0
    for b in O.bodies:
	if isinstance(b.shape,Sphere) and b.shape.radius==0.5:
                plot.addData(i=O.iter,e=kineticEnergy()/n,**O.energy) #energy kenetic
        	x_g=x_g+b.state.pos[0]
    fil.write('%d   %.3f\n' % (e,x_g/n))

#saving simulation
def Data():
    O.save('/home/hafsa/doctorat d1/inclined_channel_40w.yade.gz')

#Timestep
O.dt=.1e-2
O.run(23707)
qt.View()
#utils.waitIfBatch()

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