OpenMDAO / dymos

Open Source Optimization of Dynamic Multidisciplinary Systems
Apache License 2.0
195 stars 64 forks source link

Evaluate expressions alongside the user-defined ODE. #1057

Closed robfalck closed 2 months ago

robfalck commented 3 months ago

Proposed feature.

The notion of timeseries expressions is useful but adds excessive complication to timeseries components. This could be made significantly more simple by putting any expression evaluations in a component along side the user's ODE and promoting all inputs and outputs from both systems.

That is, where we have an ODE system now will be replaced by and ODE Group which will contain:

For now, and to continue current behavior, these expressions will be evaluated after the user defined ODE is evaluated.

Phase.add_expression(expr : str, **kwargs) will be added to provide a mechanism for adding these expressions, and will be used internally by dymos when expressions are detected in the timeseries outputs, constraints, or objective of a phase.

The main benefit of this approach is that, rather than adding all of the extra complexity to timeseries outputs to handle them, expressions are really just run-time additional outputs to the ODE.

Example

Aside from the new add_expression method in Phase, this change will be transparent to the user.

robfalck commented 2 months ago

Attempted to implement this issue, but with introspection as it currently exists, this results in circular references (parameters try to determine shape from the exec comp, which tries to determine shape from its source).

Closing for now.