yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #04311
Re: [Question #152906]: how to run the example in the tutorial
Question #152906 on Yade changed:
https://answers.launchpad.net/yade/+question/152906
Status: Answered => Open
guo is still having a problem:
Thank you very much Anton,
I use yade 0.5 and the following is the errors (example: Periodic simple
shear)
Yade [24]: # create "dense" packing by setting friction to zero initially
Yade [25]: O.materials[0].frictionAngle=0
Yade [26]:
Yade [27]: # simulation loop (will be run at every step)
Yade [28]: O.engines=[
....: ForceResetter(),
....: InsertionSortCollider([Bo1_Sphere_Aabb()]),
....: InteractionLoop(
....: [Ig2_Sphere_Sphere_L3Geom()],
....: [Ip2_FrictMat_FrictMat_FrictPhys()],
....: [Law2_L3Geom_FrictPhys_ElPerfPl()]
....: ),
....: NewtonIntegrator(damping=.4),
....: # run checkStress function (defined below) every second
....: # the label is arbitrary, and is used later to refer to this engine
....: PyRunner(command='checkStress()',realPeriod=1,label='checker'),
....: # record data for plotting every 100 steps; addData function is defined below
....: PyRunner(command='addData()',iterPeriod=100)
....: ]
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/lib/yade-0.50/py/yade/__init__.pyc in <module>()
1
2
----> 3
4
5
RuntimeError: First argument (if given) must be a string.
Yade [29]:
Yade [30]: # set the integration timestep to be 1/2 of the "critical" timestep
Yade [31]: O.dt=.5*utils.PWaveTimeStep()
Yade [32]:
Yade [33]: # prescribe isotropic normal deformation (constant strain rate)
Yade [34]: # of the periodic cell
Yade [35]: O.cell.velGrad=Matrix3(-.1,0,0, 0,-.1,0, 0,0,-.1)
Yade [36]:
Yade [37]: # when to stop the isotropic compression (used inside checkStress)
Yade [38]: limitMeanStress=-5e5
Yade [39]:
Yade [40]: # called every second by the PyRunner engine
Yade [41]: def checkStress():
....: # stress tensor as the sum of normal and shear contributions
....: # Matrix3.Zero is the intial value for sum(...)
....: stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
....: print 'mean stress',stress.trace()/3.
....: # if mean stress is below (bigger in absolute value) limitMeanStress, start shearing
....: if stress.trace()/3.<limitMeanStress:
....: # apply constant-rate distorsion on the periodic cell
....: O.cell.velGrad=Matrix3(0,0,.1, 0,0,0, 0,0,0)
....: # change the function called by the checker engine
....: # (checkStress will not be called anymore)
....: checker.command='checkDistorsion()'
....: # block rotations of particles to increase tanPhi, if desired
....: # disabled by default
....: if 0:
....: for b in O.bodies:
....: # block X,Y,Z rotations, translations are free
....: b.state.blockedDOFs='XYZ'
....: # stop rotations if any, as blockedDOFs block accelerations really
....: b.state.angVel=(0,0,0)
....: # set friction angle back to non-zero value
....: # tangensOfFrictionAngle is computed by the Ip2_* functor from material
....: # for future contacts change material (there is only one material for all particles)
....: O.materials[0].frictionAngle=.5 # radians
....: # for existing contacts, set contact friction directly
....: for i in O.interactions: i.phys.tangensOfFrictionAngle=tan(.5)
....:
Yade [42]: # called from the 'checker' engine periodically, during the shear phase
Yade [43]: def checkDistorsion():
....: # if the distorsion value is >.3, exit; otherwise do nothing
....: if abs(O.cell.trsf[0,2])>.5:
....: # save data from addData(...) before exiting into file
....: # use O.tags['id'] to distinguish individual runs of the same simulation
....: plot.saveDataTxt(O.tags['id']+'.txt')
....: # exit the program
....: #import sys
....: #sys.exit(0) # no error (0)
....: O.pause()
....:
Yade [44]: # called periodically to store data history
Yade [45]: def addData():
....: # get the stress tensor (as 3x3 matrix)
....: str
....: # give names to values we are interested in and save them
....: 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)
....: # color particles based on rotation amount
....: for b in O.bodies:
....: # rot() gives rotation vector between reference and current position
....: b.shape.color=utils.scalarOnColorScale(b.state.rot().norm(),0,pi/2.)
....:
Yade [46]: # define what to plot (3 plots in
Yade [47]: ## exz(i), [left y axis, separate by None:] szz(i), sxz(i)
Yade [48]: ## szz(exz), sxz(exz)
Yade [49]: ## tanPhi(i)
Yade [50]: # note the space in 'i ' so that it does not overwrite the 'i' entry
Yade [51]: plot.plots={'i':('exz',None,'szz','sxz'),'exz':('szz','sxz'),'i ':('tanPhi',)}
Yade [52]:
Yade [53]: # better show rotation of particles
Yade [54]: Gl1_Sphere.stripes=True
Yade [55]:
Yade [56]: # open the plot on the screen
Yade [57]: plot.plot()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/lib/yade-0.50/py/yade/__init__.pyc in <module>()
----> 1
2
3
4
5
/usr/lib/yade-0.50/py/yade/plot.pyc in plot(noShow)
101 else: plots_p_y2.append(d)
102 #plotLines[p]=
--> 103 pylab.plot(*sum([[data[p],data[d[0]],d[1]] for d in plots_p_y1],[]))
104 pylab.legend([_xlateLabel(_p[0]) for _p in plots_p_y1],loc=('upper left' if len(plots_p_y2)>0 else 'best'))
105 pylab.ylabel(','.join([_xlateLabel(_p[0]) for _p in plots_p_y1]))
KeyError: 'i'
Yade [58]:
Yade [59]: O.saveTmp()
INFO /build/buildd/yade-0.50-0.50.2/core/Omega.cpp:321 saveSimulation: Saving file :memory:
Yade [60]:
And where should i put the example1.py file? i mean its path. Thanks for your help.
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.