← Back to team overview

yade-users team mailing list archive

[Question #630995]: VTK does not work for me!

 

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

Hi all, 

Can anyone tell me why VTK and Snapshot don’t work in below script?

# encoding: utf-8
# 2012 ©Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
# This variant of triax-basic.py shows the usage of cohesive contact laws and moments at contacts

from yade import pack, qt

sp=pack.SpherePack()
## corners of the initial packing
mn,mx=Vector3(0,0,0),Vector3(40,40,40)

## box between mn and mx, avg radius ± ½(20%), 2k spheres
sp.makeCloud(minCorner=mn,maxCorner=mx,rMean=1,rRelFuzz=.5,num=1000)

## create material #0, which will be used as default
O.materials.append(CohFrictMat(alphaKr=0.025,young=100e6,poisson=0.4,density=2600,frictionAngle=radians(36.5),normalCohesion=2e6,shearCohesion=2e6,momentRotationLaw=True,etaRoll=0.2,label='spheres'))
O.materials.append(FrictMat(young=229e6,poisson=.4,frictionAngle=0,density=0,label='frictionlessWalls'))


## copy spheres from the packing into the scene
O.bodies.append([sphere(center,rad,material='spheres') for center,rad in sp])
## create walls around the packing
walls=aabbWalls(material='frictionlessWalls')
wallIds=O.bodies.append(walls)

triax=TriaxialCompressionEngine(
	wall_bottom_id=wallIds[2],
	wall_top_id=wallIds[3],
	wall_left_id=wallIds[0],
	wall_right_id=wallIds[1],
	wall_back_id=wallIds[4],
	wall_front_id=wallIds[5],
	internalCompaction=False,
	sigmaIsoCompaction=-150e3,
	sigmaLateralConfinement=-150e3,
	max_vel=10,
	strainRate=0.03,
	label="triax"
)

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
	InteractionLoop(
		#box-sphere interactions will be the simple normal-shear law, we use ScGeom for them
		[Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
		#Boxes will be frictional (FrictMat), so the sphere-box physics is FrictMat vs. CohFrictMat, the Ip type will be found via the inheritance tree (CohFrictMat is a FrictMat) and will result in FrictPhys interaction physics
		#and will result in a FrictPhys
		[Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(label="cohesiveIp")],
		#Finally, two different contact laws for sphere-box and sphere-sphere
		[Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(
			useIncrementalForm=True, #useIncrementalForm is turned on as we want plasticity on the contact moments
			always_use_moment_law=False,  #if we want "rolling" friction even if the contact is not cohesive (or cohesion is broken), we will have to turn this true somewhere
			label='cohesiveLaw'),Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=True)]
	),
	#VTKRecorder(recorders=['spheres','intr','jcfpm']),

	GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.5),
	triax,
	TriaxialStateRecorder(iterPeriod=1000,file=',jedddi150e3,alphaKr=0.025,150e3,young=100e6,poisson=0.4,density=2600,frictionAngle=radians(36.5),normalCohesion=2e6,shearCohesion=2e6,etaRoll=0.2,2%portland'),
	NewtonIntegrator(damping=.4),
	VTKRecorder(fileName='3d-vtk-',recorders=['all'],iterPeriod=1000),
	qt.SnapshotEngine(fileBase='3d-',iterPeriod=200,label='snapshot'),
]
O.dt=.5*PWaveTimeStep()



# we must open the view explicitly (limitation of the qt.SnapshotEngine)
qt.View()



from yade import plot
O.engines=O.engines[0:5]+[PyRunner(iterPeriod=500,command='history()',label='recorder')]+O.engines[5:7]
def history():
  	plot.addData(e11=-O.engines[4].strain[0], e22=-O.engines[4].strain[1], e33=-O.engines[4].strain[2],
		    s11=-O.engines[4].stress(0)[0],
		    s22=-O.engines[4].stress(2)[1],
		    s33=-O.engines[4].stress(4)[2],
		    i=O.iter)

print 'Number of elements: ', len(O.bodies)
print 'Box Volume: ',  triax.boxVolume
#plot.plots={'i':(('e11',"bo"),('e22',"ro"),('e33',"go"),None,('s11',"bx"),('s22',"rx"),('s33',"gx"))}
plot.plots={'e22':'s22'}
plot.plot()

print "computing, be patient..."
#First run without moment and without cohesion
O.run(120000,True)

#This will reload the autosaved compacted sample
O.reload()

#second run with rolling friction
O.engines[2].lawDispatcher.functors[1].always_use_moment_law = True
O.run(120000,True)
O.reload()

#third run with rolling friction + cohesion
O.engines[2].lawDispatcher.functors[1].always_use_moment_law = True
#We assign cohesion to all contacts at the next iteration
O.engines[2].physDispatcher.functors[1].setCohesionNow = True
O.run(120000,True)
#plot.saveDataTxt('200,45')
##or even generate a script for gnuplot. Open another terminal and type  "gnuplot plotScriptKEY.gnuplot:
#plot.saveGnuplot('200,45')
## display on the screen (doesn't work on VMware image it seems)
plot.plot()

#####  PLAY THE SIMULATION HERE WITH "PLAY" BUTTON OR WITH THE COMMAND O.run(N)  #####

rr=yade.qt.Renderer()
rr.shape=True
rr.intrPhys=True

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