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

the gradients calculated through discrete adjoint are near zero

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By clarkpede

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2018, 03:47
Exclamation 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: 10
Haowang is on a distinguished road
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.3E-14). 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
Attached Images
File Type: jpeg surface mesh_FFD.jpeg (153.8 KB, 40 views)
File Type: jpeg convergence_history_flow solver.jpeg (30.9 KB, 64 views)
File Type: jpeg convergence_history_adjoint solver.jpeg (38.1 KB, 64 views)
Attached Files
File Type: txt turb_ONERAM6.txt (14.7 KB, 33 views)
File Type: txt of_grad_cd.txt (1.5 KB, 20 views)
Haowang is offline   Reply With Quote

Old   January 25, 2018, 22:27
Talking
  #2
New Member
 
WANG,Hao
Join Date: Sep 2016
Location: Xi'an China
Posts: 19
Rep Power: 10
Haowang is on a distinguished road
Quote:
Originally Posted by Haowang View Post
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.3E-14). 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
Hey everybody,
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.2015-1946
Attached Images
File Type: jpeg gradients.jpeg (38.7 KB, 61 views)
Haowang is offline   Reply With Quote

Old   February 24, 2018, 13:52
Default
  #3
Super Moderator
 
Francisco Palacios
Join Date: Jan 2013
Location: Long Beach, CA
Posts: 404
Rep Power: 15
fpalacios is on a distinguished road
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
fpalacios is offline   Reply With Quote

Old   February 27, 2018, 22:30
Default
  #4
New Member
 
WANG,Hao
Join Date: Sep 2016
Location: Xi'an China
Posts: 19
Rep Power: 10
Haowang is on a distinguished road
Quote:
Originally Posted by fpalacios View Post
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
Dear Francisco
Thanks for your invitation, i am glad to use the new SU2 V6.0 and contribute to SU2.
Thanks
Haowang is offline   Reply With Quote

Old   October 15, 2019, 19:49
Default
  #5
New Member
 
cfdjetman
Join Date: Mar 2019
Posts: 25
Rep Power: 7
cfdjetman is on a distinguished road
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.
cfdjetman is offline   Reply With Quote

Old   October 17, 2019, 12:35
Default
  #6
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 14
pcg is on a distinguished road
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?
pcg is offline   Reply With Quote

Old   October 17, 2019, 14:49
Default
  #7
New Member
 
Clark
Join Date: Feb 2017
Posts: 2
Rep Power: 0
clarkpede is on a distinguished road
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.
clarkpede is offline   Reply With Quote

Old   October 17, 2019, 20:05
Default
  #8
New Member
 
cfdjetman
Join Date: Mar 2019
Posts: 25
Rep Power: 7
cfdjetman is on a distinguished road
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/AD-Build/. I've used the enable py-wrapper 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.
cfdjetman is offline   Reply With Quote

Old   October 17, 2019, 22:44
Default
  #9
New Member
 
Clark
Join Date: Feb 2017
Posts: 2
Rep Power: 0
clarkpede is on a distinguished road
> 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 wall-normal 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 1E-5.

+ 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.
bornax likes this.
clarkpede is offline   Reply With Quote

Old   October 17, 2019, 23:53
Default
  #10
New Member
 
cfdjetman
Join Date: Mar 2019
Posts: 25
Rep Power: 7
cfdjetman is on a distinguished road
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 1E-2 to 1E-6. Between 1E-4 and 1E-6 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.
cfdjetman 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
dsmcFoam setup hherbol OpenFOAM Pre-Processing 1 November 19, 2021 02:52
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


All times are GMT -4. The time now is 07:28.