← Back to team overview

yade-users team mailing list archive

[Question #678668]: O.load Error

 

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

Hi,
Thank you Jan, you have helped me a lot.I successfully loaded the simulation according to the method you taught.

However, an error will be reported at the beginning of loading:

NameError                                 Traceback (most recent call last)
/usr/bin/yade in <module>()
NameError: name 'triaxFinished' is not defined

In my first program, even though it had stopped 'O.pause()' , why did this function appear?I want to correct this error.

Thanks,
James

############################
The first script:

# encoding: utf-8
from yade import pack, qt, plot

sigmaIso=-25000

O.periodic=True

frictionAngle1= 2.862405226
frictionAngle2= 14.03624347

sphere=O.materials.append(FrictMat(young=1e7,poisson=0.3,density=1000,frictionAngle=radians(frictionAngle1),label='sphere'))

multiple=.01
length=1.5

psdSizes=[.18*multiple,.2*multiple,.21*multiple,.25*multiple,.27*multiple,.30*multiple,.31*multiple,.34*multiple,.38*multiple]
psdCumm=[0.11,0.27,0.45,0.73,0.88,0.95,0.98,0.99,1]

sp=pack.SpherePack()
sp.makeCloud((0,0,0),(length*multiple,length*multiple,length*multiple),psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True,periodic=True)
n=sp.toSimulation()

def changeMaterial():
	O.cell.trsf=Matrix3.Identity	
	for i in n:
        	O.bodies[i].material.frictionAngle=radians(frictionAngle2)
	triax.doneHook='triaxFinished()'

def triaxFinished():
   	print 'Finished'
   	O.pause()

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()]
	),
	PeriTriaxController(label='triax',
		goal=(sigmaIso,sigmaIso,sigmaIso),stressMask=7,
		dynCell=True,maxStrainRate=(1000,1000,1000),
		maxUnbalanced=1e-3,relStressTol=1e-3,
		growDamping=0,
		globUpdate=1,
		doneHook='changeMaterial()'
	),
	NewtonIntegrator(damping=.1),
	PyRunner(command='num()',initRun=1,nDo=1),
]
O.dt=.5*PWaveTimeStep()

qt.Controller()
O.run()
O.wait()
O.save('four.yade.gz')
O.saveTmp()

My second script:

#!/usr/bin/python 
from yade import pack, qt, plot

O.load('four.yade.gz')
#O.run()
O.dt=1e-9

O.engines += [PeriTriaxController(
	goal=(0,0,-1000000),
	stressMask=4,maxStrainRate=(0,0,.1),
	growDamping=0,
	globUpdate=10,
	maxUnbalanced=1e-8,doneHook='functionToRunWhenFinished()')]

O.engines += [PyRunner(command='addPlotData2()',iterPeriod=1000000)];

def functionToRunWhenFinished():
   	print 'Finished'
   	O.pause()

def addPlotData2():
	plot.addData(unbalanced=unbalancedForce(),i=O.iter,
		sxx=-triax.stress[0],syy=-triax.stress[1],szz=-triax.stress[2],
		exx=-triax.strain[0],eyy=-triax.strain[1],ezz=-triax.strain[2],
		q=-triax.stress[2]+0.5*(triax.stress[0]+triax.stress[1]),
		p=-(triax.stress[0]+triax.stress[1]+triax.stress[2])/3,
	)

plot.plots={'i':('unbalanced',),'i ':('sxx','syy','szz'),' i':('ezzs'),' p ':('q'),}
plot.plot()

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