Flow of sphere clump.

Asked by Ed Carlos Alves Rocha

Hello everyone! I need to create a sphere factory or injector, for example, a flow of 4 sphere clump. How can I do this programming in YADE?
In Yade there is an example dspherefactorvv. But I do not know how to introduce a clump of sphere.

"""Simple script which shows how to create an inlet.
"""

shotsId,steelId=O.materials.append([
 FrictMat(young=50e9,density=6000,poisson=.2,label='shots'),
 FrictMat(young=210e9,density=7800, poisson=.3,label='steel'),
])
## same as
#
# shotsId,steelId=O.materials.index('shots'),O.materials.index('steel')
#

O.bodies.append(geom.facetBox(center=(0,0,0),extents=(30e-3,30e-3,0),wallMask=32,wire=False,material='steel',color=(0,1,.3)))

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()],verletDist=.05*.29e-3),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_MindlinPhys(
   # define restitution coefficients between different pairs of material ids, see the functor's documentation for details
   #en=MatchMaker(fallback='zero',matches=((steelId,shotsId,.4),(shotsId,shotsId,1)))
   en=MatchMaker(matches=((steelId,shotsId,.4),(shotsId,shotsId,1)))
  )],
  [Law2_ScGeom_MindlinPhys_Mindlin(label='contactLaw')]
 ),
 NewtonIntegrator(damping=0),
 ## CircularFactory: disk if length=0 or cylinder if length>0
 #CircularFactory(maxParticles=10000,radius=8e-3,length=16e-3,center=(0,-15e-3,15e-3),rMin=0.28e-3,rMax=0.29e-3,vMin=100,vMax=100,vAngle=0,massFlowRate=100./60,normal=(0,1.5,-1),label='factory',materialId=shotsId),
 ## BoxFactory: a line, plane or cuboid
 BoxFactory(maxParticles=10000,extents=(8e-3,8e-3,8e-3),center=(0,-15e-3,15e-3),rMin=0.28e-3,rMax=0.29e-3,vMin=100,vMax=100,vAngle=0,massFlowRate=100./60,normal=(0,1.5,-1),label='factory',materialId=shotsId),
 DomainLimiter(lo=(-30e-3,-30e-3,0),hi=(30e-3,30e-3,60e-3),iterPeriod=200),
 #VTKRecorder(recorders=['spheres','facets','velocity'],fileName='/tmp/nozzle-',iterPeriod=500),

 # run this every once in a while, to finalize the simulation at some point
 PyRunner(iterPeriod=10000,command='if factory.numParticles>=factory.maxParticles: O.stopAtIter=O.iter+8000; timing.stats()')
]
# the timestep must be smaller because of high linear velocities of particles
# we cannot use PWaveTimeStep directly, since there are no spheres generated yet
O.dt=SpherePWaveTimeStep(factory.rMin,O.materials[factory.materialId].density,O.materials[factory.materialId].young)
O.saveTmp()
#O.timingEnabled=True
from yade import timing
try:
 from yade import qt
 # setup 3d view
 v=qt.View()
 v.upVector=(0,0,1); v.viewDir=(-1,0,-.3); v.center(median=False)
except ImportError: pass
O.run()

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Ed Carlos Alves Rocha
Solved:
Last query:
Last reply:

This question was reopened

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

Something like this?
#####################
r = 1
O.bodies.append(wall(6*r,2))
def inject():
   ss1 = (
      sphere((0,0*2**r,0*r),r),
      sphere((0,1*2**r,2*r),r),
      sphere((0,2*2**r,0*r),r),
      sphere((0,3*2**r,2*r),r),
   )
   #
   ss2 = (
      sphere((0,6*2**r,0*r),r),
      sphere((0,7*2**r,2*r),r),
      sphere((0,8*2**r,0*r),r),
      sphere((0,9*2**r,2*r),r),
   )
   #
   O.bodies.append(ss1)
   cid,bids = O.bodies.appendClumped(ss2)
   v = (1,0,1)
   for s in ss1 + ss2:
      s.state.vel = v
   O.bodies[cid].state.vel = v

O.engines = [
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()],
   ),
   NewtonIntegrator(),
   PyRunner(iterPeriod=500000,command='inject()',initRun=True),
]
O.dt = 1e-5
O.step()
#####################
cheers
Jan

Revision history for this message
Ed Carlos Alves Rocha (ed.rocha) said :
#2

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

Revision history for this message
Ed Carlos Alves Rocha (ed.rocha) said :
#3

Thank you Jan. This solves my problem. I wish you a great week.
A big hug.
cheers
Ed

Revision history for this message
Ed Carlos Alves Rocha (ed.rocha) said :
#4

Hello Jan!

I created a sphere clump for the injection, following its tips. However, when I run the particle the error below appears, can you help me with this error?

AttributeError Traceback (most recent call last)
/usr/bin/yade in <module>()

/usr/bin/yade in inject()
     27 v = (9.1924,9.1924,0)
     28 for s in ss2:
---> 29 s.state.vel = v
     30 O.bodies[cid].state.vel = v
     31

AttributeError: 'int' object has no attribute 'state'

#####################
#####################

idCana=O.materials.append(FrictMat(young=24.5e6,poisson=.3,frictionAngle=.6, density=4.5e2,label="cana"))
idSteel=O.materials.append(FrictMat(young=210e9,poisson=.3,frictionAngle=.8,density=7.85e3,label="steel"))

O.bodies.append(geom.facetBox((12,3,1.5),(13,4,3),wallMask=31,material="steel" ))
r = 0.125

def inject():
    for k in arange(0,4):
         ss2=O.bodies.appendClumped([sphere((r*i,0,k*4*r),r, material="cana") for i in range(1,9)])
    cid,bids = ss2
    v = (9.1924,9.1924,0)
    for s in ss2:
       s.state.vel = v
    O.bodies[cid].state.vel = v

O.engines = [
   ForceResetter(),
   # sphere, facet, wall
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
   InteractionLoop(
      # the loading plate is a wall, we need to handle sphere+sphere, sphere+facet, sphere+wall
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
# NewtonIntegrator(gravity=(0,0,9.81),damping=0),
      NewtonIntegrator(gravity=(0,-9.81,0),damping=0.2),
   PyRunner(iterPeriod=500000,command='inject()',initRun=True),
]
O.dt=(1e-6)*PWaveTimeStep()
#O.dt =1e-7
O.step()
#####################

from yade import qt
qt.Controller()
qt.View()

O.saveTmp()
#####################

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

O.bodies.appendClumped returns (clumpID,listOfMemberIds), so "for i in ss2" is wrong here. O.bodies[cid]... is the correct approach
Try (indent it according to your needs):

cid,bids = ss2
v = (9.1924,9.1924,0)
O.bodies[cid].state.vel = v

cheers
Jan

Revision history for this message
Ed Carlos Alves Rocha (ed.rocha) said :
#6

Hello Jan!

Thank you for your attention.

Sorry, I still can not do it. I tried the options below, however, it did not work.

#####################
#####################
def inject():
    for k in arange(0,4):
         ss2=O.bodies.appendClumped([utils.sphere((r*i,0,k*4*r),r, material="cana") for i in range(1,9)])
    cid,bids=O.bodies.append(ss2)

    v = (9.1924,9.1924,0)
# for s in ss2:

    s.state.vel = v
    O.bodies[cid].state.vel = v
#####################
#####################

def inject():
    for k in arange(0,4):
         ss2=O.bodies.appendClumped([utils.sphere((r*i,0,k*4*r),r, material="cana") for i in range(1,9)])
    cid,bids=(ss2)

    v = (9.1924,9.1924,0)
# for s in ss2:

    s.state.vel = v
    O.bodies[cid].state.vel = v
#####################
#####################

def inject():
    for k in arange(0,4):
         ss2=O.bodies.appendClumped([utils.sphere((r*i,0,k*4*r),r, material="cana") for i in range(1,9)])
    cid,bids=(ss2)

    v = (9.1924,9.1924,0)

    for s in ss2:
    s.state.vel = v
    O.bodies[cid].state.vel = v
#####################
#####################

Injection does not work. Can you help me again?

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

Hello,

> it did not work.
> Injection does not work.

please always provide a reason why it does not work (there is this and that error, there is no error but it does something else than I want...). "it does not work" alone is almost useless information..

Your injection implementations are nice excercise to guess what Python would do :-) 2x NameError and 1x IndentationError?

Try:
#####################
def inject():
   for k in arange(0,4):
      ss2=O.bodies.appendClumped([utils.sphere((r*i,0,k*4*r),r, material="cana") for i in range(1,9)])
      cid,bids = ss2
      v = (9.1924,9.1924,0)
      O.bodies[cid].state.vel = v
#####################

cheers
Jan

Revision history for this message
Ed Carlos Alves Rocha (ed.rocha) said :
#8

Hello Jan!

You are a genius. It worked.

Thank you so much.

A big hug for you.