Beispiel #1
0
def get_curved_surf_triangle_centers(vtx,
                                     rad,
                                     detector_r=1.0,
                                     focal_length=1.0,
                                     nsteps=10,
                                     b_pxl=4):
    #Changed the rotation matrix to try and keep the curved surface towards the interior
    #Make sure diameter, etc. are set properly
    curved_surf_triangle_centers = []
    mesh_surf, ring = curved_surface2(detector_r,
                                      diameter=2 * rad,
                                      nsteps=nsteps,
                                      base_pxl=b_pxl,
                                      ret_arr=True)
    initial_curved_surf = mh.rotate(
        mesh_surf,
        make_rotation_matrix(-np.pi / 2,
                             (1, 0, 0)))  #-np.pi with curved_surface2
    triangles_per_surface = initial_curved_surf.triangles.shape[0]
    phi, axs = rot_axis([0, 0, 1], vtx)
    for vx, ph, ax in zip(vtx, -phi, axs):
        curved_surf_triangle_centers.extend(
            mh.shift(
                mh.rotate(initial_curved_surf,
                          make_rotation_matrix(ph, ax)), -normalize(vx) *
                (np.linalg.norm(vx) + focal_length)).get_triangle_centers())
    return np.asarray(
        curved_surf_triangle_centers), triangles_per_surface, ring
Beispiel #2
0
def BuildBlocker(radius, height):
    nsteps = 50
    x_value = np.linspace(radius, radius + 200, nsteps)
    y_value = [1] * nsteps

    blocker = make.rotate_extrude(x_value, y_value, nsteps)

    blocker = mh.rotate(blocker, make_rotation_matrix(+np.pi / 2, (1, 0, 0)))
    blocker = mh.shift(blocker, (0, 0, height))

    return blocker
Beispiel #3
0
def PlotBlocker(radius, height):
    nsteps = 30
    x_value = np.linspace(radius, radius + 200, nsteps)
    y_value = [0] * nsteps

    blocker = make.rotate_extrude(x_value, y_value, nsteps)
    blocker = mh.rotate(blocker, make_rotation_matrix(+np.pi / 2, (1, 0, 0)))
    blocker = mh.shift(blocker, (0, 0, height))

    blocker_triangles = blocker.get_triangle_centers()
    blocker_vertices = blocker.assemble()

    X = blocker_vertices[:, :, 0].flatten()
    Y = blocker_vertices[:, :, 1].flatten()
    Z = blocker_vertices[:, :, 2].flatten()

    trianglesblocker = [[3 * ii, 3 * ii + 1, 3 * ii + 2]
                        for ii in range(len(X) / 3)]
    triang = Triangulation(X, Y, trianglesblocker)

    return triang, Z
Beispiel #4
0
def build_kabamland(kabamland, configname):
    # focal_length sets dist between lens plane and PMT plane (or back of curved detecting surface);
    #(need not equal true lens focal length)
    config = detectorconfig.configdict(configname)

    _, lens = kb.get_lens_triangle_centers(
        config.edge_length,
        config.base,
        config.diameter_ratio,
        config.thickness_ratio,
        config.half_EPD,
        config.blockers,
        blocker_thickness_ratio=config.blocker_thickness_ratio,
        light_confinement=config.light_confinement,
        focal_length=config.focal_length,
        lens_system_name=config.lens_system_name)
    surf = mh.rotate(
        kb.curved_surface2(config.detector_r,
                           diameter=2 *
                           kb.find_max_radius(config.edge_length, config.base),
                           nsteps=9),
        make_rotation_matrix(-np.pi / 2, (1, 0, 0)))
    surf = mh.shift(surf, (0, 0, -config.focal_length))
    kabamland.add_solid(Solid(surf, lm.ls, lm.ls, lm.fulldetect, 0x0000FF),
                        rotation=None,
                        displacement=(0, 0, 0))
    kabamland.add_solid(Solid(lens, lm.lensmat, lm.ls),
                        rotation=None,
                        displacement=None)

    blocker = BuildBlocker(
        np.max(lens.assemble()[:, :, 0].flatten()),
        lens.assemble()[:, :,
                        2].flatten()[np.argmax(lens.assemble()[:, :,
                                                               0].flatten())])
    kabamland.add_solid(Solid(blocker, lm.ls, lm.ls, lm.fullabsorb, 0x0000FF),
                        rotation=None,
                        displacement=(0, 0, 0))
    kabamland.channel_index_to_channel_id = [1]
    return lens, surf
Beispiel #5
0
def build_lens_icosahedron(kabamland,
                           vtx,
                           rad,
                           diameter_ratio,
                           thickness_ratio,
                           half_EPD,
                           blockers=True,
                           blocker_thickness_ratio=1.0 / 1000,
                           light_confinement=False,
                           focal_length=1.0,
                           lens_system_name=None):
    """input edge length of icosahedron 'edge_length',
       the number of small triangles in the base of each face 'base',
       the ratio of the diameter of each lens to the maximum diameter possible 'diameter_ratio' (or the fraction of the default such ratio,
       if a curved detector lens system), the ratio of the thickness of the lens to the chosen (not maximum) diameter 'thickness_ratio',
       the radius of the blocking entrance pupil 'half_EPD',
       and the ratio of the thickness of the blockers to that of the lenses 'blocker_thickness_ratio'
       to return the icosahedron of lenses in kabamland. Light_confinment=True adds cylindrical shells behind each lens that absorb all the light that touches them,
       so that light doesn't overlap between lenses. If lens_system_name is a string that matches one of the lens systems in lenssystem.py,
       the corresponding lenses and detectors will be built. Otherwise, a default simple lens will be built, with parameters hard-coded below.
    """
    # Get the list of lens meshes from the appropriate lens system as well as the lens material'''
    scale_rad = rad * diameter_ratio  #max_radius->rad of the lens assembly
    lenses = lenssystem.get_lens_mesh_list(lens_system_name, scale_rad)
    lensmat = lenssystem.get_lens_material(lens_system_name)
    face = None
    for lns in lenses:
        #lns = mh.rotate(lns,make_rotation_matrix(ph,ax))
        if not face:
            face = Solid(lns, lensmat, kabamland.detector_material)
        else:
            face += Solid(lns, lensmat, kabamland.detector_material)

    if light_confinement:
        shield = mh.rotate(
            cylindrical_shell(rad * (1 - 0.001), rad, focal_length, 32),
            make_rotation_matrix(np.pi / 2.0, (1, 0, 0)))
        baffle = Solid(shield, lensmat, kabamland.detector_material,
                       black_surface, 0xff0000)

    if blockers:
        blocker_thickness = 2 * rad * blocker_thickness_ratio
        if half_EPD < rad:
            c1 = lenssystem.get_lens_sys(
                lens_system_name).c1 * lenssystem.get_scale_factor(
                    lens_system_name, scale_rad)
            offset = [0, 0, c1 - np.sqrt(c1 * c1 - rad * rad)]
            anulus_blocker = mh.shift(
                mh.rotate(
                    cylindrical_shell(half_EPD, rad, blocker_thickness, 32),
                    make_rotation_matrix(np.pi / 2.0, (1, 0, 0))), offset)
            face += Solid(anulus_blocker, lensmat, kabamland.detector_material,
                          black_surface, 0xff0000)
    phi, axs = rot_axis([0, 0, 1], vtx)
    for vx, ph, ax in zip(vtx, -phi, axs):
        kabamland.add_solid(face,
                            rotation=make_rotation_matrix(ph, ax),
                            displacement=-vx)
        if light_confinement:
            kabamland.add_solid(baffle,
                                rotation=make_rotation_matrix(ph, ax),
                                displacement=-normalize(vx) *
                                (np.linalg.norm(vx) + focal_length / 2.0))