translation of a rotating cylinder

Asked by guilhem

Hi all,

I am trying to impose a translation of a cylinder in rotation to simulate powder crunching.

So i use two engines after bed stabilisation:

def checkUnbalanced():
   if O.iter<5000: return
   if unbalancedForce()>.1: return
   O.engines=O.engines[:4]+[RotationEngine(ids=roul,angularVelocity=0.,rotationAxis=(0,1,0),label="rotEngine")+TranslationEngine(ids=roul,translationAxis=(1,0,0),velocity=vitesse,label="transEngine")]+O.engines[4:]
   checker.command='arret()' #on passe a la fonction arret de la racle

def arret():
   if O.time()>(2*dim_lo)/vitesse:
# plate1.state.vel*=0
# plate2.state.vel*=0
      transEngine.velocity=0

This logically not working because i need to define at each time step the new position of the rotational axis of the cylinder. The solution is to use in rotationnal engine options zeroPoint (rotateAroundZero=true). But the problem is that i can't call transEngine or rotEngine during simulation:

----> 1 transEngine

NameError: name 'transEngine' is not defined

Label seems not to be take into account??????

BR

Guilhem

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

Hi Guilhem,
please provide a MWE [1] (a short but complete script, such that we can test it ourselves)
thanks
Jan

[1] https://yade-dem.org/wiki/Howtoask

Revision history for this message
guilhem (guy30) said :
#2

Ok, sorry.

Here is just a simple code showing the problem (no spheres, not important)

#####################
#creation du cylindre
#####################
rouleau_r=4
roul=O.bodies.append(geom.facetCylinder((-rouleau_r,2,rouleau_r),radius=rouleau_r,height=2,orientation=Quaternion((1,0,0),pi/2),wallMask=7,segmentsNumber=15))

#####################
#moteur de resolution
#####################
O.engines=[
   ForceResetter(),
   #prise en compte des toutes les particules, facets et walls pour les interactions
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
   InteractionLoop(
      #prise en compte des interactions sphere+sphere and facet+sphere
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
      #parametre de friction
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      #loi d interaction
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.5),
]

#####################
#translation/rotation
#####################
O.engines=O.engines[:4]+[RotationEngine(ids=roul,angularVelocity=0.,rotationAxis=(0,1,0),label='rotEngine')+TranslationEngine(ids=roul,translationAxis=(1,0,0),velocity=10,label='transEngine')]+O.engines[4:]

print 'vitesse', transEngine.velocity

avec l'erreur:
Traceback (most recent call last):
  File "/usr/bin/yade", line 178, in runScript
    execfile(script,globals())
  File "test.py", line 30, in <module>
    print 'vitesse', transEngine.velocity
NameError: name 'transEngine' is not defined
/usr/lib/python2.7/dist-packages/IPython/frontend.py:30: UserWarning: The top-level `frontend` package has been deprecated. All its subpackages have been moved to the top `IPython` level.
  warn("The top-level `frontend` package has been deprecated. "
vitesse[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key for showing help), F10 both, F9 generator, F8 plot. ]]

Same error with a more complex code.

Thanks a lot

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

Hi Guilhem,
thanks for the script. Yes, labels in this case are not taken into account. Currently only labels of "first order" engines plus special cases (like bound functors of collider or Ig2, Ip2 and Law2 functors of InteractionLoop) are projected to python, see [1,2].
Adding CombinedKinematicEngine should not be a problem, but it is not currently available.

A workaround:
####
transEngine = TranslationEngine(ids=roul,translationAxis=(1,0,0),velocity=10)
rotEngine = RotationEngine(ids=roul,angularVelocity=0.,rotationAxis=(0,1,0))
O.engines=O.engines[:4]+[rotEngine+transEngine]+O.engines[4:]
####

cheers
Jan

[1] https://github.com/yade/trunk/blob/master/py/wrapper/yadeWrapper.cpp#L542
[2] https://github.com/yade/trunk/blob/master/py/wrapper/yadeWrapper.cpp#L714

Revision history for this message
Jérôme Duriez (jduriez) said :
#4

Hi,

What if you include these TranslationEngine and RotationEngine in O.engines from the start, with dead [*] initially = 1, and just switching to dead = 0 when you actually need these engines ?

(My guess is that labels should work in this case ??..)

[*] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.TranslationEngine.dead

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

@Jerome:
The problem is not that it is not in O.engines from the start, but that RotationEngine+TranslationEngine is actually CombinedKinematicEngine. The label of CombinedKinematicEngine would be put into python, but not its subengines.
see the links from my previous message
Jan

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

Hi Guilhem,
just a remark, your code from #2 should work in yadedaily or compiled new version [1] :-)
cheers
Jan

[1] https://github.com/yade/trunk/commit/cad9387c96fad5c4f8a1dab5bfd724b14a502b13

Can you help with this problem?

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

To post a message you must log in.