← 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: Open => Answered

Jan Stránský proposed the following answer:
Hi,


> There is something
> wrong with the corner spheres. I am not sure how to export positions of
> corner spheres and there periodic images? It is very hard to understand,
> how to incorporate those in my script?
>

yes, I expected that :-) now you exportet images of particles on the faces
and the images were always shifted along one axis. However, you have also
images on edges and corners, that are shifted along 2 or 3 axes.

There are edge particles, satisfying the "edge conditions" in two
direction, and corner particles, satisfying the condition in all three
directions. So apart from you xImages, you would have xyImages (+yz and zx)
and xyzImages. For each of these, the shift would be different. As an
example:


xyImages = []
for b in O.bodies:
        xmin,xmax = O.cell.wrap(b.bound.min)[0],
O.cell.wrap(b.bound.max)[0] # x bounds
        ymin,ymax = O.cell.wrap(b.bound.min)[1],
O.cell.wrap(b.bound.max)[1] # y bounds
        if xmin > xmax and ymin > ymax: # note condition in two direction
                xyImages.append(b)
pr = [[O.cell.wrap(b.state.pos),b.shape.radius] for b in xyImages]
for i,(pos,r) in enumerate(pr):
        xShift = (1 if pos[0]<0.5*O.cell.size[0] else -1) # positive or
negative shift in x direction
        yShift = (1 if pos[1]<0.5*O.cell.size[1] else -1) # positive or
negative shift in y direction
        shift = Vector3(xShift*O.cell.size[0],yShift*O.cell.size[1],0) #
actual shift of "ghost"
        pr[i][0] += shift
# saves images into a file
f = open("/home/konda/imp/Extra_imp/one_packing/1_1_xy.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()


similarly for yz and zx, xyz would have condition in three directions..

cheers
Jan

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