en = 0.3 es = 0.3 ## Materials params=utils.getViscoelasticFromSpheresInteraction(tc,en,es) facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs sphereMat=O.materials.append(ViscElMat(density=Density,frictionAngle=frictionAngle,**params)) ### Creating the Buldozer Knife ### from facets, using GTS Knife=[] for i in linspace(pi, pi*3/2, num=numKnifeParts, endpoint=True): Knife.append(Vector3(radiusKnife*cos(i),0,radiusKnife*sin(i))) KnifeP=[Knife,[p+Vector3(0,lengthKnife,0) for p in Knife]] KnifePoly=pack.sweptPolylines2gtsSurface(KnifeP,threshold=1e-4) KnifeIDs=O.bodies.append(pack.gtsSurface2Facets(KnifePoly,color=(1,0,0),wire=False,material=facetMat)) KnifeIDs+=O.bodies.append(geom.facetBox((-lengthKnife/2-radiusKnife,lengthKnife/2,-radiusKnife+buldozerHeight/2),(lengthKnife/2,lengthKnife/2,buldozerHeight/2.),wallMask=47,color=(0,1,0),wire=False)) KnifeIDs+=O.bodies.append(geom.facetBox((-lengthKnife/2-radiusKnife-lengthKnife/4.,lengthKnife/2,-radiusKnife+buldozerHeight*3./2.-buldozerHeight/4.),(lengthKnife/4.,lengthKnife/3.,buldozerHeight/4.),wallMask=47,color=(0,0,1),wire=False)) O.bodies.append(geom.facetBox((0,0,radiusKnife),(lengthKnife*3,lengthKnife*3,lengthKnife),wallMask=16,color=(1,1,1),wire=False,material=facetMat)) ### Creating the material for buldozer colorsph1=Vector3(120,234,150); colorsph2=Vector3(0,0,1); colorsph1.normalize(); colorsph2.normalize();
en=.3 # normal restitution coefficient es=.3 # tangential restitution coefficient frictionAngle=radians(35)# density=2700 # facets material params=utils.getViscoelasticFromSpheresInteraction(10e3,tc,en,es) facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs # default spheres material dfltSpheresMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle)) O.dt=.01*tc # time step Rs=0.1 # particle radius # Create geometry plnSurf = pack.sweptPolylines2gtsSurface([[Vector3(-.5,0,0),Vector3(.5,0,0),Vector3(.5, 0, -.5),Vector3(-.5, 0, -.5)]],capStart=True,capEnd=True) plnIds=O.bodies.append(pack.gtsSurface2Facets(plnSurf.faces(),material=facetMat,color=(0,1,0))) plnSurf1 = pack.sweptPolylines2gtsSurface([[Vector3(-.5,-.5,-.5),Vector3(.5,-.5,-.5),Vector3(.5, 1.5, -.5),Vector3(-.5, 1.5, -.5)]],capStart=True,capEnd=True) plnIds1=O.bodies.append(pack.gtsSurface2Facets(plnSurf1.faces(),material=facetMat,color=(0,1,0))) # Create clumps clpId,sphId=O.bodies.appendClumped([utils.sphere(Vector3(0,Rs*2*i,Rs*2),Rs,material=dfltSpheresMat) for i in xrange(4)]) for id in sphId: s=O.bodies[id] p=utils.getViscoelasticFromSpheresInteraction(s.state['mass'],tc,en,es) s.mat['kn'],s.mat['cn'],s.mat['ks'],s.mat['cs']=p['kn'],p['cn'],p['ks'],p['cs'] # Create engines O.engines=[ ForceResetter(),
def Plane(v1,v2,v3,v4): pts = [ [Vector3(v1),Vector3(v2),Vector3(v3),Vector3(v4)] ] return pack.sweptPolylines2gtsSurface(pts,capStart=True,capEnd=True)
radiusKnife = 1 lengthKnife = 2 buldozerHeight = 1.2 radiusSph = 0.05 numBoxes = Vector3(15, 5, 2) gapBetweenBoxes = 0.05 sizeBox = (lengthKnife - (numBoxes[1] - 1) * gapBetweenBoxes) / numBoxes[1] ### Creating the Buldozer Knife ### from facets, using GTS Knife = [] for i in linspace(pi, pi * 3 / 2, num=numKnifeParts, endpoint=True): Knife.append(Vector3(radiusKnife * cos(i), 0, radiusKnife * sin(i))) KnifeP = [Knife, [p + Vector3(0, lengthKnife, 0) for p in Knife]] KnifePoly = pack.sweptPolylines2gtsSurface(KnifeP, threshold=1e-4) KnifeIDs = [] KnifeIDs = O.bodies.append( pack.gtsSurface2Facets(KnifePoly, color=(1, 0, 0), wire=False)) KnifeIDs += O.bodies.append( geom.facetBox((-lengthKnife / 2 - radiusKnife, lengthKnife / 2, -radiusKnife + buldozerHeight / 2), (lengthKnife / 2, lengthKnife / 2, buldozerHeight / 2.), wallMask=47, color=(0, 1, 0), wire=False)) KnifeIDs += O.bodies.append( geom.facetBox( (-lengthKnife / 2 - radiusKnife - lengthKnife / 4., lengthKnife / 2,
# default spheres material dfltSpheresMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle, **params)) O.dt=.1*tc # time step 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) lftIds=O.bodies.append(pack.gtsSurface2Facets(left.faces(),material=facetMat,color=(0,1,0))) right = pack.sweptPolylines2gtsSurface([[Vector3(x1b,y0b,zb),Vector3(x1t,y0t,zt),Vector3(x1t,y1t,zt),Vector3(x1b,y1b,zb)]],capStart=True,capEnd=True) rgtIds=O.bodies.append(pack.gtsSurface2Facets(right.faces(),material=facetMat,color=(0,1,0))) near = pack.sweptPolylines2gtsSurface([[Vector3(x0b,y0b,zb),Vector3(x0t,y0t,zt),Vector3(x1t,y0t,zt),Vector3(x1b,y0b,zb)]],capStart=True,capEnd=True) nearIds=O.bodies.append(pack.gtsSurface2Facets(near.faces(),material=facetMat,color=(0,1,0))) far = pack.sweptPolylines2gtsSurface([[Vector3(x0b,y1b,zb),Vector3(x0t,y1t,zt),Vector3(x1t,y1t,zt),Vector3(x1b,y1b,zb)]],capStart=True,capEnd=True) farIds=O.bodies.append(pack.gtsSurface2Facets(far.faces(),material=facetMat,color=(0,1,0))) table = pack.sweptPolylines2gtsSurface([[Vector3(x0l,y0l,zl),Vector3(x0l,y1l,zl),Vector3(x1l,y1l,zl),Vector3(x1l,y0l,zl)]],capStart=True,capEnd=True) tblIds=O.bodies.append(pack.gtsSurface2Facets(table.faces(),material=facetMat,color=(0,1,0))) # Create clumps...
VTU-files are created in /tmp directory after simulation. If you open those with paraview (or other VTK-based) program, you can create video, make screenshots etc.""" import woo from woo import * from woo.dem import * from woo.core import * from numpy import linspace from woo import pack,qt,utils from minieigen import * from math import * S=woo.master.scene=Scene(fields=[DemField(gravity=(0,0,-9.81))]) thetas=linspace(0,2*pi,num=16,endpoint=True) meridians=pack.revolutionSurfaceMeridians([[Vector2(3+rad*sin(th),10*rad+rad*cos(th)) for th in thetas] for rad in linspace(1,2,num=10)],angles=linspace(0,pi,num=10)) surf=pack.sweptPolylines2gtsSurface(meridians+[[Vector3(5*sin(-th),-10+5*cos(-th),30) for th in thetas]]) S.dem.par.add(pack.gtsSurface2Facets(surf)) S.dem.par.add(InfCylinder.make((0,0,0),axis=0,radius=2,glAB=(-10,10))) # edgy helix from contiguous rods nPrev=None for i in range(25): nNext=Node(pos=(3+3*sin(i),3*cos(i),3+.3*i)) if nPrev: S.dem.par.add(Rod.make(vertices=[nPrev,nNext],radius=.5,wire=False,fixed=True)) nPrev=nNext sp=pack.SpherePack() sp.makeCloud(Vector3(-1,-9,30),Vector3(1,-13,32),.2,rRelFuzz=.3) S.dem.par.add([utils.sphere(c,r) for c,r in sp]) S.engines=DemField.minimalEngines(damping=.2)+[VtkExport(stepPeriod=100,what=VtkExport.spheres|VtkExport.mesh,out='/tmp/p1-'),PyRunner(initRun=False,stepPeriod=0,virtPeriod=13,nDo=1,command='import woo.paraviewscript; woo.paraviewscript.fromEngines(S,launch=True); S.stop()')]
# -*- coding: utf-8 -*- from numpy import arange from woo import pack import pylab # define the section shape as polygon in 2d; repeat first point at the end to close the polygon sq2 = sqrt(2) poly = ((3 + .1, 0), (3 + 0, .1), (3 + sq2, .1 + sq2), (3 + .1 + sq2, sq2), (3 + .1, 0)) #pylab.plot(*zip(*poly)); pylab.xlim(xmin=0); pylab.grid(); pylab.title('Meridian of the revolution surface\n(close to continue)'); pylab.gca().set_aspect(aspect='equal',adjustable='box'); pylab.show() thetas = arange(0, pi / 8, pi / 24) pts = pack.revolutionSurfaceMeridians([poly for theta in thetas], thetas, origin=Vector3(-4, 0, -1), orientation=Quaternion.Identity) surf = pack.sweptPolylines2gtsSurface(pts, capStart=True, capEnd=True, threshold=1e-4) O.bodies.append(pack.gtsSurface2Facets(surf, color=(1, 0, 1))) # fill this solid with triaxial packing; it will compute minimum-volume oriented bounding box # to minimize the number of throw-away spheres. # It does away with about 3k spheres for radius 3e-2 O.bodies.append( pack.randomDensePack(pack.inGtsSurface(surf), radius=3e-2, rRelFuzz=1e-1, memoizeDb='/tmp/gts-triax-packings.sqlite')) # translate the surface away and pack it again with sphere, but without the oriented bounding box (useOBB=False) # Here, we need 20k spheres (with more or less the same result) surf.translate(0, 0, 1) O.bodies.append(pack.gtsSurface2Facets(surf, color=(1, 0, 0))) O.bodies.append(
from woo.dem import * from woo.core import * from numpy import linspace from woo import pack, qt, utils from minieigen import * from math import * S = woo.master.scene = Scene(fields=[DemField(gravity=(0, 0, -9.81))]) thetas = linspace(0, 2 * pi, num=16, endpoint=True) meridians = pack.revolutionSurfaceMeridians( [[Vector2(3 + rad * sin(th), 10 * rad + rad * cos(th)) for th in thetas] for rad in linspace(1, 2, num=10)], angles=linspace(0, pi, num=10)) surf = pack.sweptPolylines2gtsSurface( meridians + [[Vector3(5 * sin(-th), -10 + 5 * cos(-th), 30) for th in thetas]]) S.dem.par.add(pack.gtsSurface2Facets(surf)) sp = pack.SpherePack() sp.makeCloud(Vector3(-1, -9, 30), Vector3(1, -13, 32), .2, rRelFuzz=.3) S.dem.par.add([utils.sphere(c, r) for c, r in sp]) S.engines = DemField.minimalEngines(damping=.2) + [ VtkExport(stepPeriod=100, what=VtkExport.spheres | VtkExport.mesh, out='/tmp/p1-') ] qt.Controller() qt.View()
en=.3 # normal restitution coefficient es=.3 # tangential restitution coefficient frictionAngle=radians(35)# density=2700 # facets material params=utils.getViscoelasticFromSpheresInteraction(10e3,tc,en,es) facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs # default spheres material dfltSpheresMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle)) O.dt=.1*tc # time step Rs=0.1 # particle radius # Create geometry bottom = pack.sweptPolylines2gtsSurface([[Vector3(-1,-1,-1),Vector3(1,-1,-1),Vector3(1, 1, -1),Vector3(-1, 1, -1)]],capStart=True,capEnd=True) btmIds=O.bodies.append(pack.gtsSurface2Facets(bottom.faces(),material=facetMat,color=(0,1,0))) #top = pack.sweptPolylines2gtsSurface([[Vector3(-1,-1,1),Vector3(1,-1,1),Vector3(1, 1, 1),Vector3(-1, 1, 1)]],capStart=True,capEnd=True) #topIds=O.bodies.append(pack.gtsSurface2Facets(top.faces(),material=facetMat,color=(0,1,0))) left = pack.sweptPolylines2gtsSurface([[Vector3(-1,-1,-1),Vector3(1,-1,-1),Vector3(1, -1, 1),Vector3(-1, -1, 1)]],capStart=True,capEnd=True) lftIds=O.bodies.append(pack.gtsSurface2Facets(left.faces(),material=facetMat,color=(0,1,0))) right = pack.sweptPolylines2gtsSurface([[Vector3(-1,1,-1),Vector3(1,1,-1),Vector3(1, 1, 1),Vector3(-1, 1, 1)]],capStart=True,capEnd=True) rgtIds=O.bodies.append(pack.gtsSurface2Facets(right.faces(),material=facetMat,color=(0,1,0))) near = pack.sweptPolylines2gtsSurface([[Vector3(1,-1,-1),Vector3(1,1,-1),Vector3(1, 1, 1),Vector3(1, -1, 1)]],capStart=True,capEnd=True) nearIds=O.bodies.append(pack.gtsSurface2Facets(near.faces(),material=facetMat,color=(0,1,0))) far = pack.sweptPolylines2gtsSurface([[Vector3(-1,-1,-1),Vector3(-1,1,-1),Vector3(-1, 1, 1),Vector3(-1, -1, 1)]],capStart=True,capEnd=True)
params = utils.getViscoelasticFromSpheresInteraction(10e3, tc, en, es) facetMat = O.materials.append(ViscElMat( frictionAngle=frictionAngle, **params)) # **params sets kn, cn, ks, cs # default spheres material dfltSpheresMat = O.materials.append( ViscElMat(density=density, frictionAngle=frictionAngle)) O.dt = .01 * tc # time step Rs = 0.1 # particle radius # Create geometry plnSurf = pack.sweptPolylines2gtsSurface([[ Vector3(-.5, 0, 0), Vector3(.5, 0, 0), Vector3(.5, 0, -.5), Vector3(-.5, 0, -.5) ]], capStart=True, capEnd=True) plnIds = O.bodies.append( pack.gtsSurface2Facets(plnSurf.faces(), material=facetMat, color=(0, 1, 0))) plnSurf1 = pack.sweptPolylines2gtsSurface([[ Vector3(-.5, -.5, -.5), Vector3(.5, -.5, -.5), Vector3(.5, 1.5, -.5), Vector3(-.5, 1.5, -.5) ]], capStart=True, capEnd=True)
thetas=arange(0,pi/2,pi/24) # create 3d points from the 2d ones, turning the 2d meridian around the +y axis # for each angle, put the poly a little bit higher (+2e-3*theta); # this is just to demonstrate that you can do whatever here as long as the resulting # meridian has the same number of points # # There is origin (translation) and orientation arguments, allowing to transform all the 3d points once computed. # # without these transformation, it would look a little simpler: # pts=pack.revolutionSurfaceMeridians([[(pt[0],pt[1]+2e-3*theta) for pt in poly] for theta in thetas],thetas # pts=pack.revolutionSurfaceMeridians([[(pt[0],pt[1]+1e-2*theta) for pt in poly] for theta in thetas],thetas,origin=Vector3(0,-.05,.1),orientation=Quaternion((1,1,0),pi/4)) # connect meridians to make surfaces # caps will close it at the beginning and the end # threshold will merge points closer than 1e-4; this is important: we want it to be closed for filling surf=pack.sweptPolylines2gtsSurface(pts,capStart=True,capEnd=True,threshold=1e-4) # add the surface as facets to the simulation, to make it visible O.bodies.append(pack.gtsSurface2Facets(surf,color=(1,0,1))) # now fill the inGtsSurface predicate constructed form the same surface with sphere packing generated by TriaxialTest # with given radius and standard deviation (see documentation of pack.randomDensePack) # # The memoizeDb will save resulting packing into given file and next time, if you run with the same # parameters (or parameters that can be scaled to the same one), # it will load the packing instead of running the triaxial compaction again. # Try running for the second time to see the speed difference! memoizeDb='/tmp/gts-triax-packings.sqlite' O.bodies.append(pack.randomDensePack(pack.inGtsSurface(surf),radius=5e-3,rRelFuzz=1e-4,memoizeDb=memoizeDb)) # We could also fill the horse with triaxial packing, but have nice approximation, the triaxial would run terribly long, # since horse discard most volume of its bounding box # Here, we would use a very crude one, however if 1:
def Plane(v1, v2, v3, v4): pts = [[Vector3(v1), Vector3(v2), Vector3(v3), Vector3(v4)]] return pack.sweptPolylines2gtsSurface(pts, capStart=True, capEnd=True)