CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   SU2 (https://www.cfd-online.com/Forums/su2/)
-   -   The adjoint equation in the discrete adjoint solver (https://www.cfd-online.com/Forums/su2/237405-adjoint-equation-discrete-adjoint-solver.html)

Zhen ZHANG July 16, 2021 04:47

The adjoint equation in the discrete adjoint solver
 
Hi all,
I recently studied the discrete adjoint solver because I want to add some space varying design variables. I also learned the CoDi package. Here are my
understanding and questions.
Assuming f is the objective function, g is the control equation, p is the design variable, and x is the flow variable.
In an adjoint problem, we want to get df/dp. Let f_p be the partial derivative (f_p=partial f/partial p). We get

df/dp=f_p+lambda^T*g_p

where lambda is the adjoint variable and satisfies

(g_x)^T*lambda=-(f_x)^T

But in the solver, after starting recording, we register the solution and variables as the input, set dependencies, direct run, register the solution and the objective function as the output, and stop recording.

Q1: why do we need to register the solution of the direct solver as the output? Now they are both input and output.

And then in CDiscAdjSinglezoneDriver::Run(), we initialize the adjoint of the direct solver using the adjoint solver solution of the last step, set the derivative of the objective function as 1.0, compute the adjoint, extract derivatives of the solution and variables.

Q2: What are the derivatives of the solution and variables here? In the reverse mode and with the obj func derivative set to 1.0, they should be partial f/partial(). Is that right?

Q3: What does this iteration do? How does it solve the above adjoint equation?

Maybe there are some mistakes in the statement due to my limited understanding. I am grateful if you point them out.
Thank you!

Zhen ZHANG July 16, 2021 05:24

Add a question:

What is the calculated derivative of the direct solver's solution, i.e. the solution of the discrete adjoint solver?
Why does it differ from what we set to it in the function iteration->InitializeAdjoint() of CDiscAdjSinglezoneDriver::Run()?

pcg July 16, 2021 06:04

Your description is based on g being a residual function, i.e. that converges to zero.
However, in SU2 g is a fixed-point iterator for the solution variables (hence both input and output).
The entire process was very well explained just 2 days ago here
https://su2foundation.org/su2conference2021/
https://drive.google.com/file/d/18Kq...deB4pzfqR/view
There will be a recording of Tobias' presentation at some point.
See also the initial implementation paper https://bibbase.org/network/publicat...thodinsu2-2016

Zhen ZHANG July 16, 2021 07:59

Thank you! I will read these materials.


All times are GMT -4. The time now is 05:50.