Skip to content

Commit

Permalink
Fix bug that caused aviary CI failure. (#1083)
Browse files Browse the repository at this point in the history
* Fix bug that caused aviary CI failure.

* PEP

* PEP
  • Loading branch information
Kenneth-T-Moore authored Jul 11, 2024
1 parent b82fd83 commit d61cd97
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dymos/transcriptions/common/control_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ def configure_io(self):
"""
control_options = self.options['control_options']
gd = self.options['grid_data']
num_input_nodes = gd.subset_num_nodes['control_input']

self.control_interp_comp.configure_io()

Expand Down Expand Up @@ -514,6 +513,8 @@ def configure_io(self):

self.set_input_defaults(name=f'controls:{name}', val=default_val, units=options['units'])
else:
num_input_nodes = gd.subset_num_nodes['control_input']

dvname = f'controls:{name}'
shape = options['shape']
size = np.prod(shape)
Expand Down
51 changes: 51 additions & 0 deletions dymos/transcriptions/common/test/test_control_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

import unittest

import openmdao.api as om

import dymos as dm


class MyODE(om.ExplicitComponent):

def initialize(self):
self.options.declare('num_nodes', types=int)

def setup(self):
nn = self.options['num_nodes']

self.add_input('polycon', shape=(nn,))
self.add_input('con', shape=(nn,))
self.add_input('state', shape=(nn,))
self.add_output('out', shape=(nn,))
self.add_output('state_deriv', shape=(nn,))

def compute(self, inputs, outputs, discrete_inputs=None, discrete_outputs=None):
pass


class TestControlGroup(unittest.TestCase):

def test_poly_con_bug(self):
prob = om.Problem()

phase = dm.Phase(ode_class=MyODE,
transcription=dm.GaussLobatto(num_segments=3))

phase.add_state('state', rate_source='state_deriv')

phase.add_control('polycon', order=1, val=0.0, opt=True, control_type='polynomial')
phase.add_control('con', val=0.0, opt=True)

phase.add_objective('out', loc='final', ref=1000.0)

traj = dm.Trajectory()
prob.model.add_subsystem('traj', traj)
traj.add_phase('phase', phase)

# Make sure we raise no exceptions.
prob.setup()


if __name__ == '__main__': # pragma: no cover
unittest.main()

0 comments on commit d61cd97

Please sign in to comment.