clump-hopper-viscoelastic.py 2.94 KB
Newer Older
1 2
# -*- coding: utf-8

3
from builtins import range
4
from yade import pack,export,qt
5 6 7 8 9 10 11 12 13 14
import gts,os,random,itertools
from numpy import *

# Parameters
tc=0.001# collision time 
en=.3  # normal restitution coefficient
es=.3  # tangential restitution coefficient
frictionAngle=radians(35)# 
density=2700
# facets material
15
facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,tc=tc,en=en,et=es))
16
# default spheres material
17
dfltSpheresMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle,tc=tc,en=en,et=es)) 
18

Anton Gladky's avatar
Anton Gladky committed
19
O.dt=.05*tc # time step
20 21 22 23 24 25 26 27 28 29 30 31

Rs=0.05 # particle radius

# Create geometry

x0=0.; y0=0.; z0=0.; ab=.7; at=2.; h=1.; hl=h; al=at*3

zb=z0;   x0b=x0-ab/2.; y0b=y0-ab/2.; x1b=x0+ab/2.; y1b=y0+ab/2.
zt=z0+h; x0t=x0-at/2.; y0t=y0-at/2.; x1t=x0+at/2.; y1t=y0+at/2.
zl=z0-hl;x0l=x0-al/2.; y0l=y0-al/2.; x1l=x0+al/2.; y1l=y0+al/2.

left = pack.sweptPolylines2gtsSurface([[Vector3(x0b,y0b,zb),Vector3(x0t,y0t,zt),Vector3(x0t,y1t,zt),Vector3(x0b,y1b,zb)]],capStart=True,capEnd=True)
Anton Gladky's avatar
Anton Gladky committed
32
lftIds=O.bodies.append(pack.gtsSurface2Facets(left,material=facetMat,color=(0,1,0)))
33 34

right = pack.sweptPolylines2gtsSurface([[Vector3(x1b,y0b,zb),Vector3(x1t,y0t,zt),Vector3(x1t,y1t,zt),Vector3(x1b,y1b,zb)]],capStart=True,capEnd=True)
Anton Gladky's avatar
Anton Gladky committed
35
rgtIds=O.bodies.append(pack.gtsSurface2Facets(right,material=facetMat,color=(0,1,0)))
36 37

near = pack.sweptPolylines2gtsSurface([[Vector3(x0b,y0b,zb),Vector3(x0t,y0t,zt),Vector3(x1t,y0t,zt),Vector3(x1b,y0b,zb)]],capStart=True,capEnd=True)
Anton Gladky's avatar
Anton Gladky committed
38
nearIds=O.bodies.append(pack.gtsSurface2Facets(near,material=facetMat,color=(0,1,0)))
39 40

far = pack.sweptPolylines2gtsSurface([[Vector3(x0b,y1b,zb),Vector3(x0t,y1t,zt),Vector3(x1t,y1t,zt),Vector3(x1b,y1b,zb)]],capStart=True,capEnd=True)
Anton Gladky's avatar
Anton Gladky committed
41
farIds=O.bodies.append(pack.gtsSurface2Facets(far,material=facetMat,color=(0,1,0)))
42 43

table = pack.sweptPolylines2gtsSurface([[Vector3(x0l,y0l,zl),Vector3(x0l,y1l,zl),Vector3(x1l,y1l,zl),Vector3(x1l,y0l,zl)]],capStart=True,capEnd=True)
Anton Gladky's avatar
Anton Gladky committed
44
tblIds=O.bodies.append(pack.gtsSurface2Facets(table,material=facetMat,color=(0,1,0)))
45 46

# Create clumps...
47
clumpColor=(0.0, 0.5, 0.5)
48
for k,l in itertools.product(arange(0,10),arange(0,10)):
49
	clpId,sphId=O.bodies.appendClumped([sphere(Vector3(x0t+Rs*(k*4+2),y0t+Rs*(l*4+2),i*Rs*2+zt),Rs,color=clumpColor,material=dfltSpheresMat) for i in range(4)])
50 51

# ... and spheres
Anton Gladky's avatar
Anton Gladky committed
52 53
spheresColor=(0.4, 0.4, 0.4)
for k,l in itertools.product(arange(0,9),arange(0,9)):
54
	sphAloneId=O.bodies.append( [sphere( Vector3(x0t+Rs*(k*4+4),y0t+Rs*(l*4+4),i*Rs*2.3+zt),Rs,color=spheresColor,material=dfltSpheresMat) for i in range(4) ] )
55 56 57

# Create engines
O.engines=[
58
	ForceResetter(),
59
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
60
	InteractionLoop(
61
		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
62
		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
63
		[Law2_ScGeom_ViscElPhys_Basic()],
64
	),
Anton Gladky's avatar
Anton Gladky committed
65
	NewtonIntegrator(damping=0, gravity=[0,0,-9.81]),
66 67 68
	#VTKRecorder(virtPeriod=0.01,fileName='/tmp/',recorders=['spheres','velocity','facets'])
]

69
from yade import qt
70 71 72
qt.View()
O.saveTmp()