← Back to team overview

yade-users team mailing list archive

Re: Engines Python

 

Hi Chiara

I had the same problem with a "TranslationEngine" just now.

I think if you use an engine outside "O.engines[]" you have to put O.runEngine(ForceEngine(/force=(0,1e5,0),subscribedBodies=[0]/))

Cheers
Benoit



chiara modenese a écrit :
It seems not working...
Basically I want to apply a constant force after a certain number of iterations. So I do:

In the list of engines:
PeriodicPythonRunner(iterPeriod=1,command='shearForce()')

I define the function as:
def shearForce():
    if (O.iter>300):
        i=O.interactions[0,1]
        ForceEngine(force=(0,1e5,0),subscribedBodies=[0])
        plot.addData(fs=i.phys.shearForce[1],it=O.iter)

But it does not apply such force (I have checked through the plot). Any suggestions? Is it right to go on in this way?

Thanks, Chiara



On 19 March 2010 14:35, Benoit Charlas <benoit.charlas@xxxxxxxxxxx <mailto:benoit.charlas@xxxxxxxxxxx>> wrote:

    Hi

    Did you manage to understand?

    Benoit

    chiara modenese a écrit :
    Hi! Thanks for your answer. I have tried to include the
    ForceEngine as
    ForceEngine(force=(100000000,0,0))
    in the list of the engines (so at the moment it is just a simple
    case, not using PyRunner) but I do not see any force applied to
    my bodies... If I use ForceEngine should I also specify the id of
    the body/ies I want to apply the force on?
    I am still learning..;)

    Cheers, Chiara

    2010/3/19 Benoit Charlas <benoit.charlas@xxxxxxxxxxx
    <mailto:benoit.charlas@xxxxxxxxxxx>>

        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 <https://launchpad.net/%7Eyade-users>
        Post to     : yade-users@xxxxxxxxxxxxxxxxxxx <mailto:yade-users@xxxxxxxxxxxxxxxxxxx>
        Unsubscribe : https://launchpad.net/~yade-users <https://launchpad.net/%7Eyade-users>
        More help   : https://help.launchpad.net/ListHelp



        _______________________________________________
        Mailing list: https://launchpad.net/~yade-users
        <https://launchpad.net/%7Eyade-users>
        Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
        <mailto:yade-users@xxxxxxxxxxxxxxxxxxx>
        Unsubscribe : https://launchpad.net/~yade-users
        <https://launchpad.net/%7Eyade-users>
        More help   : https://help.launchpad.net/ListHelp


    ------------------------------------------------------------------------
    _______________________________________________ Mailing list:
    https://launchpad.net/~yade-users
    <https://launchpad.net/%7Eyade-users> Post to :
    yade-users@xxxxxxxxxxxxxxxxxxx
    <mailto:yade-users@xxxxxxxxxxxxxxxxxxx> Unsubscribe :
    https://launchpad.net/~yade-users
    <https://launchpad.net/%7Eyade-users> More help :
    https://help.launchpad.net/ListHelp


------------------------------------------------------------------------

_______________________________________________
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


References