← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2937: Add some more parameters to spheresPackDimensions

 

------------------------------------------------------------
revno: 2937
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Mon 2011-10-17 14:43:05 +0200
message:
  Add some more parameters to spheresPackDimensions
modified:
  py/bodiesHandling.py


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'py/bodiesHandling.py'
--- py/bodiesHandling.py	2011-10-17 08:45:13 +0000
+++ py/bodiesHandling.py	2011-10-17 12:43:05 +0000
@@ -15,7 +15,7 @@
 	:param list idSpheres: list of spheres
 	:param int mask: :yref:`Body.mask` for the checked bodies
 	
-	:return: dictionary with keys ``min`` (minimal dimension, Vector3), ``max`` (maximal dimension, Vector3), ``minId`` (minimal dimension sphere Id, Vector3), ``maxId`` (maximal dimension sphere Id, Vector3), ``center`` (central point of bounding box, Vector3), ``extends`` (sizes of bounding box, Vector3)
+	:return: dictionary with keys ``min`` (minimal dimension, Vector3), ``max`` (maximal dimension, Vector3), ``minId`` (minimal dimension sphere Id, Vector3), ``maxId`` (maximal dimension sphere Id, Vector3), ``center`` (central point of bounding box, Vector3), ``extends`` (sizes of bounding box, Vector3), ``volume`` (volume of spheres, Real), ``mass`` (mass of spheres, Real), ``number`` (number of spheres, int), 
 	
 	"""
 	idSpheresIter=[]
@@ -44,6 +44,8 @@
 	maxId = Vector3.Zero
 	
 	counter = 0
+	volume = 0.0
+	mass = 0.0
 	
 		
 	for i in idSpheresIter:
@@ -76,12 +78,15 @@
 				if ((sphereMin[dim]<min[dim]) or (counter==0)): 
 					min[dim]=sphereMin[dim]
 					minId[dim] = b.id
+			volume += 4.0/3.0*math.pi*sphereRadius*sphereRadius*sphereRadius
+			mass += b.state.mass
 			counter += 1
 	
 	center = (max-min)/2.0+min
 	extends = max-min
 	
-	dimensions = {'max':max,'min':min,'maxId':maxId,'minId':minId,'center':center, 'extends':extends}
+	dimensions = {'max':max,'min':min,'maxId':maxId,'minId':minId,'center':center,
+		'extends':extends, 'volume':volume, 'mass':mass, 'number':counter}
 	return dimensions
 
 #spheresPackDimensions==================================================