yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #02587
Re: Engines Python
Hi Chiara
I don't really understand your question. What I don't understand the
most is do you want to apply this force once (for tot iteration) or
every x TimeStep.
But i'll try to answer with my very little knowledge!
The function PeriodicPythonRunner allows you to apply an action (for
example a Python function) periodically every : virtPeriod, realPeriod
or iterPeriod
For example let's write that you want to apply your force every 1000
iteration steps
forceengine=ForceEngine(/.../)
PeriodicPythonRunner(iterPeriod=1000,command='forceengine()')
But then you'll apply the same force every 1000 steps.
You can also apply an evolution to your force or anything you want while
defining another function
Let's call your function "applyAForce()" and let's suppose you want to
increment 10 times your force
O.engines=[
...
PeriodicPythonRunner(iterPeriod=1000,command='applyAForce()')
]
...
def applyAForce():
/your function with (nearly) everything you want like ForceEngine(...)/
You should check in the directory yade/examples. There are some useful
tips in those examples !
Cheers,
Benoit
Václav Šmilauer a écrit :
is it possible to call an engine inside another engine in python? For
instance, can I use PeriodicPythonRunner to define a function that
having
satisfied a certain condition (say after tot iterations) call an engine
(say
apply a force)?
Hi Chiara, engines are callable objects (define the __call__ method), so
you can call them with ():
forceEngine=ForceEngine(...)
forceEngine()
# ForceEngine(...)() would also work
You can make the forceEngine a variable so that the engine is not
constructed every time.
Cheers, Vaclav
_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Follow ups
References