Beispiel #1
0
def test_ball():
    cortix = Cortix(use_mpi=False)
    secs = 4
    mod_list = []
    shape = geo.box(-30, 0, 30, 50)
    plot = Plot(shape=shape, length=2)
    cortix.add_module(plot)
    ball1 = BouncingBall(shape, runtime=secs)
    ball1.p0 = [0, 20]
    ball1.v0 = [20, 4]
    mod_list.append(ball1)
    cortix.add_module(ball1)
    time.sleep(0.01)
    ball2 = BouncingBall(shape, runtime=secs)
    ball2.p0 = [17, 22]
    ball2.v0 = [-5, 1]
    mod_list.append(ball2)
    cortix.add_module(ball2)

    for c, i in enumerate(mod_list):
        i.connect('plot-send{}'.format(c),
                  plot.get_port('plot-receive{}'.format(c)))
        for j in mod_list:
            if i == j:
                continue
            name = '{}{}'.format(i.timestamp, j.timestamp)
            name2 = '{}{}'.format(j.timestamp, i.timestamp)
            j.connect(name, i.get_port(name2))

    cortix.draw_network('network_graph.png')
    cortix.run()
    print('bye')
Beispiel #2
0
def main():
    '''
    Description of the run file.

    '''

    # Parameters
    time_step  = 0.1

    ir_7040 = Cortix(splash=True)
    ir_7040.network = Network()

    ir_7040_net = ir_7040.network

    # DADOS module.
    dados = Dados()
    ir_7040_net.module(dados)
    dados.rs232_filename = 'ir-7040'
    dados.rs232_request_string = '\r\nP0001 01245689BCDMNVWYZaOdghin 55}'

    # DataPlot module.
    data_plot = DataPlot()
    data_plot.title = 'IR-7040 Data Acquisition'
    data_plot.dpi = 300

    # Network connectivity

    ir_7040_net.connect( [dados,'rs-232'], [data_plot,'viz-data'] )
    rs232_port.connect(plot_port)

    ir_7040_net.draw()

    # Run application
    ir_7040.run()
Beispiel #3
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')
Beispiel #4
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')
Beispiel #5
0
    def __init__(self):
        ##        self.filename = 'ideal_gas_simulation.csv'
        ##        if os.path.isfile(self.filename):
        ##            print('file exits')
        ##        with open(self.filename,'w') as file:
        ##            file.write('Number,Collisions/Sec\n')

        n_list = [15, 30, 15, 60, 75, 500, 600, 1200, 2400, 3200, 4200, 5400]
        for i in n_list:
            print('starting:', i, 'balls')
            procs = 15
            runtime = 0.5
            balls = int(i / procs)
            cortix = Cortix(use_mpi=False)
            mod_list = []
            shape = geo.box(-30, 0, 30, 50)

            plot = Plot(number=i, modules=10, runtime=runtime)
            cortix.add_module(plot)

            for i in range(procs):
                time.sleep(0.01)
                app = BallHandler(shape, balls=balls, runtime=runtime)
                app.v0 = [40, 40]
                app.r = 0.1
                mod_list.append(app)
                cortix.add_module(app)

            for c, i in enumerate(mod_list):
                i.connect('plot-send{}'.format(c),
                          plot.get_port('plot-receive{}'.format(c)))
                for j in mod_list:
                    if i == j:
                        continue
                    name = '{}{}'.format(i.timestamp, j.timestamp)
                    name2 = '{}{}'.format(j.timestamp, i.timestamp)
                    j.connect(name, i.get_port(name2))

            cortix.run()
            time.sleep(5)
        # Ports def.
        external_flow = Port('external-flow')
        droplet.add_port(external_flow)
        visualization = Port('visualization')
        droplet.add_port(visualization)

        # DataPlot modules.
        data_plot = DataPlot()
        data_plot.title = 'Droplet Trajectory '+str(i)
        data_plot.dpi = 300
        # Ports def.
        plot = Port('viz-data:{:05}'.format(i))
        data_plot.add_port(plot)

        # Vortex module.
        # Ports def.
        fluid_flow = Port('fluid-flow:{}'.format(i))
        vortex.add_port(fluid_flow)

        # Network connectivity
        external_flow.connect(fluid_flow)
        visualization.connect(plot)

        # Add modules to Cortix
        cortix.add_module(droplet)
        cortix.add_module(data_plot)

    cortix.add_module(vortex)

    cortix.run()