silulation can not quit

Asked by lip on 2019-01-27

i was going to do creat a boundary consist of many walls, the particles deposited by gravity within the boundary, and then i want to remove one of the wall to destabilize the accumulation and let the particles flow along a chute. But i put the code which remove the wall in the checkUnbalance function and make the simulation can not quit, i do not know where to put the code to let the simulation quit. Below is my code:

from yade import polyhedra_utils,pack,plot
import random

m = PolyhedraMat()
m.density = 2600 # kg/m^3
m.young = 1E6 # Pa
m.poisson = 20000 / 1E6
m.frictionAngle = 0.6 # rad

O.bodies.append(utils.wall(-1, axis=2, sense=1, material=m))
O.bodies.append(utils.wall(10, axis=0, sense=-1, material=m))
O.bodies.append(utils.wall(0, axis=0, sense=1, material=m))
O.bodies.append(utils.wall(10, axis=1, sense=-1, material=m))
O.bodies.append(utils.wall(0, axis=1, sense=1, material=m))
# generate randomly spheres with uniform radius distribution

O.engines = [
    InsertionSortCollider([Bo1_Polyhedra_Aabb(), Bo1_Wall_Aabb(), Bo1_Facet_Aabb()]),
        [Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom(),
        [Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()], # collision "physics"
        [Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()] # contact law -- apply forces
    # GravityEngine(gravity=(0,0,-9.81)),
    NewtonIntegrator(damping=0.5, gravity=(0, 0, -9.81)),
    PyRunner(command='checkUnbalanced()', realPeriod=3, label='checker')

# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as['energyName'] subsequently
# 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:
      # plot.saveGnuplot('bbb') is also possible

# 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 ** converts dictionary-like to plot.addData arguments

# 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
# ( is function which will be called to get all defined energies)
# None separates left and right y-axis

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


i would appreciate it if you can help me

Question information

English Edit question
Yade Edit question
No assignee Edit question
Last query:
Last reply:
Jan Stránský (honzik) said : #1

Hello, [2] just runs.. To stop, you have several options:

1) call O.pause() manually [1]

2) run specific number of time steps "hardcoded" in [2] or,True)

3) use O.stopAt*[3,4]
O.stopAtIter = 1000

4) use another function in PyRunner and call O.pause (similar to what you do in checkUnbalanced):
def checkStopCondition():
   if yourConditionToStop:
O.engines = [



Can you help with this problem?

Provide an answer of your own, or ask lip for more information if necessary.

To post a message you must log in.