-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug that caused aviary CI failure. (#1083)
* Fix bug that caused aviary CI failure. * PEP * PEP
- Loading branch information
1 parent
b82fd83
commit d61cd97
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |