예제 #1
0
def modifyLayer():
    if O.iter < thres:
        return

    if O.iter > thres:
        O.pause()

    for i in s:
        if O.bodies[i].state.pos[1] > box_height or O.bodies[i].state.pos[0]>box_length:

	    #delete spheres that are above the target height
            O.bodies.erase(i) 

	    #also,delete the corresponding ids in the id list
            s.remove(i) 	    
            
    export.text('sample.txt')   
예제 #2
0
def checkHeight():
    global lastDens
    M = 0
    for i in spheres:
        if O.bodies[i].state.pos[2] > sample_h:
            O.bodies.erase(i)
            spheres.remove(i)
        else:
            M += O.bodies[i].state.mass
    dens = M / (l * d * sample_h)
    print "Density: %.3f" % dens
    print "Sample Height: %.3f" % max(
        [O.bodies[i].state.pos[2] for i in spheres])

    if dens == lastDens:  #if the density doesn't change anymore, export the file
        export.text('dens%dYoung%.1fGPaL%dH%d.txt' %
                    (dens, young / 1e9, l, sample_h))
    else:
        lastDens = dens
예제 #3
0
    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()
예제 #4
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 :-)
예제 #5
0
                        O.bodies[n.id1].state.jointNormal1=-jointNormalRef


#### for visualization:
#bj=0
#vert=(0.,1.,0.)
#hor=(0.,1.,1.)
#for o in O.bodies:
    #if o.state.onJoint==True : # or o.shape.name=='Facet':
	##if  o.shape.name=='Facet':
	    ##o.shape.wire=True
	##o.state.pos+=(0,50,0)
	##bj+=1
	#if o.state.jointNormal1.dot(hor)>0 :
	    ##o.state.pos+=(0,50,0)
	    #o.shape.color=jointcolor1
	#elif o.state.jointNormal1.dot(hor)<0 :
	    ##o.state.pos+=(0,55,0)
	    #o.shape.color=jointcolor2
	#if o.mat.type>2 :
	    #bj+=1
	    #o.shape.color=jointcolor5
	    ##print o.state.jointNormal.dot(vert)


#### Save text file with informations on each sphere
export.text(packing+'_'+DFN+'.spheres')
export.textExt(packing+'_'+DFN+'_jointedPM.spheres',format='jointedPM')

O.wait()
			O.bodies[n.id1].state.jointNormal1=-jointNormalRef


#### for visualization:
#bj=0
#vert=(0.,1.,0.)
#hor=(0.,1.,1.)
#for o in O.bodies:
    #if o.state.onJoint==True : # or o.shape.name=='Facet':
	##if  o.shape.name=='Facet':
	    ##o.shape.wire=True
	##o.state.pos+=(0,50,0)
	##bj+=1
	#if o.state.jointNormal1.dot(hor)>0 :
	    ##o.state.pos+=(0,50,0)
	    #o.shape.color=jointcolor1
	#elif o.state.jointNormal1.dot(hor)<0 :
	    ##o.state.pos+=(0,55,0)
	    #o.shape.color=jointcolor2
	#if o.mat.type>2 :
	    #bj+=1
	    #o.shape.color=jointcolor5
	    ##print o.state.jointNormal.dot(vert)


#### Save text file with informations on each sphere
export.text(packing+'_'+DFN+'.spheres')
export.textExt(packing+'_'+DFN+'_jointedPM.spheres',format='jointedPM')

O.wait()
def write():
   export.text('randomPacking'+str(int(2000*Rsreal))+'mm'+str(amount))
   O.pause()
예제 #8
0
파일: export_text.py 프로젝트: yade/trunk
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 :-)
예제 #9
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()

예제 #10
0
######################################################################
# A script for prepare loose packing of macro particles
######################################################################
from yade import export

dim = (15, 15, 15)  # dimensions for makeCloud
radius = 1
fuzz = 0.2

# use of makeCloud function
sp = pack.SpherePack()
sp.makeCloud((0, 0, 0), dim, rMean=radius, rRelFuzz=fuzz, seed=1)
sp.toSimulation()

# save the result
export.text('/tmp/cloud.txt')

try:
    from yade import qt
    qt.View()
except:
    pass
예제 #11
0
def write():
    export.text('randomPacking' + str(int(2000 * Rsreal)) + 'mm' + str(amount))
    O.pause()
예제 #12
0
def position():
    export.text(OUT + '_' + str(O.iter))
예제 #13
0
파일: makeCloud.py 프로젝트: Kubeu/trunk
######################################################################
# A script for prepare loose packing of macro particles
######################################################################
from yade import export

dim    = (15,15,15) # dimensions for makeCloud
radius = 1
fuzz   = 0.2

# use of makeCloud function
sp = pack.SpherePack()
sp.makeCloud((0,0,0), dim, rMean=radius, rRelFuzz=fuzz, seed=1)
sp.toSimulation()

# save the result
export.text('/tmp/cloud.txt')

try:
	from yade import qt
	qt.View()
except:
	pass