diff --git a/dymos/grid_refinement/refinement.py b/dymos/grid_refinement/refinement.py index 518843c1f..83c408048 100644 --- a/dymos/grid_refinement/refinement.py +++ b/dymos/grid_refinement/refinement.py @@ -5,6 +5,7 @@ from .hp_adaptive.hp_adaptive import HPAdaptive from .write_iteration import write_error, write_refine_iter +import openmdao.api as om from dymos.grid_refinement.error_estimation import check_error from dymos.load_case import load_case, find_phases @@ -35,9 +36,10 @@ def _refine_iter(problem, refine_iteration_limit=0, refine_method='hp', case_pre refinement_methods = {'hp': HPAdaptive, 'ph': PHAdaptive} _case_prefix = '' if case_prefix is None else f'{case_prefix}_' - failed = problem.run_driver(case_prefix=f'{_case_prefix}{refine_method}_0_' - if refine_iteration_limit > 0 else _case_prefix, + case_prefix = f'{_case_prefix}{refine_method}_0_' + failed = problem.run_driver(case_prefix=case_prefix if refine_iteration_limit > 0 else _case_prefix, reset_iter_counts=reset_iter_counts) + problem.cleanup() if refine_iteration_limit > 0: out_file = 'grid_refinement.out' @@ -68,7 +70,6 @@ def _refine_iter(problem, refine_iteration_limit=0, refine_method='hp', case_pre 'outputs': problem.model.list_outputs(out_stream=None, units=True, prom_name=True)} problem.setup() - load_case(problem, prev_soln, deprecation_warning=False) else: prev_soln = { @@ -79,8 +80,9 @@ def _refine_iter(problem, refine_iteration_limit=0, refine_method='hp', case_pre } problem.setup() - - problem.load_case(prev_soln) + for phase_path in refined_phases: + phs = problem.model._get_subsystem(phase_path) + phs.load_case(prev_soln) failed = problem.run_driver(case_prefix=f'{_case_prefix}{refine_method}_{i}_') diff --git a/dymos/grid_refinement/test/test_grid_refinement.py b/dymos/grid_refinement/test/test_grid_refinement.py index 0a07981eb..ffc0b135b 100644 --- a/dymos/grid_refinement/test/test_grid_refinement.py +++ b/dymos/grid_refinement/test/test_grid_refinement.py @@ -45,7 +45,7 @@ def test_refine_hp_non_ode_rate_sources(self): p.driver.declare_coloring() traj = p.model.add_subsystem('traj', dm.Trajectory()) - tx = transcription = dm.Radau(num_segments=5) + tx = dm.Radau(num_segments=5) phase = traj.add_phase('phase0', dm.Phase(ode_class=_BrysonDenhamODE, transcription=tx)) # diff --git a/dymos/phase/phase.py b/dymos/phase/phase.py index b1b8ab9e6..bb32cb829 100644 --- a/dymos/phase/phase.py +++ b/dymos/phase/phase.py @@ -2709,8 +2709,6 @@ def load_case(self, case): prev_time_val, unique_idxs = np.unique(prev_time_val, return_index=True) prev_time_units = prev_vars[prev_time_path]['units'] - print("\n".join(prev_vars.keys())) - t_initial = prev_time_val[0] t_duration = prev_time_val[-1] - prev_time_val[0] diff --git a/dymos/test/test_load_case.py b/dymos/test/test_load_case.py index 1ffc27afc..458cc3138 100644 --- a/dymos/test/test_load_case.py +++ b/dymos/test/test_load_case.py @@ -148,7 +148,6 @@ def test_load_case_lgl_to_radau(self): outputs = dict([(o[0], o[1]) for o in case.list_outputs(units=True, shape=True, out_stream=None)]) - print(outputs) time_val = outputs['phase0.timeseries.timeseries_comp.time']['val'] theta_val = outputs['phase0.timeseries.timeseries_comp.theta']['val']