
[Sponsors] 
the gradients calculated through discrete adjoint are near zero 

LinkBack  Thread Tools  Search this Thread  Display Modes 
January 25, 2018, 03:47 
the gradients calculated through discrete adjoint are near zero

#1 
New Member
WANG,Hao
Join Date: Sep 2016
Location: Xi'an China
Posts: 19
Rep Power: 5 
Hi everyone,
I am using the discrete adjoint solver of SU2 to evaluate the gradients of ONERA M6 wing under steady flow, but the resulting gradients are all near zero (ie.3E14). I have checked the convergence history of both the flow solver and the adjoint solver, the plot is shown in the file. I noticed that the sens_geo term is always zero through out the whole evaluation. Actually i have done a lot of successful discrete adjoint cases using SU2. And i have also got a reasonable gradient result for ONERA M6 wing but using a different grid file with this time. So i guess the gradient result is affected by the grid file. To make this question more clear, I have attached the cfg parameter file,the convergence history plot, the surface mesh plot and the gradients result. Any suggestions will be appreciated. PS: SU2 version is 5.0, the excute command is: discrete_adjoint.py n 20 f name.cfg 

January 25, 2018, 22:27 

#2  
New Member
WANG,Hao
Join Date: Sep 2016
Location: Xi'an China
Posts: 19
Rep Power: 5 
Quote:
i have found the reason, that is i have to set the parameter "SENS_REMOVE_SHARP" as "NO", otherwise the sens_geo term will always be zero. And here is the gradient results i have got. There is one thing to note that the "SENS_REMOVE_SHARP=YES" could be important to some adjoint cases, Only by setting as "YES" can you get reasonable gradient results. The details can be found in this paper:https://arc.aiaa.org/doi/pdf/10.2514/6.20151946 

February 24, 2018, 13:52 

#3 
Super Moderator
Francisco Palacios
Join Date: Jan 2013
Location: Long Beach, CA
Posts: 404
Rep Power: 11 
Thanks to your feedback we have worked on this problem in the new SU2 v6.0. If I were you I would take a look at the new tutorials page https://su2code.github.io/tutorials/home/
If you are a developer... do not forget to check the www.su2devsociety.org Best, Francisco 

February 27, 2018, 22:30 

#4  
New Member
WANG,Hao
Join Date: Sep 2016
Location: Xi'an China
Posts: 19
Rep Power: 5 
Quote:
Thanks for your invitation, i am glad to use the new SU2 V6.0 and contribute to SU2. Thanks 

October 15, 2019, 19:49 

#5 
New Member
cfdjetman
Join Date: Mar 2019
Posts: 19
Rep Power: 2 
I'm trying to compare the gradient from Discrete Adjoints to Finite differences using SU2v6.2 for a RAE2822 airfoil (2D) with a sharp trailing edge. I'm using the Spalart Allmaras turbulence model. The flow is transonic. I've used FFD to parameterize the airfoil. However, I cannot get my discrete adjoint values to match my finite difference values. The directions of the gradients match, however, the magnitudes differ significantly.
Both my flow and adjoint simulations have converged well. I've attach my CFD setting as well as the results from both the discrete adjoint as well as the finite differences. I had similar differences with Hicks Henne. When I set SENS_REMOVE_SHARP= YES, the gradient values are 0. Otherwise, they are as written in the attached results file. rae2822.txt grad_finite_diff.txt grad_dis_adjoint.txt Last edited by cfdjetman; October 17, 2019 at 12:09. 

October 17, 2019, 12:35 

#6 
Member
Pedro Gomes
Join Date: Dec 2017
Posts: 81
Rep Power: 4 
First suggestion is to try the develop version, some option names changed but they are fairly well documented.
Please attach all required files to replicate the problem and describe the process you followed to:  Compile the code (OS, MPI or serial build, etc.)  Run the primal and discrete adjoint case, for example is everything converging well? 

October 17, 2019, 14:49 

#7 
New Member
Clark
Join Date: Feb 2017
Posts: 2
Rep Power: 0 
When comparing the FD to the discrete adjoint, make sure that `OPT_RELAX_FACTOR = 1`. When SU2_DEF runs, it applies the `OPT_RELAX_FACTOR` to any changes in the design variables. So you only get the correct deformation if `OPT_RELAX_FACTOR=1`. The values stored in DV_VALUE aren't used directly. If OPT_RELAX_FACTOR is present in the cfg file (for finite_difference.py or for just plain SU2_DEF), then you end up with OPT_RELAX_FACTOR * DV_VALUE as your "step" size.
Since the step size is inaccurate, the gradients are consequently inaccurate, even if you're using the python "finite_difference.py" wrapper. Given that you have OPT_RELAX_FACTOR=1E3, I would expect your gradients are off by about a factor of 1E3. 

October 17, 2019, 20:05 

#8 
New Member
cfdjetman
Join Date: Mar 2019
Posts: 19
Rep Power: 2 
I'm not involved in the development of SU2. I'm just using SU2 V6.2 for my simulations.
I've installed this version of SU2 https://su2code.github.io/docs/ADBuild/. I've used the enable pywrapper option in order to use the python scripts. Yes, both my flow and adjoint simulations have converged very well. In order to run my simulations, I used the following command discrete_adjoint.py f rae2822_case2.cfg n 64 With OPT_RELAX_FACTOR=1, my gradient to scale by 1E3, but they still do not match. 

October 17, 2019, 22:44 

#9 
New Member
Clark
Join Date: Feb 2017
Posts: 2
Rep Power: 0 
> I'm not involved in the development of SU2. I'm just using SU2 V6.2 for my simulations.
Using the "develop" version doesn't mean you're actively involved in development. It's just the current "cutting edge" version. You can think of it like a beta version. There's bugs and problems, but it's usually improved over previous versions. Every new release starts as the develop branch. As for your gradients not matching, there's a lot of problems that could be occurring. I would suggest you look at this paper and this paper to learn more about the full problem. Without access to your full setup and extra free time, I can't figure out your problem for you. Here's some tips I can give: + Try a whole range of finite difference step sizes. Start with something as large as the wallnormal grid spacing. Go down in steps, such as 1/2 the size or 1/10 the size. Watch how the gradients change. Their accuracy will improve as step size goes down, then decrease in accuracy as the step sizes get too small. The correct step size to use is very problem dependent. For the RAE2822 case, the first paper I cited above used a step size of 1E5. + Make extra sure your flow solution and your discrete adjoint solution are converged. Try solving them to a slightly lower or slightly higher precision. Do the gradients change significantly? If so, then you aren't fully converged. 

October 17, 2019, 23:53 

#10 
New Member
cfdjetman
Join Date: Mar 2019
Posts: 19
Rep Power: 2 
Thanks for your input and reference papers you've provided me.
Here is what I've done for far. I've tried different step sizes from 1E2 to 1E6. Between 1E4 and 1E6 the finite difference values are nearly the same. I could try smaller step sizes. I've also converged my flow and adjoint simulations to an even higher precision, still no change in results. I also tried with a finer mesh and did not notice any change in results. I'll do through those papers you've provided me first and see if I'm missing something. I'll then install the develop version, if I do not find a problem with my case setup. 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Discrete vs Continuous Adjoint solution variable: Scaling/normalization issue?  asitav  SU2  2  November 21, 2018 20:11 
Shape optimization doesn't converge  Adjoint log file  JPBLourenco  SU2 Shape Design  0  December 11, 2017 09:41 
The discrete adjoint method uses too large memory.  Yminjo  SU2  1  April 27, 2016 11:52 
Discrete Adjoint Euler Computation  doan.nak  SU2  2  June 6, 2014 05:01 
dsmcFoam setup  hherbol  OpenFOAM PreProcessing  0  July 14, 2013 18:16 