← Back to team overview

yade-users team mailing list archive

Re: [Question #171223]: Strange behavior of spheres colliding with a moving facet

 

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

vadim posted a new comment:
def fill_box():
   """ fills the box with particles """
   def create_layer(N,r,h,offset=0):
      """ N -- number of particles in the layer
          r -- radius of particles
          h -- height of the layer
          offset -- initial offset """
      if offset==0:
         offset=2*r
      ni=nj=range(int(math.sqrt(N)))
      for i in ni:
         for j in nj:
            O.bodies.append(utils.sphere((offset+j*r*3,offset+i*r*3,h),r))#,material='particles'))

   for i in range(1):
      create_layer(16,0.008,0.01+i*0.018,offset=0.01+float(random.randint(10,20))/2500)

def shake_table():
   """ move the table according to the sine law (period T=0.5) """
   global pos_facet1
   global pos_facet2
   h=0.02*math.sin(2*pi*O.time)
   pos_facet1[2]=h
   pos_facet2[2]=h
   O.bodies[8].state.pos=pos_facet1
   O.bodies[9].state.pos=pos_facet2

# handling engines
O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
   InteractionLoop(
      # handle sphere+sphere and facet+sphere collisions
      [Ig2_Sphere_Sphere_L3Geom(),Ig2_Facet_Sphere_L3Geom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_L3Geom_FrictPhys_ElPerfPl()]
   ),
   GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.04),
   PyRunner(command='shake_table()',virtPeriod=O.dt),
]
# time step
O.dt=1e-06

#                        MAIN SCENARIO

# Create a box with no roof
O.bodies.append(utils.facetBox((0.05,0.05,0.06),(.05,.05,.1),wallMask=15))
O.materials[0].density=1500
# Create a table
O.bodies.append(utils.facet([(0,0,0),(0,0.1,0),(0.1,0.1,0)],color=(1,0,0)))
O.bodies.append(utils.facet([(0,0,0),(0.1,0,0),(0.1,0.1,0)],color=(1,0,0)))
# copy their coords into variables
pos_facet1=O.bodies[8].state.pos
pos_facet2=O.bodies[9].state.pos
# fill the box with spheres
fill_box()

O.saveTmp()

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