2D randomDensePack

Asked by Xavier Thurman

Hello,

I intend to make a 2D randomDensePack in YADE. Can you tell me how to address this problem? I am not familiar with 2D packing.

Thanks in advances,

Xavier

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hi Xavier,
one option is to take the source code of randomDensePack [1] and modify the makeCloud part to create 2D loose packing and prescribing particles zero displacement perpendicular to the 2D plane.

###

###

cheers
Jan

[1] https://github.com/yade/trunk/blob/master/py/pack/pack.py#L454

Revision history for this message
Best Jan Stránský (honzik) said :
#2

sorry, forgot to include the code :-)
Jan

###
def randomDensePack2d(predicate,radius,material=-1,dim=None,cropLayers=0,rRelFuzz=0.,spheresInCell=0,memoizeDb=None,useOBB=False,memoDbg=False,color=None,returnSpherePack=None):
   """see source of pack.randomDensePack for comments. Implemented only version with spheresInCell>0 and memoizeDb=False"""
   import sqlite3, os.path, cPickle, time, sys, numpy
   from math import pi
   from yade import _packPredicates
   assert spheresInCell > 0
   if not dim: dim=predicate.dim()
   if max(dim)==float('inf'): raise RuntimeError("Infinite predicate and no dimension of packing requested.")
   center=predicate.center()
   fullDim=dim
   # DIFF
   rMax = radius*(1+rRelFuzz)
   x1 = y1 = sqrt(spheresInCell)*3*rMax
   z1 = 10*max(dim)
   O.switchScene(); O.resetThisScene()
   sp=SpherePack()
   O.periodic=True
   O.cell.setBox((x1,y1,z1))
   O.materials.append(FrictMat(young=3e10,density=2400))
   vmin,vmax = Vector3().Zero,O.cell.refSize
   vmax[2] = 0 # DIFF (making the packing 2D geometrically)
   num=sp.makeCloud(vmin,vmax,radius,rRelFuzz,spheresInCell,True)
   O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()],verletDist=.05*radius),InteractionLoop([Ig2_Sphere_Sphere_ScGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_ScGeom_FrictPhys_CundallStrack()]),PeriIsoCompressor(charLen=2*radius,stresses=[-100e9,-1e8],maxUnbalanced=1e-2,doneHook='O.pause();',globalUpdateInt=5,keepProportions=True),NewtonIntegrator(damping=.6)]
   O.materials.append(FrictMat(young=30e9,frictionAngle=.5,poisson=.3,density=1e3))
   for s in sp: # DIFF (blocking out-of-plane DOFs of bodies
      b = utils.sphere(s[0],s[1])
      b.state.blockedDOFs = "zXY"
      O.bodies.append(b)
   O.dt=utils.PWaveTimeStep()
   O.run(); O.wait()
   sp=SpherePack(); sp.fromSimulation()
   O.switchScene()
   sp.cellFill(Vector3(fullDim[0],fullDim[1],rMax)) # DIFF
   return filterSpherePack(predicate,sp,material=material,color=color,returnSpherePack=returnSpherePack)

# tests
from yade import pack
#sp = randomDensePack2d(pack.inAlignedBox((-1,-1,-1),(2,2,2)),radius=.1,rRelFuzz=.5,spheresInCell=200)
sp = randomDensePack2d(pack.inSphere((0,0,0),3),radius=.1,rRelFuzz=.5,spheresInCell=200)
O.bodies.append(sp)
###

Revision history for this message
Xavier Thurman (xavierthurman) said :
#3

Thanks Jan Stránský, that solved my question.