yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #02651
Re: Run Engine in PeriodicRunner()
> 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(...)()
(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) (but I didn't
read it since it doesn't seem to be accessible now).
v
Follow ups
References