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')
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) j.connect(name, i.get_port(name2)) cortix.draw_network('network_graph.png') cortix.run() print('bye')