yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #20398
[Question #683101]: export plot figure and data
New question #683101 on Yade:
https://answers.launchpad.net/yade/+question/683101
Hello,
I have 2 questions when I use plot to export data and figure. For a simple example:
from yade import pack, plot
import numpy as np
sandR1=1
sandR2=0.8
sand = FrictMat(young=30e9,poisson=0.3,frictionAngle=radians(30),density=2650.0,label='sand')
O.materials.append(sand)
s1=utils.sphere((0,0,0),radius=sandR1,color=[1,1,1],fixed=True,material='sand')
s2=utils.sphere((0,0,1.8),radius=sandR2,color=[1,1,1],material='sand')
O.bodies.append(s1)
O.bodies.append(s2)
s2.state.blockedDOFs='z'
s2.state.vel = Vector3(0,0,-1e1)
Gl1_Sphere.quality=3
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(damping=0.4),
PyRunner(iterPeriod=100,command='addPlotData()',label='plotData'),
]
def addPlotData():
plot.addData(displacement=1.8-O.bodies[1].state.pos[2],force=O.forces.f(1)[2])
plot.plots={'displacement':('force',)}
plot.plot()
#plot.saveDataTxt('example.txt')
#plot.plot(noShow=True).savefig("fig1.pdf")
O.run(1000000,True)
I can correctly obtain a line on the figure.
However, when I want to export the figure like this:
from yade import pack, plot
import numpy as np
sandR1=1
sandR2=0.8
sand = FrictMat(young=30e9,poisson=0.3,frictionAngle=radians(30),density=2650.0,label='sand')
O.materials.append(sand)
s1=utils.sphere((0,0,0),radius=sandR1,color=[1,1,1],fixed=True,material='sand')
s2=utils.sphere((0,0,1.8),radius=sandR2,color=[1,1,1],material='sand')
O.bodies.append(s1)
O.bodies.append(s2)
s2.state.blockedDOFs='z'
s2.state.vel = Vector3(0,0,-1e1)
Gl1_Sphere.quality=3
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(damping=0.4),
PyRunner(iterPeriod=100,command='addPlotData()',label='plotData'),
]
def addPlotData():
plot.addData(displacement=1.8-O.bodies[1].state.pos[2],force=O.forces.f(1)[2])
plot.plots={'displacement':('force',)}
#plot.plot()
#plot.saveDataTxt('example.txt')
plot.plot(noShow=True).savefig("fig1.pdf")
O.run(1000000,True)
I can obtain fig1.pdf but with no line on it (just a blank figure), that is the first question.
Further, the 2nd question is when I uncomment:
plot.saveDataTxt('example.txt')
I got an error as:
plot.saveDataTxt('example.txt')
File "/usr/lib/x86_64-linux-gnu/yade/py/yade/plot.py", line 642, in saveDataTxt
for i in range(len(data[vars[0]])):
IndexError: list index out of range
Could you please point out the problem?
Thanks!
--
You received this question notification because your team yade-users is
an answer contact for Yade.