コード例 #1
0
    def tab_screw(self):
        height = self.max_max_coll_width_detector
        width = 3.6 * 5
        thickness = 6.

        source_distance = self.inner_radius + 5
        span = self.angle2span(source_distance,
                               self.horizontal_acceptance_angle)

        large_pillar = shapes.block(height='%s *mm' % height,
                                    width='%s *mm' % width,
                                    thickness='%s *mm' % thickness)
        small_pillar = shapes.block(height='%s *mm' % span,
                                    width='%s *mm' % (width + 1),
                                    thickness='%s *mm' % (thickness + 1))

        pillar = operations.subtract(large_pillar, small_pillar)

        length = height - span

        holes_position = span / 2 + length / 4

        holes = [
            operations.translate(operations.rotate(shapes.cylinder(
                radius='%s*mm' % 1.6, height='%s *mm' % (thickness + 55)),
                                                   transversal=1,
                                                   angle='%s *deg' % 90),
                                 vertical='%s *mm' % a)
            for a in [holes_position, -holes_position]
        ]

        all_holes = operations.unite(*holes)

        pillar_holes = operations.subtract(large_pillar, all_holes)

        vertical_rot = operations.rotate(pillar_holes,
                                         vertical=1,
                                         angle='%s *deg' % 90)

        beam_rot = operations.rotate(vertical_rot,
                                     beam=1,
                                     angle='%s *deg' % 90)

        move_beam = operations.translate(
            beam_rot,
            beam='%s *mm' % -(self.inner_radius + self.base_thickness / 2))

        move_ver = operations.translate(
            move_beam,
            vertical='%s *mm' %
            (-(self.max_coll_height_detector) / 2 + thickness / 2))

        return (vertical_rot)
コード例 #2
0
    def generate_vertical_blade_PLUS_border_list(self):

        height = self.horizontal_outer_radius * 1.2

        arc_width = height * np.deg2rad(self.vertical_acceptance_angle)

        thickness = self.wall_thickness

        pillar = shapes.block(height='%s *mm' % height,
                              width='%s *mm' % thickness,
                              thickness='%s *mm' % (arc_width))

        pyl_d = operations.translate(pillar,
                                     vertical='%s *mm' % (-(height) / 2))

        one_vertical_blade = operations.rotate(pyl_d,
                                               transversal=1,
                                               angle='%s *degree' % (90))

        vertical_blades = [
            operations.rotate(one_vertical_blade,
                              vertical="1",
                              angle='%s*deg' % a)
            for a in self.horizontal_pillar_angle_list
        ]

        return (vertical_blades)
コード例 #3
0
    def _makePack(self, name, id, instrument, pressure, npixels, radius,
                  height, gap):
        '''make a unique 8-pack
        
all physical parameters must have units attached.
'''
        from .ARCS.packSize import getSize
        size = getSize(radius, height, gap)
        shape = shapes.block(**size)
        pack = elements.detectorPack(name,
                                     shape=shape,
                                     guid=instrument.getUniqueID(),
                                     id=id)
        packGeometer = geometers.geometer(pack)
        self.local_geometers.append(packGeometer)

        det0 = self._makeDetector('det0', 0, instrument, pressure, npixels,
                                  radius, height)
        pack.addElement(det0)

        #180 degree is an artifact of current limitation of simulation
        #package.
        from .ARCS.tubePositions import getPositions
        positions = getPositions(radius, gap)
        packGeometer.register(det0, (0 * m, positions[0], 0 * m), (0, 180, 0))

        for i in range(1, 8):
            det = elements.copy('det%s' % i,
                                det0.guid(),
                                guid=instrument.getUniqueID())
            pack.addElement(det)
            packGeometer.register(det, (0 * m, positions[i], 0 * m),
                                  (0, 180, 0))
            continue
        return pack
コード例 #4
0
    def generate_box_toIntersect_big_end(self, width=None, height=None):
        if height is None:
            height = (self.channel_length +
                      self.collimator_front_end_from_center)
        else:
            height = height

        if width is None:
            width = self.collimator_height_detector(
            ) * 1.2  #height of the collimator

        else:
            width = width

        thickness = (self.channel_length +
                     self.collimator_front_end_from_center
                     ) * 1.2  #width of the collimator

        box = shapes.block(height='%s *mm' % height,
                           width='%s *mm' % thickness,
                           thickness='%s *mm' % (width))

        box_d = operations.translate(box, vertical='%s *mm' % (-(height) / 2))

        box_beam_vertical = operations.rotate(box_d,
                                              transversal=1,
                                              angle='%s *degree' % (90))

        return (box_beam_vertical)
コード例 #5
0
    def generate_box_toIntersect_big_end(self, width=None, height=None):
        if height is None:
            height = self.vertical_outer_radius
        else:
            height=height


        if width is None:
            width = self.max_coll_height_detector * 1.2 #height of the collimator

        else:
            width=width


        thickness = self.vertical_outer_radius * 1.2 #width of the collimator



        box = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness,
                              thickness='%s *mm' % (width))

        box_d = operations.translate(box, vertical='%s *mm' % (-(height) / 2))

        box_beam_vertical = operations.rotate(box_d, transversal=1, angle='%s *degree' % (90))

        return(box_beam_vertical)
コード例 #6
0
    def generate_box_toCut_big_end(self, width=None, height=None):
        if height is None:
            height = self.outer_radius
        else:
            height = height

        # print ('blade height', height)

        if width is None:
            width = self.max_coll_height_detector * 1.2
        else:
            width = width

        thickness = self.outer_radius * 1.2

        box = shapes.block(height='%s *mm' % height,
                           width='%s *mm' % thickness,
                           thickness='%s *mm' % (width))

        box_d = operations.translate(box, vertical='%s *mm' % (-(height) / 2))

        box_beam_vertical = operations.rotate(box_d,
                                              transversal=1,
                                              angle='%s *degree' % (90))

        return (box_beam_vertical)
コード例 #7
0
    def generate_vertical_blade_PLUS_border_list(self):

        height = (self.channel_length +
                  self.collimator_front_end_from_center) * 1.2

        arc_width = height * np.deg2rad(self.maximum_vertical_acceptance_angle)

        thickness = self.blade_width

        pillar = shapes.block(height='%s *mm' % height,
                              width='%s *mm' % thickness,
                              thickness='%s *mm' % (arc_width))

        pyl_d = operations.translate(pillar,
                                     vertical='%s *mm' % (-(height) / 2))

        one_vertical_blade = operations.rotate(pyl_d,
                                               transversal=1,
                                               angle='%s *degree' % (90))

        vertical_blades = [
            operations.rotate(one_vertical_blade,
                              vertical="1",
                              angle='%s*deg' % a)
            for a in self.horizontal_pillar_angle_list()
        ]

        return (vertical_blades)
コード例 #8
0
ファイル: clampcell_geo.py プロジェクト: Fahima-Islam/c3dp
    def inner_sleeve(self):
        CuBe_InDiameter = 4.74  # mm
        CuBe_InRadius = CuBe_InDiameter / 2
        CuBe_InHeight = self.sample_height + 10  #mm (total height 95.758 mm)
        CuBe_Height = self.sample_height
        CuBe_OutSmallestCone_Dia = 14.63  #(outer boundary is tappered cylinder, bottom diameter )
        CuBe_OutSmallestCone_Rad = CuBe_OutSmallestCone_Dia / 2
        CuBe_OutconeAngle = 2  # the tappered angle

        CuBe_OutLargestCone_Dia = (
            2 * np.tan(np.deg2rad(CuBe_OutconeAngle / 2)) * CuBe_Height
        ) + CuBe_OutSmallestCone_Dia  #( tappered cylinder top diamter)
        CuBe_OutLargestCone_Rad = CuBe_OutLargestCone_Dia / 2
        CuBe_OutSmallest_ConeHeight = CuBe_OutSmallestCone_Dia / (
            2 * np.tan(np.deg2rad(CuBe_OutconeAngle / 2)))
        CuBe_OutLargest_ConeHeight = CuBe_OutSmallest_ConeHeight + CuBe_Height
        CuBe_boxHeightToSubtract = CuBe_OutSmallest_ConeHeight * 2
        CuBe_boxthisckness = CuBe_OutSmallestCone_Dia + 20
        CuBe_HalfHeight = CuBe_Height / 2
        CuBe_moving_height = CuBe_OutSmallest_ConeHeight + CuBe_HalfHeight

        ### CReate the string for INNER SLEEVE ######
        CuBe_InRadius_str = str(CuBe_InRadius) + r'*mm'
        CuBe_InHeight_str = str(CuBe_InHeight) + r'*mm'
        CuBe_Height_str = str(CuBe_Height) + r'*mm'
        CuBe_OutLargestCone_Rad_str = str(CuBe_OutLargestCone_Rad) + r'*mm'
        CuBe_OutLargest_ConeHeight_str = str(
            CuBe_OutLargest_ConeHeight) + r'*mm'
        CuBe_boxHeightToSubtract_str = str(CuBe_boxHeightToSubtract) + r'*mm'
        CuBe_boxthisckness_str = str(CuBe_boxthisckness) + r'*mm'
        CuBe_moving_height_str = str(-CuBe_moving_height) + r'*mm'

        #create the outer CuBe largest cone
        CuBe_largest_cone = shapes.cone(
            radius=CuBe_OutLargestCone_Rad_str,
            height=CuBe_OutLargest_ConeHeight_str)  # upside down
        #rotation to make top wider
        CuBe_largest_cone_widertip = operations.rotate(CuBe_largest_cone,
                                                       angle="180*deg",
                                                       vertical="0",
                                                       transversal="1",
                                                       beam="0")
        #make a tapered cylinder
        CuBe_tapered_cylinder = operations.Difference(
            CuBe_largest_cone_widertip,
            shapes.block(thickness=CuBe_boxthisckness_str,
                         height=CuBe_boxHeightToSubtract_str,
                         width=CuBe_boxthisckness_str))
        #moving the center of the cylinder to the center of the coordinate
        CuBe_centered_taperedCylinder = operations.translate(
            CuBe_tapered_cylinder, vertical=CuBe_moving_height_str)

        #Creating the InnerSleeve
        CuBe_innerSleeve = operations.subtract(
            CuBe_centered_taperedCylinder,
            shapes.cylinder(radius=CuBe_InRadius_str,
                            height=CuBe_InHeight_str),
        )
        return (CuBe_innerSleeve)
コード例 #9
0
def createNormalModerator(name,
                          width,
                          height,
                          thickness,
                          type="",
                          **attributes):
    shape = shapes.block(width, height, thickness)
    return Moderator(name, shape=shape, type=type, **attributes)
コード例 #10
0
 def notify(self, parent):
     block = shapes.block(
         width=self._width,
         height=self._height,
         thickness=self._thickness,
     )
     parent.onBlock(block)
     return
コード例 #11
0
ファイル: clampcell_geo.py プロジェクト: Fahima-Islam/c3dp
    def outer_body(self):
        Al_OutDiameter = 32.05  # mm
        Al_OutRadius = Al_OutDiameter / 2
        Al_Height = self.sample_height  #28.57 #mm (total height 95.758 mm)
        Al_InSmallestCone_Dia = 14.59  #mm (inner boundary is tappered cylinder, bottom Diameter )
        Al_InSmallestCone_Rad = Al_InSmallestCone_Dia / 2
        Al_InconeAngle = 2

        Al_InHeight = Al_Height + 10  #mm (tappered cylinder height) (this should be same as Al_Height, but in constructive geometry the inner height has to be larger for correct subtraction)

        Al_InLargestCone_Dia = (
            2 * np.tan(np.deg2rad(Al_InconeAngle / 2)) * Al_InHeight
        ) + Al_InSmallestCone_Dia  #( tappered cylinder top diameter)
        Al_InLargestCone_Rad = Al_InLargestCone_Dia / 2
        Al_InSmallest_ConeHeight = Al_InSmallestCone_Dia / (
            2 * np.tan(np.deg2rad(Al_InconeAngle / 2)))
        Al_InLargest_ConeHeight = Al_InSmallest_ConeHeight + Al_InHeight
        Al_boxHeightToSubtract = Al_InSmallest_ConeHeight * 2
        Al_boxthisckness = Al_InSmallestCone_Dia + 20
        Al_HalfHeight = Al_InHeight / 2
        Al_moving_height = Al_InSmallest_ConeHeight + Al_HalfHeight

        ### CReate the string for OUTER BODY ######
        Al_OutRadius_str = str(Al_OutRadius) + r'*mm'
        Al_Height_str = str(Al_Height) + r'*mm'
        Al_InLargestCone_Rad_str = str(Al_InLargestCone_Rad) + r'*mm'
        Al_InLargest_ConeHeight_str = str(Al_InLargest_ConeHeight) + r'*mm'
        Al_InSmallest_ConeHeight_str = str(Al_InSmallest_ConeHeight) + r'*mm'
        Al_boxHeightToSubtract_str = str(Al_boxHeightToSubtract) + r'*mm'
        Al_boxthisckness_str = str(Al_boxthisckness) + r'*mm'
        Al_moving_height_str = str(-Al_moving_height) + r'*mm'

        #create the inner Al largest cone
        Al_largest_cone = shapes.cone(
            radius=Al_InLargestCone_Rad_str,
            height=Al_InLargest_ConeHeight_str)  # upside down
        #rotation to make top wider
        Al_largest_cone_widertip = operations.rotate(Al_largest_cone,
                                                     angle="180*deg",
                                                     vertical="0",
                                                     transversal="1",
                                                     beam="0")
        #make a tapered cylinder
        Al_tapered_cylinder = operations.Difference(
            Al_largest_cone_widertip,
            shapes.block(thickness=Al_boxthisckness_str,
                         height=Al_boxHeightToSubtract_str,
                         width=Al_boxthisckness_str))
        #moving the center of the cylinder to the center of the coordinate
        Al_centered_taperedCylinder = operations.translate(
            Al_tapered_cylinder, vertical=Al_moving_height_str)

        #Creating the outer Al body
        outer_Al = operations.subtract(
            shapes.cylinder(radius=Al_OutRadius_str, height=Al_Height_str),
            Al_centered_taperedCylinder,
        )
        return (outer_Al)
コード例 #12
0
    def test(self):
        """
        instrument.geometry.pml.render
        """
        import numpy as np
        from instrument.geometry.pml import weave
        from instrument.geometry import shapes, operations
        pyramid = shapes.pyramid(thickness="20.*mm",
                                 width="20.*mm",
                                 height="110.*mm")
        pyramid_along_beam = operations.rotate(pyramid,
                                               transversal="1",
                                               angle="90.*deg")
        angles = np.arange(-160, 0., 15.)
        pyramids = [
            operations.rotate(pyramid_along_beam,
                              vertical="1",
                              angle='%s*deg' % a) for a in angles
        ]
        channels = operations.unite(*pyramids)

        hollow_cylinder = operations.subtract(
            shapes.cylinder(radius="55.*mm", height="50.*mm"),
            shapes.cylinder(radius="25.*mm", height="60.*mm"),
        )
        half_cylinder = operations.subtract(
            hollow_cylinder,
            operations.translate(
                shapes.block(height="110*mm",
                             width="110*mm",
                             thickness="110*mm"),
                transversal="-55.*mm",
            ))
        all = operations.subtract(half_cylinder, channels)

        # use a special renderer
        from instrument.geometry.pml.Renderer import Renderer as base

        class Renderer(base):
            def _renderDocument(self, body):
                self.onGeometry(body)
                return

            def header(self):
                return []

            def footer(self):
                return []

            def end(self):
                return

        text = weave(all,
                     open('collimator.xml', 'wt'),
                     print_docs=False,
                     renderer=Renderer(),
                     author='')
        return
コード例 #13
0
ファイル: Monitor.py プロジェクト: danse-inelastic/instrument
def createNormalMonitor(name,
                        width,
                        height,
                        thickness,
                        mode='monitor',
                        sampledFraction=0.01,
                        **kwds):
    shape = shapes.block(width, height, thickness)
    return Monitor(name,
                   shape=shape,
                   mode=mode,
                   sampledFraction=sampledFraction,
                   **kwds)
コード例 #14
0
    def generate_channels_list(self):

        if self.max_coll_height_detector > self.max_coll_width_detector:
            height = self.horizontal_outer_radius * 1.2
            arc_width = height * np.deg2rad(self.vertical_acceptance_angle)
            # print ('height')
        else:
            height = self.vertical_outer_radius * 1.2
            arc_width = height * np.deg2rad(self.horizontal_acceptance_angle)
            # print ('width')
        width = abs(self.angle2span(height, self.horizontal_acceptance_angle))

        # arc_width = height * np.deg2rad(self.horizontal_acceptance_angle)
        # height = self.horizontal_outer_radius * 1.2
        # arc_width = height * np.deg2rad(self.vertical_acceptance_angle)

        thickness = self.wall_thickness

        pillar = shapes.block(height='%s *mm' % height,
                              width='%s *mm' % thickness,
                              thickness='%s *mm' % (arc_width))

        pyl_d = operations.translate(pillar,
                                     vertical='%s *mm' % (-(height) / 2))

        pyl_beam_vertical = operations.rotate(pyl_d,
                                              transversal=1,
                                              angle='%s *degree' % (90))

        pyls_beam_vertical = [
            operations.rotate(pyl_beam_vertical,
                              vertical="1",
                              angle='%s*deg' % a)
            for a in self.horizontal_pillar_angle_list
        ]

        pyl_beam_horizontal = operations.rotate(pyl_beam_vertical,
                                                beam=1,
                                                angle='%s *degree' % 90)

        pyls_beam_horizontal = [
            operations.rotate(pyl_beam_horizontal,
                              transversal="1",
                              angle='%s*deg' % a)
            for a in self.vertical_pillar_angle_list
        ]

        return (pyls_beam_vertical, pyls_beam_horizontal)
コード例 #15
0
    def generate_channels_list(self):

        height = self.outer_radius * 1.2

        # print ('blade height', height)
        width = abs(self.angle2span(height, self.horizontal_acceptance_angle))

        arc_width = height * np.deg2rad(self.horizontal_acceptance_angle)

        # print (' arc width', arc_width)
        thickness = self.wall_thickness

        # print ('blade width', width)

        # print ('blade thickness', thickness)

        pillar = shapes.block(height='%s *mm' % height,
                              width='%s *mm' % thickness,
                              thickness='%s *mm' % (arc_width))

        pyl_d = operations.translate(pillar,
                                     vertical='%s *mm' % (-(height) / 2))

        pyl_beam_vertical = operations.rotate(pyl_d,
                                              transversal=1,
                                              angle='%s *degree' % (90))

        pyls_beam_vertical = [
            operations.rotate(pyl_beam_vertical,
                              vertical="1",
                              angle='%s*deg' % a)
            for a in self.horizontal_pillar_angle_list
        ]

        pyl_beam_horizontal = operations.rotate(pyl_beam_vertical,
                                                beam=1,
                                                angle='%s *degree' % 90)

        pyls_beam_horizontal = [
            operations.rotate(pyl_beam_horizontal,
                              transversal="1",
                              angle='%s*deg' % a)
            for a in self.vertical_pillar_angle_list
        ]

        return (pyls_beam_vertical, pyls_beam_horizontal)
コード例 #16
0
 def test(self):
     """
     instrument.geometry.pml.render
     """
     from instrument.geometry.pml import render
     from instrument.geometry import shapes, operations
     cyl = shapes.cylinder(radius="1.*cm", height="5.*cm")
     sphere = shapes.sphere(radius="2.*cm")
     block = shapes.block(width="5*cm", height="4.*cm", thickness="1.*mm")
     u = operations.unite(cyl, sphere, block)
     t = operations.translate(u, vertical="0.2*cm")
     r = operations.rotate(t, vertical=1., angle=90.)
     pyramid = shapes.pyramid(width="4.*cm",
                              height="2.*cm",
                              thickness="1.*cm")
     i = operations.intersect(r, pyramid)
     cone = shapes.cone(radius="2.*cm", height="2.*cm")
     u = operations.unite(i, cone)
     sphere2 = shapes.sphere(radius="3.*cm")
     s = operations.subtract(sphere2, u)
     text = render(s, print_docs=False)
     print('\n'.join(text), file=open('test2.xml.rendered', 'w'))
     return
コード例 #17
0
    def gen_one_col(self, collimator_Nosupport=True):
        pyr = self.solid_pyramid()

        big_cylinder = shapes.cylinder(radius='%s *mm' % (self.vertical_outer_radius),
                                       height='%s *mm' % (self.max_coll_height_detector * 10))

        big_box=self.generate_box_toIntersect_big_end()

        outside_sphere = shapes.sphere(radius='%s *mm' % self.vertical_outer_radius)


        channels=self.generate_collimator_channels()
        channels_border=self.generate_channels_border()

        conical_colli = operations.intersect(channels, pyr)

        conical_channels_border=operations.intersect(channels_border, pyr)


        cutoff_cylinder = shapes.cylinder(radius='%s *mm' % (self.inner_radius),
                                          height='%s *mm' % (self.max_coll_height_detector * 90.))

        blade_cutoff_cylinder = shapes.cylinder(radius='%s *mm' % (self.vertical_blade_dist_fr_sample_center),
                                          height='%s *mm' % (self.max_coll_height_detector * 10))



        cutoff_box = shapes.block(width='%s *mm' % (self.inner_radius*2), thickness='%s *mm' % (self.inner_radius*2),
                                          height='%s *mm' % (self.max_coll_height_detector * 90.))

        blade_cutoff_box = shapes.block(width='%s *mm' % (self.vertical_blade_dist_fr_sample_center*2),
                                        thickness='%s *mm' % (self.vertical_blade_dist_fr_sample_center*2),
                                                height='%s *mm' % (self.max_coll_height_detector * 10))


        # return (operations.subtract(conical_channels_border, cutoff_cylinder))

        if self.collimator_parts is True:
            open_collimator = operations.intersect(operations.subtract(conical_channels_border, cutoff_box),
                                                   big_box)

            collimator_with_blades = operations.intersect(operations.subtract(conical_colli, blade_cutoff_box),
                                                          big_box)

        else:
            open_collimator=operations.intersect(operations.subtract(conical_channels_border, cutoff_cylinder), big_box)



            collimator_with_blades = operations.intersect(operations.subtract(conical_colli, blade_cutoff_cylinder), big_box)


        collimator=operations.unite(open_collimator, collimator_with_blades)



        scale_pyr = 1.1
        pyr_ht = (self.horizontal_arc_length_detector / np.deg2rad(self.horizontal_acceptance_angle)) * scale_pyr

        thickness = (self.max_coll_height_detector + 1 * self.wall_thickness) * scale_pyr
        height = (self.horizontal_arc_length_detector / np.deg2rad(self.horizontal_acceptance_angle)) * scale_pyr
        width = (self.max_coll_width_detector + 1 * self.wall_thickness) * scale_pyr

        # pyr_ht = self.vertical_outer_radius * np.cos(np.deg2rad(self.horizontal_acceptance_angle/2.)) * scale_pyr
        pyr_lateral = shapes.pyramid(
            thickness='%s *mm' % (thickness),
            # height='%s *mm' % (height),
            height='%s *mm' % (height),
            width='%s *mm' % (width+900.))
        pyr_lateral = operations.rotate(pyr_lateral, transversal=1, angle='%s *degree' % (90))

        pyr_depth = shapes.pyramid(
            thickness='%s *mm' % (thickness+6900),
            # height='%s *mm' % (height),
            height='%s *mm' % (height),
            width='%s *mm' % (width ))
        pyr_depth = operations.rotate(pyr_depth, transversal=1, angle='%s *degree' % (90))

        # collimator_support = Collimator_support()
        # collimator_support.set_constraints(
        #     truss_base_thickness=30., trass_final_height_factor=0.45,
        #     touch_to_halfcircle=6, SNAP_acceptance_angle=False)
        #
        # supports = collimator_support.support()

        supports = self.support()


        support_top=operations.intersect(operations.subtract(supports, pyr_lateral), pyr_depth)



        # support_top =operations.subtract(self.support(), pyr_lateral)

        support_bottom=operations.rotate(operations.rotate(support_top, transversal=1, angle='%s *degree' %(-180)), vertical=1, angle='%s *degree' %180)


        supports=operations.subtract(operations.unite(support_top, support_bottom), cutoff_cylinder)

        if collimator_Nosupport is True:
            return(collimator)
        else:
            return(operations.unite(collimator,supports))
コード例 #18
0
    def support(self):

        main_cylinder_radius = self.inner_radius * self.truss_height_factor

        main_cylinder_diameter = main_cylinder_radius * 2.

        height_support_main = main_cylinder_diameter - self.beam_dist_support

        base_width_support = self.truss_base_thickness

        cyli_radius = main_cylinder_radius * 2

        height_support = height_support_main

        cyli_dia = cyli_radius * 2.

        ################################################ cylinder_radius=self.inner_radius

        cylinder_radius = cyli_dia / 2.
        vertical_cylinder_height = cyli_dia + 100  ## big cylinder height should be greater than the cyli diameter

        suppert_end_distance_fr_source = self.inner_radius + base_width_support

        thickness_collimator_at_support_end = self.angle2span(
            suppert_end_distance_fr_source, self.vertical_acceptance_angle)

        height_factor = 1.
        height = thickness_collimator_at_support_end * height_factor

        cylinder = shapes.cylinder(radius='%s *mm' % (cylinder_radius),
                                   height='%s *mm' % (height * 2 + 10))

        cylinder_transversal = operations.rotate(cylinder,
                                                 beam=1,
                                                 angle='%s *degree' % 90)

        vertical_cylinder = shapes.cylinder(
            radius='%s *mm' % (cylinder_radius),
            height='%s *mm' % (vertical_cylinder_height))

        distance_fr_center_height_main = np.sqrt((main_cylinder_radius)**2 -
                                                 (height_support / 2)**2)

        angular_cut = self.span2angle(height_support,
                                      distance_fr_center_height_main) / 2.

        distance_fr_center_height = cylinder_radius * np.cos(
            np.deg2rad(angular_cut))

        vertical_cylinder_move_dist = abs(cylinder_radius -
                                          distance_fr_center_height)

        distance_fr_center_height = np.sqrt((cylinder_radius)**2 -
                                            (height_support / 2)**2)

        vertical_cylinder_move_dist = abs(cylinder_radius -
                                          distance_fr_center_height_main)

        unwanted_part_of_smallcircle0 = operations.subtract(
            cylinder_transversal,
            operations.translate(vertical_cylinder,
                                 beam='%s *mm' % -vertical_cylinder_move_dist))

        moving_dist_cylinder = 20

        # unwanted_part_of_smallcircle0= operations.translate(unwanted_part_of_smallcircle0, beam='%s *mm' %-moving_dist_cylinder)

        unwanted_part_of_bigcircle2 = operations.translate(
            unwanted_part_of_smallcircle0, beam='%s *mm' % (1))

        cylinder_radius = self.inner_radius

        cylinder_transversal_1_0 = operations.rotate(shapes.cylinder(
            radius='%s *mm' % (cylinder_radius),
            height='%s *mm' % ((height * 2))),
                                                     beam=1,
                                                     angle='%s *degree' % 90)

        # return(operations.unite(cylinder_transversal_1_0, operations.translate(vertical_cylinder, beam='%s *mm' % -vertical_cylinder_move_dist)))
        mod_cylinder_transversal = operations.subtract(
            cylinder_transversal_1_0, unwanted_part_of_smallcircle0)

        # return (operations.subtract(cylinder_transversal,operations.subtract(cylinder_transversal,operations.translate(vertical_cylinder, beam='%s *mm' % -vertical_cylinder_move_dist))))
        # return (operations.unite(cylinder_transversal_1_0,unwanted_part_of_smallcircle0 ))
        # return(mod_cylinder_transversal)
        # return (vertical_cylinder)
        # return (operations.subtract(vertical_cylinder, cylinder_transversal))

        ########################################################################################################################################
        #########################################################################################################################################

        solid_shape = mod_cylinder_transversal

        cylinder_transversal = mod_cylinder_transversal  ## small inside cylinder

        cylinder_2 = shapes.cylinder(
            radius='%s *mm' %
            (cylinder_radius + 1),  ###big cylinder (outside cylinder)
            height='%s *mm' % (height * 2))

        cylinder_transversal_2_0 = operations.rotate(cylinder_2,
                                                     beam=1,
                                                     angle='%s *degree' % 90)

        cylinder_transversal_2 = operations.subtract(
            cylinder_transversal_2_0, unwanted_part_of_bigcircle2)

        width_factor = 2.

        big_block = shapes.block(
            height='%s *mm' % cyli_dia,
            width='%s *mm' % (suppert_end_distance_fr_source * width_factor),
            thickness='%s *mm' % (height))

        big_block_rotate = operations.rotate(big_block,
                                             vertical=1,
                                             angle='%s *degree' % 90)

        big_block_2 = shapes.block(
            height='%s *mm' % (cyli_dia - 1),
            width='%s *mm' %
            ((suppert_end_distance_fr_source * width_factor) - 2),
            thickness='%s *mm' % (height + 1))  #### small blog

        big_block_rotate_2 = operations.rotate(big_block_2,
                                               vertical=1,
                                               angle='%s *degree' % 90)

        parts = operations.subtract(big_block_rotate, cylinder_transversal)

        # return(operations.unite(big_block_rotate, cylinder_transversal))

        # return(big_block_rotate)

        parts_2 = operations.subtract(big_block_rotate_2,
                                      cylinder_transversal_2)

        parts_frame = operations.subtract(parts, parts_2)

        # parts_frame=operations.unite(parts_frame, solid_shape)

        # return (parts_frame)
        # return (operations.subtract(parts_frame,parts_2))

        # return operations.unite(cylinder_transversal_1_0,unwanted_part_of_smallcircle0)
        # return(operations.unite(cylinder_transversal, cylinder_transversal_2))

        blades_in_frames = operations.subtract(self.support_design(),
                                               cylinder_transversal)

        parts_frame_blades_pre = operations.unite(parts_frame,
                                                  blades_in_frames)

        parts_frame_blades_pre = parts_frame

        # return (parts_frame_blades_pre)
        #############################################################CHANGES#####################################################
        #########################################################################################################################

        # solid=operations.subtract(vertical_cylinder, unwanted_part_of_bigcircle2)
        #
        # parts_frame_blades_pre = operations.unite(parts_frame_blades_pre, solid)

        side_cut_box = operations.translate(operations.rotate(
            shapes.block(height='%s *mm' % cyli_dia,
                         width='%s *mm' %
                         (suppert_end_distance_fr_source * width_factor),
                         thickness='%s *mm' % (height * 2)),
            vertical=1,
            angle='%s *degree' % 90),
                                            beam='%s *mm' %
                                            -(suppert_end_distance_fr_source))

        up_cut_box = operations.translate(
            operations.rotate(shapes.block(
                height='%s *mm' % cyli_dia,
                width='%s *mm' %
                ((suppert_end_distance_fr_source * width_factor) + 1),
                thickness='%s *mm' % (height * 2)),
                              vertical=1,
                              angle='%s *degree' % 90),
            vertical='%s *mm' % (cyli_dia / 2.))  ########################

        down_cut_box = operations.translate(operations.rotate(
            shapes.block(height='%s *mm' % cyli_dia,
                         width='%s *mm' %
                         ((suppert_end_distance_fr_source * width_factor) + 1),
                         thickness='%s *mm' % (height * 2)),
            vertical=1,
            angle='%s *degree' % 90),
                                            vertical='%s *mm' %
                                            (-(cyli_dia - 2)))

        parts_frame_blades = operations.subtract(
            operations.subtract(
                operations.subtract(parts_frame_blades_pre, side_cut_box),
                up_cut_box), down_cut_box)

        parts_frame_blades = operations.unite(parts_frame_blades,
                                              blades_in_frames)

        parts_frame_blades = operations.subtract(
            operations.subtract(parts_frame_blades, side_cut_box),
            down_cut_box)

        # return (parts_frame_blades)

        thickness_parts = ((suppert_end_distance_fr_source * width_factor) -
                           (self.inner_radius)) / 2

        parts_move_beam = operations.translate(
            parts_frame_blades,
            beam='%s *mm' %
            (-(self.inner_radius) * 2 - base_width_support + 1))
        angle = self.vertical_acceptance_angle  # 15
        # parts_move_up = operations.translate(parts_move_beam, vertical='%s *mm' % (
        #             self.inner_radius + (
        #                 self.curvature * self.inner_radius * np.tan(np.deg2rad(angle/2.)))))

        parts_move_up = operations.translate(
            parts_move_beam,
            vertical='%s *mm' %
            (self.inner_radius +
             (self.curvature * (self.inner_radius * 2. + base_width_support) *
              np.tan(np.deg2rad(angle / 2.)))))

        # return (parts_move_up)
        # return(parts_frame)
        return (operations.intersect(
            parts_move_up,
            self.generate_box_toCut_big_end(
                width=self.max_coll_height_detector *
                self.trass_final_height_factor,
                height=(self.inner_radius * 2. + base_width_support + 100.))))
コード例 #19
0
    def support_design(self):
        main_cylinder_radius = self.inner_radius

        main_cylinder_diameter = main_cylinder_radius * 2.

        height_support = main_cylinder_diameter - 8.

        # print (height_support)

        distance_fr_center_height_main = np.sqrt((main_cylinder_radius)**2 -
                                                 (height_support / 2)**2)

        base_width_support = self.truss_base_thickness

        suppert_end_distance_fr_source = self.inner_radius + base_width_support

        thickness_collimator_at_support_end = self.angle2span(
            suppert_end_distance_fr_source, self.vertical_acceptance_angle)

        pillar = shapes.block(
            height='%s *mm' % (main_cylinder_diameter + base_width_support +
                               self.truss_blade_length),
            width='%s *mm' % (thickness_collimator_at_support_end),
            thickness='%s *mm' % 1)

        pillar_beam = operations.rotate(pillar,
                                        transversal=1,
                                        angle="%s *degree" % 90)

        small_pillar_beam_tocut = operations.rotate(shapes.block(
            height='%s *mm' % (main_cylinder_diameter / 2.),
            width='%s *mm' % (thickness_collimator_at_support_end + 5),
            thickness='%s *mm' % 5),
                                                    transversal=1,
                                                    angle="%s *degree" % 90)

        pillar_beam = operations.subtract(
            pillar_beam,
            operations.translate(small_pillar_beam_tocut,
                                 beam='%s*mm' % -(main_cylinder_radius / 2)))

        angle = 10

        truss_rot_degree = 10
        pillar_beam_dia = operations.rotate(pillar_beam,
                                            transversal=1,
                                            angle='%s *degree' %
                                            truss_rot_degree)

        # return (pillar_beam_dia)

        blade1_needed = operations.translate(operations.subtract(
            operations.rotate(shapes.block(
                height='%s *mm' % (self.max_coll_height_detector * 90.),
                width='%s *mm' % (thickness_collimator_at_support_end),
                thickness='%s *mm' % 2),
                              transversal=1,
                              angle="%s *degree" % 90),
            operations.translate(small_pillar_beam_tocut,
                                 beam='%s*mm' % -(main_cylinder_radius / 2))),
                                             beam='%s *mm' %
                                             (distance_fr_center_height_main))

        blade1 = operations.translate(pillar_beam,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))

        blade1_dia = operations.translate(pillar_beam_dia,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        vertical_blade = operations.rotate(operations.subtract(
            operations.rotate(shapes.block(
                height='%s *mm' % (self.max_coll_height_detector),
                width='%s *mm' % (thickness_collimator_at_support_end),
                thickness='%s *mm' % 1),
                              transversal=1,
                              angle="%s *degree" % 90),
            operations.translate(small_pillar_beam_tocut,
                                 beam='%s*mm' % -(main_cylinder_radius / 2))),
                                           beam=1,
                                           angle='%s *degree' % (90))

        vertical_blade = operations.translate(vertical_blade,
                                              beam='%s *mm' %
                                              (self.inner_radius))

        vertical_blade = operations.rotate(vertical_blade,
                                           transversal=1,
                                           angle='%s *degree' % (90))

        vertical_blade = operations.rotate(vertical_blade,
                                           vertical=1,
                                           angle='%s *degree' % (90))

        vertical_blade = operations.translate(vertical_blade,
                                              beam='%s *mm' %
                                              (self.inner_radius))
        #
        # return (vertical_blade)

        # return (operations.unite(blade1, blade1_dia))

        pillar_beam2 = operations.translate(
            pillar_beam,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia2 = operations.rotate(pillar_beam2,
                                             transversal=1,
                                             angle='%s *degree' %
                                             truss_rot_degree)

        blade2 = operations.translate(pillar_beam2,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade2_dia = operations.translate(pillar_beam_dia2,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        # return (operations.unite(operations.unite(pillar_beam2, pillar_beam_dia2), pillar_beam))

        pillar_beam3 = operations.translate(
            pillar_beam2,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia3 = operations.rotate(pillar_beam3,
                                             transversal=1,
                                             angle='%s *degree' %
                                             truss_rot_degree)

        blade3 = operations.translate(
            pillar_beam3,
            beam='%s *mm' %
            (distance_fr_center_height_main - self.touch_to_halfcircle))
        blade3_dia = operations.translate(pillar_beam_dia3,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        pillar_beam4 = operations.translate(
            pillar_beam3,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia4 = operations.rotate(pillar_beam4,
                                             transversal=1,
                                             angle='%s *degree' %
                                             (truss_rot_degree))

        blade4 = operations.translate(pillar_beam4,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade4_dia = operations.translate(pillar_beam_dia4,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        pillar_beam5 = operations.translate(
            pillar_beam4,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia5 = operations.rotate(pillar_beam5,
                                             transversal=1,
                                             angle='%s *degree' %
                                             (truss_rot_degree))

        blade5 = operations.translate(pillar_beam5,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade5_dia = operations.translate(pillar_beam_dia5,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        pillar_beam6 = operations.translate(
            pillar_beam5,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia6 = operations.rotate(pillar_beam6,
                                             transversal=1,
                                             angle='%s *degree' %
                                             (truss_rot_degree))

        blade6 = operations.translate(pillar_beam6,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade6_dia = operations.translate(pillar_beam_dia6,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        # return (operations.unite(operations.unite(operations.unite(operations.unite(operations.unite(blade1, blade2), blade3), blade4), blade5), blade6))

        pillar_beam7 = operations.translate(
            pillar_beam6,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia7 = operations.rotate(pillar_beam7,
                                             transversal=1,
                                             angle='%s *degree' %
                                             (truss_rot_degree))

        blade7 = operations.translate(pillar_beam7,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade7_dia = operations.translate(pillar_beam_dia7,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        pillar_beam8 = operations.translate(
            pillar_beam7,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia8 = operations.rotate(pillar_beam8,
                                             transversal=1,
                                             angle='%s *degree' %
                                             (truss_rot_degree))

        blade8 = operations.translate(pillar_beam8,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade8_dia = operations.translate(pillar_beam_dia8,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        # return (operations.unite(blade1, blade3))

        pillar_beam9 = operations.translate(
            pillar_beam8,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia9 = operations.rotate(pillar_beam9,
                                             transversal=1,
                                             angle='%s *degree' %
                                             (truss_rot_degree))

        blade9 = operations.translate(pillar_beam9,
                                      beam='%s *mm' %
                                      (distance_fr_center_height_main))
        blade9_dia = operations.translate(pillar_beam_dia9,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))

        pillar_beam10 = operations.translate(
            pillar_beam9,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia10 = operations.rotate(pillar_beam10,
                                              transversal=1,
                                              angle='%s *degree' %
                                              (truss_rot_degree))

        blade10 = operations.translate(pillar_beam10,
                                       beam='%s *mm' %
                                       (distance_fr_center_height_main))
        blade10_dia = operations.translate(pillar_beam_dia10,
                                           beam='%s *mm' %
                                           (distance_fr_center_height_main))

        pillar_beam_last = operations.translate(
            pillar_beam10,
            vertical="%s *mm" %
            -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle))))

        pillar_beam_dia_last = operations.rotate(blade1,
                                                 transversal=1,
                                                 angle='%s *degree' % (90))

        blade_last = operations.translate(pillar_beam_last,
                                          beam='%s *mm' %
                                          (distance_fr_center_height_main))
        blade_last_dia = operations.translate(pillar_beam_dia_last,
                                              beam='%s *mm' %
                                              (distance_fr_center_height_main))

        # blade_last_up = operations.rotate(
        #     operations.rotate(pillar_beam_last, transversal=1, angle='%s *degree' % (-180)), vertical=1,
        #     angle='%s *degree' % 180)
        # return(blade_last)

        blades = [
            vertical_blade,
            blade1_needed,
            blade1_dia,
            blade2,
            blade2_dia,
            blade3,
            blade3_dia,
            blade4,
            blade4_dia,
            blade5,
            blade5_dia,
            blade6,
        ]

        # blades = [vertical_blade, blade1_needed, blade1_dia,blade2, blade2_dia, blade3, blade4,
        #           blade4_dia, blade5,
        #           blade5_dia, blade6, blade6_dia, blade7, ]

        all_blades_down = operations.unite(*blades)

        blades_up = operations.rotate(operations.rotate(all_blades_down,
                                                        transversal=1,
                                                        angle='%s *degree' %
                                                        (-180)),
                                      vertical=1,
                                      angle='%s *degree' % 180)

        # return (blades_up)

        side_cut_box = shapes.block(height='%s *mm' % 10000,
                                    width='%s *mm' % (100),
                                    thickness='%s *mm' %
                                    (self.inner_radius * 2))

        blades_up = operations.subtract(blades_up, side_cut_box)

        # return (operations.unite(blades_up, self.generate_box_toCut_big_end()))

        all_blades = operations.unite(all_blades_down, blades_up)

        # more_blades_up=operations.rotate(
        #     operations.rotate(all_blades, transversal=1, angle='%s *degree' % (-180)), vertical=1,
        #     angle='%s *degree' % 180)

        return (all_blades)
コード例 #20
0
ファイル: Monitor.py プロジェクト: danse-inelastic/instrument
    def identify(self, visitor):
        return visitor.onMonitor(self)

    def __init__(self, name, shape=None, **attributes):
        if shape is None: shape = defaultShape
        Element.__init__(self, name, shape=shape, **attributes)
        return

    pass  # end of Monitor


import instrument.geometry.shapes as shapes

from . import units
cm = units.length.cm
defaultShape = shapes.block(10 * cm, 10 * cm, 1 * cm)


def createNormalMonitor(name,
                        width,
                        height,
                        thickness,
                        mode='monitor',
                        sampledFraction=0.01,
                        **kwds):
    shape = shapes.block(width, height, thickness)
    return Monitor(name,
                   shape=shape,
                   mode=mode,
                   sampledFraction=sampledFraction,
                   **kwds)
コード例 #21
0
    def support_design(self):
        angle = 4

        truss_rot_degree = 5

        main_cylinder_radius = self.inner_radius  # inner radius of the collimator

        main_cylinder_diameter = main_cylinder_radius * 2.
        #
        # support_height = main_cylinder_diameter - self.beam_dist_support
        #
        #
        #
        # distance_fr_center_support = np.sqrt((main_cylinder_radius) ** 2 - (height_support / 2) ** 2)

        base_width_support = self.truss_base_thickness

        suppert_end_distance_fr_source = self.inner_radius + base_width_support

        collimator_thickness_at_support_end = self.angle2span(
            suppert_end_distance_fr_source, self.vertical_acceptance_angle)

        length = 1000.  ## as big as possible
        width = collimator_thickness_at_support_end
        pillar = shapes.block(height='%s *mm' % (length),
                              width='%s *mm' %
                              (collimator_thickness_at_support_end),
                              thickness='%s *mm' % 1)

        pillar_beam = operations.rotate(pillar,
                                        transversal=1,
                                        angle="%s *degree" % 90)

        pillar_beamT = operations.rotate(pillar,
                                         transversal=1,
                                         angle="%s *degree" % 90)

        small_pillar_beam_tocut = operations.rotate(shapes.block(
            height='%s *mm' % (length),
            width='%s *mm' % (width + 5),
            thickness='%s *mm' % 5),
                                                    transversal=1,
                                                    angle="%s *degree" % 90)

        pillar_beam = operations.subtract(
            pillar_beam,
            operations.translate(small_pillar_beam_tocut,
                                 beam='%s*mm' % -(length / 2)))

        pillar_beam_dia = operations.rotate(pillar_beam,
                                            transversal=1,
                                            angle='%s *degree' %
                                            truss_rot_degree)

        number_blades = 10
        vertical_distance = 0
        pillar_beams = []
        pillar_beams_dia = []
        for i in xrange(number_blades):
            pillar_beam = operations.translate(pillar_beam,
                                               vertical="%s *mm" %
                                               -(vertical_distance))
            vertical_distance = length / 2. * np.sin(np.deg2rad(angle))
            # truss_rot_degree = angle*(i/0.2)
            truss_rot_degree = 3
            pillar_beam_dia = operations.rotate(pillar_beam,
                                                transversal=1,
                                                angle='%s *degree' %
                                                truss_rot_degree)
            pillar_beams.append(pillar_beam)
            pillar_beams_dia.append(pillar_beam_dia)

        united_blades = operations.unite(*pillar_beams)
        united_blades_dia = operations.unite(*pillar_beams_dia)

        verticle_pillar = operations.translate(pillar,
                                               beam="%s *mm" %
                                               (self.inner_radius))
        blades = operations.unite(
            operations.unite(united_blades, united_blades_dia),
            verticle_pillar)

        side_cut_box = shapes.block(height='%s *mm' % 10000,
                                    width='%s *mm' % (100),
                                    thickness='%s *mm' %
                                    (self.inner_radius * 2))

        blades_cleanUp = operations.subtract(blades, side_cut_box)

        return (blades_cleanUp)