コード例 #1
0
ファイル: test_objects.py プロジェクト: pcacunar/Tracer
    def setUp(self):
        self.assembly = Assembly()

        surface1 = Surface(flat_surface.FlatGeometryManager(),
                           optics_callables.RefractiveHomogenous(1., 1.5),
                           location=N.array([0, 0, -1.]))
        surface2 = Surface(flat_surface.FlatGeometryManager(),
                           optics_callables.RefractiveHomogenous(1., 1.5),
                           location=N.array([0, 0, 1.]))

        self.object1 = AssembledObject()
        self.object1.add_surface(surface1)
        self.object1.add_surface(surface2)

        boundary = BoundarySphere(location=N.r_[0, 0., 3], radius=3.)
        surface3 = Surface(CutSphereGM(2., boundary),
                           optics_callables.perfect_mirror)
        self.object2 = AssembledObject()
        self.object2.add_surface(surface3)

        self.transform = generate_transform(N.r_[1, 0., 0], 0.,
                                            N.c_[[0., 0, 2]])
        self.assembly.add_object(self.object1)
        self.assembly.add_object(self.object2, self.transform)

        x = 1. / (math.sqrt(2))
        dir = N.c_[[0, 1., 0.], [0, x, x], [0, 0, 1.]]
        position = N.c_[[0, 0, 2.], [0, 0, 2.], [0, 0., 2.]]
        self._bund = RayBundle(position,
                               dir,
                               energy=N.ones(3),
                               ref_index=N.ones(3))
コード例 #2
0
ファイル: test_tracer_tree.py プロジェクト: kraken22/Tracer
    def setUp(self):
        self.assembly = Assembly()

        surface1 = Surface(FlatGeometryManager(),
                           opt.RefractiveHomogenous(1., 1.5),
                           location=N.array([0, 0, -1.]))
        surface2 = Surface(FlatGeometryManager(),
                           opt.RefractiveHomogenous(1., 1.5),
                           location=N.array([0, 0, 1.]))
        object1 = AssembledObject(surfs=[surface1, surface2])

        boundary = BoundarySphere(location=N.r_[0, 0., 3], radius=3.)
        surface3 = Surface(CutSphereGM(2., boundary), opt.perfect_mirror)
        object2 = AssembledObject(surfs=[surface3],
                                  transform=translate(0., 0., 2.))

        self.assembly = Assembly(objects=[object1, object2])

        x = 1. / (math.sqrt(2))
        dir = N.c_[[0, 1., 0.], [0, x, x], [0, 0, 1.]]
        position = N.c_[[0, 0, 2.], [0, 0, 2.], [0, 0., 2.]]
        self._bund = RayBundle(position,
                               dir,
                               ref_index=N.ones(3),
                               energy=N.ones(3))

        self.engine = TracerEngine(self.assembly)
コード例 #3
0
    def setUp(self):
        surface1 = Surface(HemisphereGM(2.),
                           opt.perfect_mirror,
                           rotation=general_axis_rotation(
                               N.r_[1, 0, 0], N.pi / 2.))
        surface2 = Surface(HemisphereGM(2.),
                           opt.perfect_mirror,
                           location=N.array([0, -2, 0]),
                           rotation=general_axis_rotation(
                               N.r_[1, 0, 0], -N.pi / 2.))

        self._bund = RayBundle()
        self._bund.set_directions(N.c_[[0, 1, 0]])
        self._bund.set_vertices(N.c_[[0, -1, 0]])
        self._bund.set_energy(N.r_[[1]])
        self._bund.set_ref_index(N.r_[[1]])

        assembly = Assembly()
        object1 = AssembledObject()
        object2 = AssembledObject()
        object1.add_surface(surface1)
        object2.add_surface(surface2)
        assembly.add_object(object1)
        assembly.add_object(object2)

        self.engine = TracerEngine(assembly)
コード例 #4
0
ファイル: test_tracer_tree.py プロジェクト: kraken22/Tracer
    def setUp(self):
        self.assembly = Assembly()

        surface1 = Surface(FlatGeometryManager(), opt.perfect_mirror)
        self.object1 = AssembledObject()
        self.object1.add_surface(surface1)

        boundary = BoundarySphere(location=N.r_[0, 0., 3], radius=3.)
        surface3 = Surface(CutSphereGM(2., boundary), opt.perfect_mirror)
        self.object2 = AssembledObject()
        self.object2.add_surface(surface3)

        self.transform1 = generate_transform(N.r_[1., 0, 0], N.pi / 4,
                                             N.c_[[0, 0, -1.]])
        self.transform2 = translate(0., 0., 2.)
        self.assembly.add_object(self.object1, self.transform1)
        self.assembly.add_object(self.object2, self.transform2)
コード例 #5
0
    def setUp(self):
        dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]
                       ]).T / math.sqrt(3)
        position = N.c_[[0, 0, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]]
        self._bund = RayBundle(position, dir, energy=N.ones(4))

        self.assembly = Assembly()
        object = AssembledObject()
        object.add_surface(Surface(FlatGeometryManager(), opt.perfect_mirror))
        self.assembly.add_object(object)
        self.engine = TracerEngine(self.assembly)
コード例 #6
0
ファイル: test_objects.py プロジェクト: pcacunar/Tracer
    def setUp(self):
        self.eighth_circle_trans = generate_transform(N.r_[1., 0, 0], N.pi / 4,
                                                      N.c_[[0., 1, 0]])

        self.surf = Surface(flat_surface.FlatGeometryManager(), \
            optics_callables.perfect_mirror)
        self.obj = AssembledObject(surfs=[self.surf])
        self.sub_assembly = Assembly()
        self.sub_assembly.add_object(self.obj, self.eighth_circle_trans)
        self.assembly = Assembly()
        self.assembly.add_assembly(self.sub_assembly, self.eighth_circle_trans)
コード例 #7
0
    def setUp(self):
        """
        Prepare an assembly with two subassemblies: one assembly representing
        a spherical lens behind a flat screen, and one asssembly representing a
        perfect mirror.
        The mirror will be placed at the two subassemblies' focus, so a paraxial
        ray will come back on the other side of the optical axis.
        
        Reference:
        In [1], the lensmaker equation
        """
        # focal length = 1, thickness = 1/6
        R = 1. / 6.
        back_surf = Surface(HemisphereGM(R),
                            opt.RefractiveHomogenous(1., 1.5),
                            location=N.r_[0., 0., -R / 2.])
        front_surf = Surface(HemisphereGM(R),
                             opt.RefractiveHomogenous(1., 1.5),
                             location=N.r_[0., 0., R / 2.],
                             rotation=rotx(N.pi / 2.)[:3, :3])

        front_lens = AssembledObject(surfs=[back_surf, front_surf])

        back_surf = Surface(RoundPlateGM(R),
                            opt.RefractiveHomogenous(1., 1.5),
                            location=N.r_[0., 0., -0.01])
        front_surf = Surface(RoundPlateGM(R),
                             opt.RefractiveHomogenous(1., 1.5),
                             location=N.r_[0., 0., 0.01])

        glass_screen = AssembledObject(surfs=[back_surf, front_surf],
                                       transform=translate(0., 0., 0.5))

        lens_assembly = Assembly(objects=[glass_screen, front_lens])
        lens_assembly.set_transform(translate(0., 0., 1.))
        full_assembly = Assembly(objects=[rect_one_sided_mirror(1., 1., 0.)],
                                 subassemblies=[lens_assembly])

        self.engine = TracerEngine(full_assembly)
コード例 #8
0
ファイル: test_objects.py プロジェクト: pcacunar/Tracer
    def setUp(self):
        self.assembly = Assembly()
        surface1 = Surface(Paraboloid(), optics_callables.perfect_mirror)
        self.object = AssembledObject()
        self.object.add_surface(surface1)
        self.assembly.add_object(self.object)

        x = 1. / (math.sqrt(2))
        dir = N.c_[[0, 0, -1.], [0, x, -x]]
        position = N.c_[[0, 0, 1.], [0, 0, 1.]]
        self._bund = RayBundle(position,
                               dir,
                               energy=N.ones(2),
                               ref_index=N.ones(2))
コード例 #9
0
    def setUp(self):
        surface = Surface(HemisphereGM(1.),
                          opt.perfect_mirror,
                          rotation=general_axis_rotation(N.r_[1, 0, 0], N.pi))
        self._bund = RayBundle(energy=N.ones(3))
        self._bund.set_directions(N.c_[[0, 1, 0], [0, 1, 0], [0, -1, 0]])
        self._bund.set_vertices(N.c_[[0, -2., 0.001], [0, 0, 0.001],
                                     [0, 2, 0.001]])

        assembly = Assembly()
        object = AssembledObject()
        object.add_surface(surface)
        assembly.add_object(object)

        self.engine = TracerEngine(assembly)
コード例 #10
0
ファイル: test_tracer_tree.py プロジェクト: kraken22/Tracer
    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))
コード例 #11
0
    def setUp(self):

        self.x = 1 / (math.sqrt(2))
        dir = N.c_[[0, -self.x, self.x], [0, 0, -1]]
        position = N.c_[[0, 2, 1], [0, 2, 1]]
        self._bund = RayBundle(position, dir, energy=N.ones(2))

        rot1 = general_axis_rotation([1, 0, 0], N.pi / 4)
        surf1 = Surface(FlatGeometryManager(),
                        opt.perfect_mirror,
                        rotation=rot1)
        surf2 = Surface(FlatGeometryManager(), opt.perfect_mirror)
        assembly = Assembly()
        object = AssembledObject()
        object.add_surface(surf1)
        object.add_surface(surf2)
        assembly.add_object(object)

        self.engine = TracerEngine(assembly)
コード例 #12
0
ファイル: test_objects.py プロジェクト: pcacunar/Tracer
    def setUp(self):
        self.assembly = Assembly()
        surface1 = Surface(flat_surface.FlatGeometryManager(),
                           optics_callables.RefractiveHomogenous(1., 1.5),
                           location=N.array([0, 0, -1.]))
        surface2 = Surface(flat_surface.FlatGeometryManager(),
                           optics_callables.RefractiveHomogenous(1.5, 1.),
                           location=N.array([0, 0, 1.]))

        self.object = AssembledObject(surfs=[surface1, surface2])
        self.assembly.add_object(self.object)

        x = 1 / (math.sqrt(2))
        dir = N.c_[[0, -x, x]]
        position = N.c_[[0, 1, -2.]]
        self._bund = RayBundle(position,
                               dir,
                               energy=N.r_[1.],
                               ref_index=N.r_[1.])
コード例 #13
0
ファイル: test_objects.py プロジェクト: pcacunar/Tracer
    def setUp(self):
        self.assembly = Assembly()
        surface1 = Surface(HemisphereGM(3.),
                           optics_callables.perfect_mirror,
                           location=N.array([0, 0, -1.]),
                           rotation=general_axis_rotation(N.r_[1, 0, 0], N.pi))
        surface2 = Surface(HemisphereGM(3.),
                           optics_callables.perfect_mirror,
                           location=N.array([0, 0, 1.]))

        self.object = AssembledObject()
        self.object.add_surface(surface1)
        self.object.add_surface(surface2)
        self.assembly.add_object(self.object)

        dir = N.c_[[0, 0, 1.], [0, 0, 1.]]
        position = N.c_[[0, 0, -3.], [0, 0, -1.]]

        self._bund = RayBundle(position, dir, energy=N.ones(2))
コード例 #14
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
コード例 #15
0
    def test_intersect_ray2(self):
        rot = general_axis_rotation([1, 0, 0], N.pi / 4)
        surface = Surface(FlatGeometryManager(),
                          opt.perfect_mirror,
                          rotation=rot)
        assembly = Assembly()
        object = AssembledObject()
        object.add_surface(surface)
        assembly.add_object(object)

        engine = TracerEngine(assembly)
        surfaces = assembly.get_surfaces()
        objects = assembly.get_objects()
        surfs_per_obj = [len(obj.get_surfaces()) for obj in objects]
        surf_ownership = N.repeat(N.arange(len(objects)), surfs_per_obj)
        ray_ownership = -1 * N.ones(self._bund.get_num_rays())
        surfs_relevancy = N.ones((len(surfaces), self._bund.get_num_rays()),
                                 dtype=N.bool)

        params = engine.intersect_ray(self._bund, surfaces, objects, \
            surf_ownership, ray_ownership, surfs_relevancy)[0]
        correct_params = N.array([[False, True, False]])

        N.testing.assert_array_almost_equal(params, correct_params)