CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

Extracting Jacobian Matrices from SU2

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By R.K
  • 1 Post By R.K

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2024, 13:37
Default Extracting Jacobian Matrices from SU2
  #1
R.K
New Member
 
Rutvik Khedkar
Join Date: Mar 2024
Posts: 8
Rep Power: 2
R.K is on a distinguished road
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
Tongtong1919 likes this.
R.K is offline   Reply With Quote

Old   July 18, 2024, 15:47
Default
  #2
New Member
 
Josh Kelly
Join Date: Dec 2018
Posts: 13
Rep Power: 7
joshkellyjak is on a distinguished road
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?
joshkellyjak is offline   Reply With Quote

Old   July 19, 2024, 09:22
Default
  #3
R.K
New Member
 
Rutvik Khedkar
Join Date: Mar 2024
Posts: 8
Rep Power: 2
R.K is on a distinguished road
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.
Tongtong1919 likes this.

Last edited by R.K; July 19, 2024 at 09:24. Reason: Clarity
R.K is offline   Reply With Quote

Old   July 19, 2024, 09:42
Default
  #4
New Member
 
Josh Kelly
Join Date: Dec 2018
Posts: 13
Rep Power: 7
joshkellyjak is on a distinguished road
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.
joshkellyjak is offline   Reply With Quote

Reply

Tags
adjoint variable, jacobian


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
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


All times are GMT -4. The time now is 20:30.