← Back to team overview

yade-users team mailing list archive

regularHex Pack

 

Hi,

in the RegularHex pack the spheres must have equal distance from other,
isn't it?
I check it for gap=0 , the pack is wrong,
I also draw a hexagonal pack in SOLIDWORKS and check the distance of spheres
in layers,
in file *pack.py* the distance between layers in directions y and z is
wrong.
for gap=0, in y direction must be  (1/3)*h=(1/3)*r*sqrt(3)
and  in z direction,  (2/3)*r*sqrt(6).


file pack.py:

*def regularHexa(predicate,radius,gap,**kw):
    """Return set of spheres in regular hexagonal grid, clipped inside solid
given by predicate.
    Created spheres will have given radius and will be separated by gap
space."""
    ret=[]
    a=2*radius+gap
    h=a*sqrt(3)/2.
    mn,mx=predicate.aabb()
    dim=[mx[i]-mn[i] for i in 0,1,2]
    if(max(dim)==float('inf')): raise ValueError("Aabb of the predicate must
not be infinite (didn't you use union | instead of intersection & for
unbounded predicate such as notInNotch?");

ii,jj,kk=[range(0,int(dim[0]/a)+1),range(0,int(dim[1]/h)+1),range(0,int(dim[2]/h)+1)]
    for i,j,k in itertools.product(ii,jj,kk):
        x,y,z=mn[0]+radius+i*a,mn[1]+radius+j*h,mn[2]+radius+k*h
        if j%2==0: x+= a/2. if k%2==0 else -a/2.
        if k%2!=0: x+=a/2.; y+=h/2.
        if predicate((x,y,z),radius):
ret+=[utils.sphere((x,y,z),radius=radius,**kw)]
    return ret*

Moradi

Follow ups