kw={'material':0} kwBoxes={'color':[1,0,0],'wire':False,'dynamic':False,'material':0} 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))
from woo import log, utils, pack, timing #log.setLevel('FlatGridCollider',log.TRACE) #O.bodies.append([ utils.sphere((0.2,0,0),.5,dynamic=False), 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, dynamic=False)) 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()], ), GravityEngine(gravity=[0, 0, -10]), NewtonIntegrator(damping=0.4), ] O.dt = .6 * utils.PWaveTimeStep() O.saveTmp() #O.step() #while True:
] # 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
from woo import * from woo.core import * from woo.dem import * from minieigen import * from woo import pack,log import woo log.setLevel('PeriIsoCompressor',log.DEBUG) """Simple script to create tunnel with random dense packing of spheres. The tunnel is difference between an axis-aligned box and cylinder, or which axis is going through the bottom wall (-z) of the box. The tunnel hole is oriented along +y, the face is in the xz plane. The first you run this scipt, a few minutes is neede to generate the packing. It is saved in /tmp/triaxPackCache.sqlite and at next time it will be only loaded (fast). """ # set some geometry parameters: domain box size, tunnel radius, radius of particles boxSize=Vector3(5,8,5) tunnelRad=2 rSphere=.1 # construct spatial predicate as difference of box and cylinder: # (see scripts/test/pack-predicates.py for details) pred=pack.inAlignedBox((-.5*boxSize[0],-.5*boxSize[1],0),(.5*boxSize[0],.5*boxSize[1],boxSize[2])) - pack.inCylinder((-.5*boxSize[0],0,0),(.5*boxSize[0],0,0),tunnelRad) # Use the predicate to generate sphere packing inside pack.randomDensePack(pred,radius=rSphere,rRelFuzz=.3,memoizeDb='/tmp/triaxPackCache.sqlite',spheresInCell=3000).toSimulation(woo.master.scene) from woo import qt qt.Controller() qt.View()
from woo import pack,plot # the "if 0:" block will be never executed, therefore the "else:" block will be # to use cloud instead of regular packing, change to "if 1:" or something similar if 0: # create cloud of spheres and insert them into the simulation # we give corners, mean radius, radius variation sp=pack.SpherePack() sp.makeCloud((0,0,0),(2,2,2),rMean=.1,rRelFuzz=.6,periodic=True) # insert the packing into the simulation sp.toSimulation(color=(0,0,1)) # pure blue else: # in this case, add dense packing O.bodies.append( pack.regularHexa(pack.inAlignedBox((0,0,0),(2,2,2)),radius=.1,gap=0,color=(0,0,1)) ) # create "dense" packing by setting friction to zero initially O.materials[0].frictionAngle=0 # simulation loop (will be run at every step) O.engines=[ ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb()]), InteractionLoop( [Ig2_Sphere_Sphere_L3Geom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_L3Geom_FrictPhys_ElPerfPl()] ), NewtonIntegrator(damping=.4),
log.setLevel('PeriIsoCompressor', log.DEBUG) """Simple script to create tunnel with random dense packing of spheres. The tunnel is difference between an axis-aligned box and cylinder, or which axis is going through the bottom wall (-z) of the box. The tunnel hole is oriented along +y, the face is in the xz plane. The first you run this scipt, a few minutes is neede to generate the packing. It is saved in /tmp/triaxPackCache.sqlite and at next time it will be only loaded (fast). """ # set some geometry parameters: domain box size, tunnel radius, radius of particles boxSize = Vector3(5, 8, 5) tunnelRad = 2 rSphere = .1 # construct spatial predicate as difference of box and cylinder: # (see scripts/test/pack-predicates.py for details) pred = pack.inAlignedBox( (-.5 * boxSize[0], -.5 * boxSize[1], 0), (.5 * boxSize[0], .5 * boxSize[1], boxSize[2])) - pack.inCylinder( (-.5 * boxSize[0], 0, 0), (.5 * boxSize[0], 0, 0), tunnelRad) # Use the predicate to generate sphere packing inside pack.randomDensePack(pred, radius=rSphere, rRelFuzz=.3, memoizeDb='/tmp/triaxPackCache.sqlite', spheresInCell=3000).toSimulation(woo.master.scene) from woo import qt qt.Controller() qt.View()
from woo import log,utils,pack,timing #log.setLevel('FlatGridCollider',log.TRACE) #O.bodies.append([ utils.sphere((0.2,0,0),.5,dynamic=False), 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,dynamic=False)) 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()], ), GravityEngine(gravity=[0,0,-10]), NewtonIntegrator(damping=0.4), ] 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 O.timingEnabled=True O.run(5000,True) timing.stats() import sys #sys.exit(0)