예제 #1
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""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."""

from numpy import linspace
from yade import pack
thetas = linspace(0, 2 * pi, num=16, endpoint=True)
meridians = pack.revolutionSurfaceMeridians(
    [[(3 + rad * sin(th), 10 * rad + rad * cos(th)) for th in thetas]
     for rad in linspace(1, 2, num=10)], linspace(0, pi, num=10))
surf = pack.sweptPolylines2gtsSurface(
    meridians +
    [[Vector3(5 * sin(-th), -10 + 5 * cos(-th), 30) for th in thetas]])
O.bodies.append(pack.gtsSurface2Facets(surf))

sp = pack.SpherePack()
sp.makeCloud(Vector3(-1, -9, 30), Vector3(1, -13, 32), .2, rRelFuzz=.3)
O.bodies.append([sphere(c, r) for c, r 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()]),
    NewtonIntegrator(gravity=(0, 0, -9.81)),
    VTKRecorder(iterPeriod=100,
예제 #2
0
""" CAUTION:
Running this script can take very long!
"""

from numpy import arange
from yade 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
sp1 = SpherePack()
sp1 = pack.randomDensePack(pack.inGtsSurface(surf),
                           radius=3e-2,
                           rRelFuzz=1e-1,
                           memoizeDb='/tmp/gts-triax.sqlite',
                           returnSpherePack=True)
예제 #3
0
""" CAUTION:
Running this script can take very long!
"""

from numpy import arange
from yade 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 + 0.1, 0), (3 + 0, 0.1), (3 + sq2, 0.1 + sq2), (3 + 0.1 + sq2, sq2), (3 + 0.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.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(
예제 #4
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()
# 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
예제 #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))
예제 #6
0
파일: funnel.py 프로젝트: DEMANY/trunk
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""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."""

from numpy import linspace
from yade import pack
thetas=linspace(0,2*pi,num=16,endpoint=True)
meridians=pack.revolutionSurfaceMeridians([[(3+rad*sin(th),10*rad+rad*cos(th)) for th in thetas] for rad in linspace(1,2,num=10)],linspace(0,pi,num=10))
surf=pack.sweptPolylines2gtsSurface(meridians+[[Vector3(5*sin(-th),-10+5*cos(-th),30) for th in thetas]])
O.bodies.append(pack.gtsSurface2Facets(surf))

sp=pack.SpherePack()
sp.makeCloud(Vector3(-1,-9,30),Vector3(1,-13,32),.2,rRelFuzz=.3)
O.bodies.append([sphere(c,r) for c,r 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()]
	),
	NewtonIntegrator(gravity=(0,0,-9.81)),
	VTKRecorder(iterPeriod=100,recorders=['spheres','facets','colors'],fileName='/tmp/p1-')
]
O.dt=PWaveTimeStep()