← Back to team overview

yade-users team mailing list archive

[Question #684130]: local variable 'compFricDegree' referenced before assignment

 

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

Hello, everyone!
I am trying to specify porosity value after the compaction in periodic triaxial test base on the following codes, but there is something wrong with it. 
First, I am not sure whether porosity can be specified after the compaction in a periodic triaxial test like the example of the triaxial test using TriaxialStressController. 

Second, when I try to realize it in the periodic triaxial test using PeriTriaxController(), there is something wrong with it( local variable 'compFricDegree' referenced before assignment). Here is my conde.
# Specify the porosity in periodic triaxial test

from yade import pack, qt, plot

sigmaIso=-1e5
targetPorosity = 0.3
compFricDegree = 30
young = 5e6
num_spheres = 1000
mn, mx = Vector3(0,0,0), Vector3(1,1,1)

# generate loose packing

O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=radians(compFricDegree),density=2600,label='spheres'))
O.periodic=True
sp=pack.SpherePack()
sp.makeCloud(mn,mx,-1,0.3333,num_spheres,False, 0.95,seed=1) 
sp.toSimulation()

# Set simulation loop
O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()]
	),
	PeriTriaxController(label='triax',
		# specify target values and whether they are strains or stresses
		goal=(sigmaIso,sigmaIso,sigmaIso),stressMask=7,
		# type of servo-control
		dynCell=True,maxStrainRate=(10,10,10),
		# wait until the unbalanced force goes below this value
		maxUnbalanced=.1,relStressTol=1e-3,
		# call this function when goal is reached and the packing is stable
		doneHook='compactionFinished()'
	),
	NewtonIntegrator(damping=.2),
]

O.dt=.5*PWaveTimeStep()

def compactionFinished():
	print('Compaction Finished')
	O.pause()
	pc = utils.porosity()
	print("Porosity after compaction: " + str(pc))
	# Reach a Specified Porosity precisely
	import sys #this is only for the flush() below
	while pc > targetPorosity:
	    # we decrease friction value and apply it to all the bodies and contacts
	    compFricDegree = 0.95*compFricDegree
	    setContactFriction(radians(compFricDegree))
	    pc = utils.porosity()
	    print "\r Friction: ",compFricDegree," porosity:",utils.porosity()
	    sys.stdout.flush()
	    O.run(500,1)
	return pc

Thanks!


-- 
You received this question notification because your team yade-users is
an answer contact for Yade.