← Back to team overview

yade-users team mailing list archive

Re: Engines Python

 

Mmmmh...
1/ You need to choose one way : put the forceEngine with the other engines instead of periodicRunner OR write a periodic "command" that will really apply forces on particles (like force = force + appliedForce). The latest doesn't make much sense, it would apply the force during one step each N iterations... For now, the force engine is never in the simulation, so it doesn't do anything. The simple way : ForceEngine(force=(0,1e5,0),subscribedBodies=[0]) in the list of engines.

2/ forceEngine is applying forces on bodies, not on interactions. You can't check the result by plotting interaction force (except if you assume equilibrium?).

Bruno



ForceEngine is applying

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


--
_______________
Bruno Chareyre
Associate Professor
Grenoble INP
Lab. 3SR
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43
________________




References