~yade-dev/yade/0.80

« back to all changes in this revision

Viewing changes to examples/ResetRandomPosition.py

  • Committer: Anton Gladky
  • Date: 2012-05-02 21:50:42 UTC
  • Revision ID: gladky.anton@gmail.com-20120502215042-v1fa9r65usqe7kfk
0.80.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8
 
2
 
 
3
""" THIS SCRIPT IS NOT WORKING!
 
4
ERROR MESSAGE:
 
5
 
 
6
Running script ResetRandomPosition.py                                                                                                
 
7
Traceback (most recent call last):                                                                                                   
 
8
  File "/home/me/YADE/YADE3041/bin/yade-bzr3041", line 182, in runScript                                                             
 
9
    execfile(script,globals())                                                                                                       
 
10
  File "ResetRandomPosition.py", line 31, in <module>                                                                                
 
11
    plnIds=O.bodies.append(pack.gtsSurface2Facets(pln.faces(),material=facetMat,color=(0,1,0)))                                      
 
12
  File "/home/me/YADE/YADE3041/lib/yade-bzr3041/py/yade/pack.py", line 179, in gtsSurface2Facets                                     
 
13
    return [utils.facet([v.coords() for v in face.vertices()],**kw) for face in surf.faces()]                                        
 
14
AttributeError: 'tuple' object has no attribute 'faces'
 
15
"""
 
16
 
 
17
from yade import utils,pack,export,qt
 
18
import gts,os
 
19
 
 
20
def Plane(v1,v2,v3,v4):
 
21
        pts = [ [Vector3(v1),Vector3(v2),Vector3(v3),Vector3(v4)] ]
 
22
        return pack.sweptPolylines2gtsSurface(pts,capStart=True,capEnd=True)
 
23
 
 
24
# Parameters
 
25
tc=0.001# collision time 
 
26
en=0.3  # normal restitution coefficient
 
27
es=0.3  # tangential restitution coefficient
 
28
frictionAngle=radians(35)# 
 
29
density=2700
 
30
kw=utils.getViscoelasticFromSpheresInteraction(tc,en,es)
 
31
params=utils.getViscoelasticFromSpheresInteraction(tc,en,es)
 
32
# facets material
 
33
facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,**params)) 
 
34
# default spheres material
 
35
dfltSpheresMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle,**params))
 
36
 
 
37
O.dt=.2*tc # time step
 
38
 
 
39
Rs=0.02 # mean particle radius
 
40
Rf=0.01 # dispersion (Rs±Rf*Rs)
 
41
nSpheres=1000# number of particles
 
42
 
 
43
# Create geometry
 
44
pln=Plane( (-.5, -.5, 0), (.5, -.5, -.05), (.5, .5, 0), (-.5, .5, -.05) ); 
 
45
plnIds=O.bodies.append(pack.gtsSurface2Facets(pln,material=facetMat,color=(0,1,0)))
 
46
 
 
47
fct=Plane( (-.25, -.25, .5), (.25, -.25, .5), (.25, .25, .5), (-.25, .25, .5) ); 
 
48
fctIds=O.bodies.append(pack.gtsSurface2Facets(fct,material=facetMat,color=(1,0,0),noBound=True))
 
49
 
 
50
# Create spheres
 
51
sp=pack.SpherePack(); 
 
52
sp.makeCloud(Vector3(-.5, -.5, 0),Vector3(.5, .5, .2), Rs, Rf, int(nSpheres), False)
 
53
spheres=O.bodies.append([utils.sphere(s[0],s[1],color=(0.929,0.412,0.412),material=dfltSpheresMat) for s in sp])
 
54
 
 
55
# Create engines
 
56
O.engines=[
 
57
        ForceResetter(),
 
58
        InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
 
59
        InteractionLoop(
 
60
                [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
 
61
                [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
 
62
                [Law2_ScGeom_ViscElPhys_Basic()],
 
63
        ),
 
64
        NewtonIntegrator(damping=0,gravity=[0,0,-9.81]),
 
65
        ResetRandomPosition(virtPeriod=0.01,factoryFacets=fctIds,velocity=(0,0,-2),subscribedBodies=spheres,point=(0,0,-.5),normal=(0,0,1),maxAttempts=100),
 
66
]
 
67
 
 
68
renderer = qt.Renderer()
 
69
qt.View()
 
70
O.saveTmp()
 
71
O.run()
 
72
 
 
73