Skip to content

Commit

Permalink
fixing out-of-order systems in some tests (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
naylor-b authored Jun 23, 2023
1 parent 362737e commit 90e95d3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def test_aero_coefs(self):

prob = om.Problem(model=om.Group())

prob.model.add_subsystem(name='aero', subsys=AeroCoefComp(vec_size=nn, method='lagrange3'))

ivc = prob.model.add_subsystem(name='ivc', subsys=om.IndepVarComp(), promotes_outputs=['*'])

ivc.add_output('mach', val=np.zeros(nn), units=None)
ivc.add_output('alpha', val=np.zeros(nn), units='rad')
ivc.add_output('alt', val=np.zeros(nn), units='km')
ivc.add_output('eta', val=np.zeros(nn), units='rad')

prob.model.add_subsystem(name='aero', subsys=AeroCoefComp(vec_size=nn, method='lagrange3'))

prob.model.connect('mach', 'aero.mach')
prob.model.connect('alt', 'aero.alt')
prob.model.connect('alpha', 'aero.alpha')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ def test_aero_coefs(self):

interpND_CL, interpND_CD, interpND_CM, interp_num = setup_surrogates_all(MODEL)

prob.model.add_subsystem(name='aero',
subsys=InterpNDAeroCoeffComp(vec_size=NUM_NODES,
interpND_CL=interpND_CL,
interpND_CD=interpND_CD,
interpND_CM=interpND_CM,
interp_num=interp_num))
prob.model.add_subsystem(name='h_ivc',
subsys=om.IndepVarComp('h', val=np.zeros(NUM_NODES),
units='km'),
promotes=['h'])

prob.model.add_subsystem(name='M_ivc',
subsys=om.IndepVarComp('M', val=np.zeros(NUM_NODES), units=None),
Expand All @@ -40,10 +38,13 @@ def test_aero_coefs(self):
subsys=om.IndepVarComp('eta', val=np.zeros(NUM_NODES),
units='rad'),
promotes=['eta'])
prob.model.add_subsystem(name='h_ivc',
subsys=om.IndepVarComp('h', val=np.zeros(NUM_NODES),
units='km'),
promotes=['h'])

prob.model.add_subsystem(name='aero',
subsys=InterpNDAeroCoeffComp(vec_size=NUM_NODES,
interpND_CL=interpND_CL,
interpND_CD=interpND_CD,
interpND_CM=interpND_CM,
interp_num=interp_num))

prob.model.connect('M', 'aero.M')
prob.model.connect('h', 'aero.h')
Expand Down
9 changes: 5 additions & 4 deletions dymos/test/test_run_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,10 @@ def test_simulate_array_param(self):
p.driver = om.ScipyOptimizeDriver()
p.driver.declare_coloring()

# dummy array of data
indeps = p.model.add_subsystem('indeps', om.IndepVarComp(), promotes=['*'])
indeps.add_output('array', np.linspace(1, 10, 10), units=None)

#
# Create a trajectory and add a phase to it
#
Expand All @@ -793,12 +797,9 @@ def test_simulate_array_param(self):
units='deg', lower=0.01, upper=179.9)

phase.add_parameter('g', units='m/s**2', val=9.80665)
phase.add_parameter('array', units=None, shape=(10,), static_target=True)

# dummy array of data
indeps = p.model.add_subsystem('indeps', om.IndepVarComp(), promotes=['*'])
indeps.add_output('array', np.linspace(1, 10, 10), units=None)
# add dummy array as a parameter and connect it
phase.add_parameter('array', units=None, shape=(10,), static_target=True)
p.model.connect('array', 'traj.phase0.parameters:array')

#
Expand Down
12 changes: 6 additions & 6 deletions dymos/test/test_upgrade_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ def test_simplified_ode_timeseries_output(self):
p.driver = om.ScipyOptimizeDriver()
p.driver.declare_coloring()

transcription = dm.GaussLobatto(num_segments=1,
order=13,
compressed=False)
phase = dm.Phase(ode_class=AircraftODE, transcription=transcription)
p.model.add_subsystem('phase0', phase)

# Pass Reference Area from an external source
assumptions = p.model.add_subsystem('assumptions', om.IndepVarComp())
assumptions.add_output('S', val=427.8, units='m**2')
assumptions.add_output('mass_empty', val=1.0, units='kg')
assumptions.add_output('mass_payload', val=1.0, units='kg')

transcription = dm.GaussLobatto(num_segments=1,
order=13,
compressed=False)
phase = dm.Phase(ode_class=AircraftODE, transcription=transcription)
p.model.add_subsystem('phase0', phase)

phase.set_time_options(fix_initial=True,
duration_bounds=(3600, 3600),
duration_ref=3600)
Expand Down

0 comments on commit 90e95d3

Please sign in to comment.