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))
def test_without_absorptivity(self): """Perfect mirroring works""" reflective = optics_callables.Reflective(0) self.gm.select_rays(N.arange(4)) outg = reflective(self.gm, self._bund, N.arange(4)) N.testing.assert_array_equal(outg.get_energy(), N.r_[100, 200, 300, 400])
def test_with_absorptivity(self): """A correct bundle is generated by reflective, with energy reduced correctly""" reflective = optics_callables.Reflective(0.1) self.gm.select_rays(N.arange(4)) outg = reflective(self.gm, self._bund, N.arange(4)) correct_pts = N.zeros((3,4)) correct_pts[:2,0] = 1 N.testing.assert_array_equal(outg.get_vertices(), correct_pts) correct_dirs = N.c_[[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1]] / N.sqrt(3) N.testing.assert_array_equal(outg.get_directions(), correct_dirs) N.testing.assert_array_equal(outg.get_energy(), N.r_[90, 180, 270, 360]) N.testing.assert_array_equal(outg.get_parents(), N.arange(4))