-
Notifications
You must be signed in to change notification settings - Fork 68
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
Test FLOPS Aero Builder #619
base: main
Are you sure you want to change the base?
Changes from 16 commits
4c62481
14ef4df
499dca3
0de5a9d
e15ee37
233c1d0
dd58f50
15ca235
8457556
0a2d82c
f68bc73
d6fa153
6033e46
5c9b82d
791d910
28a9b4a
8f743d7
6f880ef
f8e83b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,10 @@ | |
|
||
CoreAerodynamicsBuilder : the interface for Aviary's core aerodynamics subsystem builder | ||
""" | ||
from itertools import chain | ||
|
||
import numpy as np | ||
from itertools import chain | ||
|
||
import openmdao.api as om | ||
from dymos.utils.misc import _unspecified | ||
# from dymos.utils.misc import _unspecified | ||
|
||
from aviary.subsystems.aerodynamics.flops_based.computed_aero_group import \ | ||
ComputedAeroGroup | ||
|
@@ -39,7 +37,7 @@ | |
GASP = LegacyCode.GASP | ||
FLOPS = LegacyCode.FLOPS | ||
|
||
_default_name = 'aerodynamics' | ||
default_name = 'aerodynamics' | ||
|
||
|
||
class AerodynamicsBuilderBase(SubsystemBuilderBase): | ||
|
@@ -58,7 +56,7 @@ class AerodynamicsBuilderBase(SubsystemBuilderBase): | |
|
||
def __init__(self, name=None, meta_data=None): | ||
if name is None: | ||
name = _default_name | ||
name = default_name | ||
|
||
super().__init__(name=name, meta_data=meta_data) | ||
|
||
|
@@ -337,7 +335,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
aero_opt = phase_info['subsystem_options'][self.name] | ||
method = aero_opt['method'] | ||
except KeyError: | ||
method = 'computed' | ||
method = None | ||
|
||
if phase_info is not None: | ||
# Only solved_alpha has connectable inputs. | ||
|
@@ -387,7 +385,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
|
||
val = meta['default_value'] | ||
if val is None: | ||
val = _unspecified | ||
val = 0.0 # _unspecified | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The unittest does not like it. |
||
units = meta['units'] | ||
|
||
if var in aviary_inputs: | ||
|
@@ -397,6 +395,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
val = aviary_inputs.get_val(var) | ||
|
||
params[var] = {'val': val, | ||
'units': units, | ||
'static_target': True} | ||
|
||
for var in ENGINE_SIZED_INPUTS: | ||
|
@@ -410,7 +409,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
|
||
val = meta['default_value'] | ||
if val is None: | ||
val = _unspecified | ||
val = 0.0 # _unspecified | ||
units = meta['units'] | ||
|
||
if var in aviary_inputs: | ||
|
@@ -420,6 +419,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
val = aviary_inputs.get_val(var) | ||
|
||
params[var] = {'val': val, | ||
'units': units, | ||
'static_target': True} | ||
|
||
elif method == "low_speed": | ||
|
@@ -430,7 +430,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
|
||
val = meta['default_value'] | ||
if val is None: | ||
val = _unspecified | ||
val = 0.0 # _unspecified | ||
units = meta['units'] | ||
|
||
if var in aviary_inputs: | ||
|
@@ -440,14 +440,15 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
val = aviary_inputs.get_val(var) | ||
|
||
params[var] = {'val': val, | ||
'units': units, | ||
'static_target': True} | ||
|
||
else: | ||
|
||
# TODO: 2DOF/Gasp decided on phases based on phase names. We used | ||
# a saved phase_name to determine the correct aero variables to | ||
# promote. Ideally, this should all be refactored. | ||
if phase_info['phase_type'] in ['ascent', 'groundroll', 'rotation']: | ||
if bool(phase_info) and phase_info['phase_type'] in ['ascent', 'groundroll', 'rotation']: | ||
all_vars = (AERO_2DOF_INPUTS, AERO_LS_2DOF_INPUTS) | ||
else: | ||
all_vars = (AERO_2DOF_INPUTS, AERO_CLEAN_2DOF_INPUTS) | ||
|
@@ -458,7 +459,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
|
||
val = meta['default_value'] | ||
if val is None: | ||
val = _unspecified | ||
val = 0.0 # _unspecified | ||
units = meta['units'] | ||
|
||
if var in aviary_inputs: | ||
|
@@ -468,6 +469,7 @@ def get_parameters(self, aviary_inputs=None, phase_info=None): | |
val = aviary_inputs.get_val(var) | ||
|
||
params[var] = {'val': val, | ||
'units': units, | ||
'static_target': True} | ||
|
||
return params | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import unittest | ||
|
||
from aviary.subsystems.aerodynamics.aerodynamics_builder import CoreAerodynamicsBuilder | ||
from aviary.variable_info.enums import LegacyCode | ||
from aviary.variable_info.variables import Aircraft | ||
from aviary.variable_info.variable_meta_data import _MetaData as BaseMetaData | ||
import aviary.api as av | ||
|
||
FLOPS = LegacyCode.FLOPS | ||
|
||
|
||
class TestAeroBuilder(av.TestSubsystemBuilderBase): | ||
""" | ||
That class inherits from TestSubsystemBuilder. So all the test functions are | ||
within that inherited class. The setUp() method prepares the class and is run | ||
before the test methods; then the test methods are run. | ||
""" | ||
|
||
def setUp(self): | ||
self.subsystem_builder = CoreAerodynamicsBuilder( | ||
'core_aerodynamics', BaseMetaData, FLOPS) | ||
self.aviary_values = av.AviaryValues() | ||
self.aviary_values.set_val(Aircraft.Engine.NUM_ENGINES, [1], units='unitless') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,11 +164,11 @@ def test_get_parameters(self): | |
val, dict, "The values in the dictionary returned by get_parameters() should be dictionaries") | ||
|
||
# Verify that the dictionaries have the correct keys | ||
for val in parameters.values(): | ||
for key, val in parameters.items(): | ||
self.assertIn( | ||
'val', val, "The dictionaries returned by get_parameters() should have a 'val' key") | ||
'val', val, f"The dictionaries returned by get_parameters() should have a 'val' key for {key}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wording |
||
self.assertIn( | ||
'units', val, "The dictionaries returned by get_parameters() should have a 'units' key") | ||
'units', val, f"The dictionaries returned by get_parameters() should have a 'units' key for {key}") | ||
|
||
def test_get_initial_guesses(self): | ||
initial_guesses = self.subsystem_builder.get_initial_guesses() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep the old name - it marks default_name as a variable intended as private to this file, so other devs know they shouldn't try
from aerodynamics_builder import default_name
It's unlikely anyone would ever even want that, but it's good practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required by unittest because
TestSubsystemBuilderBase
has an attributedefault_name
.