def __init__(self, x, y, width = 100.0, height = 100.0): Reactor.__init__(self, x, y, width, height) self.draw_bounding_box = True #num_plugs = 5 spacing = 2.0 plug_size = 50.0 # (self.width / num_plugs) #pump = Pump(self.left - plug_size, 0.0, rate = 2, particle_radius = 15.0) #self.swallow(pump) #prev_plug = None #for n in range(int(self.left), int(self.right), int(plug_size)): #x = n + (plug_size / 2.0) #plug = Plug(x, 0, plug_size - spacing, plug_size - spacing) #if prev_plug is not None: #print prev_plug, plug #plug.connect_input(prev_plug) #else: #plug.connect_input(pump) #self.swallow(plug) #prev_plug = plug self.create_input(self.left + 10.0, 0.0) self.create_output(self.right, 0.0, spacing, plug_size - spacing) self.create_wall(self.left, -(plug_size/2) + (spacing/2), spacing, plug_size - spacing) self.create_wall(self.left, -(plug_size/2)-spacing, self.width, spacing) self.create_wall(self.left, +(plug_size/2), self.width, spacing) self.add_body(ReactorParticle(color=Colour.blue, newton=None, # TODO - fix bug where ode_init called twice when constructing w/ a newton initial_position=(0, 0), initial_force=(20,-10), particle_radius=3.0)) self.add_body(Plug(color=Colour.green, newton=None, # TODO - fix bug where ode_init called twice when constructing w/ a newton initial_position=(0,0),#self.left + (plug_size / 2) + spacing, 0), initial_force=(20,20), radius=(plug_size-spacing)/2)) #pr = PipeReactor(0, 0, 40.0, 40.0) #pr.color = Colour.black #self.swallow(pr) #self.add_body(pr) # turn on gravity self._ode_world.setGravity( (0,10.0,0) )
def __init__(self, x, y, width, height): print "init reactor", (width,height) Reactor.__init__(self, x, y, width, height) print "init body" Body.__init__(self, None, (0,0), (0,0), max(width,height)) print "done" thick = 2.0 spacing = thick + 4.0 self.create_wall(self.left, self.top, self.width, thick) self.create_wall(self.left, self.bottom, self.width, thick) self.create_wall(self.left-spacing, self.top + spacing, thick, self.height - (spacing*2)) #self.create_wall(self.right+spacing, self.top + spacing, # thick, self.height - (spacing*2)) self.create_input(self.left, # + spacing, 0.0) self.create_output(self.right, 0.0, thick, self.height - spacing)
def __init__(self, x, y, num_particles = [], do_reaction = False): Reactor.__init__(self, x, y, do_reaction=do_reaction) #self._ode_world.setGravity( (0,100.0,0) ) # some helpful constants pipe_size = 50.0 thick = 2.0 spacing = 1.0 # To create a wall: # # self.create_wall(x, y, # width, height) # # For example: # # A baffle: # # self.create_wall(0, 0, self.right - thick - spacing, thick) # # (0,0 would be the center of the reactor) # # top long self.create_wall(self.left-pipe_size, self.top, self.width+pipe_size, thick) # top short self.create_wall(self.left-pipe_size, self.top+pipe_size-thick, pipe_size+thick, thick) # input cap self.create_wall(self.left-pipe_size-thick-spacing, self.top, thick, pipe_size) # left self.create_wall(self.left, self.top+pipe_size+spacing, thick, self.height-pipe_size-thick-(spacing*2)) # right self.create_wall(self.right-thick, self.top+thick+spacing, thick, self.height-pipe_size-thick-(spacing*2)) # bottom short self.create_wall(self.right-thick, self.bottom-pipe_size, pipe_size+thick, thick) # bottom long self.create_wall(self.left, self.bottom-thick, self.width+pipe_size, thick) # To create the reactor input: # # self.create_input(x, y) # self.create_input(self.left - (pipe_size / 2.0) - 6.0, # - ReactorParticle.particle_radius, self.top + (pipe_size / 2.0)) # To create the reactor output: # # self.create_output(x, y, size) # self.create_output(self.right+pipe_size, self.bottom-(pipe_size/2.0), 40.0) # Initialize the system with some particles if len(num_particles) > 0: n = 0 for count in num_particles: w = (abs(self.left) + abs(self.right)) grid = MathLib.make_grid(count, w) for (x,y) in grid: self.add_body(ReactorParticle(color=colour.list[n], newton=None, # TODO - fix bug where ode_init called twice when constructing w/ a newton initial_position=(x, y), initial_force=(0,0))) n += 1
def __init__(self, source, sink): Reactor.__init__(self, 0, 0, 0) self.source = source self.sink = sink