From 29c11bab72fc74cf18de26e06803dc8d47a5ea15 Mon Sep 17 00:00:00 2001 From: Cal Wing <20716204+calw20@users.noreply.github.com> Date: Thu, 29 Aug 2024 00:47:40 +1000 Subject: [PATCH] Add force to pressure grpahs --- main.py | 153 +++++++++++++++++++++++++------------------------------- 1 file changed, 69 insertions(+), 84 deletions(-) diff --git a/main.py b/main.py index c591130..4555fa0 100644 --- a/main.py +++ b/main.py @@ -59,10 +59,34 @@ def make_pressure_graph(sheet1, aoa, rpm, air_speed, doGraph=True): #print(pressure) #print(pressure.min(), pressure.max()) + # Do the trapiztoal rule integration + da = [] + for i, _ in enumerate(pressure): + if i in [0]: continue # Skip 0 + if i in [10]: # Force tapping 11 to use tapping 1 rather then 0 + da.append(((PITOT_PLACEMENT_CHORD_NORM[i] - PITOT_PLACEMENT_CHORD_NORM[0])/2) * (pressure.iloc[0] + pressure.iloc[i])) + continue + + da.append(((PITOT_PLACEMENT_CHORD_NORM[i] - PITOT_PLACEMENT_CHORD_NORM[i-1])/2) * (pressure.iloc[i-1] + pressure.iloc[i])) + + + da = np.array(da) + + #print("\n\n\n\n") + #print(da) + #print("\n\n\n\n") + + upper_force = da[:10].sum() + lower_force = da[10 :].sum() + + force = lower_force - upper_force # Upper Sum (1-10) less Lower Sum (11-19) + lift = force * cos(aoa) + drag = force * sin(aoa) + # Extrapolate Aerofoil Tip p1 = (PITOT_PLACEMENT[9], pressure.iloc[9]) p2 = (PITOT_PLACEMENT[18], pressure.iloc[18]) - pN = (0.9*CHORD_LEN, p2[1] + (p1[1]-p2[1])/2) + pN = (1.1*max(PITOT_PLACEMENT), p2[1] + (p1[1]-p2[1])/2) #print(aoa, rpm, p1[1], p2[1], (p1[1]-p2[1])/2, pN[1], pN[1] > p1[1]) @@ -94,14 +118,14 @@ def make_pressure_graph(sheet1, aoa, rpm, air_speed, doGraph=True): # Draw Points & text {"x":PITOT_PLACEMENT, "y":pressure, "label":"Pressure Data", "type":"scatter", "args":{"zorder":2}}, {"label":[str(i) for i in range(1, len(PITOT_PLACEMENT)+1)], "x":PITOT_PLACEMENT, "y":pressure, "type":"annotate"}, - {"type":"text", "x": 0.98, "y": 0.02, "text": f"Min: {pressure.min():.3f} Pa\nMax: {pressure.max():.3f} Pa", "align": ('bottom', 'right')} + {"type":"text", "x": 0.98, "y": 0.02, "text": f"Min: {pressure.min():.3f} Pa\nMax: {pressure.max():.3f} Pa\nForce: {force:.3f}N\nLift: {lift:.3f}N\nDrag: {drag:.3f}N", "align": ('bottom', 'right')} ] } if doGraph: makeGraph(graph, False, figSavePath=f'./images/pressure/{{0}}.png', closeFig=True) - return pressure, graph, (water_density, air_density, atm_presure_inch, pitot_height_inch), (p1, p2, pN) + return pressure, graph, (water_density, air_density, atm_presure_inch, pitot_height_inch), (p1, p2, pN), aoa, (force, lift, drag, da, upper_force, lower_force) def make_cp_graph(pressure, aoa, rpm, air_speed, data, doGraph=True): @@ -113,30 +137,6 @@ def make_cp_graph(pressure, aoa, rpm, air_speed, data, doGraph=True): # Calculate Cp cp = pressure / (0.5 * air_density * (air_speed ** 2)) - # Do the trapiztoal rule integration - da = [] - for i, _ in enumerate(pressure): - if i in [0]: continue # Skip 0 - if i in [10]: # Force tapping 11 to use tapping 1 rather then 0 - da.append(((PITOT_PLACEMENT_CHORD_NORM[i] - PITOT_PLACEMENT_CHORD_NORM[0])/2) * (pressure.iloc[0] + pressure.iloc[i])) - continue - - da.append(((PITOT_PLACEMENT_CHORD_NORM[i] - PITOT_PLACEMENT_CHORD_NORM[i-1])/2) * (pressure.iloc[i-1] + pressure.iloc[i])) - - - da = np.array(da) - - #print("\n\n\n\n") - #print(da) - #print("\n\n\n\n") - - upper_force = da[:10].sum() - lower_force = da[10 :].sum() - - force = lower_force - upper_force # Upper Sum (1-10) less Lower Sum (11-19) - lift = force * cos(aoa) - drag = force * sin(aoa) - #print("force, lift, drag, upper_force, lower_force") #print(force, lift, drag, upper_force, lower_force) @@ -153,7 +153,7 @@ def make_cp_graph(pressure, aoa, rpm, air_speed, data, doGraph=True): graph = { "title": f"$C_p$ vs Pitot Placement along Chord\nfor a Clark Y 14% Aerofoil at:\nα = {int(aoa):d}° at {rpm:d} RPM ({air_speed:.1f}m/s)", "windowTitle": f"Cp along Clark Y 14 Percent Airfoil - Alpha {int(aoa):d} Degrees - {rpm:d}rpm - {air_speed:.1f}m_s", - "xLabel": "Normalized Pitot Placement", + "xLabel": "Pitot Placement [m]", "yLabel": "$C_p$", "grid": True, "yLim": (cp.min()-0.5, cp.max()+0.5), @@ -178,14 +178,14 @@ def make_cp_graph(pressure, aoa, rpm, air_speed, data, doGraph=True): # Draw Points & text {"x":PITOT_PLACEMENT_CHORD_NORM, "y":cp, "label":"cp Data", "type":"scatter", "args":{"zorder":2}}, {"label":[str(i) for i in range(1, len(PITOT_PLACEMENT_CHORD_NORM)+1)], "x":PITOT_PLACEMENT_CHORD_NORM, "y":cp, "type":"annotate"}, - {"type":"text", "x": 0.98, "y": 0.02, "text": f"Min $C_p$: {cp.min():.3f}\nMax $C_p$: {cp.max():.3f}\nForce: {force:.3f}N\nLift: {lift:.3f}N\nDrag: {drag:.3f}N", "align": ('bottom', 'right')} + {"type":"text", "x": 0.98, "y": 0.02, "text": f"Min $C_p$: {cp.min():.3f}\nMax $C_p$: {cp.max():.3f}", "align": ('bottom', 'right')} ] } if doGraph: makeGraph(graph, False, figSavePath=f'./images/cp/{{0}}.png', closeFig=True) - return cp, (force, lift, drag, da, upper_force, lower_force), graph, (p1, p2, pN), aoa + return cp, graph, (p1, p2, pN), aoa def make_rpm_graph(): @@ -225,14 +225,16 @@ if __name__ == '__main__': data = {} for raw_data in tqdm((data_508rpm, data_1000rpm), position=0): aoa_data = {} + cp_pain_data = [] for aoa in tqdm(raw_data["AoA"], position=1): sheet = raw_data["data"][f"{aoa} AoA"] - aoa_data[aoa] = make_pressure_graph(sheet, aoa, raw_data["rpm"], raw_data["airSpeed"], False) + aoa_data[aoa] = make_pressure_graph(sheet, aoa, raw_data["rpm"], raw_data["airSpeed"], True) + cp_pain_data.append(aoa_data[aoa]) data[raw_data["rpm"]] = aoa_data - if False: + if True: # All graph = { "title": f"Pressure vs Pitot Placement along Chord\nfor a Clark Y 14% Aerofoil at:\n{raw_data["rpm"]:d} RPM ({raw_data["airSpeed"]:.1f}m/s)", @@ -315,6 +317,36 @@ if __name__ == '__main__': makeGraph(graph, False, figSavePath="./images/pressure/__{0}.png") + + if True: + aoa = [a[-2] for a in cp_pain_data][1::2] + forces = [a[-1] for a in cp_pain_data][1::2] + # Force Graphs + graph = { + "title": f"All Total, Lift & Drag Forces\nfor a Clark Y 14% Aerofoil at:\n{raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m/s)", + "windowTitle": f"All Total, Lift and Drag Forces for a Clark Y 14 Percent Airfoil - {raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m_s", + "xLabel": "Attack Angle [$\\alpha$]", + "yLabel": "Force [N]", + "grid": True, + "ledgLoc": 1, + "plots": [ + {"x":aoa, "y":[f[0] for f in forces], "label":"Total Force"}, + {"x":aoa, "y":[f[1] for f in forces], "label":"Lift"}, + {"x":aoa, "y":[f[2] for f in forces], "label":"Drag"}, + ] + } + + makeGraph(graph, False, figSavePath="./images/{0}.png", closeFig=True) + + + print("\n\n") + print(raw_data["rpm"]) + print("AoA Total Lift Drag ---- Upper Force Lower Force ") + for aoa, force in [(a[-2], a[-1]) for a in cp_pain_data]: + print(f"{aoa:d}\\textdegree & {force[0]:.3f} & {force[1]:.3f} & {force[2]:.3f} -- {force[4]:.3f} {force[5]:.3f} \\\\") + print("-"*50) + print("\n\n") + print("Generating Cp Graphs") cp_data = {} @@ -333,7 +365,7 @@ if __name__ == '__main__': graph = { "title": f"All $C_p$ vs Pitot Placement along Chord\nfor a Clark Y 14% Aerofoil at:\n{raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m/s)", "windowTitle": f"All Cp along Clark Y 14 Percent Airfoil - {raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m_s", - "xLabel": "Normalized Pitot Placement", + "xLabel": "Pitot Placement [m]", "yLabel": "$C_p$", "grid": True, "ledgLoc": 1, @@ -345,7 +377,7 @@ if __name__ == '__main__': cp = this_data[0] # Extrapolate Aerofoil Tip - p1, p2, pN = this_data[3] + p1, p2, pN = this_data[2] plts = ( # Draw Lines @@ -358,7 +390,7 @@ if __name__ == '__main__': {"x": [PITOT_PLACEMENT_CHORD_NORM[9], pN[0]], "y": [cp.iloc[18], pN[1]], "colour": c["color"], "args":{"alpha":0.3}}, # Draw Points & text - {"x":PITOT_PLACEMENT_CHORD_NORM, "y":cp, "label":f"α = {int(this_data[4]):d}°", "type":"scatter", "args":{"zorder":2}, "colour": c["color"]}, + {"x":PITOT_PLACEMENT_CHORD_NORM, "y":cp, "label":f"α = {int(this_data[-1]):d}°", "type":"scatter", "args":{"zorder":2}, "colour": c["color"]}, ) for plt in plts: graph["plots"].append(plt) @@ -381,7 +413,7 @@ if __name__ == '__main__': cp = this_data[0] # Extrapolate Aerofoil Tip - p1, p2, pN = this_data[3] + p1, p2, pN = this_data[2] plts = ( # Draw Lines @@ -394,59 +426,12 @@ if __name__ == '__main__': {"x": [PITOT_PLACEMENT_CHORD_NORM[9], pN[0]], "y": [cp.iloc[18], pN[1]], "colour": c["color"], "args":{"alpha":0.3}}, # Draw Points & text - {"x":PITOT_PLACEMENT_CHORD_NORM, "y":cp, "label":f"α = {int(this_data[4]):d}°", "type":"scatter", "args":{"zorder":2}, "colour": c["color"]}, + {"x":PITOT_PLACEMENT_CHORD_NORM, "y":cp, "label":f"α = {int(this_data[-1]):d}°", "type":"scatter", "args":{"zorder":2}, "colour": c["color"]}, ) for plt in plts: graph["plots"].append(plt) makeGraph(graph, False, figSavePath="./images/cp/__{0}.png", closeFig=True) - if True: - aoa = [a[4] for a in cp_pain_data] - forces = [a[1] for a in cp_pain_data] - # Force Graphs - graph = { - "title": f"All Total, Lift & Drag Forces\nfor a Clark Y 14% Aerofoil at:\n{raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m/s)", - "windowTitle": f"All Total, Lift and Drag Forces for a Clark Y 14 Percent Airfoil - {raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m_s", - "xLabel": "Attack Angle [$\\alpha$]", - "yLabel": "Force [N]", - "grid": True, - "ledgLoc": 1, - "plots": [ - {"x":aoa, "y":[f[0] for f in forces], "label":"Total Force"}, - {"x":aoa, "y":[f[1] for f in forces], "label":"Lift"}, - {"x":aoa, "y":[f[2] for f in forces], "label":"Drag"}, - ] - } - - makeGraph(graph, False, figSavePath="./images/{0}.png", closeFig=True) - - aoa = [a[4] for a in cp_pain_data][1::2] - forces = [a[1] for a in cp_pain_data][1::2] - # Force Graphs - graph = { - "title": f"All Total, Lift & Drag Forces\nfor a Clark Y 14% Aerofoil at:\n{raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m/s)", - "windowTitle": f"All Total, Lift and Drag Forces for a Clark Y 14 Percent Airfoil - {raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m_s", - "xLabel": "Attack Angle [$\\alpha$]", - "yLabel": "Force [N]", - "grid": True, - "ledgLoc": 1, - "plots": [ - {"x":aoa, "y":[f[0] for f in forces], "label":"Total Force"}, - {"x":aoa, "y":[f[1] for f in forces], "label":"Lift"}, - {"x":aoa, "y":[f[2] for f in forces], "label":"Drag"}, - ] - } - - makeGraph(graph, False, figSavePath="./images/{0}.png", closeFig=True) - - if True: - print("\n\n") - print(raw_data["rpm"]) - print("AoA Total Lift Drag ---- Upper Force Lower Force ") - for aoa, force in [(a[4], a[1]) for a in cp_pain_data]: - print(f"{aoa:d}\\textdegree & {force[0]:.3f} & {force[1]:.3f} & {force[2]:.3f} -- {force[4]:.3f} {force[5]:.3f} \\\\") - print("-"*50) - print("\n\n") print("Complete")