gridpfacet.cylinder interacting with walls, spheres, facetbox etc.

Asked by Andrea Puglisi

I would like to have cylinders moving on a conveyor belt (horizontal wall with given velocity) and colliding with lateral walls (facetboxes). I am trying to compare the performance of two kinds of cylnders: clumps of spheres and gridpfacets. I prepared this basic script. The clumps do all I wish (they are transported by the conveyor horizontal wall, interact with the lateral facetboxes and among themselves). The gridpfacet cylinder is not transported (it seems it does not interact with the horizontal wall neither with the newtonintegrator). If I impose a velocity to it - uncommenting the commented line - (perhaps not in a very smart way), I see a part of the cylinder moving but it does not interact with the walls or with the spheres.

--------------------------------------------------------------------------------------------------------

from yade import pack,ymport,export,geom,bodiesHandling
from yade.gridpfacet import *

rad,gap=.05,.01
r=0.5
phi=30.
E=1e6

O.materials.append(FrictMat(young=10e9,poisson=.25,frictionAngle=0.5,density=1e3))
O.materials.append( CohFrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),normalCohesion=1e10,shearCohesion=1e10,momentRotationLaw=True,label='cMat' ) )
O.materials.append( FrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),label='fMat' ) )

kw={'material':0}
kwBoxes={'color':[1,0,0],'wire':False,'dynamic':False,'material':0}
kwMeshes={'color':[1,1,0],'wire':True,'dynamic':False,'material':0}

nodesIds=[]
cylIds=[]
color=[1,0,0]
cylgrid = cylinder((2,0,0.),(2,0,0.5),radius=r,nodesIds=nodesIds,cylIds=cylIds,fixed=False,color=color,intMaterial='cMat',extMaterial='fMat',mask=3)
# uncomment this to make the pfacet-cylinder move
# O.bodies[cylIds[0]].state.vel=Vector3(0,1,0)

cylTuple = O.bodies.appendClumped(pack.regularOrtho(pack.inCylinder((0,1,0),(0,1,0.5),0.5),radius=rad,gap=gap,color=(0,0,1),**kw))
O.bodies[cylTuple[0]].mask=3

cylTuple2 = O.bodies.appendClumped(pack.regularOrtho(pack.inCylinder((0,-1,0),(0,-1,0.5),0.5),radius=rad,gap=gap,color=(0,0,1),**kw))
O.bodies[cylTuple2[0]].mask=3

beltId = O.bodies.append(wall((0,0,0),axis=2))
O.bodies[beltId].state.vel=Vector3(-1,0,0)

wall1Id = O.bodies.append(geom.facetBox((0,-3,0),(1,5,5),orientation=Quaternion((0, 0, 1), (pi/2.4)),wallMask=2,**kwBoxes))
wall2Id = O.bodies.append(geom.facetBox((0,+3,0),(1,5,5),orientation=Quaternion((0, 0, 1), (-pi/2.4)),wallMask=2,**kwBoxes))

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb(),
                 Bo1_GridConnection_Aabb(),
                 Bo1_PFacet_Aabb(),
        ],label='collider'),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom(),
                 Ig2_Wall_PFacet_ScGeom(),
    Ig2_GridNode_GridNode_GridNodeGeom6D(),
   Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
   Ig2_Sphere_PFacet_ScGridCoGeom(),
   Ig2_GridConnection_PFacet_ScGeom(),
                 Ig2_Sphere_GridConnection_ScGridCoGeom(),
                ],
  [Ip2_FrictMat_FrictMat_FrictPhys(),
                ],
  [Law2_ScGeom_FrictPhys_CundallStrack(),
   Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
   Law2_ScGridCoGeom_FrictPhys_CundallStrack(),
   Law2_GridCoGridCoGeom_FrictPhys_CundallStrack()
                ],
 ),
 NewtonIntegrator(damping=.1,exactAsphericalRot=True,gravity=(1e-2,1e-2,-1000),mask=2),
        GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.1,label='ts'),
]
O.dt=PWaveTimeStep()
O.run(1,True)
try:
 from yade import qt
 qt.Controller()
 qt.View()
except ImportError: pass
O.saveTmp()
O.timingEnabled=True

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Klaus Thoeni
Solved:
Last query:
Last reply:
Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#1

Hi Andrea,

you have to understand how "rounded cylinders" work in yade. They are made of gridNodes (equivalent to a sphere) and a connection/interaction. The interaction between such a cylinder and a wall would only be via the gridNodes. In addition, for these cylinders you should use pFactes instead of facets. I adapted one of my scripts, see below.

HTH
Klaus

from yade.gridpfacet import *

##### Parameter ####
r=1 # radius cylinder
phi=30. # friction angle
E=1e7 # Young's modulus

#### Engines ####
O.engines=[
 ForceResetter(),
 InsertionSortCollider([
  Bo1_Sphere_Aabb(),
  Bo1_Wall_Aabb(),
  Bo1_PFacet_Aabb(),
 ]),
 InteractionLoop([
  Ig2_GridNode_GridNode_GridNodeGeom6D(),
  Ig2_Wall_Sphere_ScGeom(),
  Ig2_Sphere_PFacet_ScGridCoGeom(),
 ],
 [
  Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False), # internal cylinder physics
  Ip2_FrictMat_FrictMat_FrictPhys() # physics for external interactions, i.e., cylinder-cylinder interaction
 ],
 [
  Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
  Law2_ScGeom_FrictPhys_CundallStrack(),
 ]
 ),
 NewtonIntegrator(gravity=(-0.,0,-10),damping=0.5,label='newton'),
]

#### Creat materials ####
O.materials.append( CohFrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),normalCohesion=1e10,shearCohesion=1e10,momentRotationLaw=True,label='cMat' ) ) # material to create the gridConnections
O.materials.append( FrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),label='fMat' ) ) # material for general interactions

#### Create box and wall ####
wallId = O.bodies.append( wall(position=(0,0,-r),sense=0, axis=2,color=[0,1,1],material='fMat') )
O.bodies[wallId].state.vel=Vector3(1.,0,0)
O.bodies[wallId].mask=3

#### Create cylinder ####
nodeIds=[]
cylIds=[]
nodeIds.append( O.bodies.append( gridNode([0,2*r,0],r,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )
nodeIds.append( O.bodies.append( gridNode([0,2*r,2*r],r,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )

for id in nodeIds:
  O.bodies[id].bounded=1
  O.bodies[id].mask=2

cylIds.append( O.bodies.append( gridConnection(nodeIds[1],nodeIds[0],r,color=[1,0,0],material='fMat') ) )

#### Creat a pFacets -> based on 3 vertices ####

v1=Vector3(0,4*r,0)
v2=Vector3(20*r,-r,0)
v3=Vector3(20*r,-r,10*r)
vertices=[v1,v2,v3]
pfacetCreator1(vertices,r/2.,nodesIds=[],cylIds=[],pfIds=[],wire=False,color=[1,1,1],fixed=True,materialNodes='cMat',material='fMat')

#### For viewing ####
from yade import qt
qt.View()
Gl1_Sphere.stripes=True
qtr = qt.Renderer()
#qtr.wire=True
#qtr.intrWire=True
#qtr.intrPhys=True

#### Set a time step ####
O.dt=1e-05

#### Allows to reload the simulation ####
O.saveTmp()

Revision history for this message
Andrea Puglisi (andreo73) said :
#2

Dear Klaus,

with quite a large delay I wish to thank you. I continued to work with clumps of spheres, it seemed to me simpler. Now I would like to try again with the pfacet approach. I am trying a simple exercise, i.e. replace your cylinder with an object (a tetrahedron from a .gts file, http://gts.sourceforge.net/samples/tetrahedron.gts.gz ) which *should* be transported by the horizontal belt.

Again I face the problem already described to you at the beginning. The object apparently does not interact with the belt. I can't understand the basic rules of interaction of grids.

from yade.gridpfacet import *

##### Parameter ####
r=1 # radius cylinder
phi=30. # friction angle
E=1e7 # Young's modulus

#### Engines ####
O.engines=[
 ForceResetter(),
 InsertionSortCollider([
  Bo1_Sphere_Aabb(),
  Bo1_Wall_Aabb(),
  Bo1_PFacet_Aabb(),
 ]),
 InteractionLoop([
  Ig2_GridNode_GridNode_GridNodeGeom6D(),
  Ig2_Wall_Sphere_ScGeom(),
  Ig2_Sphere_PFacet_ScGridCoGeom(),
 ],
 [
  Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False), # internal cylinder physics
  Ip2_FrictMat_FrictMat_FrictPhys() # physics for external interactions, i.e., cylinder-cylinder interaction
 ],
 [
  Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
  Law2_ScGeom_FrictPhys_CundallStrack(),
 ]
 ),
 NewtonIntegrator(gravity=(-0.,0,-10),damping=0.5,label='newton'),
]

#### Creat materials ####
O.materials.append( CohFrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),normalCohesion=1e10,shearCohesion=1e10,momentRota\
tionLaw=True,label='cMat' ) ) # material to create the gridConnections
O.materials.append( FrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),label='fMat' ) ) # material for general interactions

#### Create box and wall ####
wallId = O.bodies.append( wall(position=(0,0,0),sense=0, axis=2,color=[0,1,1],material='fMat') )
O.bodies[wallId].state.vel=Vector3(1.,0,0)
O.bodies[wallId].mask=3

#### Create cylinder ####
#nodeIds=[]
#cylIds=[]
#nodeIds.append( O.bodies.append( gridNode([0,2*r,0],r,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )
#nodeIds.append( O.bodies.append( gridNode([0,2*r,2*r],r,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )

nodeIds,cylIds,pfIds = gtsPFacet('tetra.gts',shift=(0,0,3),scale=1.,radius=1e-2,wire=False,fixed=False,materialNodes='cMat',material='fMat',c\
olor=[0,0,1])

for id in nodeIds:
  O.bodies[id].bounded=1
  O.bodies[id].mask=2

#cylIds.append( O.bodies.append( gridConnection(nodeIds[1],nodeIds[0],r,color=[1,0,0],material='fMat') ) )

#### Creat a pFacets -> based on 3 vertices ####

#v1=Vector3(0,4*r,0)
#v2=Vector3(20*r,-r,0)
#v3=Vector3(20*r,-r,10*r)
#vertices=[v1,v2,v3]
#pfacetCreator1(vertices,r/2.,nodesIds=[],cylIds=[],pfIds=[],wire=False,color=[1,1,1],fixed=True,materialNodes='cMat',material='fMat')

#### For viewing ####
from yade import qt
qt.View()
Gl1_Sphere.stripes=True

#### Set a time step ####
O.dt=1e-05

#### Allows to reload the simulation ####
O.saveTmp()

Revision history for this message
Andrea Puglisi (andreo73) said :
#3

In particular I don't undestand why a simple grid (connection of nodes and cylinders) works reasonably well, it does not work anymore as soon as I create pfacets. This is a minimal example

---------------------------

from yade.gridpfacet import *

##### Parameter ####
r=1 # base radius
rr=0.1 #cyl radius
phi=30. # friction angle
E=1e7 # Young's modulus

#### Engines ####
O.engines=[
 ForceResetter(),
 InsertionSortCollider([
  Bo1_Sphere_Aabb(),
  Bo1_Wall_Aabb(),
  Bo1_PFacet_Aabb(),
 ]),
 InteractionLoop([
  Ig2_GridNode_GridNode_GridNodeGeom6D(),#internal
  Ig2_Wall_Sphere_ScGeom(),#cyl-wall
  Ig2_Sphere_PFacet_ScGridCoGeom(), #cyl-facet
 ],
 [
  Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False), # internal
  Ip2_FrictMat_FrictMat_FrictPhys() # external (cyl-wall, cyl-facet)
 ],
 [
  Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
  Law2_ScGeom_FrictPhys_CundallStrack(), # contact law for "external" cylinder forces
 ]
 ),
 NewtonIntegrator(gravity=(-0.,0,-10),damping=0.5,label='newton'),
]

#### Creat materials ####
O.materials.append( CohFrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),normalCohesion=1e10,shearCohesion=1e10,momentRotationLaw=True,label='cMat' ) ) # material to create the gridConnections
O.materials.append( FrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),label='fMat' ) ) # material for general interactions

#### Create box and wall ####
wallId = O.bodies.append( wall(position=(0,0,0),sense=0, axis=2,color=[0,1,1],material='fMat') )
O.bodies[wallId].state.vel=Vector3(1.,0,0)
O.bodies[wallId].mask=3

#### Create cylinder ####
nodeIds=[]
cylIds=[]
nodeIds.append( O.bodies.append( gridNode([0,2*r,r],rr,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )
nodeIds.append( O.bodies.append( gridNode([0,2*r,3*r],rr,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )
nodeIds.append( O.bodies.append( gridNode([0,4*r,r],rr,wire=False,fixed=False,material='cMat',color=[1,0,0]) ) )

for id in nodeIds:
  O.bodies[id].bounded=1
  O.bodies[id].mask=2

cylIds.append( O.bodies.append( gridConnection(nodeIds[1],nodeIds[0],rr,color=[1,0,0],material='fMat') ) )
cylIds.append( O.bodies.append( gridConnection(nodeIds[2],nodeIds[1],rr,color=[1,0,0],material='fMat') ) )
cylIds.append( O.bodies.append( gridConnection(nodeIds[0],nodeIds[2],rr,color=[1,0,0],material='fMat') ) )

#COMMENT THE FOLLOWING LINE AND PHYSICS SEEMS WORK WELL - OTHERWISE IT FALLS THROUGH THE FLOOR
O.bodies.append( pfacet(nodeIds[0],nodeIds[1],nodeIds[2],wire=False,color=[1,1,0],highlight=False,material='fMat') )

#### For viewing ####
from yade import qt
qt.View()
Gl1_Sphere.stripes=True
qtr = qt.Renderer()

#### Set a time step ####
O.dt=1e-05

#### Allows to reload the simulation ####
O.saveTmp()

Revision history for this message
Best Klaus Thoeni (klaus.thoeni) said :
#4

Hi Andrea,

you need the following Ig2 functor for this to work:

Ig2_Wall_PFacet_ScGeom()

Also see [1]

Klaus

[1] https://github.com/yade/trunk/blob/master/examples/pfacet/pfacetcreators.py

Revision history for this message
Andrea Puglisi (andreo73) said :
#5

Thanks! You have been a valuable source of information!

All the best

 Andrea

Revision history for this message
Andrea Puglisi (andreo73) said :
#6

Thanks Klaus Thoeni, that solved my question.