def checkForce(): # at the very start, unbalanced force can be low as there is only few # contacts, but it does not mean the packing is stable if O.iter < 20000: return # the rest will be run only if unbalanced is < .1 (stabilized packing) timing.reset() if unbalancedForce() > 0.2: return # add plate at upper box side highSphere = 0.0 for b in O.bodies: if highSphere < b.state.pos[2] and isinstance(b.shape, Sphere): highSphere = b.state.pos[2] else: pass O.bodies.append( wall(highSphere + 0.5 * Diameter, axis=2, sense=-1, material=mat1)) # without this line, the plate variable would only exist inside this # function global plate plate = O.bodies[-1] # the last particles is the plate # Wall objects are "fixed" by default, i.e. not subject to forces # prescribing a velocity will therefore make it move at constant velocity # (downwards) plate.state.vel = (0, 0, -.1) # start plotting the data now, it was not interesting before O.engines = O.engines + [ PyRunner(command='addPlotData()', iterPeriod=1000) ] # next time, do not call this function anymore, but the next one # (unloadPlate) instead fCheck.command = 'unloadPlate()'
def checkForce(): # at the very start, unbalanced force can be low as there is only few # contacts, but it does not mean the packing is stable if O.iter < 20000: return # the rest will be run only if unbalanced is < .1 (stabilized packing) timing.reset() if unbalancedForce() > 0.2: return # add plate at upper box side highSphere = 0.0 for b in O.bodies: if highSphere < b.state.pos[2] and isinstance(b.shape, Sphere): highSphere = b.state.pos[2] else: pass O.bodies.append(wall(highSphere+0.5*Diameter, axis=2, sense=-1, material=mat1)) # without this line, the plate variable would only exist inside this # function global plate plate = O.bodies[-1] # the last particles is the plate # Wall objects are "fixed" by default, i.e. not subject to forces # prescribing a velocity will therefore make it move at constant velocity # (downwards) plate.state.vel = (0, 0, -.1) # start plotting the data now, it was not interesting before O.engines = O.engines + [PyRunner(command='addPlotData()', iterPeriod=1000)] # next time, do not call this function anymore, but the next one # (unloadPlate) instead fCheck.command = 'unloadPlate()'
O.engines = [ ForceResetter(), InsertionSortCollider([ Bo1_Sphere_Aabb(), Bo1_Facet_Aabb(), ]), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()], ), RotationEngine(rotateAroundZero=True, zeroPoint=(0, 0, 0), rotationAxis=(0, 1, 1), angularVelocity=30 * (2 * pi / 60), ids=cylIds, label='rotor'), NewtonIntegrator(damping=.3, gravity=( 0, 0, -1e3)), # gravity artificially high, to make it faster going ;-) ] O.dt = PWaveTimeStep() O.stopAtIter = int(2 * pi / (rotor.angularVelocity * O.dt)) O.timingEnabled = True timing.reset() from yade import qt qt.Controller() qt.View()
facet([[1,-1,0],[0,1,0,],[1,.5,.5]],fixed=True,material=mat) ]) import random if 1: for i in range(0,100): O.bodies.append(sphere([random.gauss(0,1),random.gauss(0,1),random.uniform(1,2)],random.uniform(.02,.05),material=mat)) O.bodies[len(O.bodies)-1].state.vel=Vector3(random.gauss(0,.1),random.gauss(0,.1),random.gauss(0,.1)) else: O.bodies.append(sphere([0,0,.6],.5),material=mat) O.dt=1e-4 O.saveTmp('init') # compare 2 colliders: if 1: O.timingEnabled=True from yade import timing for collider in InsertionSortCollider(),PersistentTriangulationCollider(haveDistantTransient=True): for i in range(2): O.loadTmp('init') replaceCollider(collider) O.run(100,True) timing.reset() O.run(50000,True) timing.stats() else: #O.run(100,True) O.step() print len(O.interactions) #O.bodies[2].phys['se3']=[-.6,0,.6,1,0,0,0] #O.step()
from yade import pack,timing cyl=unitCylinder(); sq=unitSquare(); sq.translate(0,0,-1); cyl.copy(sq) cyl.scale(cylRd,cylRd,.5*cylHt); cyl.rotate(1,0,0,-pi/4) # 45° anti-colckwise in the yz plane # calling gtsSurface2Facets with just "cyl" (without constructing the faces tuple) ignores 2 faces that were copy'd before; bug in pygts? cylIds=O.bodies.append(pack.gtsSurface2Facets(cyl)) sp=pack.SpherePack(); wd=cylRd*sqrt(2); rMean=(.2*wd*wd*cylHt/(nSpheres*(4/3.)*pi))**(1/3.) print('Generating cloud…') sp.makeCloud((-wd/2,-wd/2,-.5*cylHt),(wd/2,wd/2,.5*cylHt),rMean,0,int(nSpheres),False) sp.rotate((1,0,0),-pi/4) O.bodies.append([sphere(s[0],s[1]) for s in sp]) O.engines=[ ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),]), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()], ), RotationEngine(rotateAroundZero=True,zeroPoint=(0,0,0),rotationAxis=(0,1,1),angularVelocity=30*(2*pi/60),ids=cylIds,label='rotor'), NewtonIntegrator(damping=.3,gravity=(0,0,-1e3)), # gravity artificially high, to make it faster going ;-) ] O.dt=PWaveTimeStep() O.stopAtIter=int(2*pi/(rotor.angularVelocity*O.dt)) O.timingEnabled=True; timing.reset() from yade import qt qt.Controller() qt.View()