def solid_pyramid(self): """ Returns ------- """ 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 = shapes.pyramid( thickness='%s *mm' % (thickness), # height='%s *mm' % (height), height='%s *mm' % (height), width='%s *mm' % width) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) return (pyr)
def notify(self, parent): pyramid = shapes.pyramid( thickness=self._thickness, width = self._width, height = self._height ) parent.onPyramid(pyramid) return
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
def generate_oneside_discrete_vertical_channel_left_borders(self): r""" Generate the list of the vertical channels left borders". (left or right??., please check with figures) Return ---------- list of vertical channel left borders (largest dimension in vertical direction) """ if self.collimator_height_detector > self.collimator_width_detector: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 else: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 self.vertical_channel_angle = self.span2angle( self.channel_height, self.collimator_front_end_from_center) arc_width = height * np.deg2rad(self.vertical_channel_angle) thickness = self.blade_width pyr = shapes.pyramid(thickness='%s *mm' % (thickness), height='%s *mm' % (height), width='%s *mm' % (arc_width)) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) pyl_beam_vertical = operations.rotate(pyr, beam=1, angle='%s *degree' % (90)) horizontal_pillar_extreme_angle_list = self.horizontal_pillar_angle_list( )[0] # [self.horizontal_pillar_min_angle, self.horizontal_pillar_max_angle] one_channel_border = operations.rotate( pyl_beam_vertical, vertical="1", angle='%s*deg' % horizontal_pillar_extreme_angle_list) all_channel_borders = [ operations.rotate(one_channel_border, transversal="1", angle='%s*deg' % a) for a in self.vertical_pillar_angle_list() ] return (all_channel_borders)
def generate_oneside_discrete_vertical_channel_right_borders(self): r""" Generate the list of the vertical channels right borders". Return ---------- list of vertical channel right borders (largest dimension in vertical direction) """ if self.max_coll_height_detector > self.max_coll_width_detector: height = self.horizontal_outer_radius * 1.2 else: height = self.vertical_outer_radius * 1.2 arc_width = height * np.deg2rad(self.vertical_channel_angle) thickness = self.wall_thickness pyr = shapes.pyramid(thickness='%s *mm' % (thickness), height='%s *mm' % (height), width='%s *mm' % (arc_width)) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) pyl_beam_vertical = operations.rotate(pyr, beam=1, angle='%s *degree' % (90)) horizontal_pillar_extreme_angle_list = self.horizontal_pillar_max_angle one_channel_border = operations.rotate( pyl_beam_vertical, vertical="1", angle='%s*deg' % horizontal_pillar_extreme_angle_list) all_channel_borders = [ operations.rotate(one_channel_border, transversal="1", angle='%s*deg' % a) for a in self.vertical_pillar_angle_list ] return (all_channel_borders)
def generate_oneside_discrete_horizontal_channel_bottom_borders(self): r""" Generate the list of the horizontal channels bottom borders". Return ---------- list of horizontal channel bottom borders (largest dimension in horizontal direction) """ if self.collimator_height_detector > self.collimator_width_detector: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 else: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 arc_width = height * np.deg2rad(self.horizontal_channel_angle) thickness = self.blade_width pyr = shapes.pyramid(thickness='%s *mm' % (thickness), height='%s *mm' % (height), width='%s *mm' % (arc_width)) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) vertical_blade_extreme_angle_list = self.vertical_pillar_angle_list[-1] one_channel_border = operations.rotate( pyr, transversal="1", angle='%s*deg' % vertical_blade_extreme_angle_list) all_channel_borders = [ operations.rotate(one_channel_border, vertical="1", angle='%s*deg' % a) for a in self.horizontal_pillar_angle_list() ] return (all_channel_borders)
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
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))