← Back to team overview

yade-users team mailing list archive

[Question #219806]: Cannot run the script for periodic simple shear test, with periodic boundary

 

New question #219806 on Yade:
https://answers.launchpad.net/yade/+question/219806

Dear All,

I copy the example from the website, but I can't run it. There are some errors shows. Could you please check it for me? Thank you in advance. My script is as follows:
# encoding: utf-8

# script for periodic simple shear test, with periodic boundary
# first compresses to attain some isotropic stress (checkStress),
# then loads in shear (checkDistorsion)
# 
# the initial packing is either regular (hexagonal), with empty bands along the boundary,
# or periodic random cloud of spheres
#
# material friction angle is initially set to zero, so that the resulting packing is dense
# (sphere rearrangement is easier if there is no friction)
#


# setup the periodic boundary
O.periodic=True
O.cell.refSize=(2,2,2)
EY=1e5 #Young modulus
compFricDegree=1.
def mat(): return CohFrictMat(isCohesive=True,density=2500,young=1e5,poisson=0.5,momentRotationLaw=1,frictionAngle=radians(3.),normalCohesion=10e7,shearCohesion=10e7,label='sphereMat')

from yade import pack,plot
'''
# the "if 0:" block will be never executed, therefore the "else:" block will be
# to use cloud instead of regular packing, change to "if 1:" or something similar
#if 0:
   # create cloud of spheres and insert them into the simulation
   # we give corners, mean radius, radius variation
 #  sp=pack.SpherePack()
 # sp.makeCloud((0,0,0),(2,2,2),rMean=.1,rRelFuzz=.6,periodic=True)
   # insert the packing into the simulation
   sp.toSimulation(color=(0,0,1)) # pure blue
else:
   # in this case, add dense packing
'''
O.bodies.append(
      pack.regularHexa(pack.inAlignedBox((0,0,0),(2,2,2)),radius=.1,gap=0,color=(0,0,1),material=mat)
   )

#sp.makeCloud((0,height+1.2*radius,0),(length,2*height-1.2*radius,width),-1,0.2,400,periodic=True,seed=1)
#O.materials.append(CohFrictMat(isCohesive=True,density=2500,young=EY,poisson=0.5,momentRotationLaw=1,frictionAngle=radians(compFricDegree),normalCohesion=10e7,shearCohesion=10e7,label='sphereMat'))
#O.bodies.append([utils.sphere(s[0],s[1],material='sphereMat') for s in sp])

# create "dense" packing by setting friction to zero initially
#O.materials[0].frictionAngle=0

# simulation loop (will be run at every step)
O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Box_Aabb(),Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()],verletDist=-0.1,allowBiggerThanPeriod=True),
   InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom6D()],
		[Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(label='ip2')],
		[Law2_ScGeom6D_CohFrictPhys_CohesionMoment()],
	),
   NewtonIntegrator(damping=.4),
   # run checkStress function (defined below) every second
   # the label is arbitrary, and is used later to refer to this engine
   PyRunner(iterPeriod=10,command='checkStress()',label='checker'),
   PyRunner(iterPeriod=100,command='addData()'),
]

# set the integration timestep to be 1/2 of the "critical" timestep
O.dt=.5*utils.PWaveTimeStep()

# prescribe isotropic normal deformation (constant strain rate)
# of the periodic cell
O.cell.velGrad=Matrix3(-.1,0,0, 0,-.1,0, 0,0,-.1)

yade.qt.View()
# when to stop the isotropic compression (used inside checkStress)
limitMeanStress=-5e5

def checkStress():
	stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
	print 'mean stress', stress.trance()/3.
	if stress.trace()/3.<limitMeanStress:
		O.cell.velGrad=Matrix3(0,0,.1, 0,0,0, 0,0,0)
		checker.command='checkDistorsion()'
		if O:
			for b in O.bodies:
				b.state.blockedDOFs='XYZ'
				b.state.angVel=(0,0,0)
		for b in O.bodies:
			b.mat.frictionAngle=0.5
		for i in O.interactions: i.phys.tangensOfFrictionAngle=tan(.5)

def checkDistorsion():
	if abs(O.cell.trsf[0,2])>.5:
		plot.saveDateTxt(O.tags['id']+'.txt')
		O.pause()

def addData():
	stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
	plot.addData(exz=O.cell.trsf[0,2],szz=stress[2,2],sxz=stress[0,2],tanPhi=stress[0,2]/stress[2,2],i=O.iter)
	for b in O.bodies:
		b.shape.color=utils.scalarOnColorScale(b.stat.rot().norm(),0,pi/2.)

# define what to plot (3 plots in total)
## exz(i), [left y axis, separate by None:] szz(i), sxz(i)
## szz(exz), sxz(exz)
## tanPhi(i)
# note the space in 'i ' so that it does not overwrite the 'i' entry
plot.plots={'i':('exz',None,'szz','sxz'),'exz':('szz','sxz'),'i ':('tanPhi',)}
# better show rotation of particles
Gl1_Sphere.stripes=True
yade.qt.Generator();

# open the plot on the screen
plot.plot()
#O.run(1000)
#O.saveTmp()
O.run(1000,1)


Merci beaucoup!
Cheers, Liqing


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