Example #1
0
for i in range(n):
	d = random.random()*(dMax-dMin) + dMin # distance of plane from center, random number in range (dMin,dMax)
	# http://mathworld.wolfram.com/HyperspherePointPicking.html
	normal = Vector3([random.gauss(0,10) for _ in range(3)]) # random normal vector
	normal.normalize()
	planes.append((center-d*normal,normal))
pred3 = pack.inConvexPolyhedron(planes)

try: # should be ValueError, since the 3 planes does not form closed polyhedron and finding its bounds should fail
	pred4 = pack.inConvexPolyhedron((
		((0,0,0), (+1, 0, 0)),
		((0,0,0), ( 0,+1, 0)),
		((0,0,0), ( 0, 0,+1)),
	))
except ValueError:
	print('ValueError successfully detected')
else:
	raise RuntimeError("ValueError should have been detected...")

r = .05
for p in (pred1,pred2,pred3):
	O.bodies.append(pack.regularHexa(p,r,0,color=randomColor()))


try:
	from yade import qt
	v = qt.View()
	v.axes = True
except:
	pass
Example #2
0
import itertools
import random
import yade.plot

## corners of the initial packing
mn,mx=Vector3(0,0,0),Vector3(10,10,10)

## create material #0, which will be used as default
O.materials.append(FrictMat(young=6e6,poisson=.4,frictionAngle=radians(5),density=2600))
O.materials.append(FrictMat(young=6e6,poisson=.4,frictionAngle=0,density=2600,label='frictionless'))

d=8

# clumps
for xyz in itertools.product(arange(0,d),arange(0,d),arange(0,d)):
	ids_spheres=O.bodies.appendClumped(pack.regularHexa(pack.inEllipsoid((mn[0]+xyz[0]*(mx[0]-mn[0])/d,mn[0]+xyz[1]*(mx[1]-mn[1])/d,mn[2]+xyz[2]*(mx[2]-mn[2])/d),(0.45+random.random()*0.1,0.45+random.random()*0.1,0.45+random.random()*0.1)),radius=0.15+random.random()*0.05,gap=0,color=[random.random(),random.random(),random.random()]))

## create walls around the packing
walls=aabbWalls(material='frictionless')
wallIds=O.bodies.append(walls)

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


## hope that we got the ids right?!
triax=TriaxialCompressionEngine(
	wall_bottom_id=wallIds[2],
	wall_top_id=wallIds[3],
	wall_left_id=wallIds[0],
Example #3
0
    N = int(sys.argv[1])
    M = int(sys.argv[2])

############  Build a scene (we use Yade's pre-filled scene)  ############

# sequential grain colors
import colorsys
from yade import pack
colorScale = (Vector3(colorsys.hsv_to_rgb(value * 1.0 / numThreads, 1, 1))
              for value in range(0, numThreads))

#generate packing
mn, mx = Vector3(0, 2, 0), Vector3(50, 180, 90)
pred = pack.inAlignedBox(mn, mx)
O.bodies.append(pack.regularHexa(
    pred, radius=1.20,
    gap=0))  #change radius for more spheres, r=0.45 --> ~1.5M particles
nspheres = len(O.bodies)
for b in O.bodies:
    b.material.frictionAngle = 0.05
#print "len  = ", nspheres
wallIds = aabbWalls([Vector3(0, -1, -0), Vector3(80, 360, 200)], thickness=0)
O.bodies.append(wallIds)
WALL_ID = wallIds[2]

#print "len of bodies = ", len(O.bodies)

collider.verletDist = 0.4
collider.targetInterv = 200
newton.gravity = (0, -17, 0)  #else nothing would move
tsIdx = O.engines.index(
Example #4
0
    else:
        print """horse.gts not found, you need to download input data:

		wget http://gts.sourceforge.net/samples/horse.gts.gz
		gunzip horse.gts.gz
		"""
        quit()

surf = gts.read(open('horse.coarse.gts'))

if surf.is_closed():
    pred = pack.inGtsSurface(surf)
    aabb = pred.aabb()
    dim0 = aabb[1][0] - aabb[0][0]
    radius = dim0 / 40.  # get some characteristic dimension, use it for radius
    O.bodies.append(pack.regularHexa(pred, radius=radius, gap=radius / 4.))
    surf.translate(
        0, 0, -(aabb[1][2] - aabb[0][2])
    )  # move surface down so that facets are underneath the falling spheres
O.bodies.append(pack.gtsSurface2Facets(surf, wire=True))

O.engines = [
    ForceResetter(),
    InsertionSortCollider(
        [Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()], label='collider'),
    InteractionLoop(
        [Ig2_Sphere_Sphere_L3Geom(),
         Ig2_Facet_Sphere_L3Geom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_L3Geom_FrictPhys_ElPerfPl()],
    ),
Example #5
0
from yade 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)
Example #6
0
                  wire=False))

### Creating the material for buldozer
colorsph1 = Vector3(120, 234, 150)
colorsph2 = Vector3(1, 1, 0)

colorsph1.normalize()
colorsph2.normalize()
colorSph = colorsph1
for xyz in itertools.product(arange(0, numBoxes[0]), arange(0, numBoxes[1]),
                             arange(0, numBoxes[2])):
    ids_spheres = O.bodies.appendClumped(
        pack.regularHexa(pack.inEllipsoid(
            (xyz[0] * (sizeBox + gapBetweenBoxes), xyz[1] *
             (sizeBox + gapBetweenBoxes) + sizeBox * 0.5, xyz[2] *
             (sizeBox + gapBetweenBoxes) - radiusKnife + sizeBox * 0.6),
            (sizeBox / 2, sizeBox / 2, sizeBox / 2)),
                         radius=radiusSph,
                         gap=0,
                         color=colorSph))
    if (colorSph == colorsph1):
        colorSph = colorsph2
    else:
        colorSph = colorsph1

from yade import qt

O.dt = 2 * utils.PWaveTimeStep()  # We do not need now a high accuracy
O.engines = [
    ForceResetter(),
    InsertionSortCollider([
        Bo1_Sphere_Aabb(),
Example #7
0
if rank is not None:  #mpiexec was used
    rank = int(rank)
    numThreads = int(os.getenv('OMPI_COMM_WORLD_SIZE'))
else:  #non-mpi execution, numThreads will still be used as multiplier for the problem size (2 => multiplier is 1)
    numThreads = 2 if len(sys.argv) < 1 else (int(sys.argv[1]))
    print "numThreads", numThreads

############  Build a scene (we use Yade's pre-filled scene)  ############

from yade import pack
import numpy as np
#mn,mx=Vector3(-10,-10,-10),Vector3(10,10,10) # uniform example
mn, mx = Vector3(-10, -15, -20), Vector3(10, 15,
                                         20)  # heterogeneous geometry example
pred = pack.inAlignedBox(mn, mx)
O.bodies.append(pack.regularHexa(pred, radius=0.8, gap=0))

from yade import domaindecomposition as dd

globalDomain = dd.GlobaldomainCloud(
    mn, mx, numThreads - 1
)  # automatically decompose domain into point cloud based subdomains (random subdomain shapes). Best choice for using random numbers of MPI threads
#globalDomain = dd.Globaldomain(mn,mx,numThreads-1) # automatically decompose the domain in organized grid for all directions for desired number of threads. Can use random numbers of MPI threads, but finicky
#globalDomain = dd.Globaldomain(mn,mx,xDecomp=1,yDecomp=1,zDecomp=numThreads-1) # manually decompose the domain in z direction for given number of threads. Ok choice for using random numbers of MPI threads

# sequential grain colors
import colorsys
colorScale = (Vector3(colorsys.hsv_to_rgb(value * 1.0 / numThreads, 1, 1))
              for value in range(0, numThreads))
colors = []
for i in range(numThreads):
Example #8
0

O.bodies.append(geom.facetBox((0,lengthKnife/2,radiusKnife),(lengthKnife*4,lengthKnife*4,lengthKnife),wallMask=16,color=(1,1,1),wire=False))




### Creating the material for buldozer
colorsph1=Vector3(120,234,150);
colorsph2=Vector3(1,1,0);

colorsph1.normalize();
colorsph2.normalize();
colorSph=colorsph1
for xyz in itertools.product(arange(0,numBoxes[0]),arange(0,numBoxes[1]),arange(0,numBoxes[2])):
	ids_spheres=O.bodies.appendClumped(pack.regularHexa(pack.inEllipsoid((xyz[0]*(sizeBox+gapBetweenBoxes),xyz[1]*(sizeBox+gapBetweenBoxes)+sizeBox*0.5,xyz[2]*(sizeBox+gapBetweenBoxes)-radiusKnife+sizeBox*0.6),(sizeBox/2,sizeBox/2,sizeBox/2)),radius=radiusSph,gap=0,color=colorSph))
	if (colorSph==colorsph1):
		colorSph=colorsph2
	else:
		colorSph=colorsph1


from yade import qt

O.dt=2*PWaveTimeStep() # We do not need now a high accuracy
O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
Example #9
0
'''

s1 = gts.read(open('horse.coarse.gts'))
s2 = gts.Surface()
s2.copy(s1)
s2.translate(0.04, 0, 0)
O.bodies.append(
    pack.gtsSurface2Facets(s1, color=(0, 1, 0)) +
    pack.gtsSurface2Facets(s2, color=(1, 0, 0)))

s12 = gts.Surface()
s12.copy(s1.union(s2))
s12.translate(0, 0, .1)
radius = 0.002
O.bodies.append(pack.gtsSurface2Facets(s12, color=(0, 0, 1)))

qt.View()
from time import time
t0 = time()
O.bodies.append(
    pack.regularHexa(pack.inGtsSurface(s1) | pack.inGtsSurface(s2),
                     radius,
                     gap=0,
                     color=(0, 1, 0)))
t1 = time()
print 'Using predicate union: %gs' % (t1 - t0)
O.bodies.append(
    pack.regularHexa(pack.inGtsSurface(s12), radius, gap=0., color=(1, 0, 0)))
t2 = time()
print 'Using surface union: %gs' % (t2 - t1)
Example #10
0
		nbIter=iterN[i]
		O.reset()
		
		tc=0.001
		en=.003
		es=.003
		frictionAngle=radians(35)
		density=2300
		defMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle,tc=tc,en=en,et=es))
		
		O.dt=.1*tc # time step
		rad=0.5 # particle radius
		tolerance = 0.0001
		
		SpheresID=[]
		SpheresID+=O.bodies.append(pack.regularHexa(pack.inSphere((Vector3(0.0,0.0,0.0)),rad),radius=rad/rR,gap=rad/rR*0.5,material=defMat))
		
		geometryParameters = bodiesHandling.spheresPackDimensions(SpheresID)
		print(len(SpheresID))
		
		floorId=[]
		floorId+=O.bodies.append(geom.facetBox(geometryParameters['center'],geometryParameters['extends']/2.0*1.05,material=defMat)) #Floor
		
		#Calculate the mass of spheres
		sphMass = getSpheresVolume()*density
		
		# Create engines
		O.engines=[
			ForceResetter(),
			InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
			InteractionLoop(
Example #11
0
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();
colorSph=colorsph1
for xyz in itertools.product(arange(0,numBoxes[0]),arange(0,numBoxes[1]),arange(0,numBoxes[2])):
	ids_spheres=O.bodies.appendClumped(pack.regularHexa(pack.inEllipsoid((xyz[0]*(sizeBox+gapBetweenBoxes),xyz[1]*(sizeBox+gapBetweenBoxes)+sizeBox*0.5,xyz[2]*(sizeBox+gapBetweenBoxes)-radiusKnife+sizeBox*0.6),(sizeBox/2,sizeBox/2,sizeBox/2)),radius=radiusSph,gap=0,color=colorSph,material=sphereMat))
	if (colorSph==colorsph1):
		colorSph=colorsph2
	else:
		colorSph=colorsph1

O.dt=.2*tc

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
		[Law2_ScGeom_ViscElPhys_Basic()],
	),
Example #12
0
defMat = O.materials.append(
    ViscElMat(density=density,
              frictionAngle=frictionAngle,
              tc=tc,
              en=en,
              et=es))

O.dt = .1 * tc  # time step
rad = 0.2  # particle radius
tolerance = 0.0001

SpheresID = []
SpheresID += O.bodies.append(
    pack.regularHexa(pack.inSphere((Vector3(0.0, 0.0, 0.0)), 0.5),
                     radius=rad,
                     gap=rad * 0.5,
                     material=defMat))

floorId = []
floorId += O.bodies.append(
    geom.facetBox((0, 0, 0), (0.6, 0.6, 0.6), material=defMat))  #Floor

#Calculate the weight of spheres
sphMass = utils.getSpheresVolume() * density * 9.81

# Create engines
O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),
                           Bo1_Facet_Aabb()]),
    InteractionLoop(
Example #13
0
density = 2300

params = utils.getViscoelasticFromSpheresInteraction(tc, en, es)
defMat = O.materials.append(
    ViscElMat(density=density, frictionAngle=frictionAngle, **params)
)  # **params sets kn, cn, ks, cs


O.dt = 0.1 * tc  # time step
rad = 0.2  # particle radius
tolerance = 0.0001


SpheresID = []
SpheresID += O.bodies.append(
    pack.regularHexa(pack.inSphere((Vector3(0.0, 0.0, 0.0)), 0.5), radius=rad, gap=rad * 0.5, material=defMat)
)

floorId = []
floorId += O.bodies.append(geom.facetBox((0, 0, 0), (0.6, 0.6, 0.6), material=defMat))  # Floor

# Calculate the weight of spheres
sphMass = utils.getSpheresVolume() * density * 9.81


# Create engines
O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
O.cell.refSize = (2, 2, 2)

from yade 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=0.1, rRelFuzz=0.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=0.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=0.4),
    # run checkStress function (defined below) every second
    # the label is arbitrary, and is used later to refer to this engine
    PyRunner(command="checkStress()", realPeriod=1, label="checker"),
Example #15
0
"""

from yade import pack,qt
import gts, locale

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')   #gts is locale-dependend.  If, for example, german locale is used, gts.read()-function does not import floats normally

'''
if you get "Error: unsupported locale setting"
-> type as root: "dpkg-reconfigure locales"
-> choose "en_US.UTF-8" (press space to choose)
'''

s1=gts.read(open('horse.coarse.gts'))
s2=gts.Surface(); s2.copy(s1); s2.translate(0.04,0,0)
O.bodies.append(pack.gtsSurface2Facets(s1,color=(0,1,0))+pack.gtsSurface2Facets(s2,color=(1,0,0)))

s12=gts.Surface(); s12.copy(s1.union(s2)); s12.translate(0,0,.1)
radius=0.002
O.bodies.append(pack.gtsSurface2Facets(s12,color=(0,0,1)))

qt.View()
from time import time
t0=time()
O.bodies.append(pack.regularHexa(pack.inGtsSurface(s1) | pack.inGtsSurface(s2),radius,gap=0,color=(0,1,0)))
t1=time()
print 'Using predicate union: %gs'%(t1-t0)
O.bodies.append(pack.regularHexa(pack.inGtsSurface(s12),radius,gap=0.,color=(1,0,0)))
t2=time()
print 'Using surface union: %gs'%(t2-t1)
Example #16
0
# -*- coding: utf-8 -*-
# © 2009 Václav Šmilauer <*****@*****.**>
# © 2013 Anton Gladky <*****@*****.**>

from yade import pack
import gts, os.path, locale

surf = gts.read(open('cone.gts'))

if surf.is_closed():
    pred = pack.inGtsSurface(surf)
    aabb = pred.aabb()
    dim0 = aabb[1][0] - aabb[0][0]
    radius = dim0 / 70.  # get some characteristic dimension, use it for radius
    O.bodies.appendClumped(
        pack.regularHexa(pred, radius=radius, gap=radius / 4.))
    surf.translate(
        0, -(aabb[1][1] - aabb[0][1]) / 2.0, -(aabb[1][2] - aabb[0][2])
    )  # move surface down so that facets are underneath the falling spheres
O.bodies.append(pack.gtsSurface2Facets(surf, wire=True))

O.engines = [
    ForceResetter(),
    InsertionSortCollider(
        [Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()], label='collider'),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom(),
         Ig2_Facet_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()],
    ),
from yade 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_ScGeom()],
                    [Ip2_FrictMat_FrictMat_FrictPhys()],
                    [Law2_ScGeom_FrictPhys_CundallStrack()]),
    NewtonIntegrator(damping=.4),
    # run checkStress function (defined below) every second
    # the label is arbitrary, and is used later to refer to this engine
Example #18
0
        dMax - dMin
    ) + dMin  # distance of plane from center, random number in range (dMin,dMax)
    # http://mathworld.wolfram.com/HyperspherePointPicking.html
    normal = Vector3([random.gauss(0, 10)
                      for _ in range(3)])  # random normal vector
    normal.normalize()
    planes.append((center - d * normal, normal))
pred3 = pack.inConvexPolyhedron(planes)

try:  # should be ValueError, since the 3 planes does not form closed polyhedron and finding its bounds should fail
    pred4 = pack.inConvexPolyhedron((
        ((0, 0, 0), (+1, 0, 0)),
        ((0, 0, 0), (0, +1, 0)),
        ((0, 0, 0), (0, 0, +1)),
    ))
except ValueError:
    print('ValueError successfully detected')
else:
    raise RuntimeError("ValueError should have been detected...")

r = .05
for p in (pred1, pred2, pred3):
    O.bodies.append(pack.regularHexa(p, r, 0, color=randomColor()))

try:
    from yade import qt
    v = qt.View()
    v.axes = True
except:
    pass
Example #19
0
             poisson=.4,
             frictionAngle=0,
             density=2600,
             label='frictionless'))

d = 8

# clumps
for xyz in itertools.product(arange(0, d), arange(0, d), arange(0, d)):
    ids_spheres = O.bodies.appendClumped(
        pack.regularHexa(
            pack.inEllipsoid(
                (mn[0] + xyz[0] * (mx[0] - mn[0]) / d, mn[0] + xyz[1] *
                 (mx[1] - mn[1]) / d, mn[2] + xyz[2] * (mx[2] - mn[2]) / d),
                (0.45 + random.random() * 0.1, 0.45 + random.random() * 0.1,
                 0.45 + random.random() * 0.1)),
            radius=0.15 + random.random() * 0.05,
            gap=0,
            color=[random.random(),
                   random.random(),
                   random.random()]))

## create walls around the packing
walls = aabbWalls(material='frictionless')
wallIds = O.bodies.append(walls)

from yade import qt

qt.Controller()
qt.View()
O.materials.append(FrictMat(young=5e6,poisson=0.3,density=2650,frictionAngle=radians(20),label='sphereMat'))

walls=utils.aabbWalls((Vector3(-0.001,-0.001,zmin),Vector3(hmaxx0,hmaxx0,zmax)),thickness=2.*r,oversizeFactor=1.,material='sphereMat')
wallIds=O.bodies.append(walls)
O.bodies.erase(walls[5].id)

startxyz=Vector3(-0.001,-0.001,0)

color=Vector3(0.9,0.9,0.9)
kw={'color':[0.8,0.8,0.8],'wire':False,'dynamic':True,'material':'sphereMat'}


predicate=inAlignedBox(Vector3(-0.001,-0.001,zmax),Vector3(xy+r_s,xy+r_s,zmax+2*r))   
sp=SpherePack()
sp=pack.regularHexa(predicate, radius=r_s, gap=0.001*0.10,**kw)
O.bodies.append(sp)


#predicate=inAlignedBox(Vector3(-0.001,-0.001,zmin),Vector3(xy+r_s,xy+r_s,zmean-2*r))   
#sp=SpherePack()
#sp=pack.regularHexa(predicate, radius=r_s, gap=0.001*0.10,**kw)
#O.bodies.append(sp)

Gl1_Sphere.stripes=True


topPlate=utils.wall(position=hMaxS(2)+r_s,sense=0, axis=2,color=Vector3(1,0,0),material='sphereMat')
O.bodies.append(topPlate)

Example #21
0
en=.003
es=.003
frictionAngle=radians(35)
density=2300

params=utils.getViscoelasticFromSpheresInteraction(tc,en,es)
defMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs


O.dt=.1*tc # time step
rad=0.2 # particle radius
tolerance = 0.0001


SpheresID=[]
SpheresID+=O.bodies.append(pack.regularHexa(pack.inSphere((Vector3(0.0,0.0,0.0)),0.5),radius=rad,gap=rad*0.5,material=defMat))

floorId=[]
floorId+=O.bodies.append(geom.facetBox((0,0,0),(0.6,0.6,0.6),material=defMat)) #Floor

#Calculate the weight of spheres
sphMass = utils.getSpheresVolume()*density*9.81


# Create engines
O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
Example #22
0
"""

rad,gap=.15,.02

#Add material
O.materials.append(FrictMat(young=10e9,poisson=.25,frictionAngle=0.5,density=1e3))

#Parameters, which will be passed into spheres and facets creators
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 #23
0
# this script demonstrates how to benchmark using timingEnabled: how to measure how much time each module takes.
from yade import pack, timing
#O.bodies.append([	sphere((0.2,0,0),.5,fixed=True), 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,
                     fixed=True))
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_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()],
    ),
    NewtonIntegrator(damping=0.4, gravity=[0, 0, -10]),
]
O.dt = .6 * PWaveTimeStep()
O.saveTmp()
#O.step()
#while True:
#	O.step()
# 2. Simulation setup:
# packages
from yade import pack, qt, plot 
import random, math
# periodicity
O.periodic=True
O.cell.refSize=(10*Dmax,10*Dmax,10*Dmax)
# loose particle packing
sp=pack.SpherePack()
# create different sized clusters
# hexagonal packing
Ca = []
for i in range(int(nClust)):
	size=Dmin+float(i)/float(nClust-1)*(Dmax-Dmin)
	Cai = pack.regularHexa(inEllipsoid((0,0,0),(size,size,size*ar)), Ra, -0.2*Ra)
	Caj=[]
	for j in range(len(Cai)):
		Caj.append((Cai[j].state.pos,Cai[j].shape.radius))
	Ca.append(Caj)
Cb = range(int(nClust))
for i in range(int(nClust)):
	Cb[i] = pack.SpherePack(Ca[i])
sp.makeClumpCloud((0,0,0),(10*Dmax,10*Dmax,10*Dmax),Cb,periodic=True,num=5000)
sp.toSimulation()
# Compaction completion temperature start variable
compDone=False
compIter=0.0
tempStart=False
# total heat
totHeat=0.0
Example #25
0
from yade import utils,pack,timing
#O.bodies.append([	utils.sphere((0.2,0,0),.5,fixed=True), 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,fixed=True))
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()],
	),
	NewtonIntegrator(damping=0.4,gravity=[0,0,-10]),
]
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
print('This will take a while, drink a coffee ;)')
O.timingEnabled=True
O.run(5000,True)
timing.stats()
import sys
#sys.exit(0)
Example #26
0
#Add material
O.materials.append(
    FrictMat(young=10e9, poisson=.25, frictionAngle=0.5, density=1e3))

#Parameters, which will be passed into spheres and facets creators
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
)
Example #27
0
		surf=gts.read(open('horse.gts')); surf.coarsen(1000); surf.write(open('horse.coarse.gts','w'))
	else:
		print """horse.gts not found, you need to download input data:

		wget http://gts.sourceforge.net/samples/horse.gts.gz
		gunzip horse.gts.gz
		"""
		quit()

surf=gts.read(open('horse.coarse.gts'))

if surf.is_closed():
	pred=pack.inGtsSurface(surf)
	aabb=pred.aabb()
	dim0=aabb[1][0]-aabb[0][0]; radius=dim0/40. # get some characteristic dimension, use it for radius
	O.bodies.append(pack.regularHexa(pred,radius=radius,gap=radius/4.))
	surf.translate(0,0,-(aabb[1][2]-aabb[0][2])) # move surface down so that facets are underneath the falling spheres
O.bodies.append(pack.gtsSurface2Facets(surf,wire=True))

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()],label='collider'),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()],
	),
	NewtonIntegrator(damping=.1,gravity=[0,0,-5000]),
	PyRunner(iterPeriod=1000,command='timing.stats(); O.pause();'),
	PyRunner(iterPeriod=10,command='addPlotData()')
]
## create material #0, which will be used as default
O.materials.append(FrictMat(young=6e6, poisson=0.4, frictionAngle=radians(5), density=2600))
O.materials.append(FrictMat(young=6e6, poisson=0.4, frictionAngle=0, density=2600, label="frictionless"))

d = 8

# clumps
for xyz in itertools.product(arange(0, d), arange(0, d), arange(0, d)):
    ids_spheres = O.bodies.appendClumped(
        pack.regularHexa(
            pack.inEllipsoid(
                (
                    mn[0] + xyz[0] * (mx[0] - mn[0]) / d,
                    mn[0] + xyz[1] * (mx[1] - mn[1]) / d,
                    mn[2] + xyz[2] * (mx[2] - mn[2]) / d,
                ),
                (0.45 + random.random() * 0.1, 0.45 + random.random() * 0.1, 0.45 + random.random() * 0.1),
            ),
            radius=0.15 + random.random() * 0.05,
            gap=0,
            color=[random.random(), random.random(), random.random()],
        )
    )

## create walls around the packing
walls = utils.aabbWalls(material="frictionless")
wallIds = O.bodies.append(walls)

from yade import qt

qt.Controller()
Example #29
0
from yade 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_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()]
	),
	NewtonIntegrator(damping=.4),
Example #30
0
from yade import pack, plot
from yade import export, ymport
from yade import utils
from yade import qt
from yade import plot
import sys,time

#####################
####### OBJ #######
#####################

O.materials.append(CohFrictMat(young=30000e6,poisson=0.3,density=3600,frictionAngle=radians(30),isCohesive=True,normalCohesion=1e100000000,shearCohesion=1e10000000,momentRotationLaw=True,etaRoll=0.1,label='spheres'))

pred=pack.inAlignedBox((0.05,-0.5,-0.05),(0.1,0.5,0.05))
spheres=pack.regularHexa(pred,radius=0.01,gap=0)
O.bodies.append(spheres)

for b in O.bodies:
   b.state.vel=(-18,0,0)

################
##box2 material##
################

idCA=FrictMat(density=2227,frictionAngle=radians(0.5),label='CA',young=30e9,poisson=0.15)
O.materials.append(idCA)

############################
####### BOX 2 ##############
############################