yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #10729
[Question #260135]: problem of pyrunner when import yade
New question #260135 on Yade:
https://answers.launchpad.net/yade/+question/260135
Hello,
I import yade into .py script and define a pyrunner in the Engine.
Then I use python to run the script.
But sometimes the script goes well, more often it gets an error of " name...is not defined ".
Can anyone tell me how to handle it? I use yade-1.11.0.
Here are the script and results.
__________________________________________
import sys
sys.path.append('/home/xw/tmp/trashOfTttmp/test/otherWayToImport')
from yadeimport import *
# basic material
print("~~~~~this is ~start~~~")
matS = O.materials.append(FrictMat(young=1e4))
# create 3 spheres
b1 = utils.sphere((-1,.35,4.5),.5,material=matS)
b2 = utils.sphere((.6,-2,3.5),.5,material=matS)
b3 = utils.sphere((-2,-2,4.0),.5,material=matS)
# and assign initial velocity to them
b1.state.vel = (2,0,.5)
b2.state.vel = (0,2,.5)
b3.state.vel = (2,2,.5)
yade.O.bodies.append((b1,b2,b3))
def addForceStep():
print("addForceStep")
# standard YADE engines
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()]),
PyRunner(command="addForceStep()",iterPeriod=10),
NewtonIntegrator(gravity=(0,0,-.3)),
]
O.run(11)
print("~~~~~this is ~end~~~")
__________________________________
xw@xw-P55A-UD3R:~/tmp/trashOfTttmp/test/otherWayToImport$ python 2model.py
~~~~~this is ~start~~~
~~~~~this is ~end~~~
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'addForceStep' is not defined
xw@xw-P55A-UD3R:~/tmp/trashOfTttmp/test/otherWayToImport$ python 2model.py
~~~~~this is ~start~~~
~~~~~this is ~end~~~
addForceStep
_________________________________
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.