← Back to team overview

yade-users team mailing list archive

Re: [Question #225080]: Many scenes syncronization

 

Question #225080 on Yade changed:
https://answers.launchpad.net/yade/+question/225080

Bruno Chareyre proposed the following answer:
Hi Ning,
I would think the way to go is not to add many scenes in one yade instance but, instead, to manipulate many instances of Yade with one scene each (I think it was already suggested by Jan after a previous question, and by me in a private email months ago), which doesn't need anything special on yade's side.

I justed tried now, and actually it is fairly easy to get a working
example. Below is an example script.

Since yadeThread() is always loading the same scene in my example, the two threads are computing exactly the same thing. I see two cores occupied on my pc, and an output file which looks like this (the loaded scene is a triaxial from preprocessor), indicating that they are really running at the same time (the first value is iteration number).
...
60 36509.017143665566 37829.501250125584...
60 36509.017143665566 37829.501250125584...
80 43052.343220629424 42941.210579037084...
80 43052.343220629424 42941.210579037084...
...

This is probably not the only way to do it. You may use real multithreading (here it is only spawning different processes), which will use different python modules, but you should get the idea. How you access and manipulate the data from each separate simulation may determine what is the best method.
If you can pass values efficiently between the individual instances, please don't forget to tell us, as this is a very interesting experiment. :)

Cheers.


_____

from multiprocessing import Process
def yadeThread(name):
    import yade as y
    y.Omega().load("test.yade")
    y.Omega().run(100,1)
    print "finished",name

p = Process(target=yadeThread,args=('thread1',))
p2 = Process(target=yadeThread,args=('thread2',))
p.start()
p2.start()

The output:

In [5]: Welcome to Yade 2013-03-15.git-a60fe59
Welcome to Yade 2013-03-15.git-a60fe59
TCP python prompt on localhost:9000, auth cookie `keusda'
TCP python prompt on localhost:9001, auth cookie `keacdy'
XMLRPC info provider on http://localhost:21000
XMLRPC info provider on http://localhost:21001
finished thread1
finished thread2

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.