← Back to team overview

yade-users team mailing list archive

Re: [Question #702877]: How do I correspond to the coordinates of particles and particles?

 

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

孙灿 posted a new comment:
My 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(
                [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),
        PyRunner(command='checkUnbalanced()', realPeriod=2),
        PyRunner(command='addPlotData()', iterPeriod=100)
]
O.dt = 0.5 * PWaveTimeStep()
O.trackEnergy = True

def checkUnbalanced():
	if unbalancedForce() < .05:
		O.pause()
		plot.saveDataTxt('bbb.txt.bz2')
		zMax = max(b.state.pos[2] for b in O.bodies if isinstance(b.shape,Sphere))
		print("Z ",zMax)
		layer = zMax-0.25
                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() 
                    d1 = (b.state.pos - circleCenter1).norm()
                    if d < circleRadius:
                       O.bodies.erase(b.id)
                    if d1 < circleRadius1:
                       O.bodies.erase(b.id)
                    #print(b.state.pos)	
		    if b.state.pos[2]>layer:
			print(b.id,b.state.pos)	
 		#zMax = max(b.state.pos[2] for b in O.bodies)

		#zMax = max(b.state.pos[2] for b in O.bodies)
		#print("Z ",zMax)
		(xdim,ydim,zdim)= aabbDim()

                print("Height is ",zdim)

def addPlotData():
	plot.addData(i=O.iter, unbalanced=unbalancedForce(), **O.energy)


O.saveTmp()

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


I use print (b.id, b.state.pos) to output the id and coordinates of the particle. For example, the id of a particle is 1, in the print (b.id, b.state.pos) I know its coordinates at this time, and then I run the code again, the coordinates of the particle will change, at this time I can directly call the particle with id 1, get the coordinates after running it?

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