from yade import utils,pack,timing #O.bodies.append([ utils.sphere((0.2,0,0),.5,fixed=True), utils.sphere((0.2,0.0,1.01),.5), ]) O.bodies.append(pack.regularHexa(pack.inAlignedBox((0,0,0),(10,10,1)),radius=.5,gap=0,fixed=True)) O.bodies.append(pack.regularOrtho(pack.inAlignedBox((3,3,3),(7,7,4)),radius=.05,gap=0)) O.engines=[ ForceResetter(), FlatGridCollider(step=.2,aabbMin=(0,0,0),aabbMax=(10,10,5),verletDist=0.005), # InsertionSortCollider([Bo1_Sphere_Aabb()],sweepLength=0.005), InteractionLoop( [Ig2_Sphere_Sphere_Dem3DofGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_Dem3DofGeom_FrictPhys_CundallStrack()], ), NewtonIntegrator(damping=0.4,gravity=[0,0,-10]), ] O.dt=.6*utils.PWaveTimeStep() O.saveTmp() #O.step() #while True: # O.step() # if len(O.interactions)>0 or O.bodies[1].state.pos[2]<.97: break print('This will take a while, drink a coffee ;)') O.timingEnabled=True O.run(5000,True) timing.stats() import sys #sys.exit(0)
# this script demonstrates how to benchmark using timingEnabled: how to measure how much time each module takes. from yade import pack, timing #O.bodies.append([ sphere((0.2,0,0),.5,fixed=True), sphere((0.2,0.0,1.01),.5), ]) O.bodies.append( pack.regularHexa(pack.inAlignedBox((0, 0, 0), (10, 10, 1)), radius=.5, gap=0, fixed=True)) O.bodies.append( pack.regularOrtho(pack.inAlignedBox((3, 3, 3), (7, 7, 4)), radius=.05, gap=0)) O.engines = [ ForceResetter(), FlatGridCollider(step=.2, aabbMin=(0, 0, 0), aabbMax=(10, 10, 5), verletDist=0.005), # InsertionSortCollider([Bo1_Sphere_Aabb()],sweepLength=0.005), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()], ), NewtonIntegrator(damping=0.4, gravity=[0, 0, -10]), ] O.dt = .6 * PWaveTimeStep() O.saveTmp() #O.step() #while True: # O.step()
kwMeshes={'color':[1,1,0],'wire':True,'dynamic':False,'material':0} O.bodies.append( pack.regularHexa( (pack.inSphere((0,0,4),2)-pack.inSphere((0,-2,5),2)) & pack.notInNotch(centerPoint=(0,0,4),edge=(0,1,0),normal=(-1,1,-1),aperture=.2) ,radius=rad,gap=gap,color=(0,1,0),material=0) # head +[utils.sphere((.8,1.9,5),radius=.2,color=(.6,.6,.6),material=0),utils.sphere((-.8,1.9,5),radius=.2,color=(.6,.6,.6),material=0),utils.sphere((0,2.4,4),radius=.4,color=(1,0,0),material=0)] # eyes and nose +pack.regularHexa(pack.inCylinder((-1,2.2,3.3),(1,2.2,3.3),2*rad),radius=rad,gap=gap/3,color=(0.929,0.412,0.412),material=0) #mouth ) groundId=O.bodies.append(utils.facet([(12,0,-6),(0,12,-6,),(-12,-12,-6)],dynamic=False)) # ground for part in [ pack.regularHexa ( pack.inAlignedBox((-2,-2,-2),(2,2,2))-pack.inCylinder((0,-2,0),(0,2,0),1), radius=1.5*rad,gap=2*gap,color=(1,0,1),**kw), # body, pack.regularOrtho(pack.inEllipsoid((-1,0,-4),(1,1,2)),radius=rad,gap=0,color=(0,1,1),**kw), # left leg pack.regularHexa (pack.inCylinder((+1,1,-2.5),(0,3,-5),1),radius=rad,gap=gap,color=(0,1,1),**kw), # right leg pack.regularHexa (pack.inHyperboloid((+2,0,1),(+6,0,0),1,.5),radius=rad,gap=gap,color=(0,0,1),**kw), # right hand pack.regularOrtho(pack.inCylinder((-2,0,2),(-5,0,4),1),radius=rad,gap=gap,color=(0,0,1),**kw) # left hand ]: O.bodies.appendClumped(part) # Example of geom.facetBox usage oriBody = Quaternion(Vector3(0,0,1),(math.pi/3)) O.bodies.append(geom.facetBox((12,0,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes)) oriBody = Quaternion(Vector3(0,0,1),(math.pi/2)) O.bodies.append(geom.facetBox((0,12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes)) oriBody = Quaternion(Vector3(0,0,1),(math.pi)) O.bodies.append(geom.facetBox((-12,-12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
0, 12, -6, ), (-12, -12, -6)], dynamic=False)) # ground for part in [ pack.regularHexa(pack.inAlignedBox( (-2, -2, -2), (2, 2, 2)) - pack.inCylinder((0, -2, 0), (0, 2, 0), 1), radius=1.5 * rad, gap=2 * gap, color=(1, 0, 1), **kw), # body, pack.regularOrtho(pack.inEllipsoid((-1, 0, -4), (1, 1, 2)), radius=rad, gap=0, color=(0, 1, 1), **kw), # left leg pack.regularHexa(pack.inCylinder((+1, 1, -2.5), (0, 3, -5), 1), radius=rad, gap=gap, color=(0, 1, 1), **kw), # right leg pack.regularHexa(pack.inHyperboloid((+2, 0, 1), (+6, 0, 0), 1, .5), radius=rad, gap=gap, color=(0, 0, 1), **kw), # right hand pack.regularOrtho(pack.inCylinder((-2, 0, 2), (-5, 0, 4), 1), radius=rad, gap=gap,
poisson=0.5, frictionAngle=radians(3), density=2600, label='spheres')) O.materials.append( FrictMat(young=young, poisson=0.5, frictionAngle=0, density=0, label='walls')) walls = aabbWalls([mn, mx], thickness=0, material='walls') wallIds = O.bodies.append(walls) O.bodies.append( pack.regularOrtho(pack.inAlignedBox(mn, mx), radius=rad, gap=-1e-8, material='spheres')) print('num bodies ', len(O.bodies)) ThermalEngine = ThermalEngine(dead=1, label='thermal') newton = NewtonIntegrator(damping=0.2) intRadius = 1 O.engines = [ ForceResetter(), InsertionSortCollider( [Bo1_Sphere_Aabb(aabbEnlargeFactor=intRadius), Bo1_Box_Aabb()]), InteractionLoop([ Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=intRadius),