← Back to team overview

yade-users team mailing list archive

Re: [Question #255437]: Periodic random packing of spheres in a cube

 

Question #255437 on Yade changed:
https://answers.launchpad.net/yade/+question/255437

    Status: Answered => Open

skonda2 is still having a problem:

Hi Jan,

I tried to run the script, but it generated empty output file with just the first line as " x y z "
I have attached the script that i ran, is there something wrong in that?

# Script for exporting data of all the spheres, including the one on the edges and periodic images
from yade import pack
pack.randomPeriPack(1,(10,10,10)).toSimulation()
O.step()
xImages = []
for b in O.bodies:
	xmin,xmax = O.cell.wrap(b.bound.min)[0], O.cell.wrap(b.bound.max)[0]

if xmin>xmax:
	xImages.append(b)

pr = [[O.cell.wrap(b.state.pos),b.shape.radius] for b in xImages]

for i, (pos,r) in enumerate(pr):
	shift = Vector3(O.cell.size[0],0,0)*(1 if pos[0]<.5*O.cell.size[0] else -1)
	pr[i][0] += shift

f = open("/home/konda/ximages_1.dat","w")
f.write("x y z r\n")
f.writelines("%g %g %g %g\n" % (pos[0],pos[1],pos[2],r) for pos, r in pr)
f.close()


So, " for b in O.bodies" does this also consider the bodies on the edges and their periodic images too? Because before intializing the box, it had say 72 bodies and after initialising )O.step) there should be more bodies including those on the edges. So i tried len(O.bodies), which came out as 72. I was thinking, may be in the for loop it does not consider any bodies on the edges, so there is no output. Let me kno what you think of my understanding. 

-Shailesh

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.