Ejemplo n.º 1
0
    def vision_piston(self):

        shaft_height = self.piston_shaft_height - self.piston_chamfer_height
        shaft_hollow = self.vision_seat_top_diameter

        chamfer_big_cone_height = (self.piston_chamfer_base / 2.) * np.tan(
            np.deg2rad(self.piston_chamfer_angle))

        subtraction_coneHeight_chamfer = chamfer_big_cone_height - self.piston_chamfer_height

        print('chamfer_top_length',
              (self.piston_chamfer_base / chamfer_big_cone_height) *
              subtraction_coneHeight_chamfer)

        champfer_big_cone = operations.translate(
            shapes.cone(radius='%s *mm' % (self.piston_chamfer_base / 2.),
                        height='%s *mm' % (chamfer_big_cone_height)),
            vertical='%s *mm' % (-(chamfer_big_cone_height)))

        subtraction_cone_chamfer = operations.translate(
            shapes.cone(radius='%s *mm' % (500.),
                        height='%s *mm' % (subtraction_coneHeight_chamfer)),
            vertical='%s *mm' % (-(subtraction_coneHeight_chamfer)))

        chamfer_atCenter = operations.translate(
            operations.subtract(champfer_big_cone, subtraction_cone_chamfer),
            vertical='%s *mm' % (subtraction_coneHeight_chamfer))
        ##### SHAFT #########
        shaft_solid = shapes.cylinder(radius='%s *mm' %
                                      (self.piston_chamfer_base / 2.),
                                      height='%s *mm' % (shaft_height))

        shaft_in_place = operations.translate(
            shaft_solid,
            vertical='%s *mm' %
            (-(shaft_height / 2. + self.piston_chamfer_height)))

        #### CHAMFER+SHAFET ####

        chamfer_shaft = operations.unite(chamfer_atCenter, shaft_in_place)
        subtraction_cylinder_shaft = shapes.cylinder(radius='%s *mm' %
                                                     (shaft_hollow / 2.),
                                                     height='%s *mm' % (500))

        piston_down_center = operations.subtract(chamfer_shaft,
                                                 subtraction_cylinder_shaft)
        return (piston_down_center)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
    def test(self):
        """
        instrument.geometry.pml.render
        """
        import numpy as np
        from instrument.geometry.pml import weave
        from instrument.geometry import shapes, operations
        cone = shapes.cone(radius="10.*mm", height="110.*mm")
        cone_along_beam = operations.rotate(cone,
                                            transversal="1",
                                            angle="90.*deg")
        angles = np.arange(-160, 0., 15.)
        cones = [
            operations.rotate(cone_along_beam,
                              vertical="1",
                              angle='%s*deg' % a) for a in angles
        ]
        channels = operations.unite(*cones)

        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('collimator2.xml', 'wt'),
                     print_docs=False,
                     renderer=Renderer(),
                     author='')
        return
Ejemplo n.º 5
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
Ejemplo n.º 6
0
 def notify(self, parent):
     cone = shapes.cone(radius=self._radius, height=self._height)
     parent.onCone(cone)
     return
Ejemplo n.º 7
0
    def anvil(self, girdle_length=6.):

        crown_top_triangle_height = self.crown_top_triangle_height()

        crown_total_triangle_height = self.crown_total_triangle_height(
            girdle_length)

        pavilion_bottom_triangle_height = self.pavilion_bottom_triangle_height(
        )

        print('pavilion from center', pavilion_bottom_triangle_height)

        pavilion_total_triangle_height = self.pavilion_total_triangle_height(
            girdle_length)

        upper_orLower_anvil_height_from_center = self.upper_orLower_anvil_height_from_center(
        )

        crown_top_cone = operations.translate(
            shapes.cone(radius='%s *mm' % 500,
                        height='%s*mm' % (crown_top_triangle_height)),
            vertical='%s *mm' % (-crown_top_triangle_height))

        crown_total_cone = operations.translate(
            shapes.cone(radius='%s*mm' % (girdle_length / 2, ),
                        height='%s*mm' % crown_total_triangle_height),
            vertical='%s *mm' % (-crown_total_triangle_height))

        crown = operations.subtract(crown_total_cone, crown_top_cone)

        pavilion_bottom_cone = operations.translate(
            shapes.cone(radius='%s *mm' % 500.,
                        height='%s*mm' % (pavilion_bottom_triangle_height)),
            vertical='%s *mm' % (-pavilion_bottom_triangle_height))

        pavilion_total_cone = operations.translate(
            shapes.cone(radius='%s*mm' % (girdle_length / 2),
                        height='%s*mm' % pavilion_total_triangle_height),
            vertical='%s *mm' % (-pavilion_total_triangle_height))

        pavilion = operations.rotate(operations.subtract(
            pavilion_total_cone, pavilion_bottom_cone),
                                     transversal=1,
                                     angle='%s *degree' % (180))

        girdle = shapes.cylinder(radius='%s*mm' % (girdle_length / 2.),
                                 height='%s*mm' % (self.girdle_height))
        girdle_inplace = operations.translate(
            girdle,
            vertical='%s *mm' %
            (pavilion_total_triangle_height + self.girdle_height / 2.))
        crown_inplace = operations.translate(
            crown,
            vertical='%s *mm' %
            (pavilion_total_triangle_height + self.girdle_height +
             crown_total_triangle_height))

        upper_diamond_anvil = operations.unite(
            operations.unite(crown_inplace, girdle_inplace), pavilion)

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

        # return (operations.unite(upper_diamond_anvil, lower_diamond_anvil))
        #### the following is for changing the gap between two anvil ##########

        upper_diamond_anvil_at_center = operations.translate(
            upper_diamond_anvil,
            vertical='%s *mm' % (-pavilion_bottom_triangle_height))

        upper_diamond_anvil_at_positive_pt_one_from_center = operations.translate(
            upper_diamond_anvil_at_center,
            vertical='%s *mm' % (self.sample_height / 2.))

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

        return (operations.unite(
            upper_diamond_anvil_at_positive_pt_one_from_center,
            lower_diamond_anvil_at_neg_pt_one_from_center))
Ejemplo n.º 8
0
    def vision_seat(self):
        seat_hollow_angle = self.table_angle

        seat_larger_cone_height = (self.vision_seat_bottom_diameter/ 2) / \
                                        np.tan(np.deg2rad(self.vision_seat_skirt_angle / 2))

        # seat_smaller_cone_height = (self.vision_seat_skirt_height * self.seat_top_diameter) / \
        #                            (self.seat_bottom_diameter - self.seat_top_diameter)

        seat_smaller_cone_height = seat_larger_cone_height - self.vision_seat_skirt_height

        seat_hollow_large_cone_height_at_top_seat = ((self.vision_seat_hollow_top_diamter) / 2) / \
                                        np.tan(np.deg2rad(seat_hollow_angle / 2))

        seat_hollow_large_cone_height = seat_hollow_large_cone_height_at_top_seat + 50

        seat_hollow_large_cone_diameter = 2 * seat_hollow_large_cone_height * np.tan(
            np.deg2rad(seat_hollow_angle / 2))

        # cone has to be translated to center and after translation, the cone is in the negative Y direction
        seat_cone_to_subtract = operations.translate(
            shapes.cone(radius='%s *mm' % (self.seat_top_diameter / 2. + 500.),
                        height='%s *mm' % (seat_smaller_cone_height)),
            vertical='%s *mm' % (-seat_smaller_cone_height))

        seat_larger_cone = operations.translate(shapes.cone(
            radius='%s *mm' % (self.vision_seat_bottom_diameter / 2.),
            height='%s *mm' % (seat_larger_cone_height)),
                                                vertical='%s *mm' %
                                                (-seat_larger_cone_height))

        solid_seat_not_atCenter = operations.subtract(seat_larger_cone,
                                                      seat_cone_to_subtract)

        solid_seat_at_center = operations.translate(
            solid_seat_not_atCenter,
            vertical='%s *mm' %
            (seat_smaller_cone_height))  # solid seat at center(0,0)

        ######## HOLLOW TAPPERED CONE #########
        seat_hollow_large_cone = operations.translate(
            shapes.cone(radius='%s *mm' %
                        ((seat_hollow_large_cone_diameter) / 2.),
                        height='%s *mm' % (seat_hollow_large_cone_height)),
            vertical='%s *mm' % (-(seat_hollow_large_cone_height)))

        # invert the tappered hollow

        seat_tappered_hollow = operations.translate(
            operations.rotate(seat_hollow_large_cone,
                              transversal=1,
                              angle='%s *degree' % (-180)),
            vertical='%s *mm' % (-seat_hollow_large_cone_height_at_top_seat))

        hollow_seat = operations.subtract(solid_seat_at_center,
                                          seat_tappered_hollow)

        smaller_saft_to_drill = shapes.cylinder(
            radius='%s *mm' % (self.vision_seat_hollow_bottom_diameter / 2.),
            height='%s *mm' % (self.vision_seat_shaft_height + 100.))

        seat_withSmall_hollow_shaft = operations.subtract(
            hollow_seat, smaller_saft_to_drill)

        ######## CYLINDER SHAFT #############
        solid_shaft = shapes.cylinder(
            radius='%s *mm' % (self.vision_seat_shaft_diameter / 2.),
            height='%s *mm' % (self.vision_seat_shaft_height))

        shaft_to_drill = shapes.cylinder(
            radius='%s *mm' % (self.vision_seat_hollow_bottom_diameter / 2.),
            height='%s *mm' % (self.seat_shaft_height + 100.))

        hollow_shaft_atCenter = operations.translate(
            operations.subtract(solid_shaft, shaft_to_drill),
            vertical='%s *mm' % (-self.vision_seat_shaft_height / 2.))

        hollow_shaft_atSkirt = operations.translate(
            hollow_shaft_atCenter,
            vertical='%s *mm' % (-self.vision_seat_skirt_height))

        ######## COMBINING  SEAT AND SHAFT #############
        seat_shaft_down_center = operations.unite(seat_withSmall_hollow_shaft,
                                                  hollow_shaft_atSkirt)

        return (seat_shaft_down_center)