OpenMDAO / dymos

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

Use Barycentric Lagrange Interpolation for controls in Simulation #1056

Closed robfalck closed 3 months ago

robfalck commented 3 months ago

Summary

Previously dymos had used Vandermonde interpolation for controls in ExplicitShooting, because matrices could be calculated apriori. However, the exponents on the terms in the Vandermonde matrix go up to N (the number of nodes of interpolation). When the number of nodes is large (greater than 20-30), this exceeds the floating point limitations and accuracy of the interpolation suffers.

Barycentric interpolation fixes this issue, though it is somewhat more expensive.

To improve performance, numba's just-in-time compilation is used to compute some derivatives (the control rates, derivatives of the rates). Numba is optional for this implementation, and it will work seemlessly (albeit more slowly) without it.

For pure simulation, users are unlikely to notice any performance difference at all until segments grow to ~50 nodes or so.

Related Issues

Backwards incompatibilities

None

New Dependencies

Numba jit is used to make a 4-nested for loop more performant. Numba is an optional dependency and

coveralls commented 3 months ago

Coverage Status

coverage: 92.549% (-0.5%) from 93.017% when pulling d64e95368fffb12f17d66616cad258b90f5d2a2e on robfalck:i1044 into 312161b737050eb525073cb086a0771f749a7d95 on OpenMDAO:master.