OpenMDAO / dymos

Open Source Optimization of Dynamic Multidisciplinary Systems
Apache License 2.0
201 stars 65 forks source link

Parameter arrays and grid refinement #575

Closed akrdunn closed 3 years ago

akrdunn commented 3 years ago

Summary of Issue

When attempting to use grid refinement with a parameter with size > 1, on the second iteration an error is produced related to resizing the parameter.

Issue Type

Description

If a parameter is added to a phase with a size > 1 (dynamic or not), and grid refinement is attempted, during the first refinement attempt an error will occur such as:

~\Anaconda3\envs\mdao\lib\site-packages\openmdao\core\group.py in _get_auto_ivc_out_val(self, tgts, vars_to_gather, all_abs2meta_in, abs2meta_in)
   3296                     val = value
   3297                 else:
-> 3298                     val[:] = value
   3299 
   3300                 if tgt not in vars_to_gather:

ValueError: could not broadcast input array from shape (40) into shape (75)

In this example the parameter was of length 40, and I believe the code is attempting to resize to the new number of nodes (75).

Example

The min_time_climb notebook here simply adds a dummy parameter to the "supersonic interceptor minimum time climb" example: https://github.com/akrdunn/dymos_bug

Environment

Operating System: Windows 10 Python environment: Anaconda Python 3.8.3 Packages: OpenMDAO 3.7.0, Dymos 1.0.0

akrdunn commented 3 years ago

This also seems to be happening for a single valued parameter with dynamic=False. So it seems like any parameter with shape != num_nodes

robfalck commented 3 years ago

@akrdunn When you have a chance please pull the latest commit from master and see if this works for you all.