Question #702750 on Yade changed: https://answers.launchpad.net/yade/+question/702750
孙灿 posted a new comment: I tried it and found that the code had no errors, but no z-value output for the uppermost particles. 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( # 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) #coords = [b.state.pos for b in O.bodies] #print(b.state.pos) #zMax = max(b.state.pos[2] for b in O.bodies) O.bodies.append(sphere(center=(0.05,7.38276367683319,6.11900825105632), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.33147912281321,6.33262379212493), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.24740913386372,6.53558669963537), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.13262379212493,6.72289935320946), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.98994949366117,6.88994949366117), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.82289935320946,7.03262379212493), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.63558669963537,7.14740913386372), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.43262379212493,7.23147912281322), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.21900825105632,7.28276367683319), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6,7.3), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.78099174894368,7.28276367683319), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.56737620787507,7.23147912281322), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.36441330036463,7.14740913386372), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.17710064679054,7.03262379212493), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.01005050633883,6.88994949366117), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.86737620787507,6.72289935320946), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.75259086613629,6.53558669963537), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.66852087718679,6.33262379212493), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.61723632316681,6.11900825105632), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.6,5.9), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.61723632316681,5.68099174894368), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.66852087718678,5.46737620787507), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.75259086613629,5.26441330036464), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,4.86737620787507,5.07710064679054), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.01005050633883,4.91005050633883), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.17710064679054,4.76737620787507), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.36441330036463,4.65259086613629), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.56737620787507,4.56852087718679), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,5.78099174894368,4.51723632316681), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6,4.5), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.21900825105632,4.51723632316681), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.43262379212493,4.56852087718679), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.63558669963537,4.65259086613629), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.82289935320946,4.76737620787507), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,6.98994949366117,4.91005050633883), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.13262379212493,5.07710064679054), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.24740913386372,5.26441330036464), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.33147912281321,5.46737620787507), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.38276367683319,5.68099174894368), radius=.1019, fixed=True,color=(1.,1.,1.))) O.bodies.append(sphere(center=(0.05,7.4,5.9), radius=.1019, fixed=True,color=(1.,1.,1.))) zMax = max(b.state.pos[2] for b in O.bodies) (xdim,ydim,zdim)= aabbDim() print("Height is ",zdim) # 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() Cheers -- You received this question notification because your team yade-users is an answer contact for Yade. _______________________________________________ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp