'instancemethod' object has no attribute '__getitem__'

Asked by Mehrad

Hi
I want to run this code but the error ''instancemethod' object has no attribute '__getitem__'' occure.
How can I fix this?
my script
readParamsFromTable(rMean=.05,rRelFuzz=.3)
from yade.params.table import *
from yade import polyhedra_utils,pack,qt,plot,utils,export,ymport

polyMat = PolyhedraMat(density=8050,young=210e9,poisson=.29,frictionAngle=atan(0.8))
O.materials.append(polyMat)

t=polyhedra_utils.polyhedra(polyMat,(.6,.6,.6),v=[(0,0,0),(0,0,-1.5),(0,1.5,0),(1.5,0,0)])
t.state.pos = (1,1,6)
t.state.vel = (0, 0, -20)
O.bodies.append(t)

O.bodies.append(geom.facetBox((1,1,1),(1,1,1),wallMask=31))

O.materials.append(ViscElMat(young=4e9,poisson=0.25, density=1400, frictionAngle=radians(30), label='sphereMat'))
partCloud = pack.SpherePack()
#Specify the property of the particle cloud wanted
O.bodies.append(pack.regularHexa(pack.inAlignedBox((0,0,0),(2,2,2)),radius=.08,gap=0.0001,color=(0,0,1)))

#send to simulation assigning the material
partCloud.toSimulation(material='sphereMat')

triax=TriaxialStressController(maxMultiplier=1.+2e4/4e9,finalMaxMultiplier=1.+2e3/4e9,thickness = 0,stressMask = 7,internalCompaction=True)

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Polyhedra_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Sphere_Polyhedra_ScGeom()],
      [Ip2_CpmMat_CpmMat_CpmPhys()],
   [Law2_ScGeom_CpmPhys_Cpm()]
   ),GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
triax,
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
   # call the checkUnbalanced function (defined below) every 2 seconds
   PyRunner(command='checkUnbalanced()',realPeriod=2),
   # call the addPlotData function every 200 steps
   PyRunner(command='addPlotData()',iterPeriod=100),VTKRecorder(fileName='stress',recorders=['all'],iterPeriod=1000)
]
O.dt=.5*PWaveTimeStep()

# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy['energyName'] subsequently
O.trackEnergy=True

# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
   if unbalancedForce()<.05:
      O.pause()
      plot.saveDataTxt('bbb.txt.bz2')
      # plot.saveGnuplot('bbb') is also possible

# collect history of data which will be plotted
def addPlotData():
   plot.addData(sx=triax.stress[0],sy=triax.stress[1],sz=triax.stress[2],ex=triax.strain[0],ey=triax.strain[1],ez=triax.strain[2],
      i=O.iter,unbalanced=utils.unbalancedForce(),
      totalEnergy=O.energy.total(),**O.energy)

plot.plots={'i':(('unbalanced','go'),None,'kinetic'),' i':('ex','ey','ez',None,'sx','sy','sz'),'i ':(O.energy.keys,None,('totalEnergy','bo'))}
plot.plot()
O.saveTmp()
O.run()

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

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

triax.stress is a function [1], use round brackets () instead of []. According to the docs, maybe you also change the way how sx, sy and sz are computed..
cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.TriaxialStressController.stress

Revision history for this message
Mehrad (hossein.pianist) said :
#2

Tnx dear jan
but, again an error occure. The error is ''Vector3' object is not callable''
????

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

Please post what/how you changed
Jan

Revision history for this message
Mehrad (hossein.pianist) said :
#4

According you said I've just changed [] of triax.stress to round brackets (). like below

readParamsFromTable(rMean=.05,rRelFuzz=.3)
from yade.params.table import *
from yade import polyhedra_utils,pack,qt,plot,utils,export,ymport

polyMat = PolyhedraMat(density=8050,young=210e9,poisson=.29,frictionAngle=atan(0.8))
O.materials.append(polyMat)

t=polyhedra_utils.polyhedra(polyMat,(.6,.6,.6),v=[(0,0,0),(0,0,-1.5),(0,1.5,0),(1.5,0,0)])
t.state.pos = (1,1,6)
t.state.vel = (0, 0, -20)
O.bodies.append(t)

O.bodies.append(geom.facetBox((1,1,1),(1,1,1),wallMask=31))

O.materials.append(ViscElMat(young=4e9,poisson=0.25, density=1400, frictionAngle=radians(30), label='sphereMat'))
partCloud = pack.SpherePack()
#Specify the property of the particle cloud wanted
O.bodies.append(pack.regularHexa(pack.inAlignedBox((0,0,0),(2,2,2)),radius=.08,gap=0.0001,color=(0,0,1)))

#send to simulation assigning the material
partCloud.toSimulation(material='sphereMat')

triax=TriaxialStressController(maxMultiplier=1.+2e4/4e9,finalMaxMultiplier=1.+2e3/4e9,thickness = 0,stressMask = 7,internalCompaction=True)

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Polyhedra_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Sphere_Polyhedra_ScGeom()],
      [Ip2_CpmMat_CpmMat_CpmPhys()],
   [Law2_ScGeom_CpmPhys_Cpm()]
   ),GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
triax,
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
   # call the checkUnbalanced function (defined below) every 2 seconds
   PyRunner(command='checkUnbalanced()',realPeriod=2),
   # call the addPlotData function every 200 steps
   PyRunner(command='addPlotData()',iterPeriod=100),VTKRecorder(fileName='stress',recorders=['all'],iterPeriod=1000)
]
O.dt=.5*PWaveTimeStep()

# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy['energyName'] subsequently
O.trackEnergy=True

# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
   if unbalancedForce()<.05:
      O.pause()
      plot.saveDataTxt('bbb.txt.bz2')
      # plot.saveGnuplot('bbb') is also possible

# collect history of data which will be plotted
def addPlotData():
   plot.addData(sx=triax.stress(0),sy=triax.stress(1),sz=triax.stress(2),ex=triax.strain(0),ey=triax.strain(1),ez=triax.strain(2),
      i=O.iter,unbalanced=utils.unbalancedForce(),
      totalEnergy=O.energy.total(),**O.energy)

plot.plots={'i':(('unbalanced','go'),None,'kinetic'),' i':('ex','ey','ez',None,'sx','sy','sz'),'i ':(O.energy.keys,None,('totalEnergy','bo'))}
plot.plot()
O.saveTmp()
O.run()

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

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

thanks for the code

> According you said I've just changed [] of triax.stress to round brackets ().

No, you also changed brackets of triax.strain :-) which should remain square brackets..

Jan

Revision history for this message
Mehrad (hossein.pianist) said :
#6

Tnx Jan This solved my problem :)
but ,after I run my code an error occur that is ''yade.plot: creating fake plot, since there are no y-data yet
/usr/lib/pymodules/python2.7/matplotlib/axes.py:4747: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labeled objects found. "
How can I fix this ?????

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

Please, next time open a new question for completely new question :-)

> How can I fix this ?????
> ... since there are no y-data yet

add some y-data :-) e.g. add initRun=True to PyRunner responsible for plot.addData and run one O.step() before plot.plot()

cheers
Jan

Revision history for this message
Mehrad (hossein.pianist) said :
#8

Tnx jan for your helping
but after I adding what you said, an error occur like this:

Missing columns in plot.data, adding NaN: sz,sy,sx

> How can I fix this ?????

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

Instant raplay: Please, next time open a new question for completely new question :-)

I have tried it and could not reproduced your problem. If needed, please open a NEW question

cheers
Jan

Revision history for this message
Launchpad Janitor (janitor) said :
#10

This question was expired because it remained in the 'Open' state without activity for the last 15 days.