Translation and rotation engines

Asked by m.asd

hi,
I am a new user of yade and i am going to model a box in which some particles deposit. then I delete particles upper than a predefined elevation and add some fine particles. then I delete these fines upper than that elevation too. after that, I add a plate on top and define a velocity up to a specific load. set the velocity of the plate to zero (fix place) and then let sidewalls to rotate around the Y axis with a fixed angVel.
here is my problem,
when I use "plate.state.vel" it says that "Nonetype object has no attribute state"
and when I use rotationengine and translationengine it shows an error and do not proceed.
as I am not so experienced in running yade, changing the script in many ways made me frustrated. I will be so grateful if anyone helps me.
furthermore, It sometimes stops running with this error
"segmentation fault (core dumped)" what is the reason
here is my script

overburden=10
from yade import pack,plot,qt
idmat=O.materials.append(FrictMat(density=2700,young=1e6,poisson=0.5,frictionAngle=0))
O.bodies.append(utils.wall(position=0,axis=2,sense=1))
O.bodies.append(utils.wall(position=0,axis=1,sense=1))
O.bodies.append(utils.wall(position=0.01,axis=1,sense=-1))
O.bodies.append(utils.wall(position=0,axis=0,sense=1))
LW=O.bodies[-1]
O.bodies.append(utils.wall(position=0.01,axis=0,sense=-1))
RW=O.bodies[-1]
sp=pack.SpherePack()
sp.makeCloud((0,0,0.001),(0.01,0.01,0.02),rMean=.0008,rRelFuzz=0)
sp.toSimulation(color=(0,0,1)) # blue

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 GravityEngine(gravity=(0,0,-9.81)),
 NewtonIntegrator(damping=0.4),
 qt.SnapshotEngine(fileBase='3d-',iterPeriod=100000,label='snapshot'),
 PyRunner(command='unbalancedData()',iterPeriod=30000),
 PyRunner(command='checkUnbalanced()',realPeriod=1,label='checker'),
]

O.dt=1e-6

def checkUnbalanced():
 if O.iter<500000: return
 if utils.unbalancedForce()>.08: return
 for b in O.bodies:
  if isinstance(b.shape,Sphere):
   if (b.state.pos[2]+b.shape.radius)>0.007: O.bodies.erase(b.id)
 fines=pack.SpherePack()
 fines.makeCloud((0,0,0.007),(0.01,0.01,0.01),rMean=.0004,rRelFuzz=0)
 fines.toSimulation()
 O.engines=O.engines+[GravityEngine(gravity=(0,0,-9.81),mask=-1)]
 checker.command='addfines()'

def addfines():
 if O.iter<650000: return
 if utils.unbalancedForce()>.08: return
 for b in O.bodies:
  if isinstance(b.shape,Sphere):
   if (b.state.pos[2]+b.shape.radius)>0.007: O.bodies.erase(b.id)
 posi=O.bodies[5].state.pos[2]+O.bodies[5].shape.radius
 m=5
 while m in range(len(O.bodies)):
  b=O.bodies[m]
  try:
   if isinstance(b.shape,Sphere):
    posi2=b.state.pos[2]+b.shape.radius
    if posi2>=posi: posi=posi2
    m=m+1
  except: m=m+1
 O.bodies.append(utils.wall(position=posi,axis=2,sense=-1))
 global plate
 plate=O.bodies[-1]
 O.engines=O.engines[:4]+[TranslationEngine(ids=plate,translationAxis=(0,0,1),velocity=0.002,label="transEngine")]+O.engines[4:] #here is the problem
 checker.command='shearing()'
 O.materials[0].frictionAngle=.5
 for i in O.interactions: i.phys.tangensOfFrictionAngle=tan(.5)

def shearing():
 if abs(O.forces.f(plate.id)[2])<overburden: return
 transEngine.velocity=0
 O.engines=O.engines[:5]+[RotationEngine(ids=[LW,RW],angularVelocity=0.005,rotationAxis=(0,1,0),label="rotEngine")]+O.engines[5:] #and here too
 checker.command='stopShearing()'

def stopShearing():
 if O.bodies[3].state.rot<(0,0.005,0): return
 O.pause()
 utils.makeVideo(snapshot.snapshots,'3dshear.mpeg',fps=10,bps=10000)
 print 'Finished'

def unbalancedData():
 plot.addData(itperi=O.iter,unbalanced=utils.unbalancedForce())

plot.plots={'itperi':('unbalanced',)}
plot.plot()

Gl1_Sphere.stripes=True
qt.View()

rr=yade.qt.Renderer()
rr.shape=True
O.saveTmp()

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

few comments:

next time please add to the email whole error code you get, it will make it
much more easier to find the problem and to help you. In case ot
TranslationEngine and RotationEngine I would say that the problem is in
parameter ids, which should be list of integers, while in your case it is
Body instance, so write ids=[plate.id] or ids=[LW.id,RW.id] instead.

You wrote about error while using plate.state.vel. Could you provide us
with a short script producing this error?

Some more comments, not causing error but making the script nicer:
- in checkUnbalanced function, don't add GravitiyEngine. The existing one
(defined in first O.engines) should work for new particles and is placed
before NewtonIntegrator, which is correct.
- don't use "while m in range(len(O.bodies))", use "while m <
len(O.bodies)" or just "for b in O.bodies". Python does need to construct
range(len(O.bodies)) list every loop iteration.
- instead of try except pair in addfines function use "if b is not None".

cheers
Jan

2012/11/30 m.asd <email address hidden>

> New question #215627 on Yade:
> https://answers.launchpad.net/yade/+question/215627
>
> hi,
> I am a new user of yade and i am going to model a box in which some
> particles deposit. then I delete particles upper than a predefined
> elevation and add some fine particles. then I delete these fines upper than
> that elevation too. after that, I add a plate on top and define a velocity
> up to a specific load. set the velocity of the plate to zero (fix place)
> and then let sidewalls to rotate around the Y axis with a fixed angVel.
> here is my problem,
> when I use "plate.state.vel" it says that "Nonetype object has no
> attribute state"
> and when I use rotationengine and translationengine it shows an error and
> do not proceed.
> as I am not so experienced in running yade, changing the script in many
> ways made me frustrated. I will be so grateful if anyone helps me.
> furthermore, It sometimes stops running with this error
> "segmentation fault (core dumped)" what is the reason
> here is my script
>
>
> overburden=10
> from yade import pack,plot,qt
>
> idmat=O.materials.append(FrictMat(density=2700,young=1e6,poisson=0.5,frictionAngle=0))
> O.bodies.append(utils.wall(position=0,axis=2,sense=1))
> O.bodies.append(utils.wall(position=0,axis=1,sense=1))
> O.bodies.append(utils.wall(position=0.01,axis=1,sense=-1))
> O.bodies.append(utils.wall(position=0,axis=0,sense=1))
> LW=O.bodies[-1]
> O.bodies.append(utils.wall(position=0.01,axis=0,sense=-1))
> RW=O.bodies[-1]
> sp=pack.SpherePack()
> sp.makeCloud((0,0,0.001),(0.01,0.01,0.02),rMean=.0008,rRelFuzz=0)
> sp.toSimulation(color=(0,0,1)) # blue
>
> O.engines=[
> ForceResetter(),
> InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
> InteractionLoop(
> [Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
> [Ip2_FrictMat_FrictMat_FrictPhys()],
> [Law2_ScGeom_FrictPhys_CundallStrack()]
> ),
> GravityEngine(gravity=(0,0,-9.81)),
> NewtonIntegrator(damping=0.4),
>
> qt.SnapshotEngine(fileBase='3d-',iterPeriod=100000,label='snapshot'),
> PyRunner(command='unbalancedData()',iterPeriod=30000),
> PyRunner(command='checkUnbalanced()',realPeriod=1,label='checker'),
> ]
>
> O.dt=1e-6
>
> def checkUnbalanced():
> if O.iter<500000: return
> if utils.unbalancedForce()>.08: return
> for b in O.bodies:
> if isinstance(b.shape,Sphere):
> if (b.state.pos[2]+b.shape.radius)>0.007:
> O.bodies.erase(b.id)
> fines=pack.SpherePack()
>
> fines.makeCloud((0,0,0.007),(0.01,0.01,0.01),rMean=.0004,rRelFuzz=0)
> fines.toSimulation()
> O.engines=O.engines+[GravityEngine(gravity=(0,0,-9.81),mask=-1)]
> checker.command='addfines()'
>
> def addfines():
> if O.iter<650000: return
> if utils.unbalancedForce()>.08: return
> for b in O.bodies:
> if isinstance(b.shape,Sphere):
> if (b.state.pos[2]+b.shape.radius)>0.007:
> O.bodies.erase(b.id)
> posi=O.bodies[5].state.pos[2]+O.bodies[5].shape.radius
> m=5
> while m in range(len(O.bodies)):
> b=O.bodies[m]
> try:
> if isinstance(b.shape,Sphere):
> posi2=b.state.pos[2]+b.shape.radius
> if posi2>=posi: posi=posi2
> m=m+1
> except: m=m+1
> O.bodies.append(utils.wall(position=posi,axis=2,sense=-1))
> global plate
> plate=O.bodies[-1]
>
> O.engines=O.engines[:4]+[TranslationEngine(ids=plate,translationAxis=(0,0,1),velocity=0.002,label="transEngine")]+O.engines[4:]
> #here is the problem
> checker.command='shearing()'
> O.materials[0].frictionAngle=.5
> for i in O.interactions: i.phys.tangensOfFrictionAngle=tan(.5)
>
> def shearing():
> if abs(O.forces.f(plate.id)[2])<overburden: return
> transEngine.velocity=0
>
> O.engines=O.engines[:5]+[RotationEngine(ids=[LW,RW],angularVelocity=0.005,rotationAxis=(0,1,0),label="rotEngine")]+O.engines[5:]
> #and here too
> checker.command='stopShearing()'
>
> def stopShearing():
> if O.bodies[3].state.rot<(0,0.005,0): return
> O.pause()
> utils.makeVideo(snapshot.snapshots,'3dshear.mpeg',fps=10,bps=10000)
> print 'Finished'
>
> def unbalancedData():
> plot.addData(itperi=O.iter,unbalanced=utils.unbalancedForce())
>
> plot.plots={'itperi':('unbalanced',)}
> plot.plot()
>
> Gl1_Sphere.stripes=True
> qt.View()
>
> rr=yade.qt.Renderer()
> rr.shape=True
> O.saveTmp()
>
>
> --
> 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
Anton Gladky (gladky-anton) said :
#2

Hi,

2012/11/30 m.asd <email address hidden>:
> furthermore, It sometimes stops running with this error
> "segmentation fault (core dumped)" what is the reason

Sometimes it happens due to a graphical interface. Try to check
your script without GUI.

Or you faced the bug LP:1056684, if you run Ubuntu 12.10 or higher.

Cheers,

Anton

Revision history for this message
m.asd (mozhgan-asd) said :
#3

hi,
thank you Jan and Anton for your replies
when I change ids=plate to ids=[plate.id] it leads in the following error

62 global plate
     63 plate=O.bodies[-1]
---> 64 O.engines=O.engines[:4]+[TranslationEngine(ids=[plate.id],translationAxis=(0,0,1),velocity=0.002,label="transEngine")]+O.engines[4:]
     65 checker.command='shearing()'
     66 O.materials[0].frictionAngle=.5

AttributeError: 'NoneType' object has no attribute 'id'

It seems that I am facing the bug LP:1056684 because before adding the plate, I delete some bodies , I am using Ubuntu 12.04
how can I fix it?

cheers,
mozhgan

Revision history for this message
m.asd (mozhgan-asd) said :
#4

hi everybody,

after changing the script, now I can run the script. but during running, the plate interacts with spheres appropriately. however, side-walls (I mean ids=[ LW.id,RW.id]) rotate freely and ignore spheres (either with implementing RotationEngine or body.state.angvel).
this is true even when I use ( young=1e9 and O.dt=1e-8). what is the problem?

Best regads
mozhgan

Revision history for this message
Jan Stránský (honzik) said :
#5

Hello Mozhgan,

what exactly do you mean by "they rotate freely and ignore spheres"? did
you try to change the "sense" parameter?
Thanks for further info
Jan

2012/12/10 m.asd <email address hidden>

> Question #215627 on Yade changed:
> https://answers.launchpad.net/yade/+question/215627
>
> m.asd posted a new comment:
> hi everybody,
>
> after changing the script, now I can run the script. but during running,
> the plate interacts with spheres appropriately. however, side-walls (I mean
> ids=[ LW.id,RW.id]) rotate freely and ignore spheres (either with
> implementing RotationEngine or body.state.angvel).
> this is true even when I use ( young=1e9 and O.dt=1e-8). what is the
> problem?
>
>
> Best regads
> mozhgan
>
> --
> 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
m.asd (mozhgan-asd) said :
#6

Hi jan,
I mean that walls rotate without any interaction with spheres and spheres pass through the wall. the problem can not be fixed with sense parameter. can O.engine or material property be responsible for that?

thanks
mozhgan

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

Dear Mozhgan,
First, the collider stride mechanism is not well adapted to rotating walls. Try setting verletDist=0 in the collider to eliminate one possible source of problems.
If the problem persists, see if the problem is in the rotation engine by removing it, and simply rotating one wall by hand:
wall.state.rotVel=something
Does it ignore spheres again?

Revision history for this message
m.asd (mozhgan-asd) said :
#8

dear chareyre,
I had changed the script and nothing changed, please let me know if there is any mistake in the script, as I cannot find and fix it.

overburden=8
from yade import pack,plot,qt
idmat=O.materials.append(FrictMat(density=2700,young=1e9,poisson=0.5,frictionAngle=0))
O.bodies.append(utils.wall(position=0,axis=2,sense=1))
O.bodies.append(utils.wall(position=0,axis=1,sense=1))
O.bodies.append(utils.wall(position=0.01,axis=1,sense=-1))
O.bodies.append(utils.wall(position=0,axis=0,sense=1))
O.bodies.append(utils.wall(position=0.01,axis=0,sense=-1))
sp=pack.SpherePack()
sp.makeCloud((0,0,0),(0.01,0.01,0.02),rMean=.0008,rRelFuzz=0)
sp.toSimulation(color=(0,0,1)) # blue

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()],verletDist=0),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 GravityEngine(gravity=(0,0,-9.81)),
 NewtonIntegrator(damping=0.6),
 qt.SnapshotEngine(fileBase='3d-',iterPeriod=233000,label='snapshot'),
 PyRunner(command='sphereData()',iterPeriod=2000000),
 PyRunner(command='interactionData()',iterPeriod=2000000),
 PyRunner(command='unbalancedData()',iterPeriod=2000000),
 PyRunner(command='plateData()',iterPeriod=2000000),
 PyRunner(command='side1Data()',iterPeriod=2000000),
 PyRunner(command='side2Data()',iterPeriod=2000000),
 PyRunner(command='checkUnbalanced()',realPeriod=1,label='checker'),
]

O.dt=1e-7

def checkUnbalanced():
 if O.iter<5000000: return
 if utils.unbalancedForce()>.05: return
 posi=O.bodies[5].state.pos[2]+O.bodies[5].shape.radius
 m=5
 while m<len(O.bodies):
  b=O.bodies[m]
  try:
   if isinstance(b.shape,Sphere):
    posi2=b.state.pos[2]+b.shape.radius
    if posi2>=posi: posi=posi2
    m=m+1
  except: m=m+1
 O.bodies.append(utils.wall(position=posi,axis=2,sense=-1))
 global plate
 plate=O.bodies[-1]
 plate.state.vel=(0,0,-.002)
 checker.command='shearing()'
 O.materials[0].frictionAngle=.2
 for i in O.interactions: i.phys.tangensOfFrictionAngle=tan(.2)

def shearing():
 if abs(O.forces.f(plate.id)[2])<overburden: return
 plate.state.vel*=0
 O.bodies[3].state.angVel=(0,0.1,0)
 O.bodies[4].state.angVel=(0,0.1,0)
 checker.command='stopShearing()'

def stopShearing():
 if O.bodies[3].state.rot<(0,0.001,0): return
 O.pause(); O.wait()
 plot.saveGnuplot('shearplot')
 plot.saveDataTxt('shearunbal.txt.bz2',vars=('itperi','unbalanced'))
 plot.saveDataTxt('shearsphere.txt.bz2',vars=('itperi','bodyid','radi','posiX','posiY','posiZ','oriX','oriY','oriZ','oripi'))
 plot.saveDataTxt('shearinteraction.txt.bz2',vars=('itperi','bodynum1','bodynum2','normstiff','shearstiff','normforceX','normforceY','normforceZ','shearforceX','shearforceY','shearforceZ'))
 plot.saveDataTxt('shearwall1.txt.bz2',vars=('itperi','rotor1X','rotor1Y','rotor1Z','rotor1pi','F1x','F1z'))
 plot.saveDataTxt('shearwall2.txt.bz2',vars=('itperi','rotor2X','rotor2Y','rotor2Z','rotor2pi','F2x','F2z'))
 plot.saveDataTxt('shearplate.txt.bz2',vars=('itperi','Fz','w'))
 print 'Finished'

def unbalancedData():
 plot.addData(itperi=O.iter,unbalanced=utils.unbalancedForce())

def sphereData():
 i=5
 while i<len(O.bodies):
  if isinstance(O.bodies[-1].shape,Wall):
   plot.addData(); return
  b=O.bodies[i]
  plot.addData(itperi=O.iter,bodyid=b.id,posiX=b.state.pos[0],posiY=b.state.pos[1],posiZ=b.state.pos[2],radi=b.shape.radius,oriX=b.state.ori[0],oriY=b.state.ori[1],oriZ=b.state.ori[2],oripi=b.state.ori[3])
  i=i+1

def interactionData():
 i=5 #id num of bodies for interaction detection starting from spheres
 while i<len(O.bodies):
  id1=i
  j=0
  while j<len(O.bodies):
   id2=j
   try:
    interact=O.interactions[id1,id2]
    plot.addData(itperi=O.iter,bodynum1=id1,bodynum2=id2,normstiff=interact.phys.kn,shearstiff=interact.phys.ks,normforceX=interact.phys.normalForce[0],normforceY=interact.phys.normalForce[1],normforceZ=interact.phys.normalForce[2],shearforceX=interact.phys.shearForce[0],shearforceY=interact.phys.shearForce[1],shearforceZ=interact.phys.shearForce[2])
    j=j+1
   except:
    j=j+1
  i=i+1

def plateData():
 if not isinstance(O.bodies[-1].shape,Wall):
  plot.addData(); return
 Fz=O.forces.f(plate.id)[2]
 w=plate.state.refPos[2]-plate.state.pos[2]
 plot.addData(Fz=Fz,w=w)

def side1Data():
 if not isinstance(O.bodies[3].shape,Wall):
  plot.addData(); return
 rotor1X=O.bodies[3].state.ori[0]
 rotor1Y=O.bodies[3].state.ori[1]
 rotor1Z=O.bodies[3].state.ori[2]
 rotor1pi=O.bodies[3].state.ori[3]
 F1x=O.forces.f(O.bodies[3].id)[0]
 F1z=O.forces.f(O.bodies[3].id)[2]
 plot.addData(itperi=O.iter,F1x=F1x,F1z=F1z,rotor1X=rotor1X,rotor1Y=rotor1Y,rotor1Z=rotor1Z,rotor1pi=rotor1pi)

def side2Data():
 if not isinstance(O.bodies[4].shape,Wall):
  plot.addData(); return
 rotor2X=O.bodies[4].state.ori[0]
 rotor2Y=O.bodies[4].state.ori[1]
 rotor2Z=O.bodies[4].state.ori[2]
 rotor2pi=O.bodies[4].state.ori[3]
 F2x=O.forces.f(O.bodies[4].id)[0]
 F2z=O.forces.f(O.bodies[4].id)[2]
 plot.addData(itperi=O.iter,F2x=F2x,F2z=F2z,rotor2X=rotor2X,rotor2Y=rotor2Y,rotor2Z=rotor2Z,rotor2pi=rotor2pi)

plot.plots={'itperi':('unbalanced',)}
plot.plot()

Gl1_Sphere.stripes=True
qt.View()

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

Can you help with this problem?

Provide an answer of your own, or ask m.asd for more information if necessary.

To post a message you must log in.