# yade-users team mailing list archive

## [Question #693704]: spheres move out of range

```New question #693704 on Yade:

hi,

i generated a 2D rectangular made of pfacets in which exist many sparse spheres, then i added gravity in the engine so that they could fall down to a dense pack, DOF of spheres was set to "yXZ" to move in x-z plane, in which case spheres would fall on Pfacet, actually they didn't. some of them did fall on the surface of pfacet, the others just fell out of range(x-z plane)..i cant figure out why. Below is my code.

#------------------------------------------------------------------------------------------------------------
from random import random
import numpy as np
from numpy import *
import math
import os

#parameters
rParticle = 0.14e-3#diameter0.28
rRelFuzz=.0005
mi,ma = (-500e-3,0.,0.),(500e-3,0,250e-3)
frictionAngleSph=30
frictionAngleCyl=20
width = int(1000e-3),
height = int(250e-3),

#=============================meterials========================================
O.materials.append(FrictMat(young=4.0e6,poisson=.3,frictionAngle=30,density=2630e+6,label='sphereMat'))#for sphere

O.materials.append(FrictMat(young=3e9,poisson=.15,frictionAngle=20,density=910e+6,label='extcylMat'))#for sphere-cylinder
O.materials.append(CohFrictMat(young=3e9,poisson=.15,density=910e6,frictionAngle=20,normalCohesion=1e40,shearCohesion=1e40,momentRotationLaw=True,label='intcylMat'))#for cylinder-cylinder

O.materials.append( CohFrictMat( young=3e8,poisson=0.15,density=910e6,frictionAngle=20,normalCohesion=3e100,shearCohesion=3e100,momentRotationLaw=True,label='gridNodeMat' ) )#for gridNodes
#O.materials.append(CohFrictMat(young=3e9,poisson=.15,density=910e6,frictionAngle=20,normalCohesion=1e40,shearCohesion=1e40,momentRotationLaw=True,label='gridNodeMat'))#for gridNodes
O.materials.append(FrictMat(young=4e6,poisson=0.3,density=10e1000,frictionAngle=20,label='pFacetMat')) #for pfacet

#==============================Engines=========================================
O.engines=[
ForceResetter(),
InsertionSortCollider([
Bo1_Box_Aabb(),
Bo1_Sphere_Aabb(),
Bo1_GridConnection_Aabb(),
Bo1_PFacet_Aabb(),
]),
InteractionLoop([
Ig2_Sphere_Sphere_ScGeom(),
Ig2_Box_Sphere_ScGeom(),
Ig2_GridNode_GridNode_GridNodeGeom6D(),
Ig2_Sphere_GridConnection_ScGridCoGeom(),
Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
Ig2_GridConnection_PFacet_ScGeom(),
Ig2_PFacet_PFacet_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, sphere-sphere, cylinder-sphere
],
[
Law2_ScGeom_FrictPhys_CundallStrack(),	# contact law for sphere-sphere
Law2_ScGridCoGeom_FrictPhys_CundallStrack(),	# contact law for cylinder-sphere
Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),	# contact law for "internal" cylinder forces
Law2_GridCoGridCoGeom_FrictPhys_CundallStrack()	# contact law for cylinder-cylinder interaction
]
),
GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.1,label='ts'),
NewtonIntegrator(gravity=(0,0,-.0181),damping=0.5,label='newton'),
]
#=======================================pfacet=================================================
color=[255./255.,102./255.,0./255.]
r=0.002

aa = O.bodies.append(gridNode([-500e-3, 5e-3,0],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
bb = O.bodies.append(gridNode([ 500e-3, 5e-3,0],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
cc = O.bodies.append(gridNode([ 500e-3,-5e-3,0],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
dd = O.bodies.append(gridNode([-500e-3,-5e-3,0],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
pfacetCreator3(aa,bb,cc,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)
pfacetCreator3(aa,cc,dd,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)

ee = O.bodies.append(gridNode([-500e-3, 5e-3,250e-3],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
ff = O.bodies.append(gridNode([ 500e-3, 5e-3,250e-3],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
gg = O.bodies.append(gridNode([ 500e-3,-5e-3,250e-3],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
hh = O.bodies.append(gridNode([-500e-3,-5e-3,250e-3],r,wire=False,fixed=fixed,material='gridNodeMat',color=color))
pfacetCreator3(ee,ff,gg,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)
pfacetCreator3(ee,gg,hh,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)

pfacetCreator3(bb,ff,gg,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)
pfacetCreator3(bb,gg,cc,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)

pfacetCreator3(dd,aa,ee,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)
pfacetCreator3(dd,ee,hh,cylIds=[],pfIds=[],wire=False,material='pFacetMat',color=color)

sp.makeCloud(mi,ma,porosity=0.7/1.7,psdSizes=[.0014,0.0016,0.0022,.003,.0035],psdCumm=[0.,0.1,0.3,0.6,1.],num=350)
spheres=sp.toSimulation(color=(0,0.5,0.7),material='sphereMat')

for i in O.bodies:
if isinstance(i.shape,Sphere):
i.state.blockedDOFs="yXZ"
if isinstance(i.shape,GridNode):
i.state.blockedDOFs="xyzXYZ"
if isinstance(i.shape,GridConnection):
i.state.blockedDOFs="xyzXYZ"

#### For viewing ####
qt.View()
Gl1_Sphere.stripes=True
#----------------------------------------------------------------------------

thanks!
ZHY

--