def gen_rays(self, num_rays, flux=1000.):
		#========================
		individual_source = True
		#========================

		if individual_source:
			# Pillbox source on a per-heliostat basis
			radius = 1.20 * math.sqrt(2 * 3.405**2)

			direction = N.array(-self.sun_vec)

			ray_list = []
			num_surfs = self.pos.shape[0]
			for i in xrange(num_surfs):
				centre = N.c_[50 * self.sun_vec + self.pos[i]]
				rayb = solar_disk_bundle(num_rays/num_surfs, centre, direction, radius, 4.65e-3, flux)
				ray_list.append(rayb)

			rays = concatenate_rays(ray_list)
			del ray_list
			
		else:
			# Large pillbox sunshape source disc source covering entire field area:
			radius = 1.10 * math.sqrt((self.x_dist/2)**2 + (self.y_dist/2)**2)

			self.source_area = N.pi * radius**2

			centre = N.c_[300*self.sun_vec + self.field_centre]
			direction = N.array(-self.sun_vec)

			rays = solar_disk_bundle(num_rays, centre, direction, radius, 4.65e-3, flux)
				
		return rays
    def test_rotation(self):
        dir = N.array([0., 0, 1])
        center = N.array([0, 0, 0]).reshape(-1, 1)
        R = 2

        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)

        dir = 1 / math.sqrt(3) * N.ones(3)
        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)
Example #3
0
    def test_location(self):
        dir = N.array([0., 0, 1])
        center = N.array([0, 0, 0]).reshape(-1, 1)
        R = 2

        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)

        center = N.array([7, 7, 7]).reshape(-1, 1)
        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)
Example #4
0
    def test_rotation(self):
        dir = N.array([0., 0, 1])
        center = N.array([0, 0, 0]).reshape(-1, 1)
        R = 2

        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)

        dir = 1 / math.sqrt(3) * N.ones(3)
        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)
    def test_location(self):
        dir = N.array([0., 0, 1])
        center = N.array([0, 0, 0]).reshape(-1, 1)
        R = 2

        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)

        center = N.array([7, 7, 7]).reshape(-1, 1)
        rays = solar_disk_bundle(1000, center, dir, R, N.pi / 100.)
        self.assert_radius(rays.get_vertices(), center, R)
    def create_dish_source(self):
        """
        Creates the two basic elements of this simulation: the parabolic dish,
        and the pillbox-sunshape ray bundle. Uses the variables set by 
        TraitsUI.
        """
	diameter=26.3
	f = diameter/4./(N.sqrt(2) - 1)
	receiver_pos=15.8
	concent=2100.
        dish, f, H = petal_dish(diameter, receiver_pos, self.receiver_side, self.refl, concent, 1.)
	print(f,'f')
	

	for surf in dish.get_surfaces():
            surf.colour = (1., 0., 0.)
        dish.get_main_reflector().colour = (0., 0., 1.)
	theta=0.
    	alpha=0.#print(self.receiver_pos)
	x=-N.cos(theta)*N.sin(alpha)
	y=-N.sin(theta)*N.sin(alpha)
	z=-N.cos(alpha)
	# the transformation matrix needs to be a 4*4 rotational matric
        source = solar_disk_bundle(self.disp_num_rays, N.c_[[0., 0., f + H ]], N.r_[x,y,z], diameter/2, 0.00467)
#solar_disk_bundle(num_rays,  center,  direction,  radius, ang_range, flux=None, radius_in=0., angular_span=[0.,2.*N.pi]):) N.r_ must be a unit vector
	#source = solar_disk_bundle(self.disp_num_rays, N.c_[[0., 0., f + H + 0.5]], N.r_[0., 0., -1.], 0.5, 0.197)
	# what is this 0.5 here
	#print(source,'source')
        source.set_energy(N.ones(self.disp_num_rays)*1000.*N.pi*diameter**2*0.25/float(self.disp_num_rays) )# gives intensity value which is the inverse of the number of solar arrays
        self.dish=dish
        return dish, source
Example #7
0
def test_case(focus, num_rays=100, h_depth=0.7, side=0.4):
    # Case parameters (to be moved out:
    D = 5.
    
    center = N.c_[[0, 7., 7.]]
    x = -1/(math.sqrt(2))
    direction = N.array([0,x,x])
    radius_sun = 2.5 
    ang_range = 0.005
    
    iterate = 100
    min_energy = 1e-6
    
    # Model:
    assembly = MiniDish(D, focus, 0.9, focus + h_depth, side, h_depth, 0.9)
    assembly.set_transform(rotx(-N.pi/4))
    
    # Rays:
    sun = solar_disk_bundle(num_rays, center, direction, radius_sun, ang_range,
        flux=1000.)
    
    # Do the tracing:
    engine = TracerEngine(assembly)
    engine.ray_tracer(sun, iterate, min_energy)
    
    # Plot, scale in suns:
    f = plot_hits(assembly.histogram_hits()[0]/(side/50)**2/1000., (-side/2., side/2., -side/2., side/2.))
    f.show()
Example #8
0
    def create_dish_source(self):
        """
        Creates the two basic elements of this simulation: the parabolic dish,
        and the pillbox-sunshape ray bundle. Uses the variables set by 
        TraitsUI.
        """
        dish, f, H = petal_dish(1.0, self.receiver_pos, self.receiver_side, self.refl, 1.0)
        print(f, "f")
        # receiver=TwoNparamcav([0.22], [0.75], [0.2], 1., 0.04, 0.9, 0.2, 0.6, 0.23, None, False)
        # receiver_surf=Surface(receiver, opt.LambertianReceiver(0.9))
        # recv = AssembledObject(surfs=[receiver_surf])
        # self._assemblies=Assembly(objects=[dish], subassemblies=[recv])
        # petal_dish(self, diameter, receiver_pos, receiver_side, dish_opt_eff,\
        # receiver_aspect=1.)
        # Add GUI annotations to the dish assembly:
        # for surf in dish.get_homogenizer().get_surfaces():
        for surf in dish.get_surfaces():
            surf.colour = (1.0, 0.0, 0.0)
        dish.get_main_reflector().colour = (0.0, 0.0, 1.0)
        theta = 0
        alpha = 0.1  # print(self.receiver_pos) alpha angle is of more significance
        x = -N.cos(theta) * N.sin(alpha)
        y = -N.sin(theta) * N.sin(alpha)
        z = -N.cos(alpha)
        # the transformation matrix needs to be a 4*4 rotational matric
        source = solar_disk_bundle(self.disp_num_rays, N.c_[[0.0, 0.0, f + H]], N.r_[x, y, z], 0.5, 0.00467)
        # solar_disk_bundle(num_rays,  center,  direction,  radius, ang_range, flux=None, radius_in=0., angular_span=[0.,2.*N.pi]):) N.r_ must be a unit vector
        # source = solar_disk_bundle(self.disp_num_rays, N.c_[[0., 0., f + H + 0.5]], N.r_[0., 0., -1.], 0.5, 0.197)
        # what is this 0.5 here
        # print(source,'source')
        source.set_energy(
            N.ones(self.disp_num_rays) * 1000.0 / float(self.disp_num_rays)
        )  # gives intensity value which is the inverse of the number of solar arrays

        return dish, source
Example #9
0
def test_case(focus, num_rays=100, h_depth=0.7, side=0.4):
	# Case parameters:
	D = 5.
	
	center = N.c_[[0, 7., 7.]]
	x = -1/(math.sqrt(2))
	direction = N.array([0,x,x])
	radius_sun = 3. 
	ang_range = 0.005
	
	iterate = 100
	min_energy = 1e-6
	
	# Model:
	assembly = MiniDish(D, focus, 0.9, focus + h_depth, side, h_depth, 0.9)
	assembly.set_transform(rotx(-N.pi/4))
	
	# Rays:
	sun = solar_disk_bundle(num_rays, center, direction, radius_sun, ang_range,
		flux=1000.)
	
	# Do the tracing:
	engine = TracerEngine(assembly)
	engine.ray_tracer(sun, iterate, min_energy)

	resolution = 20
 
	# Render a subset of the total rays:
	v = R(engine)
	v.show_rays(max_rays=100, resolution=resolution, fluxmap=True)	

	# Plot, scale in suns:
	f = plot_hits(assembly.histogram_hits(bins=resolution)[0]/(side/resolution)**2/1000., (-side/2., side/2., -side/2., side/2.))
	f.show()
Example #10
0
    def test_energy(self):
        """When flux is given, the solar disk bundle has proper energy"""
        dir = N.array([0., 0, 1])
        center = N.array([0,  0, 0]).reshape(-1, 1)
        R = 2; theta_max = N.pi/100.

        rays = solar_disk_bundle(5000, center, dir, R, theta_max, flux=1000.)
        N.testing.assert_array_equal(rays.get_energy(), N.pi*4/5.)
Example #11
0
    def test_energy(self):
        """When flux is given, the solar disk bundle has proper energy"""
        dir = N.array([0., 0, 1])
        center = N.array([0, 0, 0]).reshape(-1, 1)
        R = 2
        theta_max = N.pi / 100.

        rays = solar_disk_bundle(5000, center, dir, R, theta_max, flux=1000.)
        N.testing.assert_array_equal(rays.get_energy(), N.pi * 4 / 5.)
Example #12
0
 def test_directions_rotated(self):
     """Ray directions OK when the bundle directions isn't on one of the axes"""
     dir = N.array([0., N.sqrt(2), N.sqrt(2)])/2.
     center = N.c_[[0,  0, 0]]
     R = 2; theta_max = N.pi/100.
     
     rays = solar_disk_bundle(5000, center, dir, R, theta_max)
     directs = rays.get_directions()
     dir_dots = N.dot(dir, directs)
     self.failUnless((dir_dots >= N.cos(theta_max)).all())
Example #13
0
    def test_directions_rotated(self):
        """Ray directions OK when the bundle directions isn't on one of the axes"""
        dir = N.array([0., N.sqrt(2), N.sqrt(2)]) / 2.
        center = N.c_[[0, 0, 0]]
        R = 2
        theta_max = N.pi / 100.

        rays = solar_disk_bundle(5000, center, dir, R, theta_max)
        directs = rays.get_directions()
        dir_dots = N.dot(dir, directs)
        self.failUnless((dir_dots >= N.cos(theta_max)).all())
    def gen_rays(self, num_rays, flux=1000.):
        #========================
        individual_source = True
        #========================

        if individual_source:
            # Pillbox source on a per-heliostat basis
            radius = 1.20 * math.sqrt(2 * 3.405**2)

            direction = N.array(-self.sun_vec)

            ray_list = []
            num_surfs = self.pos.shape[0]
            for i in xrange(num_surfs):
                centre = N.c_[50 * self.sun_vec + self.pos[i]]
                rayb = solar_disk_bundle(num_rays / num_surfs, centre,
                                         direction, radius, 4.65e-3, flux)
                ray_list.append(rayb)

            rays = concatenate_rays(ray_list)
            del ray_list

        else:
            # Large pillbox sunshape source disc source covering entire field area:
            radius = 1.10 * math.sqrt((self.x_dist / 2)**2 +
                                      (self.y_dist / 2)**2)

            self.source_area = N.pi * radius**2

            centre = N.c_[300 * self.sun_vec + self.field_centre]
            direction = N.array(-self.sun_vec)

            rays = solar_disk_bundle(num_rays, centre, direction, radius,
                                     4.65e-3, flux)

        return rays
Example #15
0
    def create_dish_source(self):
        """
        Creates the two basic elements of this simulation: the parabolic dish,
        and the pillbox-sunshape ray bundle. Uses the variables set by 
        TraitsUI.
        """
        dish, f, W, H = standard_minidish(1., self.concent, self.refl, 1., 1.)
        # Add GUI annotations to the dish assembly:
        for surf in dish.get_homogenizer().get_surfaces():
            surf.colour = (1., 0., 0.)
        dish.get_main_reflector().colour = (0., 0., 1.)

        source = solar_disk_bundle(self.disp_num_rays,
            N.c_[[0., 0., f + H + 0.5]], N.r_[0., 0., -1.], 0.5, 0.00465)
        source.set_energy(N.ones(self.disp_num_rays)*1000./self.disp_num_rays)
        
        return dish, source
Example #16
0
    def create_dish_source(self):
        """
        Creates the two basic elements of this simulation: the parabolic dish,
        and the pillbox-sunshape ray bundle. Uses the variables set by 
        TraitsUI.
        """
        dish, f, W, H = standard_minidish(1., self.concent, self.refl, 1., 1.)
        # Add GUI annotations to the dish assembly:
        for surf in dish.get_homogenizer().get_surfaces():
            surf.colour = (1., 0., 0.)
        dish.get_main_reflector().colour = (0., 0., 1.)

        source = solar_disk_bundle(self.disp_num_rays,
            N.c_[[0., 0., f + H + 0.5]], N.r_[0., 0., -1.], 0.5, 0.00465)
        source.set_energy(N.ones(self.disp_num_rays)*1000./self.disp_num_rays)
        
        return dish, source
Example #17
0
 def test_ray_directions(self):
     """Test that the angle between the rays and the bundle direction is uniformly
     spaced, and that the rays are rotated around the bundle direction at uniformly
     distributed angles.
     """
     dir = N.array([0., 0, 1])
     center = N.array([0,  0, 0]).reshape(-1, 1) 
     R = 2; theta_max = N.pi/100.
     
     rays = solar_disk_bundle(5000, center, dir, R, theta_max)
     directs = rays.get_directions()
     dir_dots = N.dot(dir, directs)
     self.failUnless((dir_dots >= N.cos(theta_max)).all())
     
     on_disk_plane = directs - N.outer(dir, dir_dots)
     angs = N.arctan2(on_disk_plane[0], on_disk_plane[1])
     self.assert_uniform(angs, lb=-N.pi, ub=N.pi)
Example #18
0
    def test_ray_directions(self):
        """Test that the angle between the rays and the bundle direction is uniformly
        spaced, and that the rays are rotated around the bundle direction at uniformly
        distributed angles.
        """
        dir = N.array([0., 0, 1])
        center = N.array([0, 0, 0]).reshape(-1, 1)
        R = 2
        theta_max = N.pi / 100.

        rays = solar_disk_bundle(5000, center, dir, R, theta_max)
        directs = rays.get_directions()
        dir_dots = N.dot(dir, directs)
        self.failUnless((dir_dots >= N.cos(theta_max)).all())

        on_disk_plane = directs - N.outer(dir, dir_dots)
        angs = N.arctan2(on_disk_plane[0], on_disk_plane[1])
        self.assert_uniform(angs, lb=-N.pi, ub=N.pi)
Example #19
0
    def gen_rays(self, rays):
        sun_vec = solar_vector(self.azimuth, self.zenith)
        source_centre = N.array([[self.field_centroid[0] + 200.0 * sun_vec[0]],
                                 [self.field_centroid[1] + 200. * sun_vec[1]],
                                 [self.field_centroid[2] + 200.0 * sun_vec[2]]
                                 ])
        #print(self.field_centroid + (500.0*sun_vec))

        #print(sun_vec_array)
        self.DNI = 1000.0
        self.rays = rays
        #self.raybundle = buie_sunshape(self.rays, source_centre, -1.0*sun_vec, 165.0, 0.0225, flux=self.DNI)
        self.raybundle = solar_disk_bundle(self.rays,
                                           source_centre,
                                           -1.0 * sun_vec,
                                           self.field_radius,
                                           4.65e-3,
                                           flux=self.DNI)
        #print(self.DNI, sum(self.raybundle.get_energy()))
        return rays