Ejemplo n.º 1
0
"""This example demonstrates GTS (http://gts.sourceforge.net/) opportunities for creating surfaces
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()')]
Ejemplo n.º 2
0
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))

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-')
]
Ejemplo n.º 3
0
# -*- 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)))
Ejemplo n.º 4
0
poly=((1e-2,5e-2),(5e-2,2e-2),(7e-2,-2e-2),(1e-2,-5e-2),(1e-2,5e-2))
# show us the meridian shape
#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()
# angles at which we want this polygon to appear
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))
Ejemplo n.º 5
0
poly=((1e-2,5e-2),(5e-2,2e-2),(7e-2,-2e-2),(1e-2,-5e-2),(1e-2,5e-2))
# show us the meridian shape
#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()
# angles at which we want this polygon to appear
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))
Ejemplo n.º 6
0
# -*- 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(pack.randomDensePack(pack.inGtsSurface(surf),radius=3e-2,rRelFuzz=1e-1,memoizeDb='/tmp/gts-triax-packings.sqlite',useOBB=False))