Beispiel #1
0
# 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'
sp=SpherePack()
sp=pack.randomDensePack(pack.inGtsSurface(surf),radius=5e-3,rRelFuzz=1e-4,memoizeDb=memoizeDb,returnSpherePack=True)
sp.toSimulation()
# 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:
	import gts
	horse=gts.read(open('horse.coarse.gts')) #; horse.scale(.25,.25,.25)
	O.bodies.append(pack.gtsSurface2Facets(horse))
	sp=pack.randomDensePack(pack.inGtsSurface(horse),radius=5e-3,memoizeDb=memoizeDb,returnSpherePack=True)
	sp.toSimulation()
	horse.translate(.07,0,0)
	O.bodies.append(pack.gtsSurface2Facets(horse))
	# specifying spheresInCell makes the packing periodic, with the given number of spheres, proportions being equal to that of the predicate
	sp=pack.randomDensePack(pack.inGtsSurface(horse),radius=1e-3,spheresInCell=2000,memoizeDb=memoizeDb,returnSpherePack=True)
	sp.toSimulation()
Beispiel #2
0
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)
sp1.toSimulation()
# 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)))
sp2 = SpherePack()
sp2 = pack.randomDensePack(pack.inGtsSurface(surf),
                           radius=3e-2,
                           rRelFuzz=1e-1,
                           memoizeDb='/tmp/gts-triax-packings.sqlite',
                           useOBB=False,
                           returnSpherePack=True)
sp2.toSimulation()
    aabb = pred.aabb()
    dim = pred.dim()
    center = pred.center()
    minDim = min(dim[0], dim[1], dim[2])
    # define discretisation
    radius = minDim / (2 * sizeRatio)
    print center, dim, ' | minDim=', minDim, ' | diameter=', 2 * radius
    ### regular packing
    #O.bodies.append(pack.regularHexa(pred,radius=radius,gap=0.,color=(0.9,0.8,0.6)))
    #O.bodies.append(pack.regularOrtho(pred,radius=radius,gap=0.,color=(0.9,0.8,0.6)))
    sp = SpherePack()
    # random packing
    sp = pack.randomDensePack(
        pred,
        radius=radius,
        rRelFuzz=0.3,
        useOBB=True,
        memoizeDb='/tmp/gts-triax-packings.sqlite',
        returnSpherePack=True)  # cropLayers=5 (not to use)
    # periodic random packing
    #sp=pack.randomDensePack(pred,radius=radius,rRelFuzz=0.3,useOBB=True,spheresInCell=2000,memoizeDb='/tmp/gts-triax-packings.sqlite',returnSpherePack=True) # cropLayers=5 (not to use)
    sp.toSimulation(color=(0.9, 0.8, 0.6))

#### import mesh
O.bodies.append(
    pack.gtsSurface2Facets(surface, color=(0.8, 0.8, 0.8), wire=True))

#### export packing
export.text(mesh + '_' + str(int(sizeRatio)) + '.spheres')

#### VIEW
Beispiel #4
0
	# isotropic confinement (should be negative)
	isoPrestress=0,
)

from yade.params.table import *

if 'description' in O.tags.keys(): O.tags['id']=O.tags['id']+O.tags['description']


# make geom; the dimensions are hard-coded here; could be in param table if desired
# z-oriented hyperboloid, length 20cm, diameter 10cm, skirt 8cm
# using spheres 7mm of diameter
concreteId=O.materials.append(CpmMat(young=young,frictionAngle=frictionAngle,poisson=poisson,density=4800,sigmaT=sigmaT,relDuctility=relDuctility,epsCrackOnset=epsCrackOnset,isoPrestress=isoPrestress))

sps=SpherePack()
sp=pack.randomDensePack(pack.inHyperboloid((0,0,-.5*specimenLength),(0,0,.5*specimenLength),.25*specimenLength,.17*specimenLength),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite',returnSpherePack=True)
#sp=pack.randomDensePack(pack.inAlignedBox((-.25*specimenLength,-.25*specimenLength,-.5*specimenLength),(.25*specimenLength,.25*specimenLength,.5*specimenLength)),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite',returnSpherePack=True)
sp.toSimulation(material=concreteId)
bb=uniaxialTestFeatures()
negIds,posIds,axis,crossSectionArea=bb['negIds'],bb['posIds'],bb['axis'],bb['area']
O.dt=dtSafety*PWaveTimeStep()
print 'Timestep',O.dt

mm,mx=[pt[axis] for pt in aabbExtrema()]
coord_25,coord_50,coord_75=mm+.25*(mx-mm),mm+.5*(mx-mm),mm+.75*(mx-mm)
area_25,area_50,area_75=approxSectionArea(coord_25,axis),approxSectionArea(coord_50,axis),approxSectionArea(coord_75,axis)

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=intRadius,label='is2aabb'),],verletDist=.05*sphereRadius),
	InteractionLoop(
Beispiel #5
0
maxCorner = (10, 10, 10)
center = (5, 5, 5)
normal = (1, 1, 1)

from yade import pack, export
pred = pack.inAlignedBox(Vector3.Zero, maxCorner)
O.bodies.append(
    pack.randomDensePack(pred, radius=1., rRelFuzz=.5, spheresInCell=500))

export.text('/tmp/test.txt')
# text2vtk and text2vtkSection function can be copy-pasted from yade/py/export.py into separate py file to avoid executing yade or to use pure python
export.text2vtk('/tmp/test.txt', '/tmp/test.vtk')
export.text2vtkSection('/tmp/test.txt',
                       '/tmp/testSection.vtk',
                       point=center,
                       normal=normal)

# now open paraview, click "Tools" menu -> "Python Shell", click "Run Script", choose "pv_section.py" from this directiory
# or just run python pv_section.py
# and enjoy :-)
O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=radians(angfric),density=2600,label='sph'))

walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)

vect=[0, 1, 1.25, 2.25, 2.5, 3.5, 3.75]
vect=1/3.75*numpy.array(vect)

cuadr1=pack.inAlignedBox((0,0,H*vect[0]),(D,D,H*vect[1])) #grueso
cuadr2=pack.inAlignedBox((0,0,H*vect[1]),(D,D,H*vect[2])) #fino
cuadr3=pack.inAlignedBox((0,0,H*vect[2]),(D,D,H*vect[3])) #grueso
cuadr4=pack.inAlignedBox((0,0,H*vect[3]),(D,D,H*vect[4])) #fino
cuadr5=pack.inAlignedBox((0,0,H*vect[4]),(D,D,H*vect[5])) #grueso
cuadr6=pack.inAlignedBox((0,0,H*vect[5]),(D,D,H*vect[6])) #fino

sph1=pack.randomDensePack(cuadr1,spheresInCell=1000,radius=rmean,rRelFuzz=Sd,returnSpherePack=True)
sph2=pack.randomDensePack(cuadr2,spheresInCell=2000,radius=rmean/R1,rRelFuzz=Sd,returnSpherePack=True)
sph3=pack.randomDensePack(cuadr3,spheresInCell=1000,radius=rmean,rRelFuzz=Sd,returnSpherePack=True)
sph4=pack.randomDensePack(cuadr4,spheresInCell=2000,radius=rmean/R1,rRelFuzz=Sd,returnSpherePack=True)
sph5=pack.randomDensePack(cuadr5,spheresInCell=1000,radius=rmean,rRelFuzz=Sd,returnSpherePack=True)
sph6=pack.randomDensePack(cuadr6,spheresInCell=2000,radius=rmean/R1,rRelFuzz=Sd,returnSpherePack=True)

sph1.toSimulation(material='sph')
sph2.toSimulation(material='sph')
sph3.toSimulation(material='sph')
sph4.toSimulation(material='sph')
sph5.toSimulation(material='sph')
sph6.toSimulation(material='sph')

n1=len(sph1)
n2=len(sph2)
Beispiel #7
0
    noTableOk=True,
    young=25e9,
    poisson=.2,
    epsCrackOnset=1e-4,
    relDuctility=30,
    sigmaT=3e6,
    frictionAngle=atan(0.8),
    density=4800.,
    intRadius=1.5,
    dtSafety=.8,
    damping=0.3,
    strainRateTension=.4,
    strainRateCompression=3,
    specimenSize=50e-3,
    radius=1e-3,
    outBase="/tmp/cpm_uniax",
)
from yade.params.table import *

if 'description' in O.tags.keys():
    outBase = "{}_{}".format(outBase, O.tags['description'])

s = specimenSize
sp = pack.randomDensePack(inAlignedBox((0, 0, 0), (s, s, s)),
                          radius,
                          spheresInCell=1000,
                          memoizeDb="packing.db",
                          returnSpherePack=True)
sp.toSimulation()
sp.save("/tmp/aaa.ps")
Beispiel #8
0
# 	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:
	import gts
	horse=gts.read(open('horse.coarse.gts')) #; horse.scale(.25,.25,.25)
	O.bodies.append(pack.gtsSurface2Facets(horse))
	O.bodies.append(pack.randomDensePack(pack.inGtsSurface(horse),radius=5e-3,memoizeDb=memoizeDb))
	horse.translate(.07,0,0)
	O.bodies.append(pack.gtsSurface2Facets(horse))
	# specifying spheresInCell makes the packing periodic, with the given number of spheres, proportions being equal to that of the predicate
	O.bodies.append(pack.randomDensePack(pack.inGtsSurface(horse),radius=1e-3,spheresInCell=2000,memoizeDb=memoizeDb))
Beispiel #9
0
if not os.path.exists('VTK' + timeStr + identifier):
    os.mkdir('VTK' + timeStr + identifier)
else:
    shutil.rmtree('VTK' + timeStr + identifier)
    os.mkdir('VTK' + timeStr + identifier)

mx = Vector3(0.9639118565206523, 0.9324110610237126, 0.8800533096533549)
mn = Vector3(-0.9518976876470108, -0.9685168132064216, -0.9451956043076566)

walls = aabbWalls([mn, mx], thickness=0)
wallIds = O.bodies.append(walls)

pred = pack.inSphere(Vector3(0, 0, 0), 1)
sp = pack.randomDensePack(pred,
                          radius=0.1,
                          rRelFuzz=0.1,
                          returnSpherePack=False,
                          seed=1)
O.bodies.append(sp)

O.engines = O.engines[0:3] + [
    FlowEngine(dead=0, label="flow", multithread=False)
] + O.engines[3:5]


# visualization of the alpha boundary: filter cells by "alpha" in paraview
def pressureField():
    flow.saveVtk('VTK' + timeStr + identifier + '/', withBoundaries=False)


O.engines = O.engines + [
Beispiel #10
0
# material
concreteId = O.materials.append(
    CpmMat(
        young=young,
        poisson=poisson,
        frictionAngle=frictionAngle,
        epsCrackOnset=epsCrackOnset,
        relDuctility=relDuctility,
        sigmaT=sigmaT,
    ))

# spheres
sp = pack.randomDensePack(pack.inCylinder((0, 0, 0), (specimenLength, 0, 0),
                                          specimenRadius),
                          radius=sphereRadius,
                          spheresInCell=500,
                          memoizeDb='/tmp/packing-brazilian.db',
                          returnSpherePack=True)
sp.toSimulation()

# walls
zMin, zMax = [pt[2] for pt in aabbExtrema()]
wallIDs = O.bodies.append([wall((0, 0, z), 2) for z in (zMin, zMax)])
walls = wallMin, wallMax = [O.bodies[i] for i in wallIDs]
v = strainRate * 2 * specimenRadius
wallMin.state.vel = (0, 0, +v)
wallMax.state.vel = (0, 0, -v)

# engines
O.engines = [
    ForceResetter(),
Beispiel #11
0
"""

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)
sp1.toSimulation()
# 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)))
sp2=SpherePack()
sp2=pack.randomDensePack(pack.inGtsSurface(surf),radius=3e-2,rRelFuzz=1e-1,memoizeDb='/tmp/gts-triax-packings.sqlite',useOBB=False,returnSpherePack=True)
sp2.toSimulation()

from yade import qt
qt.View()
Beispiel #12
0
# -*- coding: utf-8 -*-
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
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))
Beispiel #13
0
if surface.is_closed():
	pred=pack.inGtsSurface(surface)
	# get characteristic dimensions
	aabb=pred.aabb()
	dim=pred.dim()
	center=pred.center()
	minDim=min(dim[0],dim[1],dim[2])
	# define discretisation
	radius=minDim/(2*sizeRatio)
	print center, dim, ' | minDim=', minDim, ' | diameter=', 2*radius
	### regular packing
	#O.bodies.append(pack.regularHexa(pred,radius=radius,gap=0.,color=(0.9,0.8,0.6)))
	#O.bodies.append(pack.regularOrtho(pred,radius=radius,gap=0.,color=(0.9,0.8,0.6)))
	sp=SpherePack()
	# random packing
	sp=pack.randomDensePack(pred,radius=radius,rRelFuzz=0.3,useOBB=True,memoizeDb='/tmp/gts-triax-packings.sqlite',returnSpherePack=True) # cropLayers=5 (not to use)
	# periodic random packing
	#sp=pack.randomDensePack(pred,radius=radius,rRelFuzz=0.3,useOBB=True,spheresInCell=2000,memoizeDb='/tmp/gts-triax-packings.sqlite',returnSpherePack=True) # cropLayers=5 (not to use)
	sp.toSimulation(color=(0.9,0.8,0.6))

#### import mesh
O.bodies.append(pack.gtsSurface2Facets(surface,color=(0.8,0.8,0.8),wire=True))

#### export packing
export.text(mesh+'_'+str(int(sizeRatio))+'.spheres')

#### VIEW
from yade import qt
qt.View()

Beispiel #14
0
    JCFpmMat(young=young,
             cohesion=cohesion,
             density=density,
             frictionAngle=radians(finalFricDegree),
             tensileStrength=sigmaT,
             poisson=poisson,
             label='JCFmat'))

#### preprocessing to get dimensions
numSpheres = 10000

pred = pack.inAlignedBox(
    mn, mx)  #- pack.inCylinder((0, -.01, 0), (0, .01, 0), 0.04)
sp = pack.randomDensePack(pred,
                          radius=0.0015,
                          spheresInCell=numSpheres,
                          rRelFuzz=0.25,
                          returnSpherePack=True)
sp.toSimulation()
export.textExt('240x80mmBeam_1.5mmrad.spheres', 'x_y_z_r')

dim = utils.aabbExtrema()
xinf = dim[0][0]
xsup = dim[1][0]
X = xsup - xinf
yinf = dim[0][1]
ysup = dim[1][1]
Y = ysup - yinf
zinf = dim[0][2]
zsup = dim[1][2]
Z = zsup - zinf
Beispiel #15
0
from yade import pack, export
pred = pack.inAlignedBox((0,0,0),(10,10,10))
O.bodies.append(pack.randomDensePack(pred,radius=1.,rRelFuzz=.5,spheresInCell=500,memoizeDb='/tmp/pack.db'))

export.textExt('/tmp/test.txt',format='x_y_z_r_attrs',attrs=('b.state.pos.norm()','b.state.pos'),comment='dstN dstV_x dstV_y dstV_z')
# text2vtk and text2vtkSection function can be copy-pasted from yade/py/export.py into separate py file to avoid executing yade or to use pure python
export.text2vtk('/tmp/test.txt','/tmp/test.vtk')
export.text2vtkSection('/tmp/test.txt','/tmp/testSection.vtk',point=(5,5,5),normal=(1,1,1))

# now open paraview, click "Tools" menu -> "Python Shell", click "Run Script", choose "pv_section.py" from this directiory
# or just run python pv_section.py
# and enjoy :-)
Beispiel #16
0
                                      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:
    import gts
    horse = gts.read(open('horse.coarse.gts'))  #; horse.scale(.25,.25,.25)
    O.bodies.append(pack.gtsSurface2Facets(horse))
    O.bodies.append(
        pack.randomDensePack(pack.inGtsSurface(horse),
                             radius=5e-3,
                             memoizeDb=memoizeDb))
    horse.translate(.07, 0, 0)
    O.bodies.append(pack.gtsSurface2Facets(horse))
    # specifying spheresInCell makes the packing periodic, with the given number of spheres, proportions being equal to that of the predicate
Beispiel #17
0
           sigmaT=sigmaT,
           epsCrackOnset=epsCrackOnset,
           relDuctility=relDuctility))
frictMat = O.materials.append(
    FrictMat(young=young, poisson=poisson, frictionAngle=frictionAngle))

# spheres
pred = pack.inCylinder(
    (0, 0, 0),
    (0, 0, height), .5 * width) if testType == 'cyl' else pack.inAlignedBox(
        (-.5 * width, -.5 * width, 0),
        (.5 * width, .5 * width, height)) if testType == 'cube' else None
sp = SpherePack()
sp = pack.randomDensePack(pred,
                          spheresInCell=2000,
                          radius=rParticle,
                          memoizeDb='/tmp/triaxTestOnCylinder.sqlite',
                          returnSpherePack=True)
spheres = sp.toSimulation(color=(0, 1, 1), material=concMat)

# bottom and top of specimen. Will have prescribed velocity
bot = [
    O.bodies[s] for s in spheres
    if O.bodies[s].state.pos[2] < rParticle * bcCoeff
]
top = [
    O.bodies[s] for s in spheres
    if O.bodies[s].state.pos[2] > height - rParticle * bcCoeff
]
vel = strainRate * (height - rParticle * 2 * bcCoeff)
for s in bot:
Beispiel #18
0
maxCorner = (10,10,10)
center = (5,5,5)
normal = (1,1,1)

from yade import pack, export
pred = pack.inAlignedBox(Vector3.Zero,maxCorner)
O.bodies.append(pack.randomDensePack(pred,radius=1.,rRelFuzz=.5,spheresInCell=500))

export.text('/tmp/test.txt')
# text2vtk and text2vtkSection function can be copy-pasted from yade/py/export.py into separate py file to avoid executing yade or to use pure python
export.text2vtk('/tmp/test.txt','/tmp/test.vtk')
export.text2vtkSection('/tmp/test.txt','/tmp/testSection.vtk',point=center,normal=normal)

# now open paraview, click "Tools" menu -> "Python Shell", click "Run Script", choose "pv_section.py" from this directiory
# or just run python pv_section.py
# and enjoy :-)
Beispiel #19
0
from yade.params.table import *
assert testType in ['cyl','cube']

# materials
concMat = O.materials.append(CpmMat(
	young=young,frictionAngle=frictionAngle,poisson=poisson,sigmaT=sigmaT,
	epsCrackOnset=epsCrackOnset,relDuctility=relDuctility
))
frictMat = O.materials.append(FrictMat(
	young=young,poisson=poisson,frictionAngle=frictionAngle
))

# spheres
pred = pack.inCylinder((0,0,0),(0,0,height),.5*width) if testType=='cyl' else pack.inAlignedBox((-.5*width,-.5*width,0),(.5*width,.5*width,height)) if testType=='cube' else None
sp=SpherePack()
sp = pack.randomDensePack(pred,spheresInCell=2000,radius=rParticle,memoizeDb='/tmp/triaxTestOnCylinder.sqlite',returnSpherePack=True)
spheres=sp.toSimulation(color=(0,1,1),material=concMat)

# bottom and top of specimen. Will have prescribed velocity
bot = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]<rParticle*bcCoeff]
top = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]>height-rParticle*bcCoeff]
vel = strainRate*(height-rParticle*2*bcCoeff)
for s in bot:
	s.shape.color = (1,0,0)
	s.state.blockedDOFs = 'xyzXYZ'
	s.state.vel = (0,0,-vel)
for s in top:
	s.shape.color = Vector3(0,1,0)
	s.state.blockedDOFs = 'xyzXYZ'
	s.state.vel = (0,0,vel)
Beispiel #20
0
# -*- coding: utf-8 -*-

""" 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
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(pack.inGtsSurface(surf),radius=3e-2,rRelFuzz=1e-1,memoizeDb='/tmp/gts-triax-packings.sqlite',useOBB=False))

from yade import qt
qt.View()
Beispiel #21
0

# --- Creating a sample of spheres

# definition of a predicate 
from yade import pack
Lx = 10
Ly = 10
Lz = 6
pred = pack.inAlignedBox((0,0,0),(Lx,Ly,Lz))
# use of randomDensePack() function
nSpheres = 1500.0
poros=0.13 # apparently the value of porosity of samples generated by pack.randomDensePack
rMeanSpheres = pow(Lx*Ly*Lz*3.0/4.0*(1-poros)/(pi*nSpheres),1.0/3.0)
print('\nGenerating sphere sample, be patient')
sp = pack.randomDensePack(pred,radius=rMeanSpheres,rRelFuzz=0.3,memoizeDb='/tmp/gts-triax-packings.sqlite',returnSpherePack=True)
sp.toSimulation(color=(0.9,0.8,0.6),wire=False,material=mat)
print('Sphere sample generated !')


# --- The joint surface : half of the height
import gts
v1 = gts.Vertex(0 , 0 , Lz/2.0)
v2 = gts.Vertex(Lx, 0 , Lz/2.0)
v3 = gts.Vertex(Lx, Ly, Lz/2.0)
v4 = gts.Vertex(0 , Ly, Lz/2.0)

e1 = gts.Edge(v1,v2)
e2 = gts.Edge(v2,v4)
e3 = gts.Edge(v4,v1)
f1 = gts.Face(e1,e2,e3)
from yade import pack, export
pred = pack.inAlignedBox((0, 0, 0), (10, 10, 10))
O.bodies.append(
    pack.randomDensePack(pred,
                         radius=1.,
                         rRelFuzz=.5,
                         spheresInCell=500,
                         memoizeDb='/tmp/pack.db'))

export.textExt('/tmp/test.txt',
               format='x_y_z_r_attrs',
               attrs=('b.state.pos.norm()', 'b.state.pos'),
               comment='dstN dstV_x dstV_y dstV_z')
# text2vtk and text2vtkSection function can be copy-pasted from yade/py/export.py into separate py file to avoid executing yade or to use pure python
export.text2vtk('/tmp/test.txt', '/tmp/test.vtk')
export.text2vtkSection('/tmp/test.txt',
                       '/tmp/testSection.vtk',
                       point=(5, 5, 5),
                       normal=(1, 1, 1))
Beispiel #23
0
# z-oriented hyperboloid, length 20cm, diameter 10cm, skirt 8cm
# using spheres 7mm of diameter
concreteId = O.materials.append(
    CpmMat(young=young,
           frictionAngle=frictionAngle,
           poisson=poisson,
           density=4800,
           sigmaT=sigmaT,
           relDuctility=relDuctility,
           epsCrackOnset=epsCrackOnset,
           isoPrestress=isoPrestress))

spheres = pack.randomDensePack(pack.inHyperboloid(
    (0, 0, -.5 * specimenLength), (0, 0, .5 * specimenLength),
    .25 * specimenLength, .17 * specimenLength),
                               spheresInCell=2000,
                               radius=sphereRadius,
                               memoizeDb='/tmp/triaxPackCache.sqlite',
                               material=concreteId)
#spheres=pack.randomDensePack(pack.inAlignedBox((-.25*specimenLength,-.25*specimenLength,-.5*specimenLength),(.25*specimenLength,.25*specimenLength,.5*specimenLength)),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite')
O.bodies.append(spheres)
bb = uniaxialTestFeatures()
negIds, posIds, axis, crossSectionArea = bb['negIds'], bb['posIds'], bb[
    'axis'], bb['area']
O.dt = dtSafety * PWaveTimeStep()
print 'Timestep', O.dt

mm, mx = [pt[axis] for pt in aabbExtrema()]
coord_25, coord_50, coord_75 = mm + .25 * (mx - mm), mm + .5 * (
    mx - mm), mm + .75 * (mx - mm)
area_25, area_50, area_75 = approxSectionArea(
Beispiel #24
0
)
from yade.params.table import *
assert testType in ['cyl','cube']

# materials
concMat = O.materials.append(CpmMat(
	young=young,frictionAngle=frictionAngle,poisson=poisson,sigmaT=sigmaT,
	epsCrackOnset=epsCrackOnset,relDuctility=relDuctility
))
frictMat = O.materials.append(FrictMat(
	young=young,poisson=poisson,frictionAngle=frictionAngle
))

# spheres
pred = pack.inCylinder((0,0,0),(0,0,height),.5*width) if testType=='cyl' else pack.inAlignedBox((-.5*width,-.5*width,0),(.5*width,.5*width,height)) if testType=='cube' else None
sp = pack.randomDensePack(pred,spheresInCell=2000,radius=rParticle,memoizeDb='/tmp/triaxTestOnCylinder.sqlite',color=(0,1,1),material=concMat)
O.bodies.append(sp)
# bottom and top of specimen. Will have prescribed velocity
bot = [s for s in sp if s.state.pos[2]<rParticle*bcCoeff]
top = [s for s in sp if s.state.pos[2]>height-rParticle*bcCoeff]
for s in sp: s.shape.color = (0,1,1)
vel = strainRate*(height-rParticle*2*bcCoeff)
for s in bot:
	s.shape.color = (1,0,0)
	s.state.blockedDOFs = 'xyzXYZ'
	s.state.vel = (0,0,-vel)
for s in top:
	s.shape.color = Vector3(0,1,0)
	s.state.blockedDOFs = 'xyzXYZ'
	s.state.vel = (0,0,vel)
Beispiel #25
0
# definition of a predicate
from yade import pack
Lx = 10
Ly = 10
Lz = 6
pred = pack.inAlignedBox((0, 0, 0), (Lx, Ly, Lz))
# use of randomDensePack() function
nSpheres = 1500.0
poros = 0.13  # apparently the value of porosity of samples generated by pack.randomDensePack
rMeanSpheres = pow(Lx * Ly * Lz * 3.0 / 4.0 * (1 - poros) / (pi * nSpheres),
                   1.0 / 3.0)
print('\nGenerating sphere sample, be patient')
sp = pack.randomDensePack(pred,
                          radius=rMeanSpheres,
                          rRelFuzz=0.3,
                          memoizeDb='/tmp/gts-triax-packings.sqlite',
                          returnSpherePack=True)
sp.toSimulation(color=(0.9, 0.8, 0.6), wire=False, material=mat)
print('Sphere sample generated !')

# --- The joint surface : half of the height
import gts
v1 = gts.Vertex(0, 0, Lz / 2.0)
v2 = gts.Vertex(Lx, 0, Lz / 2.0)
v3 = gts.Vertex(Lx, Ly, Lz / 2.0)
v4 = gts.Vertex(0, Ly, Lz / 2.0)

e1 = gts.Edge(v1, v2)
e2 = gts.Edge(v2, v4)
e3 = gts.Edge(v4, v1)
Beispiel #26
0
radius=1e-02


kwBoxes={'color':[1,0,0],'wire':True,'dynamic':False,'material':1}
O.bodies.append(utils.geom.facetCylinder(center=Vector3(0,0,L/2.), radius=l, height=L, orientation=Quaternion((1, 0, 0), 0),**kwBoxes))

###erase the top and bottom facet of the cylinder
for i in range(0,40,4):
	O.bodies.erase(i)
for i in range(1,38,4):
	O.bodies.erase(i)


predicate=inCylinder(centerBottom=Vector3(0,0,0), centerTop=Vector3(0,0,L+L/2.), radius=l-0.005)	
sp=SpherePack()
sp=pack.randomDensePack(predicate, radius=radius, material='Smat',  cropLayers=10, rRelFuzz=0.0, spheresInCell=100,returnSpherePack=True)
sp.toSimulation()


########################
#### WALL GENERATION  ##
########################
O.materials.append(FrictMat(young=E,poisson=poisson,density=density,frictionAngle=frictionAngleW,label='Wmat'))
topPlate=utils.wall(position=hMax(2)+radius*10,sense=0, axis=2,color=Vector3(1,0,0),material='Wmat')
O.bodies.append(topPlate)
bottomPlate=utils.wall(position=0,sense=0, axis=2,color=Vector3(1,0,0),material='Wmat')
O.bodies.append(bottomPlate)

######################
#### MOVE TOP WALL  ##
######################
Beispiel #27
0
	# use the ScGeom variant
	scGeom=False
)

from yade.params.table import *

if 'description' in O.tags.keys(): O.tags['id']=O.tags['id']+O.tags['description']


# make geom; the dimensions are hard-coded here; could be in param table if desired
# z-oriented hyperboloid, length 20cm, diameter 10cm, skirt 8cm
# using spheres 7mm of diameter
concreteId=O.materials.append(CpmMat(young=young,frictionAngle=frictionAngle,poisson=poisson,density=4800,sigmaT=sigmaT,crackOpening=crackOpening,epsCrackOnset=epsCrackOnset,isoPrestress=isoPrestress))

spheres=pack.randomDensePack(pack.inHyperboloid((0,0,-.5*specimenLength),(0,0,.5*specimenLength),.25*specimenLength,.17*specimenLength),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite',material=concreteId)
#spheres=pack.randomDensePack(pack.inAlignedBox((-.25*specimenLength,-.25*specimenLength,-.5*specimenLength),(.25*specimenLength,.25*specimenLength,.5*specimenLength)),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite')
O.bodies.append(spheres)
bb=uniaxialTestFeatures()
negIds,posIds,axis,crossSectionArea=bb['negIds'],bb['posIds'],bb['axis'],bb['area']
O.dt=dtSafety*PWaveTimeStep()
print 'Timestep',O.dt

mm,mx=[pt[axis] for pt in aabbExtrema()]
coord_25,coord_50,coord_75=mm+.25*(mx-mm),mm+.5*(mx-mm),mm+.75*(mx-mm)
area_25,area_50,area_75=approxSectionArea(coord_25,axis),approxSectionArea(coord_50,axis),approxSectionArea(coord_75,axis)

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=intRadius,label='is2aabb'),],verletDist=.05*sphereRadius),
	InteractionLoop(
Beispiel #28
0
# 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(
        pack.inGtsSurface(surf), radius=3e-2, rRelFuzz=1e-1, memoizeDb="/tmp/gts-triax-packings.sqlite", useOBB=False
    )
)

from yade import qt

qt.View()
Beispiel #29
0
# using spheres 7mm of diameter
concreteId = O.materials.append(
    CpmMat(young=young,
           frictionAngle=frictionAngle,
           poisson=poisson,
           density=4800,
           sigmaT=sigmaT,
           relDuctility=relDuctility,
           epsCrackOnset=epsCrackOnset,
           isoPrestress=isoPrestress))

sps = SpherePack()
sp = pack.randomDensePack(pack.inHyperboloid(
    (0, 0, -.5 * specimenLength), (0, 0, .5 * specimenLength),
    .25 * specimenLength, .17 * specimenLength),
                          spheresInCell=2000,
                          radius=sphereRadius,
                          memoizeDb='/tmp/triaxPackCache.sqlite',
                          returnSpherePack=True)
#sp=pack.randomDensePack(pack.inAlignedBox((-.25*specimenLength,-.25*specimenLength,-.5*specimenLength),(.25*specimenLength,.25*specimenLength,.5*specimenLength)),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite',returnSpherePack=True)
sp.toSimulation(material=concreteId)
bb = uniaxialTestFeatures()
negIds, posIds, axis, crossSectionArea = bb['negIds'], bb['posIds'], bb[
    'axis'], bb['area']
O.dt = dtSafety * PWaveTimeStep()
print 'Timestep', O.dt

mm, mx = [pt[axis] for pt in aabbExtrema()]
coord_25, coord_50, coord_75 = mm + .25 * (mx - mm), mm + .5 * (
    mx - mm), mm + .75 * (mx - mm)
area_25, area_50, area_75 = approxSectionArea(
Beispiel #30
0
from yade import pack

"""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)
#
# http://beta.arcig.cz/~eudoxos/yade/epydoc/yade._packPredicates.inAlignedBox-class.html
# http://beta.arcig.cz/~eudoxos/yade/epydoc/yade._packPredicates.inCylinder-class.html

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 
#
# http://beta.arcig.cz/~eudoxos/yade/epydoc/yade.pack-module.html#randomDensePack
O.bodies.append(pack.randomDensePack(pred,radius=rSphere,rRelFuzz=.3,memoizeDb='/tmp/triaxPackCache.sqlite',spheresInCell=3000))

from yade import qt
qt.Controller()
qt.View()