|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Rutvik Khedkar
Join Date: Mar 2024
Posts: 8
Rep Power: 2 ![]() |
Hi SU2 community,
I am trying to perform adjoint optimisation using SU2 as a black box for the simulations and python (JAX) for derivatives. I have already found the derivative of the objective function with respect to the flow field (∂J/∂U) using JAX's autodiff. To form the adjoint problem I need the derivatives of residual with respect to the flow field and design variables (∂R/∂U and ∂R/∂x). I was reading the source code and believe they are stored (at least ∂R/∂U, not sure about ∂R/∂x) in the CSysSolve_b.cpp and CSysMatrix.cpp codes. Is there a way to extract them? Thank you. RK |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Josh Kelly
Join Date: Dec 2018
Posts: 13
Rep Power: 7 ![]() |
I am not sure why you would use JAX to calculate the sensitivties when SU2 has adjoint capabilities already, which you would have to run to calculate dR/dx. If you have located where they are stored I think you would have to implement a method to extract them, is there a specific reason why you want to use JAX to assemble your gradients?
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
Rutvik Khedkar
Join Date: Mar 2024
Posts: 8
Rep Power: 2 ![]() |
I should have been clearer in my original post. My objective function is to reduce the momentum deficit in the boundary layer. To evaluate it I need to extract the boundary layer profiles over my geometry. Currently I am using the VTk library to extract them. I don't know if theres a way to extract them in SU2, I am open to suggestions if there is. While SU2 has adjoint capabilities, I am not sure how to write my custom objective function into the source code. There is a way of writing a custom objective function in the config file, but that works for variables calculated within the code (from what I understand). Since the input of my objective function are the boundary layer profiles, I dont think they can be incorporated or evaluated through the config file. As for using JAX, its auto-diff capabilities provide a greater flexibility in computing the gradient (of nearly any function).
For extracting the Jacobians, do I need to write a function in the source code of CSysMatrix.cpp? Additionally the Jacobian is calculated for each solver (eg in CAdjNSSolver.cpp). Do I need to change anything here? My knowledge in C++ is very limited. Last edited by R.K; July 19, 2024 at 09:24. Reason: Clarity |
|
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
Josh Kelly
Join Date: Dec 2018
Posts: 13
Rep Power: 7 ![]() |
By the sounds of it you will probably have to modify from the source code. I think your best bet is to join the developer meetings to ask your question in more detail - I think some figures would be beneficial to understand what you are trying to do. SU2 already contains AD tools and this is what is used to calculate the jacobians you want to extract. I think you would need to include your objective function in this calculation to solve your adjoint linear system for dR/dU.
|
|
![]() |
![]() |
![]() |
Tags |
adjoint variable, jacobian |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Extracting Jacobian | jyotir | SU2 | 0 | July 7, 2023 01:19 |
Introducing SU2 International Developers Society (IDS) | fpalacios | SU2 News & Announcements | 1 | June 17, 2019 22:38 |
SU2 crashed when "Initialize Jacobian structure" | falltime | SU2 | 2 | October 20, 2014 20:01 |
Jacobian Coefficient matrices for the viscous flux | Andy | Main CFD Forum | 8 | February 25, 2004 23:53 |
Jacobian Coefficient matrices for the viscous flux | Andy | Main CFD Forum | 0 | February 19, 2004 13:59 |