Exemple #1
0
class Simulation:
    def __init__(self):
        self.n_list = [15,]

        self.procs = 15
        self.runtime=30
        
        
        
        self.mod_list = []
        self.shape = geo.Polygon([(0, 0), (0, 30), (30, 30),(30,25),
                                  (65,25),(65,-20),(85,-20),(85,-40),
                                  (45,-40),(45,-20),(49,-20),(49,15),
                                  (30,15),(30,0)])

        self.fps = 60

    def run(self):
        for c,i in enumerate(self.n_list):
            self.cortix = Cortix(use_mpi=False)
            self.net = Network()
            self.cortix.network = self.net
            self.plot = Plot(self.shape,modules=self.procs,runtime=self.runtime)
            self.plot.fps = self.fps
            self.net.add_module(self.plot)
            print(c,'iterations')
            self.balls = i
            self.balleach = int(self.balls/self.procs)
            self.mod_list = []
            for i in range(self.procs):    
                if i <5:
                    app = BallHandler(self.shape, balls=self.balleach,runtime = self.runtime,bn=[2,2,28,28],color='r')
                if i>=5:
                    app = BallHandler(self.shape, balls=self.balleach,runtime = self.runtime,bn=[43,-38,83,-22],color='b')
                self.mod_list.append(app)
                self.net.add_module(app)
            for c,i in enumerate(self.mod_list):
                self.net.connect([i,'plot-send{}'.format(c)],[self.plot,'plot-receive{}'.format(c)])
                for j in self.mod_list:
                    if i == j:
                        continue
                    name = '{}{}'.format(i.name,j.name)
                    name2 = '{}{}'.format(j.name,i.name)
                    self.net.connect([i,name], [j,name2])
            self.cortix.run()
            del self.cortix
            print('finished sim')
Exemple #2
0
class Simulation:
    def __init__(self):
        self.n_list = [15,]

        self.procs = 15
        self.runtime=30
        self.t_step = 0.01
        
        self.r=1
        self.mod_list = []
        self.shape = geo.Polygon([(0, 0), (0, 100), (100, 100),(100,0)])

        self.fps = 60

    def run(self):
        for c,i in enumerate(self.n_list):
            self.cortix = Cortix(use_mpi=False)
            self.net = Network()
            self.cortix.network = self.net
            self.plot = Plot(self.shape,modules=self.procs,runtime=self.runtime)
            self.plot.fps = self.fps
            self.net.add_module(self.plot)
            print(c,'iterations')
            self.balls = i
            self.balleach = int(self.balls/self.procs)
            self.mod_list = []
            for i in range(self.procs):    
                app = BallHandler(self.shape, balls=self.balleach,runtime = self.runtime)
                app.r=self.r
                app.t_step = 0.01
                self.mod_list.append(app)
                self.net.add_module(app)
            for c,i in enumerate(self.mod_list):
                self.net.connect([i,'plot-send{}'.format(c)],[self.plot,'plot-receive{}'.format(c)])
                for j in self.mod_list:
                    if i == j:
                        continue
                    name = '{}{}'.format(i.name,j.name)
                    name2 = '{}{}'.format(j.name,i.name)
                    self.net.connect([i,name], [j,name2])
            self.cortix.run()
            del self.cortix
            print('finished sim')