← Back to team overview

yade-users team mailing list archive

Re: [Question #250147]: Error occur for sys.exit()

 

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

    Status: Answered => Open

Jie Qin is still having a problem:
Hi, Klause, thank you for your reply.

Firstly, like the following "bouncing spheres", the example provided by
Yade, when I add a exit() function, the errors occur.

Secondly, I do want to use yade-batch to simulate multiple situations
and that is why I want to use the exit function. I do not catch what is
your meaning that it automatically exits, because I was just following
the tutorials of yade-batch method.

---------------------------------bouncing spheres----------------------------------------------------------
O.bodies.append([
   utils.sphere((0,0,0),.5,fixed=True),
   utils.sphere((0,0,2),.5)
])

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_L3Geom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_L3Geom_FrictPhys_ElPerfPl()]
   ),
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.2),
   PyRunner(command='checkPosition()',realPeriod=2)
]
O.dt=0.5e-3*utils.PWaveTimeStep()

def checkPosition():
   if utils.unbalancedForce()<0.001:
      import sys
      sys.exit()


----------------------------------yade-batch tutorial---------------------------------------------
O.engines+=[PyRunner(iterPeriod=1000,command='checkUnbalancedForce()')]    # call our function defined below periodically

def checkUnbalancedForce():
   if utils.unbalancedForce<0.05:                      # exit Yade if unbalanced force drops below 0.05
      utils.saveDataTxt(O.tags['d.id']+'.data.bz2')    # save all data into a unique file before exiting
      import sys
      sys.exit(0)                                      # exit the program

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.