← Back to team overview

yade-users team mailing list archive

[Question #701030]: Why is my pyrunner command not being called?

 

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

I want to use pyrunner's command to control the loading and unloading process, but it doesn't work.

So I was wondering maybe there's something wrong with the engine code, so I add the "print ('hello')", and it did work. But the pyrunner command still doesn't work. I do not know what is going wrong.

Here is my code, could you please help me to check about it?

Many thanks for your help.


##########################
from yade import pack
# The following 5 lines will be used later for batch execution
nRead=readParamsFromTable(
	num_spheres=1000,# number of spheres
	compFricDegree = 30, # contact friction during the confining phase
	key='_triax_base_', # put you simulation's name here
	unknownOk=True
)
from yade.params import table

num_spheres=table.num_spheres# number of spheres
key=table.key
targetPorosity = 0.43 #the porosity we want for the packing
compFricDegree = table.compFricDegree # initial contact friction during the confining phase (will be decreased during the REFD compaction process)
finalFricDegree = 30 # contact friction during the deviatoric loading
rate=-0.02 # loading rate (strain rate)
damp=0.2 # damping coefficient
stabilityThreshold=0.01 # we test unbalancedForce against this value in different loops (see below)
young=5e6 # contact stiffness
mn,mx=Vector3(0,0,0),Vector3(10,10,.1) # corners of the initial packing


## create materials for spheres and plates
O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=radians(compFricDegree),density=2600,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=0,density=0,label='walls'))

## create walls around the packing
walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)

## use a SpherePack object to generate a random loose particles packing
sp=pack.SpherePack()

sp.makeCloud(minCorner=mn,maxCorner=mx,rRelFuzz=0,num=2000)
sp.toSimulation(material='spheres')

triax=TriaxialStressController(
	
	maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth)
	finalMaxMultiplier=1.+2e3/young, # spheres growing factor (slow growth)
	thickness = 0,
	
	internalCompaction=False,
	
	stressMask = 1,
        goal1=-2e5,
	goal2=rate,

	)
	
	
O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()]
	),
	GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
        
	triax,
	
	TriaxialStateRecorder(iterPeriod=100, file='WallStresses.txt'),
	NewtonIntegrator(damping=damp),
	PyRunner(command='triaxload()',iterPeriod=1, label='triaxload'),
]

triax.stressMask = 1
triax.goal1=-2e5
triax.goal2=rate

print('hello')

def triaxload():
        
	if abs(O.triax.stress(triax.wall_top_id)[1])> 150000:
		triax.stressMask = 1
		triax.goal1=-3e5
		triax.goal2=rate
		triaxload.command=('triaxunload')
	
def triaxunload():
	if abs(triax.stress(triax.wall_top_id)[1])< 5e4:
		triax.stressMask = 1
		triax.goal1=-1e5
		triax.goal2=rate







from yade import plot



O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
def history():
	plot.addData(e11=-triax.strain[0], 
	        e22=-triax.strain[1], 
		s11=-triax.stress(triax.wall_right_id)[0],
		s22=-triax.stress(triax.wall_top_id)[1],
		
		i=O.iter)

plot.plots={'e11': ('s11',),'e22': ('s22',)}

O.saveTmp()
plot.plot()



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