Example #1
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)
Example #2
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')
        # 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()
Example #4
0
    # Parameters
    time_step = 0.1

    cortix = Cortix(use_mpi=False)

    # DADOS module.
    dados = Dados()
    # Port def.
    rs232_port = Port('rs-232')
    dados.add_port(rs232_port)
    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
    # Port def.
    plot_port = Port('viz-data')
    data_plot.add_port(plot_port)

    # Network connectivity
    rs232_port.connect(plot_port)

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

    # Run application
    cortix.run()
Example #5
0
        for i in self.ports:  #Send 'done' string to plot module as end condition
            if 'plot' in str(i):
                self.send('done', i)
        print('Time Elapsed: ', self.elapsed)
        print('Done')


if __name__ == '__main__':
    cortix = Cortix(use_mpi=False)
    mod_list = []
    shape = geo.box(-30, 0, 30, 50)

    plot = Plot(shape=shape, modules=10)
    plot.fps = 10
    cortix.add_module(plot)

    for i in range(10):
        time.sleep(0.01)
        app = BallHandler(shape, balls=10, runtime=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)