Skip to content

Commit

Permalink
Added test for N+3 HSA example
Browse files Browse the repository at this point in the history
  • Loading branch information
eytanadler committed Oct 27, 2021
1 parent 8d99e7d commit 5496e55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
2 changes: 1 addition & 1 deletion examples/HybridTwin_active_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from openconcept.utilities.visualization import plot_trajectory

"""
WARNING: This example has known convergence issues because of the chiller in the
WARNING: This example has known convergence problems because of the chiller in the
propulsion layout (TwinSeriesHybridElectricPropulsionRefrigerated)
Eytan Adler, 27/10/2021
Expand Down
36 changes: 11 additions & 25 deletions examples/tests/test_example_aircraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from examples.Caravan import run_caravan_analysis
from examples.KingAirC90GT import run_kingair_analysis
from examples.ElectricSinglewithThermal import run_electricsingle_analysis
from examples.N3_HybridSingleAisle_Refrig import run_hybrid_sa_analysis


class TBMAnalysisTestCase(unittest.TestCase):
Expand Down Expand Up @@ -130,29 +131,14 @@ def test_values_B738(self):
assert_near_equal(prob.get_val('loiter.fuel_used_final', units='lbm'), 34424.68533072, tolerance=3e-4)
# changelog: 9/2020 - previously 34555.313, updated CFM surrogate model to reject spurious high Mach, low altitude points

class N3HSATestCase(unittest.TestCase):
def setUp(self):
self.prob = run_hybrid_sa_analysis(plots=False)

def test_values_N3HSA(self):
prob = self.prob
# block fuel (no reserve, since the N+3 HSA uses the basic 3-phase mission)
assert_near_equal(prob.get_val('descent.fuel_used_final', units='lbm'), 9006.52397811, tolerance=1e-5)

if __name__=="__main__":
# unittest.main()

prob = run_hybrid_twin_active_thermal_analysis()

climb_duct_area = np.array([ 0.80614565, 3.25480096, 7.11240858, 12.075577 , 17.55488029,
23.40694116, 29.15510781, 34.44182758, 39.05343787, 43.00420553, 46.43866073])
cruise_duct_area = np.array([17.17611522, 15.22748148, 14.66271227, 14.38669164, 14.2745505 ,
14.20434496, 14.15713767, 14.11684779, 14.08034799, 14.04524349, 14.01099713])
prob.set_val('climb.propmodel.duct.area_nozzle', climb_duct_area, units='inch**2')
prob.set_val('cruise.propmodel.duct.area_nozzle', cruise_duct_area, units='inch**2')
prob.run_model()

assert_near_equal(prob.get_val('climb.OEW', units='lb'), 6673.001027260613, tolerance=1e-5)
# assert_near_equal(prob.get_val('descent.fuel_used_final', units='lb'), 871.66394047, tolerance=1e-5)
# assert_near_equal(prob.get_val('descent.propmodel.batt1.SOC_final', units=None), 0.00484123, tolerance=1e-5)

assert_near_equal(prob.get_val('climb.propmodel.duct.area_nozzle', units='inch**2'), climb_duct_area, tolerance=1e-5)
assert_near_equal(prob.get_val('cruise.propmodel.duct.area_nozzle', units='inch**2'), cruise_duct_area, tolerance=1e-5)
Wdot = np.array([ 6618.15094465, 17863.48477045, 25558.10458551, 30652.72996714, 33805.46342847, 35538.5460011,
36221.44062722, 36149.9707508, 35539.35428109, 34562.89222503, 33346.05141285])
assert_near_equal(prob.get_val('climb.propmodel.refrig.elec_load', units='W'), Wdot, tolerance=1e-5)
assert_near_equal(prob.get_val('cruise.propmodel.refrig.elec_load', units='W'), np.zeros(11), tolerance=1e-5)
assert_near_equal(prob.get_val('climb.propmodel.motorheatsink.T', units='degC')[-1], 76.48202028574951, tolerance=1e-5)
assert_near_equal(prob.get_val('climb.propmodel.batteryheatsink.T', units='degC')[-1], 6.9112870295027165, tolerance=1e-5)
assert_near_equal(prob.get_val('cruise.propmodel.duct.drag', units='lbf')[-1], 1.5888992670493287, tolerance=1e-5)
unittest.main()

0 comments on commit 5496e55

Please sign in to comment.