saving the data after simulation

Asked by Swapnil

I am running the following script to perform a certain test (penetration of a sphere into an assembly of other spheres). However, I am facing problems saving the plotted data. My script is as follows:

from yade import pack,plot
import os
pred=pack.inCylinder((0,0,0),(0,0,0.25),0.10)
sp=pack.randomDensePack(pred,radius=0.01,spheresInCell=300)
O.bodies.append(sp)
yade.qt.Controller()
idSteel=O.materials.append(FrictMat(young=210e9,poisson=.25,frictionAngle=.8,label="steel"))
hammer=sphere((0,0,0.30),0.04,material=idSteel)
hammerID=O.bodies.append(hammer)
hammer.state.blockedDOFs='z'
calm()
hammer.state.vel=Vector3(0,0,-0.5)
O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()]),InteractionLoop([Ig2_Sphere_Sphere_ScGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_ScGeom_FrictPhys_CundallStrack()]),NewtonIntegrator(),PyRunner(iterPeriod=100,command="addPlotData()")]
def addPlotData():
  Dz=hammer.state.displ()[2]
  Fz=O.forces.f(hammerID)[2]
  plot.addData(i=O.iter,Fz=Fz,Dz=Dz)
plot.plots={'Dz':('Fz')}
plot.plot()
O.dt=0.5*PWaveTimeStep()
O.saveTmp()
O.run()
#plot.saveDataTxt(/home/zg/scriptf/respentry1.dat)
print os.path.abspath("/home/zg/scriptf/representary1.dat")

The last line is what I have to figure out in order to save the required data. I, however, do not see any data file by the name "representary1" at the mentioned location. The terminal displays the following message:

TCP python prompt on localhost:9003, auth cookie `ssdeyc'
XMLRPC info provider on http://localhost:21003
Running script pentry1.py
No suitable packing in database found, running PERIODIC compression
/usr/lib/x86_64-linux-gnu/yade/py/yade/pack.py:296: FutureWarning: The default behavior will change; specify returnSpherePack=True for the new behavior, and False to get rid of this warning (your code will break in the future, however). The returned SpherePack object can be added to the simulation using SpherePack.toSimulation()
  warnings.warn('The default behavior will change; specify returnSpherePack=True for the new behavior, and False to get rid of this warning (your code will break in the future, however). The returned SpherePack object can be added to the simulation using SpherePack.toSimulation()',category=FutureWarning)
/home/zg/scriptf/representary1.dat
[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key for showing help), F10 both, F9 generator, F8 plot. ]]
[0;34mYade [[1;34m1[0;34m]: [0m
-----

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Swapnil (swapspace) said :
#1

My mistake I tried:
plot.saveDataTxt(/home/zg/scriptf/representry1.dat) (without the "#")
print os.path.abspath("/home/zg/scriptf/representary1.dat")

I can see the representary file but no data in there now.

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

Hello,

> print os.path.abspath("/home/zg/scriptf/representary1.dat")

no need to print it, it was just to show the difference between home/... and /home/...
You can just use plot.saveDataTxt("representary1.dat")
with the same result (assuming you are running your script from /home/zg/scriptf/

> I can see the representary file but no data in there now.

good :-) no data are there simply because at the time of saving, no data are stored yet

O.run(1000,True)
plot.saveDataTxt(...)

should do the job

cheers
Jan

Revision history for this message
Swapnil (swapspace) said :
#3

It does indeed :) Thanks

Can you help with this problem?

Provide an answer of your own, or ask Swapnil for more information if necessary.

To post a message you must log in.