def make_slits_reservoir(self, nslit, pitch, width, contact_distance, layers): # 5 additional slits as material reservoir res_slit = 5 gap = contact_distance + 2. + 2. res_length = (length - gap - 2.5*margin)/2 res_width = width res_pitch = pitch resField = Cell("resField") reservoir = Cell("Single Reservoir") res_path = Path([(-res_length / 2., 0), (res_length / 2., 0)], width = res_width, layer = layers) reservoir.add(res_path) reservoirs= CellArray(reservoir, 2, res_slit, spacing = (res_length + gap, res_pitch)) reservoirs.translate((-(res_length + gap)/2,0)) res_array = Cell("Multiple Slit") res_array.add(reservoirs) resField.add(res_array, origin=(0,0), rotation=rot_angle) if contact_distance > margin: add_slit = Cell("Additional Reservoir") add_res_path = Path([(-(contact_distance - 0.8*margin) / 2., 0), ((contact_distance - 0.8*margin) / 2., 0)], width = res_width, layer = layers) add_slit.add(add_res_path) add_reservoir = CellArray(add_slit, 1, res_slit, spacing = (0, res_pitch)) add_reservoir.translate((0,0)) add_res_array = Cell("Additional Multiple Slit") add_res_array.add(add_reservoir) resField.add(add_res_array, origin=(0,0), rotation=rot_angle) self.add(resField, origin= (0,(nslit+1) * pitch/2 )) self.add(resField, origin= (0, -((nslit+1+(2*(res_slit-1))) * pitch/2 )))
def make_branch_device_array(self, spacing, _widths, array_height, array_width, array_spacing, len_inner, len_outer, n_membranes, layers): if not (type(layers) == list): layers = [layers] if not (type(_widths) == list): _widths = [_widths] for l in layers: i = -1 j = 0 manydevices = Cell("ManyDevices") for width in _widths: device = self.make_branch_device(width, spacing, len_inner, len_outer, n_membranes, l) [[x_min, y_min], [x_max, y_max]] = device.bounding_box x_size = abs(x_max - x_min) y_size = abs(y_max - y_min) i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left nx = int(array_width / (x_size + spacing)) ny = int(array_height / (y_size + spacing)) devices = CellArray(device, nx, ny, (x_size + spacing, y_size + spacing)) devices.translate((-(nx - 1) * (x_size + spacing) / 2., -(ny - 1) * (y_size + spacing) / 2.)) device_array = Cell("DeviceArray") device_array.add(devices) # Make the labels for each array of devices text = Label( 'w/s/l\n%i/%.1f/%i' % (width * 1000, spacing, len_outer), 5) lbl_vertical_offset = 1.40 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -array_height / lbl_vertical_offset))) ) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, array_height / lbl_vertical_offset))) ) # Center justify label # TODO: Finish this below device_array.add(text) manydevices.add( device_array, origin=((array_width + array_spacing) * i, (array_height + 2. * array_spacing) * j - array_spacing / 2.)) self.add(manydevices, origin=(-i * (array_width + array_spacing) / 2, -(j + 1.5) * (array_height + array_spacing) / 2))
def make_slit_array(self, _pitches, spacing, _widths, _lengths, rot_angle, array_height, array_width, array_spacing, layers): if not (type(layers) == list): layers = [layers] if not (type(_pitches) == list): _pitches = [_pitches] if not (type(_lengths) == list): _lengths = [_lengths] if not (type(_widths) == list): _widths = [_widths] manyslits = i = j = None for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") pitch = _pitches[0] for length in _lengths: j += 1 i = -1 for width in _widths: # for pitch in pitches: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left pitch_v = pitch / np.cos(np.deg2rad(rot_angle)) # widthV = width / np.cos(np.deg2rad(rotAngle)) nx = int(array_width / (length + spacing)) ny = int(array_height / pitch_v) # Define the slits slit = Cell("Slits") rect = Rectangle((-length / 2., -width / 2.), (length / 2., width / 2.), layer=l) rect = rect.copy().rotate(rot_angle) slit.add(rect) slits = CellArray(slit, nx, ny, (length + spacing, pitch_v)) slits.translate((-(nx - 1) * (length + spacing) / 2., -(ny - 1) * pitch_v / 2.)) slit_array = Cell("SlitArray") slit_array.add(slits) text = Label('w/p/l\n%i/%i/%i' % (width * 1000, pitch, length), 5, layer=l) lbl_vertical_offset = 1.35 if j % 2 == 0: text.translate( tuple(np.array(-text.bounding_box.mean(0)) + np.array(( 0, -array_height / lbl_vertical_offset)))) # Center justify label else: text.translate( tuple(np.array(-text.bounding_box.mean(0)) + np.array(( 0, array_height / lbl_vertical_offset)))) # Center justify label slit_array.add(text) manyslits.add(slit_array, origin=((array_width + array_spacing) * i, ( array_height + 2. * array_spacing) * j - array_spacing / 2.)) self.add(manyslits, origin=(-i * (array_width + array_spacing) / 2, -(j + 1.5) * ( array_height + array_spacing) / 2))
def slit_elongation_array(pitches, spacing, widths, lengths, rot_angle, array_height, array_spacing, layers): if not (type(layers) == list): layers = [layers] if not (type(pitches) == list): pitches = [pitches] if not (type(lengths) == list): lengths = [lengths] if not (type(widths) == list): widths = [widths] for l in layers: j = -1 manyslits = Cell("SlitArray") slitarray = Cell("SlitArray") pitch = pitches[0] width = widths[0] j += 1 i = -1 x_length = 0 slit = Cell("Slits") for length in lengths: spacing = length / 5. + 0.1 i += 1 pitch_v = pitch / np.cos(np.deg2rad(rot_angle)) n_y = int(array_height / pitch_v) # Define the slits if x_length == 0: translation = (length / 2., 0) x_length += length else: translation = (x_length + spacing + length / 2., 0) x_length += length + spacing pt1 = np.array((-length / 2., -width / 2.)) + translation pt2 = np.array((length / 2., width / 2.)) + translation rect = Rectangle(pt1, pt2, layer=l) rect = rect.copy().rotate(rot_angle) slit.add(rect) slits = CellArray(slit, 1, n_y, (0, pitch_v)) slits.translate( (-slits.bounding_box[1, 0] / 2., -slits.bounding_box[1, 1] / 2.)) slitarray.add(slits) text = Label('w/p\n%i/%i' % (width * 1000, pitch * 1000), 2, layer=l_smBeam) lbl_vert_offset = 1.4 text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, array_height / lbl_vert_offset)))) # Center justify label slitarray.add(text) manyslits.add(slitarray) return manyslits
def processCheck_Slits(self, position, arrayWidth, slitWidth, pitch, length, rotation, layers): if not (type(layers) == list): layers = [layers] Nx = int(arrayWidth / pitch) Ny = 1 for l in layers: # Define the slits slit = Cell("Slits") rect = Rectangle((-slitWidth / 2., -length / 2.), (slitWidth / 2., length / 2.), layer=l) slit.add(rect) slits = CellArray(slit, Nx, Ny, (pitch, 0)) slits.translate((-(Nx) * (pitch) / 2., 0.)) slits.translate(position) slitarray = Cell("ProcessCheckingSlits") slitarray.add(slits) self.add(slitarray)
def make_slits(self, length, width, nslit, pitch, rot_angle, layers): """ Define a single slit or a slit array with a given length, width and pitch """ slitField = Cell("slitField") slit = Cell("Single Slit") slit_path = Path([(-length / 2., 0), (length / 2., 0)], width = width, layer = layers) slit.add(slit_path) if nslit == 1: slitField.add(slit, origin=(0,0), rotation=rot_angle) elif nslit > 1: slits = CellArray(slit, 1, nslit, (0,pitch)) slits.translate((0, -(nslit-1) * pitch / 2.)) slit_array = Cell("Multiple Slit") slit_array.add(slits) slitField.add(slit_array, origin=(0,0), rotation=rot_angle) else: print("Error in the number of slits. Check the internal code"*50) quit() self.add(slitField)
def make_slit_array(self, _pitches, spacing, _widths, _lengths, rot_angle, array_height, array_width, array_spacing, layers): if not (type(layers) == list): layers = [layers] if not (type(_pitches) == list): _pitches = [_pitches] if not (type(_lengths) == list): _lengths = [_lengths] if not (type(_widths) == list): _widths = [_widths] manyslits = i = j = None for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") pitch = _pitches[0] for length in _lengths: j += 1 i = -1 for width in _widths: # for pitch in pitches: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left nx = int(array_width / (length + spacing)) ny = int(array_height / pitch) # Define the slits slit = Cell("Slits") rect = Rectangle((-length / 2., -width / 2.), (length / 2., width / 2.), layer=l) slit.add(rect) slits = CellArray(slit, nx, ny, (length + spacing, pitch)) slits.translate((-(nx - 1) * (length + spacing) / 2., -(ny - 1) * pitch / 2.)) slit_array = Cell("SlitArray") slit_array.add(slits) text = Label('w/p/l\n%i/%i/%i' % (width * 1000, pitch, length), 5, layer=l) lbl_vertical_offset = 1.35 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -array_height / lbl_vertical_offset)) )) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, array_height / lbl_vertical_offset )))) # Center justify label slit_array.add(text) manyslits.add( slit_array, origin=((array_width + array_spacing) * i, (array_height + 2. * array_spacing) * j - array_spacing / 2.)) # This is an ugly hack to center rotated slits, should fix this properly... hacky_offset_x = 200 if rot_angle == 45 else 0 # TODO: fix this ugly thing hacky_offset_y = -25 if rot_angle == 45 else 0 self.add(manyslits, origin=(-i * (array_width + array_spacing) / 2 + hacky_offset_x, -(j + 1.5) * (array_height + array_spacing) / 2 + hacky_offset_y), rotation=rot_angle)
def make_slit_array(x_vars, y_vars, stat_vars, var_names, spacing, rot_angle, array_height, array_width, array_spacing, layers): if len(var_names) != 3: raise Exception('Error! Need to have three variable names.') if not (type(layers) == list): layers = [layers] if not (type(x_vars) == list): x_vars = [x_vars] if not (type(y_vars) == list): y_vars = [y_vars] if not (type(stat_vars) == list): stat_vars = [stat_vars] x_var_name = var_names[0] y_var_name = var_names[1] stat_var_name = var_names[2] for l in layers: j = -1 manyslits = Cell("SlitArray") for x_var in x_vars: j += 1 i = -1 for y_var in y_vars: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left var_dict = { x_var_name: x_var, y_var_name: y_var, stat_var_name: stat_vars[0] } pitch = var_dict['pitch'] width = var_dict['width'] length = var_dict['length'] pitch_v = pitch / np.cos(np.deg2rad(rot_angle)) # widthV = width / np.cos(np.deg2rad(rotAngle)) n_x = int(array_width / (length + spacing)) n_y = int(array_height / pitch_v) # Define the slits slit = Cell("Slits") rect = Rectangle((-length / 2., -width / 2.), (length / 2., width / 2.), layer=l) rect = rect.copy().rotate(rot_angle) slit.add(rect) slits = CellArray(slit, n_x, n_y, (length + spacing, pitch_v)) slits.translate((-(n_x - 1) * (length + spacing) / 2., -(n_y - 1) * pitch_v / 2.)) slit_array = Cell("SlitArray") slit_array.add(slits) text = Label('w/p/l\n%i/%i/%i' % (width * 1000, pitch * 1000, length * 1000), 2, layer=l_smBeam) lbl_vert_offset = 1.35 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -array_height / lbl_vert_offset))) ) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, array_height / lbl_vert_offset))) ) # Center justify label slit_array.add(text) manyslits.add(slit_array, origin=((array_width + array_spacing) * i, (array_height + 2. * array_spacing) * j - array_spacing / 2.)) return manyslits
def makeSlitArray3(pitches, spacing, widths, lengths, rotAngle, arrayHeight, arrayWidth, arraySpacing, layers): ''' Give it a single pitch and arrays for spacings/widths and it will generate an array for all the combinations Makes seperate frame for each pitch ''' if not (type(layers) == list): layers = [layers] if not (type(pitches) == list): pitches = [pitches] if not (type(lengths) == list): lengths = [lengths] if not (type(widths) == list): widths = [widths] for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") length = lengths[0] spacing = length / 5. + 0.1 # Set the spacing between arrays for pitch in pitches: j += 1 i = -1 for width in widths: # for pitch in pitches: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left pitchV = pitch / np.cos(np.deg2rad(rotAngle)) # widthV = width / np.cos(np.deg2rad(rotAngle)) Nx = int(arrayWidth / (length + spacing)) Ny = int(arrayHeight / (pitchV)) # Define the slits slit = Cell("Slits") rect = Rectangle((-length / 2., -width / 2.), (length / 2., width / 2.), layer=l) rect = rect.copy().rotate(rotAngle) slit.add(rect) slits = CellArray(slit, Nx, Ny, (length + spacing, pitchV)) slits.translate((-(Nx - 1) * (length + spacing) / 2., -(Ny - 1) * (pitchV) / 2.)) slitarray = Cell("SlitArray") slitarray.add(slits) text = Label('w/p/l\n%i/%i/%i' % (width * 1000, pitch * 1000, length * 1000), 2, layer=l_smBeam) lblVertOffset = 1.35 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -arrayHeight / lblVertOffset)))) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, arrayHeight / lblVertOffset)))) # Center justify label slitarray.add(text) manyslits.add(slitarray, origin=((arrayWidth + arraySpacing) * i, (arrayHeight + 2. * arraySpacing) * j - arraySpacing / 2.)) return manyslits
def makeSlitArray(pitches, spacing, widths, lengths, rotAngle, arrayHeight, arraySpacing, layers): ''' Give it a single pitch and width and it will generate an array for all the lengths ''' if not (type(layers) == list): layers = [layers] if not (type(pitches) == list): pitches = [pitches] if not (type(lengths) == list): lengths = [lengths] if not (type(widths) == list): widths = [widths] for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") slitarray = Cell("SlitArray") pitch = pitches[0] width = widths[0] j += 1 i = -1 xlength = 0 slit = Cell("Slits") for length in lengths: spacing = length / 5. + 0.1 i += 1 pitchV = pitch / np.cos(np.deg2rad(rotAngle)) # widthV = width / np.cos(np.deg2rad(rotAngle)) # Nx = int(arrayWidth / (length + spacing)) Ny = int(arrayHeight / (pitchV)) # Define the slits if xlength == 0: translation = (length / 2., 0) xlength += length else: translation = (xlength + spacing + length / 2., 0) xlength += length + spacing pt1 = np.array((-length / 2., -width / 2.)) + translation pt2 = np.array((length / 2., width / 2.)) + translation rect = Rectangle(pt1, pt2, layer=l) rect = rect.copy().rotate(rotAngle) slit.add(rect) slits = CellArray(slit, 1, Ny, (0, pitchV)) # slits.translate((-(Nx - 1) * (length + spacing) / 2., -(Ny - 1)* (pitchV) / 2.)) slits.translate( (-slits.bounding_box[1, 0] / 2., -slits.bounding_box[1, 1] / 2.)) slitarray.add(slits) text = Label('w/p\n%i/%i' % (width * 1000, pitch * 1000), 2, layer=l_smBeam) lblVertOffset = 1.4 text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, arrayHeight / lblVertOffset)))) # Center justify label slitarray.add(text) # manyslits.add(slitarray,origin=((arrayWidth + arraySpacing) * i, (arrayHeight + 2.*arraySpacing) * j-arraySpacing/2.)) manyslits.add(slitarray) # self.add(manyslits, origin=(-i * (arrayWidth + arraySpacing) / 2, -j * (arrayHeight + arraySpacing) / 2)) # self.add(manyslits) return manyslits
def make_branch_array(self, _widths, _lengths, nx, ny, spacing_structs, spacing_arrays, rot_angle, layers): if not (type(layers) == list): layers = [layers] if not (type(_lengths) == list): _lengths = [_lengths] if not (type(_widths) == list): _widths = [_widths] l = layers[0] _length = _lengths[0] manyslits = i = j = None slits = [] for width in _widths: slit = Cell("Slit_{:.0f}".format(width * 1000)) line = Path([[-_length / 2., 0], [_length / 2., 0]], width=width, layer=l) slit.add(line) slits.append(slit) buffers = self.make_branch_device(0.08, 1.0, _lengths[0] / 2., _lengths[0] / 2., 4, layers[0], buffers_only=True) many_crosses = Cell("CrossArray") x_pos = 0 y_pos = 0 array_pitch = (ny - 1) * ( length + spacing_structs) - spacing_structs + spacing_arrays for j, width_vert in enumerate(_widths[::-1]): for i, width_horiz in enumerate(_widths): # Define a single cross cross = Cell("Cross_{:.0f}_{:.0f}".format( width_horiz * 1000, width_vert * 1000)) cross.add(slits[i]) # Horizontal slit cross.add(slits[j], rotation=90) # Vertical slit cross.add(buffers) # Define the cross array cross_array = Cell("CrossArray_{:.0f}_{:.0f}".format( width_horiz * 1000, width_vert * 1000)) slit_array = CellArray( cross, nx, ny, (_length + spacing_structs, _length + spacing_structs)) slit_array.translate( (-(nx - 1) * (_length + spacing_structs) / 2., (-(ny - 1) * (_length + spacing_structs) / 2.))) cross_array.add(slit_array) many_crosses.add(cross_array, origin=(x_pos, y_pos)) x_pos += array_pitch y_pos += array_pitch x_pos = 0 # Make the labels lbl_cell = Cell("Lbl_Cell") for i, width in enumerate(_widths): text_string = 'W{:.0f}'.format(width * 1000) text = Label(text_string, 5, layer=l) text.translate(tuple(np.array(-text.bounding_box.mean(0)))) x_offset = -1.5 * array_pitch + i * array_pitch text.translate(np.array((x_offset, 0))) # Center justify label lbl_cell.add(text) centered_cell = Cell('Centered_Cell') bbox = np.mean(many_crosses.bounding_box, 0) # Get center of cell centered_cell.add(many_crosses, origin=tuple(-bbox)) lbl_vertical_offset = 1.5 centered_cell.add(lbl_cell, origin=(0, -bbox[1] * lbl_vertical_offset)) centered_cell.add(lbl_cell, origin=(-bbox[1] * lbl_vertical_offset, 0), rotation=90) self.add(centered_cell, rotation=rot_angle)
def make_slit_patterns(self, sflabels, _pitches, spacing, _widths, _lengths, rot_angle, array_height, array_width, array_spacing, layers): if not (type(layers) == list): layers = [layers] if not (type(_pitches) == list): _pitches = [_pitches] if not (type(_lengths) == list): _lengths = [_lengths] if not (type(_widths) == list): _widths = [_widths] manyslits = i = j = None for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") pitch = _pitches[0] for length in _lengths: j += 1 i = -1 for width in _widths: # for pitch in pitches: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left nx = int(array_width / (length + spacing)) ny = int(array_height / pitch) # Define the slits slit = Cell("Slit_w{:.0f}".format(width * 1000)) slit_path = Path([(-length / 2., 0), (length / 2., 0)], width=width, layer=l) slit.add(slit_path) slits = CellArray(slit, nx, ny, (length + spacing, pitch)) slits.translate((-(nx - 1) * (length + spacing) / 2., -(ny - 1) * pitch / 2.)) slit_array = Cell("SlitArray_w{:.0f}".format(width * 1000)) slit_array.add(slits) text = Label('w/p/l\n%i/%i/%i' % (width * 1000, pitch, length), 5, layer=l) lbl_vertical_offset = 1.35 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -array_height / lbl_vertical_offset)) )) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, array_height / lbl_vertical_offset )))) # Center justify label slit_array.add(text) manyslits.add( slit_array, origin=((array_width + array_spacing) * i, (array_height + 2. * array_spacing) * j - array_spacing / 2.)) specific_label = Label(sflabels, 20, layer=l) specific_label.translate( (-lbl_vertical_offset * smMarkerPosition, -lbl_vertical_offset * smMarkerPosition)) # Center Small Field slit_array.add(specific_label) # This is an ugly hack to center rotated slits, should fix this properly... if rot_angle == 45: # TODO: fix this ugly thing hacky_offset_x = 200 hacky_offset_y = -25 elif rot_angle == 90: hacky_offset_x = 356 hacky_offset_y = 96.5 elif rot_angle == 180: hacky_offset_x = 260 hacky_offset_y = 452 elif rot_angle == 270 or rot_angle == -90: hacky_offset_x = -96.5 hacky_offset_y = 356 else: hacky_offset_x = 0 hacky_offset_y = 0 self.add(manyslits, origin=(-(i * (array_width + array_spacing)) / 2 + hacky_offset_x, -(j + 1.5) * (array_height + array_spacing) / 2 + hacky_offset_y), rotation=rot_angle)
def makeSlitArray2(pitches, spacing, widths, lengths, rotAngle, arrayHeight, arrayWidth, arraySpacing, layers): ''' Give it a single pitch and lengths/widths and it will generate an array for all the combinations Makes seperate frame for each length value ''' if not (type(layers) == list): layers = [layers] if not (type(pitches) == list): pitches = [pitches] if not (type(lengths) == list): lengths = [lengths] if not (type(widths) == list): widths = [widths] for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") pitch = pitches[0] for length in lengths: j += 1 i = -1 for width in widths: # for pitch in pitches: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left pitchV = pitch / np.cos(np.deg2rad(rotAngle)) # widthV = width / np.cos(np.deg2rad(rotAngle)) Nx = int(arrayWidth / (length + spacing)) Ny = int(arrayHeight / (pitchV)) # Define the slits membrane = Path([(-length / 2., 0), (length / 2., 0)], width=width, layer=l) membrane_cell = Cell('Membrane_w{:.0f}_l{:.0f}'.format( width * 1000, length * 1000)) membrane_cell.add(membrane) slit = Cell("Slits") slit.add(membrane_cell, rotation=rotAngle) if Nx <= 1: slits = CellArray(slit, Nx, Ny, (length, pitchV)) slits.translate((0, -(Ny - 1) * (pitchV) / 2.)) else: slits = CellArray(slit, Nx, Ny, (length + spacing, pitchV)) slits.translate((-(Nx - 1) * (length + spacing) / 2., -(Ny - 1) * (pitchV) / 2.)) slitarray = Cell("SlitArray") slitarray.add(slits) text = Label('w/p/l\n%i/%i/%i' % (width * 1000, pitch * 1000, length), 2, layer=l_smBeam) lblVertOffset = 1.35 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -arrayHeight / lblVertOffset)))) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, arrayHeight / lblVertOffset)))) # Center justify label slitarray.add(text) manyslits.add(slitarray, origin=((arrayWidth + arraySpacing) * i, (arrayHeight + 2. * arraySpacing) * j - arraySpacing / 2.)) return manyslits
def make_slits_reservoir( self, length, width, nslit, pitch, contact_distance, layers): # 5 additional slits as material reservoir res_slit = 5 slit_margin = 0.5 res_width = width res_pitch = pitch resField = Cell("resField") # Outer reservoir outer_res = Cell("Outer Reservoir") out_res_length = (margin - fing_width - slit_margin) outer_res_path = Path([(-out_res_length / 2, 0), (out_res_length / 2, 0)], width=res_width, layer=layers) outer_res.add(outer_res_path) out_gap = length - margin + slit_margin out_x_spac = (out_res_length + out_gap) / np.cos(rad_angle) out_y_spac = res_pitch out_reservoirs = CellArray(outer_res, 2, res_slit, spacing=(out_x_spac, out_y_spac)) out_x_transl = -(out_res_length + out_gap) / ( 2 * np.cos(rad_angle)) + (slit_margin) * np.sin(rad_angle) out_reservoirs.translate((out_x_transl, 0)) out_res_array = Cell("Multiple Slit") out_res_array.add(out_reservoirs) resField.add(out_res_array, origin=(0, 0), rotation=rot_angle) # Main reservoir reservoir = Cell("Single Reservoir") res_length = fake_slit_length res_path = Path([(-res_length / 2., 0), (res_length / 2., 0)], width=res_width, layer=layers) reservoir.add(res_path) gap = contact_distance + 2 * (slit_margin + fing_width) x_spac = (res_length + gap) / np.cos(rad_angle) y_spac = res_pitch reservoirs = CellArray(reservoir, 2, res_slit, spacing=(x_spac, y_spac)) x_transl = -(res_length + gap) / (2 * np.cos(rad_angle)) + ( slit_margin) * np.sin(rad_angle) reservoirs.translate((x_transl, 0)) res_array = Cell("Multiple Slit") res_array.add(reservoirs) resField.add(res_array, origin=(0, 0), rotation=rot_angle) # Inner reservoir if contact_distance > slit_margin: add_slit = Cell("Additional Reservoir") add_res_path = Path([(-(contact_distance - 0.5) / 2., 0), ((contact_distance - 0.5) / 2., 0)], width=res_width, layer=layers) add_slit.add(add_res_path) add_reservoir = CellArray(add_slit, 1, res_slit, spacing=(0, res_pitch)) add_reservoir.translate((0, 0)) add_res_array = Cell("Additional Multiple Slit") add_res_array.add(add_reservoir) resField.add(add_res_array, origin=(0, 0), rotation=rot_angle) self.add(resField, origin=(0, (nslit + 1) * pitch / 2) / np.cos(rad_angle)) self.add(resField, origin=(0, -((nslit + 1 + (2 * (res_slit - 1))) * pitch / 2) / np.cos(rad_angle)))
def makeSlitArray(self, pitches, spacing, widths, lengths, rotAngle, arrayHeight, arrayWidth, arraySpacing, layers): if not (type(layers) == list): layers = [layers] if not (type(pitches) == list): pitches = [pitches] if not (type(lengths) == list): lengths = [lengths] if not (type(widths) == list): widths = [widths] for l in layers: i = -1 j = -1 manyslits = Cell("SlitArray") pitch = pitches[0] for length in lengths: j += 1 i = -1 for width in widths: # for pitch in pitches: i += 1 if i % 3 == 0: j += 1 # Move to array to next line i = 0 # Restart at left pitchV = pitch / np.cos(np.deg2rad(rotAngle)) # widthV = width / np.cos(np.deg2rad(rotAngle)) Nx = int(arrayWidth / (length + spacing)) Ny = int(arrayHeight / (pitchV)) # Define the slits slit = Cell("Slits") rect = Rectangle((-length / 2., -width / 2.), (length / 2., width / 2.), layer=l) rect = rect.copy().rotate(rotAngle) slit.add(rect) slits = CellArray(slit, Nx, Ny, (length + spacing, pitchV)) slits.translate((-(Nx - 1) * (length + spacing) / 2., -(Ny - 1) * (pitchV) / 2.)) slitarray = Cell("SlitArray") slitarray.add(slits) text = Label( 'w/p/l\n%i/%i/%i' % (width * 1000, pitch, length), 5) lblVertOffset = 1.35 if j % 2 == 0: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, -arrayHeight / lblVertOffset))) ) # Center justify label else: text.translate( tuple( np.array(-text.bounding_box.mean(0)) + np.array((0, arrayHeight / lblVertOffset))) ) # Center justify label slitarray.add(text) manyslits.add( slitarray, origin=((arrayWidth + arraySpacing) * i, (arrayHeight + 2. * arraySpacing) * j - arraySpacing / 2.)) self.add(manyslits, origin=(-i * (arrayWidth + arraySpacing) / 2, -(j + 1.5) * (arrayHeight + arraySpacing) / 2))
def make_tapered_cross_array(self, _nom_width, _taper_widths, _length, _taper_length, nx, ny, spacing_structs, spacing_arrays, rot_angle, layers): if not (type(layers) == list): layers = [layers] if not (type(_taper_widths) == list): _taper_widths = [_taper_widths] if type(_nom_width ) == list: # Only accept a single membrane width for now _nom_width = _nom_width[0] if type(_length ) == list: # Only accept a single membrane length for now _length = _length[0] if type(_taper_length ) == list: # Only accept a single taper length for now _taper_length = _taper_length[0] layer = layers[0] many_crosses = Cell("CrossArray") x_pos = 0 y_pos = 0 array_pitch = ny * (length + spacing_structs) - spacing_structs + spacing_arrays membrane_cell = Cell('Testing') # fix the taper length, put this in a loop and iterate over various combined taper width values for j, tw_vert in enumerate(_taper_widths): for i, tw_horiz in enumerate(_taper_widths): # Define a single cross cross = self.make_tapered_cross(_nom_width, _nom_width, tw_horiz, tw_vert, _length, _length, _taper_length, _taper_length, layer) # Define the cross array cross_array = Cell("TaperedCrossArray_{:.0f}_{:.0f}".format( tw_horiz * 1000, tw_vert * 1000)) slit_array = CellArray( cross, nx, ny, (_length + spacing_structs, _length + spacing_structs)) slit_array.translate( (-(nx - 1) * (_length + spacing_structs) / 2., (-(ny - 1) * (_length + spacing_structs) / 2.))) cross_array.add(slit_array) many_crosses.add(cross_array, origin=(x_pos, y_pos)) x_pos += array_pitch y_pos += array_pitch x_pos = 0 # Make the labels lbl_cell = Cell("Lbl_Cell") for i, width in enumerate(_taper_widths): text_string = 'TW{:.0f}'.format(width * 1000) text = Label(text_string, 5, layer=layer) text.translate(tuple(np.array(-text.bounding_box.mean(0)))) x_offset = -1.5 * array_pitch + i * array_pitch text.translate(np.array((x_offset, 0))) # Center justify label lbl_cell.add(text) # Make label for the whole field frame_lbl = Cell("Cell_Label") text_string = 'NomW {:.0f}, TL {:.0f}'.format(_nom_width * 1000, _taper_length * 1000) text = Label(text_string, 5, layer=layer) text.translate(tuple(np.array(-text.bounding_box.mean(0)))) frame_lbl.add(text) centered_cell = Cell('Centered_Cell') bbox = np.mean(many_crosses.bounding_box, 0) # Get center of cell centered_cell.add(many_crosses, origin=tuple(-bbox)) centered_cell.add(frame_lbl, origin=(0, -200)) lbl_vertical_offset = 1.5 centered_cell.add(lbl_cell, origin=(0, -bbox[1] * lbl_vertical_offset)) centered_cell.add(lbl_cell, origin=(-bbox[1] * lbl_vertical_offset, 0), rotation=90) self.add(centered_cell, rotation=rot_angle)