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

Get gradients using AD

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 8, 2019, 06:57
Default Get gradients using AD
  #1
New Member
 
Amir Bagheri
Join Date: Feb 2019
Location: Southampton, UK
Posts: 11
Rep Power: 7
Amirkb is on a distinguished road
Hi all,


I am trying to use the AD module in the discrete adjoint solver to calculate the sensitivity of the lift coefficient with respect to the closure coefficients of the SA turbulence model.


I've created new variable names in the CConfig class for the SA closure coefficients and have modified the code so that it reads the values for the coefficients from the config file, instead of the given hard coded values. (I would need to change the values later on).


Now I'm trying to get the sensitivity of my objective function (in this case Cl as specified in the config file) with respect to these closure coefficients.


I've modified the CDiscAdjSolver class in solver_structure.hpp and solver_structure.inl by adding new variables for the sensitivities I want to calculate, defining inline Get functions which return the sensitivity values, and defining virtual functions onto the CSolver class.


I've modified solver_adjoint_discrete.cpp by adding new variables which read in the values of the closure coefficients from the config class and passing these variables onto AD::RegisterInput() (these are done in the RegisterVariables routine), and then passing them onto SU2_TYPE::GetDerivative() to calculate the derivatives (this is done in the ExtractAdjoint_Variables routine). I store the derivative values as new variables called Total_Sens_SA, similar to what's already done for Total_Sens_AoA, for example.


The problem I have is that when I pass the variables onto SU2_TYPE::GetDerivative(), the output is returned as 0. As far as I see, I've followed the same steps that are done to get the other sensitivity values such as Total_Sens_AoA or Total_Sens_Mach, but I don't understand why the derivative is being returned as 0. Is there something I'm missing here? I assumed as long as I register the variables whose derivatives I want onto AD::RegisterInput() the rest should be taken care of inside the AD and codi modules and the derivatives should be calculated correctly?


Curiously, in output_structure.cpp where values such as Total_Sens_AoA are called again to be printed to screen, these values differ from those calculated inside solver_adjoint_discrete.cpp. This to me suggests that the sensitivity values are altered elsewhere, but I cannot seem to find where this occurs.


Any help would be appreciated.


Kind regards,
Amir
Amirkb is offline   Reply With Quote

Old   May 16, 2019, 05:32
Default
  #2
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 13
pcg is on a distinguished road
This question is being handled in https://github.com/su2code/SU2/issues/679
pcg is offline   Reply With Quote

Old   June 11, 2019, 12:17
Default
  #3
New Member
 
Amir Bagheri
Join Date: Feb 2019
Location: Southampton, UK
Posts: 11
Rep Power: 7
Amirkb is on a distinguished road
Question solved, see link above.
Amirkb is offline   Reply With Quote

Reply


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
Gradients at boundary for NSCBC fportela OpenFOAM Programming & Development 6 July 1, 2021 05:21
QuickStart gradients at low Mach numbers Ry10 SU2 0 May 11, 2016 16:09
Velocity Gradients or Pressure Gradients? owayz OpenFOAM 9 August 14, 2012 13:09
Large pressure gradients = anisotropy??? cfd_enthusiast Main CFD Forum 0 February 9, 2010 11:09
density gradients in CFX post prabhu CFX 1 June 12, 2006 06:47


All times are GMT -4. The time now is 21:49.