remove functions from PyRunner

Asked by Christian Jakob

Hi,

For generation process of my model I create some spheres randomly. Then the model has to calm, because there are some overlaps. So I wrote a small function:

def calm():
 for ii in range(0,sum_spheres+1):
  O.bodies[ii].state.vel=Vector3(0,0,0)

I can add this function to O.engines with the PyRunner command:

O.engines=O.engines+[PyRunner(iterPeriod=10,command='calm()')]
O.run(1000,True)

My question is:

How can I remove this function? I need it only on the first few steps in my model.
I tried...

O.engines=O.engines-[PyRunner(iterPeriod=10,command='calm()')]

...but it doesnt work.

Christian.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Christian Jakob
Solved:
Last query:
Last reply:
Revision history for this message
Chiara Modenese (chiara-modenese) said :
#1

We added some time ago a useful feature which would solve your problem. If
you add a label to the engine you want to eliminate from the simulation
(e.g. PyRunner(iterPeriod=10,command='calm()',label='MyEngine')), then you
can say:
MyEngine.dead=True
It practically means that since next iteration that engine will not be
active any longer.

HTH,
Chiara

On 3 August 2011 12:41, Christian Jakob <
<email address hidden>> wrote:

> New question #166809 on Yade:
> https://answers.launchpad.net/yade/+question/166809
>
> Hi,
>
> For generation process of my model I create some spheres randomly. Then the
> model has to calm, because there are some overlaps. So I wrote a small
> function:
>
> def calm():
> for ii in range(0,sum_spheres+1):
> O.bodies[ii].state.vel=Vector3(0,0,0)
>
> I can add this function to O.engines with the PyRunner command:
>
> O.engines=O.engines+[PyRunner(iterPeriod=10,command='calm()')]
> O.run(1000,True)
>
> My question is:
>
> How can I remove this function? I need it only on the first few steps in my
> model.
> I tried...
>
> O.engines=O.engines-[PyRunner(iterPeriod=10,command='calm()')]
>
> ...but it doesnt work.
>
> Christian.
>
> --
> 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,

I would not recommend you to remove an engine. I prefer to "disable"
not needed engines.
Every engine has a flag "dead", by default it is false.

You can add a label to your PyRunner, for example
(PyRunner.....,label="calmLabel")

Then, when you do not need this engine any more, just do:
calmLabel.dead=True

and after that your engine will be "switched off" and ignored by Yade.

For more options with PyRunner, please, see:
https://www.yade-dem.org/doc/yade.wrapper.html#yade.wrapper.PeriodicEngine

Anton

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

Thank you. This solved the problem.

Another related question now occurs:

If I use the command twice, with calmLabel=True, but with differnt iterPeriods...

O.engines=O.engines+[PyRunner(iterPeriod=10,command='calm()')]
O.run(1000,True)
O.engines=O.engines+[PyRunner(iterPeriod=20,command='calm()')]
O.run(1000,True)

... what will happen then?

Is this function active twice too?

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

sorry, little mistake in my last post:

it should mean:

If I use the command twice, without calmLabel and calmLabel.dead=True, but with different iterPeriods...

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

I think, it should work independently each of other.

Anton