← Back to team overview

yade-users team mailing list archive

Re: [Question #702665]: How to calculate the height of particle accumulation?

 

Question #702665 on Yade changed:
https://answers.launchpad.net/yade/+question/702665

孙灿 posted a new comment:
I tried the code again and there was no output from zdim.
The code is as follows:


from yade import pack,plot
O.bodies.append(geom.facetBox((0.05, 9, 10), (0.1, 9, 10), wallMask=63))
sp = pack.SpherePack()
sp.makeCloud(Vector3(0.05,0,0),Vector3(0.05,18,20), rMean=0.1, rRelFuzz=1/3)
sp.toSimulation()

(xdim,ydim,zdim)= aabbDim()

print("Height is ",zdim)

for b in O.bodies:
   if isinstance(b.shape,Sphere):
       b.state.blockedDOFs='ZxY'
       b.shape.color=(3.,2.,1.)
       
circleRadius=1.5
circleCenter = Vector3(0.05,6,6)
circleRadius1=1.5
circleCenter1 = Vector3(0.05,12,6)
   #
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 = 0.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


# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
	if unbalancedForce() < .05:
		O.pause()
		plot.saveDataTxt('bbb.txt.bz2')
                for b in O.bodies:
		    if isinstance(b.shape,Sphere):
                        #b.state.blockedDOFs='zxy'
                        b.state.vel=(0,0,0)
                        b.state.angVel=(0,0,0)
                    d = (b.state.pos - circleCenter).norm() # distance of circleCenter and center of "b"
                    d1 = (b.state.pos - circleCenter1).norm() # distance of circleCenter and center of "b"
                    if d < circleRadius:
                       O.bodies.erase(b.id)
                    if d1 < circleRadius1:
                       O.bodies.erase(b.id)
 

		O.bodies.append(sphere(center=(0.05,7.378730854,6.1431074487337), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.315569669,6.37882820065594), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.212435565,6.6), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.07246222,6.79990265356116), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.899902654,6.97246222036657), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.7,7.11243556529821), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.478828201,7.21556966910027), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.243107449,7.27873085421709), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6,7.3), radius=.1274, fixed=True,color=(1.,1.,1.)))

		O.bodies.append(sphere(center=(0.05,5.756892551,7.27873085421709), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.521171799,7.21556966910027), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.3,7.11243556529822), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.100097346,6.97246222036657), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.92753778,6.79990265356116), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.787564435,6.6), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.684430331,6.37882820065594), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.621269146,6.1431074487337), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.6,5.9), radius=.1274, fixed=True,color=(1.,1.,1.)))

		O.bodies.append(sphere(center=(0.05,4.621269146,5.6568925512663), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.684430331,5.42117179934406), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.787564435,5.2), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,4.92753778,5.00009734643885), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.100097346,4.82753777963343), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.3,4.68756443470179), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.521171799,4.58443033089973), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,5.756892551,4.52126914578291), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6,4.5), radius=.1274, fixed=True,color=(1.,1.,1.)))

		O.bodies.append(sphere(center=(0.05,6.243107449,4.52126914578291), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.478828201,4.58443033089973), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.7,4.68756443470179), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,6.899902654,4.82753777963343), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.07246222,5.00009734643885), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.212435565,5.2), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.315569669,5.42117179934406), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.378730854,5.6568925512663), radius=.1274, fixed=True,color=(1.,1.,1.)))
		O.bodies.append(sphere(center=(0.05,7.4,5.9), radius=.1274, fixed=True,color=(1.,1.,1.)))


# collect history of data which will be plotted
def addPlotData():
	# 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)


# 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)}

# show the plot on the screen, and update while the simulation runs
plot.plot()

O.saveTmp()


# to see it
from yade import qt
qt.Controller()
qt.View()
qt.View()

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.