Skip to content

Commit

Permalink
cleaned up some tests for CI failures and a couple minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
crecine committed Jun 10, 2024
1 parent dfa5ac3 commit f3918c4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions aviary/examples/level2_shooting_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def custom_run_aviary(aircraft_filename, optimizer=None,
"""
This function runs the aviary optimization problem for the specified aircraft configuration and mission.
It first creates an instance of the AviaryProblem class using the given phase_info, mission_method, and mass_method.
It first creates an instance of the AviaryProblem class using the given mission_method and mass_method.
It then loads aircraft and options data from the user-provided aircraft_filename and checks for any clashing inputs.
Pre-mission systems are added, phases are added and linked, then post-mission systems are added.
A driver is added using the specified optimizer (The default optimizer depends on the analysis scheme).
Expand Down Expand Up @@ -48,7 +48,7 @@ def custom_run_aviary(aircraft_filename, optimizer=None,
'builder': SGMCruise,
'user_options': {
'mach': (0, 'unitless'),
'distance_trigger': (300, 'NM'),
'attr:distance_trigger': (500, 'NM'),
},
},
'desc1': {
Expand Down
18 changes: 10 additions & 8 deletions aviary/examples/test/test_level2_shooting_traj.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import unittest

from openmdao.utils.testing_utils import require_pyoptsparse, use_tempdirs

from aviary.api import AnalysisScheme
from aviary.examples.level2_shooting_traj import custom_run_aviary
from aviary.interface.default_phase_info.two_dof import phase_info
from openmdao.utils.testing_utils import require_pyoptsparse, use_tempdirs
import unittest


@use_tempdirs
@require_pyoptsparse(optimizer='IPOPT')
def test_run_aviary():
input_deck = 'models/large_single_aisle_1/large_single_aisle_1_GwGm.csv'
custom_run_aviary(input_deck, phase_info,
analysis_scheme=AnalysisScheme.SHOOTING, run_driver=False)
class CustomTrajTestCase(unittest.TestCase):
@require_pyoptsparse(optimizer='IPOPT')
def test_run_aviary(self):
input_deck = 'models/large_single_aisle_1/large_single_aisle_1_GwGm.csv'
custom_run_aviary(
input_deck, analysis_scheme=AnalysisScheme.SHOOTING, run_driver=False)


if __name__ == "__main__":
Expand Down
11 changes: 7 additions & 4 deletions aviary/mission/gasp_based/phases/time_integration_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ def compute(self, inputs, outputs):
for name, data in vals_to_set.items():
var, units = data
if name.startswith('attr:'):
new_val = (
np.squeeze(self.convert2units(var, inputs[var], units)),
units
)
if isinstance(var, str):
new_val = (
np.squeeze(self.convert2units(var, inputs[var], units)),
units
)
else:
new_val = data
setattr(phase, name.replace('attr:', ''), new_val)
elif name.startswith('rotation.'):
phase.rotation.set_val(name.replace(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import warnings
import importlib

import openmdao.api as om
from aviary.interface.default_phase_info.two_dof_fiti_deprecated import create_2dof_based_descent_phases
Expand All @@ -14,7 +15,6 @@
from aviary.variable_info.enums import Verbosity
from aviary.utils.process_input_decks import create_vehicle
from aviary.utils.preprocessors import preprocess_propulsion
import importlib


@unittest.skipUnless(importlib.util.find_spec("pyoptsparse") is not None, "pyoptsparse is not installed")
Expand Down

0 comments on commit f3918c4

Please sign in to comment.