-
Notifications
You must be signed in to change notification settings - Fork 2
/
sweep.py
68 lines (58 loc) · 1.69 KB
/
sweep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os, sys
sys.path.insert(0, os.path.abspath(".."))
from design_opt import *
param_range = np.linspace(1, 1.169, 30)
outputs = []
for i, param in enumerate(param_range):
print(f"{'-' * 50}\nIteration {i + 1} of {len(param_range)}\n{'-' * 50}")
opti.set_value(wing_drag_multiplier, param)
try:
sol = opti.solve()
opti.set_initial(sol.value_variables())
opti.set_initial(opti.lam_g, sol.value(opti.lam_g))
outputs.append(sol.value(wing_span))
except:
outputs.append(np.NaN)
outputs = np.array(outputs)
import matplotlib.pyplot as plt
from matplotlib import style
import seaborn as sns
sns.set(font_scale=1)
fig, ax = plt.subplots(1, 1, figsize=(6.4, 4.8), dpi=200)
plt.plot(100 * (param_range - 1), outputs, ".-")
plt.axvline(x=0, ls='--', color="gray")
plt.text(
x=0,
y=0.95*ax.get_ylim()[1]+(1-0.95)*ax.get_ylim()[0],
s="Previous Baseline",
color="gray",
horizontalalignment='right',
verticalalignment='top',
rotation=90
)
plt.axvline(x=16.9, ls='--', color="gray")
plt.text(
x=16.9,
y=0.05*ax.get_ylim()[1]+(1-0.05)*ax.get_ylim()[0],
s="Conservative Worst-Case",
color="gray",
horizontalalignment='right',
verticalalignment='bottom',
rotation=90
)
plt.axvline(x=16.9 * 0.75, ls='--', color="gray")
plt.text(
x=16.9 * 0.75,
y=0.05*ax.get_ylim()[1]+(1-0.05)*ax.get_ylim()[0],
s="New Baseline?",
color="gray",
horizontalalignment='right',
verticalalignment='bottom',
rotation=90
)
plt.xlabel(r"Increase in Wing Drag over Baseline [%]")
plt.ylabel(r"Wing Span [m]")
plt.title(r"Effect of Tripped Boundary Layers on Vehicle Sizing")
plt.tight_layout()
plt.legend()
plt.show()