Skip to content

Commit c61ff5a

Browse files
committed
tests
1 parent 5bce62f commit c61ff5a

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

openaerostruct/tests/test_aerostruct_wingbox_wave_fuel_vol_constraint_opt.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test(self):
289289
# Airfoil properties for viscous drag calculation
290290
"k_lam": 0.05, # percentage of chord with laminar
291291
# flow, used for viscous drag
292-
"t_over_c_cp": np.array([0.08, 0.08, 0.08, 0.10, 0.10, 0.08]),
292+
"t_over_c_cp": 0.12 * np.ones(6), # np.array([0.08, 0.08, 0.08, 0.10, 0.10, 0.12]),
293293
"original_wingbox_airfoil_t_over_c": 0.12,
294294
"c_max_t": 0.38, # chordwise location of maximum thickness
295295
"with_viscous": True,
@@ -317,10 +317,11 @@ def test(self):
317317

318318
# Add problem information as an independent variables component
319319
indep_var_comp = om.IndepVarComp()
320-
indep_var_comp.add_output("v", val=0.85 * 295.07, units="m/s")
320+
Mach = 0.77
321+
indep_var_comp.add_output("v", val=Mach * 295.07, units="m/s")
321322
indep_var_comp.add_output("alpha", val=0.0, units="deg")
322-
indep_var_comp.add_output("Mach_number", val=0.85)
323-
indep_var_comp.add_output("re", val=0.348 * 295.07 * 0.85 * 1.0 / (1.43 * 1e-5), units="1/m")
323+
indep_var_comp.add_output("Mach_number", val=Mach)
324+
indep_var_comp.add_output("re", val=0.348 * 295.07 * Mach * 1.0 / (1.43 * 1e-5), units="1/m")
324325
indep_var_comp.add_output("rho", val=0.348, units="kg/m**3")
325326
indep_var_comp.add_output("CT", val=0.53 / 3600, units="1/s")
326327
indep_var_comp.add_output("R", val=14.307e6, units="m")
@@ -412,7 +413,7 @@ def test(self):
412413
prob.model.add_design_var("wing.twist_cp", lower=-15.0, upper=15.0, scaler=0.1)
413414
prob.model.add_design_var("wing.spar_thickness_cp", lower=0.003, upper=0.1, scaler=1e2)
414415
prob.model.add_design_var("wing.skin_thickness_cp", lower=0.003, upper=0.1, scaler=1e2)
415-
prob.model.add_design_var("wing.geometry.t_over_c_cp", lower=0.07, upper=0.2, scaler=10.0)
416+
prob.model.add_design_var("wing.geometry.t_over_c_cp", lower=0.06, upper=0.2, scaler=10.0)
416417

417418
prob.model.add_constraint("AS_point_0.CL", equals=0.5)
418419
prob.model.add_constraint("AS_point_0.wing_perf.failure", upper=0.0)
@@ -429,8 +430,9 @@ def test(self):
429430

430431
prob.run_driver()
431432

432-
assert_near_equal(prob["AS_point_0.fuelburn"][0], 78292.730861421, 1e-5)
433-
assert_near_equal(prob["wing.structural_mass"][0] / 1.25, 16168.330307591294, 1e-5)
433+
self.assertEqual(prob.driver.get_exit_status(), "SUCCESS")
434+
assert_near_equal(prob["AS_point_0.fuelburn"][0], 85348.88283214, 1e-5)
435+
assert_near_equal(prob["wing.structural_mass"][0], 13029.71120634, 1e-5)
434436

435437

436438
if __name__ == "__main__":

openaerostruct/tests/test_scaneagle.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
from openaerostruct.geometry.utils import generate_mesh
99
from openaerostruct.integration.aerostruct_groups import AerostructGeometry, AerostructPoint
1010
from openaerostruct.utils.constants import grav_constant
11+
from openaerostruct.utils.testing import assert_check_totals
1112

1213

1314
class Test(unittest.TestCase):
14-
def test(self):
15+
def setUp(self):
1516
# Total number of nodes to use in the spanwise (num_y) and
1617
# chordwise (num_x) directions. Vary these to change the level of fidelity.
1718
num_y = 21
@@ -86,7 +87,7 @@ def test(self):
8687
"c_max_t": 0.303, # chordwise location of maximum (NACA0015)
8788
# thickness
8889
"with_viscous": True,
89-
"with_wave": False, # if true, compute wave drag
90+
"with_wave": True, # if true, compute wave drag
9091
# Material properties taken from http://www.performance-composites.com/carbonfibre/mechanicalproperties_2.asp
9192
"E": 85.0e9,
9293
"G": 25.0e9,
@@ -200,13 +201,29 @@ def test(self):
200201
# Set up the problem
201202
prob.setup()
202203

203-
# Actually run the optimization problem
204-
prob.run_driver()
204+
self.prob = prob
205205

206-
assert_near_equal(prob["AS_point_0.fuelburn"][0], 4.6365011384888275, 1e-5)
207-
assert_near_equal(prob["wing.twist_cp"], np.array([2.25819837, 10.39881572, 5.0]), 1e-5)
208-
assert_near_equal(prob["wing.sweep"][0], 18.964409030629632, 1e-5)
209-
assert_near_equal(prob["alpha"][0], 2.0366563718492547, 1e-5)
206+
def test_opt(self):
207+
# Actually run the optimization problem
208+
self.prob.run_driver()
209+
210+
assert_near_equal(self.prob["AS_point_0.fuelburn"][0], 4.6365011384888275, 1e-5)
211+
assert_near_equal(self.prob["wing.twist_cp"], np.array([2.25819837, 10.39881572, 5.0]), 1e-5)
212+
assert_near_equal(self.prob["wing.sweep"][0], 18.964409030629632, 1e-5)
213+
assert_near_equal(self.prob["alpha"][0], 2.0366563718492547, 1e-5)
214+
215+
def test_totals(self):
216+
self.prob.run_model()
217+
totals = self.prob.check_totals(
218+
method="fd",
219+
form="central",
220+
step=5e-4,
221+
step_calc="rel",
222+
compact_print=True,
223+
abs_err_tol=1e-2,
224+
rel_err_tol=1e-5,
225+
)
226+
assert_check_totals(totals, atol=1e-4, rtol=1e-5)
210227

211228

212229
if __name__ == "__main__":

0 commit comments

Comments
 (0)