← Back to team overview

yade-users team mailing list archive

Re: [Question #682172]: Some particles move out of the boundary

 

Question #682172 on Yade changed:
https://answers.launchpad.net/yade/+question/682172

jamespaul posted a new comment:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from yade import pack,qt
import math

#material
sphere1=O.materials.append(FrictMat(young=6e6,poisson=0.3,density=2460,frictionAngle=float(atan(0.3)),label='sphere1'))
drum1=O.materials.append(FrictMat(young=6e10,poisson=0.3,density=2460,frictionAngle=float(atan(0.3)),label='drum1'))

#drum
drumradius=0.071
drumheight=0.005

Cylinder=O.bodies.append(geom.facetCylinder(center=(drumheight/2,drumradius*1.5,drumradius*1.5),radius=drumradius,height=drumheight*2,wallMask=4,orientation=Quaternion(Vector3(0,1,0),(pi/2.0)),segmentsNumber=24,color=(1,0,0),material='drum1'))

#generate spheres
pred1 = pack.inCylinder((-drumheight/2,drumradius*1.5,drumradius*1.5),(drumheight/2,drumradius*1.5,drumradius*1.5),drumradius*0.8)
sphs1 = pack.randomDensePack(pred1,radius=0.0006,material=sphere1,spheresInCell=3000)
O.bodies.append(sphs1)

#periodic box
O.periodic = True
O.cell.setBox(drumheight,3*drumradius,3*drumradius)

O.engines=[
   	ForceResetter(),
   	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()],allowBiggerThanPeriod=True),
   	InteractionLoop(
      		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],        
     		[Ip2_FrictMat_FrictMat_FrictPhys()], 
      		[Law2_ScGeom_FrictPhys_CundallStrack()]   
   	),
   	NewtonIntegrator(gravity=(0,0,-9.81),damping=0.1), 
   	PyRunner(command='motion()',virtPeriod=.2,nDo=2),  	
	PyRunner(command='addPlotData()',virtPeriod=.2), 
]

O.dt=.1*PWaveTimeStep()

qt.Controller()
O.saveTmp()
O.run()

def motion():   	       	
	O.engines += [RotationEngine(ids=Cylinder,rotationAxis=[1,0,0],rotateAroundZero=True,angularVelocity=1.77,zeroPoint=(0,drumradius*1.5,drumradius*1.5))];

#I erase the spheres which are move out of the cylinder and keep counting the total number of particles
def addPlotData():
	num=0
	for b in O.bodies:
		if isinstance(b.shape,Sphere): 
			num+=1
			if math.pow((b.state.pos[1]-drumradius*1.5),2)+math.pow((b.state.pos[2]-drumradius*1.5),2)>drumradius*drumradius:
				O.bodies.erase(b.id)

        print 'num=',num

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