Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for failing multi-engine tests. #618

Closed
wants to merge 6 commits into from
Closed
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
15 changes: 15 additions & 0 deletions aviary/utils/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,21 @@ def preprocess_propulsion(aviary_options: AviaryValues, engine_models: list = No
aviary_options.set_val(Aircraft.Engine.NUM_WING_ENGINES, num_wing_engines_all)
aviary_options.set_val(Aircraft.Engine.NUM_FUSELAGE_ENGINES, num_fuse_engines_all)

# Update nacelle-related variables in aero to be sized to the number of
# engine types.
if num_engine_type > 1:

keys = [
Aircraft.Nacelle.LAMINAR_FLOW_LOWER,
Aircraft.Nacelle.LAMINAR_FLOW_UPPER
]

for var in keys:
try:
aviary_options.get_val(var)
except KeyError:
aviary_options.set_val(var, np.zeros(num_engine_type))
Comment on lines +410 to +413
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be more clear?

Suggested change
try:
aviary_options.get_val(var)
except KeyError:
aviary_options.set_val(var, np.zeros(num_engine_type))
if key not in aviary_options:
aviary_options.set_val(var, np.zeros(num_engine_type))


if Mission.Summary.FUEL_FLOW_SCALER not in aviary_options:
aviary_options.set_val(Mission.Summary.FUEL_FLOW_SCALER, 1.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def test_multiengine_static(self):
alloc_cruise = prob.get_val('traj.cruise.parameter_vals:throttle_allocations')
alloc_descent = prob.get_val('traj.descent.parameter_vals:throttle_allocations')

assert_near_equal(alloc_climb[0], 0.5, tolerance=1e-2)
assert_near_equal(alloc_cruise[0], 0.64, tolerance=1e-2)
assert_near_equal(alloc_climb[0], 0.51, tolerance=1e-2)
assert_near_equal(alloc_cruise[0], 0.747, tolerance=1e-2)
assert_near_equal(alloc_descent[0], 0.999, tolerance=1e-2)

@require_pyoptsparse(optimizer="SNOPT")
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_multiengine_dynamic(self):
alloc_descent = prob.get_val('traj.descent.controls:throttle_allocations')

# Cruise is pretty constant, check exact value.
assert_near_equal(alloc_cruise[0], 0.646, tolerance=1e-2)
assert_near_equal(alloc_cruise[0], 0.75, tolerance=1e-2)

# Check general trend: favors engine 1.
self.assertGreater(alloc_climb[2], 0.55)
Expand Down
Loading