mdolab / openconcept

OpenConcept: A toolkit for conceptual MDAO of aircraft with unconventional propulsion architectures
MIT License
36 stars 32 forks source link

Sparse partials for ExecComps #63

Closed kanekosh closed 8 months ago

kanekosh commented 8 months ago

Purpose

I added has_diag_partials=True for the ExecComps with vector inputs and outputs. This tells OpenMDAO that those components have sparse diagonal partials. This should (slightly) reduce the runtime by eliminating the OM's automatic Jacobian coloring computations.

Type of change

Testing

Checklist

Put an x in the boxes that apply.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (6fc0a1c) 79.95% compared to head (d4e2a58) 79.95%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #63 +/- ## ======================================= Coverage 79.95% 79.95% ======================================= Files 85 85 Lines 9300 9300 ======================================= Hits 7436 7436 Misses 1864 1864 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

eytanadler commented 8 months ago

When has_diag_partials is set to True, does OpenMDAO perturb all elements in a given vectorized input simultaneously when computing the complex step derivatives? Many of these components can be replaced with OpenConcept's ElementMultiplyDivideComp, which might be even better. You have a better sense than I do of the times for coloring vs. actually computing derivatives.

kanekosh commented 8 months ago

When has_diag_partials is set to True, does OpenMDAO perturb all elements in a given vectorized input simultaneously when computing the complex step derivatives?

Yes, that's what OM does (reference). ElementMultiplyDivideComp would be slightly better but I guess the speedup is minimal because that's just one additional compute evaluation with complex numbers in ExecComp.