Skip to content

Commit

Permalink
updated aerodynamics init (#43)
Browse files Browse the repository at this point in the history
* updated aero init

* Updated reference values in drag polar tests to match OAS drag fix

* Updated reference values in aerostructural tests to match OAS drag fix

* Ran black on aerodynamics init file

* Updated reference values in examples that use OAS

Co-authored-by: eytanadler <[email protected]>
  • Loading branch information
kanekosh and eytanadler authored Oct 21, 2022
1 parent 8a7661f commit 805ebd2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
6 changes: 5 additions & 1 deletion openconcept/aerodynamics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
from .aerodynamics import PolarDrag, StallSpeed, Lift
from .openaerostruct import VLMDragPolar, AerostructDragPolar

try:
from .openaerostruct import VLMDragPolar, AerostructDragPolar
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_surf_options(self):
p.run_model()

# Ensure they're all the same
assert_near_equal(p.get_val("drag", units="N"), 33112.3426245 * np.ones(nn), tolerance=1e-10)
assert_near_equal(p.get_val("drag", units="N"), 33058.43316461 * np.ones(nn), tolerance=1e-10)

def test_vectorized(self):
nn = 7
Expand Down Expand Up @@ -218,7 +218,7 @@ def test_vectorized(self):
p.run_model()

# Ensure they're all the same
assert_near_equal(p.get_val("drag", units="N"), 35911.23954369 * np.ones(nn), tolerance=1e-10)
assert_near_equal(p.get_val("drag", units="N"), 35692.26543182 * np.ones(nn), tolerance=1e-10)


@unittest.skipIf(not OAS_installed, "OpenAeroStruct is not installed")
Expand Down Expand Up @@ -272,7 +272,7 @@ def test_defaults(self):
]
)
CD = np.array(
[[[0.0423459, 0.04473217], [0.07565092, 0.0781007]], [[0.03668226, 0.04308131], [0.11930142, 0.15852171]]]
[[[0.04196198, 0.04421198], [0.07526711, 0.07758053]], [[0.03631444, 0.04259311], [0.11894307, 0.158035]]]
)

assert_near_equal(p.get_val("CL_train"), CL, tolerance=1e-7)
Expand Down Expand Up @@ -338,7 +338,7 @@ def test_defaults(self):

# Use values computed offline from an OAS wingbox case with the same inputs
assert_near_equal(p.get_val("fltcond|CL"), 0.22369546, tolerance=1e-6)
assert_near_equal(p.get_val("fltcond|CD"), 0.01664464, tolerance=1e-6)
assert_near_equal(p.get_val("fltcond|CD"), 0.015608634462089457, tolerance=1e-6)
assert_near_equal(p.get_val("failure"), -0.64781499, tolerance=1e-6)
assert_near_equal(p.get_val("ac|weights|W_wing", units="kg"), 29322.10058108, tolerance=1e-6)

Expand All @@ -348,7 +348,7 @@ def test_wave_drag(self):

# Use values computed offline from an OAS wingbox case with the same inputs
assert_near_equal(p.get_val("fltcond|CL"), 0.22369546, tolerance=1e-6)
assert_near_equal(p.get_val("fltcond|CD"), 0.0164930472, tolerance=1e-6)
assert_near_equal(p.get_val("fltcond|CD"), 0.015457034121371742, tolerance=1e-6)
assert_near_equal(p.get_val("failure"), -0.64781499, tolerance=1e-6)
assert_near_equal(p.get_val("ac|weights|W_wing", units="kg"), 29322.10058108, tolerance=1e-6)

Expand Down Expand Up @@ -397,7 +397,7 @@ def test_defaults(self):
p.run_model()

# Use values computed offline from an OAS wingbox case with the same inputs
CD = CD0 + np.array([0.015167035551253, 0.015746642643445, 0.016644647603543])
CD = CD0 + np.array([0.014130134503259, 0.014710068221375, 0.015608634461878])
assert_near_equal(p.get_val("drag"), q * S * CD, tolerance=1e-6)
assert_near_equal(p.get_val("failure"), np.array([-0.89649433, -0.77578479, -0.64781499]), tolerance=1e-6)
assert_near_equal(p.get_val("ac|weights|W_wing", units="kg"), 29322.10058108, tolerance=1e-6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test(self):
mesh.get_val("fltcond|CL"), p.get_val("aero_surrogate.CL"), tolerance=1e-10
) # check convergence
assert_near_equal(6, p.get_val("alpha_bal.alpha", units="deg"), tolerance=1e-2)
assert_near_equal(mesh.get_val("fltcond|CD") + 0.01, p.get_val("aero_surrogate.CD"), tolerance=5e-2)
assert_near_equal(mesh.get_val("fltcond|CD") + 0.01, p.get_val("aero_surrogate.CD"), tolerance=6e-2)
assert_near_equal(p.get_val("drag", units="N"), p.get_val("aero_surrogate.CD") * 100 * 5e3, tolerance=5e-2)

def test_surf_options(self):
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_surf_options(self):
p.run_model()

# Ensure they're all the same
assert_near_equal(p.get_val("drag", units="N"), 34962.6043231 * np.ones(nn), tolerance=1e-10)
assert_near_equal(p.get_val("drag", units="N"), 34905.69308752 * np.ones(nn), tolerance=1e-10)

def test_vectorized(self):
nn = 7
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_vectorized(self):
p.run_model()

# Ensure they're all the same
assert_near_equal(p.get_val("drag", units="N"), 37845.94053713 * np.ones(nn), tolerance=1e-10)
assert_near_equal(p.get_val("drag", units="N"), 37615.14285108 * np.ones(nn), tolerance=1e-10)


@unittest.skipIf(not OAS_installed, "OpenAeroStruct is not installed")
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_defaults(self):
]
)
CD = np.array(
[[[0.03465792, 0.03701483], [0.06816224, 0.07051915]], [[0.03455214, 0.03648223], [0.20238882, 0.20431891]]]
[[[0.03425776, 0.03647253], [0.06776208, 0.06997685]], [[0.03415836, 0.03597205], [0.20199504, 0.20380873]]]
)

assert_near_equal(CL, p.get_val("CL_train"), tolerance=1e-7)
Expand Down
6 changes: 3 additions & 3 deletions openconcept/examples/tests/test_example_aircraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def tearDown(self):
def test_values_B738(self):
prob = self.prob
# block fuel
assert_near_equal(prob.get_val("descent.fuel_used_final", units="lbm"), 28443.39604559, tolerance=1e-5)
assert_near_equal(prob.get_val("descent.fuel_used_final", units="lbm"), 27841.06640683, tolerance=1e-5)
# total fuel
assert_near_equal(prob.get_val("loiter.fuel_used_final", units="lbm"), 34075.30721371, tolerance=1e-5)
assert_near_equal(prob.get_val("loiter.fuel_used_final", units="lbm"), 33412.41922187, tolerance=1e-5)


@unittest.skipIf(not OAS_installed, "OpenAeroStruct is not installed")
Expand All @@ -192,7 +192,7 @@ def tearDown(self):
def test_values_B738(self):
prob = self.prob
# block fuel
assert_near_equal(prob.get_val("descent.fuel_used_final", units="lbm"), 34310.44045734, tolerance=1e-5)
assert_near_equal(prob.get_val("descent.fuel_used_final", units="lbm"), 33611.18277099, tolerance=1e-5)


class N3HSATestCase(unittest.TestCase):
Expand Down

0 comments on commit 805ebd2

Please sign in to comment.