def pillbox_cavity_model(input_parameters):
    """ Generates the geometry for the pillbox cavity in FreeCAD. Also writes out the geometry as STL files 
       and writes a "sidecar" text file containing the input parameters used.

         Args:
            input_parameters (dict): Dictionary of input parameter names and values.
        """

    try:
        wire1, face1 = make_circular_aperture(input_parameters['pipe_radius'])
        wire2, face2 = make_circular_aperture(
            input_parameters['cavity_radius'])
        beampipe_vacuum1 = make_beampipe(
            face1, input_parameters['pipe_length'],
            (-input_parameters['pipe_length'] / 2. -
             input_parameters['cavity_length'] / 2., 0, 0))
        cavity_vacuum = make_beampipe(face2, input_parameters['cavity_length'])
        beampipe_vacuum2 = make_beampipe(
            face1, input_parameters['pipe_length'],
            (input_parameters['pipe_length'] / 2. +
             input_parameters['cavity_length'] / 2., 0, 0))

        vac1 = beampipe_vacuum1.fuse(cavity_vacuum)
        vac2 = vac1.fuse(beampipe_vacuum2)

        wire3, face3 = make_circular_aperture(
            input_parameters['pipe_radius'] +
            input_parameters['wall_thickness'])
        wire4, face4 = make_circular_aperture(
            input_parameters['cavity_radius'] +
            input_parameters['wall_thickness'])
        beampipe_shell1 = make_beampipe(
            face3, input_parameters['pipe_length'],
            (-input_parameters['pipe_length'] / 2. -
             input_parameters['cavity_length'] / 2., 0, 0))
        cavity_shell = make_beampipe(
            face4, input_parameters['cavity_length'] +
            2 * input_parameters['wall_thickness'])
        beampipe_shell2 = make_beampipe(
            face3, input_parameters['pipe_length'],
            (input_parameters['pipe_length'] / 2. +
             input_parameters['cavity_length'] / 2., 0, 0))

        shell1 = beampipe_shell1.fuse(cavity_shell)
        shell2 = shell1.fuse(beampipe_shell2)
        shell3 = shell2.cut(vac2)
    except Exception as e:
        raise ModelException(e)
    # An entry in the parts dictionary corresponds to an STL file. This is useful for parts of differing materials.
    parts = {'vac': vac2, 'shell': shell3}
    return parts, os.path.splitext(os.path.basename(MODEL_NAME))[0]
示例#2
0
def simple_buttons_model(input_parameters):
    """ Generates the geometry for the pillbox cavity in FreeCAD. Also writes out the geometry as STL files 
       and writes a "sidecar" text file containing the input parameters used.

         Args:
            input_parameters (dict): Dictionary of input parameter names and values.
        """

    try:
        wire1, face1 = make_elliptical_aperture(input_parameters['pipe_height'], input_parameters['pipe_width'])
        wire2, face2 = make_elliptical_aperture(input_parameters['pipe_height'] + input_parameters['pipe_thickness'],
                                                input_parameters['pipe_width'] + input_parameters['pipe_thickness'])
        beampipe_vac = make_beampipe(face1, input_parameters['pipe_length'] + 2e-3)
        beampipe = make_beampipe(face2, input_parameters['pipe_length'])

        block = Part.makeCylinder(input_parameters['block_radius'], input_parameters['block_s'],
                                  Base.Vector(-input_parameters['block_s'] / 2., 0, 0),
                                  Base.Vector(1, 0, 0)
                                  )

        hole1 = single_button_hole(input_parameters, quadrants=(1, 1, 1))
        hole2 = single_button_hole(input_parameters, quadrants=(-1, 1, -1))
        hole3 = single_button_hole(input_parameters, quadrants=(-1, -1, 1))
        hole4 = single_button_hole(input_parameters, quadrants=(1, -1, -1))

        vac1 = beampipe_vac.fuse(hole1)
        vac2 = vac1.fuse(hole2)
        vac3 = vac2.fuse(hole3)
        vac4 = vac3.fuse(hole4)

        button_block = block.cut(vac4)

        beampipe1 = beampipe.cut(block)
        beampipe2 = beampipe1.cut(beampipe_vac)

        button1, pin1, ceramic1, shell1 = single_button(input_parameters, quadrants=(1, 1, 1))
        button2, pin2, ceramic2, shell2 = single_button(input_parameters, quadrants=(-1, 1, -1))
        button3, pin3, ceramic3, shell3 = single_button(input_parameters, quadrants=(-1, -1, 1))
        button4, pin4, ceramic4, shell4 = single_button(input_parameters, quadrants=(1, -1, -1))

    except Exception as e:
        raise ModelException(e)
    # An entry in the parts dictionary corresponds to an STL file. This is useful for parts of differing materials.
    parts = {'vac': vac4, 'block': button_block, 'beampipe': beampipe2,
             'button1': button1, 'pin1': pin1, 'ceramic1': ceramic1, 'shell1': shell1,
             'button2': button2, 'pin2': pin2, 'ceramic2': ceramic2, 'shell2': shell2,
             'button3': button3, 'pin3': pin3, 'ceramic3': ceramic3, 'shell3': shell3,
             'button4': button4, 'pin4': pin4, 'ceramic4': ceramic4,  'shell4': shell4
             }
    # 'hole1': hole1, 'hole2': hole2, 'hole3': hole3, 'hole4': hole4
    return parts, os.path.splitext(os.path.basename(MODEL_NAME))[0]
def racetrack_taper_model(input_parameters):
    """Generates the geometry for the racetrack shadowing taper in FreeCAD. 
       Also writes out the geometry as STL files 
       and writes a "sidecar" text file containing the input parameters used.

         Args:
            input_parameters (dict): Dictionary of input parameter names and values.
        """
    try:
        wire1, face1 = make_racetrack_aperture(input_parameters['pipe_height'],
                                               input_parameters['pipe_width'])
        wire2, face2 = make_racetrack_aperture(
            input_parameters['cavity_height'],
            input_parameters['cavity_width'])
        beampipe1 = make_beampipe(
            face1, input_parameters['pipe_length'],
            (-input_parameters['pipe_length'] / 2. -
             input_parameters['taper_length'] -
             input_parameters['cavity_length'] / 2., 0, 0))
        taper1 = make_taper(wire2, wire1, input_parameters['taper_length'],
                            (-input_parameters['cavity_length'] / 2., 0, 0),
                            (0, 180, 0))
        beampipe2 = make_beampipe(face2, input_parameters['cavity_length'])
        taper2 = make_taper(wire2, wire1, input_parameters['taper_length'],
                            (input_parameters['cavity_length'] / 2., 0, 0))
        beampipe3 = make_beampipe(
            face1, input_parameters['pipe_length'],
            (input_parameters['pipe_length'] / 2. +
             input_parameters['taper_length'] +
             input_parameters['cavity_length'] / 2., 0, 0))
        fin1 = beampipe1.fuse(taper1)
        fin2 = fin1.fuse(beampipe2)
        fin3 = fin2.fuse(taper2)
        fin4 = fin3.fuse(beampipe3)
    except Exception as e:
        raise ModelException(e)
    # An entry in the parts dictionary corresponds to an STL file. This is useful for parts of differing materials.
    parts = {'all': fin4}
    return parts, os.path.splitext(os.path.basename(MODEL_NAME))[0]
def racetrack_to_octagonal_cavity_model(input_parameters):
    """Generates the geometry for a circular cavity with tapers to a racetrack pipe in FreeCAD. 
       Also writes out the geometry as STL files 
       and writes a "sidecar" text file containing the input parameters used.

         Args:
            input_parameters (dict): Dictionary of input parameter names and values.
        """
    try:
        wire1, face1 = make_racetrack_aperture(
            input_parameters['racetrack_height'],
            input_parameters['racetrack_width'])
        wire2, face2 = make_circular_aperture(
            input_parameters['cavity_radius'])
        wire3, face3 = make_racetrack_aperture(
            input_parameters['racetrack_height'] +
            input_parameters['pipe_thickness'],
            input_parameters['racetrack_width'] +
            input_parameters['pipe_thickness'])
        wire4, face4 = make_circular_aperture(
            input_parameters['cavity_radius'] +
            input_parameters['pipe_thickness'])
        beampipe_vac1 = make_beampipe(
            face1, input_parameters['racetrack_length'],
            (-input_parameters['racetrack_length'] / 2. -
             input_parameters['taper_length'] -
             input_parameters['cavity_length'] / 2., 0, 0))
        taper_vac1 = make_taper(
            wire2, wire1, input_parameters['taper_length'],
            (-input_parameters['cavity_length'] / 2., 0, 0), (0, 180, 0))
        beampipe_vac2 = make_beampipe(face2, input_parameters['cavity_length'])
        taper_vac2 = make_taper(wire2, wire1, input_parameters['taper_length'],
                                (input_parameters['cavity_length'] / 2., 0, 0))
        beampipe_vac3 = make_beampipe(
            face1, input_parameters['racetrack_length'],
            (input_parameters['racetrack_length'] / 2. +
             input_parameters['taper_length'] +
             input_parameters['cavity_length'] / 2., 0, 0))
        beampipe1 = make_beampipe(
            face3, input_parameters['racetrack_length'],
            (-input_parameters['racetrack_length'] / 2. -
             input_parameters['taper_length'] -
             input_parameters['cavity_length'] / 2., 0, 0))
        taper1 = make_taper(wire4, wire3, input_parameters['taper_length'],
                            (-input_parameters['cavity_length'] / 2., 0, 0),
                            (0, 180, 0))
        beampipe2 = make_beampipe(face4, input_parameters['cavity_length'])
        taper2 = make_taper(wire4, wire3, input_parameters['taper_length'],
                            (input_parameters['cavity_length'] / 2., 0, 0))
        beampipe3 = make_beampipe(
            face3, input_parameters['racetrack_length'],
            (input_parameters['racetrack_length'] / 2. +
             input_parameters['taper_length'] +
             input_parameters['cavity_length'] / 2., 0, 0))
        fin1 = beampipe1.fuse(taper1)
        fin2 = fin1.fuse(beampipe2)
        fin3 = fin2.fuse(taper2)
        fin4 = fin3.fuse(beampipe3)

        vac1 = beampipe_vac1.fuse(taper_vac1)
        vac2 = vac1.fuse(beampipe_vac2)
        vac3 = vac2.fuse(taper_vac2)
        vac4 = vac3.fuse(beampipe_vac3)

        full_pipe = fin4.cut(vac4)
    except Exception as e:
        raise ModelException(e)
    # An entry in the parts dictionary corresponds to an STL file. This is useful for parts of differing materials.
    parts = {'pipe': full_pipe, 'vac': vac4}
    return parts, os.path.splitext(os.path.basename(MODEL_NAME))[0]
示例#5
0
def simple_stripline_model(input_parameters):
    """ Generates the geometry for a simplified stripline in FreeCAD. Also writes out the geometry as STL files 
       and writes a "sidecar" text file containing the input parameters used.

         Args:
            input_parameters (dict): Dictionary of input parameter names and values.
        """

    try:
        # Make cavity
        wire1, face1 = make_circular_aperture(input_parameters['pipe_radius'])
        wire2, face2 = make_circular_aperture(
            input_parameters['cavity_radius'])
        beampipe1 = make_beampipe(
            face1, input_parameters['pipe_length'],
            (-input_parameters['pipe_length'] / 2. -
             input_parameters['cavity_length'] / 2., 0, 0))
        beampipe3 = make_beampipe(
            face1, input_parameters['pipe_length'],
            (input_parameters['pipe_length'] / 2. +
             input_parameters['cavity_length'] / 2., 0, 0))
        beampipe2 = make_beampipe(face2, input_parameters['cavity_length'])
        fin1 = beampipe1.fuse(beampipe2)
        outer = fin1.fuse(beampipe3)

        # Basic feedthrough
        cylinder1 = Part.makeCylinder(
            input_parameters['feedthrough_hole_radius'], 100,
            Base.Vector(-input_parameters['port_offset'], -35, 0),
            Base.Vector(0, -1, 0))
        cylinder2 = Part.makeCylinder(
            input_parameters['feedthrough_hole_radius'], 100,
            Base.Vector(input_parameters['port_offset'], -35, 0),
            Base.Vector(0, -1, 0))
        cylinder3 = Part.makeCylinder(
            input_parameters['feedthrough_hole_radius'], 100,
            Base.Vector(-input_parameters['port_offset'], 35, 0),
            Base.Vector(0, 1, 0))
        cylinder4 = Part.makeCylinder(
            input_parameters['feedthrough_hole_radius'], 100,
            Base.Vector(input_parameters['port_offset'], 35, 0),
            Base.Vector(0, 1, 0))
        # Pins
        pin1 = Part.makeCylinder(
            input_parameters['feedthrough_pin_radius'],
            input_parameters['cavity_radius'] -
            input_parameters['stripline_offset'],
            Base.Vector(-input_parameters['port_offset'], -30, 0),
            Base.Vector(0, -1, 0))
        pin2 = Part.makeCylinder(
            input_parameters['feedthrough_pin_radius'],
            input_parameters['cavity_radius'] -
            input_parameters['stripline_offset'],
            Base.Vector(input_parameters['port_offset'], -30, 0),
            Base.Vector(0, -1, 0))
        pin3 = Part.makeCylinder(
            input_parameters['feedthrough_pin_radius'],
            input_parameters['cavity_radius'] -
            input_parameters['stripline_offset'],
            Base.Vector(-input_parameters['port_offset'], 30, 0),
            Base.Vector(0, 1, 0))
        pin4 = Part.makeCylinder(
            input_parameters['feedthrough_pin_radius'],
            input_parameters['cavity_radius'] -
            input_parameters['stripline_offset'],
            Base.Vector(input_parameters['port_offset'], 30, 0),
            Base.Vector(0, 1, 0))

        # Basic striplines
        stripline1 = Part.makeBox(
            input_parameters['stripline_length'], 2,
            input_parameters['stripline_width'],
            Base.Vector(-input_parameters['stripline_length'] / 2., 30,
                        -input_parameters['stripline_width'] / 2.))
        stripline2 = Part.makeBox(
            input_parameters['stripline_length'], 2,
            input_parameters['stripline_width'],
            Base.Vector(-input_parameters['stripline_length'] / 2., -30,
                        -input_parameters['stripline_width'] / 2.))

        diff3 = outer.cut(cylinder1)
        diff4 = diff3.cut(cylinder2)
        diff5 = diff4.cut(cylinder3)
        diff6 = diff5.cut(cylinder4)

        pins = pin1.fuse(pin2)
        pins = pins.fuse(pin3)
        pins = pins.fuse(pin4)

        striplines = stripline1.fuse(stripline2)

    except Exception as e:
        raise ModelException(e)
    # An entry in the parts dictionary corresponds to an STL file. This is useful for parts of differing materials.
    parts = {'cavity': diff6, 'striplines': striplines, 'pins': pins}
    return parts, os.path.splitext(os.path.basename(MODEL_NAME))[0]