Exemplo n.º 1
0
	def trace(self, rph, iters = 10000, minE = 1e-9, render = False):
		"""Commences raytracing using (rph) number of rays per heliostat, for a maximum of 
		   (iters) iterations, discarding rays with energy less than (minE). If render is
		   True, a 3D scene will be displayed which would need to be closed to proceed."""
		# Get the solar vector using azimuth and elevation
		sun_vec = solar_vector(self.sun_az*degree, self.sun_elev*degree)
        	# Calculate number of rays used. Rays per heliostat * number of heliostats.
        	num_rays = rph*len(self.field.get_heliostats())
		self.no_of_rays += num_rays
		# Generates the ray bundle
        	rot_sun = rotation_to_z(-sun_vec)
        	direct = N.dot(rot_sun, pillbox_sunshape_directions(num_rays, 0.00465))
        
        	xy = N.random.uniform(low=-0.25, high=0.25, size=(2, num_rays))
        	base_pos = N.tile(self.pos, (rph, 1)).T #Check if its is rph or num_rays
       		base_pos += N.dot(rot_sun[:,:2], xy)
        	
        	base_pos -= direct
        	rays = RayBundle(base_pos, direct, energy=N.ones(num_rays))

		# Perform the raytracing
		e = TracerEngine(self.plant)
		e.ray_tracer(rays, iters, minE, tree=True)
		e.minener = minE
		rays_in = sum(e.tree._bunds[0].get_energy())
		self.helio_hits = sum(e.tree._bunds[1].get_energy())


		# Optional rendering
		if render == True:
			trace_scene = Renderer(e)
			trace_scene.show_rays()
Exemplo n.º 2
0
    def trace(self):
        """Generate a flux map using much more rays than drawn"""
        # Generate a large ray bundle using a radial stagger much denser
        # than the field.
        sun_vec = solar_vector(self.sun_az * degree, self.sun_elev * degree)

        hstat_rays = 20
        num_rays = hstat_rays * len(self.field.get_heliostats())
        rot_sun = rotation_to_z(-sun_vec)
        direct = N.dot(rot_sun, pillbox_sunshape_directions(num_rays, 0.00465))

        xy = N.random.uniform(low=-0.25, high=0.25, size=(2, num_rays))
        base_pos = N.tile(self.pos, (hstat_rays, 1)).T
        base_pos += N.dot(rot_sun[:, :2], xy)

        base_pos -= direct
        rays = RayBundle(base_pos, direct, energy=N.ones(num_rays))

        # Perform the trace:
        e = TracerEngine(self.plant)
        e.ray_tracer(rays, 100, 0.05, tree=True)
        e.minener = 1e-5

        # Render:
        trace_scene = Renderer(e)
        trace_scene.show_rays()
Exemplo n.º 3
0
    def trace(self):
        """Generate a flux map using much more rays than drawn"""
        # Generate a large ray bundle using a radial stagger much denser
        # than the field.
        sun_vec = solar_vector(self.sun_az*degree, self.sun_elev*degree)
        
        hstat_rays = 20
        num_rays = hstat_rays*len(self.field.get_heliostats())
        rot_sun = rotation_to_z(-sun_vec)
        direct = N.dot(rot_sun, pillbox_sunshape_directions(num_rays, 0.00465))
        
        xy = N.random.uniform(low=-0.25, high=0.25, size=(2, num_rays))
        base_pos = N.tile(self.pos, (hstat_rays, 1)).T
        base_pos += N.dot(rot_sun[:,:2], xy)
        
        base_pos -= direct
        rays = RayBundle(base_pos, direct, energy=N.ones(num_rays))
        
        # Perform the trace:
        e = TracerEngine(self.plant)
        e.ray_tracer(rays, 100, 0.05, tree=True)
        e.minener = 1e-5

		# Render:
        trace_scene = Renderer(e)
        trace_scene.show_rays()
Exemplo n.º 4
0
    def trace(self):
        """Generate a flux map using much more rays than drawn"""
        # Generate a large ray bundle using a radial stagger much denser
        # than the field.
        sun_vec = solar_vector(self.sun_az*degree, self.sun_elev*degree)
        #hstat_rays
        hstat_rays = 1000
        num_rays = hstat_rays*len(self.field.get_heliostats())
        rot_sun = rotation_to_z(-sun_vec)
        direct = N.dot(rot_sun, pillbox_sunshape_directions(num_rays, 0.00465))
        
        xy = N.random.uniform(low=-0.25, high=0.25, size=(2, num_rays))
        base_pos = N.tile(self.pos, (hstat_rays, 1)).T
        base_pos += N.dot(rot_sun[:,:2], xy)
        
        base_pos -= direct
        rays = RayBundle(base_pos, direct, energy=N.ones(num_rays))
        
        # Perform the trace:
        e = TracerEngine(self.plant)
        e.ray_tracer(rays, 100, 0.05, tree=True)
        e.minener = 1e-6 # default 1e-5

	# Render:
        #trace_scene = Renderer(e)
        #trace_scene.show_rays()

        # Initialise a histogram of hits:
        energy, pts = self.reclist.get_optics_manager().get_all_hits()
        x, y = self.reclist.global_to_local(pts)[:2]
        rngx = 0.55 #0.5
        rngy = 0.55 #0.5
        
        bins = 100 #50
        H, xbins, ybins = N.histogram2d(x, y, bins, \
            range=([-rngx,rngx], [-rngy,rngy]), weights=energy)
        
        #print(H, xbins, ybins)
        total=N.sum(H)
        print(total)

        extent = [ybins[0], ybins[-1], xbins[-1], xbins[0]]
        plt.imshow(H, extent=extent, interpolation='nearest')
        plt.colorbar()
	plt.title("front")
        plt.show()
Exemplo n.º 5
0
	def traceMP(self, rays_per_run, iters = 10000, minE = 1e-9, render = False,procs = 1):
		"""Commences raytracing using (rph) number of rays per heliostat, for a maximum of 
		   (iters) iterations, discarding rays with energy less than (minE). If render is
		   True, a 3D scene will be displayed which would need to be closed to proceed."""
		# Get the solar vector using azimuth and elevation
		sun_vec = solar_vector(self.sun_az*degree, self.sun_elev*degree)
		rot_sun = rotation_to_z(-sun_vec)
        	# Calculate number of rays used. Rays per heliostat * number of heliostats.
		rppph = int(rays_per_run/(procs*len(self.field.get_heliostats())))
		rpp = rppph*len(self.field.get_heliostats())
		rpr = rpp*procs					#actual rays per run used

		ray_sources = []
		n = 1
		while n <= procs:
			direct = N.dot(rot_sun, pillbox_sunshape_directions(rpp, 0.00465))
			xy = N.random.uniform(low=-0.25, high=0.25, size=(2, rpp))
        		base_pos = N.tile(self.pos, (rppph, 1)).T
        		base_pos += N.dot(rot_sun[:,:2], xy)

        		base_pos -= direct
        		rays = RayBundle(base_pos, direct, energy=N.ones(rpp))
			ray_sources.append(rays)
			n += 1

		e = TracerEngineMP(self.plant)
		e.multi_ray_sim(ray_sources,procs)
		self.plant = e._asm
		self.helio_hits = sum(e.tree._bunds[1].get_energy())
			# Note that you may need some stuff in here
		if render == True:
			trace_scene = Renderer(e)
			trace_scene.show_rays(resolution=10)
			render = False

		return rpr #this is special
Exemplo n.º 6
0
 def _fmap_btn_fired(self):
     """Generate a flux map using much more rays than drawn"""
     # Generate a large ray bundle using a radial stagger much denser
     # than the field.
     sun_vec = solar_vector(self.sun_az*degree, self.sun_elev*degree)
     
     hstat_rays = 1000
     num_rays = hstat_rays*len(self.field.get_heliostats())
     rot_sun = rotation_to_z(-sun_vec)
     direct = N.dot(rot_sun, pillbox_sunshape_directions(num_rays, 0.00465))
     
     xy = N.random.uniform(low=-0.25, high=0.25, size=(2, num_rays))
     base_pos = N.tile(self.pos, (hstat_rays, 1)).T
     base_pos += N.dot(rot_sun[:,:2], xy)
     
     base_pos -= direct
     rays = RayBundle(base_pos, direct, energy=N.ones(num_rays))
     
     # Perform the trace:
     self.rec.get_optics_manager().reset()
     e = TracerEngine(self.plant)
     e.ray_tracer(rays, 1000, 0.05)
     
     # Show a histogram of hits:
     energy, pts = self.rec.get_optics_manager().get_all_hits()
     x, y = self.rec.global_to_local(pts)[:2]
     rngx = 0.5
     rngy = 0.5
     
     bins = 50
     H, xbins, ybins = N.histogram2d(x, y, bins, \
         range=([-rngx,rngx], [-rngy,rngy]), weights=energy)
     
     self.fmap.axes[0].images=[]
     self.fmap.axes[0].imshow(H, aspect='auto')
     wx.CallAfter(self.fmap.canvas.draw)