Exemplo n.º 1
0
 def test_mesh(self):
     """Correct mesh for rect-plate"""
     r = RectPlateGM(5, 6)
     res = 10
     x, y, z = r.mesh(res)
     
     rx = N.linspace(-2.5, 2.5, res*5)
     ry = N.linspace(-3, 3, res*6)
     cx, cy = N.broadcast_arrays(rx[:,None], ry)
     
     N.testing.assert_array_equal(x, cx)
     N.testing.assert_array_equal(y, cy)
     N.testing.assert_array_equal(z, N.zeros_like(x))
Exemplo n.º 2
0
	def test_mesh(self):
		"""Correct mesh for rect-plate"""
		r = RectPlateGM(5, 6)
		res = 10
		x, y, z = r.mesh(res)
		
		rx = N.linspace(-2.5, 2.5, res+1)
		ry = N.linspace(-3, 3, res+1)
		cx, cy = N.broadcast_arrays(rx[:,None], ry)		

		N.testing.assert_array_equal(x, cx)
		N.testing.assert_array_equal(y, cy)
		N.testing.assert_array_equal(z, N.zeros_like(x))
Exemplo n.º 3
0
    def setUp(self):
        absorptive = Surface(RectPlateGM(1., 1.),
                             opt.Reflective(1.),
                             location=N.r_[0.5, 0., 1.])
        reflective = Surface(RectPlateGM(1., 1.),
                             opt.Reflective(0.),
                             location=N.r_[-0.5, 0., 1.])
        self.assembly = Assembly(
            objects=[AssembledObject(surfs=[absorptive, reflective])])

        # 4 rays: two toward absorptive, two toward reflective.
        pos = N.zeros((3, 4))
        pos[0] = N.r_[0.5, 0.25, -0.25, -0.5]
        direct = N.zeros((3, 4))
        direct[2] = 1.
        self.bund = RayBundle(pos, direct, energy=N.ones(4))
Exemplo n.º 4
0
	def test_selection(self):
		pos = N.zeros((3,4))
		pos[0] = N.r_[0, 0.5, 2, -2]
		pos[2] = 1.
		dir = N.tile(N.c_[[0,0,-1]], (1,4))
		bund = RayBundle(pos, dir)
		
		surf = Surface(RectPlateGM(1, 0.25), opt.perfect_mirror)
		misses = N.isinf(surf.register_incoming(bund))
		
		N.testing.assert_array_equal(misses, N.r_[False, False, True, True])
Exemplo n.º 5
0
def two_sided_receiver(width, height, absorptivity=1., location=None):
    """
	Constructs a receiver centred at a location and parallel to the xz plane
	
	Arguments:
	width - the extent along the x axis in the local frame.
	height - the extent along the y axis in the local frame.
	absorptivity - the ratio of energy incident on the reflective side that's
		not reflected back.
	
	Returns:
	front - the receiving surface
	obj - the AssembledObject containing both surfaces
	"""
    front = Surface(RectPlateGM(height, width),
                    ReflectiveReceiver(absorptivity),
                    location,
                    rotation=rotation_matrix(N.pi / 2.0, 0.0, 0.0))
    obj = AssembledObject(surfs=[front])
    return front, obj