← Back to team overview

yade-users team mailing list archive

Re: [Question #269942]: How calculate the repose angle

 

Question #269942 on Yade changed:
https://answers.launchpad.net/yade/+question/269942

    Status: Open => Answered

Christian Jakob proposed the following answer:
Hi,

I had the same problem some years ago. I used pythons scatter function for this purpose. 
You need to give some input data at the beginning of the script and it should work (not tested).
A scatter-plot window should open and you can get the angle by clicking at two points in the window.
Here is the script:

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

center_model = Vector3(0,0,0)  #put the center of your model here

O.load(yourSaveFile)  #put the name of your save file here

outputFilename = 'yourOutputName.out'  #put your output filename here

height = []
rad_dist = []
for ii in range(0,len(O.bodies)):
	b = O.bodies[ii]
	if b and isinstance(b.shape,Sphere):
		pos = b.state.pos
		dist_vec = pos - center_model
		rad_dist.append(sqrt( (dist_vec[0])**2 + (dist_vec[1])**2 ))#get radial distance from center axis
		height.append(pos[2])	#get height and write into list

from pylab import *

scatter(rad_dist,height,marker='+')

data_for_angle = ginput(0,0)            #get the coordinates by clicking
two points, then click on the mouse wheel

zdiff = abs(data_for_angle[0][1] - data_for_angle[1][1])	#y entries of picked points (respectively spheres height)
rdiff = abs(data_for_angle[0][0] - data_for_angle[1][0])	#x entries of picked points (respectively spheres radial distance from center)

alpha = atan(zdiff/rdiff)
alpha = 180*alpha/math.pi	#in [°]

'''
	z	|-
	d	|  -
	i	|    -
	f	|    ( -	<- tan(alpha) = zdiff / rdiff
	f	----------
		 rdiff
'''

# print result and write output:
print 'angle of repose is ',alpha,' degree'

f = open(outputFilename,'a')
f.write('result for %s: %.2f degree\n' % (part,alpha))
f.close()
exit()

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.