← Back to team overview

yade-users team mailing list archive

[Question #169494]: PyRunner can't find a function

 

New question #169494 on Yade:
https://answers.launchpad.net/yade/+question/169494

I am a beginner with YADE. I tried to add PyRunner to Engines but it doesn't work properly. The code does not work:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O.bodies.append(utils.sphere((.1,.1,.2),0.1,color=(0,0,1)))
O.bodies.append(utils.facet([(0,0,0),(.2,0,0),(0,.2,0)]))
O.bodies.append(utils.facet([(.2,.2,0),(.2,0,0),(0,.2,0)]))

def myrun():
   print 'hello world :)'

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
   InteractionLoop(
      # handle sphere+sphere and facet+sphere collisions
      [Ig2_Sphere_Sphere_L3Geom(),Ig2_Facet_Sphere_L3Geom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_L3Geom_FrictPhys_ElPerfPl()]
   ),
   GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.1),
   PyRunner(command='myrun()',iterPeriod=200)
]

O.dt=0.000001
O.saveTmp()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An error message appears: "name 'myrun' is not defined"
The same problem occurs when I copy/paste the code from the "Gravity deposition" example. PyRunner can't find the function. What can it be? Thank you

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