Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for trajectory parameters that had no valid target but raised no meaningful error. #744

Merged
merged 5 commits into from
May 4, 2022

Conversation

robfalck
Copy link
Contributor

Summary

If a user tried to create a trajectory parameter that was intended to be connected to phase parameters, but someone made an erroneous target specification, Dymos would not raise an error and run without the user's intended behavior.

Related Issues

Backwards incompatibilities

This may find issues with trajectory parameters that were previously missed.

New Dependencies

None

…ctory parameters are not properly defined. Even found a few existing issues in tests.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coveralls
Copy link

coveralls commented Apr 29, 2022

Coverage Status

Coverage decreased (-0.08%) to 95.477% when pulling a76c7f7 on robfalck:i739_2 into 8d5a9ff on OpenMDAO:master.

@@ -379,7 +379,8 @@
"# In this case, we connect 'm' to pre-existing input parameters\n",
"# named 'mass' in each phase.\n",
"traj.add_parameter('m', units='kg', val=1.0,\n",
" targets={'ascent': 'mass', 'descent': 'mass'}, static_target=True)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did these tests pass before? Is the default value of mass the same as the value set in the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly not sure, that must be the case.

p.driver.options['optimizer'] = OPTIMIZER
p.driver.declare_coloring()

if transcription == 'gauss-lobatto':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were you going to parameterize this test for both transcriptions?

phase.add_parameter('S', val=49.2386)

# Unit introspection for traj params. This doesn't work.
traj.add_parameter('Isp', val=1600.0, targets={'phase0': 'Isp'})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused that this one raises an error message. Isp is a variable in the phase (though not a parameter.) BTW, I ran my LEAPS stuff with your branch, and it works. This is my add_parameter:

for name in aero_inputs:
    traj.add_parameter(name, units=MetaData[name]['units'],
                       targets={'climb': [name]}, shape=1, static_target=True)

I guess it only works for me because static_target is True, but I am not sure why that makes a difference here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's a very subtle difference, which is why I've come to prefer forcing users to explicitly add parameters to phases and then let them be targed by trajectory parameters.

In targets={'phase0': 'Isp'}, 'Isp' is a string so it's assumed to be a parameter. If 'Isp' was provided in a sequence (['Isp']), then it would assume its to find it in the ODE. Some of this implementation dates back to the time before we could do introspection.

I think things are a lot simpler with being explicit here: Parameters provide an input to get external values into the phase, and we can use trajectory parameters to connect an external output to a single target (the trajectory parameter) and have connect to all relevant parameters in the phase.

I'd be in favor of ONLY documenting that way, and deprecating the use of a sequence for targets.

@robfalck robfalck merged commit 6e7ad66 into OpenMDAO:master May 4, 2022
@robfalck robfalck deleted the i739_2 branch August 25, 2022 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit instrospection is broken when adding parameters on a trajectory.
4 participants