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

hi all,

I want to get the particle stress at a specific region. but I get an error, can 
anyone give me some suggestions.

here is the MWE.



from yade import pack, plot, export
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=.08,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()]
        ),
        PyRunner(command='checkUnbalanced()',realPeriod=2),
        PyRunner(command='addPlotData()',iterPeriod=100),
        PyRunner(command='subbox()',iterPeriod=100),
        PyRunner(command='stress_export()',iterPeriod=100),
        NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
]
O.dt=.5*PWaveTimeStep()
print(len(O.bodies))
def checkUnbalanced():
        if unbalancedForce()<.05:
                O.pause()
                #plot.saveDataTxt('bbb.txt')
def addPlotData():
        plot.addData(i=O.iter,unbalanced=unbalancedForce())
#plot.plots={'i':('unbalanced')}
#plot.plot()
######################## sub-region and coloring#############################
ball_list1 =[]
ball_list2 =[]
ball_list3 =[]
def subbox():
        for b in O.bodies:
                if 0< b.state.pos[2] <= 0.15:
                        b.shape.color =Vector3(255,255,255) # white
                        m = b.id
                        ball_list1.append(m)
                elif 0.15 < b.state.pos[2] <= 0.3:
                        b.shape.color =Vector3(0,100,000) # green
                        n = b.id
                        ball_list2.append(n)                    
                elif    b.state.pos[2] > 0.3:
                        b.shape.color =Vector3(00,00,255) # blue
                        q = b.id
                        ball_list3.append(q)
######################## sub-region and coloring#############################

######################################## get the per-perticle 
stess#####################

TW=TesselationWrapper()
TW.setState()
TW.computeVolumes()
vtk = export.VTKExporter("stress_field")
def stress_export():
        s=bodyStressTensors()
        for i in ball_list3:
                b = O.bodies(i)
                if isinstance(b.shape,Sphere):
                        b.mystress = 
s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id) 
        
vtk.exportSpheres(ids='ball_list3',what=[('pos','b.state.pos'),('stress','b.mystress')],useRef=False)
######################################## get the per-perticle 
stess#####################


when I run the code, here is the error:


TypeError                                 Traceback (most recent call last)
/usr/bin/yade in <module>()

/usr/bin/yade in stress_export()
     60         s=bodyStressTensors()
     61         for i in ball_list3:
---> 62                 b = O.bodies(i)
     63                 if isinstance(b.shape,Sphere):
     64                         b.mystress = 
s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id)

TypeError: 'BodyContainer' object is not callable


thanks,
yong








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

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to