|
[Sponsors] |
July 28, 2016, 22:50 |
Help with Discrete adjoint in SU2
|
#1 |
New Member
Anand Pratap Singh
Join Date: Jul 2014
Posts: 1
Rep Power: 0 |
Hi,
I have some issues trying to use discrete adjoint on SU2. It will be really helpful if you could provide me some pointers. My problem setup is as follows: I am using the setup of discadj_naca0012 at AoA = 10 degree with NO change in configuration file (except for changing direct to discrete_adoint). My design variable (beta) is a field of size = number of grid points, I multiply these to the corresponding SA production in CSourcePieceWise_TurbSA::ComputeResidual. Therefore dRdbeta = Production and hence dobjective_dbeta = psi_sa*Production (assuming no explicit dependence of objective on beta). I write out the production from CSourcePieceWise_TurbSA::ComputeResidual function. Using this, I get the following solution: dCd_finite diff: -0.01165 dCd_adjoint @ beta_{all} = 1 + 1e-2 (perturb all beta) -0.000184900879096 dCd_adjoint @ beta__{all} = 1 - 1e-2 -0.000181856832584 avg dCd_adjoint -0.00018337885584 I am printing sum_i {dobjective_dbeta_i} or total derivative. Apart from trivial errors, which I have checked multiple times, I could think of following reasons for this discrepancy: 1. Since the error is so large I thought whether I am missing some internal normalization of the production term. I tried bunch of scaling without any luck. Essentially the dimensions of Production should be consistent with psi_sa in restart file. Do you think this can be an issue? 2. The AD part in the function CSourcePieceWise_TurbSA::ComputeResidual is commented out, is it correct? To verify I calculated dCd_dmach for the same case, which are as follows: dCd_fd: - 0.07515 dCd_adjoint @ .15 + 0.01 -0.098246 dCd_adjoint @ .15 - 0.01 -0.12189 avg dCd_adjoint -0.110068 This at least seem reasonable, however in this case the sensitivity is weakly dependent on turbulence model so its effect might not show up. I would greatly appreciate if you could provide some pointers on these issues. The only two changes I made was to read beta field from a file and multiply to the SA production and write out production to a file. commit history: https://github.com/anandpratap/SU2/c...756a2abf649f4e Thanks, |
|
July 29, 2016, 05:57 |
|
#2 |
Super Moderator
Tim Albring
Join Date: Sep 2015
Posts: 195
Rep Power: 11 |
Hi Anand,
Please note that when you want to add new design variables you have to declare them as input inside of the discrete adjoint solver so that you can extract the derivatives later. The best place is in CDiscAdjSolver::RegisterVariables using the AD::RegisterInput function. For example like this: Code:
// We only want to do it for the turbulent solver if (KindDirect_Solver == RUNTIME_TURB_SYS)){ for (iPoint = 0; iPoint < nPoint; iPoint++){ Beta = direct_solver->node[iPoint]->GetBeta(); // Declare it as input of the iteration AD::RegisterInput(Beta); direct_solver->node[iPoint]->SetBeta(Beta); } }| Code:
// We only want to do it for the turbulent solver if (KindDirect_Solver == RUNTIME_TURB_SYS)){ for (iPoint = 0; iPoint < nPoint; iPoint++){ Beta_Sens[iPoint] = AD::GetDerivative(direct_solver->node[iPoint]->GetBeta()); } }| If you want to add your own obj. function have a look at CDiscAdjSolver::RegisterObj_Func(). If you have further questions, let me know. Tim |
|
May 9, 2019, 07:56 |
|
#3 |
New Member
Amir Bagheri
Join Date: Feb 2019
Location: Southampton, UK
Posts: 11
Rep Power: 7 |
Hi Anand,
I wonder if you managed to get AD to give you the derivatives for the new design variables? I am facing a similar problem. I want the gradient of an objective function with respect to the SA closure coefficients. I have modified the code so that the SA coefficients are read from the config file as opposed to them being hardcoded, so I can call them from the CConfig class. Now I use AD::RegisterInput inside CDiscAdjSolver::RegisterVariables, to register the closure coefficients, then I use SU2_TYPE::GetDerivative inside CDiscAdjSolver::ExtractAdjoint_Variables to get the gradients. However for some reason the gradient for the closure coefficients is always returned as 0. Have you had something similar with your case? I have a feeling I am missing an intermediary step between registering the variables and getting the gradients. Any help would be appreciated. Thanks, Amir |
|
Tags |
adjoint solver |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
wrong SU2 calculation for lift and drag coefficient for NAC4421 | mechy | SU2 | 7 | January 9, 2017 06:18 |
The discrete adjoint method uses too large memory. | Yminjo | SU2 | 1 | April 27, 2016 11:52 |
hard to convergent with SU2 4.0 for Euler adjoint | Xianguu | SU2 | 1 | July 14, 2015 18:09 |
Discrete Adjoint Euler Computation | doan.nak | SU2 | 2 | June 6, 2014 05:01 |
best setting for SU2 | mechy | SU2 | 3 | April 20, 2014 20:13 |