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

Refactored the timeseries handling to be more general and less transcription-specific. #816

Merged
merged 38 commits into from
Aug 31, 2022

Conversation

robfalck
Copy link
Contributor

@robfalck robfalck commented Aug 30, 2022

Summary

Timeseries now have a two-step configuration process. In the first configure_timeseries_output_glob_expansion method, dymos replaces any wildcard timeseries additions with their matching ODE outputs.

In the second stage, configure_timeseries_output_introspeciton, dymos performs introspection to determine default units, shape, and tags of the requested timeseries outputs.

Internally, there's a change to the way "default" timeseries outputs are added (we call add_timeseries_output for states, controls, time, and parameters). This keeps the code for introspecting timeseries outputs more general and just requires each transcription to implement _get_timeseries_var_source. See the implementation in the various transcriptions if you're curious.

Added a new dymos-specific tag: dymos.static_output tells dymos that an output is not sized with num_nodes as its first dimension and therefore cannot be added to a timeseries or used as a boundary/path constraint. If a user wishes to constrain the quantity, they should apply OpenMDAO's add_constraint method to the relevant ODE path.

The docs made references to the notion of "tandem phases" but they weren't explained. An example has been added.

Related Issues

Timeseries rate outputs have been extended to SolveIVP so that the user can get approximated rates from simulate. Note: The equidistant time-spacing of simulate will make these interpolated rates appear to be noisier in some points than they actually are.

Timeseries rate outputs still are not implemented for ExplicitShooting.

Since timeseries outputs can be renamed and "special" variables are no longer treated differently, a user can now choose to add a timeseries output that renames a state. This can be helpful if two different phases use ODE's that employ different variable naming. A state can be renamed in the timeseries output to be whatever the user wishes.

The Commercial aircraft example was displaying automatically generated plots, but the path to those plots recently changed.

Backwards incompatibilities

  • The shape of parameter_val:{param_name} is now (1,) + shape. Adding the first axis makes it possible to more easily connect the parameter into a timeseries with a slicer, such as src_indices=om.slicer[gd.subset_num_nodes['all'], ...]

  • While generally used only internally, get_source_metadata was changed to return a single dictionary of keys rather than a tuple. This will allow us to change what metadata may be returned without changing the structure of the call.

New Dependencies

None

robfalck added 30 commits June 22, 2022 09:44
…gup with the integration comp in ExplicitShooting...it needs an add_timeseries_output_configure that in turn reallocates the storage arrays.
…utputs.

Colliding glob patterns will now result in a RuntimeError being raised during configure rather than a warning.
…lows for inputs to feed multiple outputs again.
…essarily not as accurate as the Pseudospectral one due to the equidistant time-spacing of nodes.

Added some checks of SolveIVP rate outputs to the min time climb tests.
Timeseries wildcard units are now handled correctly in the new system.
… order to more closely match the old warning. Removed some of the logic that checks for timeseries outputs not in the ODE in the RKIntegrationComp since it was being triggered by non-ode-outputs like states and controls.
…rror as a NameError instead of a RuntimeError.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -339,6 +350,26 @@ def configure_interleave_comp(self, phase):
f'interleave_comp.col_values:state_rates:{state_name}',
src_indices=col_src_idxs)

for timeseries_name, timeseries_options in phase._timeseries.items():

for ts_output_name, ts_output in phase._timeseries[timeseries_name]['outputs'].items():
Copy link
Member

Choose a reason for hiding this comment

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

phase._timeseries[timeseries_name] --> timeseries_options

output_options['units'] = output_meta['units']

if not_found:
sorted_list = ' '.join(sorted(not_found))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe comma separate this list?


for pattern in _patterns:
filtered.extend(fnmatch.filter(output_names, pattern))
filtered = list(set(filtered)) # de-dupe
Copy link
Member

Choose a reason for hiding this comment

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

No need to convert set to a list 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.

old habits die hard

for pattern in patterns:
filtered.update(fnmatch.filter(outputs, pattern))
output_names = list(outputs.keys())
filtered = []
Copy link
Member

Choose a reason for hiding this comment

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

Better to just make filtered a set to begin with and call update on it with results from fnmatch instead of creating a list first and then converting to a set.

@coveralls
Copy link

coveralls commented Aug 30, 2022

Coverage Status

Coverage decreased (-0.1%) to 94.893% when pulling 8189392 on robfalck:timeseries_revamp into 83f4098 on OpenMDAO:master.

Removed unnecessary _get_rate_source_path implelmentation for SolveIVP.
@robfalck robfalck merged commit a95b64b into OpenMDAO:master Aug 31, 2022
@robfalck robfalck removed the request for review from Kenneth-T-Moore August 31, 2022 20:40
@robfalck robfalck deleted the timeseries_revamp branch October 17, 2022 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants