← Back to team overview

yade-users team mailing list archive

[Question #634452]: A question about the function

 

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

Hello,
      I try to define a function to caculate the distance of the pheres after they  dropped the plank, but there are some error in my code, could someone can help me ? 
 Thanks a lot in advance.

  ZDJ
*******code *********
##makeCloud####

sp=pack.SpherePack()
sp.makeCloud((0,0,0.00025),(0.0027,0.01,0.00075),psdSizes=[0.0001, 0.00011, 0.00013, 0.00014, 0.00016, 0.00018,0.0002],psdCumm=[0, 0.1, 0.5, 0.8, 0.9, 0.95, 1],porosity=0.3)
sp.toSimulation(color=(0.8,0.8,0.8),material='steel')

###Function#####

def measureDis():
	for i in sp:  
		cz = i.state.pos[2]
		czmax = max(cz)
		czmin = min(cz)
		Dis = czmax - czmin
		if unbalancedForce() < 0.3:
		   print 'the distance is:',Dis

*******error in  screen *********

AttributeError                            Traceback (most recent call last)
/usr/bin/yade in <module>()

/usr/bin/yade in measureDis()
     65 def measureDis():
     66         for i in sp:
---> 67                 cz = i.state.pos[2]
     68                 czmax = max(cz)
     69                 czmin = min(cz)

AttributeError: 'tuple' object has no attribute 'state'

But when I change the code of function like this:

###Function#####

def measureDis():
	for i in sp:  
		cz = O.bodies(i).state.pos[2]
		czmax = max(cz)
		czmin = min(cz)
		Dis = czmax - czmin
		if unbalancedForce() < 0.3:
		   print 'the distance is:',Dis

The error is below 
*******error in  screen *********

TypeError                                 Traceback (most recent call last)
/usr/bin/yade in <module>()

/usr/bin/yade in measureDis()
     65 def measureDis():
     66         for i in sp:
---> 67                 cz = O.bodies(i).state.pos[2]
     68                 czmax = max(cz)
     69                 czmin = min(cz)

TypeError: 'BodyContainer' object is not callable


What should I do to  correct it ? Thanks again.


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