← Back to team overview

yade-users team mailing list archive

[Question #153493]: Example problem, or to create a function ?

 

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

Hi,

I'm a beginner with Yade Software, I have Ubuntu 10.10 and Yade bzr2811.

I try to run the example Gravity Deposition of the tutorial but I have some problems.

The script is:
"from yade import pack, plot

O.bodies.append(utils.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))

sp=pack.SpherePack()

sp.makeCloud((0,0,0),(1,1,1),rMean=.05,rRelFuzz=.5)

sp.toSimulation()
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
    InteractionLoop(
        [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.4),
    PyRunner(command='checkUnbalanced()',realPeriod=2),
    PyRunner(command='addPlotData()',iterPeriod=100)
    ]

O.dt=.5*utils.PWaveTimeStep()

O.trackEnergy=True

def checkUnbalanced():
if utils.unbalancedForce()<.05:
O.pause()
plot.saveDataTxt('bbb.txt.bz2')

def addPlotData():
plot.addData(i=O.iter,unbalanced=utils.unbalancedForce(),**O.energy)

plot.plots={'i':('unbalanced',None,O.energy.keys)}

plot.plot()
O.saveTmp()"

When I try to run it's written:
"Yade [18]: ---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/arthur/yade/build/lib/yade-new/py/yade/__init__.pyc in <module>()
----> 1 
      2 
      3 
      4 
      5 

NameError: name 'checkUnbalanced' is not defined

NameError: name 'addPlotData' is not defined
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/arthur/yade/build/lib/yade-new/py/yade/__init__.pyc in <module>()
----> 1 
      2 
      3 
      4 
      5 "
So my question is what is not good with the code ? And why to define the functions checkUnbalanced and addPlotData after the O.engines, why not before O.engines ?
How do I run a plot; 'cause when I write 
"Yade [21]: import yade.plot; yade.plot.plot();
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

/home/arthur/yade/build/lib/yade-new/py/yade/__init__.pyc in <module>()
----> 1 
      2 
      3 
      4 
      5 

/home/arthur/yade/build/lib/yade-new/py/yade/plot.pyc in plot(noShow, subPlots)
    586         global currLineRefs
    587         figs=set([l.line.get_axes().get_figure() for l in currLineRefs])
--> 588         if not hasattr(list(figs)[0],'show') and not noShow:
    589                 import warnings
    590                 warnings.warn('plot.plot not showing figure (matplotlib using headless backend?)')

IndexError: list index out of range" ?

Thanks !



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