def get_clipped_section_data(cls, sectiondata, inlet_height, angle): '''Function to get a SectionAIRFOILData instance from a SectionData as required for a parafoil by clipping the front portion as specified by the inlet height and angle of cut ''' dx = sectiondata.data_points[:, 0] xmin, xmax = numpy.min(dx), numpy.max(dx) xchange = numpy.argmax(dx) if dx[1] > dx[0] else numpy.argmin(dx) x = numpy.unique(dx) # datax, datay dxu, dyu = sectiondata.data_points[:xchange+1, 0], sectiondata.data_points[:xchange+1, 1] a = numpy.argsort(dxu) dxu, dyu = dxu[a], dyu[a] dxl, dyl = sectiondata.data_points[xchange:, 0], sectiondata.data_points[xchange:, 1] a = numpy.argsort(dxl) dxl, dyl = dxl[a], dyl[a] angle_r = angle * numpy.pi / 180 #def err_angle err_angle = lambda x,x1,y1: angle_r - numpy.arctan2(y1 - numpy.interp(x, dxl, dyl), x1 - x) get_err_angle = lambda x1,y1: lambda x: err_angle(x,x1,y1) def get_inlet_height(x, angle): x1 = x y1 = numpy.interp(x1, dxu, dxu) x2 = false_position_method(get_err_angle(x1,y1), x1, x1 + 0.01, angle_r / 100, max_iter=100) y2 = numpy.interp(x, dxl, dyl) return y1 - y2 err_height = lambda x: get_inlet_height(x, angle) - inlet_height x1 = x_inlet = false_position_method(err_height, 0.1, 0.11, inlet_height / 1000, max_iter=100)[0] x2_inlet = false_position_method(get_err_angle(x1,numpy.interp(x1, dxu, dxu)), x1, x1 + 0.01, angle_r / 100, max_iter=100)[0] dxu_new = dxu[dxu>x_inlet] dxu_new = numpy.concatenate(([x_inlet],dxu_new)) dyu_new = numpy.interp(dxu_new, dxu, dyu) dxl_new = dxl[dxl>x2_inlet] dxl_new = numpy.concatenate(([x2_inlet],dxl_new)) dyl_new = numpy.interp(dxl_new, dxl, dyl) dx_new = numpy.concatenate((dxl_new[::-1],dxu_new)) dy_new = numpy.concatenate((dyl_new[::-1],dyu_new)) # now translate the data to get x_le = 0.0 dx_new = dx_new-x_inlet # now scale to get initial chord to compensate for the cut dx_new = dx_new/(1-x_inlet) dy_new = dy_new/(1-x_inlet) data_points = numpy.array([dx_new,dy_new]).T print data_points.shape ret = SectionAIRFOILData(data_points=data_points) return ret
def get_inlet_height(x, angle): x1 = x y1 = numpy.interp(x1, dxu, dxu) x2 = false_position_method(get_err_angle(x1,y1), x1, x1 + 0.01, angle_r / 100, max_iter=100) y2 = numpy.interp(x, dxl, dyl) return y1 - y2