def import_ods(filename, glider=None): ods = ezodf.opendoc(filename) sheets = ods.sheets # Profiles -> map xvalues profiles = [Profile2D(profile) for profile in transpose_columns(sheets[3])] xvalues = sorted(profiles, key=lambda prof: prof.numpoints)[0].x_values # Use airfoil with maximum profilepoints for profile in profiles: profile.x_values = xvalues # Ballooning old : 1-8 > upper (prepend/append (0,0),(1,0)), 9-16 > lower (same + * (1,-1)) balloonings_temp = transpose_columns(sheets[4]) balloonings = [] for baloon in balloonings_temp: upper = [[0, 0]] + baloon[:7] + [[1, 0]] lower = [[0, 0]] + [[i[0], -1 * i[1]] for i in baloon[8:15]] + [[1, 0]] balloonings.append(BallooningBezier([upper, lower])) # Data data = {} datasheet = sheets[-1] assert isinstance(datasheet, ezodf.Sheet) for i in range(datasheet.nrows()): data[datasheet.get_cell([i, 0]).value] = datasheet.get_cell([i, 1]).value #print(data["GLEITZAHL"]) glider.data = data cells = [] main = sheets[0] x = y = z = span_last = 0. alpha2 = 0. thisrib = None # TODO: Glide -> DATAIMPORT for i in range(1, main.nrows()): line = [main.get_cell([i, j]).value for j in range(main.ncols())] if not line[0]: #print("leere zeile:", i, main.nrows()) break chord = line[1] # Rib-Chord span = line[2] # spanwise-length (flat) alpha1 = alpha2 # angle before the rib alpha2 += line[4] * numpy.pi / 180 # angle after the rib alpha = (span > 0) * (alpha1 + alpha2) * 0.5 + line[6] * numpy.pi / 180 # rib's angle x = line[3] # x-value -> front/back (ribwise) y += numpy.cos(alpha1) * (span - span_last) # y-value -> spanwise z -= numpy.sin(alpha1) * (span - span_last) # z-axis -> up/down aoa = line[5] * numpy.pi / 180 zrot = line[7] * numpy.pi / 180 span_last = span profile = merge(line[8], profiles) ballooning = merge(line[9], balloonings) lastrib = thisrib thisrib = Rib(profile, ballooning, numpy.array([x, y, z]), chord, alpha, aoa, zrot, data["GLEITZAHL"]) if i == 1 and y != 0: # Middle-cell #print("midrib!", y) lastrib = thisrib.copy() lastrib.mirror() if lastrib: cell = Cell(lastrib, thisrib, []) cell.name = "Cell_no"+str(i) cells.append(cell) if glider: glider.cells = cells glider.close_rib() glider.attachment_points = read_elements(sheets[2], "AHP", AttachmentPoint) glider.attachment_points_lower = get_lower_aufhaengepunkte(glider.data) for p in glider.attachment_points: p.force = numpy.array([0, 0, 1]) p.get_position(glider) glider.lines = tolist_lines(sheets[6], glider.attachment_points_lower, glider.attachment_points) glider.lines.calc_geo() glider.lines.calc_sag() return return cells
def import_ods(filename, glider): ods = ezodf.opendoc(filename) sheets = ods.sheets # Profiles -> map xvalues profiles = [Profile2D(profile) for profile in transpose_columns(sheets[3])] xvalues = sorted(profiles, key=lambda prof: prof.numpoints)[0].x_values # Use airfoil with maximum profilepoints for profile in profiles: profile.x_values = xvalues # Ballooning old : 1-8 > upper (prepend/append (0,0),(1,0)), 9-16 > lower (same + * (1,-1)) balloonings_temp = transpose_columns(sheets[4]) balloonings = [] for baloon in balloonings_temp: upper = [[0, 0]] + baloon[:7] + [[1, 0]] lower = [[0, 0]] + [[i[0], -1 * i[1]] for i in baloon[8:15]] + [[1, 0]] balloonings.append(BallooningBezier(upper, lower)) # Data data = {} datasheet = sheets[-1] assert isinstance(datasheet, ezodf.Sheet) for i in range(datasheet.nrows()): data[datasheet.get_cell([i, 0]).value] = datasheet.get_cell([i, 1]).value #print(data["GLEITZAHL"]) glider.data = data cells = [] main = sheets[0] x = y = z = span_last = 0. alpha2 = 0. thisrib = None for i in range(1, main.nrows()): line = [main.get_cell([i, j]).value for j in range(main.ncols())] if not line[0]: break # skip empty line chord = line[1] # Rib-Chord span = line[2] # spanwise-length (flat) alpha1 = alpha2 # angle before the rib alpha2 += line[4] * np.pi / 180 # angle after the rib alpha = (span > 0) * (alpha1 + alpha2) * 0.5 + line[6] * np.pi / 180 # rib's angle x = line[3] # x-value -> front/back (ribwise) y += np.cos(alpha1) * (span - span_last) # y-value -> spanwise z -= np.sin(alpha1) * (span - span_last) # z-axis -> up/down aoa = line[5] * np.pi / 180 zrot = line[7] * np.pi / 180 span_last = span profile = merge(line[8], profiles) ballooning = merge(line[9], balloonings) lastrib = thisrib thisrib = Rib(profile, np.array([x, y, z]), chord, alpha, aoa, zrot, data["GLIDE"], name="Rib ({})".format(i)) if i == 1 and y != 0: # Middle-cell #print("midrib!", y) lastrib = thisrib.copy() lastrib.mirror() if lastrib: cell = Cell(lastrib, thisrib, ballooning) cell.name = "Cell_no"+str(i) cells.append(cell) glider.cells = cells glider.close_rib() ######################################LINESET###################################################### attachment_points = [AttachmentPoint(glider.ribs[args[0]], args[1], args[2]) for args in read_elements(sheets[2], "AHP", len_data=2)] attachment_points.sort(key=lambda element: element.name) attachment_points_lower = get_lower_aufhaengepunkte(glider.data) for p in attachment_points: p.force = np.array([0, 0, 10]) p.get_position() glider.lineset = tolist_lines(sheets[6], attachment_points_lower, attachment_points) glider.lineset.recalc() ####################################PANELS########################################################## cuts = [cut+[1, glider.data["Designzugabe"]] for cut in read_elements(sheets[1], "DESIGNO")] cuts += [cut+[1, glider.data["Designzugabe"]] for cut in read_elements(sheets[1], "DESIGNM")] cuts += [cut+[2, glider.data["EKzugabe"]] for cut in read_elements(sheets[1], "EKV")] cuts += [cut+[2, glider.data["EKzugabe"]] for cut in read_elements(sheets[1], "EKH")] for i, cell in enumerate(glider.cells): # cut = [cell_no, x_left, x_right, cut_type, amount_add] cuts_this = [cut for cut in cuts if cut[0] == i] cuts_this.sort(key=lambda cut: cut[1]) cuts_this.sort(key=lambda cut: cut[2]) # Insert leading-/trailing-edge cuts_this.insert(0, [i, -1, -1, 3, glider.data["HKzugabe"]]) cuts_this.append([i, 1, 1, 3, glider.data["HKzugabe"]]) cell.panels = [] for j in range(len(cuts_this)-1): if cuts_this[j][3] != 2 or cuts_this[j+1][3] != 2: # skip entry cell.panels.append(Panel(cuts_this[j][1:], cuts_this[j+1][1:])) return glider