← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2744: 1. Added shop.py. Like shop.cpp but in python not to make yade.utils too crowd

 

------------------------------------------------------------
revno: 2744
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Thu 2011-02-17 12:32:00 +0100
message:
  1. Added shop.py. Like shop.cpp but in python not to make yade.utils too crowd
  2. Added yade.geom and yade.shop to sphinx
  3. Some fixes in docs
  4. yade.shop.spheresPackDimensions is added with corresponding example in packs.py
added:
  doc/sphinx/yade.geom.rst
  doc/sphinx/yade.shop.rst
  py/shop.py
modified:
  doc/sphinx/yadeSphinx.py
  examples/packs/packs.py
  py/SConscript
  py/geom.py
  py/utils.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
=== added file 'doc/sphinx/yade.geom.rst'
--- doc/sphinx/yade.geom.rst	1970-01-01 00:00:00 +0000
+++ doc/sphinx/yade.geom.rst	2011-02-17 11:32:00 +0000
@@ -0,0 +1,9 @@
+.. _yade.geom:
+
+yade.geom module
+==========================================
+
+.. automodule:: yade.geom
+	:members:
+	:undoc-members:
+

=== added file 'doc/sphinx/yade.shop.rst'
--- doc/sphinx/yade.shop.rst	1970-01-01 00:00:00 +0000
+++ doc/sphinx/yade.shop.rst	2011-02-17 11:32:00 +0000
@@ -0,0 +1,9 @@
+.. _yade.shop:
+
+yade.shop module
+==========================================
+
+.. automodule:: yade.shop
+	:members:
+	:undoc-members:
+

=== modified file 'doc/sphinx/yadeSphinx.py'
--- doc/sphinx/yadeSphinx.py	2011-02-11 18:26:51 +0000
+++ doc/sphinx/yadeSphinx.py	2011-02-17 11:32:00 +0000
@@ -33,7 +33,7 @@
 #
 # don't forget to put the module in index.rst as well!
 #
-mods={'export':[],'eudoxos':['_eudoxos'],'log':[],'post2d':[],'pack':['_packSpheres','_packPredicates','_packObb','_packSpherePadder'],'plot':[],'timing':[],'utils':['_utils'],'ymport':[],'qt':['_qt','qt._GLViewer'],'linterpolation':[]}
+mods={'export':[],'eudoxos':['_eudoxos'],'log':[],'post2d':[],'pack':['_packSpheres','_packPredicates','_packObb','_packSpherePadder'],'plot':[],'timing':[],'utils':['_utils'],'ymport':[],'geom':[],'shop':[],'qt':['_qt','qt._GLViewer'],'linterpolation':[]}
 #
 # generate documentation, in alphabetical order
 mm=mods.keys(); mm.sort()

=== modified file 'examples/packs/packs.py'
--- examples/packs/packs.py	2011-01-13 10:21:10 +0000
+++ examples/packs/packs.py	2011-02-17 11:32:00 +0000
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
-from yade import pack,ymport,export,log,geom
+from yade import pack,ymport,export,log,geom,shop
 import math
 
 """ This script demonstrates how to use 2 components of creating packings:
@@ -66,12 +66,20 @@
 oriBody = Quaternion(Vector3(0,0,1),(math.pi/2))
 O.bodies.append(ymport.gmsh('cone.mesh',orientation=oriBody,**kwMeshes))#generates facets from the mesh file
 
+SpheresID=[]
 oriBody = Quaternion(Vector3(0,0,1),(math.pi/2))
-O.bodies.append(ymport.gengeoFile('LSMGenGeo.geo',shift=Vector3(-7.0,-7.0,0.0),scale=1.0,orientation=oriBody,color=(1,0,1),**kw))
+SpheresID+=O.bodies.append(ymport.gengeoFile('LSMGenGeo.geo',shift=Vector3(-7.0,-7.0,0.0),scale=1.0,orientation=oriBody,color=(1,0,1),**kw))
+
+#Demonstration of spheresPackDimensions function. The "Edge" particles are colored with blue color
+geometryParameters = shop.spheresPackDimensions(SpheresID)
+for v in [geometryParameters['minId'],geometryParameters['maxId']]:
+	for i in v:
+		O.bodies[int(i)].shape.color = Vector3(0,0,1)
+
 
 #facetBunker Demonstration
 #Demonstration of HarmonicMotionEngine
-vibrationPlate = O.bodies.append(geom.facetBunker((-7.0,-7.0,-3.0),dBunker=5.0,dOutput=3.0,hBunker=11.0,hOutput=1.5,hPipe=0.8,wallMask=5,segmentsNumber=20,**kwMeshes))
+vibrationPlate = O.bodies.append(geom.facetBunker((-7.0,-7.0,-3.0),dBunker=geometryParameters['extends'][0]*1.1,dOutput=3.0,hBunker=11.0,hOutput=1.5,hPipe=0.8,wallMask=5,segmentsNumber=20,**kwMeshes))
 
 # spheresToFile saves coordinates and radii of all spheres of the simulation into the text file, works but disabled. Please, uncomment it, if you need
 #print "Saved into the OutFile " + str (export.text("OutFile")) + " spheres";

=== modified file 'py/SConscript'
--- py/SConscript	2011-01-31 19:09:24 +0000
+++ py/SConscript	2011-02-17 11:32:00 +0000
@@ -27,6 +27,7 @@
 	env.File('utils.py'),
 	env.File('ymport.py'),
 	env.File('geom.py'),
+	env.File('shop.py'),
 	env.File('export.py'),
 	env.File('eudoxos.py'),
 	env.File('plot.py'),

=== modified file 'py/geom.py'
--- py/geom.py	2011-01-26 12:39:07 +0000
+++ py/geom.py	2011-02-17 11:32:00 +0000
@@ -144,25 +144,24 @@
 	"""
 	Create arbitrarily-aligned bunker, composed of facets, with given center, radii, heights and orientation.
 	Return List of facets forming the bunker;
-	
-	   dBunker
-	______________
-	|            |
-	|            |
-	|            | hBunker
-	|            |
-	|            |
-	|            |
-	|____________|
-	\            /
-	 \          /
-	  \        /   hOutput
-	   \      /
-	    \____/
-	    |    |
-	    |____|     hPipe
-	    dOutput
-	
+	::
+		   dBunker
+		______________
+		|            |
+		|            |
+		|            | hBunker
+		|            |
+		|            |
+		|            |
+		|____________|
+		\            /
+		 \          /
+		  \        /   hOutput
+		   \      /
+		    \____/
+		    |    |
+		    |____|     hPipe
+		    dOutput
 	
 	:param Vector3 center: center of the created bunker
 	:param float dBunker: bunker diameter, top

=== added file 'py/shop.py'
--- py/shop.py	1970-01-01 00:00:00 +0000
+++ py/shop.py	2011-02-17 11:32:00 +0000
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+# encoding: utf-8
+"""
+Miscillaneous functions, which are can be useful for simulation.
+"""
+
+from yade.wrapper import *
+from miniEigen import *
+import utils,math,numpy
+
+#spheresPackDimensions==================================================
+def spheresPackDimensions(idSpheres):
+	"""The function accepts the list of spheres idSpheres, and calculates max and min dimensions.
+
+	:param list idSpheres: list of spheres
+	
+	:return: dictionary with keys ``min`` (minimal dimension, Vector3), ``max`` (maximal dimension, Vector3), ``minId`` (minimal dimension sphere Id, Vector3), ``miaxnId`` (maximal dimension sphere Id, Vector3), ``center`` (central point of bounding box, Vector3), ``extends`` (sizes of bounding box, Vector3)
+	
+	"""
+	
+	try:
+		if (len(idSpheres)<2):
+			raise RuntimeError("Only a list of particles with length > 1 can be analyzed")
+	except TypeError:
+			raise TypeError("There should be list if ints")
+		
+	min = Vector3.Zero
+	max = Vector3.Zero
+	
+	minId = Vector3.Zero
+	maxId = Vector3.Zero
+	
+	counter = 0
+	
+		
+	for i in idSpheres:
+		spherePosition=O.bodies[i].state.pos
+		try:
+			sphereRadius=O.bodies[i].shape.radius	#skip non-spheres
+		except AttributeError: continue
+		
+		sphereRadiusVec3 = Vector3(sphereRadius,sphereRadius,sphereRadius)
+		
+		sphereMax = spherePosition + sphereRadiusVec3
+		sphereMin = spherePosition - sphereRadiusVec3
+		
+		for dim in range(0,3):
+			if ((sphereMax[dim]>max[dim]) or (counter==0)): 
+				max[dim]=sphereMax[dim]
+				maxId[dim] = i
+			if ((sphereMin[dim]<min[dim]) or (counter==0)): 
+				min[dim]=sphereMin[dim]
+				minId[dim] = i
+		counter += 1
+	
+	center = (max-min)/2.0+min
+	extends = max-min
+	
+	dimensions = {'max':max,'min':min,'maxId':maxId,'minId':minId,'center':center, 'extends':extends}
+	return dimensions
+	

=== modified file 'py/utils.py'
--- py/utils.py	2011-02-15 11:36:29 +0000
+++ py/utils.py	2011-02-17 11:32:00 +0000
@@ -83,7 +83,7 @@
 	return radius/sqrt(young/density)
 
 def randomColor():
-	"Return random Vector3 with each component in interval 0…1 (uniform distribution)"
+	"""Return random Vector3 with each component in interval 0…1 (uniform distribution)"""
 	return Vector3(random.random(),random.random(),random.random())
 
 def typedEngine(name):