saveDataTxT

Asked by Christian Sommerfeld

Hi,

i want to save my plot data into a txt-file. Therefore i add all forces of a plane from a facet model. But there is no data in the txt-file. Now i'm a little confused because i tried a lot of ways.

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(damping=0.4, gravity=(0,0,-9.81)),
 RotationEngine(rotateAroundZero=True,zeroPoint=(0,0,0),rotationAxis=(0,0,1),angularVelocity=100*(2*pi/60),ids=tool,label='rotor'),
 PyRunner(iterPeriod=20,command="myAddPlotData()"),
]

def myAddPlotData():
 plot.addData(t=O.time,F=O.forces.f(0).norm()+O.forces.f(1).norm()+O.forces.f(2).norm()+O.forces.f(3).norm()+O.forces.f(4).norm()+O.forces.f(5).norm()+O.forces.f(6).norm()+O.forces.f(7).norm()+O.forces.f(8).norm()+O.forces.f(9).norm()+O.forces.f(10).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(12).norm()+O.forces.f(13).norm()+O.forces.f(14).norm()+O.forces.f(15).norm()+O.forces.f(16).norm()+O.forces.f(17).norm()+O.forces.f(18).norm()+O.forces.f(19).norm())

plot.plots={'t':('F')}
plot.plot()
plot.saveDataTxt('Force.txt.bz2')

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Christian Sommerfeld
Solved:
Last query:
Last reply:
Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

Is there really something in plot.data before you save it?
I never used this function. I usually prefer plot.saveGnuplot(), which not only save a data file but also generates a gnuplot script to plot it.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#2

No there isn't any data in plot.data at the beginning. I want to save it after a certain number of timesteps or simultaneously to the simulation. Is this possible?

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#3

Oh, it is the same with plot.saveGnuplot()

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

Hello Christian,
is that you complete script? if so, please notice that there is no run()
nor step() to execute the PyRunner with myAddPlotData() function.. Then of
course plot.data is empty.
Jan

2012/9/28 Christian Sommerfeld <email address hidden>

> New question #209832 on Yade:
> https://answers.launchpad.net/yade/+question/209832
>
> Hi,
>
> i want to save my plot data into a txt-file. Therefore i add all forces of
> a plane from a facet model. But there is no data in the txt-file. Now i'm a
> little confused because i tried a lot of ways.
>
>
>
> 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(damping=0.4, gravity=(0,0,-9.81)),
>
> RotationEngine(rotateAroundZero=True,zeroPoint=(0,0,0),rotationAxis=(0,0,1),angularVelocity=100*(2*pi/60),ids=tool,label='rotor'),
> PyRunner(iterPeriod=20,command="myAddPlotData()"),
> ]
>
>
>
> def myAddPlotData():
>
> plot.addData(t=O.time,F=O.forces.f(0).norm()+O.forces.f(1).norm()+O.forces.f(2).norm()+O.forces.f(3).norm()+O.forces.f(4).norm()+O.forces.f(5).norm()+O.forces.f(6).norm()+O.forces.f(7).norm()+O.forces.f(8).norm()+O.forces.f(9).norm()+O.forces.f(10).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(12).norm()+O.forces.f(13).norm()+O.forces.f(14).norm()+O.forces.f(15).norm()+O.forces.f(16).norm()+O.forces.f(17).norm()+O.forces.f(18).norm()+O.forces.f(19).norm())
>
> plot.plots={'t':('F')}
> plot.plot()
> plot.saveDataTxt('Force.txt.bz2')
>
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#5

Yes, please, post working scripts, not just random lines.
You are asking us to read this piece of code, understand it, guess what could be before it and after it in a real script, then imagine the possible inconsistencies in that part of the code that we don't see...

To much work, really.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#6

Hi,

sorry for that! Here is the hole script:

from yade import pack, plot, geom, utils

O.materials.append(FrictMat(young=5e7,poisson=0.5,frictionAngle=.5,density=10000, label='mat_box'))

O.materials.append(FrictMat(young=5e6,poisson=0.5,frictionAngle=.5,density=2400, label='mat_spheres'))

O.materials.append(FrictMat(young=5e7,poisson=0.5,frictionAngle=.5,density=2400, label='mat_cylinder'))

for l in O.bodies:
 g=l.id
 print g

smallcylinder=O.bodies.append(utils.geom.facetCylinder((.1,.01,.2),.004,.01,orientation=Quaternion(((math.pi)/2, 0, 0),1),segmentsNumber=5,wallMask=7, color=(1,1,1), fixed=True))

for l in O.bodies:
 g=l.id
 print g

bigcylinder=O.bodies.append(utils.geom.facetCylinder((.1,0,.2),.05,.01,orientation=Quaternion(((math.pi)/2, 0, 0),1
), segmentsNumber=20,wallMask=7, color=(0,0,1), fixed=True))

pot=O.bodies.append(utils.geom.facetCylinder((0,0,.25),.25,.5,orientation=Quaternion((0, 0, 0),0),segmentsNumber=20,wallMask=6, color=(0,1,0), fixed=True))

tool=bigcylinder+smallcylinder

sphereRadius = 0.006
nbSpheres = (10,10,30)

for i in xrange(nbSpheres[0]):
    for j in xrange(nbSpheres[1]):
        for k in xrange(nbSpheres[2]):
            x = (i*2 - nbSpheres[0])*sphereRadius*1.1
            y = (j*2 - nbSpheres[1])*sphereRadius*1.1
            z = (k*2 - nbSpheres[2])*sphereRadius*1.1
            sp1=utils.sphere([x,y,z+2],sphereRadius,color=(1,0,0),material='mat_spheres')
            O.bodies.append(sp1)

sphereRadius = 0.006
nbSpheres = (10,10,30)

for i in xrange(nbSpheres[0]):
    for j in xrange(nbSpheres[1]):
        for k in xrange(nbSpheres[2]):
            x = (i*2 - nbSpheres[0])*sphereRadius*1.1
            y = (j*2 - nbSpheres[1])*sphereRadius*1.1
            z = (k*2 - nbSpheres[2])*sphereRadius*1.1
            sp2=utils.sphere([x,y,z+1],sphereRadius,color=(1,0,0),material='mat_spheres')
            O.bodies.append(sp2)

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(damping=0.4, gravity=(0,0,-9.81)),

 RotationEngine(rotateAroundZero=True,zeroPoint=(0,0,0),rotationAxis=(0,0,1),angularVelocity=100*(2*pi/60),ids=tool,label='rotor'),

 PyRunner(iterPeriod=20,command="myAddPlotData()"),
 VTKRecorder(iterPeriod=100,fileName='/tmp/QuaderAufnahme-',recorders=['spheres','facets'])
]

O.dt=1*utils.PWaveTimeStep()

def myAddPlotData():
 force=plot.addData(t=O.time,F=O.forces.f(0).norm()+O.forces.f(1).norm()+O.forces.f(2).norm()+O.forces.f(3).norm()+O.forces.f(4).norm()+O.forces.f(5).norm()+O.forces.f(6).norm()+O.forces.f(7).norm()+O.forces.f(8).norm()+O.forces.f(9).norm()+O.forces.f(10).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(11).norm()+O.forces.f(12).norm()+O.forces.f(13).norm()+O.forces.f(14).norm()+O.forces.f(15).norm()+O.forces.f(16).norm()+O.forces.f(17).norm()+O.forces.f(18).norm()+O.forces.f(19).norm())

plot.plots={'t':('F')}
plot.plot()

from yade import qt
v=qt.View()
v.axes=True; v.sceneRadius=1

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#7

Hi Christian,

I tested your script, it works very well, when you replace these lines:

plot.plots={'t':('F')}
plot.plot()

by these lines:

O.run(5000,True)
plot.plots={'t':('F')}
plot.plot(subPlots=False)
plot.saveDataTxt('Force.txt.bz2')

You have to run simulation before the execution of command plot.saveDataTxt ;)

Hope it helps,

Cheers.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#8

Thank you Christian! That was what i'm looking for!

Cheers