Aero-Structural Discrete Adjoint Sensitivities and Python Wrapper Developments #1750
Aero-Structural Discrete Adjoint Sensitivities and Python Wrapper Developments #1750
Conversation
Co-authored-by: Nijso <bigfootedrockmidget@hotmail.com>
Co-authored-by: Nijso <bigfootedrockmidget@hotmail.com>
|
If you can add a test in parallel_regression_ad.py and add some kind of tutorial testcase, then it looks good to go for me. Maybe @pcarruscag can chime in and give additional code suggestions |
|
Hi @patelha57 what is the current status? Would be nice to see a couple of older PR's get merged into develop, especially this one. |
No additional code development needed from my POV (please correct me if I'm wrong!). Just need to fix these regression tests failures, add example for the residual solver adjoint, and add documentation. |
| /*! | ||
| * \brief Get total sensitivity of the objective function w.r.t. surface coordinates or displacements at mesh | ||
| * vertices. \return Total sensitivity of the objective function w.r.t. the un-deformed coordinates. | ||
| */ | ||
| vector<vector<passivedouble>> GetObjectiveCoordinatesTotalSensitivities() const; | ||
|
|
||
| /*! | ||
| * \brief Get total sensitivity of the objective function w.r.t. surface coordinates or displacements at a mesh | ||
| * vertex. \param[in] iPoint - Mesh vertex index. \return Total sensitivity of the objective function w.r.t. the | ||
| * un-deformed coordinates. | ||
| */ | ||
| vector<passivedouble> GetObjectiveCoordinatesTotalSensitivities(unsigned long iPoint) const; | ||
|
|
||
| /*! | ||
| * \brief Get total sensitivity of the objective function w.r.t. surface coordinates or displacements at marker | ||
| * vertices. \param[in] iMarker - Marker identifier. \return Total sensitivity of the objective function w.r.t. the | ||
| * surface coordinates. | ||
| */ | ||
| vector<vector<passivedouble>> GetMarkerObjectiveCoordinatesTotalSensitivities(unsigned short iMarker) const; | ||
|
|
||
| /*! | ||
| * \brief Get total sensitivity of the objective function w.r.t. surface coordinates or displacements at a marker | ||
| * vertex. \param[in] iMarker - Marker identifier. \param[in] iVertex - Marker vertex index. \return Total sensitivity | ||
| * of the objective function w.r.t. the surface coordinates. | ||
| */ | ||
| vector<passivedouble> GetMarkerObjectiveCoordinatesTotalSensitivities(unsigned short iMarker, | ||
| unsigned long iVertex) const; | ||
|
|
||
| /*! | ||
| * \brief Get total sensitivity of the objective function w.r.t. the design variables. | ||
| * \return Total sensitivity of the objective function w.r.t. the design variables. | ||
| */ | ||
| vector<vector<passivedouble>> GetObjectiveDesignVariablesTotalSensitivities() const; | ||
|
|
||
| /*! | ||
| * \brief Get total sensitivity of the objective function w.r.t. a design variable. | ||
| * \param[in] iDV - Design Variable index. | ||
| * \return Total sensitivity of the objective function w.r.t. a design variable. | ||
| */ | ||
| vector<passivedouble> GetObjectiveDesignVariablesTotalSensitivities(unsigned short iDV) const; |
There was a problem hiding this comment.
This interface is not adequate, there is a better alternative as I've explained before.
There was a problem hiding this comment.
You are talking about the matrix view implementation, correct?
There was a problem hiding this comment.
Yep, there is a recent example of doing that for another type of container here https://github.com/su2code/SU2/pull/2388/changes
| import sys | ||
| import pysu2ad | ||
| from optparse import OptionParser | ||
| import numpy as np |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix an unused-import issue, you remove the import statement for the symbol that is never referenced. This eliminates an unnecessary dependency and clarifies which modules are actually required.
Here, the best fix is to delete the line import numpy as np in TestCases/py_wrapper/disc_adj_residual_solver/run_adjoint.py (line 4). No other code in this file refers to np, so no additional changes are needed. This preserves all existing functionality while cleaning up the import list.
| @@ -1,7 +1,6 @@ | ||
| import sys | ||
| import pysu2ad | ||
| from optparse import OptionParser | ||
| import numpy as np | ||
|
|
||
|
|
||
| def main(): |
Motivation
Fundamental bottlenecks exist for industrial adoption of high-fidelity physics codes with fully coupled discrete adjoint sensitivity analysis. These bottlenecks include a lack of flexibility, modularity, and robustness of the computational tools, as well as the potential startup development costs needed to implement and verify the MDAO features. The purpose of this work is to facilitate the coupling of SU2 with external structural codes (e.g. NASTRAN, TACS, Airbus structural suite Lagrange) for gradient-based aerodynamic shape and structural sizing optimization using dedicated frameworks (e.g. OpenMDAO).
Startup development costs include the creation of modular tools that are designed to be driven by another framework like OpenMDAO, rather than to drive execution themselves. However, leveraging those MDAO frameworks assumes that software codes and modules to be coupled exist, have appropriate data structures, execution and query APIs, and are wrapped in Python for flexibility and ease of use. The proposed changes were motivated with the goal of making SU2 more modular and flexible, particularly to facilitate its integration into large-scale MDAO frameworks. For more details on the motivation, methodology, and verification & validation results, please refer to our paper from AIAA Aviation 2022.
Proposed Changes
@aa-g and I propose the following code updates:
Implementation of residual-based discrete adjoint solver as
CDiscAdjResidualSolvera. New config option:
KIND_DISC_ADJEnhancements and standardization of SU2 Python API
a. Add pysu2/pysu2ad methods
b. Standardize Python API and function names
c. Overloaded getter/setter methods to make data handling more flexible
Related Work
These efforts are related to Issue #1262, Pull Request #1300, and Discussion #1325.
PR Checklist