← Back to team overview

yade-users team mailing list archive

Re: Run Engine in PeriodicRunner()

 

2010/3/23 Václav Šmilauer <eudoxos@xxxxxxxx>

> > I was trying to use PeriodicPythonRunner() to run an Engine. I defined
> > a function to be called in PreiodicRunner() as something like:
> >
> > def shearForce():
> >     if (O.iter>300):
> >         i=O.interactions[0,1]
> >         O.runEngine(ForceEngine(force=(0,0,3e5),subscribedBodies=[0]))
> >
> > Well, something strange happened. I mean, it is like if forces.sync()
> > function was called twice and so the code was ending up with the wrong
> > force in the NewtonIntegrator. I can say this because I was getting
> > different results when calling O.forces.f() and printing out in the
> > screen the force used in NewtonIntegrator to get the acceleration
> > (they should look the same, right?).
>
> ForceEngine will augment current force, not set its absolute value.
> Could that explain the difference? What was the other case you mention?
> If you run:
>
> O.engines=[...,ForceEngine(...),...]
>
> or
>
> O.engines=[...,PeriodicPythonRunner(command='runForceEngine()'),...]
> def runForceEngine():
>        ForceEngine(...)()
>

If I do as you say it is fine, but in the example I am dealing with I call
the same engine (ForceEngine) twice (one in the list of Engine and the other
one in the PeriodicRunner). I do not know if this is the problem (a double
called, I mean). Maybe I will try again and then I will let you know more
precisely if I still see that something is wrong.



>
> (BTW if you run recent version, O.runEngine will give you warning. You
> should use simply engine() to run it instead, like above.)
>
> You should get the same results, provided engines are the same
> otherwise, in both cases. Note that the second case will be less
> efficient, because of c++/python roundtrips.
>
>
> > BTW, could you tell what the variable "thread" corresponds to?
>
> Guessing what you mean...(?) Single process (yade) can run multiple
> threads simultaneously; threads share memory space (variables etc),
> which is how they differ from processes, which are completely
> independent. Besides GUI thread, logger thread etc, OpenMP spawns
> (creates) several threads for running some loops in parallel, to speed
> up the computation. Was this your question? You can look at
> http://en.wikipedia.org/wiki/Thread_(computer_science)<http://en.wikipedia.org/wiki/Thread_%28computer_science%29>(but I didn't
> read it since it doesn't seem to be accessible now).
>
> Ehm I was meaning the variable called "nThreads". Just because I saw this
one as a private variable in the sync() function and I was guessing about
its value.

Chiara


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

Follow ups

References