Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def z_rot(x_ang,y_ang,z_ang):
    """
    Returns the rotation matrix of a rotation about each coordinate axes done one after another. Input in Radians.
    """
    #remove my
    mx = N.matrix(general_axis_rotation(r_[1,0,0],x_ang))
    my = N.matrix(general_axis_rotation(r_[0,1,0],y_ang))
    mz = N.matrix(general_axis_rotation(r_[0,0,1],z_ang))
    M1 = my*mx
    M2 = mz*M1
    return M2
Ejemplo n.º 3
0
def rotation_matrix(x_ang, y_ang, z_ang):
    """
    Returns the rotation matrix of a rotation about each coordinate axes done one after another. Input in Radians.
    """
    #remove my
    mx = N.matrix(general_axis_rotation(r_[1, 0, 0], x_ang))
    my = N.matrix(general_axis_rotation(r_[0, 1, 0], y_ang))
    mz = N.matrix(general_axis_rotation(r_[0, 0, 1], z_ang))
    M1 = my * mx
    M2 = mz * M1
    return M2
Ejemplo n.º 4
0
    def setUp(self):
        self.x = 1/(math.sqrt(2))
        dir = N.c_[[0,self.x,-self.x],[0,1,0]]
        position = N.c_[[0,0,1],[0,0,1]]
        self._bund = RayBundle(position, dir, energy=N.ones(2))

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

        self.engine = TracerEngine(self.assembly)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    def setUp(self):
        self.x = 1 / (math.sqrt(2))
        dir = N.c_[[0, self.x, -self.x], [0, 1, 0]]
        position = N.c_[[0, 0, 1], [0, 0, 1]]
        self._bund = RayBundle(position, dir, energy=N.ones(2))

        rot1 = general_axis_rotation([1, 0, 0], N.pi / 4)
        rot2 = general_axis_rotation([1, 0, 0], N.pi / (-4))
        surf1 = Surface(FlatGeometryManager(),
                        opt.perfect_mirror,
                        rotation=rot1)
        surf2 = Surface(FlatGeometryManager(),
                        opt.perfect_mirror,
                        rotation=rot2)

        self.assembly = Assembly()
        object = AssembledObject()
        object.add_surface(surf1)
        object.add_surface(surf2)
        self.assembly.add_object(object)

        self.engine = TracerEngine(self.assembly)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    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))
Ejemplo n.º 10
0
    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))
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
def thin_bladed_receiver(width, height, absorptivity, blades):
    """
    Constructs lambertian receiver consisting of thin blades.
    """
    front = Surface(RectPlateGM(width, height),opt.LambertianReceiver(absorptivity),location=r_[0.,width/-2.,0.],rotation=general_axis_rotation(r_[1,0,0],N.pi/2))
    n = 0
    front.axis = [1,0,0]
    front.tilt = N.pi/2
    crit_ls = []
    crit_ls.append(front)
    while n < blades:
	blade = Surface(RectPlateGM(width, height),opt.LambertianReceiver(absorptivity),location=r_[width/2-(n*width/(blades-1)),0.,0.],rotation=general_axis_rotation(r_[0,1,0],N.pi/-2))
	blade.number = n+1
	blade.axis = [0,1,0]
	blade.tilt = N.pi/2
	crit_ls.append(blade)
	n += 1
    rec_obj = AssembledObject(surfs=crit_ls)
    #obj.surfaces_for_next_iteration = types.MethodType(surfaces_for_next_iteration, obj, obj.__class__)
    return rec_obj, obj_ls, crit_ls
Ejemplo n.º 14
0
def cavity_receiver(width, height, absorptivity=1.):
    """
    Constructs a lambertian receiver consisting of three faces. Returns a list of receiving faces, the assembled object
    """
    front = Surface(RectPlateGM(width, height),opt.LambertianReceiver(absorptivity),location=r_[0.,0.,0.],rotation=general_axis_rotation(r_[1,0,0],N.pi/2))
    left = Surface(RectPlateGM(width, height),opt.LambertianReceiver(absorptivity),location=r_[width/2,width/2,0.],rotation=general_axis_rotation(r_[0,1,0],N.pi/-2))
    left.width = width
    left.height = height/2.
    right = Surface(RectPlateGM(width, height),opt.LambertianReceiver(absorptivity),location=r_[width/-2,width/2,0.],rotation=general_axis_rotation(r_[0,1,0],N.pi/2))
    right.width = width
    right.height = height/2.
    rec_obj = AssembledObject(surfs=[left, front, right])
    #obj.surfaces_for_next_iteration = types.MethodType(surfaces_for_next_iteration, obj, obj.__class__)
    return rec_obj,[left, front, right], [left, front, right]