Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ aircraft:engine:flight_idle_max_fraction,1,unitless
aircraft:engine:flight_idle_min_fraction,0.08,unitless
aircraft:engine:flight_idle_thrust_fraction,0,unitless
aircraft:engine:fuel_flow_scaler_constant_term,0,unitless
aircraft:engine:fuel_flow_scaler_linear_term,1,unitless
aircraft:engine:fuel_flow_scaler_linear_term,0,unitless
aircraft:engine:generate_flight_idle,True,unitless
aircraft:engine:geopotential_alt,False,unitless
aircraft:engine:ignore_negative_thrust,False,unitless
Expand Down
45 changes: 24 additions & 21 deletions aviary/subsystems/propulsion/test/test_engine_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import openmdao.api as om
from openmdao.utils.assert_utils import assert_check_partials, assert_near_equal
from openmdao.utils.testing_utils import use_tempdirs

from aviary.subsystems.propulsion.engine_deck import EngineDeck
from aviary.subsystems.propulsion.engine_scaling import EngineScaling
Expand All @@ -16,14 +17,13 @@

class EngineScalingTest(unittest.TestCase):
def setUp(self):
self.prob = om.Problem(model=om.Group())
self.prob = om.Problem()

def test_case(self):
nn = 4
count = 1

filename = 'models/engines/turbofan_28k.csv'
filename = get_path(filename)
filename = get_path('models/engines/turbofan_28k.csv')

options = AviaryValues()
options.set_val(Settings.VERBOSITY, 0)
Expand All @@ -32,7 +32,7 @@ def test_case(self):
# make supersonic scaling factor extremely high so it is obvious if it gets used
options.set_val(Aircraft.Engine.SUPERSONIC_FUEL_FLOW_SCALER, 1000)
options.set_val(Aircraft.Engine.FUEL_FLOW_SCALER_CONSTANT_TERM, 1.15)
options.set_val(Aircraft.Engine.FUEL_FLOW_SCALER_LINEAR_TERM, 1.05)
options.set_val(Aircraft.Engine.FUEL_FLOW_SCALER_LINEAR_TERM, 0.05)
options.set_val(Aircraft.Engine.CONSTANT_FUEL_MASS_CONSUMPTION, 10.0, units='lbm/h')
options.set_val(Aircraft.Engine.SCALE_FACTOR, 0.9)
options.set_val(Aircraft.Engine.GENERATE_FLIGHT_IDLE, True)
Expand All @@ -43,10 +43,8 @@ def test_case(self):
options.set_val(Aircraft.Engine.GEOPOTENTIAL_ALT, False)
options.set_val(Aircraft.Engine.INTERPOLATION_METHOD, 'slinear')

# engine1 uses all scaling factors
engine1 = EngineDeck(options=options)

preprocess_propulsion(options, [engine1])
engine = EngineDeck(options=options)
preprocess_propulsion(options, [engine])

engine_variables = {
EngineModelVariables.THRUST: 'lbf',
Expand Down Expand Up @@ -74,20 +72,25 @@ def test_case(self):

self.prob.run_model()

thrust = self.prob.get_val(Dynamic.Vehicle.Propulsion.THRUST)
fuel_flow = self.prob.get_val(Dynamic.Vehicle.Propulsion.FUEL_MASS_FLOW_RATE_NEGATIVE)
nox_rate = self.prob.get_val(Dynamic.Vehicle.Propulsion.NOX_RATE)
# exit_area = self.prob.get_val(Dynamic.Mission.EXIT_AREA)

thrust_expected = np.array([900.0, 900.0, 900.0, 900])

fuel_flow_expected = np.array([-1836.55, -1836.55, -1836.55, -1836.55])

nox_rate_expected = np.array([9.0, 9.0, 9.0, 9])
expected_values = {
Dynamic.Vehicle.Propulsion.THRUST: (
np.array([900.0, 900.0, 900.0, 900.0]),
'lbf',
),
Dynamic.Vehicle.Propulsion.FUEL_MASS_FLOW_RATE_NEGATIVE: (
np.array([-1755.55, -1755.55, -1755.55, -1755.55]),
'lbm/h',
),
Dynamic.Vehicle.Propulsion.NOX_RATE: (
np.array([9.0, 9.0, 9.0, 9.0]),
'lbm/h',
),
}

assert_near_equal(thrust, thrust_expected, tolerance=1e-10)
assert_near_equal(fuel_flow, fuel_flow_expected, tolerance=1e-10)
assert_near_equal(nox_rate, nox_rate_expected, tolerance=1e-10)
for var_name, (expected, units) in expected_values.items():
with self.subTest(var=var_name):
actual = self.prob.get_val(var_name, units=units)
assert_near_equal(actual, expected, tolerance=1e-10)

partial_data = self.prob.check_partials(out_stream=None, method='cs')
assert_check_partials(partial_data, atol=1e-11, rtol=1e-10)
Expand Down
Loading
Loading