← Back to team overview

yade-users team mailing list archive

[Question #697874]: Dose 'utils' object has the attribute 'saveDataTxt'

 

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

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()

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.