Cannot run the script for periodic simple shear test, with periodic boundary

Asked by Liqing Jiao

Dear All,

I copy the example from the website, but I can't run it. There are some errors shows. Could you please check it for me? Thank you in advance. My script is as follows:
# encoding: utf-8

# script for periodic simple shear test, with periodic boundary
# first compresses to attain some isotropic stress (checkStress),
# then loads in shear (checkDistorsion)
#
# the initial packing is either regular (hexagonal), with empty bands along the boundary,
# or periodic random cloud of spheres
#
# material friction angle is initially set to zero, so that the resulting packing is dense
# (sphere rearrangement is easier if there is no friction)
#

# setup the periodic boundary
O.periodic=True
O.cell.refSize=(2,2,2)
EY=1e5 #Young modulus
compFricDegree=1.
def mat(): return CohFrictMat(isCohesive=True,density=2500,young=1e5,poisson=0.5,momentRotationLaw=1,frictionAngle=radians(3.),normalCohesion=10e7,shearCohesion=10e7,label='sphereMat')

from yade import pack,plot
'''
# the "if 0:" block will be never executed, therefore the "else:" block will be
# to use cloud instead of regular packing, change to "if 1:" or something similar
#if 0:
   # create cloud of spheres and insert them into the simulation
   # we give corners, mean radius, radius variation
 # sp=pack.SpherePack()
 # sp.makeCloud((0,0,0),(2,2,2),rMean=.1,rRelFuzz=.6,periodic=True)
   # insert the packing into the simulation
   sp.toSimulation(color=(0,0,1)) # pure blue
else:
   # in this case, add dense packing
'''
O.bodies.append(
      pack.regularHexa(pack.inAlignedBox((0,0,0),(2,2,2)),radius=.1,gap=0,color=(0,0,1),material=mat)
   )

#sp.makeCloud((0,height+1.2*radius,0),(length,2*height-1.2*radius,width),-1,0.2,400,periodic=True,seed=1)
#O.materials.append(CohFrictMat(isCohesive=True,density=2500,young=EY,poisson=0.5,momentRotationLaw=1,frictionAngle=radians(compFricDegree),normalCohesion=10e7,shearCohesion=10e7,label='sphereMat'))
#O.bodies.append([utils.sphere(s[0],s[1],material='sphereMat') for s in sp])

# create "dense" packing by setting friction to zero initially
#O.materials[0].frictionAngle=0

# simulation loop (will be run at every step)
O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Box_Aabb(),Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()],verletDist=-0.1,allowBiggerThanPeriod=True),
   InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom6D()],
  [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(label='ip2')],
  [Law2_ScGeom6D_CohFrictPhys_CohesionMoment()],
 ),
   NewtonIntegrator(damping=.4),
   # run checkStress function (defined below) every second
   # the label is arbitrary, and is used later to refer to this engine
   PyRunner(iterPeriod=10,command='checkStress()',label='checker'),
   PyRunner(iterPeriod=100,command='addData()'),
]

# set the integration timestep to be 1/2 of the "critical" timestep
O.dt=.5*utils.PWaveTimeStep()

# prescribe isotropic normal deformation (constant strain rate)
# of the periodic cell
O.cell.velGrad=Matrix3(-.1,0,0, 0,-.1,0, 0,0,-.1)

yade.qt.View()
# when to stop the isotropic compression (used inside checkStress)
limitMeanStress=-5e5

def checkStress():
 stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
 print 'mean stress', stress.trance()/3.
 if stress.trace()/3.<limitMeanStress:
  O.cell.velGrad=Matrix3(0,0,.1, 0,0,0, 0,0,0)
  checker.command='checkDistorsion()'
  if O:
   for b in O.bodies:
    b.state.blockedDOFs='XYZ'
    b.state.angVel=(0,0,0)
  for b in O.bodies:
   b.mat.frictionAngle=0.5
  for i in O.interactions: i.phys.tangensOfFrictionAngle=tan(.5)

def checkDistorsion():
 if abs(O.cell.trsf[0,2])>.5:
  plot.saveDateTxt(O.tags['id']+'.txt')
  O.pause()

def addData():
 stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
 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)
 for b in O.bodies:
  b.shape.color=utils.scalarOnColorScale(b.stat.rot().norm(),0,pi/2.)

# define what to plot (3 plots in total)
## exz(i), [left y axis, separate by None:] szz(i), sxz(i)
## szz(exz), sxz(exz)
## tanPhi(i)
# note the space in 'i ' so that it does not overwrite the 'i' entry
plot.plots={'i':('exz',None,'szz','sxz'),'exz':('szz','sxz'),'i ':('tanPhi',)}
# better show rotation of particles
Gl1_Sphere.stripes=True
yade.qt.Generator();

# open the plot on the screen
plot.plot()
#O.run(1000)
#O.saveTmp()
O.run(1000,1)

Merci beaucoup!
Cheers, Liqing

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
Last query:
Last reply:
Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

Better report the error, it makes life easier for people helping you.

Revision history for this message
Liqing Jiao (liqing) said :
#2

Dear Prof. Chareyre,

Bonjour! I am not sure if I made mistake in script. The errors seem weird. When I run the script, no error shows and it doesn't work. I didn't see this case before. When I just run Yade, then copy all python code to run it, some weird errors show such as "can't find addData" (In fact, I wrote addData funtion there already). That's the reason I said it's weird.

Thank you for your kind reply. Look forward to your reply again.
Merci and Cheers, Liqing

At 2013-01-22 16:21:15,Chareyre <email address hidden> wrote:
>Question #219806 on Yade changed:
>https://answers.launchpad.net/yade/+question/219806
>
>Chareyre posted a new comment:
>Better report the error, it makes life easier for people helping you.
>
>--
>You received this question notification because you are a member of
>yade-users, which is an answer contact for Yade.
>
>_______________________________________________
>Mailing list: https://launchpad.net/~yade-users
>Post to : <email address hidden>
>Unsubscribe : https://launchpad.net/~yade-users
>More help : https://help.launchpad.net/ListHelp

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#3

dear liqing jiao,

i ran your script and here are the problems:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "jiao-problem.py", line 76, in checkStress
    print 'mean stress', stress.trance()/3.
AttributeError: 'Matrix3' object has no attribute 'trance'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "jiao-problem.py", line 97, in addData
    b.shape.color=utils.scalarOnColorScale(b.stat.rot().norm(),0,pi/2.)
AttributeError: 'Body' object has no attribute 'stat'

the second one is easy to fix: use b.state.rot() instead of b.stat.rot() in line 97 ...

for the first error trance() is no valid command. I think you can replace line 76 with:

        print 'mean stress', ( (stress[0,0] + stress[1,1] + stress[2,2]) / 3. )

hope it helps,

christian

Revision history for this message
Liqing Jiao (liqing) said :
#4

Hi Christian,

Thank you very much! Yes, I modified as you suggested. It can run now. But, the result is not similar with the example from the website. What about yours? Is it similar? Thanks again for your reply and very helpful suggestion.

Look forward to your reply.
Cheers, Liqing

At 2013-01-22 17:25:55,"Christian Jakob" <email address hidden> wrote:
>Your question #219806 on Yade changed:
>https://answers.launchpad.net/yade/+question/219806
>
> Status: Open => Answered
>
>Christian Jakob proposed the following answer:
>dear liqing jiao,
>
>i ran your script and here are the problems:
>
>Traceback (most recent call last):
> File "<string>", line 1, in <module>
> File "jiao-problem.py", line 76, in checkStress
> print 'mean stress', stress.trance()/3.
>AttributeError: 'Matrix3' object has no attribute 'trance'
>Traceback (most recent call last):
> File "<string>", line 1, in <module>
> File "jiao-problem.py", line 97, in addData
> b.shape.color=utils.scalarOnColorScale(b.stat.rot().norm(),0,pi/2.)
>AttributeError: 'Body' object has no attribute 'stat'
>
>the second one is easy to fix: use b.state.rot() instead of b.stat.rot()
>in line 97 ...
>
>for the first error trance() is no valid command. I think you can
>replace line 76 with:
>
> print 'mean stress', ( (stress[0,0] + stress[1,1] + stress[2,2])
>/ 3. )
>
>hope it helps,
>
>christian
>
>--
>If this answers your question, please go to the following page to let us
>know that it is solved:
>https://answers.launchpad.net/yade/+question/219806/+confirm?answer_id=2
>
>If you still need help, you can reply to this email or go to the
>following page to enter your feedback:
>https://answers.launchpad.net/yade/+question/219806
>
>You received this question notification because you asked the question.

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#5

> But, the result is not similar with the example from the website.

Which website? Can you provide a link?

Revision history for this message
Liqing Jiao (liqing) said :
#6

Dear Christian,

The web link is as follows:
https://yade-dem.org/doc/tutorial-examples.html#periodic-simple-shear .
In my script, I used another constitutive law, since I need to consider the cohesion and friction of the material. I found that in my case, it can't distort the model. I don't know why.

I appreciate any reply from you. Thank you.
Cheers, Liqing

At 2013-01-22 20:31:10,"Christian Jakob" <email address hidden> wrote:
>Your question #219806 on Yade changed:
>https://answers.launchpad.net/yade/+question/219806
>
>Christian Jakob posted a new comment:
>> But, the result is not similar with the example from the website.
>
>Which website? Can you provide a link?
>
>--
>You received this question notification because you asked the question.

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#7

hi liqing,

1.)
I found, that there is a trace() command for (stress) matrix:

https://yade-dem.org/doc/external.html?highlight=trace#miniEigen.Matrix3.trace

so please change line 76 again and use trace() instead of trance()

2.)
If you use original script, you should get the same results, as shown on the website (if not, please report). If you change the script, the results will propably also change...
i am not familiar with shear test, so i can not help you in details.

regards,

christian

Revision history for this message
Best Bruno Chareyre (bruno-chareyre) said :
#8

>I copy the example from the website, but I can't run it

The errors were only on your side actually (e.g. trance() at line 76 does not appear on the website). Make sure your problems don't come from other similar mistakes.

Revision history for this message
Liqing Jiao (liqing) said :
#9

Thanks Chareyre, that solved my question.

Revision history for this message
liucheng83 (lcheng83) said :
#10

Hi, Jiao Liqing (shu yang?)
#sp.makeCloud((0,height+1.2*radius,0),(length,2*height-1.2*radius,width),-1,0.2,400,periodic=True,seed=1)
Maybe something wrong with the periodic keyword.
Many problem in the manual is not working now.

Revision history for this message
Anton Gladky (gladky-anton) said :
#11

2013/4/13 liucheng83 <email address hidden>:
> Many problem in the manual is not working now.

Please, report bugreports, if it is really a true.

Thanks,

Anton

Revision history for this message
liucheng83 (lcheng83) said :
#12

Really, I sugget to test all the scripts in Yade Documentation before the new Documentation comes out, it's a difficult task for the first time, but it can save lots of time for begginers.

Revision history for this message
Anton Gladky (gladky-anton) said :
#13

Yade, as any other open-source project, appreciates any help from the
community. Better in a form of patches.

Thanks.

Anton

2013/4/14 liucheng83 <email address hidden>:
> Really, I sugget to test all the scripts in Yade Documentation before
> the new Documentation comes out, it's a difficult task for the first
> time, but it can save lots of time for begginers.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#14

Dear liucheng83,

Besides I don't understand what comment #10 actually means, please don't post comments at the bottom of a question closed 4 months ago (#9). If you have a question, open a new question.

The original problems of Liqing's were due to wrong modifications of a script taken from the documentation. Feel free to report bugs, as suggested by Anton Gladky (https://bugs.launchpad.net/yade) if you detect problems in original scripts.

Your offer to test and fix all scripts is really nice. Let us know when it is done, then we can release Yade 1.00. We can assist for incorporating your changes in the development version of Yade.

Bruno

Revision history for this message
liucheng83 (lcheng83) said :
#15

Hi, Anton and Chareyre,
I really want to do something for the yade If I can, it's a prize for me.

Sorry for this:
Besides I don't understand what comment #10 actually means, please don't post comments at the bottom of a question closed 4 months ago (#9). If you have a question, open a new question.