Assigned bodies motion law

Asked by Riccardo carta

Hi everyone
I'm new yade user and my problem is:
I realized a body by importing a .mesh file into the model, now I want this body to translate with an assigned velocity profile(a function of time).

It is possible to define a velocity profile to be used into the TranslationEngine()? If yes how should I do?

I have been thinking(maybe I saw it in some examples) about defining a function to update the position of the facets the body is made of through a PyRunner engine but I need some help. Is this a possible way to solve my problem?

Thanks

Riccardo

Question information

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

Hi Riccardo,

before someone else will give better answer, here is a quick solution based
on your idea of PyRunner:

def setTransEngineVelocity():
  transEngine.velocity = 0.01 * O.iter

O.engines = [
  ...
  TranslationEngine( ids = [yourParticleID], translationAxis = (1,0,0),
velocity = 0, label= "transEngine" ),
  PyRunner( iterperiod = 1, command = "setTransEngineVelocity()" ),
  ...
]

First you define function setTransEngineVelocity() where you set, in
dependence on simulation time, some velocity to transEngine. With this
0.01*O.iter you would get constant acceleration, but you can define any
time function you want. It is also possible to change the translationAxis
parameter, so basicly you are able to prescribe arbitrary movement. Then
you have to call this function in PyRunner, iterperiod=1 means, that it
will be called in each time step. In case of further questions don't
hesitate to ask.

good luck

Jan

2012/11/28 Riccardo carta <email address hidden>

> New question #215485 on Yade:
> https://answers.launchpad.net/yade/+question/215485
>
> Hi everyone
> I'm new yade user and my problem is:
> I realized a body by importing a .mesh file into the model, now I want
> this body to translate with an assigned velocity profile(a function of
> time).
>
> It is possible to define a velocity profile to be used into the
> TranslationEngine()? If yes how should I do?
>
> I have been thinking(maybe I saw it in some examples) about defining a
> function to update the position of the facets the body is made of through
> a PyRunner engine but I need some help. Is this a possible way to solve my
> problem?
>
> Thanks
>
> Riccardo
>
> --
> 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
Riccardo carta (riccardo-carta) said :
#2

Thanks Jan!
>>transEngine.velocity = 0.01 * O.iter
I don't understand why you choose O.iter instead of O.time, for example I need to define the velocity as sinus function of time....it is v=math.sin(O.iter or O.time?)

And some more according to this definition of the velocity profile:
the "velocity" field in TranslationEngine is meant to be always positive, I mean that the versus of the velocity is defined by the translationalAxis field am I right?
So, to define a sinus velocity profile I do have to change also the axis parameter by PyRunner, am I right? How can I do this?
It is enough to add something inside the function like
   def setTransEngineVelocity():
     transEngine.velocity = 0.01 * O.iter
     transEngine.axis= ....

??

thanks in advance

Riccardo

Revision history for this message
Riccardo carta (riccardo-carta) said :
#3

I wrote this but it does not seem to work

def setTransEngineVelocity():
 v =math.sin(O.time)
 transEngine.velocity = v
 if v > 0:
  transEngine.axis = [0,0,-1]
 else:
  transEngine.axis = [0,0,1]

O.engines=[
 ......
    TranslationEngine(translationAxis=[0,0,-1],velocity=0,ids=tool,label= "transEngine"),
 PyRunner(iterPeriod=1,command='setTransEngineVelocity()'),
    ...
]

Revision history for this message
Riccardo carta (riccardo-carta) said :
#4

I'm sorry, my fault, it works!
I am waiting for your ok but I think that I got it...

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

Hi Riccardo,

I would suggest to first ignore translationEngine, it is useless in most cases.

If you want the position to be X=f(t), then you can simply play with the body's velocity at each iteration:
body.vel = (df/dt)(t)
I.e. in your case: vel=omega*cosine(omega*time)*amplitude
Ok, it will not exactly give X=f(t). Only a first order approximation.

So, even better, you can do simply:
body.vel = (f(t+dt)-f(t))/dt

Remember to block the DOFs of the body, so it really move with your prescribed velocity.
Also note that the obvious body.pos=f(t) is not an option in general, as it would break many parts of the code (namely contact laws and collider).
Yade likes to integrate velocities, it dislikes instantaneous move from one place to another.

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

Oh... You solved the problem while I was typing? :)

Bruno

Revision history for this message
Riccardo carta (riccardo-carta) said :
#7

Thanks Bruno, I will take into account your advice also.
What I wrote above seems to work fine by now

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

Hi Riccardo,

you can choose if you prescribe the veocity directly to the bodies or use
TranslationEngine. If you use it for many particles, I would personally
prefere TranslationEngine as it does all looping in C++, but basicly it
doesn't matter much :-)

concerning TranslationEngine, "velocity" parameter may be both positive and
negative. The actual velocity vector applied to bodies is simply
velocity*translationAxis, so your function can be simplified to

def setTransEngineVelocity():
    v = math.sin(O.time)
    transEngine.velocity = v

and it should work..

Jan

2012/11/28 Riccardo carta <email address hidden>

> Question #215485 on Yade changed:
> https://answers.launchpad.net/yade/+question/215485
>
> Riccardo carta posted a new comment:
> Thanks Bruno, I will take into account your advice also.
> What I wrote above seems to work fine by now
>
> --
> 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
Riccardo carta (riccardo-carta) said :
#9

Thanks!
that solved my question