Skip to content

Commit

Permalink
Merge pull request OpenMDAO#507 from Kenneth-T-Moore/paramport_refactor2
Browse files Browse the repository at this point in the history
Paramport Part 2 - removal of most variables from 2DOF (gasp-based) paramport.
  • Loading branch information
ehariton authored Sep 9, 2024
2 parents e543c9d + e8cd8b3 commit 4134100
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 111 deletions.
16 changes: 11 additions & 5 deletions aviary/interface/methods_for_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,15 @@ def add_subsystem_timeseries_outputs(phase, phase_name):
phase_name, self._get_phase(phase_name, phase_idx))
add_subsystem_timeseries_outputs(phase, phase_name)

if phase_name == 'ascent' and self.mission_method is TWO_DEGREES_OF_FREEDOM:
self._add_groundroll_eq_constraint(phase)
if self.mission_method is TWO_DEGREES_OF_FREEDOM:

# In GASP, we still use the phase name to infer the phase type.
# We need this information to be available in the builders.
# TODO - Ultimately we should overhaul all of this.
self.phase_info[phase_name]['phase_type'] = phase_name

if phase_name == 'ascent':
self._add_groundroll_eq_constraint(phase)

# loop through phase_info and external subsystems
external_parameters = {}
Expand All @@ -1107,9 +1114,8 @@ def add_subsystem_timeseries_outputs(phase, phase_name):
for parameter in parameter_dict:
external_parameters[phase_name][parameter] = parameter_dict[parameter]

if self.mission_method in (HEIGHT_ENERGY, SOLVED_2DOF):
traj = setup_trajectory_params(
self.model, traj, self.aviary_inputs, phases, meta_data=self.meta_data, external_parameters=external_parameters)
traj = setup_trajectory_params(
self.model, traj, self.aviary_inputs, phases, meta_data=self.meta_data, external_parameters=external_parameters)

self.traj = traj

Expand Down
3 changes: 3 additions & 0 deletions aviary/mission/gasp_based/ode/climb_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,6 @@ def setup(self):
val=174000 * np.ones(nn), units='lbm')
self.set_input_defaults(Dynamic.Mission.MACH,
val=0 * np.ones(nn), units="unitless")

from aviary.variable_info.variables import Aircraft
self.set_input_defaults(Aircraft.Wing.AREA, val=1.0, units="ft**2")
4 changes: 3 additions & 1 deletion aviary/mission/gasp_based/ode/descent_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aviary.mission.gasp_based.ode.constraints.speed_constraints import SpeedConstraints

from aviary.variable_info.enums import AnalysisScheme, AlphaModes, SpeedType
from aviary.variable_info.variables import Mission, Dynamic
from aviary.variable_info.variables import Aircraft, Mission, Dynamic
from aviary.subsystems.aerodynamics.aerodynamics_builder import AerodynamicsBuilderBase
from aviary.subsystems.propulsion.propulsion_builder import PropulsionBuilderBase
from aviary.mission.gasp_based.ode.time_integration_base_classes import add_SGM_required_inputs
Expand Down Expand Up @@ -232,3 +232,5 @@ def setup(self):
val=0 * np.ones(nn), units="unitless")
self.set_input_defaults(Dynamic.Mission.THROTTLE,
val=0 * np.ones(nn), units="unitless")

self.set_input_defaults(Aircraft.Wing.AREA, val=1.0, units="ft**2")
2 changes: 2 additions & 0 deletions aviary/mission/gasp_based/ode/groundroll_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ def setup(self):
self.set_input_defaults(Dynamic.Mission.VELOCITY, val=np.zeros(nn), units="kn")
self.set_input_defaults(Dynamic.Mission.VELOCITY_RATE,
val=np.zeros(nn), units="kn/s")

self.set_input_defaults(Aircraft.Wing.INCIDENCE, val=1.0, units="deg")
161 changes: 95 additions & 66 deletions aviary/mission/gasp_based/ode/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,9 @@
class ParamPort(om.ExplicitComponent):

param_data = {
Aircraft.Wing.AREA: dict(units="ft**2", val=1370.3),
Aircraft.Wing.INCIDENCE: dict(units="deg", val=0),
Aircraft.Wing.HEIGHT: dict(units="ft", val=8),
Aircraft.Wing.SPAN: dict(units="ft", val=117.8),
Mission.Design.GROSS_MASS: dict(units="lbm", val=175400),
Mission.Summary.GROSS_MASS: dict(units="lbm", val=175400),
Mission.Summary.FUEL_FLOW_SCALER: dict(units="unitless", val=1.0),
Mission.Takeoff.AIRPORT_ALTITUDE: dict(units="ft", val=0),
Mission.Landing.AIRPORT_ALTITUDE: dict(units="ft", val=0),
Aircraft.Wing.FLAP_DEFLECTION_TAKEOFF: dict(units="deg", val=10),
Aircraft.Wing.FLAP_DEFLECTION_LANDING: dict(units="deg", val=40),
Aircraft.Wing.AVERAGE_CHORD: dict(units="ft", val=12.615),
Aircraft.Fuselage.AVG_DIAMETER: dict(units="inch", val=12 * 13.100),
Aircraft.HorizontalTail.AVERAGE_CHORD: dict(units="ft", val=9.577),
Aircraft.HorizontalTail.AREA: dict(units="ft**2", val=375.880),
Aircraft.HorizontalTail.SPAN: dict(units="ft", val=42.254),
Aircraft.VerticalTail.AVERAGE_CHORD: dict(units="ft", val=16.832),
Aircraft.VerticalTail.AREA: dict(units="ft**2", val=469.318),
Aircraft.VerticalTail.SPAN: dict(units="ft", val=27.996),
Aircraft.Fuselage.LENGTH: dict(units="ft", val=129.4),
Aircraft.Nacelle.AVG_LENGTH: dict(units="ft", val=14.5),
Aircraft.Fuselage.WETTED_AREA: dict(units="ft**2", val=4000),
Aircraft.Nacelle.SURFACE_AREA: dict(units="ft**2", val=659.23 / 2),
Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: dict(units="unitless", val=0.1397),
Aircraft.Strut.CHORD: dict(
units="ft", val=0
), # only available if Aviary_option Aircraft.Wing.HAS_STRUT
Aircraft.Wing.ASPECT_RATIO: dict(units="unitless", val=10.13),
Aircraft.Wing.TAPER_RATIO: dict(units="unitless", val=0.33),
Aircraft.Wing.THICKNESS_TO_CHORD_ROOT: dict(units="unitless", val=0.15),
Aircraft.Wing.THICKNESS_TO_CHORD_TIP: dict(units="unitless", val=0.12),
Aircraft.HorizontalTail.VERTICAL_TAIL_FRACTION: dict(units="unitless", val=0),
Aircraft.Wing.SWEEP: dict(units="deg", val=25),
Aircraft.HorizontalTail.SWEEP: dict(units="deg", val=25),
Aircraft.HorizontalTail.MOMENT_RATIO: dict(units="unitless", val=0.2307),
Aircraft.Wing.MOUNTING_TYPE: dict(units="unitless", val=0),
Aircraft.Design.STATIC_MARGIN: dict(units="unitless", val=0.03),
Aircraft.Design.CG_DELTA: dict(units="unitless", val=0.25),
Aircraft.Wing.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.Fuselage.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.Nacelle.FORM_FACTOR: dict(units="unitless", val=1.5),
Aircraft.VerticalTail.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.HorizontalTail.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.Wing.FUSELAGE_INTERFERENCE_FACTOR: dict(units="unitless", val=1.1),
Aircraft.Strut.FUSELAGE_INTERFERENCE_FACTOR: dict(units="unitless", val=0),
Aircraft.Design.DRAG_COEFFICIENT_INCREMENT: dict(units="unitless", val=0.00175),
Aircraft.Fuselage.FLAT_PLATE_AREA_INCREMENT: dict(units="ft**2", val=0.25),
Aircraft.Wing.CENTER_DISTANCE: dict(units="unitless", val=0.463),
Aircraft.Wing.MIN_PRESSURE_LOCATION: dict(units="unitless", val=0.3),
Aircraft.Wing.MAX_THICKNESS_LOCATION: dict(units="unitless", val=0.4),
Aircraft.Strut.AREA_RATIO: dict(units="unitless", val=0),
Aircraft.Wing.ZERO_LIFT_ANGLE: dict(units="deg", val=-1.2),
Aircraft.Design.SUPERCRITICAL_DIVERGENCE_SHIFT: dict(units="unitless", val=0.033),
Aircraft.Wing.FLAP_CHORD_RATIO: dict(units="unitless", val=0.3),
Mission.Design.LIFT_COEFFICIENT_MAX_FLAPS_UP: dict(units="unitless", val=1.2596),
Mission.Takeoff.LIFT_COEFFICIENT_MAX: dict(units="unitless", val=2.1886),
Mission.Landing.LIFT_COEFFICIENT_MAX: dict(units="unitless", val=2.8155),
Mission.Takeoff.LIFT_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=0.4182
),
Mission.Landing.LIFT_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=1.0293
),
Mission.Takeoff.DRAG_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=0.0085
),
Mission.Landing.DRAG_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=0.0406
),
}

def setup(self):
Expand Down Expand Up @@ -149,3 +83,98 @@ def promote_params(sys, trajs=None, phases=None):
static_target=True,
)
sys.promotes(phasename, inputs=proms)


params_for_unit_tests = {
Aircraft.Wing.AREA: dict(units="ft**2", val=1370.3),
Aircraft.Wing.HEIGHT: dict(units="ft", val=8),
Aircraft.Wing.SPAN: dict(units="ft", val=117.8),
Mission.Design.GROSS_MASS: dict(units="lbm", val=175400),
Mission.Summary.GROSS_MASS: dict(units="lbm", val=175400),
Mission.Summary.FUEL_FLOW_SCALER: dict(units="unitless", val=1.0),
Mission.Takeoff.AIRPORT_ALTITUDE: dict(units="ft", val=0),
Mission.Landing.AIRPORT_ALTITUDE: dict(units="ft", val=0),
Aircraft.Wing.AVERAGE_CHORD: dict(units="ft", val=12.615),
Aircraft.Fuselage.AVG_DIAMETER: dict(units="inch", val=12 * 13.100),
Aircraft.HorizontalTail.AVERAGE_CHORD: dict(units="ft", val=9.577),
Aircraft.HorizontalTail.AREA: dict(units="ft**2", val=375.880),
Aircraft.HorizontalTail.SPAN: dict(units="ft", val=42.254),
Aircraft.VerticalTail.AVERAGE_CHORD: dict(units="ft", val=16.832),
Aircraft.VerticalTail.AREA: dict(units="ft**2", val=469.318),
Aircraft.VerticalTail.SPAN: dict(units="ft", val=27.996),
Aircraft.Fuselage.LENGTH: dict(units="ft", val=129.4),
Aircraft.Nacelle.AVG_LENGTH: dict(units="ft", val=14.5),
Aircraft.Fuselage.WETTED_AREA: dict(units="ft**2", val=4000),
Aircraft.Nacelle.SURFACE_AREA: dict(units="ft**2", val=659.23 / 2),
Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: dict(units="unitless", val=0.1397),
Aircraft.Strut.CHORD: dict(
units="ft", val=0
), # only available if Aviary_option Aircraft.Wing.HAS_STRUT
Aircraft.Wing.ASPECT_RATIO: dict(units="unitless", val=10.13),
Aircraft.Wing.TAPER_RATIO: dict(units="unitless", val=0.33),
Aircraft.Wing.THICKNESS_TO_CHORD_ROOT: dict(units="unitless", val=0.15),
Aircraft.Wing.THICKNESS_TO_CHORD_TIP: dict(units="unitless", val=0.12),
Aircraft.HorizontalTail.VERTICAL_TAIL_FRACTION: dict(units="unitless", val=0),
Aircraft.Wing.SWEEP: dict(units="deg", val=25),
Aircraft.HorizontalTail.SWEEP: dict(units="deg", val=25),
Aircraft.HorizontalTail.MOMENT_RATIO: dict(units="unitless", val=0.2307),
Aircraft.Wing.MOUNTING_TYPE: dict(units="unitless", val=0),
Aircraft.Design.STATIC_MARGIN: dict(units="unitless", val=0.03),
Aircraft.Design.CG_DELTA: dict(units="unitless", val=0.25),
Aircraft.Wing.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.Fuselage.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.Nacelle.FORM_FACTOR: dict(units="unitless", val=1.5),
Aircraft.VerticalTail.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.HorizontalTail.FORM_FACTOR: dict(units="unitless", val=1.25),
Aircraft.Wing.FUSELAGE_INTERFERENCE_FACTOR: dict(units="unitless", val=1.1),
Aircraft.Strut.FUSELAGE_INTERFERENCE_FACTOR: dict(units="unitless", val=0),
Aircraft.Design.DRAG_COEFFICIENT_INCREMENT: dict(units="unitless", val=0.00175),
Aircraft.Fuselage.FLAT_PLATE_AREA_INCREMENT: dict(units="ft**2", val=0.25),
Aircraft.Wing.CENTER_DISTANCE: dict(units="unitless", val=0.463),
Aircraft.Wing.MIN_PRESSURE_LOCATION: dict(units="unitless", val=0.3),
Aircraft.Wing.MAX_THICKNESS_LOCATION: dict(units="unitless", val=0.4),
Aircraft.Strut.AREA_RATIO: dict(units="unitless", val=0),
Aircraft.Wing.ZERO_LIFT_ANGLE: dict(units="deg", val=-1.2),
Aircraft.Design.SUPERCRITICAL_DIVERGENCE_SHIFT: dict(units="unitless", val=0.033),
Aircraft.Wing.FLAP_CHORD_RATIO: dict(units="unitless", val=0.3),
Mission.Design.LIFT_COEFFICIENT_MAX_FLAPS_UP: dict(units="unitless", val=1.2596),
Mission.Takeoff.LIFT_COEFFICIENT_MAX: dict(units="unitless", val=2.1886),
Mission.Landing.LIFT_COEFFICIENT_MAX: dict(units="unitless", val=2.8155),
Mission.Takeoff.LIFT_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=0.4182
),
Mission.Landing.LIFT_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=1.0293
),
Mission.Takeoff.DRAG_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=0.0085
),
Mission.Landing.DRAG_COEFFICIENT_FLAP_INCREMENT: dict(
units="unitless", val=0.0406
),
}


def set_params_for_unit_tests(prob):
"""
Helper function to set parameters for several ode tests with the 2DOF method.
This is needed because the Paramport used to contain default values for some
variables.
Parameters
----------
prob : Problem
OpenMDAO problem that has been setup.
Returns
-------
Problem
"""
for key, val in params_for_unit_tests.items():
try:
prob.set_val(key, val['val'], units=val['units'])
except:
pass

return prob
9 changes: 6 additions & 3 deletions aviary/mission/gasp_based/ode/test/test_accel_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from openmdao.utils.assert_utils import assert_check_partials

from aviary.mission.gasp_based.ode.accel_ode import AccelODE
from aviary.variable_info.options import get_option_defaults
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
from aviary.variable_info.variables import Dynamic
from aviary.mission.gasp_based.ode.params import set_params_for_unit_tests
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
from aviary.variable_info.options import get_option_defaults
from aviary.variable_info.variables import Dynamic


class AccelerationODETestCase(unittest.TestCase):
Expand All @@ -35,6 +36,8 @@ def test_accel(self):
self.prob.set_val(Dynamic.Mission.VELOCITY, [185, 252], units="kn")
self.prob.set_val(Dynamic.Mission.MASS, [174974, 174878], units="lbm")

set_params_for_unit_tests(self.prob)

self.prob.run_model()
testvals = {
Dynamic.Mission.LIFT: [174974, 174878],
Expand Down
3 changes: 3 additions & 0 deletions aviary/mission/gasp_based/ode/test/test_ascent_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from openmdao.utils.assert_utils import assert_check_partials, assert_near_equal

from aviary.mission.gasp_based.ode.ascent_ode import AscentODE
from aviary.mission.gasp_based.ode.params import set_params_for_unit_tests
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
from aviary.variable_info.options import get_option_defaults
Expand All @@ -30,6 +31,8 @@ def test_ascent_partials(self):
self.prob.set_val(Dynamic.Mission.VELOCITY, [100, 100], units="kn")
self.prob.set_val("t_curr", [1, 2], units="s")

set_params_for_unit_tests(self.prob)

self.prob.run_model()

tol = tol = 1e-6
Expand Down
3 changes: 3 additions & 0 deletions aviary/mission/gasp_based/ode/test/test_breguet_cruise_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from openmdao.utils.assert_utils import assert_check_partials, assert_near_equal

from aviary.mission.gasp_based.ode.breguet_cruise_ode import BreguetCruiseODESolution
from aviary.mission.gasp_based.ode.params import set_params_for_unit_tests
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
from aviary.variable_info.options import get_option_defaults
Expand Down Expand Up @@ -34,6 +35,8 @@ def test_cruise(self):

self.prob.set_val(Dynamic.Mission.MACH, [0.7, 0.7], units="unitless")

set_params_for_unit_tests(self.prob)

self.prob.run_model()

tol = tol = 1e-6
Expand Down
9 changes: 7 additions & 2 deletions aviary/mission/gasp_based/ode/test/test_climb_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from openmdao.utils.assert_utils import assert_check_partials

from aviary.mission.gasp_based.ode.climb_ode import ClimbODE
from aviary.mission.gasp_based.ode.params import set_params_for_unit_tests
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
from aviary.variable_info.options import get_option_defaults
from aviary.variable_info.variables import Aircraft, Dynamic
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems


class ClimbODETestCase(unittest.TestCase):
Expand Down Expand Up @@ -43,6 +44,8 @@ def test_start_of_climb(self):
# slightly greater than zero to help check partials
self.prob.set_val(Aircraft.Wing.INCIDENCE, 0.0000001, units="deg")

set_params_for_unit_tests(self.prob)

self.prob.run_model()

testvals = {
Expand Down Expand Up @@ -79,6 +82,8 @@ def test_end_of_climb(self):
self.prob.set_val(Dynamic.Mission.MASS, np.array([174149, 171592]), units="lbm")
self.prob.set_val("EAS", np.array([270, 270]), units="kn")

set_params_for_unit_tests(self.prob)

self.prob.run_model()

testvals = {
Expand Down
11 changes: 8 additions & 3 deletions aviary/mission/gasp_based/ode/test/test_descent_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from packaging import version

from aviary.mission.gasp_based.ode.descent_ode import DescentODE
from aviary.variable_info.options import get_option_defaults
from aviary.mission.gasp_based.ode.params import set_params_for_unit_tests
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
from aviary.variable_info.enums import SpeedType
from aviary.variable_info.options import get_option_defaults
from aviary.variable_info.variables import Dynamic
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems


class DescentODETestCase(unittest.TestCase):
Expand Down Expand Up @@ -43,6 +44,8 @@ def test_high_alt(self):
self.prob.set_val(Dynamic.Mission.ALTITUDE, np.array([36500, 14500]), units="ft")
self.prob.set_val(Dynamic.Mission.MASS, np.array([147661, 147572]), units="lbm")

set_params_for_unit_tests(self.prob)

self.prob.run_model()

testvals = {
Expand Down Expand Up @@ -79,6 +82,8 @@ def test_low_alt(self):
self.prob.set_val(Dynamic.Mission.MASS, 147410, units="lbm")
self.prob.set_val("EAS", 250, units="kn")

set_params_for_unit_tests(self.prob)

self.prob.run_model()

testvals = {
Expand Down
5 changes: 5 additions & 0 deletions aviary/mission/gasp_based/ode/test/test_flight_path_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from openmdao.utils.assert_utils import assert_check_partials, assert_near_equal

from aviary.mission.gasp_based.ode.flight_path_ode import FlightPathODE
from aviary.mission.gasp_based.ode.params import set_params_for_unit_tests
from aviary.variable_info.options import get_option_defaults
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
Expand All @@ -30,6 +31,8 @@ def test_case1(self):
"""
self.prob.setup(check=False, force_alloc_complex=True)

set_params_for_unit_tests(self.prob)

self.prob.set_val(Dynamic.Mission.VELOCITY, [100, 100], units="kn")
self.prob.set_val(Dynamic.Mission.MASS, [100000, 100000], units="lbm")
self.prob.set_val(Dynamic.Mission.ALTITUDE, [500, 500], units="ft")
Expand Down Expand Up @@ -66,6 +69,8 @@ def test_case2(self):
self.fp.options["ground_roll"] = True
self.prob.setup(check=False, force_alloc_complex=True)

set_params_for_unit_tests(self.prob)

self.prob.set_val(Dynamic.Mission.VELOCITY, [100, 100], units="kn")
self.prob.set_val(Dynamic.Mission.MASS, [100000, 100000], units="lbm")
self.prob.set_val(Dynamic.Mission.ALTITUDE, [500, 500], units="ft")
Expand Down
Loading

0 comments on commit 4134100

Please sign in to comment.