Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
0
class TestMiniDish(unittest.TestCase):
    def setUp(self):
        """Create a basic minidish assembly to abuse"""
        self.md = MiniDish(5, 5, 0.9, 5.7, .4, 0.7, 0.9)
        self.e = tracer.tracer_engine.TracerEngine(self.md)

        pos = N.zeros((3, 5))
        pos[0] = N.r_[-2:2:5j]
        pos[2] = 6.
        self.pos = pos

        dir = N.zeros((3, 5))
        dir[2] = -1.
        self.dir = dir

    def test_upright(self):
        """Dish without rotation"""
        bund = tracer.ray_bundle.RayBundle()

        bund.set_vertices(self.pos)
        bund.set_directions(self.dir)

        bund.set_energy(N.ones(5) * 100)
        bund.set_ref_index(N.ones(5))

        self.e.ray_tracer(bund, 1776, 0.05)

        receiver = self.md.get_receiver_surf()
        energy, pts = receiver.get_optics_manager().get_all_hits()
        x, y = receiver.global_to_local(pts)[:2]

        self.failUnless(N.allclose(y, 0))
        N.testing.assert_array_equal(energy, N.r_[90., 90., 81., 81.])

    def test_rotated(self):
        """Dish with rotation"""
        bund = tracer.ray_bundle.RayBundle()

        rot = roty(N.pi / 4)
        self.md.set_transform(rot)
        bund.set_vertices(N.dot(rot[:3, :3], self.pos))
        bund.set_directions(N.dot(rot[:3, :3], self.dir))

        bund.set_energy(N.ones(5) * 100)
        bund.set_ref_index(N.ones(5))

        self.e.ray_tracer(bund, 1776, 0.05)

        receiver = self.md.get_receiver_surf()
        energy, pts = receiver.get_optics_manager().get_all_hits()
        x, y = receiver.global_to_local(pts)[:2]

        self.failUnless(N.allclose(y, 0))
        N.testing.assert_array_equal(energy, N.r_[90., 90., 81., 81.])
Esempio n. 4
0
class TestMiniDish(unittest.TestCase):
    def setUp(self):
        """Create a basic minidish assembly to abuse"""
        self.md = MiniDish(5, 5, 0.9, 5.7, .4, 0.7, 0.9)
        self.e = tracer.tracer_engine.TracerEngine(self.md)
        
        pos = N.zeros((3, 5))
        pos[0] = N.r_[-2:2:5j]
        pos[2] = 6.
        self.pos = pos

        dir = N.zeros((3, 5))
        dir[2] = -1.
        self.dir = dir
        
    def test_upright(self):
        """Dish without rotation"""
        bund = tracer.ray_bundle.RayBundle()
        
        bund.set_vertices(self.pos)
        bund.set_directions(self.dir)
        
        bund.set_energy(N.ones(5)*100)
        bund.set_ref_index(N.ones(5))
        
        self.e.ray_tracer(bund, 1776, 0.05)
        
        receiver = self.md.get_receiver_surf()
        energy, pts = receiver.get_optics_manager().get_all_hits()
        x, y = receiver.global_to_local(pts)[:2]
        
        self.failUnless(N.allclose(y, 0))
        N.testing.assert_array_equal(energy, N.r_[90., 90., 81., 81.])
    
    def test_rotated(self):
        """Dish with rotation"""
        bund = tracer.ray_bundle.RayBundle()
        
        rot = roty(N.pi/4)
        self.md.set_transform(rot)
        bund.set_vertices(N.dot(rot[:3,:3], self.pos))
        bund.set_directions(N.dot(rot[:3,:3], self.dir))
        
        bund.set_energy(N.ones(5)*100)
        bund.set_ref_index(N.ones(5))
        
        self.e.ray_tracer(bund, 1776, 0.05)
        
        receiver = self.md.get_receiver_surf()
        energy, pts = receiver.get_optics_manager().get_all_hits()
        x, y = receiver.global_to_local(pts)[:2]
        
        self.failUnless(N.allclose(y, 0))
        N.testing.assert_array_equal(energy, N.r_[90., 90., 81., 81.])