yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #17615
Re: [Question #670501]: gravity deposition of clumps
Question #670501 on Yade changed:
https://answers.launchpad.net/yade/+question/670501
Status: Needs information => Open
rhaven gave more information on the question:
Hi Jan,
It should work as extend was a global variable.
In case it still doesnt work, Ive moved the section where extend is used to be a part of gravityDeposition()
######################################################################
# A script for creating a dense packing of clumps
#
# Each aggragate is a dense packing, but macroscopically the packing
# is loose
######################################################################
def getClumpInfo():
c = []
for b in O.bodies:
#print(b.isClump)
if b.isClump:
c.append(b)
#print(b.shape)
print('Clump ',b.id,' has following members:')
keys = b.shape.members.keys()
for ii in range(0,len(keys)):
print('- Body ',keys[ii])
#print(c)
return c
def setClumpInfo(disp=False):
c = []
aggNum = -1
for b in O.bodies:
#print(b.isClump)
if b.isClump:
aggNum+=1
c.append(b)
#print(b.shape)
if disp: print('Clump ',b.id,' has following members:')
keys = b.shape.members.keys()
for ii in range(0,len(keys)):
if disp: print('- Body ',keys[ii])
#O.bodies[keys[ii]].agglomerate = b.id # tell each particle who is its agglomerate
O.bodies[keys[ii]].agglomerate = aggNum # tell each particle who is its agglomerate
print(str(len(c))+ ' ' + str(aggNum))
return len(c) #number of clumps
# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
from yade import pack, plot
if unbalancedForce()<.05:
O.pause()
plot.saveDataTxt('bbb.txt.bz2')
# plot.saveGnuplot('bbb') is also possible
# collect history of data which will be plotted
def addPlotData():
from yade import pack, plot
# each item is given a names, by which it can be the unsed in plot.plots
# the **O.energy converts dictionary-like O.energy to plot.addData arguments
plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
def gravityDeposition():
# gravity deposition in box, showing how to plot and save history of data,
# and how to control the simulation while it is running by calling
# python functions from within the simulation loop
# import yade modules that we will use below
from yade import pack, plot
dim=utils.aabbExtrema()
dim=utils.aabbExtrema()
xinf=dim[0][0]
xsup=dim[1][0]
xdim = xsup-xinf
X=xinf+(xdim)/2.
yinf=dim[0][1]
ysup=dim[1][1]
ydim = ysup-yinf
Y=yinf+(ydim)/2.
zinf=dim[0][2]
zsup=dim[1][2]
zdim = zsup-zinf
Z=zinf+(zdim)/2.
center = Vector3(X,Y,Z) #center of the packing
extend = Vector3(xdim,ydim,zdim) #extends of the packing
# create rectangular box from facets
O.bodies.append(geom.facetBox(center,extend,wallMask=31))
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
# call the checkUnbalanced function (defined below) every 2 seconds
PyRunner(command='checkUnbalanced()',realPeriod=2),
# call the addPlotData function every 200 steps
PyRunner(command='addPlotData()',iterPeriod=100)
]
O.dt=.5*PWaveTimeStep()
# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy['energyName'] subsequently
O.trackEnergy=True
#O.run(500,True)
raw_input('test')
# define how to plot data: 'i' (step number) on the x-axis, unbalanced force
# on the left y-axis, all energies on the right y-axis
# (O.energy.keys is function which will be called to get all defined energies)
# None separates left and right y-axis
plot.plots={'i':('unbalanced',None,O.energy.keys)}
O.run(1000,True)
# show the plot on the screen, and update while the simulation runs
plot.plot()
from yade import pack,export,ymport
import random
random.seed(1) # to make colors always the same
numClumps = 2
minCorner = (0,0,0)
maxCorner = (7e-7,7e-7,7e-7)
#O.periodic=True
sp = pack.SpherePack()
# load clumps
ymport.textClumps('/tmp/clump0.txt')
c0 = pack.SpherePack()
c0.fromSimulation()
ymport.textClumps('/tmp/clump1.txt')
#c1 = getClumpInfo()
c1 = pack.SpherePack()
c1.fromSimulation()
O.switchScene(); O.resetThisScene() #####!!!!!!!
print('Creating Clump Cloud')
test = sp.makeClumpCloud(minCorner, maxCorner, [c0,c1], periodic=True, num = 1000)#, periodic=True, num=-1, seed=1)
print(test)
sp.toSimulation()
raw_input('Before gravity')
gravityDeposition()
raw_input('After gravity')
quit()
setClumpInfo()
#print(enumerate(sp))
# save the result, including information of agglomerates which the particle belongs to
export.textExt('/tmp/divided.txt','x_y_z_r_attrs',attrs=['b.agglomerate'])
print('Number of particles = ' , len(O.bodies))
try:
from yade import qt
qt.View()
except:
pass
--
You received this question notification because your team yade-users is
an answer contact for Yade.