Skip to content

Commit

Permalink
Merge pull request #633 from suavecode/fix_rotor
Browse files Browse the repository at this point in the history
Fix rotor
  • Loading branch information
planes committed Nov 29, 2022
2 parents f01d6a2 + f1b984b commit 469036e
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 61 deletions.
4 changes: 2 additions & 2 deletions regression/scripts/AVL/test_AVL.py
Expand Up @@ -141,7 +141,7 @@ def main():

# lift coefficient check
lift_coefficient = results.segments.cruise.conditions.aerodynamics.lift_coefficient[0][0]
lift_coefficient_true = 0.6124936427552575
lift_coefficient_true = 0.6125259974142665

print(lift_coefficient)
diff_CL = np.abs(lift_coefficient - lift_coefficient_true)
Expand All @@ -151,7 +151,7 @@ def main():

# moment coefficient check
moment_coefficient = results.segments.cruise.conditions.stability.static.CM[0][0]
moment_coefficient_true = -0.5764235338199974
moment_coefficient_true = -0.5764667256663776

print(moment_coefficient)
diff_CM = np.abs(moment_coefficient - moment_coefficient_true)
Expand Down
2 changes: 1 addition & 1 deletion regression/scripts/B737/results_mission_B737.res

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions regression/scripts/Regional_Jet_Optimization/Optimize2.py
Expand Up @@ -39,10 +39,10 @@ def main():
print(con3)

actual = Data()
actual.obj = 0.66680042
actual.con = 2.89275501
actual.obj2 = 0.69643961
actual.con3 = 3.08464784
actual.obj = 0.6645457
actual.con = 2.89918485
actual.obj2 = 0.69389189
actual.con3 = 3.09059233

error = Data()
error.obj = (actual.obj - obj)/actual.obj
Expand Down
2 changes: 1 addition & 1 deletion regression/scripts/aerodynamics/aerodynamics_results.res
@@ -1 +1 @@
{"lift": [[-0.5259630550568174], [-0.3760451720034401], [-0.3475304118160083], [-0.24452696114041383], [-0.003967881856492357], [0.26347572475103526], [0.46598722965669714], [0.6889146999385382], [1.0119888177923257], [1.4020969697893308], [1.3459572899206365]], "cd_c": [[0.00021084213592037642], [3.216025849507262e-08], [1.7266684526204684e-22], [3.2904740881154703e-09], [0.0005339274191304674], [4.644407858546013e-05], [1.5108473501523067e-09], [2.3892863212650703e-11], [4.142548005778556e-05], [0.0026569168600391714], [4.8816063850836635e-14]], "cd_i": [[0.017628827563233505], [0.011808053631861447], [0.010803464137949876], [0.0067126108543920735], [0.0027304524751980115], [0.004614811166757508], [0.012401997536030988], [0.026706125679655527], [0.052429912509830055], [0.09272377262369227], [0.10637381506803112]], "cd_m": [[0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587]], "cd_p_fuse": [[0.004946796492229381], [0.005779147627615916], [0.008926136636732203], [0.005664504686306866], [0.005781749578763487], [0.004836139656952647], [0.005932995796868884], [0.007354422551288761], [0.005775532561515405], [0.005181868350841586], [0.006015432386719305]], "cd_p_wing": [[0.005798868938543027], [0.005927946059650478], [0.009429864691794812], [0.005732597261818282], [0.0065300434752118205], [0.00501664506296736], [0.005990576383227908], [0.007597374507523542], [0.006009631658542192], [0.005562832184720839], [0.006025780055498028]], "cd_tot": [[0.036147188285001824], [0.030083172706561703], [0.038839811604950675], [0.024413069226369204], [0.02269722921446303], [0.020122392432332686], [0.030977266721887275], [0.05002292710332585], [0.07170013330317539], [0.11427882129980278], [0.12698533787625896]]}
{"lift": [[-0.5259630548735018], [-0.37604517190863146], [-0.3475304118725103], [-0.24452696096385945], [-0.003967881653940969], [0.2634757253938914], [0.46598723017773197], [0.688914700606597], [1.0119888185935246], [1.4020969707315618], [1.3459572911433624]], "cd_c": [[0.0002108421359963761], [3.2160258502353464e-08], [1.7266684529335444e-22], [3.2904740887327617e-09], [0.000533927419149616], [4.6444078584106674e-05], [1.5108473500279697e-09], [2.389286321020139e-11], [4.142548005311629e-05], [0.002656916860077522], [4.881606384980262e-14]], "cd_i": [[0.017628827555745446], [0.011808053598313455], [0.010803464107462003], [0.006712610832532182], [0.002730452465217076], [0.004614811173823257], [0.012401997552561989], [0.02670612571277804], [0.052429912563271966], [0.09272377271092394], [0.10637381518027891]], "cd_m": [[0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587], [0.0011255918999274587]], "cd_p_fuse": [[0.004946796492229381], [0.005779147627615916], [0.008926136636732203], [0.005664504686306866], [0.005781749578763487], [0.004836139656952647], [0.005932995796868884], [0.007354422551288761], [0.005775532561515405], [0.005181868350841586], [0.006015432386719305]], "cd_p_wing": [[0.005798868938543027], [0.005927946059650478], [0.009429864691794812], [0.005732597261818282], [0.0065300434752118205], [0.00501664506296736], [0.005990576383227908], [0.007597374507523542], [0.006009631658542192], [0.005562832184720839], [0.006025780055498028]], "cd_tot": [[0.03531806817991019], [0.030083097303558317], [0.038839811573853036], [0.024413064835146384], [0.02248085232699704], [0.02011383189665597], [0.03097726654153106], [0.05002292713486758], [0.07169738680074404], [0.11408212364314657], [0.12698533799074646]]}
@@ -1 +1 @@
{"CL": [-0.29720186925002035, 0.33834971768961464, 0.9595777066043815, -0.3167309679838157, 0.30943821920666836, 0.9157391929138856, -0.1914640232768408, 0.4093977795624484, 0.9819953212211241], "CDi": [0.021208501808035806, 0.013598563518241147, 0.0658330743959147, 0.043118905010923914, 0.028550015888229776, 0.07370811948530372, 0.10914058053146088, 0.09741034034681852, 0.14366943311207356], "CM": [0.20453038484502795, -0.6374102387969508, -1.4635778378551703, 1.2148330984404698, 0.38820808150475056, -0.4375665458027248, 1.5898563244892279, 0.7901615069649182, -0.010244539859071405]}
{"CL": [-0.29720186878924787, 0.3383497179239063, 0.9595777065891437, -0.3167309673245075, 0.30943821976675145, 0.9157391933420813, -0.1914640234430447, 0.4093977780983102, 0.9819953184645844], "CDi": [0.021208501734265337, 0.013598563593377919, 0.06583307457673096, 0.04311890497828657, 0.028550016040742556, 0.07370811973286943, 0.10914058183610603, 0.09741034184271874, 0.14366943495424145], "CM": [0.20453038370934515, -0.6374102399771059, -1.463577839065431, 1.2148330942911774, 0.38820807739555296, -0.4375665498001729, 1.5898563236149348, 0.790161507051483, -0.01024454]}
Binary file modified regression/scripts/multifidelity/f_data.npy
Binary file not shown.
Binary file modified regression/scripts/multifidelity/x_samples.npy
Binary file not shown.
2 changes: 1 addition & 1 deletion regression/scripts/noise_optimization/Noise_Test.py
Expand Up @@ -40,7 +40,7 @@ def main():
# Compare with truth values
noise_cumulative_margin = objectives[0]
actual = Data()
actual.noise_cumulative_margin = 21.586738829964858
actual.noise_cumulative_margin = 21.639139008007746


error = Data()
Expand Down
16 changes: 8 additions & 8 deletions regression/scripts/propeller/propeller_test.py
Expand Up @@ -219,10 +219,10 @@ def main():
Cplast_a_truth = 0.10450832

# Truth values for propeller without airfoil geometry defined
F_truth = 2629.013537561697
Q_truth = 787.38469662
P_truth = 163115.87734548
Cplast_truth = 0.08407389
F_truth = 2682.883049614873
Q_truth = 804.66619031
P_truth = 166695.93931239
Cplast_truth = 0.08591914

# Truth values for rotor with airfoil geometry defined
Fr_a_truth = 1266.0906132241278
Expand All @@ -231,10 +231,10 @@ def main():
Cplastr_a_truth = 0.03486995

# Truth values for rotor without airfoil geometry defined
Fr_truth = 1250.185882189092
Qr_truth = 121.95416738
Pr_truth = 25264.22102656
Cplastr_truth = 0.03973936
Fr_truth = 1276.4378657580712
Qr_truth = 125.37681959
Pr_truth = 25973.26315058
Cplastr_truth = 0.04085465

# Store errors
error = Data()
Expand Down
38 changes: 19 additions & 19 deletions regression/scripts/segments/segment_test.py
Expand Up @@ -74,25 +74,25 @@ def main():
print(val)

# Truth values
climb_throttle_1_truth = 1.0779171064877817
climb_throttle_2_truth = 1.0825265840224687
climb_throttle_3_truth = 0.674660268669148
climb_throttle_4_truth = 1.1315606426230955
climb_throttle_5_truth = 1.1836691794281005
climb_throttle_6_truth = 0.7820927446131135
climb_throttle_7_truth = 0.9575782120087092
climb_throttle_8_truth = 1.1806251177582514
climb_throttle_9_truth = 1.2803044387670226
climb_throttle_10_truth = 1.0
cruise_CL_1_truth = 0.697527528118587
cruise_CL_2_truth = 0.6978305032649874
cruise_CL_3_truth = 0.7853555716641899
descent_throttle_1_truth = 0.09557733021666127
descent_throttle_2_truth = 0.2467066714518043
single_pt_CL_1_truth = 0.25119411851114865
single_pt_CL_2_truth = 0.2511952953215362
loiter_CL_truth = 0.5115243029776504
descent_throttle_3_truth = 0.17985343172510482
climb_throttle_1_truth = 1.0779172001580994
climb_throttle_2_truth = 1.082526695692354
climb_throttle_3_truth = 0.6746599245287441
climb_throttle_4_truth = 1.131556307691754
climb_throttle_5_truth = 1.183629999830914
climb_throttle_6_truth = 0.7796000622149822
climb_throttle_7_truth = 0.9470934374535483
climb_throttle_8_truth = 1.1619277522734948
climb_throttle_9_truth = 1.260973822735993
climb_throttle_10_truth = 1.0
cruise_CL_1_truth = 0.6977166846933968
cruise_CL_2_truth = 0.6980183965324797
cruise_CL_3_truth = 0.7854348456470898
descent_throttle_1_truth = 0.09562278771507186
descent_throttle_2_truth = 0.24681832658985817
single_pt_CL_1_truth = 0.2512631812992136
single_pt_CL_2_truth = 0.25126434016263305
loiter_CL_truth = 0.5116647507936652
descent_throttle_3_truth = 0.17994332698047444

# Store errors
error = Data()
Expand Down
16 changes: 10 additions & 6 deletions regression/scripts/segments/transition_segment_test.py
Expand Up @@ -55,17 +55,21 @@ def main():
transition_1_throttle = results.segments.transition_1.conditions.propulsion.throttle[:,0]
cruise_throttle = results.segments.cruise.conditions.propulsion.throttle[:,0]

print(departure_throttle)
print(transition_1_throttle)
print(cruise_throttle)

# Truth values
departure_throttle_truth = 0.651687547816525
transition_1_throttle_truth = 0.601399797479313
cruise_throttle_truth = 0.4649280739025156
departure_throttle_truth = 0.6516875478807475
transition_1_throttle_truth = 0.6013997974737667
cruise_throttle_truth = 0.46492807449474316

# Store errors
error = Data()
error.departure_throttle = np.abs(departure_throttle[-1] - departure_throttle_truth)
error.transition_1_throttle = np.abs(transition_1_throttle[-1] - transition_1_throttle_truth)
error.cruise_throttle = np.abs(cruise_throttle[-1] - cruise_throttle_truth)

error.transition_1_throttle = np.abs(transition_1_throttle[-1] - transition_1_throttle_truth)
error.cruise_throttle = np.abs(cruise_throttle[-1] - cruise_throttle_truth)
print('Errors:')
print(error)

Expand Down
8 changes: 4 additions & 4 deletions regression/scripts/solar_network/solar_network.py
Expand Up @@ -74,10 +74,10 @@ def main():

# Truth results

truth_F = 82.5075384708843
truth_rpm = 196.48257054445452
truth_i = 86.20577553870862
truth_bat = 124605420.10966778
truth_F = 82.50753846534539
truth_rpm = 194.40119841317366
truth_i = 86.06579017876555
truth_bat = 124628733.8676211

print('battery energy')
print(energy)
Expand Down
6 changes: 3 additions & 3 deletions regression/scripts/sweeps/test_sweeps.py
Expand Up @@ -31,7 +31,7 @@ def main():

outputs_sweep = linear_sweep(problem)

truth_obj_sweeps = [[6964.39612518, 6400.84619649]]
truth_obj_sweeps = [[6938.91890449, 6372.63693836]]

print('sweeps = {}'.format(outputs_sweep['objective']))

Expand All @@ -44,8 +44,8 @@ def main():

outputs_carpet = variable_sweep(problem)

truth_obj_carp = [[6867.55035192, 6407.40469717],
[7185.2512495 , 6375.68648074]]
truth_obj_carp = [[6845.86363474, 6382.72737946],
[7160.2722498, 6350.28087445]]
print('carpet:\n{}'.format(outputs_carpet['objective']))

#print outputs_carpet
Expand Down
Expand Up @@ -45,7 +45,7 @@ def main():

plot_results(results)

distance_regression = 3902453.700210854
distance_regression = 3909067.571732345
distance_calc = results.conditions.frames.inertial.position_vector[-1,0]
print('distance_calc = ', distance_calc)
error_distance = abs((distance_regression - distance_calc )/distance_regression)
Expand Down
30 changes: 25 additions & 5 deletions trunk/SUAVE/Input_Output/OpenVSP/vsp_read.py
Expand Up @@ -15,10 +15,11 @@
from copy import deepcopy

import SUAVE
from SUAVE.Input_Output.OpenVSP.vsp_propeller import read_vsp_propeller
from SUAVE.Input_Output.OpenVSP.vsp_fuselage import read_vsp_fuselage
from SUAVE.Input_Output.OpenVSP.vsp_wing import read_vsp_wing
from SUAVE.Input_Output.OpenVSP.vsp_nacelle import read_vsp_nacelle
from SUAVE.Input_Output.OpenVSP.vsp_propeller import read_vsp_propeller
from SUAVE.Input_Output.OpenVSP.vsp_fuselage import read_vsp_fuselage
from SUAVE.Input_Output.OpenVSP.vsp_wing import read_vsp_wing
from SUAVE.Input_Output.OpenVSP.vsp_nacelle import read_vsp_nacelle
from SUAVE.Input_Output.OpenVSP.get_vsp_measurements import get_vsp_measurements

from SUAVE.Components.Energy.Networks.Lift_Cruise import Lift_Cruise
from SUAVE.Components.Energy.Networks.Battery_Propeller import Battery_Propeller
Expand All @@ -40,7 +41,7 @@


## @ingroup Input_Output-OpenVSP
def vsp_read(tag, units_type='SI',specified_network=None,use_scaling=True):
def vsp_read(tag, units_type='SI',specified_network=None,use_scaling=True,calculate_wetted_area=True):
"""This reads an OpenVSP vehicle geometry and writes it into a SUAVE vehicle format.
Includes wings, fuselages, and propellers.
Expand Down Expand Up @@ -163,6 +164,17 @@ def vsp_read(tag, units_type='SI',specified_network=None,use_scaling=True):
geom_name = vsp.GetGeomName(geom)
geom_names.append(geom_name)
print(str(geom_name) + ': ' + geom)


# Use OpenVSP to calculate wetted area
if calculate_wetted_area:
measurements = get_vsp_measurements()
if units_type == 'SI':
units_factor = Units.meter * 1.
elif units_type == 'imperial':
units_factor = Units.foot * 1.
elif units_type == 'inches':
units_factor = Units.inch * 1.

# --------------------------------
# AUTOMATIC VSP ENTRY & PROCESSING
Expand Down Expand Up @@ -196,20 +208,28 @@ def vsp_read(tag, units_type='SI',specified_network=None,use_scaling=True):
sym_flag = [1]
for fux_idx in range(num_fus): # loop through fuselages on aircraft
fuselage = read_vsp_fuselage(fuselage_id,fux_idx,sym_flag[fux_idx],units_type,use_scaling)

if calculate_wetted_area:
fuselage.areas.wetted = measurements[vsp.GetGeomName(fuselage_id)] * (units_factor**2)

vehicle.append_component(fuselage)

# --------------------------------------------------
# Read Wings
# --------------------------------------------------
for wing_id in vsp_wings:
wing = read_vsp_wing(wing_id, units_type,use_scaling)
if calculate_wetted_area:
wing.areas.wetted = measurements[vsp.GetGeomName(wing_id)] * (units_factor**2)
vehicle.append_component(wing)

# --------------------------------------------------
# Read Nacelles
# --------------------------------------------------
for nac_id, nacelle_id in enumerate(vsp_nacelles):
nacelle = read_vsp_nacelle(nacelle_id,vsp_nacelle_type[nac_id], units_type)
if calculate_wetted_area:
nacelle.areas.wetted = measurements[vsp.GetGeomName(nacelle_id)] * (units_factor**2)
vehicle.append_component(nacelle)

# --------------------------------------------------
Expand Down
Expand Up @@ -59,7 +59,8 @@ def section_properties(state,settings,geometry):

# Calculate 2-D CLmax
# From 241 A/B notes
Cl_max_ref = -0.0009*tc*tc*tc + 0.0217*tc*tc - 0.0442*tc + 0.7005
tc_1 = tc*100
Cl_max_ref = -0.0009*tc_1*tc_1*tc_1 + 0.0217*tc_1*tc_1 - 0.0442*tc_1 + 0.7005
Re_ref = 9.*10**6
#CL1maxp = Cl_max_ref * ( RE / Re_ref ) **0.1
CL1maxp = 1.5 * np.ones_like(state.conditions.freestream.altitude)
Expand Down
Expand Up @@ -40,15 +40,17 @@ def compressibility_drag_wing_total(state,settings,geometry):
# unpack
conditions = state.conditions
wings = geometry.wings
S_ref = geometry.reference_area

#compute parasite drag total
total_compressibility_drag = 0.0

# from wings
for wing in wings.values():
s_wing = wing.areas.reference
compressibility_drag = conditions.aerodynamics.drag_breakdown.compressible[wing.tag].compressibility_drag
conditions.aerodynamics.drag_breakdown.compressible[wing.tag].compressibility_drag = compressibility_drag * 1. # avoid linking variables
total_compressibility_drag += compressibility_drag
total_compressibility_drag += compressibility_drag * (s_wing/S_ref)

conditions.aerodynamics.drag_breakdown.compressible.total = total_compressibility_drag

Expand Down
Expand Up @@ -83,7 +83,9 @@ def compute_airfoil_aerodynamics(beta,c,r,R,B,Wa,Wt,a,nu,airfoils,a_loc,ctrl_pts
Cdval[:,locs] = Cdval_af[:,locs]
else:
# Estimate Cl max
Cl_max_ref = -0.0009*tc**3 + 0.0217*tc**2 - 0.0442*tc + 0.7005
tc_1 = tc*100
Cl_max_ref = -0.0009*tc_1**3 + 0.0217*tc_1**2 - 0.0442*tc_1 + 0.7005
Cl_max_ref[Cl_max_ref<0.7] = 0.7
Re_ref = 9.*10**6
Cl1maxp = Cl_max_ref * ( Re / Re_ref ) **0.1

Expand All @@ -95,7 +97,8 @@ def compute_airfoil_aerodynamics(beta,c,r,R,B,Wa,Wt,a,nu,airfoils,a_loc,ctrl_pts
Cl[alpha>=np.pi/2] = 0.

# Scale for Mach, this is Karmen_Tsien
Cl[Ma[:,:]<1.] = Cl[Ma[:,:]<1.]/((1-Ma[Ma[:,:]<1.]*Ma[Ma[:,:]<1.])**0.5+((Ma[Ma[:,:]<1.]*Ma[Ma[:,:]<1.])/(1+(1-Ma[Ma[:,:]<1.]*Ma[Ma[:,:]<1.])**0.5))*Cl[Ma<1.]/2)
KT_cond = np.logical_and((Ma[:,:]<1.),(Cl>0))
Cl[KT_cond] = Cl[KT_cond]/((1-Ma[KT_cond]*Ma[KT_cond])**0.5+((Ma[KT_cond]*Ma[KT_cond])/(1+(1-Ma[KT_cond]*Ma[KT_cond])**0.5))*Cl[KT_cond]/2)

# If the blade segments are supersonic, don't scale
Cl[Ma[:,:]>=1.] = Cl[Ma[:,:]>=1.]
Expand Down

0 comments on commit 469036e

Please sign in to comment.