New question #689863 on Yade:
https://answers.launchpad.net/yade/+question/689863
hi all,
I want to get the local variables, something like the local stress for a
specific region.
my idea is to set a local region and then under that condition, I can calculate
these variables.
my first step is to set a local region, I think this is very easy. see the code
below.
however, when I count the number of particles in this region, the number by
using the code is not the same as shown in the 3D plot.
here is the code.
#####################
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()
######################## sub-region and coloring#########################
ball_list1 =[]
ball_list2 =[]
ball_list3 =[]
def subbox():
global ball_list1
global ball_list2
global ball_list3
for b in O.bodies:
if 0< b.state.pos[2] <= 0.15:
if isinstance(b.shape,Sphere):
b.shape.color =Vector3(255,255,255) # white
m = b.id
ball_list1.append(m)
elif 0.15 < b.state.pos[2] <= 0.3:
if isinstance(b.shape,Sphere):
b.shape.color =Vector3(0,100,000) # green
n = b.id
ball_list2.append(n)
elif b.state.pos[2] > 0.3:
if isinstance(b.shape,Sphere):
b.shape.color =Vector3(00,00,255) # blue
q = b.id
ball_list3.append(q)
print("this is the number in region
3:",len(ball_list3))
######################## sub-region and coloring############################
I divide the particles into three regions. as you can see, region three is the
upper layer. if we count the number in this region, theere are about 20
particles. however, if we use the print function, this number is about 4500.
I think this may relate to the global or local variable of the " global
ball_list3". but right now I haven't figure out how to solve this problem.
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