def trim_front_wedge(self, cutpos, angle): self.contour.trim(surf="top", discard="front", cutpos=cutpos, station=self.pos[0]) bx = self.find_flap_bottom_front(cutpos, angle) botpos = contour.Cutpos(xpos=bx) self.contour.trim(surf="bottom", discard="front", cutpos=botpos, station=self.pos[0]) return bx
def add_spar(self, surf="top", orientation="vertical", \ percent=None, front=None, rear=None, xpos=None, \ xsize=0.0, ysize=0.0, \ start_station=None, end_station=None, mirror=True, \ part=""): cutpos = contour.Cutpos(percent, front, rear, xpos) cutout = contour.Cutout(surf, orientation, cutpos, xsize, ysize) if start_station == None: start_station = self.stations[0] if end_station == None: end_station = self.stations[len(self.stations) - 1] spar = Stringer(cutout, start_station, end_station, part) spar.side = "right" self.spars.append(spar) if mirror: spar = Stringer(cutout, -start_station, -end_station, part) spar.side = "left" self.spars.append(spar)
def trim_front_wedge(self, cutpos, angle): self.contour.trim(surf="top", discard="front", cutpos=cutpos, station=self.pos[0]) wedge_angle = math.radians(90.0 - angle) wedge_slope = -math.tan(wedge_angle) tx = self.contour.get_xpos(cutpos, station=self.pos[0]) ty = self.contour.simple_interp(self.contour.top, tx) bx = self.contour.intersect("bottom", (tx, ty), wedge_slope) botpos = contour.Cutpos(xpos=bx) self.contour.trim(surf="bottom", discard="front", cutpos=botpos, station=self.pos[0]) return bx
def add_build_tab(self, surf="top", \ percent=None, front=None, rear=None, xpos=None, \ xsize=0.0, ypad=0.0, \ start_station=None, end_station=None, mirror=True, \ part=""): cutpos = contour.Cutpos(percent, front, rear, xpos) if start_station == None: start_station = self.stations[0] if end_station == None: end_station = self.stations[len(self.stations) - 1] tab = BuildTab( surf, cutpos, xsize, ypad, \ start_station, end_station, part ) tab.side = "right" self.build_tabs.append(tab) if mirror: tab = BuildTab(surf, cutpos, xsize, ypad, -start_station, -end_station, part) tab.side = "left" self.build_tabs.append(tab)
bounds = blend.get_bounds() # leading edge diamond (before washout rotate) blend.cutout_leading_edge_diamond( 0.200 ) # sheet whole wing #blend.cutout_sweep( side="top", xstart=bounds[0][0], xdist=size*2, ysize=0.0625 ) #blend.cutout_sweep( side="bottom", xstart=bounds[0][0], xdist=size*2, ysize=0.0625 ) # sheet trailing eng blend.cutout_sweep( side="top", xstart=bounds[1][0]-2.0, xdist=3, ysize=0.0625 ) blend.cutout_sweep( side="bottom", xstart=bounds[1][0]-2.0, xdist=3, ysize=0.0625 ) # stringer position tapers with wing (if there is a taper) cutpos = contour.Cutpos( percent=0.15 ) cutout = contour.Cutout( side="top", orientation="tangent", cutpos=cutpos, \ xsize=0.125, ysize=0.125 ) blend.cutout_stringer( cutout ) # stringer position fixed relative to nose of rib cutpos = contour.Cutpos( front=0.25 ) cutout = contour.Cutout( side="top", orientation="tangent", cutpos=cutpos, \ xsize=0.125, ysize=0.125 ) blend.cutout_stringer( cutout ) # rear stringer (before washout rotate) cutpos = contour.Cutpos( percent=0.7 ) cutout = contour.Cutout( side="top", orientation="tangent", cutpos=cutpos, \ xsize=0.125, ysize=0.125 ) blend.cutout_stringer( cutout )
wing.add_stringer( side="top", orientation="tangent", percent=0.50, \ xsize=0.125, ysize=0.125, \ start_station=10.0, end_station=30.0, part="wing" ) wing.add_stringer( side="bottom", orientation="tangent", percent=0.50, \ xsize=0.125, ysize=0.125, \ start_station=10.0, end_station=30.0, part="wing" ) #wing.add_stringer( side="top", orientation="tangent", percent=0.50, \ # xsize=0.125, ysize=0.125, \ # start_station=15.0, end_station=28.0 ) #wing.add_stringer( side="top", orientation="tangent", xpos=3.0, \ # xsize=0.125, ysize=0.125 ) #wing.add_stringer( side="bottom", orientation="tangent", xpos=3.0, \ # xsize=0.125, ysize=0.125 ) # simple round hole pos = contour.Cutpos(xpos=-0.75) wing.add_simple_hole(radius=0.325, pos1=pos, part="wing") # shaped lightening holes start = contour.Cutpos(percent=0.35) end = contour.Cutpos(percent=0.55) wing.add_shaped_hole( pos1=start, pos2=end, \ material_width=0.2, radius=0.1, part="wing" ) # define the control surfaces ailpos = contour.Cutpos(xpos=4.0, atstation=17.0, slope=-0.1) edge_stringer_size = (0.250, 0.125) # width x height #edge_stringer_size = None wing.add_flap( start_station=17.0, end_station=28.0, \ pos=ailpos, type="builtup", angle=30.0, \ edge_stringer_size=edge_stringer_size )
def build(self): if len(self.stations) < 2: print "Must define at least 2 stations to build a wing" return sweep_y2 = spline.derivative2( self.sweep.top ) taper_y2 = spline.derivative2( self.taper.top ) # make the base ribs at each defined station for index, station in enumerate(self.stations): percent = station / self.span # generate airfoil if not self.tip: af = self.root else: af = airfoil.blend(self.root, self.tip, percent) # compute placement parameters lat_dist = station twist = self.twist * percent # compute chord if self.taper: sp_index = spline.binsearch(self.taper.top, lat_dist) chord = spline.spline(self.taper.top, taper_y2, sp_index, lat_dist) else: print "Cannot build a wing with no chord defined!" return print "building station @ " + str(lat_dist) \ + " chord = " + str(chord) # compute sweep offset pos if a sweep function provided if self.sweep: sw_index = spline.binsearch(self.sweep.top, lat_dist) sweep_dist = spline.spline(self.sweep.top, sweep_y2, sw_index, \ lat_dist) else: sweep_dist = 0.0 # make the rib (cutouts will be handled later) label = 'WR' + str(index+1) right_rib = self.make_raw_rib(af, chord, lat_dist, sweep_dist, \ twist, label) right_rib.side = "right" if percent < 0.001: right_rib.nudge = -right_rib.thickness * 0.5 elif percent > 0.999: right_rib.nudge = right_rib.thickness * 0.5 self.right_ribs.append(right_rib) label = 'WL' + str(index+1) left_rib = self.make_raw_rib(af, chord, -lat_dist, sweep_dist, \ twist, label) left_rib.side = "left" if percent < 0.001: left_rib.nudge = right_rib.thickness * 0.5 elif percent > 0.999: left_rib.nudge = -right_rib.thickness * 0.5 self.left_ribs.append(left_rib) # make the control surface ribs. Instead of dividing the # original base ribs into two parts, we make copies of the # base ribs and then trim off the parts we don't want. This # makes a bit of sense considering we need double ribs at the # cutout edges. We do this in one pass per side, stepping # through each rib and seeing if it matches a control surface # cutout and if it's an inner, outer, or mid rib. new_ribs = [] for rib in self.right_ribs: for flap in self.flaps: if self.match_station(flap.start_station, flap.start_station, rib.pos[0]): #print "start station = " + str(rib.pos[0]) newrib = copy.deepcopy(rib) rib.nudge = rib.thickness * 0.5 newrib.nudge = -rib.thickness * 1.0 flap.start_bot_str_pos = newrib.trim_front_wedge(flap.pos, flap.angle) newrib.part = "flap" newrib.has_le = False new_ribs.append(newrib) elif self.match_station(flap.end_station, flap.end_station, rib.pos[0]): #print "end station = " + str(rib.pos[0]) newrib = copy.deepcopy(rib) rib.nudge = -rib.thickness * 0.5 newrib.nudge = rib.thickness * 1.0 flap.end_bot_str_pos = newrib.trim_front_wedge(flap.pos, flap.angle) newrib.part = "flap" newrib.has_le = False new_ribs.append(newrib) elif self.match_station(flap.start_station, flap.end_station, rib.pos[0]): #print "match flap at mid station " + str(rib.pos[0]) newrib = copy.deepcopy(rib) newrib.trim_front_wedge(flap.pos, flap.angle) newrib.part = "flap" newrib.has_le = False new_ribs.append(newrib) rib.trim_rear(flap.pos) rib.has_te = False for rib in new_ribs: self.right_ribs.append(rib) new_ribs = [] for rib in self.left_ribs: for flap in self.flaps: if self.match_station(flap.start_station, flap.start_station, rib.pos[0]): #print "start station = " + str(rib.pos[0]) newrib = copy.deepcopy(rib) rib.nudge = -rib.thickness * 0.5 newrib.nudge = rib.thickness * 1.0 flap.start_bot_str_pos = newrib.trim_front_wedge(flap.pos, flap.angle) newrib.part = "flap" newrib.has_le = False new_ribs.append(newrib) elif self.match_station(flap.end_station, flap.end_station, rib.pos[0]): #print "end station = " + str(rib.pos[0]) newrib = copy.deepcopy(rib) rib.nudge = rib.thickness * 0.5 newrib.nudge = -rib.thickness * 1.0 flap.end_bot_str_pos = newrib.trim_front_wedge(flap.pos, flap.angle) newrib.part = "flap" newrib.has_le = False new_ribs.append(newrib) elif self.match_station(flap.start_station, flap.end_station, rib.pos[0]): #print "left match flap at station " + str(rib.pos[0]) newrib = copy.deepcopy(rib) newrib.trim_front_wedge(flap.pos, flap.angle) newrib.part = "flap" newrib.has_le = False new_ribs.append(newrib) rib.trim_rear(flap.pos) rib.has_te = False #rib.contour.trim(surf="top", discard="rear", cutpos=flap.pos) #rib.contour.trim(surf="bottom", discard="rear", cutpos=flap.pos) for rib in new_ribs: self.left_ribs.append(rib) # now place the leading edge bottom stringer for each flap. # This is left until now because this can be very dynamic # depending on the wing layout and control surface blending. for flap in self.flaps: if flap.start_bot_str_pos != None and flap.end_bot_str_pos != None \ and flap.edge_stringer_size != None: xdist = flap.end_station - flap.start_station if math.fabs(xdist) > 0.0001: atstation = flap.start_station ydist = flap.end_bot_str_pos - flap.start_bot_str_pos slope = ydist / xdist half_offset = flap.edge_stringer_size[0] * 0.5 if flap.side == "left": atstation *= -1.0 slope *= -1.0 cutpos = contour.Cutpos(xpos=flap.start_bot_str_pos, \ atstation=atstation, \ slope=slope) cutpos.move(half_offset) cutout = contour.Cutout(surf="bottom", \ orientation="tangent", \ cutpos=cutpos, \ xsize=flap.edge_stringer_size[0], \ ysize=flap.edge_stringer_size[1] ) print "making bottom stringer: " + str(flap.start_station) + " - " + str(flap.end_station) stringer = Stringer( cutout, flap.start_station, flap.end_station, "flap" ) stringer.side = flap.side self.stringers.append( stringer ) else: print "skipped building a flap bottom stringer" print str(flap.start_bot_str_pos) print str(flap.end_bot_str_pos) print str(flap.edge_stringer_size) # do all the cutouts now at the end after we've made and # positioned all the ribs for the wing and the control # surfaces for rib in self.right_ribs: self.make_rib_cuts(rib) for rib in self.left_ribs: self.make_rib_cuts(rib) # a quick pass to update labels on "flap" parts after the # cutouts so there is half a chance the label ends up on the # part itself for rib in self.right_ribs: if rib.part == "flap": rib.relabel_flap() for rib in self.left_ribs: if rib.part == "flap": rib.relabel_flap()
def build(self): if len(self.stations) < 2: print "Must define at least 2 stations to build a wing" return sweep_y2 = spline.derivative2(self.sweep.top) taper_y2 = spline.derivative2(self.taper.top) # make the base ribs at each defined station for index, station in enumerate(self.stations): percent = station / self.span # generate airfoil if not self.tip: af = self.root else: af = airfoil.blend(self.root, self.tip, percent) # compute placement parameters lat_dist = station twist = self.twist * percent # compute chord if self.taper: sp_index = spline.binsearch(self.taper.top, lat_dist) chord = spline.spline(self.taper.top, taper_y2, sp_index, lat_dist) else: print "Cannot build a wing with no chord defined!" return print "building station @ " + str(lat_dist) \ + " chord = " + str(chord) # compute sweep offset pos if a sweep function provided if self.sweep: sw_index = spline.binsearch(self.sweep.top, lat_dist) sweep_dist = spline.spline(self.sweep.top, sweep_y2, sw_index, lat_dist) else: sweep_dist = 0.0 # make the rib (cutouts will be handled later) label = 'WR' + str(index + 1) right_rib = self.make_raw_rib(af, chord, lat_dist, sweep_dist, twist, label) right_rib.side = "right" if percent < 0.001: right_rib.nudge = -right_rib.thickness * 0.5 elif percent > 0.999: right_rib.nudge = right_rib.thickness * 0.5 self.right_ribs.append(right_rib) label = 'WL' + str(index + 1) left_rib = self.make_raw_rib(af, chord, -lat_dist, sweep_dist, twist, label) left_rib.side = "left" if percent < 0.001: left_rib.nudge = right_rib.thickness * 0.5 elif percent > 0.999: left_rib.nudge = -right_rib.thickness * 0.5 self.left_ribs.append(left_rib) # at the ends of each control surface we need a full length # rib to cap off the space, so we need to create copies of the # ribs at these points. self.right_ribs = self.make_new_ribs_for_flaps(self.right_ribs, 'right') self.left_ribs = self.make_new_ribs_for_flaps(self.left_ribs, 'left') for rib in self.right_ribs: rib_pos = rib.pos[0] - rib.nudge for flap in self.flaps: if self.match_station(flap.start_station, flap.end_station, rib_pos): if rib.part == "flap": if rib.type == "inner": pos = rib.trim_front_wedge(flap.pos, flap.angle) flap.start_bot_str_pos = pos print "flap start bot = " + str(pos) elif rib.type == "outer": pos = rib.trim_front_wedge(flap.pos, flap.angle) flap.end_bot_str_pos = pos print "flap end bot = " + str(pos) elif rib.type == "inner-shared": #pos = rib.find_flap_bottom_front(flap.pos, flap.angle) pos = rib.trim_front_wedge(flap.pos, flap.angle) flap.start_bot_str_pos = pos print "flap start bot = " + str(pos) elif rib.type == "outer-shared": pos = rib.find_flap_bottom_front( flap.pos, flap.angle) flap.end_bot_str_pos = pos print "flap end bot = " + str(pos) else: # add cut lines rib.add_wedge_cut_lines(flap.pos, flap.angle) else: print "skipping rear trim" # rib.trim_rear(flap.pos) for rib in self.left_ribs: rib_pos = rib.pos[0] - rib.nudge for flap in self.flaps: if self.match_station(flap.start_station, flap.end_station, rib_pos): if rib.part == "flap": if rib.type == "inner": pos = rib.trim_front_wedge(flap.pos, flap.angle) flap.start_bot_str_pos = pos print "flap start bot = " + str(pos) elif rib.type == "outer": pos = rib.trim_front_wedge(flap.pos, flap.angle) flap.end_bot_str_pos = pos print "flap end bot = " + str(pos) elif rib.type == "inner-shared": pos = rib.find_flap_bottom_front( flap.pos, flap.angle) pos = rib.trim_front_wedge(flap.pos, flap.angle) flap.start_bot_str_pos = pos print "flap start bot = " + str(pos) elif rib.type == "outer-shared": pos = rib.find_flap_bottom_front( flap.pos, flap.angle) flap.end_bot_str_pos = pos print "flap end bot = " + str(pos) else: # add cut lines rib.add_wedge_cut_lines(flap.pos, flap.angle) else: print "skipping rear trim" # rib.trim_rear(flap.pos) # now place the leading edge bottom stringer for each flap. # This is left until now because this can be very dynamic # depending on the wing layout and control surface blending. for flap in self.flaps: if flap.start_bot_str_pos != None and flap.end_bot_str_pos != None \ and flap.edge_stringer_size != None: xdist = flap.end_station - flap.start_station if math.fabs(xdist) > 0.0001: atstation = flap.start_station ydist = flap.end_bot_str_pos - flap.start_bot_str_pos slope = ydist / xdist half_offset = flap.edge_stringer_size[0] * 0.5 if flap.side == "left": atstation *= -1.0 slope *= -1.0 cutpos = contour.Cutpos(xpos=flap.start_bot_str_pos, \ atstation=atstation, \ slope=slope) cutpos.move(half_offset) cutout = contour.Cutout(surf="bottom", \ orientation="tangent", \ cutpos=cutpos, \ xsize=flap.edge_stringer_size[0], \ ysize=flap.edge_stringer_size[1] ) print "making bottom stringer: " + str( flap.start_station) + " - " + str(flap.end_station) stringer = Stringer(cutout, flap.start_station, flap.end_station, "flap") stringer.side = flap.side self.stringers.append(stringer) else: print "skipped building a flap bottom stringer" print str(flap.start_bot_str_pos) print str(flap.end_bot_str_pos) print str(flap.edge_stringer_size) # do all the cutouts now at the end after we've made and # positioned all the ribs for the wing and the control # surfaces for rib in self.right_ribs: self.make_rib_cuts(rib) for rib in self.left_ribs: self.make_rib_cuts(rib) # a quick pass to update labels on "flap" parts after the # cutouts so there is half a chance the label ends up on the # part itself for rib in self.right_ribs: if rib.part == "flap": rib.relabel_flap() for rib in self.left_ribs: if rib.part == "flap": rib.relabel_flap()