-
Notifications
You must be signed in to change notification settings - Fork 902
Aero-Structural Discrete Adjoint Sensitivities and Python Wrapper Developments #1750
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
base: develop
Are you sure you want to change the base?
Conversation
|
Hi, are there any updates on this feature? Or maybe some simple example? |
|
dr. @patelha57 what is the status of this PR? Do you still have time to finalize it? Would be nice to have it, there's a lot of work that you've put into it. |
Hi, Nijso! You're absolutely right and that's my bad for slacking. The PR requires some finishing touches (mainly adoption of CPyWrapperMatrixView for some methods) and bug fixes until the regression tests are passing. I will find time to finalize it over the holidays |
| ///////////////////////////////////////////////////////////////////////////// | ||
| /* Functions related to farfield flow variables. */ | ||
| ///////////////////////////////////////////////////////////////////////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change these to the more common /*--- comment ---*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean just something like this instead? Removing all the ///// from top and bottom as well?
/*--- Functions related to farfield flow variables. ---*/
|
@patelha57 do you want to remove the [WIP] from the title to indicate it is ready? |
Co-authored-by: Nijso <[email protected]>
Co-authored-by: Nijso <[email protected]>
Co-authored-by: Nijso <[email protected]>
|
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 |
| @@ -0,0 +1,16 @@ | |||
| import pysu2ad | |||
| import numpy as np | |||
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, we should remove the unused numpy import from the code. This will clean up the code and eliminate the unnecessary dependency. The change should be made directly in the file TestCases/py_wrapper/disc_adj_residual_solver/run_adjoint.py by deleting the line import numpy as np.
-
Copy modified line R4
| @@ -1,5 +1,5 @@ | ||
| import pysu2ad | ||
| import numpy as np | ||
|
|
||
| try: | ||
|
|
||
| from mpi4py import MPI |
| from mpi4py import MPI | ||
| except ImportError: | ||
| comm = None | ||
| rank = 0 |
Check notice
Code scanning / CodeQL
Unused global variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, we can rename the variable rank to _unused_rank to indicate that it is intentionally unused. This approach preserves the assignment in case it is needed for future use or documentation purposes, while also adhering to conventions for unused variables. Alternatively, if the variable is not needed at all, we can remove the assignment entirely.
Since the assignment of rank does not have any side effects, the best fix is to remove the assignment altogether.
-
Copy modified line R8 -
Copy modified line R11
| @@ -7,6 +7,6 @@ | ||
| comm = None | ||
| rank = 0 | ||
|
|
||
| else: | ||
| comm = MPI.COMM_WORLD | ||
| rank = MPI.COMM_WORLD.Get_rank() | ||
|
|
||
|
|
| rank = 0 | ||
| else: | ||
| comm = MPI.COMM_WORLD | ||
| rank = MPI.COMM_WORLD.Get_rank() |
Check notice
Code scanning / CodeQL
Unused global variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, we need to address the unused rank variable. Since it is not used anywhere in the provided code snippet and does not have side effects, the best approach is to remove the assignment entirely. This involves deleting the line where rank is assigned a value (line 11) and ensuring that the code remains functional without it.
-
Copy modified line R11
| @@ -10,3 +10,3 @@ | ||
| comm = MPI.COMM_WORLD | ||
| rank = MPI.COMM_WORLD.Get_rank() | ||
|
|
||
|
|
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