Dose 'utils' object has the attribute 'saveDataTxt'

Asked by Russell

Hi, I am learning Yade-tutorial "setting up a simulation". I was trying to run the "Gravity deposition" script in batch mode according to the Yade-tutorial. However, an error occurred in this line of code " utils.saveDataTxt(O.tags['d.id']+'.data.bz2') ".

The error message is as follows:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "02-gravity-deposition-batchMode-3-queation.py", line 34, in checkUnbalanced
    utils.saveDataTxt(O.tags['d.id']+'.data.bz2')
AttributeError: 'module' object has no attribute 'saveDataTxt'

It seems that in my simulation, utils' object has no attribute 'saveDataTxt', while in Yade-tutorial "setting up a simulation", the expression "utils.saveDataTxt(O.tags['d.id']+'.data.bz2') " was used.

could you please help me with this problem.

Thank you very much!

My operating system is Ubuntu 16.04.

My codes are as follows:

############################## code #############################

# gravity deposition in box, showing how to plot and save history of data,
# and how to control the simulation while it is running by calling
# python functions from within the simulation loop

from yade import pack, plot

utils.readParamsFromTable(damping=.2)
from yade.params import table

O.bodies.append(geom.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_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 NewtonIntegrator(gravity=(0,0,-9.81),damping=table.damping),
 PyRunner(command='checkUnbalanced()',iterPeriod=1000),
 PyRunner(command='addPlotData()',iterPeriod=100)
]
O.dt=.5*PWaveTimeStep()

O.trackEnergy=True

def checkUnbalanced():
 if utils.unbalancedForce()<.05:
  utils.saveDataTxt(O.tags['d.id']+'.data.bz2')
  import sys
  sys.exit(0)

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

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

plot.plot()

O.run()
utils.waitIfBatch()

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
Russell (russell-zhang) said :
#1

My Yade version is Yade 1.20.0.

Revision history for this message
Robert Caulk (rcaulk) said :
#2

Please update your yade version and retry. Let us know if this fixes your problem.

Thank you,

Robert

Revision history for this message
Best Jan Stránský (honzik) said :
#3

Hello,

this is not about yade version (update will not fix the problem).
There is a mistake in the tutorial, the correct command is
plot.saveDataTxt(...) # plot, not utils, see also [1]

Cheers
Jan

[1] https://yade-dem.org/doc/yade.plot.html#yade.plot.saveDataTxt

Revision history for this message
Russell (russell-zhang) said :
#4

Thanks Jan Stránský, that solved my question.

Revision history for this message
Janek Kozicki (cosurgi) said :
#5

Thanks for pointing this out, it will be fixed once this is merged: https://gitlab.com/yade-dev/trunk/-/merge_requests/697