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 scenario dir unit test #155

Merged
merged 10 commits into from
Jul 5, 2023
2 changes: 0 additions & 2 deletions mphys/mphys_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ def configure(self):
def _mphys_promote_by_tag(self, iotype, tag):
for subsystem in self.mphys_subsystems:
promoted = []
print(f'promoting from {subsystem.name}')
tagged_variables = subsystem.get_io_metadata(iotypes=iotype,
metadata_keys=['tags'],
tags=tag)
for val in tagged_variables.values():
variable = val['prom_name']
if variable not in promoted:
print('promoting var:', variable)
self.promotes(subsystem.name, any=[variable])
promoted.append(variable)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
packages = find_packages(),
install_requires=[
'numpy',
'openmdao>=3.25'
'openmdao >= 3.25, != 3.27.0'
],
)
2 changes: 1 addition & 1 deletion tests/unit_tests/fake_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def setup(self):
self.add_output('x_aero0', val=np.ones(aero_num_nodes*3), tags=['mphys_coordinates'])


class AeroPreCouplingComp(om.IndepVarComp):
class AeroPreCouplingComp(om.ExplicitComponent):
def setup(self):
self.add_input('x_aero', shape_by_conn=True, tags=['mphys_coordinates'])
self.add_output('prestate_aero', tags=['mphys_coupling'])
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/fake_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setup(self):
self.add_output('x_struct0', val=np.ones(struct_num_nodes*3), tags=['mphys_coordinates'])


class StructPreCouplingComp(om.IndepVarComp):
class StructPreCouplingComp(om.ExplicitComponent):
def setup(self):
self.add_input('x_struct0', shape_by_conn=True, tags=['mphys_coordinates'])
self.add_output('prestate_struct', tags=['mphys_coupling'])
Expand All @@ -30,7 +30,7 @@ def compute(self, inputs, outputs):
outputs['u_struct'] = inputs['x_struct0'] + inputs['prestate_struct']


class StructPostCouplingComp(om.IndepVarComp):
class StructPostCouplingComp(om.ExplicitComponent):
def setup(self):
self.add_input('prestate_struct', tags=['mphys_coupling'])
self.add_input('x_struct0', shape_by_conn=True, tags=['mphys_coordinates'])
Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/test_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class PreComp(om.IndepVarComp):
def setup(self):
self.add_output('out_pre', val=1.0, tags=['mphys_coupling'])

class PostComp(om.IndepVarComp):
class PostComp(om.ExplicitComponent):
def setup(self):
self.add_input('out_pre', tags=['mphys_coupling'])
self.add_output('out_post', val=1.0, tags=['mphys_coupling'])

class UserPostCompPromoteInputsAndOutputs(om.IndepVarComp):
class UserPostCompPromoteInputsAndOutputs(om.ExplicitComponent):
def setup(self):
self.add_input('out_post')
self.add_output('out_user', val=1.0)

class UserPostCompMphysPromote(om.IndepVarComp):
class UserPostCompMphysPromote(om.ExplicitComponent):
def setup(self):
self.add_input('out_post', tags=['mphys_coupling'])
self.add_output('out_user2', val=2.0, tags=['mphys_result'])

class UserPostCompUseGeneralPromotes(om.IndepVarComp):
class UserPostCompUseGeneralPromotes(om.ExplicitComponent):
def setup(self):
self.add_input('out_post')
self.add_output('out_user3', val=3.0)
Expand Down
10 changes: 7 additions & 3 deletions tests/unit_tests/test_scenario_directory_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup(self):
self.add_output('x_aero0', val=np.ones(num_nodes*3), tags=['mphys_coordinates'])


class PreCouplingComp(om.IndepVarComp):
class PreCouplingComp(om.ExplicitComponent):
def setup(self):
self.add_input('x_aero', shape_by_conn=True, tags=['mphys_coordinates'])
self.add_output('prestate_aero', tags=['mphys_coupling'])
Expand All @@ -39,7 +39,7 @@ def compute(self, inputs, outputs):
outputs['f_aero'] = inputs['x_aero'] + inputs['prestate_aero']


class PostCouplingComp(om.IndepVarComp):
class PostCouplingComp(om.ExplicitComponent):
def setup(self):
self.add_input('prestate_aero', tags=['mphys_coupling'])
self.add_input('x_aero', shape_by_conn=True, tags=['mphys_coordinates'])
Expand Down Expand Up @@ -92,6 +92,9 @@ def make_dir(dir_name):


class TestScenarioAerodynamic(unittest.TestCase):
# don't want multiple procs to get out of sync since using file creation/removal
N_PROCS = 1

def setUp(self):
self.scenarios = ['cruise', 'maneuver']
for scenario in self.scenarios:
Expand All @@ -109,9 +112,10 @@ def setUp(self):
def tearDown(self):
for scenario in self.scenarios:
remove_dir(scenario)

def test_run_model(self):
self.common.test_run_model(self)
for scenario in ['cruise', 'maneuver']:
for scenario in self.scenarios:
for expected_file in ['precoupling_compute', 'coupling_compute', 'postcoupling_compute']:
self.assertTrue(Path(f'{scenario}/{expected_file}').exists())

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_scenario_structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fake_geometry import Geometry, GeometryBuilder


class PreCouplingComp(om.IndepVarComp):
class PreCouplingComp(om.ExplicitComponent):
def setup(self):
self.add_input('x_struct0', shape_by_conn=True, tags=['mphys_coordinates'])
self.add_output('f_struct', val=np.ones(struct_num_nodes*3), tags=['mphys_coupling'])
Expand Down